<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%@ taglib prefix="webpath" uri="/WEB-INF/tlds/path.tld"%>
<%@ taglib prefix="webpage" uri="/WEB-INF/tlds/pageview.tld"%>


<head>
	<style type="text/css">
     	body{
			background:url(<webpath:path/>/resources/images/timg1.jpg);
			filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale')";  
			-moz-background-size:100% 100%;  
			background-size:100% 100%;  
			background-attachment: fixed;
		}
		.h22 {
			FONT-SIZE: 30px; font-family:PingFangSC,helvetica neue,hiragino sans gb,arial,microsoft yahei ui,microsoft yahei,simsun,"sans-serif" !important;font-weight: bold; COLOR: #f0f0f0; FONT-WEIGHT: 5px;
		}
		.divTityle{
			border-bottom: 1px solid rgba(255,255,255,0.3);	
		}
		.form-control{
			height:26px;
		}
		label.error{
			color:#ff0000;
		}
	</style>

</head>
	
	<div class="main-container col-sm-12" style="padding:0px; margin:0px;">
			<div class="main-content col-sm-12"  style="padding:0px; margin:0px;">
				<div class="row" style="width:100%;margin:0;">
					<div class="col-sm-12" style="padding:0px; margin:0px;">
						<div class="login-container divTityle" style="width:100%; height:80px;">
							<div class="left col-sm-12 " style="height:0; padding:20px;padding-left:60px;"  >
                            	<img alt="logo" src="<webpath:path/>/resources/images/logo.png" height="40" style=""/>&nbsp;&nbsp;&nbsp;
                                <img alt="wz" src="<webpath:path/>/resources/images/wz.png"  height="40" style="margin-top:5px; "/>&nbsp;&nbsp;&nbsp;
							</div>
		
							<div class="space-6"></div>
							<div class="position-relative" style="top:140px" >
								<div id="login-box" class="login-box visible widget-box no-border " style="width: 745px; margin-left: auto;margin-right: auto; padding: 0px;" >
									<div class="widget-body" style="margin-bottom:100px;">
										<div class="widget-main" style="padding: 40px;">
										
											<h3 class="blue lighter bigger" style="text-align: left;height:50px;" id="teamNameTitle">${user.teamName}</h3> 
											<div class="space-6"></div>
											<form action="#" id="profile_form" name="profile_form" method="post" onsubmit="return false">
												<fieldset>
													<label class="block clearfix">
														<span class="block col-sm-2 ">
														编号：
														</span>
														<span class="block col-sm-10 ">
															${user.userId}
														</span>
													</label>
													<label class="block clearfix">
														<span class="block col-sm-2 ">
														团队名称：
														</span>
														<span class="block col-sm-10 ">
															<input type="text" class="form-control"  id="teamName" name="teamName"  value="${user.teamName}"/>
														</span>
													</label>
													<label class="block clearfix">
														<span class="block col-sm-2 ">
														单位名称：
														</span>
														<span class="block col-sm-10 ">
															<input type="text" class="form-control"  id="userName" name="userName"  value="${user.userName}"/>
														</span>
													</label>
													<label class="block clearfix">
														<span class="block col-sm-2 ">
														组别：
														</span>
														<span class="block col-sm-10 ">
															<c:if test="${user.groups==1}">
								                            	本科生组
								                            </c:if>
								                            <c:if test="${user.groups==2}">
								                            	研究生组
								                            </c:if>
								                            <c:if test="${user.groups==3}">
								                            	业界组
								                            </c:if>
														</span>
													</label>	
													<label class="block clearfix">
															<span class="block col-sm-2 ">
															手机号：
															</span>
															<span class="block col-sm-10 ">
																${user.mobile}
															</span>
														</label>
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															邮箱：
															</span>
															
															<span class="block col-sm-10 ">
																<input type="text" class="form-control"  id="email" name="email"  value="${user.email}"/>
															</span>
														</label>
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															联系人：
															</span>
															
															<span class="block col-sm-10 ">
																<input type="text" class="form-control"  id="contacts" name="contacts"  value="${user.contacts}"/>
															</span>
														</label>
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															指导老师：
															</span>
															
															<span class="block col-sm-2 ">
																<input type="text" class="form-control" id="teacher" name="teacher"  value="${user.teacher}"/>
															</span>
															
															<span class="block col-sm-1" style="padding:0;">
															电话：
															</span>
															
															<span class="block col-sm-3" style="padding-left:0;">
																<input type="text" class="form-control" id="teacherTel" name="teacherTel"  value="${user.teacherTel}"/>
															</span>
															
															<span class="block col-sm-1" style="padding:0;">
															邮箱：
															</span>
															
															<span class="block col-sm-3" style="padding-left:0;">
																<input type="text" class="form-control" id="teacherEmail" name="teacherEmail"  value="${user.teacherEmail}"/>
															</span>
														</label>
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															团队成员：
															</span>
															<span class="block col-sm-2 ">
																姓名
															</span>
															
															<span class="block col-sm-2 " style="padding:0;">
																性别
															</span>
															
															<span class="block col-sm-2 ">
																电话
															</span>
															
															<span class="block col-sm-2 ">
																邮箱
															</span>
															
															<span class="block col-sm-2 ">
																年级、专业
															</span>
														</label>
														
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															</span>
															<span class="block col-sm-2 " >
																<input type="text" class="form-control" id="memberName1" name="memberName1"  value="${user.memberName1}"/>
															</span>
															
															<span class="block col-sm-2 " style="padding-left:0;">
																<select class="form-control" placeholder="性别" id="memberGender1" name="memberGender1" style="height: 26px;padding: 0px;">    
																	<option value="">请选择</option>  
	                                                            	<option value="male" <c:if test="${user.memberGender1=='male'}">selected="selected"</c:if>>男</option>
	                                                            	<option value="female" <c:if test="${user.memberGender1=='female'}">selected="selected"</c:if>>女</option>                                  
																</select>   
															</span>
															
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberTel1" name="memberTel1"  value="${user.memberTel1}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberEmail1" name="memberEmail1"  value="${user.memberEmail1}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberGrade1" name="memberGrade1"  value="${user.memberGrade1}"/>
															</span>
														</label>
														
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															</span>
															<span class="block col-sm-2 " >
																<input type="text" class="form-control" id="memberName2" name="memberName2"  value="${user.memberName2}"/>
															</span>
															
															<span class="block col-sm-2 " style="padding-left:0;">
																<select class="form-control" placeholder="性别" id="memberGender2" name="memberGender2" style="height: 26px;padding: 0px;">    
																	<option value="">请选择</option>  
	                                                            	<option value="male" <c:if test="${user.memberGender2=='male'}">selected="selected"</c:if>>男</option>
	                                                            	<option value="female" <c:if test="${user.memberGender2=='female'}">selected="selected"</c:if>>女</option>                                  
																</select>   
															</span>
															
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberTel2" name="memberTel2"  value="${user.memberTel2}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberEmail2" name="memberEmail2"  value="${user.memberEmail2}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberGrade2" name="memberGrade2"  value="${user.memberGrade2}"/>
															</span>
														</label>
														
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															</span>
															<span class="block col-sm-2 " >
																<input type="text" class="form-control" id="memberName3" name="memberName3"  value="${user.memberName3}"/>
															</span>
															
															<span class="block col-sm-2 " style="padding-left:0;">
																<select class="form-control" placeholder="性别" id="memberGender3" name="memberGender3" style="height: 26px;padding: 0px;">    
																	<option value="">请选择</option>  
	                                                            	<option value="male" <c:if test="${user.memberGender3=='male'}">selected="selected"</c:if>>男</option>
	                                                            	<option value="female" <c:if test="${user.memberGender3=='female'}">selected="selected"</c:if>>女</option>                                  
																</select>   
															</span>
															
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberTel3" name="memberTel3"  value="${user.memberTel3}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberEmail3" name="memberEmail3"  value="${user.memberEmail3}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberGrade3" name="memberGrade3"  value="${user.memberGrade3}"/>
															</span>
														</label>
														
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															</span>
															<span class="block col-sm-2 " >
																<input type="text" class="form-control" id="memberName4" name="memberName4"  value="${user.memberName4}"/>
															</span>
															
															<span class="block col-sm-2 " style="padding-left:0;">
																<select class="form-control" placeholder="性别" id="memberGender4" name="memberGender4" style="height: 26px;padding: 0px;">    
																	<option value="">请选择</option>  
	                                                            	<option value="male" <c:if test="${user.memberGender4=='male'}">selected="selected"</c:if>>男</option>
	                                                            	<option value="female" <c:if test="${user.memberGender4=='female'}">selected="selected"</c:if>>女</option>                                  
																</select>   
															</span>
															
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberTel4" name="memberTel4"  value="${user.memberTel4}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberEmail4" name="memberEmail4"  value="${user.memberEmail4}"/>
															</span>
															<span class="block col-sm-2" style="padding-left:0;">
																<input type="text" class="form-control" id="memberGrade4" name="memberGrade4"  value="${user.memberGrade4}"/>
															</span>
														</label>
														
														
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															修改密码：
															</span>
															<span class="block col-sm-10 ">
																<input  type='checkbox' name="changePassword" id="changePassword"  value=""  onchange="profile.changePassword();"/>
															</span>
														</label>
														<div class="pw-div" style="display:none">
															<label class="block clearfix">
																<span class="block col-sm-2 ">
																原密码：
																</span>
																<span class="block col-sm-10 ">
																	<input type="password" class="form-control col-sm-12" id="oldpwd" name="oldpwd"/>
																	
																</span>
															</label>
															
															<label class="block clearfix">
																<span class="block col-sm-2 ">
																密码：
																</span>
																<span class="block col-sm-10 ">
																	<input type="password" class="form-control col-sm-12" id="pwd" name="pwd"/>
																	
																</span>
															</label>
															<label class="block clearfix">
																<span class="block col-sm-2 ">
																确认密码：
																</span>
																<span class="block col-sm-10 ">
																	<input type="password" class="form-control col-sm-12" id="confirmpassword" name="confirmpassword"/>
																	
																</span>
															</label>
														</div>
														
														
														<label class="block clearfix">
															<span class="block col-sm-2 ">
															
															</span>
															<span class="block col-sm-10 ">
																说明：成员至少填写两人
															</span>
														</label>
														
														<div class="space"></div>
														<div class="clearfix" style="text-align: center;">
															<a class="inline" >
															</a>
															<button type="submit" class="pull-left btn btn-sm btn-primary col-sm-5" style="height: 40px;">
																保存信息
															</button>
															
															<button type="button" class="pull-right btn btn-sm btn-primary col-sm-5" onclick="window.location.href='<webpath:path/>/product'" style="height: 40px;">
																提交作品
															</button>
															
														</div>
													
													<div class="space-4"></div>
												</fieldset>
											</form>
										</div><!-- /widget-main -->
									</div><!-- /widget-body -->
								</div><!-- /login-box -->
							</div><!-- /position-relative -->
						</div>
					</div><!-- /.col -->		
				</div><!-- /.row -->
			</div>
		</div>	
	
	


	<script type="text/javascript">
			if("ontouchend" in document)
				document.write("<script src='resources/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script type="text/javascript" src="resources/js/tools/jquerysession.js"></script>
	
		<script type="text/javascript">
			$().ready(function() {
				
				jQuery.validator.addMethod("isMobile", function(value, element) {  
			        var length = value.length;  
			        var mobile = /^1[0-9]{10}$/;  
			        return this.optional(element) || (length == 11 && mobile.test(value));  
			    }, "手机格式不正确");  
				
				$("#profile_form").validate({
					rules:{
						teamName:{
							required: true
					    },
						teacher:{
							required: function(){
								var groups = ${user.groups};
								if ( groups == 3){
									return false;
								}else {
									return true;
								}
							}
					    },
					    email:{
							required: true
					    },
						contacts:{
							required: true
						},
						memberName1:{
							required: true
					    },
					    memberGender1:{
							required: true
					    },
					    memberTel1:{
							required: true
					    },
					    memberEmail1:{
							required: true
						},
						memberGrade1:{
							required: true
						},
						memberName2:{
							required: true
					    },
					    memberGender2:{
							required: true
					    },
					    memberTel2:{
							required: true
					    },
					    memberEmail2:{
							required: true
						},
						memberGrade2:{
							required: true
						},
						oldpwd:{
							required : "#changePassword:checked"
						},
						pwd:{
							required : "#changePassword:checked"
						},
						confirmpassword:{
							required : "#changePassword:checked",
							equalTo:"#pwd"
						}
					},
					messages:{
						teamName:{
							required: "请填写团队名称"
					    },
						teacher:{
							required:"请填写老师"
					    },
					    email:{
							required:"请填写邮箱"
					    },
						contacts:{
							required:"请填写联系人"
						},
						
						memberName1:{
							required: "请填写姓名"
					    },
					    memberGender1:{
							required: "请选择性别"
					    },
					    memberTel1:{
							required: "请填写电话"
					    },
					    memberEmail1:{
							required: "请填写邮箱"
						},
						memberGrade1:{
							required: "请填写年级专业"
						},
						memberName2:{
							required: "请填写姓名"
					    },
					    memberGender2:{
							required: "请选择性别"
					    },
					    memberTel2:{
							required: "请填写电话"
					    },
					    memberEmail2:{
							required: "请填写邮箱"
						},
						memberGrade2:{
							required: "请填写年级专业"
						},
						oldpwd:{
							required:"请填写原密码!"
					    },
						pwd:{
							required:"请填写密码!"
					    },
						confirmpassword:{
							required: "请再次填写密码!",
							equalTo:"两次输入密码不一致!"
						}
					},
					submitHandler:function(form){
						var userName = $('#userName').val();
						var teamName = $('#teamName').val();
						var email =$('#email').val();
						var oldpwd=$('#oldpwd').val();
						var pwd=$('#pwd').val();
						var confirmpassword=$('#confirmpassword').val();
						var teacher=$('#teacher').val();
						var teacherTel=$('#teacherTel').val();
						var teacherEmail=$('#teacherEmail').val();
						var contacts=$('#contacts').val();
						var changePassword=$('#changePassword').val();
						
						var memberName1=$('#memberName1').val();
						var memberGender1=$('#memberGender1').val();
						var memberTel1=$('#memberTel1').val();
						var memberEmail1=$('#memberEmail1').val();
						var memberGrade1=$('#memberGrade1').val();
						
						var memberName2=$('#memberName2').val();
						var memberGender2=$('#memberGender2').val();
						var memberTel2=$('#memberTel2').val();
						var memberEmail2=$('#memberEmail2').val();
						var memberGrade2=$('#memberGrade2').val();
						
						var memberName3=$('#memberName3').val();
						var memberGender3=$('#memberGender3').val();
						var memberTel3=$('#memberTel3').val();
						var memberEmail3=$('#memberEmail3').val();
						var memberGrade3=$('#memberGrade3').val();
						
						var memberName4=$('#memberName4').val();
						var memberGender4=$('#memberGender4').val();
						var memberTel4=$('#memberTel4').val();
						var memberEmail4=$('#memberEmail4').val();
						var memberGrade4=$('#memberGrade4').val();
						
						$.ajax({
							  type: 'POST',
							  url: '/api/user/save',
							  dataType:'json',
							  data: {
								  id:"${user.id}",
								  userName:userName,
								  teamName:teamName,
								  email:email,
								  pwd:pwd,
								  oldpwd:oldpwd,
								  teacher:teacher,
								  teacherTel:teacherTel,
								  teacherEmail:teacherEmail,
								  memberName1:memberName1,
								  memberGender1:memberGender1,
								  memberTel1:memberTel1,
								  memberEmail1:memberEmail1,
								  memberGrade1:memberGrade1,
								  memberName2:memberName2,
								  memberGender2:memberGender2,
								  memberTel2:memberTel2,
								  memberEmail2:memberEmail2,
								  memberGrade2:memberGrade2,
								  memberName3:memberName3,
								  memberGender3:memberGender3,
								  memberTel3:memberTel3,
								  memberEmail3:memberEmail3,
								  memberGrade3:memberGrade3,
								  memberName4:memberName4,
								  memberGender4:memberGender4,
								  memberTel4:memberTel4,
								  memberEmail4:memberEmail4,
								  memberGrade4:memberGrade4,
								  contacts:contacts,
								  changePassword:changePassword,
							  },
							  success: function(data){
								  console.info(data);
								  var message = data.message;
								  if (message == "oldPwdError"){
									  bootbox.dialog({
											message:"原密码不正确，信息保存失败！",
											buttons:{
												"success":{
													"label":"OK",
													"className":"btn-sm btn-primary"
													}
												}
											});
								  }else{
									  bootbox.dialog({
											message:"信息保存成功！",
											buttons:{
												"success":{
													"label":"OK",
													"className":"btn-sm btn-primary"
													}
												}
											});
									  $(".pw-div").fadeOut("fast");
									  $("#changePassword").prop("checked",false);
									  $("input[type='password']").val('');
									  $("#teamNameTitle").html(teamName);
									  
								  }
							   }
						  });
					}
				});
			});
			
			var profile = {
					changePassword: function(){
						if ($("#changePassword").attr("checked") == "checked"){
							$("#changePassword").val(true);
							$(".pw-div").slideDown("fast");
						}else{
							$("#changePassword").val(false);
							$(".pw-div").fadeOut("fast");
						}
					}
			}
			
		</script>
