<!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" %> <%@page import="java.text.DecimalFormat,com.csc.library.database.MyHashMap" %> <%@ 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); String empList = ""; EmvHelpEntry screen = (EmvHelpEntry) EMV.process("EmvHelpEntry", "MG_TIMEHELP"); screen.inq.setFilter("status in (select statuscode from mempl_status where statustype = 'A')"); screen.inq.refresh(); //screen.nextRec(); while (screen.inq.next()) { empList += "'"+screen.inq.getString("employeeid")+"',"; } if (!empList.equals("")) { empList =empList.substring(0, empList.length()-1); } CscCalendar cs=new CscCalendar(); FormulaString fs = new FormulaString(); DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df2 = new DecimalFormat("00.00"); CheckNull chkNull = CheckNull.getInstance(); String showswipetype = chkNull.chkNullString(request.getParameter("showswipetype")); //String empID = EMV.getUProfile().getEmvEmpId(); DbInquiry inqSwipeTime = new InitialInquiry(screen.getUProfile()).getDbInquiry(); inqSwipeTime.initMyTable("Ttimetemp", "", "employeeid,swipedate,swipetime"); inqSwipeTime.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=TIS620" /> </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("SW012374"); 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:-1, defaultDate:-1, changeMonth: true, changeYear: true }); $("input[name=date_end]").datepicker("destroy"); }); $("input[name=date_end]").change(function(){ console.log(chkInputDateString($("input[name=date_start]"),$("input[name=date_end]"))); // console.log($("input[name=date_start]").val()); // console.log($("input[name=date_end]").val()); // console.log($("input[name=date_start]").val()>$("input[name=date_end]").val()); // 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 }); }); showSwipeType(); $("input[name='showswipetype']").on("change", function(){ showSwipeType(); }); function showSwipeType() { let isChecked = $("input[name='showswipetype']").prop("checked"); if(isChecked) { $(".swipetype").show(); } else { $(".swipetype").hide(); } } }); function chkInputDateString(obj1,obj2) { var temp1 = obj1.val(); var temp2 = obj2.val(); // console.log(temp1); // console.log(temp2); var tempdate1 = obj1.val().split("-"); var tempdate2 = obj2.val().split("-"); var chk = true; if (obj1.val() == "") { if(obj2.val() == "" ) { obj1.val() = datePresent(); } else { obj1.val(obj2.val()) ; } } if (obj2.val() == "") { if(obj1.val() == "" ) { obj2.val() = datePresent(); } else { obj2.val(obj1.val()) ; } } if (!chkInputDate(obj1[0])) { chk = false; obj1.focus(); } else if (!chkInputDate(obj2[0])) { chk = false; obj2.focus(); } else if (!checkFdateEdate(obj1.val(),obj2.val())) { obj2.val(obj1.val()) ; chk = false; obj2.focus(); //alert(MyCode[119]); } return chk; } function goHelp(helpName,inputName){ //alert(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 GoSearch(){ with(document.cscform){ if (__subgroupid.value=="") { __desc.value = ""; } search(); } } function pageDesc(empCode, empName){ with(document.cscform){ var a=chkDateTime1(date_start.value); var b=chkDateTime1(date_end.value); //alert(date1.value+"==="+date2.value); //alert(__fixCon.value); window.open("EMP_SWIPETIME.jsp?__cmd="+ "&__date_start="+a+"&__date_end="+b+ "&date_start="+a+"&date_end="+b+ "&__empID="+empCode+"&__empName="+empName+ "&showswipetype="+showswipetype.checked, "Memployee","left=50,top=50,width=900,height=650,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_SWIPETIME.jsp"> <%=screen.InitialVariable()%> <input type="hidden" name="__cmd" value=""> <input type="hidden" name="__screen" value="MG_SWIPETIME"> <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" 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='SW013324'>Punch Time Report</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" class="text" size="15" 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" class="text" size="15" /> <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" class="text" size="60" value="<%=request.getParameter("__desc")%>"/> <% } else { %> <input class="form-control" name="__desc" type="text" class="text" size="60" /> <% } %> </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='SW000275'>Begin Date</label> </div> <div class="col-md-2 col-sm-2 col-xs-2"> <% if (request.getParameter("date_start")==null) { CscCalendar csNow = new CscCalendar(); csNow.decDate(5); %> <input class="form-control" name="date_start" type="text" value="<%=csNow.getDDMMYYYY()%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,date_end)" onKeypress = "chkIntegerOfDate(this.value)"> <% } else {%> <input class="form-control" name="date_start" type="text" value="<%=request.getParameter("date_start")%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,date_end)" onKeypress = "chkIntegerOfDate(this.value)"> <% }%> </div> <div class="col-md-1 col-sm-1 col-xs-1"> <label class="control-label label-right" swlang code='SW002379'>To Date</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 = "chkIntegerOfDate(this.value)"> <% } 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 = "chkIntegerOfDate(this.value)"> <% }%> </div> </div> </div> <div class="center"> <span><input type="checkbox" name="showswipetype" value="1" <%if(showswipetype.equals("1")){%>checked<%}%>> แสดงสถานะเวลาทำงาน (I=ขาเข้า, O=ขาออก)</span> </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> <tr> <th class="table-title" colspan=7> <% String group = request.getParameter("__subgroupid"); CscCalendar c1 = new CscCalendar(); CscCalendar c2 = new CscCalendar(); if (request.getParameter("date_start")==null && request.getParameter("date_end")==null) { c1.decDate(5); } else { c1 = new CscCalendar(request.getParameter("date_start")); c2 = new CscCalendar(request.getParameter("date_end")); } if (screen.getUProfile().get("lang").equals("tha")) { out.println(c1.getThaiFull()+" - "+c2.getThaiFull()); } else { out.println(c1.getEngFull()+" - "+c2.getEngFull()); } %> </th> </tr> </thead> <% if (!empList.equals("")) { %> <!-- Select Employee WorkingShift and SwipeTime To HashMap --> <% HashMap hmEvent = new HashMap(); // try { DbInquiry inq = new InitialInquiry(screen.getUProfile()).getDbInquiry(); inq.setSchemaName(screen.getUProfile().getSchemaName()); inq.initMyTable("Meventgrp", "", ""); inq.setColumn("*"); inq.referLangOn(); inq.refresh(); while (inq.next()) { DbRecord rec = inq.getCurrentDbRecord(); hmEvent.put(rec.getString("eventgrpid"), rec.getString("tdesc")); } } catch (Exception e) {} //out.println("===>"+empList); Vector vEmp = new Vector(); MyHashMap hmEmpName = new MyHashMap(); //เก็บชื่อของพนักงาน MyHashMap hmEmpData = new MyHashMap(); //เก็บข้อมูลต่างๆ ในการทำงานของพนักงาน HashMap param = new HashMap(); param.put("date_start", c1.getDDMMYYYY()); param.put("date_end", c2.getDDMMYYYY()); DbInquiry inqEmp = new InitialInquiry(screen.getUProfile()).getDbInquiry(); inqEmp.setParam(param); inqEmp.setSchemaName(screen.getUProfile().getSchemaName()); inqEmp.initMyTable("Memployee_worktime1", "employeeid in ("+empList+")", "employeeid"); //inqEmp.initMyTable("Memployee_worktime1", "employeeid='M01'", "employeeid"); inqEmp.setColumn("employeeid, emp_prefix, fname, lname, efname, elname, time0, runno, bossid, bu1, bu2, bu3, bu4, bu5, companyid, status, startdate, resigndate, emp_group, emp_level"); inqEmp.refresh(); while (inqEmp.next()) { vEmp.add(inqEmp.getString("employeeid")); hmEmpName.put(inqEmp.getString("employeeid"), inqEmp.getString("fullname")); //ทำการหาข้อมูลการรูดบัตร MyHashMap hmSwipeTime = new MyHashMap(); int count = 0; String tmpDate = "", swipeTime = ""; inqSwipeTime.setFilter("employeeid='"+inqEmp.getString("employeeid")+"' and (swipedate between '"+c1.getYYYYMMDD()+"' and '"+c2.getYYYYMMDD()+"')"); inqSwipeTime.refresh(); while (inqSwipeTime.next()) { String swipeTypeDesc = inqSwipeTime.getString("SWIPETYPE").equals("0")?"(I)":"(O)"; swipeTypeDesc = "<span class='swipetype' style='display:none'>"+swipeTypeDesc+"</span>"; if (count==0 || tmpDate.equals(inqSwipeTime.getString("swipedate"))) { swipeTime += " , "+df.format(inqSwipeTime.getCurrentDbRecord().getDouble("swipetime")) + swipeTypeDesc; } 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")) + swipeTypeDesc; } } count++; tmpDate = inqSwipeTime.getString("swipedate"); } if (!tmpDate.equals("") && !swipeTime.equals("")) { CscCalendar d = new CscCalendar(tmpDate); hmSwipeTime.put(d.getDDMMYYYY(), swipeTime.substring(3, swipeTime.length())); } //out.println(inqEmp.getString("employeeid")+" "+hmSwipeTime+"<br>"); MyHashMap hmDayShift = new MyHashMap(); WorkingShift pws = (WorkingShift) inqEmp.getCurrentDbRecord().getParam().get("ws"); if (pws!=null && !pws.isEmpty()) { for (Iterator IT = pws.keySet().iterator(); IT.hasNext(); ) { String key = (String) IT.next(); DayShift dShift = (DayShift) pws.get(key); //MyHashMap hmShift = new MyHashMap(); MyTreeMap trShift = new MyTreeMap(); int i=1; for (Iterator IT1 = dShift.keySet().iterator(); IT1.hasNext(); ) { String key1 = (String) IT1.next(); Shift sh = (Shift) dShift.get(key1); MyHashMap hm = new MyHashMap(); //วันที่ของกะนั้น hm.put("date", sh.getShiftDate().getDDMMYYYY()); //รหัสของกะนั้น hm.put("time0id", sh.getTimeCode()); //วันของกะนั้น จันทร์ , อังคาร, พุธ เป็นต้น if (((String) screen.getUProfile().get("lang")).equalsIgnoreCase("THA")) { hm.put("day", sh.getShiftDate().getDOWTHI()); } else hm.put("day", sh.getShiftDate().getDOWENG()); //วันเวลาของกะนั้น //hm.put("workingtime", 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())); hm.put("workingtime", df2.format(sh.getResult_c_dt_in().getCSCTime())+" - "+df2.format(sh.getResult_c_dt_out().getCSCTime())); //เวลาที่รูดบัตร if (hmSwipeTime.containsKey(sh.getShiftDate().getDDMMYYYY())) { hm.put("swipetime", hmSwipeTime.getString(sh.getShiftDate().getDDMMYYYY())); } else hm.put("swipetime", ""); //ประเภทวัน String type = ""; if (sh.getTR_Type().indexOf("T")>-1 && (!sh.getDocType().equals("C") && !sh.getDocType().equals("E"))) { type = ""; } else { if (sh.getEventGroup().equalsIgnoreCase("T")) { //ถ้าเป็นวันปกติ (T) ให้แสดงช่องว่าง type = ""; } else { type = sh.getEventGroup(); } } hm.put("eventgrp", type); //จำนวนชม ที่ลา หรือที่ขอโอที if (sh.getLv()==0 && sh.getAp_ot()==0) { //ถ้า ชม ลา หรือ ชม โอที = 0 ให้แสดงช่องว่าง hm.put("total_hour", df.format(sh.getHour_d())); hm.put("lv_hour", "0"); hm.put("ot_hour", "0"); } else if (sh.getLv()>0) { hm.put("total_hour", df.format(sh.getLv())); hm.put("lv_hour", df.format(sh.getLv())); hm.put("ot_hour", "0"); } else if (sh.getAp_ot()>0) { hm.put("total_hour", df.format(sh.getAp_ot())); hm.put("lv_hour", "0"); hm.put("ot_hour", df.format(sh.getAp_ot())); } //hmShift.put(String.valueOf(i), hm); trShift.put(Integer.valueOf(String.valueOf(i)), hm); i++; } //End for (Iterator IT1 = dShift.keySet().iterator(); IT1.hasNext(); ) //out.println(dShift.getShiftDate()+"<br>"); if (dShift.getShiftDate()!=null) { //hmDayShift.put(dShift.getShiftDate().getDDMMYYYY(), hmShift); hmDayShift.put(dShift.getShiftDate().getDDMMYYYY(), trShift); } } } else { //is WorkingShitf is Empty } hmEmpData.put(inqEmp.getString("employeeid"), hmDayShift); } //End while (inqEmp.next()) //out.println(vEmp); //out.println(hmEmpName); //out.println(hmEmpData); %> <tbody> <% while (c1.beforeEquals(c2)) { %> <tr> <th swlang code="SW001393"><script>swapLang('No.')</script></th> <th swlang code="SW007745">Name Surname</th> <th swlang code='SW001855'>Shift ID</th> <th swlang code="SW001815">Working Time</th> <th swlang code="SW013322">Punch Time</th> <th swlang code="SW000367">Day Type</th> <th swlang code="SW013248">Total(HH.MM)</th> </tr> <tr> <td class="table-title" colspan="7"> <% if (screen.getUProfile().get("lang").equals("tha")) { out.println(c1.getThaiFull()); } else { out.println(c1.getEngFull()); } %> </td> </tr> <!-- Display --> <% String cFont = ""; CscTime ot = new CscTime(0); CscTime leave = new CscTime(0); CscTime work = new CscTime(0); for (int j=0;j<vEmp.size();j++) { int no = j+1; String empCode = (String) vEmp.elementAt(j); String empName = (String) hmEmpName.get(empCode); MyHashMap hmDayShift_Display = (MyHashMap) hmEmpData.get(empCode); //out.println(">>>"+hmDayShift_Display); MyTreeMap hmShift_Display = (MyTreeMap) hmDayShift_Display.get(c1.getDDMMYYYY()); //out.println("==="+hmShift_Display); MyHashMap hm_Display = null; int rows = 1; if (hmShift_Display!=null) { rows = hmShift_Display.size(); int k = 1; for (Iterator IT = hmShift_Display.keySet().iterator(); IT.hasNext();) { Integer key = (Integer) IT.next(); hm_Display = (MyHashMap) hmShift_Display.get(key); cFont = ""; if (hm_Display.getString("eventgrp").equals("H")) { cFont ="week"; } else if (hm_Display.getString("eventgrp").equals("I")) { cFont = "holiday"; } ot.add(hm_Display.getFloat("ot_hour")); leave.add(hm_Display.getFloat("lv_hour")); if (hm_Display.getFloat("lv_hour")==0) { work.add(hm_Display.getFloat("total_hour")); } %> <tr> <% if (k==1) { %> <td class="<%=cFont%>" rowspan="<%=rows%>"><%=no%></td> <td class="table-title <%=cFont%>" rowspan="<%=rows%>"><a href="javascript:pageDesc('<%=empCode%>','<%=empName%>')"><%=empCode%>:<%=empName%></a></td> <% } %> <td class="<%=cFont%>"><%=hm_Display.getString("time0id")%></td> <td class="<%=cFont%>"><%=hm_Display.getString("workingtime")%></td> <% if (k==1) { %> <td rowspan="<%=rows%>" class="<%=cFont%>"><%=hm_Display.getString("swipetime")%></td> <% } %> <td class="<%=cFont%>"> <% String lv_code = hm_Display.getString("eventgrp"); if (lv_code.equals("T")) { out.println(); } else { String lv_type = (String) hmEvent.get(lv_code); if (lv_type==null || lv_type.equals("null")) { out.println(); } else out.println(lv_type); } %> </td> <td class="<%=cFont%>"><%=hm_Display.getString("total_hour")%></td> </tr> <% k++; } //End for (Iterator IT = hmShift_Display.keySet().iterator(); IT.hasNext();) } else { //End if (hmShift_Display!=null) %> <tr> <td><%=no%></td> <td class="table-title"><%=empCode%>:<%=empName%></td> <td>*</td> <td>*</td> <td>*</td> <td>*</td> <td>*</td> </tr> <% } } //End for (int j=0;j<vEmp.size();j++) %> <tr> <td class="result-right" colspan="6" swlang code="SW000385">OT Total</td> <td class="result"><%=df.format(ot.getFloat())%></td> </tr> <tr> <td class="result-right" colspan="6" swlang code="SW001820">Leave Total</td> <td class="result"><%=df.format(leave.getFloat())%></td> </tr> <tr> <td class="result-right" colspan="6" swlang code="SW001824">Working Total</td> <td class="result"><%=df.format(work.getFloat())%></td> </tr> <% c1.incDate(1); } //while (c1.beforeEquals(c2) && (group!=null && !group.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>