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

<%@ Import Namespace="Whir.Framework" %>
<%@ 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] + "\" />" + arr[i] + "";
            }
            $("#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 result = $(this).prop("checked");
                if (result == "checked" || result == "true" || result == true) {
                    $(this).parent().parent().find(":checkbox").prop("checked", true);
                } else {
                    $(this).parent().parent().find(":checkbox").prop('checked', false);
                }
            });

            //全选 
            $("#selectAll").click(function () {
                $("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 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">
                <div class="actions btn-group">
                    <a href="Jurisdiction_menu.aspx" class="btn btn-white"><b>菜单权限</b></a> <a href="Jurisdiction_column.aspx"
                        class="btn btn-white"><b>栏目权限</b></a>
                </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; 按功能快速选择</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 >
                                            栏目名称
                                        </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=" " />
                                                </td>
                                                <td> 
                                                    <%#Eval("name")%><%# GetColumnCategoryFunction(Eval("ResultType").ToStr(), Eval("IdValue").ToStr(), Eval("SubjectID").ToStr())%>
                                                </td>
                                                <td>
                                                    <%#GetColumnFunctionCheckBox(Eval("ResultType").ToStr(),Eval("IdValue").ToStr(),Eval("SubjectId").ToStr(),Eval("FunctionIds").ToStr())%>
                                                      <br/> <%# GetColumnWorkFlowCheckBox(Eval("IdValue").ToStr(), Eval("SubjectID").ToStr())%>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </table>
                            </div>
                            <div class="button_submit_div">
                                  <asp:HiddenField runat="server" ID="hidCategoryData" />
                                <asp:UpdatePanel ID="upSave" runat="server">
                                    <ContentTemplate>
                                        <asp:LinkButton ID="btnSave" runat="server" CssClass="btn btn-primary" Visible="false" CommandArgument="Save"  OnClientClick="return getCategoryData();"
                                            OnClick="btnSave_Click">
                                         <b>保存</b>
                                        </asp:LinkButton>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    </form>
</asp:Content>
