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

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

$this->title = '类别列表';

$js = <<<JS
    $("#show-first").on('click',function(){
        var url = $(this).data('url'); 
        var showFirst = ($(this).is(":checked")) ? 1 : 0 ;
        window.location.href = url + showFirst;
    });
JS;
$this->registerJs($js, \yii\web\View::POS_END);
?>

<!--container-->
<div class="container manage-project fix">
    <?= $this->render('@home/views/site/_left-menu') ?>

  <!--manage-left -->
  <div class="manage-right">
    <div class="tab-column tab-manage">
        <div class="tab-right">
            <button title="添加类别" type="button" data-width="400" data-height="280" data-url='<?= Url::to([$this->context->id . '/create']) ?>' data-title="添加申请单类别" class="btn btn-default btn-task open-dialog">
                <i class="icon-plus"></i>
            </button>
                <input type="checkbox" <?= (isset($get['show_first']) && $get['show_first'] ==1) ? 'checked="checked"' : '' ?> id="show-first" data-url="<?= Url::to(['index', 'type' => (isset($get['type'])) ? $get['type'] : '' ,'show_first' => '']) ?>" style="position:relative; top:2px; left:-2px;">
                只看一级目录 
        </div>
        <p class="caption">申请单类别</p>
    </div>
    <?= \home\widgets\Alert::widget(); ?>
    <?php $mainForm = ActiveForm::begin([ 'id' => 'main-form', 'action' => '']); ?>
    <table class="table task-table">
        <tr>
            <th width="60"><label style="font-weight:lighter" ><input type="checkbox" name="select_all" class="box-select-all" style="position:relative;top:2px;" /> 全选</label></th>
            <th width="50">排序</th>
            <th width="60%">名称</th>
            <th width="50">状态</th>
            <th width="150" align="center">操作</th>
        </tr>
        <?php if (empty($models)) : ?>
        <tr><td colspan="6" class="tac red">还没有任何数据...</td></tr>
        <?php else : ?>
            <?php echo ApplicationCategory::getIndexTree(0, [], Yii::$app->request->get('show_first')); ?>
        <?php endif; ?>
    </table>
    <div class="tab-column tab-manage">
        <button title="删除" type="button" class="btn btn-default btn-task batch-delete" data-url="<?= Url::to([$this->context->id.'/delete']) ?>" >
          <i class="icon-trash"></i>
        </button>
    </div>
    <?php ActiveForm::end(); ?>
    
  </div>
  <!--manage-right--> 

</div>
<!--container-->