<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<%
If InStr(session("GroupPurview"),"|1,") = 0 Then
    response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    response.End
End If
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">
<%
Dim Result
Result = request.QueryString("Result")
Dim ID, GroupID, GroupName, GroupPurview, GroupExplain,Purview, AddTime, RanNum
ID = request.QueryString("ID")
Randomize Timer
RanNum = Int((8999) * Rnd + 1009)
If ID = "" Then GroupID = Year(Now)&Month(Now)&Day(Now)&Hour(Now)&Minute(Now)&Second(Now)&RanNum
    Call MemGroupEdit()

%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="editMemGroup" method="post" action="MemGroupEdit.Asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>"">
    <tr>
      <th height="22" colspan="2" sytle="line-height:150%">【<%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>用户组】</th>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRow">用户组名称：</td>
      <td width="80%" class="forumRowHighlight"><input name="GroupName" type="text" id="GroupName" style="width: 180" value="<%=GroupName%>"> <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">用户组别号：</td>
      <td class="forumRowHighlight"><input name="GroupID" type="text" id="GroupID" style="width: 180" value="<%=GroupID%>" maxlength="18" readonly> <font color="red">*</font></td>
    </tr>
	<tr <%if ID=1 then response.write ("style=display:none")%>>
      <td align="right" class="forumRow">操作权限：</td>
      <td class="forumRowHighlight">
	  <input name="Purview1" type="checkbox" value="|1,"<%if Instr(Purview,"|1,")>0 then response.write ("checked")%>>用户组管理
	  <input name="Purview2" type="checkbox" value="|2,"<%if Instr(Purview,"|2,")>0 then response.write ("checked")%>>员工档案管理
	  <input name="Purview3" type="checkbox" value="|3,"<%if Instr(Purview,"|3,")>0 then response.write ("checked")%>>用户权限管理
	  <input name="Purview4" type="checkbox" value="|4,"<%if Instr(Purview,"|4,")>0 then response.write ("checked")%>>部门设置
	  </td>
	</tr>
<tr <%if ID=1 then response.write ("style=display:none")%>>
      <td align="right" class="forumRow">&nbsp;</td>
      <td class="forumRowHighlight">
	  <input name="Purview5" type="checkbox" value="|5,"<%if Instr(Purview,"|5,")>0 then response.write ("checked")%>>客户分类管理	  
	  <input name="Purview6" type="checkbox" value="|6,"<%if Instr(Purview,"|6,")>0 then response.write ("checked")%>>公司客户管理
	  <input name="Purview7" type="checkbox" value="|7,"<%if Instr(Purview,"|7,")>0 then response.write ("checked")%>>客户回收站管理
	  </td>
	</tr>	
<tr <%if ID=1 then response.write ("style=display:none")%>>
      <td align="right" class="forumRow">&nbsp;</td>
      <td class="forumRowHighlight">
	  <input name="Purview8" type="checkbox" value="|8,"<%if Instr(Purview,"|8,")>0 then response.write ("checked")%>>新闻类别管理	  
	  <input name="Purview9" type="checkbox" value="|9,"<%if Instr(Purview,"|9,")>0 then response.write ("checked")%>>新闻管理	
	  </td>
	</tr>
<tr <%if ID=1 then response.write ("style=display:none")%>>
      <td align="right" class="forumRow">&nbsp;</td>
      <td class="forumRowHighlight">
	  <input name="Purview10" type="checkbox" value="|10,"<%if Instr(Purview,"|10,")>0 then response.write ("checked")%>>
	  客户-&gt;我的销售团队管理(主管)  
      <input name="Purview13" type="checkbox" value="|13,"<%if Instr(Purview,"|13,")>0 then response.write ("checked")%>>
      销售计划-&gt;我的团队
	  <input name="Purview11" type="checkbox" value="|11,"<%if Instr(Purview,"|11,")>0 then response.write ("checked")%>>
      机会-&gt;我的团队
	  </td>
	</tr>
<tr <%if ID=1 then response.write ("style=display:none")%>>
      <td align="right" class="forumRow">&nbsp;</td>
      <td class="forumRowHighlight">
	  <input name="Purview12" type="checkbox" value="|12,"<%if Instr(Purview,"|12,")>0 then response.write ("checked")%>>
	  待办事项分类管理
	  </td>
	</tr>
    <tr>
      <td align="right" class="forumRow">备注：</td>
      <td class="forumRowHighlight"><textarea name="GroupExplain" rows="8" id="GroupExplain" style="width: 500"><%=GroupExplain%></textarea></td>
    </tr>
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="保存"></td>
    </tr>
  </form>
</table>
<%
Sub MemGroupEdit()
    Dim Action, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
        Set rs = server.CreateObject("adodb.recordset")
        If Result = "Add" Then
            sql = "select * from Zqj_MemGroup"
            rs.Open sql, conn, 1, 3
            rs.addnew
            If Len(Trim(Request.Form("GroupName")))<2 Or Len(Trim(Request.Form("GroupName")))>16 Then
                response.Write "<script language='javascript'>alert('请填写用户组名称(4-16个字符或2-8个汉字)！');history.back(-1);</script>"
                response.End
            End If
            rs("GroupID") = Request.Form("GroupID")
            rs("GroupName") = Trim(Request.Form("GroupName"))
            rs("GroupPurview") = Request.Form("Purview1") & Request.Form("Purview2") &_
            Request.Form("Purview3") & Request.Form("Purview4") & Request.Form("Purview5") &_
			Request.Form("Purview6") & Request.Form("Purview7") & Request.Form("Purview8") &_
			Request.Form("Purview9") & Request.Form("Purview10") & Request.Form("Purview11") &_
			Request.Form("Purview12") & Request.Form("Purview13")
            rs("GroupExplain") = Trim(Request.Form("GroupExplain"))
            rs("AddTime") = Now()
        End If
        If Result = "Modify" Then
            sql = "select * from Zqj_MemGroup where ID="&ID
            rs.Open sql, conn, 1, 3
            If Len(Trim(Request.Form("GroupName")))<2 Or Len(Trim(Request.Form("GroupName")))>16 Then
                response.Write "<script language='javascript'>alert('请填写用户组别名称(4-16个字符或2-8个汉字)！');history.back(-1);</script>"
                response.End
            End If
            rs("GroupName") = Trim(Request.Form("GroupName"))
			if ID<>1 then
			rs("GroupPurview") = Request.Form("Purview1") & Request.Form("Purview2") &_
            Request.Form("Purview3") & Request.Form("Purview4") & Request.Form("Purview5") &_
			Request.Form("Purview6") & Request.Form("Purview7") & Request.Form("Purview8") &_
			Request.Form("Purview9") & Request.Form("Purview10") & Request.Form("Purview11") &_
			Request.Form("Purview12") & Request.Form("Purview13")
			end if
			rs("GroupExplain") = Trim(Request.Form("GroupExplain"))
            conn.Execute("Update Zqj_Members set GroupName='"&Trim(Request.Form("GroupName"))&"' where GroupID='"&Trim(Request.Form("GroupID"))&"'")
        End If
        rs.update
        rs.Close
        Set rs = Nothing
        response.Write "<script language='javascript'>alert('设置成功！');location.replace('MemGroupList.Asp');</script>"
    Else
        If Result = "Modify" Then
            Set rs = server.CreateObject("adodb.recordset")
            sql = "select * from Zqj_MemGroup where ID="& ID
            rs.Open sql, conn, 1, 1
            If rs.RecordCount = 0 Then
                response.Write "<script language='javascript'>alert('无此记录！');history.back(-1)</script>"
                response.End
            End If
            ID = rs("ID")
            GroupID = rs("GroupID")
            GroupName = rs("GroupName")
            Purview = rs("GroupPurview")
            GroupExplain = rs("GroupExplain")
            rs.Close
            Set rs = Nothing
        End If
    End If
End Sub
%>