<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	response.setHeader("Pragma","No-cache");    
	response.setHeader("Cache-Control","no-cache");    
	response.setDateHeader("Expires", -10);  
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@include file="/WEB-INF/views/base.jsp"%>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>添加用户</title>
	<%@include file="/WEB-INF/views/common_base_css.jsp"%>
</head>

<body>
	<input type="hidden" id="basePath" value="<%=basePath %>"  >
    <div id="wrapper">

    	<jsp:include page="../menu.jsp"></jsp:include>

        <div id="page-wrapper" class="gray-bg">
        	<jsp:include page="../head.jsp"></jsp:include>
        	<jsp:include page="../pageNav.jsp"></jsp:include>
            <!-- 页面 主题内容  开始-->
	        <div class="wrapper wrapper-content animated fadeInRight">
	        <div class="row">
	        	<!-- row开始 -->
	           <div class="row">
                	<div class="col-lg-12">
	                    <div class="ibox float-e-margins">
	                        <div class="ibox-title">
	                            <h5>添加用户</h5>
	                        </div>
	                        <div class="ibox-content">
	                        	<form:form id="form" modelAttribute="user" method="post" class="form-horizontal">
	                                <div class="form-group"><label class="col-sm-2 control-label">姓名</label>
	                                    <div class="col-sm-10">
	                                    	<form:input path="username" autocomplete="off"  required=""  class="form-control" />
	                                    	<form:errors path="username" class="field-has-error"></form:errors>
	                                  	</div>
	                                </div>
		      
	                                <div class="form-group"><label class="col-sm-2 control-label">英文名</label>
	                                    <div class="col-sm-10">
	                                    	<form:input path="usernameen" autocomplete="off" class="form-control" /> 
	                                    </div>
	                                </div>
	                                
	                                <div class="form-group"><label class="col-sm-2 control-label">员工号</label>
	                                    <div class="col-sm-10">
	                                    	<form:input path="employeeno" autocomplete="off"  required="" class="form-control" /> 
	                                    	<form:errors path="employeeno" class="field-has-error"></form:errors>
	                                    </div>
	                                </div>
	                                
	                                <div class="form-group"><label class="col-sm-2 control-label">密码</label>
	                                    <div class="col-sm-10">
	                                    	<form:password path="password" autocomplete="off"  required=""  class="form-control" />
	                                    	<form:errors path="password" class="field-has-error"></form:errors>
	                                    </div>
	                                </div>
	                                
	                                
	                                <div class="form-group">
			                            <label class="control-label col-md-2" for="DepID">部门</label>
			                            <div class="col-md-10">
			                            	<form:select class="form-control" path="sysDepartment.depid" onchange="changePosition(this)"  >
			                            		<form:options items="${depList}" itemLabel="depname" itemValue="depid" />
			                            	</form:select>
			                            </div>
			                        </div>
	                                
	                                <div class="form-group">
			                            <label class="control-label col-md-2" for="DepID">职位</label>
			                            <div class="col-md-10">
			                                <form:select class="form-control" path="sysPosition.positionid"  >
			                                	<c:forEach var="dep" items="${depList}" >
			                                		<form:options class="current_${dep.depid}" items="${dep.positions}" itemLabel="positionname" itemValue="positionid" /> 
			                                	</c:forEach>
			                                </form:select>
			                            </div>
			                        </div>
	                                
	                                <div class="form-group"><label class="col-sm-2 control-label">手机</label>
	                                    <div class="col-sm-10">
	                                    	<form:input path="mobilenumber" autocomplete="off" class="form-control"  /> 
	                                    </div>
	                                </div>
	                                
	                                <div class="form-group"><label class="col-sm-2 control-label">邮箱</label>
	                                    <div class="col-sm-10">
	                                    	<form:input path="emailaddress" autocomplete="off" class="form-control"  /> 
	                                    </div>
	                                </div>
	                                
	                                <div class="form-group"><label class="col-sm-2 control-label">是否冻结</label>
	                                    <div class="col-sm-10"><label class="checkbox-inline"> 
	                                    	<form:checkbox class="userStatus" onchange="changeUserStatus()" path="isenabled" value="false" /> &nbsp; </label>
	                                    </div>
	                                </div>
	                                
	                                <div class="form-group">
	                                    <div class="col-sm-4 col-sm-offset-2">
	                                        <button onclick="history.go(-1)" class="btn btn-warning" type="button"><i class="fa fa-mail-forward"></i>&nbsp;&nbsp;返回</button>
	                                        <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i>&nbsp;&nbsp;保存</button>
	                                    </div>
	                                </div>
	                                
	                            </form:form>    
	                        </div>
	                    </div>
                	</div>
            	</div>
	            <!-- row结束 -->	
	        </div>    
	        </div>
	        <!-- 页面主题内容 结束 -->

        </div>
    </div>


    <!-- Mainly scripts -->
    <%@include file="/WEB-INF/views/common_base_script.jsp"%>
        <script>
            $(document).ready(function () {
                $('.i-checks').iCheck({
                    checkboxClass: 'icheckbox_square-green',
                    radioClass: 'iradio_square-green',
                });
            });
        </script>
        <script>
        /**
        *级联显示 部门和职位
       	*/
			function init(number){
				var $current = $(".current_"+number);
				if($current.length > 0){
					$current.siblings().hide();
					$current.siblings().attr("selected", false);
					$current.show();
					$current.eq(0).attr("selected",true);
				} else {
					$(".par_position option").hide();
				}
			}        
        	function changePosition(obj){
        		var value = obj.value;
        		init(value);
        	}
        	//改变用户状态
        	function changeUserStatus(){
        		if($(".userStatus").is(":checked")) {
        			$(".userStatus").val("true")
        		} else {
        			$(".userStatus").val("false");
        		}
        	}
        	
        	var firstDep = ${firstDep};
        	init(firstDep);
        </script>
        <script>
        $(function(){
        	//前台js验证
        	var ruleObj = {username:{required:true}, password:{required:true}};
        	var messageObj = {username:{required:"请输入用户名"}, password:{required:"请输入密码"}};
        	CommonUtils.formValidate("form", ruleObj, messageObj);
        })
        </script>
</body>

</html>