<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserInfo.aspx.cs" Inherits="Web.User.UserInfo" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>用户信息</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--#include file = "../Css/head.htm" -->
    <!--#include file = "../Css/userCssEdit.htm" -->
    <script type="text/javascript">
        function checkAll() {
            //验证
            if (checkAllValidate()) {
                return true;
            } else {
                return false;
            }
        };

        function divClose() {
            parent.$.fancybox.close();
            parent.location = "../wpdcc/manageUsers.aspx";
        };

        function delayClose() {
            setTimeout("divClose()", 1000);
        }
    </script>

</head>
<body>
    <form id="user" method="post" runat="server">
        <div class="edit-func-box func-box">
            <div class="hd b">
                <asp:Label ID="labtitle" runat="server" Text=""></asp:Label>
            </div>
            <div class="bd">
                <table class="edit-table" style="table-layout: fixed">
                    <tr>
                        <th width="20%">用户帐号：
                        </th>
                        <td width="25%">
                            <asp:TextBox ID="name" class="input-md" runat="server" MaxLength="30"></asp:TextBox>
                            <span style="color: red;">*</span>
                            <asp:Label ID="nameExit" runat="server" ForeColor="Red" Visible="False">用户名已存在！</asp:Label>
                        </td>
                        <th rowspan="4" width="18%" align="center"></th>
                        <td rowspan="4" align="left" valign="middle" width="25%">
                            <div id="pho" style="display: inline; width: 80px; height: 80px;" runat="server"></div>
                            <asp:HiddenField ID="photo" runat="server" />
                            <p><a id="uploaduserphoto" href="#" class="btn btn-primary btn-xs"><i class="ace-icon fa fa-cloud-upload"></i>上传头像</a></p>
                            <p><span class="lgrey">(80*80)</span></p>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <th>用户昵称：
                        </th>
                        <td colspan="3">
                            <asp:TextBox ID="fullName" runat="server" CssClass="input-md" MaxLength="30"></asp:TextBox>
                            <span style="color: red;">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:CheckBox ID="allow" runat="server" Text="更改密码：" AutoPostBack="True" OnCheckedChanged="allow_CheckedChanged"></asp:CheckBox><asp:Label ID="lbpwd" runat="server" Text="输入密码：" Visible="false"></asp:Label>
                        </th>
                        <td>
                            <asp:TextBox ID="password" runat="server" TextMode="Password" Enabled="False" onkeyup="changePwdRank(this)" CssClass="input-md" MaxLength="16" data-toggle="tooltip" data-container="body" data-placement="right" title="密码最长16位"></asp:TextBox>
                            <asp:HiddenField ID="km" runat="server" />
                            <span style="color: red;">*</span>
                            <span id="PasswordCheck" style="width: 200px; display: none; background-position: 0px 0px; background-image: url(../images/resfile/password_check_bk.gif); background-repeat: no-repeat; height: 15px; overflow: hidden"></span>
                        </td>
                    </tr>
                    <tr>
                        <th>确认密码：
                        </th>
                        <td>
                            <asp:TextBox ID="password1" runat="server" TextMode="Password" Enabled="False" CssClass="input-md" MaxLength="16"></asp:TextBox>
                            <span style="color: red;">*</span>
                        </td>
                    </tr>
                    <tr id="add1" runat="server">
                        <th>密码提示问题：
                        </th>
                        <td>
                            <asp:TextBox ID="question" runat="server" CssClass="input-md" MaxLength="30" notNull="true" msgName="密码提示问题"></asp:TextBox>
                            <span style="color: red;">*</span>
                        </td>
                        <th>提示问题答案：
                        </th>
                        <td>
                            <asp:TextBox ID="answer" runat="server" CssClass="input-md" MaxLength="30" notNull="true" msgName="提示问题答案"></asp:TextBox>
                            <span style="color: red;">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>性别：
                        </th>
                        <td>
                            <asp:DropDownList ID="sex" class="input-md" runat="server">
                                <asp:ListItem Value="" Selected="True">未选择</asp:ListItem>
                                <asp:ListItem Value="男">男</asp:ListItem>
                                <asp:ListItem Value="女">女</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <th></th>
                        <td style="width: 100%">
                            <span style="color: red;" id="tips" runat="server" visible="false">该用户为最后一个超级管理员，不可更改设计后台权限！</span>
                        </td>                       
                    </tr>
                    <tr>
                        <th>出生日期：
                        </th>
                        <td>
                            <asp:TextBox ID="born" runat="server" CssClass="input-md" MaxLength="19" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"></asp:TextBox>
                        </td>
                        <th>
                            <asp:Label ID="LabEditOthersAdmin" runat="server" Text="管理员类型："></asp:Label>
                        </th>
                        <td>
                            <asp:DropDownList ID="DropEditOthersAdmin" runat="server" class="input-md">
                                <asp:ListItem Value="0" Selected="True">内容后台管理员</asp:ListItem>
                                <%--<asp:ListItem Value="1">允许查看</asp:ListItem>
                                <asp:ListItem Value="2">允许修改</asp:ListItem>
                                <asp:ListItem Value="3">允许修改和删除</asp:ListItem>--%>
                                <asp:ListItem Value="4">超级管理员</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td style="width: 100%;display:none" id="adminNum">
                            <span style="color: red;">超级管理员个数最多为5个！</span>
                        </td>
                    </tr>
                    <tr>
                        <th>工作单位：
                        </th>
                        <td>
                            <asp:TextBox ID="company" runat="server" CssClass="input-md" MaxLength="40"></asp:TextBox>
                        </td>
                        <th>
                            <asp:Label ID="LabBackupAssign" runat="server" Text="备份恢复权限："></asp:Label>
                        </th>
                        <td>
                            <asp:DropDownList ID="DropBackupAssign" runat="server" class="input-md">
                                <asp:ListItem Value="0" Selected="True">无权限</asp:ListItem>
                                <asp:ListItem Value="1">仅备份</asp:ListItem>
                                <asp:ListItem Value="2">备份和恢复</asp:ListItem>
                                <asp:ListItem Value="3">备份恢复及删除</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>所在部门：
                        </th>
                        <td>
                            <asp:DropDownList ID="department" runat="server" DataTextField="name" DataValueField="pkId" class="input-md">
                            </asp:DropDownList>
                        </td>
                        <th>
                            <asp:Label ID="LabLoginType" runat="server" Text="登录默认跳转："></asp:Label>
                        </th>
                        <td>
                            <asp:DropDownList ID="DropLoginType" runat="server" class="input-md">
                                <asp:ListItem Value="0" Selected="True">内容管理后台</asp:ListItem>
                                <asp:ListItem Value="1">设计控制后台</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>联系电话：
                        </th>
                        <td>
                            <asp:TextBox ID="tel" runat="server" CssClass="input-md" MaxLength="30"></asp:TextBox>
                        </td>
                        <th>
                            <asp:Label ID="labNetworkTest" runat="server" Text="内外网测试员："></asp:Label>
                        </th>
                        <td>
                            <asp:DropDownList ID="networkTest" runat="server" CssClass="input-md">
                                <asp:ListItem Value="0">否</asp:ListItem>
                                <asp:ListItem Value="1">是</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>QQ号码：
                        </th>
                        <td>
                            <asp:TextBox ID="qq" runat="server" CssClass="input-md" MaxLength="15"></asp:TextBox>
                        </td>
                        <th>
                            <asp:Label ID="labGradeId" runat="server" Text="用户等级："></asp:Label>
                        </th>
                        <td>
                            <asp:DropDownList ID="gradeId" runat="server" DataValueField="pkId" DataTextField="name" CssClass="input-md">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>电子邮件：
                        </th>
                        <td>
                            <asp:TextBox ID="email" CssClass="input-md" runat="server"></asp:TextBox>
                            <span style="color: red;">*</span>
                        </td>
                        <th>
                            <asp:Label ID="labUsersGroup" runat="server" Text="用户组："></asp:Label>
                        </th>
                        <td>
                            <asp:DropDownList ID="usersGroup" runat="server" DataTextField="groupName" DataValueField="pkId" CssClass="input-md">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>个人简介：
                        </th>
                        <td colspan="3">
                            <asp:TextBox ID="intro" runat="server" CssClass="input-md" MaxLength="50" Width="460"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <asp:HiddenField ID="readInfoType" runat="server" />
                <asp:HiddenField ID="manageAll" runat="server" />
                <asp:HiddenField ID="Auditing" runat="server" />
                <asp:HiddenField ID="recommandRight" runat="server" />
                <asp:HiddenField ID="topRight" runat="server" />
            </div>
            <p><br /></p>
            <div class="action-field text-center">
                <asp:Button ID="ok" class="btn btn-sm btn-primary" runat="server" Text="修 改" OnClientClick="return CheckPassword();" OnClick="ok_Click"></asp:Button>
                &nbsp;&nbsp;&nbsp;
                <input type="button" class="btn btn-sm btn-primary" value="关 闭" onclick="parent.$.fancybox.close();" />
                <p></p><asp:Label ID="labMassage" runat="server" Text="" ForeColor="Red" Visible="false"></asp:Label>
            </div>
        </div>
    </form>

    <!--#include file = "../Css/foot.htm" -->
    <script type="text/javascript" src="../js/base64.js"></script>
    <script language="javascript" type="text/javascript" src="../Wpedt/My97DatePicker/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript" src="../Js/pwdintensity.js"></script>
    <script language="javascript" type="text/javascript">

        var rank = 100;
        function changePwdRank(o) {
            if (o) {
                rank = PwdIntensity(o.value);
                printIntensity(rank);
            }
        }
	
        function CheckPassword(){

            var flag = document.getElementById("<%= allow.ClientID %>");
            var upwd = $("#password").val();
            $("#km").val(Base64.base64encode(Base64.utf16to8(upwd)));
            if(flag==null )
            {
                if (rank < <%= Common.Config.userStrongPassword %>)
                {
                    alert("密码过于简单,请重新输入密码!")
                    return false;
            }else{
                if(addCheckText()){
                    return true ;
                }else {
                    return false ;
                }
            }
        }
        else{
            if (flag.checked)
        {
            if (rank < <%= Common.Config.userStrongPassword %>)
        {
                    alert("密码过于简单,请重新输入密码!")
            return false;
    }else{
                    if(checkText()){
                        return true ;
                    }else {
                        return false ;
    }
    }
    }else{
        if(checkTextNopwd()){
            return true ;
        }else {
            return false ;
        }
    }
    }
        
    }
	
    //加载预览图片
    function showuserphoto(){
        if(document.user.photo.value!=null)
        {
            var arr = document.user.photo.value;
            document.getElementById("pho").innerHTML="<img src="+arr+" height='80' width='80' />";
        }
    }
	
    function checkTextNopwd(){
        var fullName=document.getElementById("fullName").value;
        if(fullName==""){
            alert ("用户昵称不能为空");
            return false ;
        }
        var email=document.getElementById("email").value;
        if(email==""){
            alert ("电子邮件不能为空");
            return false ;
        }else{
            var zzmob = /^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/;
            if ( !(zzmob.test(document.getElementById("email").value)) ) {
                alert("电子邮件格式有误!");
                document.getElementById("email").focus();
                return false;
            }
        }
        //验证
        if (checkAllValidate()) {
            return true;
        }
        else {
            return false;
        }
        return true ;
    }
	
    function checkText(){
        var password=document.getElementById("password").value;
        if(password==""){
            alert ("密码不能为空");
            return false ;
        }
        var password1=document.getElementById("password1").value;
        if(password1!=password){
            alert ("验证密码不一致");
            return false ;
        }
	    
        var fullName=document.getElementById("fullName").value;
        if(fullName==""){
            alert ("用户昵称不能为空");
            return false ;
        }
        var email=document.getElementById("email").value;
        if(email==""){
            alert ("电子邮件不能为空");
            return false ;
        }else{
            var zzmob = /^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/;
            if ( !(zzmob.test(document.getElementById("email").value)) ) {
                alert("电子邮件格式有误!");
                document.getElementById("email").focus();
                return false;
            }
        }
        //验证
        if (checkAllValidate()) {
            return true;
        }
        else {
            return false;
        }
        return true ;
    }
	
    function addCheckText(){
        var password=document.getElementById("name").value;
        if(password==""){
            alert ("用户帐号不能为空");
            return false ;
        }
        var password=document.getElementById("password").value;
        if(password==""){
            alert ("密码不能为空");
            return false ;
        }
        var password1=document.getElementById("password1").value;
        if(password1!=password){
            alert ("验证密码不一致");
            return false ;
        }
	    
        var fullName=document.getElementById("fullName").value;
        if(fullName==""){
            alert ("用户昵称不能为空");
            return false ;
        }
        var email=document.getElementById("email").value;
        if(email==""){
            alert ("电子邮件不能为空");
            return false ;
        }else{
            var zzmob = /^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/;
            if ( !(zzmob.test(document.getElementById("email").value)) ) {
                alert("电子邮件格式有误!");
                document.getElementById("email").focus();
                return false;
            }
        }
        //验证
        if (checkAllValidate()) {
            return true;
        }
        else {
            return false;
        }
        return true ;
    }
    //权限选择样式效果
    $(function(){
        var id1 = $("#DropEditOthersAdmin").find("option:selected").val();
        if(id1 == 0)
        {
            document.getElementById("LabBackupAssign").style.display="none";
            document.getElementById("DropBackupAssign").style.display="none";
            document.getElementById("LabLoginType").style.display="none";
            document.getElementById("DropLoginType").style.display="none";
            document.getElementById("adminNum").style.display="none";
        }
        else if(id1 == 4)
        {
            document.getElementById("LabBackupAssign").style.display="none";
            document.getElementById("DropBackupAssign").style.display="none";
            document.getElementById("adminNum").style.display="block";
        }
        else
        {
            document.getElementById("LabBackupAssign").style.display="block";
            document.getElementById("DropBackupAssign").style.display="block";
            document.getElementById("LabLoginType").style.display="block";
            document.getElementById("DropLoginType").style.display="block";
            document.getElementById("adminNum").style.display="none";
        }
	        
        $("#DropEditOthersAdmin").change(function(){
            var id = $("#DropEditOthersAdmin").find("option:selected").val();
            if(id == 0)
            {
                document.getElementById("LabBackupAssign").style.display="none";
                document.getElementById("DropBackupAssign").style.display="none";
                document.getElementById("LabLoginType").style.display="none";
                document.getElementById("DropLoginType").style.display="none";
                document.getElementById("adminNum").style.display="none";
            }
            else if(id == 4)
            {
                document.getElementById("LabBackupAssign").style.display="none";
                document.getElementById("DropBackupAssign").style.display="none";
                document.getElementById("LabLoginType").style.display="block";
                document.getElementById("DropLoginType").style.display="block";
                document.getElementById("adminNum").style.display="block";
            }
            else
            {
                document.getElementById("LabBackupAssign").style.display="block";
                document.getElementById("DropBackupAssign").style.display="block";
                document.getElementById("LabLoginType").style.display="block";
                document.getElementById("DropLoginType").style.display="block";
                document.getElementById("adminNum").style.display="none";
            }
        });
        
    })
    
    </script>
    <script type="text/javascript" language="javascript">
        //自定义上传图片控件加载，支持自定义上传图片功能需先引用三个文件，[themes/default/default.css] [kindeditor.js] [lang/zh_CN.js]
        KindEditor.ready(function(K) {
            var editor = K.editor({
                uploadJson : '../Wpedt/UserEditor/aspnet/upload_json.ashx',
                fileManagerJson : '../Wpedt/UserEditor/aspnet/file_manager_json.ashx',
                allowFileManager : true
            });
            K('#uploaduserphoto').click(function() {
                editor.loadPlugin('zdyimage', function() {
                    editor.plugin.zdyimageDialog({
                        zdyimageUrl : K('#photo').val(),
                        clickFn : function(url) {
                            K('#photo').val(url);
                            editor.hideDialog();
                            showuserphoto();
                        }
                    });
                });
            });
        });
    </script>
</body>
</html>
