{template "header.html"}

<form class="form-horizontal" method="post" name="myform" id="myform">
    {dr_form_hidden()}
    <div class="portlet bordered light myfbody">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject bold uppercase"><i class="fa fa-user"></i> {dr_lang('用户权限')}</span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="form-body">

                {if $is_cms}
                <div class="alert alert-info" style="margin-bottom:20px;">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
                    <i class="fa fa-info-circle"></i>
                    {dr_lang('内容相关权限（整站访问、模块访问、栏目权限等）已迁移至内容系统，请前往')}
                    <a href="{$cms_auth_url}" class="alert-link">{dr_lang('内容系统 → 权限设置 → 内容权限')}</a>
                    {dr_lang('进行配置。本页仅设置用户侧权限。')}
                </div>
                {/if}

                <div class="form-group">
                    <label class="col-md-2 control-label">{dr_lang('模式选择')}</label>
                    <div class="col-md-9">
                        <div class="mt-radio-inline">
                            <label class="mt-radio mt-radio-outline"><input onclick="dr_auth_mode(0)" type="radio" name="auth_type" value="0" {if !$auth_type}checked=""{/if}> {dr_lang('按全局设置')} <span></span></label>
                            <label class="mt-radio mt-radio-outline"><input onclick="dr_auth_mode(1)" type="radio" name="auth_type" value="1" {if $auth_type == 1}checked=""{/if}> {dr_lang('按用户组设置')} <span></span></label>
                            <label class="mt-radio mt-radio-outline"><input onclick="dr_auth_mode(2)" type="radio" name="auth_type" value="2" {if $auth_type == 2}checked=""{/if}> {dr_lang('按用户组等级设置')} <span></span></label>
                        </div>
                        <span class="help-block">
                            {if !$auth_type}{dr_lang('全部用户共用同一套权限配置')}
                            {else if $auth_type == 1}{dr_lang('按用户组分别配置，可横向对比填写')}
                            {else}{dr_lang('按用户组等级分别配置，表头会标明所属用户组')}
                            {/if}
                        </span>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-12">
                        <div style="border-top:1px solid #eee;margin:5px 0 20px;"></div>
                    </div>
                </div>

                {if $is_single}
                {$form_html}
                {else}
                <div class="form-group">
                    <div class="col-md-12">
                        <div class="table-scrollable fc-auth-wrap">
                            <table class="table table-striped table-bordered table-hover fc-auth-table">
                                <thead>
                                <tr class="heading">{$thead_html}</tr>
                                </thead>
                                <tbody>{$tbody_html}</tbody>
                            </table>
                        </div>
                    </div>
                </div>
                {/if}

            </div>
        </div>
    </div>

    <div class="portlet-body form myfooter">
        <div class="form-actions text-center">
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn green">
                <i class="fa fa-save"></i> {dr_lang('保存权限配置')}
            </button>
        </div>
    </div>
</form>

<script>
function dr_auth_mode(id) {
    var loading = layer.load(2, {
        shade: [0.3, '#fff'],
        time: 100000000
    });
    $.ajax({
        type: "GET",
        dataType: "json",
        url: "{dr_url('member/auth/save_edit')}&value=" + id,
        success: function (json) {
            layer.close(loading);
            dr_cmf_tips(1, json.msg);
            setTimeout(function () {
                window.location.href = "{dr_url('member/auth/index')}";
            }, 500);
        },
        error: function (HttpRequest, ajaxOptions, thrownError) {
            layer.close(loading);
            dr_ajax_alert_error(HttpRequest, this, thrownError);
        }
    });
}
</script>
<style>
.fc-auth-wrap { margin-bottom: 10px; }
.fc-auth-table { margin-bottom: 0; }
.fc-auth-table > thead > tr > th,
.fc-auth-table > tbody > tr > td {
    vertical-align: middle !important;
}
.fc-auth-table .fc-auth-name {
    width: 150px;
    min-width: 150px;
    background: #f9f9f9;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 2;
}
.fc-auth-table thead .fc-auth-name { z-index: 3; }
.fc-auth-table .fc-auth-col {
    text-align: center;
    min-width: 120px;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}
.fc-auth-table .fc-auth-check {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    vertical-align: middle;
    position: relative;
    top: 0;
}
.fc-auth-table .fc-auth-gname {
    display: block;
    color: #999;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.3;
}
.fc-auth-table .fc-auth-lname {
    display: block;
    line-height: 1.4;
}
.fc-auth-table .fc-auth-num-cell { padding: 10px 6px !important; }
.fc-auth-table .fc-auth-num {
    width: 120px;
    margin: 3px auto;
}
.fc-auth-table .fc-auth-num .form-control { text-align: center; }
</style>
{template "footer.html"}
