{template "header.html"}

<form action="" class="form-horizontal" method="post" name="myform" id="myform">
    {dr_form_hidden(['page' => $page])}
    <div class="portlet bordered light myfbody">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject bold uppercase">
                    <i class="fa fa-cog"></i> {$page_name} - {dr_lang('栏目权限')}
                </span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="form-body">

                {if $is_share_page}
                {if $share_categroy}
                <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="rr('share_cat', this.value)" type="radio" name="data[home][is_category]" value="0" {if !$data.home.is_category}checked=""{/if}> {dr_lang('统一设置')} <span></span></label>
                            <label class="mt-radio mt-radio-outline"><input onclick="rr('share_cat', this.value)" type="radio" name="data[home][is_category]" value="1" {if $data.home.is_category}checked=""{/if}> {dr_lang('按栏目设置')} <span></span></label>
                        </div>

                        <div id="rr_share_cat_0" style="display: none" class="margin-bottom-15">
                            <div class="table-scrollable" style="padding: 10px">
                                {template "auth_share_category.html"}
                            </div>
                        </div>
                        <div id="rr_share_cat_1" style="display: none">
                            <div class="table-scrollable">
                                <table class="fc-user-table table table-striped table-bordered table-checkable dataTable">
                                    <thead>
                                    <tr class="heading">
                                        <th class="myselect">Id</th>
                                        <th width="300">{dr_lang('栏目')}</th>
                                        <th></th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {loop $share_categroy $catid $cat}
                                    <tr class="">
                                        <td> {$cat.id}</td>
                                        <td> {$cat.spacer} <a href="{$cat.url}" target="_blank">{$cat.name}</a></td>
                                        <td>
                                            <button onclick="dr_iframe('{dr_lang('[%s]权限', $cat.name)}', '{dr_url('cms/auth/edit', ['at' => 'share_category', 'aid'=>$aid, 'id'=>$catid])}', '700px', '300px', 'nogo')" type="button" class="btn blue btn-xs"> <i class="fa fa-cog"></i> {dr_lang('设置权限')}</button>
                                            <button onclick="dr_iframe('{dr_lang('复制')}', '{dr_url('cms/auth/copy_edit', ['at'=>'share_category', 'aid'=>$aid, 'id'=>$catid])}')" type="button" class="btn red btn-xs"> <i class="fa fa-copy"></i> {dr_lang('同步到其他栏目')}</button>
                                        </td>
                                    </tr>
                                    {/loop}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                {else}
                <div class="alert alert-warning">{dr_lang('暂无共享栏目')}</div>
                {/if}

                {else}

                <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="rr('module_cat', this.value)" type="radio" name="data[module][{$mid}][is_category]" value="0" {if !$data['module'][$mid]['is_category']}checked=""{/if}> {dr_lang('统一设置')} <span></span></label>
                            <label class="mt-radio mt-radio-outline"><input onclick="rr('module_cat', this.value)" type="radio" name="data[module][{$mid}][is_category]" value="1" {if $data['module'][$mid]['is_category']}checked=""{/if}> {dr_lang('按栏目设置')} <span></span></label>
                        </div>

                        <div id="rr_module_cat_0" style="display: none" class="margin-bottom-15">
                            <div class="table-scrollable" style="padding: 10px">
                                {template "auth_category.html"}
                            </div>
                        </div>
                        <div id="rr_module_cat_1" style="display: none">
                            <div class="table-scrollable">
                                <table class="fc-user-table table table-striped table-bordered table-checkable dataTable">
                                    <thead>
                                    <tr class="heading">
                                        <th class="myselect">Id</th>
                                        <th width="300">{dr_lang('栏目')}</th>
                                        <th></th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {loop $m.category $catid $cat}
                                    <tr class="">
                                        <td> {$cat.id}</td>
                                        <td> {$cat.spacer} <a href="{$cat.url}" target="_blank">{$cat.name}</a></td>
                                        <td>
                                            <button onclick="dr_iframe('{dr_lang('[%s]权限', $cat.name)}', '{dr_url('cms/auth/edit', ['at' => 'category', 'aid'=>$aid,'mid'=>$mid, 'id'=>$catid])}', '700px', '300px', 'nogo')" type="button" class="btn blue btn-xs"> <i class="fa fa-cog"></i> {dr_lang('设置权限')}</button>
                                            <button onclick="dr_iframe('{dr_lang('复制')}', '{dr_url('cms/auth/copy_edit', ['at'=>'category', 'aid'=>$aid,'mid'=>$mid, 'id'=>$catid])}')" type="button" class="btn red btn-xs"> <i class="fa fa-copy"></i> {dr_lang('同步到其他栏目')}</button>
                                        </td>
                                    </tr>
                                    {/loop}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>

                {loop $diy.module $d}
                <div app="{$d.app}">
                    {php $dfile=$d.file;}
                    {load "$dfile"}
                </div>
                {/loop}

                {/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()}&page={$page}', 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存权限配置')}</button>
        </div>
    </div>
</form>

<script>
function rr(name, id) {
    $('#rr_'+name+'_1').hide();
    $('#rr_'+name+'_0').hide();
    $('#rr_'+name+'_'+id).show();
}
$(function () {
    {if $is_share_page}
    rr('share_cat', {intval($data.home.is_category)});
    {else}
    rr('module_cat', {intval($data['module'][$mid]['is_category'])});
    {/if}
});
</script>
<style>
.mt-checkbox-single {
    margin-right: 10px;
}
</style>
{template "footer.html"}
