EMV_USERSETTING.jsp 14.6 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
<!DOCTYPE HTML>
<%@page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.csc.library.entry.*" %>
<%@ page import="com.csc.library.system.*" %>
<%@ page import="com.csc.library.session.*" %>
<%@ page import="com.csc.library.utilities.*" %>
<%@ page import="com.csc.library.database.*" %>
<%@ page import="com.csc.library.report.ReportUDF" %>

<%@ include file="../CHECKPROFILE.jsp" %>

<jsp:useBean id="uset" class="com.csc.library.system.Task" scope="page"/>
<jsp:setProperty name="uset" property="appname" value="empview" /> 
<%
	uset.setChannel(request,response);


	HelpEntry screen_udetail=(HelpEntry)uset.process("HelpEntry","MUSERHELP");

	SingleEntry screen=(SingleEntry)uset.process("SingleEntry","PI-PASSWORD");
	CheckNull chk=new CheckNull();
	String filter="";
	filter=" lower(usernameid) like lower('"+uprofile.get("username")+"')";
	screen_udetail.getInquiry().setFilter(filter);
	screen_udetail.getInquiry().refresh();
	
	screen.getRecord();

	ReportUDF muserstate=new ReportUDF();

	screen_udetail.nextRec();

	String pwdflag=muserstate.getSystemCode("PWDSTATUS",uset.getUProfile().get("lang"),screen_udetail.getString("pwdstatus"));
	String cmd=chk.chkNullString(request.getParameter("__cmd"));
	String password = "";
	screen.referLangOff();
	
	if(request.getParameter("__password")!=null && screen.getRecord().getConfirmStatus()==-99) {		
		password=chk.chkNullString(request.getParameter("__password"));
	}
	screen_udetail.referLangOn();


	if(cmd.equals("")||screen.getRecord().getConfirmStatus()<0||screen.getRecord().getConfirmStatus()==2){
	 	screen.getRecord().set("usernameid",screen.getUProfile().get("user"));
		screen.getRecord().set("company",screen.getUProfile().getCompanyid());
		screen.getRecord().search();	
	 }

	String fieldtype=screen.getRecord().getField("password").getType().toLowerCase();
%>

<html ng-app="myHR">
	<head>
		<script type="text/javascript" src="../JS/webtoolkit.sha1.js"></script>
		<script language="JavaScript" src="../JS/SCREEN.js"></script>
		<script type='text/javascript' src='../JS/ICONSMENU.js'></script>
	</head>
	<body>
		<div class="bg-com"></div>
		<jsp:include page="EMV_HEADMENU.jsp" flush="true" />

		<script type="text/javascript">
			setLang("<%=screen.getUProfile().get("lang")%>");
			var swap = new swaplang();
            var titlename = swap.swap2String("SW012326");
			setPageTitle(titlename);

			setLang("<%=screen_udetail.getUProfile().get("lang")%>"); 

			EngCode[200]="password is used "
			ThaiCode[200]="รหัสผ่านนี้ถูกใช้ไปแล้ว";

			EngCode[201]="Not enough number or charactor "
			ThaiCode[201]="รหัสผ่านมีตัวเลขหรือตัวอักษรน้อยกว่าที่กำหนด";

			EngCode[202]="password invalid "
			ThaiCode[202]="รหัสผ่านไม่ถูกต้อง";

			EngCode[203]="Password should have least <%=screen.getDataLabel("muser_role","pwmin")%> characters.\n"
			ThaiCode[203]="รหัสผ่านควรมีความยาวอย่างน้อย <%=screen.getDataLabel("muser_role","pwmin")%> ตัวอักษร\n";
			
			EngCode[204]="Characters [a-zA-Z] least <%=screen.getDataLabel("muser_role","pwstr")%>\n"
			ThaiCode[204]="ตัวอักษร [a-zA-Z] อย่างน้อย <%=screen.getDataLabel("muser_role","pwstr")%>\n";

			EngCode[205]="Number [0-9] least <%=screen.getDataLabel("muser_role","pwnumber")%>\n"
			ThaiCode[205]="ตัวเลข  [0-9] อย่างน้อย <%=screen.getDataLabel("muser_role","pwnumber")%>\n";

			EngCode[206]="Special characters [@#+$%] least  <%=screen.getDataLabel("muser_role","pwspecial")%>\n"
			ThaiCode[206]="อักขระพิเศษ  [@#+$%] อย่างน้อย  <%=screen.getDataLabel("muser_role","pwspecial")%>\n";

			function checkConfirm(){
				var conCode="";
				var conDesc="";
				with(document.cscform){
				//	alert(__confirm.value);
				 conCode=getConfirmIndex(__confirm.value,"0");
				 conDesc=getConfirmIndex(__confirm.value,"1");
				 if(__confirm.value=="-6")alert(MyCode[200]);
				 if(__confirm.value=="-11")alert(MyCode[202]);
				 if(__confirm.value=="-7"||__confirm.value=="-8"||__confirm.value=="-9"||__confirm.value=="-10")alert(MyCode[201]);
				 if(__confirm.value=="4")alert(MyCode[19]);
				 if(__confirm.value=="1" || __confirm.value=="2")alert(MyCode[18]);
				 if(__confirm.value=="-1" || __confirm.value=="-2" || __confirm.value=="-6")alert(MyCode[17]);
					if(conCode=="-99"){
						updateRecord();
					}
				}
			}

			$(document).ready(function(){
				var lang='<%=screen_udetail.getString("lang")%>';
				
				var numcount=$("div.child-tab").length;
				var tabheight=$(".tab-body").height();
				var result=Math.ceil(tabheight/numcount)+1;
				$(".child-tab").css("height",result);
				$(".child-tab").css("line-height",result+"px");
				
				/*if (lang=="ENG"){
					$("input[name=__lang]:nth-of-type(1)").attr("checked",true);
				} else if(lang=="THA"){
					$("input[name=__lang]:nth-of-type(0)").attr("checked",true);
				}*/

				$(".child-tab").click(function(){
					if ($(this).data("tab"))
					{
						$(".tab-body").removeClass("active");
						$(".child-tab").removeClass("active");

						var tabid=$(this).data("tab");

						$(this).addClass("active");
						$(tabid).addClass("active");
					}
				});

				$.chkPassword = function(){
					if (($("input[name=__password]").val()=="") && ($("input[name=__newpassword]").val()=="") && ($("input[name=__confirmpw]").val()=="")){
						$("input[name=__password]").prop("disabled",true);										
						$("input[name=__newpassword]").prop("disabled",true);
						$("input[name=__confirmpw]").prop("disabled",true);
						return true;

					}else if ( $("input[name=__password]").val()=="" ){
						alert(MyCode[0]);
						$("input[name=__password]").focus();
						return false;

					} else if ( $("input[name=__newpassword").val()=="" ){
						alert(MyCode[0]);
						$("input[name=__newpassword]").focus();
						return false;
					} else if ( $("input[name=__confirmpw]").val()=="" ){
						alert(MyCode[0]);
						$("input[name=__confirmpw]").focus();
						return false;

					} else if ($("input[name=__newpassword]").val().length<<%=screen.getDataLabel("muser_role","pwmin")%>){
						alert(MyCode[203]);
						$("input[name=__newpassword]").focus();
						return false;
					} else if ($("input[name=__newpassword").val()!=$("input[name=__confirmpw").val()){
						alert(MyCode[50]);
						$("input[name=__newpassword]").val("");
						$("input[name=__confirmpw]").val("");
						return false;

					}else {
						return true;
					}
				};

				$.GoSave = function (){
					if ($.chkPassword()){

						if ( !$("input[name=__password]").prop("disabled") && !$("input[name=__newpassword").prop("disabled") && !$("input[name=__confirmpw").prop("disabled") ){
							var msg="";
							var niw=$("input[name=__newpassword]").val().replace(/[\D\.]+/g,"").length;
							var ciw=$("input[name=__newpassword]").val().replace(/[^a-zA-Z]+/g,"").length;
							var siw=$("input[name=__newpassword]").val().length-(niw+ciw);
							
							$("input[name=__niw]").val(niw);
							$("input[name=__ciw]").val(ciw);
							$("input[name=__siw]").val(siw);
							if (niw<<%=screen.getDataLabel("muser_role","pwnumber")%>){
								msg+=MyCode[205];
							}
							
							if(ciw<<%=screen.getDataLabel("muser_role","pwstr")%>){
								msg+=MyCode[204];
							}
							
							if(siw<<%=screen.getDataLabel("muser_role","pwspecial")%>){
								msg+=MyCode[206];
							}

							if(msg.length>0){
								msg=MyCode[201]+"\n"+msg;
								alert(msg);
							}else{
							<% 
								if (fieldtype.equals("password")){
							%>
									$("input[name=__password]").val(SHA1($("input[name=__password]").val()));
									$("input[name=__newpassword]").val(SHA1($("input[name=__newpassword]").val()));
									$("input[name=__confirmpw]").val(SHA1($("input[name=__confirmpw]").val()));
									update();
							<%
								}
							%>
							}
						}else {
							update();
						}
					}
				};
			});
		</script>

		<section>
			<div class="container csc-content">
				<div class="row">
					<div class="tab">
						<div class="tab-left">
							<div class="child-tab active" data-tab="#1" swlang code='SW012326'>
								User Detail
							</div>
							<div class="child-tab" data-tab="#2" swlang code='SW012327'>
								Profile Setting
							</div>
						</div> <!-- end tab-left -->
						<div class="tab-body active" id="1">
							<div class="center">
								<h2 swlang code='SW012326'>User Detail</h2>
							</div>
					
							<div class="tab-detail">
								<div class="tab-data tab-form">
									<div class="col-sm-3">
										<span swlang code='SW001984'>Name-Lastname</span>
									</div> 

									<div class="col-sm-1">
										:
									</div>

									<div class="col-sm-6">
										<%=screen_udetail.getString("MEMPLOYEE","fullname")%>
									</div>
												
								</div>
							</div><!-- end tab detail-->
									
							<div class="tab-detail">
								<div class="tab-data tab-form">
									<div class="col-sm-3">
										<span swlang code='SW012328'>User Group</span>
									</div>

									<div class="col-sm-1">
										:
									</div>

									<div class="col-sm-6">
										<%=screen_udetail.getString("USER_LEVEL")%>
									</div>
								</div>
							</div>
							<div class="tab-detail">
								<div class="tab-data tab-form">
									<div class="col-sm-3">
										<span swlang code='SW012329'>User Role</span>
									</div>

									<div class="col-sm-1">
										:
									</div>

									<div class="col-sm-6">
										<%=screen_udetail.getString("USER_ROLE")%>
									</div>
								</div>
							</div> <!-- end tab-detail -->

							<div class="tab-detail">
								<div class="tab-data tab-form">
									<div class="col-sm-3">
										<span swlang code='SW012330'>Password Expire date</span>
									</div>

									<div class="col-sm-1">
										:
									</div>
											
									<div class="col-sm-6">
										 <%=screen_udetail.getString("expiredate")%>
									</div>
								</div>
							</div> <!-- end tab-detail-->

							<div class="tab-detail">
								<div class="tab-data">
									<div class="col-sm-3">
										<span swlang code='SW012331'>Password Status</span>
									</div>

									<div class="col-sm-1">
										:
									</div>
									<div class="col-sm-6">
										<%=pwdflag%>
									</div>
								</div>
							</div> <!-- end tab-detail -->
			
							
						</div><!-- end tab 1-->
						
						<div class="tab-body" id="2">
							<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
							<form name="cscform" method="post">
								<!----------BEGIN CSC INITIAL ZONE ------------------------>

								<%=screen.InitialVariable()%>

								<!----------END CSC INITIAL ZONE -------------------------->
								<input type="hidden" name="__cmd" value=""> 
								<input type="hidden" name="__screen" value="EMV_USERSETTING">
								<input type="hidden" name="__help" value="">
								<input type="hidden" name="__fixCon" value="">
								<input type="hidden" name="__helpReturn" value="">
								<input type="hidden" name="__notNull" value="<%=screen.getRequire()%>">
								<input type="hidden" name="__company" value="<%=screen.getUProfile().get("companyid")%>"> 
								<input type="hidden" name="__usernameid" value="<%=screen_udetail.getString("usernameid")%>">
								<input type="hidden" name="__user_role" value ="<%=screen_udetail.getDataLabel("user_role")%>">
								<input type="hidden" name="__referPage" value="">
								<input type="hidden" name="__isclean" value ="1">
								<input type="hidden" name="__niw" value ="0">
								<input type="hidden" name="__ciw" value ="0">
								<input type="hidden" name="__siw" value ="0">
							
								<script type="text/javascript">//initToolTips();</script>
								<div class="center">
									<h2 swlang code='SW012327'>Profile setting</h2>
								</div>
								<div class="tab-detail">
									<div class="tab-data tab-form">
										<div class="col-sm-3">
											<div class="control-label control-label-form" swlang code='SW001807'>Old Password</div>
										</div>

										<div class="col-sm-1">:
										</div>
										
										<div class="col-sm-6">
											<input type="password" class="form-control" name="__password">
										</div>
									</div><!-- end tab-data -->
								</div><!-- end tab-detail -->

								<div class="tab-detail">
									<div class="tab-data tab-form">
										<div class="col-sm-3">
											<div class="control-label control-label-form" swlang code='SW001808'>New Password</div>
										</div>
										
										<div class="col-sm-1">:
										</div>

										<div class="col-sm-6">
											<input type="password" class="form-control" name="__newpassword">
										</div>
									</div><!-- end tab-data -->
								</div><!-- end tab-detail -->

								<div class="tab-detail">
									<div class="tab-data tab-form">
										<div class="col-sm-3">
											<div class="control-label control-label-form" swlang code='SW001809'>Confirm Password</div>
										</div>
										
										<div class="col-sm-1">:
										</div>

										<div class="col-sm-6">
											<input type="password" class="form-control" name="__confirmpw">
										</div>
									</div><!-- end tab-data -->
								</div><!-- end tab-detail-->

								<div class="tab-detail">
									<div class="tab-data tab-form">
										<div class="col-sm-3">
											<div class="control-label control-label-form" swlang code='SW012332'>Set Default Language</div>
										</div>

										<div class="col-xs-1">:
										</div>

										<div class="col-sm-6">	
											<%=screen.getInput("lang")%>
											<!--<label class="radio-inline">
												<input type="radio" name="__lang" id="__langth" value="THA"> Thai
											</label>
											<label class="radio-inline">
												<input type="radio" name="__lang" id="__langen" value="ENG"> English
											</label>-->
											
										</div>
									</div><!-- end tab-data -->
								</div><!-- end tab-detail-->

								<div class="tab-detail center">
									<a href="javascript:$.GoSave()" class="btn btn-primary" id="usersub" swlang code='SW012098'>Submit</a>
									<!-- <a href="#" class="btn btn-primary" id="usercan" swlang code='SW012132'>Cancel</a> -->
								</div> <!-- end button-->

								<div class="tab-note">
									 <%@ include file="../msgpassword.jsp" %>
								</div>
								<%=screen.endJSP()%>
							</form>
						</div><!-- end tab2 -->
						
					</div> <!-- end tab -->
				</div>
			</div>
		</section>
		<jsp:include page="FOOTER.jsp" flush="true" />
	</body>
</html>