<?php
use home\assets\MainAsset;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use home\modules\receivable\models\Receivable;
use home\modules\receivable\models\Account;
use home\modules\receivable\models\Bank;
use home\models\PaymentMethod;
use common\widgets\DatePicker;

/* @var $this \yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \home\modules\receivable\models\receivable */

$attrLabels = $model->attributeLabels();

$form = ActiveForm::begin([
        'id' => 'main-form',
		'options' => ['class' => 'informationform f14'],
        'action' => $action,
		'fieldConfig' => [
			'options' => ['tag' => 'td'],
			'template' => "{input}{hint}{error}",
			'errorOptions' => ["class" => "error" ]
		]
    ]); 
?>

<table cellpadding="0" cellspacing="10" width="100%">
	<tbody>
		<tr>
			<td align="right" width="15%"><?= $model->getAttributeLabel('contract_no') ?>：</td>
			<input type="hidden" name="Receivable[contract_no]" id="contract-id" value="<?= $model->contract_no ?>"/>
            <?php if(!empty($model->isNewRecord) && !empty($model->contract_no)) : ?>
                <?= $form
                    ->field($model, 'contract_name')
                    ->textInput([
                        'class' => 'form-control',
                        'readonly' => 'readonly'
                    ])
                ?>
            <?php else : ?>
                <?= $form
                    ->field($model, 'contract_name')
                    ->textInput([
                        'class' => 'form-control select-contract',
                        'placeholder' => '点击选择',
                        'data-hidden-id' => 'contract-id',
                        'data-url' => Url::to(['/link/contract']),
                        'data-title' => '选择合同',
                        'data-callback' => 'linkSelectCallback'
                    ])
                ?>
            <?php endif; ?>
			
			<td><span class="redstar" width="5%">*</span></td>
            <td align="right"><?= $model->getAttributeLabel('customer_name') ?>：</td>
			<?= $form->field($model, 'customer_name')->textInput(['class' => 'form-control customer_name', 'disabled'=>'true', 'width' => '30%']) ?>
			<td><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('rece_no') ?>：</td>
			<?= $form->field($model, 'rece_no')->textInput(['class' => 'form-control', 'readonly' => ($model->isNewRecord) ? false : true]) ?>
			<td><span class="redstar">*</span></td>
			<td align="right"><?= $model->getAttributeLabel('rece_money') ?>：</td>
			<?= $form->field($model, 'rece_money')->textInput(['class' => 'form-control']) ?>
			<td><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('rece_bank') ?>：</td>
			<?= $form->field($model, 'rece_bank')->textInput(['class' => 'form-control']) ?>
			<td><span class="redstar"></span></td>
			<td align="right"><?= $model->getAttributeLabel('rece_account') ?>：</td>
			<?= $form->field($model, 'rece_account')->textInput(['class' => 'form-control']) ?>
			<td><span class="redstar"></span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('receiving_bank') ?>：</td>
			<?= $form->field($model, 'receiving_bank')->dropDownList(Bank::getBankList(), ['class' => 'form-control select_bank']) ?>
			<td><span class="redstar"></span></td>
			<td align="right"><?= $model->getAttributeLabel('receiving_account') ?>：</td>
			<td><select class="form-control select_account" id="receivable-receiving_account" name="Receivable[receiving_account]"></select></td>
			<td><span class="redstar"></span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('method_id') ?>：</td>
            <?= $form->field($model, 'method_id')->dropDownList(PaymentMethod::getMethodList(), ['class' => 'form-control']) ?>
			<td></td>
			<td align="right"><?= $model->getAttributeLabel('to_date') ?>：</td>
			<?= DatePicker::widget(['model' => $model, 'form' => $form, 'attribute' => 'to_date', 'inputConfig' => ['class' => 'form-control'], 'dateConfig' => ['maxDate' => '%y-%M-%d']]) ?>
			<td><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('remark') ?>：</td>
			<?= $form->field($model, 'remark', ['options' => ['colspan' => '4']])->textarea(['class' => 'form-control', 'rows' => '5']) ?>
			<td><span class="redstar"></span></td> 
		</tr>
	</tbody>
</table>
<?= ($model->isNewRecord)?'':Html::hiddenInput('id' ,$model->rece_id); ?>
<?php ActiveForm::end(); ?>
