<?php

use qcbase\assets\MenuAsset;
use yii\helpers\Url;
use qcbase\models\Menu;
use yii\widgets\ActiveForm;

MenuAsset::register($this);
?>

<div class="nav">
    <ul class="cc">
        <li class="current"><a href="<?= Url::to(['menu/index']) ?>">菜单管理</a></li>
        <li><a href="<?= Url::to(['menu/create']) ?>">添加菜单</a></li>
    </ul>
</div>
<?= $this->render('/site/_search', ['get' => $get, 'model' => $model, 'action' => 'menu/search-menu']); ?>
<div class="table_list">
    <?php $mainForm = ActiveForm::begin([ 'id' => 'main-form', 'action' => '']); ?>
    <table width="100%">
        <thead>
            <tr>
                <td width="50"><input type="checkbox" name="select_all" class="box-select-all" />全选</td>
                <td width="50">排序</td>
                <td width="5%">ID</td>
                <td>应用/菜单名称</td>
                <td>模块名称</td>
                <td >控制器名称</td>
                <td>动作名称</td>
                <td>是否显示</td>
                <td width="20%" align="center">操作</td>
            </tr>
        </thead>
        <?php if (empty($models)) : ?>
            <tr><td colspan="9" class="tac red">还没有任何数据...</td></tr>
        <?php else : ?>
            <?php foreach ($models as $model) : ?>
                <tr data-class-id="{$r['menu_id']}" data-parent-class="{$id}">
                    <td><input type="checkbox" name="delete[]" class="box-delete" value="<?= $model->menu_id ?>" /></td>
                    <td><input type="text" size="4" value="<?= $model->sort ?>" class="input" name="sort[<?= $model->menu_id ?>]" /></td>
                    <td><?= $model->menu_id ?></td>
                    <td><?= $model->name ?></td>
                    <td><?= $model->module ?></td>
                    <td><?= $model->controller ?></td>
                    <td><?= $model->action ?></td>
                    <td><?= ($model->status == Menu::STATUS_ENABLE) ? '<font color="green">显示</font>' : '<font color="red">隐藏</font>' ?></td>
                    <td align="center">
                        <a href="<?= Url::to([$this->context->id.'/view', 'id' => $model->menu_id]) ?>" >编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='<?= Url::to([$this->context->id.'/create', 'menu_id' => $model->menu_id,'app_name' =>  $model->app_name]) ?>'>添加子菜单</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?= Url::to([$this->context->id.'/delete', 'id'=>$model->menu_id]) ?>" class="link-delete" >删除</a>
                    </td>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </table>
    <?php ActiveForm::end(); ?>
</div>
<div class="pages">
<?= \yii\widgets\LinkPager::widget([
      'pagination' => $pages,
 ]); ?>
</div>
<div class="btn_wrap">
    <div class="btn_wrap_pd">
        <button class="btn btn_submit mr10 batch-delete" data-url="<?= Url::to(['menu/delete', 'id' => '']) ?>" type="submit" >删除</button>
        <button class="btn  mr10 batch-sort" data-url="<?= Url::to(['menu/sort']) ?>" type="submit">排序</button>
    </div>
</div>
<script>
    var getMenuUrl = "<?= Url::to(['menu/get-menu-list']) ?>"
</script>
