EMP_WORKINGTIME_CHKWK.jsp 19.3 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 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@page import="com.csc.library.entry.HelpEntry,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"  %>
<%@ include file="../CHECKPROFILE.jsp" %>
<%@page import="java.text.DecimalFormat"  %>
<% 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);	
	ThaiUtilities thaicode=new ThaiUtilities();
	CheckNull chk = new CheckNull();
	String empID = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__empID")));
	String empName = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__empName")));
	String month = chk.chkNullString(request.getParameter("__monthid"));
	String year = chk.chkNullString(request.getParameter("__yearid"));
	CscCalendar startDate = new CscCalendar("01-"+month+"-"+year);
	CscCalendar endDate = new CscCalendar(startDate.getEndDateOfMonth()+"-"+month+"-"+year);
	HelpEntry screen = (HelpEntry)EMV.process("HelpEntry", "EMP_WORKINGTIMEHELP"); 	
	screen.inq.setFilter("employeeid = '"+empID+"' and (dateid between '"+startDate.getYYYYMMDD()+"' and '"+endDate.getYYYYMMDD()+"')");
	//screen.inq.refresh();	
	//screen.nextRec();
	screen.process();
	
	CscCalendar cs = new CscCalendar();
	DecimalFormat df = new DecimalFormat("0.00");
	DecimalFormat df2 = new DecimalFormat("00.00");
	FormulaString fs = new FormulaString();

	HashMap hmTimetemp = getTimeTemp(screen.getUProfile()
							, empID
							, new CscCalendar(startDate.getYYYYMMDD()).decDate(1)
							, new CscCalendar(endDate.getYYYYMMDD()).incDate(1));
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myHR">
<html>
<title>Employee View</title>
	<head>
		<link rel="stylesheet" href="<%=request.getContextPath()%>/CSS/font-awesome.css">
		<link rel="stylesheet" type="text/css" href="../CSS/Bootstrap/css/bootstrap.css" />
		<link rel="stylesheet" type="text/css" href="../CSS/EMPVIEW_LAYOUT.min.css" />
		
		<script type="text/javascript" src="../JS/EVENTS.js"></script>
		<script type="text/javascript" src="../JS/DDMENU.js"></script>
		<script type="text/javascript" src="../JS/UTILITIES.js"></script>
		<script type="text/javascript" src="../JS/ACTIVE_OBJECT.js"></script>
		<script type="text/javascript" src="../JS/SCREEN.js"></script>
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
		<script type="text/javascript" src="../JS/angular-1.3.15/angular.js"></script>
		<script type="text/javascript" src="../JS/ANGULAR/SCREEN_ANGULAR.js"></script>

		<script>
			setLang('<%=screen.getUProfile().get("lang")%>');
			var swap = new swaplang();
            var titlename = swap.swap2String("SW011251");
			setPageTitle(titlename);
	
		</script>
	</head>
	
	<body>
		<div class="bg-com"></div>
			<div class="container csc-content">
				<form name="cscform" class="form-horizontal" method="post">
					<input type="hidden" name="__screen"  value="EMV_WORKINGTIME">
					<input type="hidden" name="__fixCon" value="<%=request.getParameter("__fixCon")%>">
					<input type="hidden" name="__cmd"  value="">
					<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__companyid" value='<%=screen.getUProfile().get("companyid")%>'>
					<input type="hidden" name="__employeeid" value="<%=request.getParameter("__empID")%>">
					<input type="hidden" name="__referPage" value="">
					<input type="hidden" name="__childFilter">
					<input type="hidden" name="__gorec">
					<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
					<script language="javascript">initToolTips();</script> 
					
					<div class="csc-block-white">
						<div class="center">
							<h4><label swlang code='SW011251'>Working Time History Detail</label> <label swlang code='SW001838'>of</label> <label swlang code='SW000307'>Employee</label> : <%=empID%>&nbsp;&nbsp;<%=empName %> </h4>
						</div>
						<div class="container csc-content">
							<table class="table table-head table-hover table-bordered table-title-left table-content-center">
								<thead>
									<tr>
										<th class="table-title" colspan=16 >
											<%
												if (startDate!=null && !startDate.equals("") && endDate!=null && !endDate.equals("")) {
													if (screen.getUProfile().get("lang").equals("tha")) {
														out.println(startDate.getThaiFull()+" - "+endDate.getThaiFull());
													} else {
														out.println(startDate.getEngFull()+" - "+endDate.getEngFull());
													}
												} 
											%>
										</th>
									</tr>
									<tr>
										<th swlang code='SW000002'>Date</th> 
										<th swlang code='SW000262'>Day</th>  
										<th swlang code='SW001815'>Working Time</th>  
										<th swlang code='SW001822'>SwipeTime</th>  
										<th>Device No</th>
										<th swlang code='SW000367'>Day Type</th>  
										<th swlang code='SW000055'>Late</th>  
										<th swlang code='SW000056'>Absent</th>  
										<th swlang code='SW000299'>Leave</th>  
										<th swlang code='SW000301'>OT</th> 
										<th swlang code='SW001882'>OT1</th> 
										<th swlang code='SW001883'>OT5</th> 
										<th swlang code='SW001884'>OT2</th> 
										<th swlang code='SW001885'>OT3</th> 
										<th swlang code='SW001886'>Work</th>  
										<th swlang code='SW001887'>Other</th> 
									</tr>
								</thead>
								<tbody>
									<%
										HashMap hmHoliday = new HashMap();
										String wkarea = "";
										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", "", "");
											inqTime.setColumn("*");
											inqTime.putChild(inqHoliday);					
											
											DbInquiry inqEmp = new InitialInquiry(screen.getUProfile()).getDbInquiry();
											inqEmp.setSchemaName(screen.getUProfile().getSchemaName());
											inqEmp.initMyTable("Memployee", "employeeid='"+request.getParameter("__empID")+"'", "");
											inqEmp.setColumn("*");
											inqEmp.putChild(inqTime);								
											inqEmp.refresh();
											while (inqEmp.next()) {
																		inqEmp.referLangOn();
												DbInquiry childTime =  (DbInquiry) inqEmp.getChild("Mtime0");
												DbInquiry child = (DbInquiry) childTime.getChild("Mholiday1");
												do {
													CscCalendar cHol = new CscCalendar(child.getString("hdate"));
													hmHoliday.put(cHol.getDDMMYYYY(), child.getString("tdesc"));
												} while (child.next());

												wkarea = inqEmp.getString("workarea");
											}
										} catch (Exception e) {}
										//out.println(hmHoliday);
									%>       
									<%
										String holiday = "";
										CscTime ct_late = new CscTime();
										CscTime ct_absent = new CscTime();
										CscTime ct_leave = new CscTime();
										CscTime ct_ot = new CscTime();
										CscTime ct_ot1 = new CscTime();
										CscTime ct_ot5 = new CscTime();
										CscTime ct_ot2 = new CscTime();
										CscTime ct_ot3 = new CscTime();
										CscTime ct_work = new CscTime();
										while (screen.nextRec()) {	
																screen.referLangOn();
											DbRecord rec = screen.inq.getCurrentDbRecord();
											CscCalendar cDate = new CscCalendar(rec.getString("dateid"));
											String day = "", cFont  = "";
											if (((String) screen.getUProfile().get("lang")).equalsIgnoreCase("THA")) { //แสดงวันจันทร์ , อังคาร, พุธ เป็นต้น
												day = cDate.getDOWTHI(); 
											} else day = cDate.getDOWENG(); 
											if (rec.getString("eventgrp").equals("H")) {
												cFont = "week";
											} else if (rec.getString("eventgrp").equals("I")) {
												cFont = "holiday";
												String tmp = ((String) hmHoliday.get(cDate.getDDMMYYYY()));
												if (tmp==null) tmp="";
												holiday += cDate.getDDMMYYYY()+" "+tmp+", ";
											} else if (rec.getString("eventgrp").equals("J")) {
												cFont = "absent";
											}	
											
											String in_mchinno = getMachinnoHTML(getMachinNoByInOut(rec.getString("m_dt_bg"), rec.getString("m_tm_bg"), hmTimetemp)
																						, isValidWorkarea(
																								rec.getString("m_dt_en")
																								, rec.getString("m_tm_bg") 
																								, getMachineNoByWorkArea(wkarea)
																								, hmTimetemp));

											String out_mchinno = getMachinnoHTML(getMachinNoByInOut(rec.getString("m_dt_bg"), rec.getString("m_tm_en"), hmTimetemp)
																						, isValidWorkarea(
																								rec.getString("m_dt_en")
																								, rec.getString("m_tm_en") 
																								, getMachineNoByWorkArea(wkarea)
																								, hmTimetemp));
									%>
									<tr>
										<td class="<%=cFont%>"><%=cDate.getDDMMYYYY()%></td>
										<td class="<%=cFont%>"><%=day%></td>
										<td class="<%=cFont%>"><%=df2.format(rec.getDouble("c_tm_bg"))%> - <%=df2.format(rec.getDouble("c_tm_en"))%></td>
										<td class="<%=cFont%>">
											<%
												String time_in = "";
												String time_out = "";
												if (rec.getString("forget_in").equals("1")) {
													time_in = "__-__";
												} else time_in = df2.format(rec.getDouble("m_tm_bg"));
												if (rec.getString("forget_out").equals("1")) {
													time_out = "__-__";
												} else time_out = df2.format(rec.getDouble("m_tm_en"));
												out.println(time_in+" - "+time_out);
											%>
										</td>
										<!-- columns device no -->
										<td><%=in_mchinno + " - " + out_mchinno%></td>
										<td class="<%=cFont%>">
											<%
												String lv_type = (String) screen.getString("meventgrp","tdesc");
												if (lv_type==null ||  lv_type.equals("null"))  {
													out.println();
												} else { 
													if (rec.getString("eventgrp").equals("I")) {
														if (hmHoliday.get(cDate.getDDMMYYYY())!=null) {
															out.println(hmHoliday.get(cDate.getDDMMYYYY()));
														} else out.println(lv_type);
													} else out.println(lv_type);
												}
											%>
											<%/* if (rec.getString("eventgrp").equals("H") || rec.getString("eventgrp").equals("I")) { */%>
												<!-- <script language="javascript">swapLang('Holiday')</script> -->
											<%/* } else { 
												out.println(screen.getString("meventgrp","tdesc"));
											 }*/ %>
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getDouble("lt")>0) { 
													ct_late.add(rec.getDouble("lt"));
													out.println(df.format(rec.getDouble("lt")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getString("eventgrp").equals("J") && rec.getDouble("m_lv")>0) { 
													ct_absent.add(rec.getDouble("m_lv"));
													out.println(df.format(rec.getDouble("m_lv")));
												} 
											%>
										</td>
										<td class="<%=cFont%>">
											<% 
												if (!rec.getString("eventgrp").equals("J") && rec.getDouble("m_lv")>0) { 
													ct_leave.add(rec.getDouble("m_lv"));
													out.println(df.format(rec.getDouble("m_lv")));
												} 
											%>
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getDouble("ac_ot")>0) { 
													ct_ot.add(rec.getDouble("ac_ot"));
													out.println(df.format(rec.getDouble("ac_ot")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getDouble("ot1")>0) { 
													ct_ot1.add(rec.getDouble("ot1"));
													out.println(df.format(rec.getDouble("ot1")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% 
												//nuiss edit 15/10/2551
												//กำหนดตัวแปร ผิดนิดเดียว เอา ct_ot1 มารับ แก้เป็น ct_ot5
												if (rec.getDouble("ot5")>0) { 
													ct_ot5.add(rec.getDouble("ot5"));
													out.println(df.format(rec.getDouble("ot5")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getDouble("ot2")>0) { 
													ct_ot2.add(rec.getDouble("ot2"));
													out.println(df.format(rec.getDouble("ot2")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getDouble("ot3")>0) { 
													ct_ot3.add(rec.getDouble("ot3"));
													out.println(df.format(rec.getDouble("ot3")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% 
												if (rec.getDouble("hour_d")>0) { 
													ct_work.add(rec.getDouble("hour_d"));
													out.println(df.format(rec.getDouble("hour_d")));
												} 
											%> 
										</td>
										<td class="<%=cFont%>">
											<% if (rec.getDouble("unused1")>0) { %>
											<span class="status-default"></span>
											<% } %>
											<% if (rec.getDouble("unused2")>0) { %>
											<span class="status-wait"></span>
											<% } %>
											<% if (rec.getDouble("unused3")>0) { %>
											<span class="status-notapprove"></span>
											<% } %>
											<% if (rec.getDouble("unused4")>0) { %>
											<span class="status-timeover"></span>
											<% } %>
											<% if (rec.getDouble("unused5")>0) { %>
											<span class="status-approve"></span>
											<% } %>
										</td>
									</tr>
									<%
										} //while (screen.inq.next()) 
									%> 
									<tr>  <!-- Display Summary -->
										<td class="result-right" colspan="6" swlang code='SW000024'>Total</td>
										<td class="result"><%=(ct_late.getFloat()==0)?"":df.format(ct_late.getFloat())%></td>
										<td class="result"><%=(ct_absent.getFloat()==0)?"":df.format(ct_absent.getFloat())%></td>
										<td class="result"><%=(ct_leave.getFloat()==0)?"":df.format(ct_leave.getFloat())%></td>
										<td class="result"><%=(ct_ot.getFloat()==0)?"":df.format(ct_ot.getFloat())%></td>
										<td class="result"><%=(ct_ot1.getFloat()==0)?"":df.format(ct_ot1.getFloat())%></td>
										<td class="result"><%=(ct_ot5.getFloat()==0)?"":df.format(ct_ot5.getFloat())%></td>
										<td class="result"><%=(ct_ot2.getFloat()==0)?"":df.format(ct_ot2.getFloat())%></td>
										<td class="result"><%=(ct_ot3.getFloat()==0)?"":df.format(ct_ot3.getFloat())%></td>
										<td class="result"><%=(ct_work.getFloat()==0)?"":df.format(ct_work.getFloat())%></td>
										<td class="result"> </td>
									</tr>
									<%
										String color1 = "", color2 = "", color3= "", color4 = "", color5 = "";
										try {
											color1 = (String) StaticConfig.getConfigCompany(screen.getUProfile(), "ta1021");
											color2 = (String) StaticConfig.getConfigCompany(screen.getUProfile(), "ta1022");
											color3 = (String) StaticConfig.getConfigCompany(screen.getUProfile(), "ta1023");
											color4 = (String) StaticConfig.getConfigCompany(screen.getUProfile(), "ta1024");
											color5 = (String) StaticConfig.getConfigCompany(screen.getUProfile(), "ta1025");
										} catch (Exception e) {}
									%>
									<!--tr>
										<td class="table-title" colspan="15">
											<div class="list-status">
												<span class="status-timeover"><%=color1%>,</span>      
												<span class="status-wait"><%=color2%>,</span>			
												<span class="status-notapprove"><%=color3%>,</span>		
												<span class="status-default"><%=color4%>,</span>		
												<span class="status-approve"><%=color5%></span>			
											</div>
										</td>
									</tr-->
									<tr>
										<td class="table-title" colspan="16"><label><%=holiday%></label></td>
									</tr>
								</tbody>
							</table>
							<div class="center">
								<a class="btn btn-primary" swlang code="SW012104" onclick="javascript:window.close()">Close</a>
							</div>
						</div>
					</div>
				</form>
			</div>
	</body>
</html>
<%!
private HashMap getTimeTemp(UProfile upf, String emp, CscCalendar st, CscCalendar en) {
	HashMap hm = new HashMap();
	try {
		DbInquiry inq = new InitialInquiry(upf).getDbInquiry("Ttimetemp");
		inq.setColumn("employeeid,companyid,swipedate,swipetime,machinno");
		inq.setFilter("employeeid = '" + emp + "' and swipedate between '" + st.getYYYYMMDD() + "' and '" + en.getYYYYMMDD() + "'");
		inq.refresh();

		while(inq.next()){
			CscCalendar cs = new CscCalendar(inq.getString("swipedate"));
			cs.setCSCTime(Float.parseFloat(inq.getString("swipetime")));
			hm.put(cs.getYYYYMMDDHHMMSS() , inq.getString("machinno"));
		}
	}catch(Exception e){
		e.printStackTrace();
	}
	return hm ;
}

private String getMachinnoHTML(String punch, boolean status){
	try {
		if(punch.equals("")){
			punch = "__.__";
		}

		if(punch.equals("__.__")){
			return "<font>" + punch + "</font>"; 
		}

		if(status){
			return "<font color='blue'>" + punch + "</font>"; 
		}else{
			return "<font color='red'>" + punch + "</font>"; 
		}
	}catch(Exception e){
		e.printStackTrace();
	}
	return "" ;
}

private boolean isValidWorkarea(String date, String inout, List lArea, HashMap hmTime){
	try {
		if(inout.equals("__.__") || inout.equals("")){
			return true ;
		}
		
		String machineno = getMachinNoByInOut(date, inout, hmTime);

		if(!machineno.equals("")) {
			if(lArea != null) {
				for(int i=0; i < lArea.size(); i++){
					if(machineno.equals(lArea.get(i))){
						return true ;
					}
				}
			}
		}
	}catch(Exception e){
		e.printStackTrace();
	}
	return false ;
}

private String getMachinNoByInOut(String date, String inout, HashMap hmTime){
	try {
		if(inout.equals("__.__") || inout.equals("")){
			return "__.__" ;
		}

		CscCalendar punch = new CscCalendar(date);
		punch.setCSCTime(Float.parseFloat(inout));

		String key = punch.getYYYYMMDDHHMMSS()  ;
		if(hmTime.containsKey(key)){
			return (String) hmTime.get(key);
		}
	}catch(Exception e){
		e.printStackTrace();
	}
	return "";
}

private List getMachineNoByWorkArea(String area){
	
	try {
		List l = new ArrayList<String>();
		if(area.equals("BKK") || area.equals("1") || area.equals("2") || area.equals("NONE")){
			l.add("001");
			l.add("0001");
			l.add("00001");
			l.add("002");
			l.add("0002");
			l.add("00002");
		}else if(area.equals("OEI")){
			l.add("003");
			l.add("0003");
			l.add("00003");
			l.add("004");
			l.add("0004");
			l.add("00004");
		}else if(area.equals("SSI")){
			l.add("005");
			l.add("0005");
			l.add("00005");
			l.add("006");
			l.add("0006");
			l.add("00006");
		}else if(area.equals("KIP")){
			l.add("007");
			l.add("0007");
			l.add("00007");
			l.add("008");
			l.add("0008");
			l.add("00008");
		}

		return l;
	}catch(Exception e){
		e.printStackTrace();
	}

	return null ;
}


	
%>