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

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

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

<div class="modal-window">
    <?= \home\widgets\Alert::widget(); ?>
    <?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 class="table task-table taskdetail-table">
        <tr>
            <td width="25%" class="table-blue"><?= $model->getAttributeLabel('name') ?></td>
            <td colspan="3"><?= $model->name ?></td>
        </tr>
        <tr>
            <td width="25%" class="table-blue">关联信息</td>
            <td colspan="3"> <?= ArrayHelper::getValue(common\models\Common::getLinkData($model->link_type, $model->link_id), 'name'); ?></td>
        </tr>
        <tr>
            <td width="25%" class="table-blue"><?= $model->getAttributeLabel('reim_time') ?></td>
            <td width="35%" > <?= $model->reim_time ?></td>
            <td width="20%" class="table-blue"><?= $model->getAttributeLabel('reim_people') ?></td>
            <td width="20%" > <?= $model->reim_people ?></td>
        </tr>
        <tr>
            <td width="25%" class="table-blue"><?= $model->getAttributeLabel('reim_money') ?></td>
            <td width="35%" > <?= $model->reim_money ?></td>
            <td width="20%" class="table-blue"><?= $model->getAttributeLabel('bill_amount') ?></td>
            <td width="20%" > <?= $model->bill_amount ?></td>
        </tr>
        <tr>
            <td width="25%" class="table-blue"><?= $model->getAttributeLabel('category_id') ?></td>
            <td colspan="3"><?= isset($model->category->name)?$model->category->name:'' ?></td>
        </tr>
        <?php if (isset($model->application)) : ?>
        <tr>
            <td width="25%" class="table-blue"><?= $model->getAttributeLabel('appli_name') ?></td>
            <td width="35%"> <?= $model->appli_name ?></td>
            <td width="20%" class="table-blue"><?= $model->getAttributeLabel('appli_isverify') ?></td>
            <td width="20%" > <?= $model->appli_isverify ?></td>
        </tr>
        <?php endif; ?>
        <tr>
            <td width="25%" class="table-blue"><?= $model->getAttributeLabel('remark') ?></td>
            <td colspan="3"> <?= $model->remark ?></td>
        </tr>
        <?php if ($model->isShow) : ?>
            <!-- <tr style="display:none;">
                <td width="25%" class="table-blue">审核状态</td>
                <?= $form->field($model, 'verify_status', ['options' => ['colspan' => '3']])->radioList(Reimbursement::getStatusList(), ['itemOptions' => ['labelOptions' => ['class'=>'radio-inline'] ] ]) ?>
            </tr> -->
            <?= Html::hiddenInput('verify_status', Reimbursement::ISVERIFY_ENABLE) ?>
            <tr>
                <td width="25%" class="table-blue">审核意见</td>
                <?= $form->field($model, 'verify_remark', ['options' => ['colspan' => '4']])->textarea(['class' => 'form-control', 'rows' => '5']) ?>
            </tr>
        <?php endif; ?>
    </table>

    <table class="table task-table taskdetail-table-min">
        <tr>
            <td  class="table-blue" colspan="6" style="text-align: center;">审批记录
            <?php if ($model->isverify == Reimbursement::ISVERIFY_ENABLE) : ?>
                <font color="green">[当前审核已通过]</font>
            <?php elseif ($model->isverify == Reimbursement::ISVERIFY_DISABLE) : ?>
                <font color="red">[当前审核已否决]</font>
            <?php endif; ?>
            </td>
        </tr>
        <?php if (empty($verifys)) : ?>
        <tr><td colspan="6" style="text-align: center;">还没有任何审批记录...</td></tr>
        <?php else : ?>
            <?php foreach ($verifys as $key =>$verify) : ?>
                <tr>
                    <td width="10%" class="table-blue" >审批人</td>
                    <td width="15%" > <?= $verify->user->realname ?> </td>
                    <td width="20%" rowspan="2" class="table-blue">审批记录-->批示</td>
                    <td width="30%" rowspan="2"> <?= $verify->remark ?> </td>
                    <td width="10%" rowspan="2" class="table-blue">审批状态</td>
                    <td width="10%" rowspan="2">
                        <?php 
                            if ($verify->status == Verify::STATUS_WAIT) {
                                echo '<font color="green">待审核</font>';
                            } elseif ($verify->status == Verify::STATUS_ENABLE) {
                                echo '<font color="green">通过</font>';
                            } else {
                                echo '<font color="red">否决</font>';
                            }
                        ?>
                    </td>
                </tr>
                <tr>
                    <td width="10%" class="table-blue">批示时间</td>
                    <td width="15%" > <?= date('Y-m-d H:m:s', $verify->verify_time) ?> </td>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </table>
    <?= ($model->isNewRecord) ? '' : Html::hiddenInput('id', $model->reim_id); ?>
    <?= ($model->verify_id != '') ? Html::hiddenInput('verify_id', $model->verify_id) : ''; ?>
    <?php ActiveForm::end(); ?>
</div>

<script>
    var disable = <?= Reimbursement::ISVERIFY_DISABLE ?>;
</script>