PI_CHANGE_SWIPETIME_ADMIN_out.jsp 19.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 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
<!DOCTYPE html>
<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@page import="com.csc.library.entry.*,com.csc.library.system.*,com.csc.library.utilities.*,java.util.*"%>
<%@page import="com.csc.library.utilities.CscCalendar,com.csc.library.entry.HelpEntry,com.csc.library.system.*"%>
<%@page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*,com.csc.library.formula.FormulaString"  %>
<%@page import="com.csc.library.timeattendance.DayShift,com.csc.library.timeattendance.Shift,com.csc.library.timeattendance.WorkingShift"  %>
<%@page import="java.text.DecimalFormat"  %>
<%@ include file="../CHECKPROFILE.jsp" %>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="EMV" class="com.csc.library.system.Task" scope="page" />
<jsp:setProperty name="EMV" property="appname" value="empview" />
<%
	EMV.setChannel(request, response);	
	EmvHelpEntry screen = (EmvHelpEntry) EMV.process("EmvHelpEntry", "PI_SWIPETIMEHELP"); 
	
	CheckNull chk=new CheckNull();
	String ft_empid = chk.chkNullString(request.getParameter("__employeeid"));
//	screen.inq.setFilter("employeeid = '"+EMV.getUProfile().getEmvEmpId()+"' ");
	screen.inq.setFilter("employeeid = '"+ft_empid+"' ");
	
	screen.inq.refresh();	
	screen.nextRec();
	screen.referLangOn();

	CscCalendar cs = new CscCalendar();
	FormulaString fs = new FormulaString();
	DecimalFormat df = new DecimalFormat("0.00");
	DecimalFormat df2 = new DecimalFormat("00.00");

	String empID = EMV.getUProfile().getEmvEmpId();
	DbInquiry inqSwipeTime = new InitialInquiry(screen.getUProfile()).getDbInquiry();
	inqSwipeTime.initMyTable("Ttimetemp", "", "employeeid,swipedate,swipetime");
	inqSwipeTime.setColumn("*");
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myHR">
	<head>
		<title>Employee View</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	</head>

	<script type='text/javascript' src='/hr/dwr/engine.js'></script>
	<script type="text/javascript" src="/hr/dwr/interface/UserChangeShift.js"></script>
	<script type='text/javascript' src='/hr/dwr/util.js'></script>

	<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("SW012470");
			setPageTitle(titlename);


			$(document).ready(function(){
				
				//datepicker function
				var myLang='<%=screen.getUProfile().get("lang")%>';
				if (myLang=="tha"){
					$.datepicker.setDefaults($.datepicker.regional['tha']); 
				}
				
				$("input[name=date_start]").hover(function(){
					$("input[name=date_start]").datepicker({
						dateFormat:"dd-mm-yy",
						maxDate:0,
						defaultDate:-1,
						changeMonth: true,
						changeYear: true
					});
					$("input[name=date_end]").datepicker("destroy");
				});
				
				
				$("input[name=date_end]").change(function(){
					if ($("input[name=date_start]").val()>$("input[name=date_end]").val()){
						$("input[name=date_start]").val($("input[name=date_end]").val());
					} else if ($("input[name=date_start]").val()==""){
						$("input[name=date_start]").val($("input[name=date_end]").val());
					}
				});
				
				
				$("input[name=date_end]").hover(function(){
					$("input[name=date_end]").datepicker({
						minDate: new Date(ConvertDate($("input[name=date_start]").val())),
						dateFormat:"dd-mm-yy",
						changeMonth: true,
						changeYear: true
					});
				});
				
				
			});

			<!--
			function getMsg(msg){
				var lang = document.getElementById("__language");

				if(lang.value == "th"){
					return msg[0] ;
				}else{
					return msg[1] ;
				}
			}

			function setHoliday(obj){
				var rawdat = obj.value ;
				var cols = rawdat.split("#");
				var conb = false ;
				var newShift = "";

				var msg1 = ["ต้องการเปลี่ยนเป็นวันหยุด", "Change to holiday ?"];
				var msg2 = ["ต้องการเปลี่ยนเป็นวันทำงาน", "Change to work ?"];

				var emp = document.getElementById("__employeeid");
				var time0 = document.getElementById("__time0");


				if(cols[0] == "H" || cols[0] == "I"){
					conb = confirm(getMsg(msg2));
					if(conb){
						obj.checked = false;

						//hideLoadPopup(false);
						UserChangeShift.changeShiftByUser(emp.value, cols[2], "D", callbackResult);
					}else{
						obj.checked = true ;
					}
				}else{
					conb = confirm(getMsg(msg1));
					if(conb){
						obj.checked = true;

						//hideLoadPopup(false);
						UserChangeShift.changeShiftByUser(emp.value, cols[2], "A", callbackResult);
					}else{
						obj.checked = false ;
					}
				}
			}

			var callbackResult = function(data){
				search();
			}

			function hideLoadPopup(stat){
				var lp = document.getElementById("loading_leave");

				if(stat){
					lp.style.display = "none";
				}else{
					lp.style.display = "";
				}
			}

			function goHelp(helpName,inputName) {
				var helpReturn;
				var fixCon = "";
				if(inputName=="__employeeid" ) {
					helpReturn="__employeeid:employeeid,MEMPLOYEE@FULLNAME";	
				}
						
				linkHelp_Return(helpName,helpReturn, fixCon);	
			}
			//-->
		</script>
		
		<section>
			<div class="container csc-content">
				<div id="loading_leave" class="popup" align="center" style="display:none">
					<IMG SRC="../IMAGES/loading.gif">
				</div>
				<form name="cscform" class="form-horizontal" method="post" action="PI_CHANGE_SWIPETIME_ADMIN.jsp">
					<input type="hidden" name="__cmd" value="">
					<input type="hidden" name="__screen"  value="PI_CHANGE_SWIPETIME_ADMIN"> 
					<input type="hidden" name="__help" value="">
					<input type="hidden" name="__helpReturn" value="">
					<input type="hidden" name="__helpName" value="">
					<input type="hidden" name="__pageCall" >
					<input type="hidden" name="__referPage" value="">
					<input type="hidden" name="__calendar">
					<script language="javascript">getInputFormatDate();</script>
					<input type="hidden" name="__companyid"  value="<%=screen.getUProfile().get("companyid")%>">
					<input type="hidden" name="__fixCon"  > 
					<input type="hidden" id="__language" name="__language" value="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__childFilter" >
					<input type="hidden" name="__empID" value="<%=screen.getString("employeeid")%>"> 
					<input type="hidden" name="__empName" value="<%=screen.getString("fullname")%>">   
					<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
					<script language="javascript">initToolTips();</script>
					
					<div class="csc-block">
						<div class="center">
							<h2 class="csc-block-head" swlang code='SW012470'>SET DAYOFF</h2>
						</div>

						<div class="form-horizontal">

							<div class="row">
								<div class="form-group">
									<div class="col-md-4 col-sm-4 col-xs-4">
										<label class="control-label label-right" swlang code='SW000274'>Employee ID</label>
									</div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<div class="input-group">
											<input type="text" class="form-control" name="__employeeid" id="__employeeid" value="<%=chk.chkNullString(request.getParameter("__employeeid")) %>" size="8">
											<a class="input-group-addon" href="javascript: goHelp('MEMPLOYEEHELP','__employeeid');">
												<i class="fa fa-search"></i>
											</a>
										</div>
									</div>
									<div class="col-md-3 col-sm-3 col-xs-3">
										<input type="text" class="form-control" name="MEMPLOYEE@FULLNAME" id="MEMPLOYEE@FULLNAME" size="40" value="<%=chk.chkNullString(request.getParameter("MEMPLOYEE@FULLNAME")) %>" readonly class="disabled">
									</div>
								</div>
							</div>

							<div class="row">
								<div class="form-group">
									<div class="col-md-4 col-sm-4 col-xs-4">
										<label class="control-label label-right" swlang code='SW000275'>Begin Date</label>
									</div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<% if (request.getParameter("date_start")==null) { %>									 
										<input class="form-control" name="date_start" type="text" value="<%="01-"+cs.getMM()+"-"+cs.getYear()%>"  maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,date_end)" onKeypress = "chkInteger()" >
										<% } else {%>
										<input class="form-control" name="date_start" type="text" value="<%=request.getParameter("date_start")%>" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,date_end)" onKeypress = "chkInteger()" >
										<% }%>
									</div>
									<div class="col-md-1 col-sm-1 col-xs-1">
										<label class="control-label label-right" swlang code='SW002095'>To</label>
									</div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<% if (request.getParameter("date_end")==null) { %>
										<input class="form-control" name="date_end" type="text" value="<%=cs.getDDMMYYYY()%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(date_start,this)" onKeypress = "chkInteger()" >
										<% } else {%>
										<input class="form-control" name="date_end" type="text" value="<%=request.getParameter("date_end")%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(date_start,this)" onKeypress = "chkInteger()" >
										<% }%>
									</div>
								</div>
							</div>
							
							<div class="center">
								<a class="btn btn-primary" href="javascript:search();" swlang code='SW003537'>Search</a>
							</div>
						</div>
					</div>

					<div class="table-responsive">
						<table class="table table-head table-hover table-bordered table-content-center">
							<thead>
								<tr>
									<th swlang code='SW001033'>Date</th>
									<th swlang code='SW000262'>Day</th>
									<th swlang code='SW001815'>Working Time</th>
									<th swlang code='SW001822'>SwipeTime</th>
									<th swlang code='SW000367'>Day Type</th>
									<th swlang code='SW001888'>Holiday</th>
								</tr>
							</thead>
							<tbody>
									<%
										if (!screen.getDataLabel("employeeid").equals("")) {
											//out.println("employeeid -->> "+screen.getDataLabel("employeeid"));
											//out.println("if test  emp-->> "+screen.inq.getCurrentDbRecord().getParam().get("ws"));
											if (screen.inq.getCurrentDbRecord().getParam().get("ws")!=null) {
												WorkingShift pws = (WorkingShift) screen.inq.getCurrentDbRecord().getParam().get("ws");
												//out.println("-->> "+pws);
												HashMap hm = new HashMap();
												try {
													DbInquiry inq = new InitialInquiry(screen.getUProfile()).getDbInquiry();
													inq.setSchemaName(screen.getUProfile().getSchemaName());
													inq.initMyTable("Meventgrp", "", "");
													inq.setColumn("*");
													inq.refresh();
													inq.referLangOn();
													while (inq.next()) {
														DbRecord rec = inq.getCurrentDbRecord();
														hm.put(rec.getString("eventgrpid"), rec.getString("tdesc"));								
													}
												} catch (Exception e) {}
												
												HashMap hmHoliday = new HashMap();
												try {
													DbInquiry inqHoliday = new InitialInquiry(screen.getUProfile()).getDbInquiry();
													inqHoliday.setSchemaName(screen.getUProfile().getSchemaName());
													inqHoliday.initMyTable("Mholiday1", "", "");
													inqHoliday.setColumn("*");
													
													DbInquiry inqTime = new InitialInquiry(screen.getUProfile()).getDbInquiry();
													inqTime.setSchemaName(screen.getUProfile().getSchemaName());
													inqTime.initMyTable("Mtime0", "time0id='"+screen.getDataLabel("time0")+"'", "");
													inqTime.setColumn("*");
													inqTime.putChild(inqHoliday);								
													inqTime.refresh();
													inqTime.referLangOn();
													while (inqTime.next()) {
														DbRecord rec = inqTime.getCurrentDbRecord();
														DbInquiry child = (DbInquiry) inqTime.getChild("Mholiday1");
														do {
															CscCalendar cHol = new CscCalendar(child.getString("hdate"));
															hmHoliday.put(cHol.getDDMMYYYY(), child.getString("tdesc"));
														} while (child.next());
													}
												} catch (Exception e) {}
												//out.println(hmHoliday);
									%>
									<%
												//ทำการหาข้อมูลการรูดบัตร
												CscCalendar c1 = new CscCalendar();
												CscCalendar c2 = new CscCalendar();
												if (request.getParameter("date_start")==null && request.getParameter("date_end")==null) { 
													c1 = new CscCalendar("01-"+cs.getMM()+"-"+cs.getYear());
													c2 = new CscCalendar(cs.getDDMMYYYY());
												} else {
													c1 = new CscCalendar(request.getParameter("date_start"));
													c2 = new CscCalendar(request.getParameter("date_end"));
												}
												MyHashMap hmSwipeTime = new MyHashMap();
												int count = 0;
												String tmpDate = "", swipeTime = "";
												inqSwipeTime.setFilter("employeeid='"+screen.getDataLabel("employeeid")+"' and (swipedate between '"+c1.getYYYYMMDD()+"' and '"+c2.getYYYYMMDD()+"')");
												inqSwipeTime.refresh();
												while (inqSwipeTime.next()) {
													if (count==0 || tmpDate.equals(inqSwipeTime.getString("swipedate"))) {
														swipeTime += " , "+df.format(inqSwipeTime.getCurrentDbRecord().getDouble("swipetime"));
													} else {
														if (!tmpDate.equals("") && !swipeTime.equals("")) {
															CscCalendar d = new CscCalendar(tmpDate);
															hmSwipeTime.put(d.getDDMMYYYY(), swipeTime.substring(3, swipeTime.length()));
															swipeTime = " , "+df.format(inqSwipeTime.getCurrentDbRecord().getDouble("swipetime"));
														}
													}
													count++;
													tmpDate = inqSwipeTime.getString("swipedate");
												}
												if (!tmpDate.equals("") && !swipeTime.equals("")) {
													CscCalendar d = new CscCalendar(tmpDate);
													hmSwipeTime.put(d.getDDMMYYYY(), swipeTime.substring(3, swipeTime.length()));
												}				
									%>
									<%
											CscTime ot = new CscTime();
											CscTime leave = new CscTime();						
											CscTime working = new CscTime();
											CscTime working_total = new CscTime();
											String cFont = "";
											String tmp = "";
											int rows = 1;
											for (Iterator IT = pws.keySet().iterator(); IT.hasNext(); ) {
												String key = (String) IT.next();
												DayShift dShift = (DayShift) pws.get(key);
												rows = dShift.size();
												for (Iterator IT1 = dShift.keySet().iterator(); IT1.hasNext(); ) {
													String key1 = (String) IT1.next();
													Shift sh = (Shift) dShift.get(key1);								

													cFont = "";
													if (sh.getEventGroup().equals("H")) {
														cFont ="week";
													} else if (sh.getEventGroup().equals("I")) {
														cFont = "holiday";
													}

													if (sh.getDocType().equals("O") || sh.getDocType().equals("B") || sh.getDocType().equals("OM")) { //ทำการบวกชม ที่ทำโอที
														ot.add(sh.getAp_ot());
														working_total.add(sh.getAp_ot());
													} else if (sh.getDocType().equals("A") || sh.getDocType().equals("S")) { //ทำการบวกชม ที่ลา
														leave.add(sh.getLv());
													} else { 
														working.add(sh.getHour_d());
														working_total.add(sh.getHour_d());
													}
												%>
								<tr> 
									<%
										String date = "";
										if (tmp.equals(sh.getShiftDate().getDDMMYYYY())) {
											date = "";
										} else date = sh.getShiftDate().getDDMMYYYY();
									%>
									
									<% if (rows>1 && !date.equals("")) { %>
									
									<td rowspan="<%=rows%>" class="<%=cFont%>"><%=date%></td>
									
									<% } else if (rows==1) { %>
									
									<td rowspan="<%=rows%>" class="<%=cFont%>"><%=date%></td>
									
									<% } %>
									 
									<%
										String day = "";
										if (tmp.equals(sh.getShiftDate().getDDMMYYYY())) {
											day = "";
										} else {
											if (((String) screen.getUProfile().get("lang")).equalsIgnoreCase("THA")) { //แสดงวันจันทร์ , อังคาร, พุธ เป็นต้น
												day = sh.getShiftDate().getDOWTHI(); 
											} else day = sh.getShiftDate().getDOWENG(); 
										}
									%>
									
									<% if (rows>1 && !date.equals("")) { %>
									
									<td rowspan="<%=rows%>" class="table-title <%=cFont%>"><%=day%></td>
									
									<% } else if (rows==1) { %>
									
									<td rowspan="<%=rows%>" class="table-title <%=cFont%>"><%=day%></td>
									
									<% } %>
									
									<td class="<%=cFont%>">
										<%=
											sh.getResult_c_dt_in().getDDMMYYYY()+" : "+df2.format(sh.getResult_c_dt_in().getCSCTime())+ " - "+
											sh.getResult_c_dt_out().getDDMMYYYY()+" : "+df2.format(sh.getResult_c_dt_out().getCSCTime())
										%>
									</td>
									
									<%	
										String txtSwipeTime = "";
										if (hmSwipeTime.containsKey(sh.getShiftDate().getDDMMYYYY())) {
											txtSwipeTime = hmSwipeTime.getString(sh.getShiftDate().getDDMMYYYY());
										} 
									%>
									
									<% if (rows>1 && !date.equals("")) { %>
									
									<td rowspan="<%=rows%>" class="<%=cFont%>"><%=txtSwipeTime%></td>
									
									<% } else if (rows==1) { %>
									
									<td rowspan="<%=rows%>" class="<%=cFont%>"><%=txtSwipeTime%></td>
									
									<% } %>
									
									<td class="<%=cFont%>">
										<%
											//out.println(sh.getEventGroup());
											if (sh.getTR_Type().indexOf("T")>-1 && (!sh.getDocType().equals("C") && !sh.getDocType().equals("E"))) {
												out.println();
											} else {
												if (sh.getEventGroup().equalsIgnoreCase("T"))	 { //ถ้าเป็นวันปกติ (T) ให้แสดงช่องว่าง
												out.println();
												} else	{ 
													String lv_type = (String) hm.get(sh.getEventGroup());
													if (lv_type==null ||  lv_type.equals("null"))  {
														out.println();
													} else { 
														if (sh.getEventGroup().equals("I")) {
															if (hmHoliday.get(sh.getShiftDate().getDDMMYYYY())!=null) {
																out.println(hmHoliday.get(sh.getShiftDate().getDDMMYYYY()));
															} else out.println(lv_type);
														} else out.println(lv_type);
													}
												}
											}
										%>
									</td>
									
									<td class="<%=cFont%>">
										<%if(!sh.getEventGroup().equals("I")){%>
	                                	<input type="checkbox" name="chk$<%=sh.getShiftDate().getYYYYMMDD()%>" value="<%=sh.getEventGroup()+"#"+sh.getTimeCode()+"#"+sh.getShiftDate().getYYYYMMDD()%>" <%=(sh.getEventGroup().equals("H")||sh.getEventGroup().equals("I"))?"checked":""%> onclick="setHoliday(this)">
										<%}%>
									</td>
								</tr>
								<%
									tmp = sh.getShiftDate().getDDMMYYYY();
									} //End for (Iterator IT1 = dShift.keySet().iterator(); IT1.hasNext(); )
									} //End for (Iterator IT = pws.keySet().iterator(); IT.hasNext(); )
									} //End if (screen.inq.getCurrentDbRecord().getParam().get("ws")!=null)
									} //End if (!screen.getDataLabel("employeeid").equals("")) 
								%> 
							</tbody>
						</table>
					</div>
				</form>
			</div>
			<a href="#top" id="top-button">
				<i class="fa fa-angle-up"></i>
				<div class="top-word">Back to top</div>
			</a>
		</section>
		<jsp:include page="FOOTER.jsp" flush="true" />
	</body>
</html>