<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_Manager.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
%>
<script src="<%=CmsAdminMapPath%>js/check/manager.role.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <div class="navigation"><a href="Admin.Role.List.Asp" class="back">角色管理</a> 控制面板 &gt; 管理员管理 &gt; 角色管理 &gt; 添加角色 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">添加角色</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 角色名称： </th>
            <td class="td2"><input type="text" name="RoleName" id="RoleName" maxlength="50" class="txtInput w350" autocomplete="off" />
              <label>*</label></td>
          </tr>
          <tr>
            <th> 角色类型： </th>
            <td class="td2"><%=GetRoleType(Easp.Cookie("ZjjCmsCms>RoleType"), 0)%></td>
          </tr>
          <tr>
            <th> 角色权限： </th>
            <td class="td2"><label style="margin: 0;">
                <input type="checkbox" class="cball" onclick="SelectedItems(this, 'config');" />
                <b>系统设置</b></label></td>
          </tr>
          <tr>
            <th> </th>
            <td class="item_list"><ul>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_config|show" />
                    查看系统配置</label>
                </li>
                <li>
                  <input type="hidden" name="hidName" value="sys_config" />
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_config|edit" />
                    修改系统配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_model|show" />
                    查看模型配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_model|edit" />
                    修改模型配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|show" />
                    查看频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|add" />
                    添加频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|edit" />
                    修改频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|del" />
                    删除频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|show" />
                    查看自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|add" />
                    添加自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|edit" />
                    修改自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|del" />
                    删除自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templet|show" />
                    查看模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templet|add" />
                    添加模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templet|edit" />
                    修改模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templet|del" />
                    删除模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|show" />
                    查看广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|add" />
                    添加广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|edit" />
                    修改广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|del" />
                    删除广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|show" />
                    查看友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|add" />
                    添加友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|edit" />
                    修改友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|del" />
                    删除友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|show" />
                    查看幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|add" />
                    添加幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|edit" />
                    修改幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|del" />
                    删除幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|show" />
                    查看留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|audit" />
                    审核留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|reply" />
                    回复留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|del" />
                    删除留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|show" />
                    查看管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|add" />
                    添加管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|edit" />
                    修改管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|del" />
                    删除管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|show" />
                    查看管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|add" />
                    添加管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|edit" />
                    修改管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|del" />
                    删除管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|pass" />
                    修改管理密码</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_upload|show" />
                    上传文件管理</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_upload|del" />
                    删除上传文件</label>
                </li>
              </ul></td>
          </tr>
          <tr>
            <th> </th>
            <td><table border="0" cellspacing="0" cellpadding="0" class="border_table">
                <thead>
                  <tr>
                    <th width="150"> 频道设置 </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_show');" />
                        <b>查看</b></label>
                    </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_add');" />
                        <b>添加</b></label>
                    </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_edit');" />
                        <b>修改</b></label>
                    </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_delete');" />
                        <b>删除</b></label>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  <%
                  Dim ChannelRs, ArrayList, i
                  Set ChannelRs = Easp.db.GR(TablePrefix & "Channel:Id,BriefName", "", " Px Asc,Id Desc ")
                  If Not Easp.IsN(ChannelRs) Then
                      ArrayList = ChannelRs.GetRows()
                  End If
                  If IsArray(ArrayList) Then
                      For i = 0 To UBound(ArrayList, 2)
                  %>
                  <tr class="td_c">
                    <td><%=ArrayList(1,i)%>频道 </td>
                    <td><input name="ChkChannel" type="checkbox" class="item_show" value="<%=ArrayList(0,i)%>|show" /></td>
                    <td><input name="ChkChannel" type="checkbox" class="item_add" value="<%=ArrayList(0,i)%>|add" /></td>
                    <td><input name="ChkChannel" type="checkbox" class="item_edit" value="<%=ArrayList(0,i)%>|edit" /></td>
                    <td><input name="ChkChannel" type="checkbox" class="item_delete" value="<%=ArrayList(0,i)%>|delete" /></td>
                  </tr>
                  <%
                      Next
                  End If
                  %>
                </tbody>
              </table></td>
          </tr>
          <tr>
            <th> </th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_role", "add"
    '=====================================================================
    Dim RoleName, RoleType
    RoleName = Trim(Easp.Post("RoleName:s"))
    RoleType = Easp.Post("RoleType:n:0")
    If Easp.IsN(RoleName) Then
        CmsAdmin.JscriptMsg "角色名称不能为空！", "back", "Error", "null"
    End If
    If RoleType = 0 Then
        CmsAdmin.JscriptMsg "角色类型必须选择！", "back", "Error", "null"
    End If
    '===================================================================== 保存角色
    Easp.Use "list"
    Set List = Easp.List.New
    List("RoleName") = RoleName
    List("RoleType") = RoleType
    List("AddTime") = Now()
    ResultVal = Easp.db.AR(TablePrefix & "Admin_Role:id", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then

        '=====================================================================
        Dim ChkSysName, SpSysName, ChkChannel, SpChannel
        Dim i, ii, ChannelId, ChannelName, ValType, List, ResultVal
        ChkSysName = Trim(Easp.Post("ChkSysName:s"))
        ChkChannel = Trim(Easp.Post("ChkChannel:s"))
        If Not Easp.IsN(ChkSysName) Then
            ChkSysName = Split(ChkSysName, ",")
            For i = 0 To UBound(ChkSysName)
                SpSysName = Split(ChkSysName(i), "|")
                ChannelName = Trim(SpSysName(0))
                ValType = Trim(SpSysName(1))
                '============================================================= 开始入库基本设置权限
                Easp.Use "list"
                Set List = Easp.List.New
                List("RoleId") = ResultVal
                List("ChannelName") = ChannelName
                List("ChannelId") = 0
                List("ValType") = ValType
                List("AddTime") = Now()
                Easp.db.AR TablePrefix & "Admin_Role_Val", List.Hash
                Easp.C List
            Next
        End If
        '=====================================================================
        If Not Easp.IsN(ChkChannel) Then
            ChkChannel = Split(ChkChannel, ",")
            For ii = 0 To UBound(ChkChannel)
                SpChannel = Split(ChkChannel(ii), "|")
                ChannelId = Trim(SpChannel(0))
                ValType = Trim(SpChannel(1))
                '============================================================= 开始入库基本设置权限
                Easp.Use "list"
                Set List = Easp.List.New
                List("RoleId") = ResultVal
                List("ChannelId") = ChannelId
                List("ChannelName") = "Channel"
                List("ValType") = ValType
                List("AddTime") = Now()
                Easp.db.AR TablePrefix & "Admin_Role_Val", List.Hash
                Easp.C List
            Next
        End If
        CmsAdmin.JscriptMsg "添加角色成功！", "Admin.Role.List.Asp", "Success", "null"
    End If
    '=====================================================================
End Sub
%>
