<?php

use yii\helpers\Url;
use qcbase\models\Auth;
use yii\widgets\ActiveForm;
use qcbase\assets\RoleAuthAsset;
use yii\helpers\StringHelper;

RoleAuthAsset::register($this);
?>

<div class="nav">
    <ul class="cc">
        <li class="current"><a href="<?= Url::to(['role/index']) ?>">角色管理</a></li>
        <li><a href="<?= Url::to(['role/create']) ?>">添加角色</a></li>
    </ul>
</div>

<div class="h_a">温馨提示</div>
<div class="prompt_text">
    <p>1.角色决定用户的上下级关系，上级角色将拥有下级角色的所有权限!</p>
    <p>2.请在添加、修改完所有角色后，<a href="javascript:parent.iframeJudge({elem:this, id:'cache', title:'更新缓存', href:'<?= Url::to(['/site/cache']) ?>' });">更新缓存</a>，否则数据将不会同步更新 !</p>
</div>

<div class="table_list">
    <table width="100%">
        <thead>
            <tr>
                <!--<td width="50"><input type="checkbox" name="select_all" class="box-select-all" />全选</td>-->
                <td width="15%">角色名称</td>
                <td width="30%">人员</td>
                <td align="left">描述</td>
                <td width="30%" align="center">操作</td>
            </tr>
        </thead>
        <?php if (empty($roleList)) : ?>
            <tr><td colspan="3" class="tac red">还没有任何数据...</td></tr>
        <?php else : ?>
            <?php foreach ($roleList as $role) : ?>
                <tr>
                    <!--<td><input type="checkbox" name="delete[]" class="box-delete" value="<?= $role['name'] ?>" /></td>-->
                    <td><?= $role['tree_spacer'] . $role['name'] ?></td>
                    <td align="left" title="<?= $role['allUserStr'] ?>"><?= StringHelper::truncate($role['allUserStr'], 50) ?></td>
                    <td align="left"><?= $role['description'] ?></td>
                    <td align="center" >
                    <?php if ($role['name'] != Yii::$app->params['auth']['superAdminRole']) : ?>
                        <a href="<?= Url::to(['role/view', 'id' => $role['name']]) ?>" >编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <a href="<?= Url::to(['role/show-auth-menu', 'role' => $role['name'], 'app_name' => 'home']) ?>" >权限管理</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <a href="<?= Url::to(['role/delete', 'id' => $role['name']]) ?>" class="link-delete" >删除</a>
                    <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </table>
</div>

<div class="btn_wrap">
</div>
<script>
    var csrfToken = "<?= Yii::$app->request->getCsrfToken() ?>";
    var authUrl = "<?= Url::to(['role/auth']) ?>";
</script>
