<!-- #include file="../conn.asp" -->
<!-- #include file="../const.asp" -->
<%call chksunzom()
if nowuserid>1 then
if usershu>=int(chk0(sunzs(3)))  then response.write "<script language=JavaScript>" & "alert('您的注册用户端已超出，请联系软件开发商！！');" & "history.back()" & "</script>":response.end
end if
if instr(quanxs,"x7t")<=0 then call sunzomqx()
if instr(quanxs,"zxtj")<=0 then call sunzomqx()
nowqx=""
%>
<!-- #include file="../inc/md5.asp" -->

<html>
<head>
<title><%=dianming%> - 添加员工</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/sunzom.css" rel="stylesheet" type="text/css">

<script>
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
</script>
</HEAD>
<BODY>
<%if request("hid1")="" then%> 
<script language="javascript">
function check()
{
if (document.form1.bianhao.value==""||document.form1.username.value==""||document.form1.pwd.value==""||document.form1.sfz.value=="")
{
alert("有*号的必须填写！");
return false;
}
}
</script>
<form name="form1">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#C4D8ED">
<tr>
<td><img src="../images/r_1.gif" alt="" /></td>
<td width="100%" background="../images/r_0.gif">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>&nbsp;添加员工/账号(带*号的为必填项)</td>
	  <td align="right">　</td>
    </tr>
  </table>
</td>
<td><img src="../images/r_2.gif" alt="" /></td>
</tr>
<tr>
<td></td>
<td>
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
      <tr>
        <td height="30" align="right">所属部门：</td>
        <td class="category"><%=zuxuan(zuid,zux1)%></td>
      </tr>
	  <tr>
        <td height="30" align="right">职务：</td>
        <td class="category"><%=zwxuan(zuzw,"zuzw","dan")%></td>
      </tr>
	  <tr>
        <td height="30" align="right">姓名(登陆账号1)：</td>
        <td class="category"><input type="text" name="bianhao" style="width:100px">
          编号(登陆账号2)&nbsp;<input type="text" name="username" style="width:100px"><font color="#ff0000">*</font>&nbsp;
		<input type="radio" name="xinbie" value="女" checked="">女 <input type="radio" name="xinbie" value="男">男		 
		<font color="#666666">(不能有同名的员工)</font></td>
      </tr>
      <tr>
        <td align="right" height="30">登陆密码：</td>
        <td class="category">
		<input type="password" name="pwd" style="width:200px" size="10">&nbsp;&nbsp;<font color="#ff0000">*</font>   身份证号：<input type="text" name="sfz">&nbsp;&nbsp;<font color="#ff0000">*</font></td>
      </tr>
      <tr>
        <td align="right" height="30">账号状态：</td>
        <td class="category"><input type="checkbox" name="userzt" value="1" checked>账号开启</td>
      </tr>	  
	  <tr>
        <td align="right" height="30">手机号码：</td>
        <td class="category"><input type="text" name="tel" style="width:200px">&nbsp; 家庭住址：<input type="text" name="address" style="width:200px"></td>
      </tr>
	  <tr>
        <td align="right" height="30">QQ：</td>
        <td class="category"><input type="text" name="qq" style="width:200px" onKeyUp="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')">&nbsp; Email：<input type="text" name="email" style="width:200px"></td>
      </tr>
      <tr>
        <td align="right" height="30">日常工作安排：</td>
        <td class="category">
        <textarea rows="4" name="rcwork" cols="74"></textarea></td>
      </tr>
      <tr>
        <td align="right" height="30" valign="top">账号权限<input name="chkall" type="checkbox" id="chkall" value="select" onClick="CheckAll(this.form)" style="border:0"> 全选
<br><input type="reset" value=" 恢复默认 " class="button"></td>
        <td class="category">
<%if request.Cookies("sunzom_id")="1" then%>
		<table cellpadding="3" cellspacing="0" width="100%" border="0">
		  <tr>
			<td>基本管理：<input type="checkbox" name="quanxian" value="增加" <%if instr(nowqx,"增加")>0 then%>checked<%end if%>>增加 
<input type="checkbox" name="quanxian" value="增加" <%if instr(nowqx,"增加")>0 then%>checked<%end if%>>删除
<input type="checkbox" name="quanxian" value="修改" <%if instr(nowqx,"修改")>0 then%>checked<%end if%>>修改
<input type="checkbox" name="quanxian" value="审核" <%if instr(nowqx,"审核")>0 then%>checked<%end if%>>审核&nbsp; <%if instr(nowqx,"admall")>0 or  nowuserid=1 then%><input type="checkbox" name="quanxian" value="admall" <%if instr(nowqx,"admall")>0 then%>checked<%end if%>>查看全局数据<%end if%>

<%if instr(nowqx,"admxgall")>0 or  nowuserid=1 then%><input type="checkbox" name="quanxian" value="admxgall" <%if instr(nowqx,"admxgall")>0 then%>checked<%end if%>>修改全局数据<%end if%>

			　</td></tr>
		  <tr>
			<td style="background-color: #DDDDDD">
			<b>菜单权限</b></td></tr>
<tr>
		    <td width="100%">
<%
sql="select * from sz_cd where cla1=0 order by cdpx desc,id asc"  
set rsc1 =server.createobject("ADODB.RecordSet")	
rsc1.open sql,conn,1,3
shu=rsc1.recordcount
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
Response.Write "<input type=""checkbox"" name=""quanxian"" value=""c"&id1&"d"""
if instr(nowqx,"c"&id1&"d")>0 then Response.Write "checked" 
Response.Write "><b>"&rsc1("cdname")&"</b>："

sql="select * from SZ_cd where cla1="&id1&" order by cdpx desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
Response.Write "<input type=""checkbox"" name=""quanxian"" value=""c"&id2&"d"""
if instr(nowqx,"c"&id2&"d")>0 then Response.Write "checked" 
Response.Write ">"&rsc2("cdname")&"&nbsp;"
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing

Response.Write "</ul></div>"
aa=ii
rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing
%>
</td>
		  </tr>	
<tr>
		    <td width="100%" style="background-color: #DDDDDD">
<b>模型权限</b></td>
		  </tr>	
<tr>
		    <td width="100%"><%
sql="select * from sz_mx where bid=0 order by mxpx desc,id asc"  
set rsc1 =server.createobject("ADODB.RecordSet")	
rsc1.open sql,conn,1,3
shu=rsc1.recordcount
if not rsc1.bof then
do while not rsc1.eof
Response.Write "<input type=""checkbox"" name=""quanxian"" value=""m"&rsc1("id")&"x"""
if instr(nowqx,"m"&rsc1("id")&"x")>0 then Response.Write "checked" 
Response.Write "><b>"&rsc1("mxname")&"</b>："

sql="select * from SZ_mx where bid="&rsc1("id")&" order by mxpx desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
Response.Write "<input type=""checkbox"" name=""quanxian"" value=""m"&chk0(rsc2("id"))&"x"""
if instr(nowqx,"m"&rsc2("id")&"x")>0 then Response.Write "checked" 
Response.Write ">"&rsc2("mxname")&"&nbsp;"


sql="select * from SZ_mx where bid="&rsc2("id")&" order by mxpx desc,id asc"
set rsc3=conn.execute(sql)
if not rsc3.bof then
do while not rsc3.eof
Response.Write "<input type=""checkbox"" name=""quanxian"" value=""m"&chk0(rsc3("id"))&"x"""
if instr(nowqx,"m"&rsc3("id")&"x")>0 then Response.Write "checked" 
Response.Write ">"&rsc3("mxname")&"&nbsp;"
rsc3.movenext
loop
end if
rsc3.close:set rsc3=nothing

rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing

Response.Write "</ul></div>"
aa=ii
rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing
%></td>
		  </tr>	
		  <tr><td bgcolor="#DDDDDD">
			<input type="checkbox" name="quanxian" value="x0t" <%if instr(nowqx,"x0t")>0 then%>checked<%end if%>><b>系统设置</b></td></tr>
		  <tr>
		    <td>
<input type="checkbox" name="quanxian" value="x1t" <%if instr(nowqx,"x1t")>0 then%>checked<%end if%>>基本信息设置  
<input type="checkbox" name="quanxian" value="smstx" <%if instr(nowqx,"smstx")>0 then%>checked<%end if%>>短信/邮件提醒
<input type="checkbox" name="quanxian" value="x5t" <%if instr(nowqx,"x5t")>0 then%>checked<%end if%>>部门管理 
<input type="checkbox" name="quanxian" value="x6t" <%if instr(nowqx,"x6t")>0 then%>checked<%end if%>>职位管理 
<input type="checkbox" name="quanxian" value="x7t" <%if instr(nowqx,"x7t")>0 then%>checked<%end if%>>员工管理 
<input type="checkbox" name="quanxian" value="x8t" <%if instr(nowqx,"x8t")>0 then%>checked<%end if%>>数据备份
<input type="checkbox" name="quanxian" value="x9t" <%if instr(nowqx,"x9t")>0 then%>checked<%end if%>>数据还原
<input type="checkbox" name="quanxian" value="x10t" <%if instr(nowqx,"x10t")>0 then%>checked<%end if%>>登陆日志</p></td>
		  </tr>
		</table><%end if%>		</td>
      </tr>	
      <tr>
	    <td height="30">　</td>
        <td class="category"><input type="submit" value=" 确认添加 " onClick="return check()" class="button">&nbsp;&nbsp;&nbsp;&nbsp;
		  <input type="hidden" name="hid1" value="ok">
		  <input type="reset" value=" 重新填写 " class="button">		</td>
      </tr>	    
</table>
</td>
<td></td>
</tr>
<tr>
<td><img src="../images/r_4.gif" alt="" /></td>
<td></td>
<td><img src="../images/r_3.gif" alt="" /></td>
</tr>
</table>
</form>
<%
else
nowbianhao=request("bianhao")
nowqq=request("qq")
nowemail=request("email")
nowid_zu=request("zuid")
nowusername=request("username")
nowpwd=request("pwd")
nowuserzt=chk0(requestA("userzt"))
nowxinbie=request("xinbie")
nowtel=request("tel")
nowaddress=request("address")
nowsfz=request("sfz")
nowquanxian=replace(requestA("quanxian")," ","")
nowrcwork=request("rcwork")

sql="select * from login where bianhao='"&nowbianhao&"'"
set rs=conn.execute(sql)
if rs.eof=false then
%>
<script language="javascript">
alert("您输入的编号已经存在,请重新输入！")
window.history.go(-1)
</script> 
<%
  response.end
end if
sql="select * from login where username='"&nowusername&"'"
set rs=conn.execute(sql)
if rs.eof=false then
%>
<script language="javascript">
alert("您输入的姓名已经存在，如果有同名员工，请加以区分！")
window.history.go(-1)
</script> 
<%
  response.end
end if

sql="insert into login(bianhao,username,pwd,quanxian,xinbie,tel,address,sfz,qq,email,id_zu,zuzw,userzt,rcwork) values('"&nowbianhao&"','"&nowusername&"','"&md5(nowpwd)&"','"&nowquanxian&"','"&nowxinbie&"','"&nowtel&"','"&nowaddress&"','"&nowsfz&"','"&nowqq&"','"&nowemail&"',"&nowid_zu&",'"&nowzuzw&"',"&nowuserzt&",'"&nowrcwork&"')"
conn.execute(sql)
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"|"&nowuserhao&"','增加员工','"&userip&"','"&nowbianhao&"|"&nowusername&"')")
%>
<script language="javascript">
alert("员工添加成功！")
window.location.href="user.asp"
</script> 
<%
end if
%>
</body>
</html>