<%@ Page Title="" Language="C#" MasterPageFile="~/whir_system/master/SystemMasterPage.master"
    AutoEventWireup="true" CodeFile="Jurisdiction_column.aspx.cs" Inherits="whir_system_module_developer_Jurisdiction_column" %>

<%@ Import Namespace="Whir.Framework" %>
<%@ Import Namespace="Whir.Language" %>
<%@ Register Src="Jurisdiction_column_top.ascx" TagName="Jurisdiction_column_top"
    TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script>
        whir.skin.checkbox(false); //取消美化checkbox
        jQuery(document).ready(function () {

            //快速选择、按功能快速选择，一定要位于点击事件前面，否则无法触发点击事件
            var arr = new Array();
            $("input[functionname]").each(function (index) {
                arr[index] = $(this).attr("functionname");
            });
            arr = unique(arr); //过滤重
            var str = "&nbsp;&nbsp;";
            for (var i = 0; i < arr.length; i++) {
                str += " <input type=\"checkbox\"  name=\"selectColumn\" value=\"" + arr[i] + "\" functionname=\"" + arr[i] + "\" />" + arr[i] + "";
                if (i % 16 == 0 && i != 0) {//超过16个换行
                    str += "<br/>";
                }
            }
            $("#sampleSelect").html(str);

            //按功能快速选择
            $("input[name='selectColumn']").click(function () {
                var functionName = $(this).val();
                var result = $(this).prop("checked");
                if (result == "checked" || result == "true" || result == true) {
                    $("input[functionname='" + functionName + "']").prop('checked', true);
                } else {
                    $("input[functionname='" + functionName + "']").prop('checked', false);
                }
            });

            //按栏目快速选择
            $("input[name='SelectByColumnId']").click(function () {
                var columnid = $(this).val();
                var result = $(this).prop("checked");
                if (result == "checked" || result == "true" || result == true) {
                    $("input[columnid='" + columnid + "']").prop('checked', true);
                } else {
                    $("input[columnid='" + columnid + "']").prop('checked', false);
                }
            });

            //全选 
            $("#selectAll").click(function () {
                //$("input[functionname]").attr("checked", "checked"); jquery1.6版本以上就不能使用该方法了
                $("input[functionname]").prop('checked', true);
            });
            //取消
            $("#cancelAll").click(function () {
                $("input[functionname]").prop('checked', false);
            });
            //打开类别窗口
            $("a[columnid]").click(function () {
                var columnid = $(this).attr("columnid");
                var maincolumnid = $(this).attr("maincolumnid");
                var categoryids = $(this).attr("selectCategory");
                whir.dialog.frame('<%="分配类别权限"%>', "<%= SysPath %>module/security/Jurisdiction_category.aspx?columnid=" + columnid + "&maincolumnid=" + maincolumnid + "&roleid=2&siteId=<%=SiteId%>&jscallback=CategoryCallBack&ids=" + categoryids, 'showCategory', 500, 300);
            });
        });

        //分配类别权限回调函数
        function CategoryCallBack(data, columnid, maincolumnid) {
           
            $("a[maincolumnid='" + maincolumnid + "']").attr("selectCategory", data);
            var d = $("a[maincolumnid='" + maincolumnid + "']").attr("selectCategory");
        }

        //获取类别信息
        function getCategoryData() {
          
            var categoryData = "";
            $("a[columnid]").each(function () {
                var columnid = $(this).attr("columnid");
                var categoryids = $(this).attr("selectCategory");
                var ids = categoryids.split(',');
                var columnData = "";
                for (var i = 0; i < ids.length; i++) {
                    if (ids[i] != "") {
                        columnData += "category|siteId<%=SiteId%>|" + columnid + "|" + ids[i] + ",";
                    }
                }
                categoryData += columnData;
            });
            $("#<%=hidCategoryData.ClientID %>").val(categoryData);
            return true;
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <form id="Form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="content-wrap">
        <div class="space15">
        </div>
        <div class="panel">
            <div class="panel-heading">超管权限设置</div>
            <div class="panel-body">
                <ul class="nav nav-tabs">
                    <li><a href="Jurisdiction_menu.aspx">菜单权限</a></li>
                    <li class="active"><a href="Jurisdiction_column.aspx">栏目权限</a></li>
                </ul>
                <div class="space15"></div>
                <uc1:Jurisdiction_column_top ID="Jurisdiction_column_top1" runat="server" />
                
                <div class="panel panel-default" id="Table_ColumnFunctionList" runat="server" visible="false">
                    <div class="panel-heading">&nbsp; <%="按功能快速选择".ToLang()%></div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="site_select" id="sampleSelect">
                            </div>
                        </div>
                    </div>
                </div>
                
                <table width="100%" border="0" cellspacing="0" cellpadding="0" id="Table_ColumnList"
                    runat="server" visible="false">
                    <tr>
                        <td class="box_common" valign="top">
                            <div class="list-group-item ">
                                <table width="100%" class=" table-hover" >
                                    <tr style="height: 40px" >
                                        <th width="40" class="th_center"></th>
                                        <th><%="栏目名称".ToLang()%></th>
                                        <th><a id="selectAll" style="cursor: pointer;">全选</a>/<a id="cancelAll" style="cursor: pointer;">取消</a></th>
                                    </tr>
                                    <asp:Repeater ID="rptColumnList" runat="server">
                                        <ItemTemplate>
                                            <tr  style="height: 40px">
                                                <td align="center">
                                                    <input type="checkbox" name="SelectByColumnId" value="<%#Eval("ColumnId") %>" />
                                                </td>
                                                <td>
                                                    <%#Eval("ColumnName")%><%# GetColumnCategoryFunction(Eval("ColumnID").ToStr(), Eval("SiteID").ToStr(),  Eval("MarkType").ToStr())%>
                                                </td>
                                                <td>
                                                    <%#GetColumnFunctionCheckBox(Eval("ColumnId").ToStr(),Eval("SiteId").ToStr(),Eval("FunctionIds").ToStr()) %>
                                                    <br />
                                                    <%# GetColumnWorkFlowCheckBox(Eval("ColumnID").ToStr())%>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </table>
                            </div>
                            <div class="row">
                                <div class="col-md-offset-2 col-md-6">
                                    <asp:HiddenField runat="server" ID="hidCategoryData" />
                                    <asp:UpdatePanel ID="upSave" runat="server">
                                        <ContentTemplate>
                                            <asp:LinkButton ID="btnSave" runat="server" 
                                                CssClass="btn btn-info btn-block" Visible="false" 
                                                OnClientClick="return getCategoryData();"
                                                CommandArgument="Save" OnClick="btnSave_Click">
                                                保存
                                            </asp:LinkButton>
                                            <%-- <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upSave"
                                            DisplayAfter="1">
                                            <ProgressTemplate>
                                                <div id="divProgress" align="center" style="position: absolute; left: 40%; width: 150px;
                                                    height: 32px; background: #6A8BAA; margin-bottom: 200px; border: 1px solid black;">
                                                    正在保存...
                                                </div>
                                            </ProgressTemplate>
                                        </asp:UpdateProgress>--%>
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </div>
                            </div>

                            <div id="testDiv"><%=TestString %></div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    </form>
</asp:Content>
