{template "header.html"}
<div class="note note-danger">
    <p><a href="javascript:dr_update_cache_all();">{dr_lang('更改数据之后请更新下全站缓存')}</a></p>
</div>

<div class="right-card-box">
    <form class="form-horizontal" role="form" id="myform">
        {dr_form_hidden()}
        <div class="table-scrollable">
            <table class="table table-striped table-bordered table-hover table-checkable dataTable">
                <thead>
                <tr class="heading">
                    {if $ci->_is_admin_auth('del')}
                    <th class="myselect">
                        <label class="mt-table mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                            <input type="checkbox" class="group-checkable" data-set=".checkboxes" />
                            <span></span>
                        </label>
                    </th>
                    {/if}
                    <th class="hidden-mobile" width="70" style="text-align:center"> {dr_lang('排序')} </th>
                    <th class="hidden-mobile" width="60" style="text-align:center"> {dr_lang('可用')} </th>
                    <th width="300"> {dr_lang('名称')} </th>
                    {if dr_count($ci->site_info) > 1}
                    <th width="100">
                        {if $ci->_is_admin_auth('add')}<a href="javascript:dr_iframe('add', '{dr_url('menu/add', ['pid'=>0])}', '600px', '500px');" class="btn btn-xs blue"> <i class="fa fa-plus"></i> {dr_lang('添加')} </a>{/if}
                    </th>
                    <th> {dr_lang('站点划分')} </th>
                    {else}
                    <th>
                        {if $ci->_is_admin_auth('add')}<a href="javascript:dr_iframe('add', '{dr_url('menu/add', ['pid'=>0])}');" class="btn btn-xs blue"> <i class="fa fa-plus"></i> {dr_lang('添加')} </a>{/if}
                    </th>
                    {/if}
                </tr>
                </thead>
                <tbody>
                {php $top=[];}
                {loop $data $t}
                {php $t.pid == 0 && $top[] = $t.id;$t.site = dr_string2array($t.site);}
                <tr class="odd gradeX" id="dr_row_{$t.id}">
                    {if $ci->_is_admin_auth('del')}
                    <td class="myselect">
                        <label class="mt-table mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                            <input type="checkbox" class="checkboxes checkboxes{$t.tid} checkboxes{$t.pid} group-checkable" data-set=".checkboxes{$t.id}"  name="ids[]" value="{$t.id}" />
                            <span></span>
                        </label>
                    </td>
                    {/if}
                    <td class="hidden-mobile" style="text-align:center"> <input type="text" onblur="dr_ajax_save(this.value, '{dr_url('menu/save_edit', ['id'=>$t.id])}', 'displayorder')" value="{$t.displayorder}" class="displayorder form-control input-sm input-inline input-mini"> </td>
                    <td class="hidden-mobile" style="text-align:center">
                        <a href="javascript:;" onclick="dr_ajax_open_close(this, '{dr_url('menu/use_edit', ['id'=>$t.id])}', 1);" class="badge badge-{if $t.hidden}no{else}yes{/if}"><i class="fa fa-{if $t.hidden}times{else}check{/if}"></i></a>
                    </td>
                    <td>
                        {$t.spacer} <a href="javascript:dr_iframe('edit', '{dr_url('menu/edit', ['id'=>$t.id])}', '600px');"><i class="{$t.icon}"></i> {dr_lang($t.name)}</a>
                    </td>
                    <td>
                        {if $ci->_is_admin_auth('add') && ($t.pid == 0 || dr_in_array($t.pid, (array)$top))}<a href="javascript:dr_iframe('add', '{dr_url('menu/add', ['pid'=>$t.id])}', '600px', '{if !in_array($t.pid, $top)}500px{/if}');" class="btn btn-xs blue"> <i class="fa fa-plus"></i> {dr_lang('添加')} </a>{/if}
                    </td>
                    {if dr_count($ci->site_info) > 1}
                    <td>
                        <label><a title="{$ci->site_info[1]['SITE_NAME']}" class="btn btn-xs dark" style="background-color:#3fa9e4;border-color:#3fa9e4"> {dr_lang('主站')} </a></label>
                        {loop $t.site $b $sid}
                        {if $sid > 1}
                        <label id="dr_site_{$t.id}_{$sid}"><a href="javascript:dr_site_delete('{$t.id}', '{$sid}');" title="{$ci->site_info[$sid]['SITE_NAME']}" class="btn btn-xs {$color[$b]}">{dr_strcut($ci->site_info[$sid]['SITE_NAME'], 4)} <i class="fa fa-times"></i> </a></label>
                        {/if}
                        {/loop}
                    </td>
                    {/if}
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        <div class="row fc-list-footer table-checkable ">
            <div class="col-md-5 fc-list-select">
                {if $ci->_is_admin_auth('del')}
                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                    <input type="checkbox" class="group-checkable" data-set=".checkboxes" />
                    <span></span>
                </label>
                <button type="button" onclick="dr_ajax_option('{dr_url('menu/del')}', '{dr_lang('你确定要删除它们吗？')}', 1)" class="btn red btn-sm"> <i class="fa fa-trash"></i> {dr_lang('删除')}</button>
                {/if}
                {if $ci->_is_admin_auth('edit') && dr_count($ci->site_info) > 1}
                <label style="margin-left: 20px;"><button type="button" onclick="dr_ajax_option('{dr_url('menu/site_add')}', '{dr_lang('你确定要这样操作吗？')}', 1)" class="btn blue btn-sm"> <i class="fa fa-edit"></i> {dr_lang('批量划分站点权限')}</button></label>
                <label>
                    <select name="siteid" class="form-control">
                        <option value=""> {dr_lang('--')} </option>
                        {loop $ci->site_info $sid $t}
                        {if $sid > 1}
                        <option value="{$t.SITE_ID}">{$t.SITE_NAME}</option>
                        {/if}
                        {/loop}
                    </select>
                </label>
                {/if}
            </div>
            <div class="col-md-7 fc-list-page">
                {$mypages}
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">

    function dr_site_delete(id, sid) {
        {if !$ci->_is_admin_auth('del')}
        dr_tips(0, '{dr_lang('无权限删除')}');
        return;
        {/if}
            var index = layer.load(2, {
                shade: [0.3,'#fff'], //0.1透明度的白色背景
                time: 10000
            });
            $.ajax({
                type: "GET",
                cache: false,
                url: '{dr_url('menu/site_del')}&id='+id+'&sid='+sid,
            dataType: "json",
            success: function (json) {
            layer.close(index);
            if (json.code == 1) {
                $('#dr_site_'+id+'_'+sid).hide();
                dr_tips(1, json.msg);
            } else {
                dr_tips(0, json.msg);
            }
        },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError);
            }
        });
        }
</script>
{template "footer.html"}