<?php
use home\assets\MainAsset;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use home\modules\reimbursement\models\Application;
use home\modules\reimbursement\models\ApplicationCategory;

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

$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="70"><?= $model->getAttributeLabel('name') ?>：</td>
			<?= $form->field($model, 'name', ['options' => ['width' => '32%']])->textInput(['class' => 'form-control']) ?>
			<td><span class="redstar">*</span></td>
			
			<td align="right" class="link_name" width="70">关联： </td>
			<td class="link_name">
				<select class="form-control link-select" name="Application[link_type]" style="width:35%; display: inline">
					<?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="application-link_name" name="Application[link_name]" value="<?= $model->link_name ?>" data-hidden-id="link-id" data-switch="0" style="width: 62%; display: inline" placeholder='单击选择'/>
				
				<?= $form->field($model, 'link_id', ['options' => ['tag'=>'div']])->hiddenInput(['id' => 'link-id']) ?>
			</td>
			<td><span class="redstar">*</span></td>
		</tr>
		<tr>
			<td align="right"><?= $model->getAttributeLabel('verify_ids') ?>：</td>

			<?php if (Yii::$app->cache->get('application_config')['application_verify_select']) : ?>
			<?= $form->field($model, 'verify_names')->textInput(['class' => 'form-control select-multi-user', 'data-hidden-id' => 'verify-ids', 'data-url' => Url::to(['/link/multi-user', 'type_module' => 'appli']), 'data-title' => '选择审核人', 'readonly' => true]) ?>
			<?php else : ?>
			<?= $form->field($model, 'verify_names')->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>

			<td align="right"><?= $model->getAttributeLabel('category_id') ?>：</td>
			<td><select class="form-control" name="Application[category_id]">
                    <?php echo ApplicationCategory::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('money') ?>：</td>
			<?= $form->field($model, 'money')->textInput(['class' => 'form-control']) ?>
			<td><span class="redstar">*</span></td>

			<td align="right"><?= $model->getAttributeLabel('create_time') ?>：</td>
			<?= $form->field($model, 'create_time')->textInput(['class' => 'form-control', 'disabled' => 'disabled']) ?>
			<td><span class="redstar">*</span></td>
        </tr>
        
        <?php if (!$model->isNewRecord && Application::readAccess('reimbursement/reimbursement/change-isused')) : ?>
        	<tr>
            	<td align="right">使用状态：</td>
            	<?= $form->field($model, 'isused')->radioList(Application::getIsusedList(), ['itemOptions' => ['labelOptions' => ['class'=>'radio-inline'] ] ]) ?>
            </tr>
        <?php else : ?>
            <?= Html::hiddenInput('Application[isused]', $model->isused); ?>
        <?php endif; ?>
		
		<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->appli_id); ?>
<?php ActiveForm::end(); ?>
