MG_WORKINGTIME.jsp 15.8 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
<!DOCTYPE html>
<%@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"  %>
<%@page import="com.csc.library.timeattendance.DayShift,com.csc.library.timeattendance.Shift,com.csc.library.timeattendance.WorkingShift"  %>
<%@ 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);
	CheckNull chk = new CheckNull();
	String groupID = chk.chkNullString(request.getParameter("__subgroupid"));

	String empList = "";

	EmvHelpEntry screen = (EmvHelpEntry) EMV.process("EmvHelpEntry", "MG_WORKINGTIMEHELP");
	screen.inq.refresh();
	//screen.nextRec();

	while (screen.inq.next()) {
		empList += "'"+screen.inq.getString("employeeid")+"',";
	}
	if (!empList.equals("")) {
		empList =empList.substring(0, empList.length()-1);
	}
	//out.println("TOTAL ====>"+empList);
	CscCalendar c = new CscCalendar();
	FormulaString fs = new FormulaString();
	DecimalFormat df = new DecimalFormat("0.00");
	DecimalFormat df2 = new DecimalFormat("00.00");


	DbInquiry inqEmpTime = new InitialInquiry(screen.getUProfile()).getDbInquiry();
	inqEmpTime.initMyTable("Ttime_current1", "", "");
	inqEmpTime.setColumn("*");


%>
<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" />

		<style>
			.th-mini{
				padding-left:1px !important;
				padding-right:1px !important;
				font-size:14px !important;
				max-width:3px !important;
			}
			.th-nor{
				font-size:14px !important;
			}
			.table-title-mini{
				min-width:120px !important;
			}
			td{
				font-size:12px !important;
			}
		</style>

	</head>
	<body>
		<div class="bg-com"></div>
		<jsp:include page="EMV_HEADMENU.jsp" flush="true" />

		<script>
			setLang("<%=screen.getUProfile().get("lang")%>");
			var swap = new swaplang();
            var titlename = swap.swap2String("SW012476");
			setPageTitle(titlename);

			function goHelp(helpName,inputName){
				with(document.cscform){
					var helpReturn="";
					var fcon=__fixCon.value;
					var sub_value = "";
					if (inputName=="__subgroupid") {
						__fixCon.value = "employeeid='<%=EMV.getUProfile().get("employeeid")%>'";
						helpReturn = inputName+":groupid,__desc:edesc"
						linkHelp_Return(helpName,helpReturn);
					}
					__fixCon.value = "";
				}
			}

			function getMonthName(m){
				with(document.cscform){
					var monthName = "";
					var engMonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
					var thaiMonth = new Array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
					if (__language.value=='tha') {
						monthName = thaiMonth[parseInt(m)-1];
					} else monthName = engMonth[parseInt(m)-1];
					//alert(m+" "+engDate);
					document.write(monthName);
				}
			}

			function GoSearch(){
				with(document.cscform){
					if (__subgroupid.value=="") {
						__desc.value = "";
					}
					search();
				}
			}

			function alertData(emp, msg) {
				var message = msg.replace(/<br>/g,"\n");
				alert(emp+"\n"+message);
			}

			function pageDesc(empCode, empName){
				with(document.cscform){
					window.open("EMP_WORKINGTIME.jsp?__cmd="+
						"&__monthid="+__monthid.value+"&__yearid="+__yearid.value+
						"&__empID="+empCode+"&__empName="+empName,
						"Memployee","left=150,top=100,width=1100,height=500,toolbar=no,status=yes,scrollbars=yes,resizable=yes"
					);
					//submit();
				}
			}
		</script>

		<section>
			<div class="container csc-content">
				<form name="cscform" class="form-horizontal" method="post" action="MG_WORKINGTIME.jsp">
					<%=screen.InitialVariable() %>
					<input type="hidden" name="__cmd" value="">
					<input type="hidden" name="__screen"  value="MG_WORKINGTIME">
					<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">
					<input type="hidden" name="__companyid"  value="<%=screen.getUProfile().get("companyid")%>">
					<input type="hidden" name="__fixCon"  >
					<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__childFilter" >
					<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
					<script>initToolTips();</script>

					<div class="csc-block">
						<div class="center">
							<h2 class="csc-block-head" swlang code='SW012476'>Working Time Detail</h2>
						</div>

						<div class="form-horizontal">
							<div class="row">
								<div class="form-group">
									<div class="col-md-2 col-sm-2 col-xs-2"></div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW002085'>Subordinate Group </label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-2">
										<% if (request.getParameter("__subgroupid")!=null) { %>
										<div class="input-group">
											<input class="form-control" name="__subgroupid" type="text" value="<%=request.getParameter("__subgroupid")%>"/>
											<a class="input-group-addon" href="javascript:goHelp('MSUBORDINATE_GRPHELP','__subgroupid')">
												<i class="fa fa-search"></i>
											</a>
										</div>
										<% } else { %>
										<div class="input-group">
											<input class="form-control" name="__subgroupid" type="text" />
											<a class="input-group-addon" href="javascript:goHelp('MSUBORDINATE_GRPHELP','__subgroupid')">
												<i class="fa fa-search"></i>
											</a>
										</div>
										<% } %>
									</div>
									<div class="col-md-3 col-sm-3 col-xs-3">
										<% if (request.getParameter("__desc")!=null) { %>
										<input class="form-control" name="__desc" type="text" value="<%=request.getParameter("__desc")%>"/>
										<% } else { %>
										<input class="form-control" name="__desc" type="text" />
										<% } %>
									</div>
								</div>
							</div>

							<div class="row">
								<div class="form-group">
									<div class="col-md-2 col-sm-2 col-xs-2"></div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW000800'>Month </label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-2">
										<select class="form-control" name="__monthid">
											<%
												String m = "";
												if (request.getParameter("__monthid")!=null) {
													m = request.getParameter("__monthid");
												} else {
													m =c.getMM();
												}
											%>
											<option value="01" <% if (m.equals("01")) { %> selected <%}%> swlang code='SW012039'>January</option>
											<option value="02" <% if (m.equals("02")) { %> selected <%}%> swlang code='SW001840'>February</option>
											<option value="03" <% if (m.equals("03")) { %> selected <%}%> swlang code='SW001841'>March</option>
											<option value="04" <% if (m.equals("04")) { %> selected <%}%> swlang code='SW001842'>April</option>
											<option value="05" <% if (m.equals("05")) { %> selected <%}%> swlang code='SW001843'>May</option>
											<option value="06" <% if (m.equals("06")) { %> selected <%}%> swlang code='SW001844'>June</option>
											<option value="07" <% if (m.equals("07")) { %> selected <%}%> swlang code='SW001845'>July</option>
											<option value="08" <% if (m.equals("08")) { %> selected <%}%> swlang code='SW012040'>August</option>
											<option value="09" <% if (m.equals("09")) { %> selected <%}%> swlang code='SW001847'>September</option>
											<option value="10" <% if (m.equals("10")) { %> selected <%}%> swlang code='SW012041'>October</option>
											<option value="11" <% if (m.equals("11")) { %> selected <%}%> swlang code='SW011910'>November</option>
											<option value="12" <% if (m.equals("12")) { %> selected <%}%> swlang code='SW001850'>December</option>
										</select>
									</div>
									<div class="col-md-1 col-sm-1 col-xs-1">
										<label class="control-label label-right" swlang code='SW000717'>Year</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-2">
										<% if (request.getParameter("__yearid")!=null) { %>
										<input class="form-control" type="text" name="__yearid" value="<%=request.getParameter("__yearid")%>" size="5" maxlength="4" onkeypress="chkInteger()" onkeyup="formatYear(this)" onblur="chkTrueYear(this)">
										<% } else { %>
										<input class="form-control" type="text" name="__yearid" value="<%=c.getYear()%>" size="5" maxlength="4" onkeypress="chkInteger()" onkeyup="formatYear(this)" onblur="chkTrueYear(this)">
										<% }%>
									</div>
								</div>
							</div>
							<div class="center">
								<a class="btn btn-primary" swlang code="SW003537" href="javascript:GoSearch();">Search</a>
							</div>
						</div>
					</div>

					<div class="table-responsive">
						<table class="table table-head table-hover table-bordered table-title-left table-content-center">
							<thead>
								<% if (!empList.equals("")) { %>
								<%
									String month = request.getParameter("__monthid");
									String year = request.getParameter("__yearid");
									if (month==null || year==null || month.equals("") && year.equals("")) {
										CscCalendar cDate = new CscCalendar();
										month = cDate.getMM();
										year = String.valueOf(cDate.getYear());
									}

									if (month!=null && year!=null && !month.equals("") && !year.equals("")) {
										//out.println(">>>"+group+" >>>"+month+" >>>"+year);

										CscCalendar c1 = new CscCalendar("01"+"-"+month+"-"+year);
										int dayCount = c1.getEndDateOfMonth();
										double col_width = 64/dayCount;
										CscCalendar c2 = new CscCalendar(dayCount+"-"+month+"-"+year);
									%>
									<div align = "right" swlang code='SW013247'>unit : HH.MM</div>
								<tr>
									<th class="th-nor" swlang code="SW007745">Name Surname</th>
									<%
										String day;
										for (int i=1;i<=dayCount;i++ ) {
											if(i<=9){
												day="&nbsp;"+i;
											}else{

												day=""+i+"";
											}
									%>
									<th class="th-mini"><%=day%></th>
									<%
										}
									%>
									<th swlang code="SW000301">OT</th>
									<th swlang code="SW001859">LE</th>
								</tr>
							</thead>
							<tbody>
								<%
									CscCalendar mycalen = new CscCalendar();
									/*if (!chk.chkNullString(request.getParameter("__yearid"),"").equalsIgnoreCase("")){
										int param_year = Integer.parseInt(request.getParameter("__yearid"));
										mycalen.setYear(param_year);
									}

									if (!chk.chkNullString(request.getParameter("__monthid"),"").equalsIgnoreCase("")){
										int param_month = Integer.parseInt(request.getParameter("__monthid"));
										mycalen.setMonth(param_month);
									}*/

									mycalen.setDate(01);
									DbInquiry inqEmp = new InitialInquiry(screen.getUProfile()).getDbInquiry();
									inqEmp.initMyTable("Memployee", "employeeid in ("+empList+") AND (status ='A' OR status='V' OR (status='Y' AND resigndate>='"+mycalen.getYYYYMMDD()+"'))", "employeeid");
									inqEmp.setColumn("employeeid,companyid,fname,lname,efname,elname,emp_prefix,emp_level,time0,bu1,bu2,bu3,bu4,bu5");
									inqEmp.refresh();
									while (inqEmp.next()) {
										CscTime ctLEAVE = new CscTime(0);
										CscTime ctOT = new CscTime(0);
										DbRecord rec = inqEmp.getCurrentDbRecord();
										MyHashMap hmDate = new MyHashMap();
										String filter = "employeeid='"+rec.getString("employeeid")+"' "+
											" and (dateid between '"+c1.getYYYYMMDD()+"' and '"+c2.getYYYYMMDD()+"')";
										inqEmpTime.setFilter(filter);
										inqEmpTime.refresh();
										while (inqEmpTime.next()) {
											DbRecord recTime = inqEmpTime.getCurrentDbRecord();
											CscCalendar d = new CscCalendar(recTime.getString("dateid"));
											MyHashMap hm = new MyHashMap();
											hm.put("LATE", df.format(recTime.getDouble("lt")));
											hm.put("LEAVE", df.format(recTime.getDouble("m_lv")));
											hm.put("OT", df.format(recTime.getDouble("ac_ot")));
																		hm.put("LEAVE_TYPE", recTime.getString("lv_ty"));
																		hm.put("DOCTYPE", recTime.getString("doctype"));
											hm.put("EVENTGRP", recTime.getString("eventgrp"));
											hmDate.put(d.getDDMMYYYY(), hm);
										} //End while (inqEmpTime.next())

										String emp = rec.getString("employeeid")+" : "+rec.getString("fullname");
								%>
								<tr>
									<td class="table-title table-title-mini"><a href="javascript:pageDesc('<%=rec.getString("employeeid")%>','<%=rec.getString("fullname")%>')"><%=emp%></a></td>
									<%
										for (int i=1;i<=dayCount;i++ ) {
											String sign = "";
											String holiday = "";
											CscCalendar cLoop = new CscCalendar(i+"-"+month+"-"+year);
											if (hmDate.get(cLoop.getDDMMYYYY())!=null) {
												MyHashMap hLoop = (MyHashMap) hmDate.get(cLoop.getDDMMYYYY());
												if (hLoop.getString("DOCTYPE").equals("A")) {
													sign += "L";
													ctLEAVE.add(hLoop.getDouble("LEAVE"));
												}

												if (hLoop.getDouble("OT")>0) {
													sign += "O";
													ctOT.add(hLoop.getDouble("OT"));
												}

												if (hLoop.getString("EVENTGRP").equals("J")) {
													sign = "A";
												}

												if (hLoop.getString("LEAVE_TYPE").equals("T")) {
													holiday = "present";
												}

												if (hLoop.getString("EVENTGRP").equals("H")) {
													holiday = "dayoff";

												} else if (hLoop.getString("EVENTGRP").equals("I")) {
													holiday = "annual-holiday";
												}
											} else {
												sign = "*";
											}//end if
									%>
									<td class="<%=holiday%>"><%=sign%></td>
									<%
										}
									%>
									<td><%=ctOT.getFloat()%></td>
									<td><%=ctLEAVE.getFloat()%></td>
								</tr>
								<%
									} //End while (inqEmp.next())
								%>
								<%
									} //End if (group!=null && month!=null && year!=null && !group.equals("") && !month.equals("") && !year.equals(""))
								%>
								<%
									} //End if (!empList.equals(""))
								%>

								<tr>
									<td class="table-title" colspan=35>
										* = <label swlang code="SW002194">NO DATA</label>,
										L = <label swlang code="SW002189">LEAVE</label>,
										A = <label swlang code="SW001880">ABSENT</label>,
										O = <label swlang code="SW002191">OVERTIME</label>,
										<span class="highlight-present"></span> &nbsp;= <label swlang code="SW002188">PRESENT</label>,
										<span class="highlight-dayoff"></span> &nbsp;= <label swlang code="SW011611">DAY OFF</label>,
										<span class="highlight-holiday"></span> &nbsp;= <label swlang code="SW002193">ANNUAL HOLIDAY</label>
									</td>
								</tr>
							</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>