<?php
use home\assets\MainAsset;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use common\widgets\DatePicker;
use home\modules\reimbursement\models\Reimbursement;
use home\modules\reimbursement\models\Category;

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

$attrLabels = $model->attributeLabels();
?>

<?php $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="70"><?= $model->getAttributeLabel('name') ?>：</td>
			<?= $form->field($model, 'name', ['options' => ['width' => '32%']])->textInput(['class' => 'form-control']) ?>
			<td width="30">
				<?php if(!$model->showLink) { ?>
					&nbsp;&nbsp;
		            <label style="font-weight:lighter;">
		              	<input type="checkbox" class="check-box select-link" >&nbsp;关联
		          	</label>
	          	<?php } ?>
	          	<span class="redstar">*</span>
          	</td>

			<td align="right" class="link_name" <?= ($model->showLink) ? '' : "style='display: none;'" ?>>关联： </td>
			<td class="link_name" <?= ($model->showLink) ? '' : "style='display: none;'" ?>>
				<select class="form-control link-select" name="Reimbursement[link_type]" style="width:35%; display: inline" <?= ($model->isSelect) ? '' : "disabled" ?>>
					<?php foreach(common\models\Common::getLinkTypes($linkArr) as $type) : ?>
						<option value="<?= $type['type'] ?>" <?= $model->link_type == $type['type'] ? 'selected="selected"' : '' ?> data-class="<?= $type['class'] ?>" data-url="<?= Url::to($type['url']) ?>" data-title="选择<?= $type['name'] ?>" ><?= $type['name'] ?></option>
					<?php endforeach; ?>
				</select>

				<input type="text" class="form-control" id="reimbursement-link_name" name="Reimbursement[link_name]" value="<?= $model->link_name ?>" data-hidden-id="link-id" data-switch="0" style="width: 62%; display: inline" placeholder='单击选择' <?= ($model->isSelect) ? '' : "disabled" ?>/>

				<?= ($model->isSelect)?'':Html::hiddenInput('Reimbursement[link_type]', $model->link_type); ?>
				<?= $form->field($model, 'link_id', ['options' => ['tag'=>'div']])->hiddenInput(['id' => 'link-id']) ?>
			</td>
			<td class="link_name" <?= ($model->showLink) ? '' : "style='display: none;'" ?>><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('reim_people') ?>：</td>
			<?= $form->field($model, 'reim_people')->textInput(['class' => 'form-control', 'readonly' => true]) ?>
			<td><span class="redstar">*</span></td>

			<td align="right" width="70"><?= $model->getAttributeLabel('reim_time') ?>：</td>
			<?= DatePicker::widget(['model' => $model, 'form' => $form, 'attribute' => 'reim_time', 'inputConfig' => ['class' => 'form-control reim_time', 'readonly' => true], 'dateConfig' => ['maxDate' => '%y-%M-%d']]) ?>
			
			<td><span class="redstar">*</span></td>
		</tr>
		<tr <?= ($model->isNewRecord) ? '' : "style='display: none;'" ?>>
			<td align="right"><?= $model->getAttributeLabel('verify_ids') ?>：</td>
			
			<?php if (Yii::$app->cache->get('reimbursement_config')['reimbursement_verify_select']) : ?>
			<?= $form->field($model, 'verify_names', ['options' => ['colspan' => '4']])->textInput(['class' => 'form-control select-multi-user', 'data-hidden-id' => 'verify-ids', 'data-url' => Url::to(['/link/multi-user', 'type_module' => 'reim']), 'data-title' => '选择审核人', 'readonly' => true]) ?>
			<?php else : ?>
			<?= $form->field($model, 'verify_names', ['options' => ['colspan' => '4']])->textInput(['class' => 'form-control', 'readonly' => true]) ?>
			<?php endif; ?>
			
			<?= $form->field($model, 'verify_ids', ['options' => ['tag'=>'div']])->hiddenInput(['id' => 'verify-ids']) ?>
			<td><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('bill_amount') ?>：</td>
			<?= $form->field($model, 'bill_amount')->textInput(['class' => 'form-control']) ?>
			<td><span class="redstar">*</span></td>

			<td align="right"><?= $model->getAttributeLabel('category_id') ?>：</td>
			<td><select class="form-control" name="Reimbursement[category_id]">
                    <?php echo Category::getDropDownTree($model->category_id, 0, true, 'cat_id'); ?>
                </select>
                <div class="error"></div>
            </td>
			<td><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('reim_money') ?>：</td>
			<?= $form->field($model, 'reim_money')->textInput(['class' => 'form-control reim_money']) ?>
			<td><span class="redstar">*</span></td>

			<td align="right" class="reim_appli" <?= ($model->showAppli) ? '' : "style='display: none;'" ?>>申请单： </td>
			<td class="reim_appli" <?= ($model->showAppli) ? '' : "style='display: none;'" ?>>
				<input type="input" id="appli_name" class="form-control select-application" name="Reimbursement[appli_name]" value="<?= $model->appli_name ?>" data-title='选择申请单' data-url='<?= Url::to(['/link/application']) ?>', data-hidden-id="appli-id" placeholder='单击选择'/>
				<?= $form->field($model, 'appli_id', ['options' => ['tag'=>'div']])->hiddenInput(['id' => 'appli-id']) ?>
			</td>
			<td class="reim_appli" width="30px;" <?= ($model->showAppli) ? '' : "style='display: none;'" ?>>
				<span class="c6"><a href="javascript:;" class="clear-input" data-input-id="appli_name" data-hidden-id="appli-id" style="color:#888;">清空</a></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->reim_id); ?>
<?php ActiveForm::end(); ?>
