<!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.*,com.csc.library.formula.*"%> <%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*,com.csc.library.swaplang.*,java.util.*,java.text.*" %> <%@ page import="com.csc.library.databean.Mtime0, com.csc.library.timeattendance.*" %> <% request.setCharacterEncoding("UTF-8"); %> <%@ include file="../CHECKPROFILE.jsp" %> <jsp:useBean id="EMVTIME" class="com.csc.library.system.Task" scope="page" /> <jsp:setProperty name="EMVTIME" property="appname" value="empview" /> <% EMVTIME.setChannel(request,response); UProfile mypro = null; if (session !=null){ mypro = (UProfile)session.getAttribute("userprofile"); } CheckNull chk = new CheckNull(); Swaplang myswlang = new Swaplang(); CscCalendar calen = new CscCalendar(),newcalen=null; String myemployeeid = chk.chkNullString(request.getParameter("__employeeid")); String myempname = chk.chkNullString(request.getParameter("__employeename")); String param_bu = chk.chkNullString(request.getParameter("__selectMyBu"),"mbu1"); String mytimelist = chk.chkNullString(request.getParameter("__timelist")); String empbufield="bu1",bufield="bu1id"; String mymonth=""; String empfilter=""; int myyear=0; HashMap hmWorkPlan = new HashMap(); HashMap workDesc = new HashMap(); boolean status = false; if (chk.chkNullString(request.getParameter("__month")).equals("")){ mymonth = calen.getMM(); }else{ mymonth = request.getParameter("__month"); } if (chk.chkNullString(request.getParameter("__year")).equals("")){ myyear = calen.getYear(); }else{ myyear = Integer.parseInt(request.getParameter("__year")); } if (param_bu.equals("mbu1")){ empbufield = "bu1"; bufield = "bu1id"; }else if (param_bu.equals("mbu2")){ empbufield = "bu2"; bufield = "bu2id"; }else if (param_bu.equals("mbu3")){ empbufield = "bu3"; bufield = "bu3id"; }else if (param_bu.equals("mbu4")){ empbufield = "bu4"; bufield = "bu4id"; }else if (param_bu.equals("mbu5")){ empbufield = "bu5"; bufield = "bu5id"; } if (mytimelist.equals("")==false){ newcalen = new CscCalendar(myyear+"-"+mymonth+"-"+"01"); delWorkShift(mypro,myemployeeid,myyear+"-"+mymonth+"-"+"01",myyear+"-"+mymonth+"-"+Integer.toString(newcalen.getEndDateOfMonth())); saveWorkShift(mypro,myemployeeid,mytimelist); status = true; } WorkingShift wstmp = null; if (myemployeeid.equals("")==false){ DbRecord empdb = new InitialRecord(mypro).getDbRecord("MEMPLOYEE"); empdb.setParam("rsc_skip","true"); empdb.set("employeeid", myemployeeid); if(empdb.search() == 1){ Mtime0 time0db = (Mtime0) new InitialRecord(mypro).getDbRecord("Mtime0"); time0db.set("time0id", empdb.getString("time0")); time0db.set("companyid", mypro.get("companyid")); if(time0db.search() == 1) { time0db.setEmpRec(empdb); CscCalendar stGenWorkingSF = new CscCalendar(myyear + "-" + mymonth + "-" + "01"); CscCalendar enGenWorkingSF = new CscCalendar(myyear + "-" + mymonth + "-" + Integer.toString(stGenWorkingSF.getEndDateOfMonth())); wstmp = time0db.genWorkingShift(new CscCalendar(stGenWorkingSF.getTimestamp()), new CscCalendar(enGenWorkingSF.getTimestamp()), "true");wstmp.setUProfile(mypro); wstmp.setEmprec(empdb); wstmp.setEmployeeid(empdb.getString("employeeid")); wstmp.meargeWithShiftTrans(empdb, new CscCalendar(stGenWorkingSF.getTimestamp()), new CscCalendar(enGenWorkingSF.getTimestamp())); } } } DbInquiry myemp = new InitialInquiry(mypro).getDbInquiry("memployee"); DbRecord recemp = new InitialRecord(mypro).getDbRecord("memployee"); recemp.setColumn("employeeid,bu1,bu2,bu3,bu4,bu5"); myemp.setColumn("employeeid,fname,lname,efname,elname,bu1,bu2,bu3,bu4,bu5,companyid"); DbInquiry mybu = new InitialInquiry(mypro).getDbInquiry(param_bu); mybu.setColumn("*"); mybu.refresh(); mybu.referLangOn(); DbInquiry mtimeinq = new InitialInquiry(mypro).getDbInquiry("mtime0"); mtimeinq.setFilter(" status ='0'"); mtimeinq.setColumn("*"); mtimeinq.refresh(); DbInquiry mytran = new InitialInquiry(mypro).getDbInquiry("MEMPL_TIME0TRANS"); mytran.setColumn("*"); String myfilter=""; if (!myemployeeid.equals("")){ newcalen = new CscCalendar(myyear+"-"+mymonth+"-"+"01"); mytran.setFilter("employeeid ='"+myemployeeid+"' and (start_date between '"+myyear+"-"+mymonth+"-"+"01"+"' and '"+myyear+"-"+mymonth+"-"+Integer.toString(newcalen.getEndDateOfMonth())+"')"); mytran.putChild(mtimeinq); mytran.refresh(); } %> <html ng-app="myHR"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style> .title-listbox{ width:55%; text-align:right !important; display:block; float:left; } .title-searchbox{ width:43%; text-align:right !important; float:left; display:block; } .all-list{ display:none; } .listof-body-event{ display:block; cursor : pointer; } .listof-body-event{ color:#6E6565; } .listof-body-event:hover{ background: rgba(201, 201, 201, 0.9); color:#6E6565; } .listof-body-event-hover{ background: rgba(201, 201, 201, 0.9); color:#6E6565; } .open-icon{ padding-right:10px; } .mylist-event{ display: block; float: left; width: 75%; height: 10%; } .mtime-block{ height: 170px; /*width: 100%;*/ border: 2px solid #8C8C8C; margin-left: 60px; margin-top: 50px; overflow-y:auto; } .list-block-ev-ent{ margin-top:50px !important; } .fc-event-list{ padding-left:2%; /*padding-right:2%;*/ margin-bottom:20px; /*overflow-y:auto;*/ display:block; float:left; } .fc-event{ display:inline-block !important; padding-left:10px; padding-right:10px; margin-top:10px; width:49%; cursor: pointer; } .ui-selected{ background: #F39814; color: white; border-color:#E19426 !important; } .fc-day-grid-event.fc-event{ width: 90%; margin-left:5%; } .ui-selected { background: #F39814 !important; } .submit-block{ display:block; width:100%; float:left; text-align:center; } .myicon{ cursor: pointer; } .input-group{ float:right; cursor: pointer; } .mysearch{ width:50% !important; float:right !important; } .blocksearch{ position:absolute; display:none; float:right; width:80%; left:20%; background:#fff; border: 1px solid #000; height: 120px; z-index:9999; overflow-y:auto; text-align:left; top:100%; } .blocksearch .fc-event{ width : 96%; margin-left:2%; } .body-event{ cursor: pointer; } .listhover{ background: rgb(239, 239, 239); } </style> </head> <body> <div class="bg-com"></div> <jsp:include page="EMV_HEADMENU.jsp" flush="true" /> <section> <div class="container container-90 csc-content"> <form name="cscform" class="form-horizontal" method="post" action="?"> <input type="hidden" name="__cmd" value=""> <input type="hidden" name="__fixCon" value=""> <input type="hidden" name="__screen" value="EMV_TIME0TRANS"> <input type="hidden" name="__help" value=""> <input type="hidden" name="__helpReturn" value=""> <input type="hidden" name="__helpName" value=""> <input type="hidden" name="__goPage" value=""> <input type="hidden" name="__referPage" value=""> <input type="hidden" name="__companyid" value="<%=mypro.get("companyid")%>"> <input type="hidden" name="__notNull" value=''> <input type="hidden" name="__confirm" value=''> <input type="hidden" name="__timelist" value=""> <div class="csc-block"> <div class="center"> <h2 swlang code='SW000727' class="csc-block-head">List of Employee</h2> </div> <div class="row"> <div class="form-group"> <div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div> <div class="col-sm-2 col-md-2 col-lg-2"> <label class="control-label label-right" swlang code="SW012125">Business Units</label> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <select name="__selectMyBu" class="form-control"> <option value="mbu1" <% if (param_bu.equals("mbu1")){out.println("selected");} %>><%=recemp.getField("bu1").getDescription()%></option> <option value="mbu2" <% if (param_bu.equals("mbu2")){out.println("selected");} %>><%=recemp.getField("bu2").getDescription()%></option> <option value="mbu3" <% if (param_bu.equals("mbu3")){out.println("selected");} %>><%=recemp.getField("bu3").getDescription()%></option> <option value="mbu4" <% if (param_bu.equals("mbu4")){out.println("selected");} %>><%=recemp.getField("bu4").getDescription()%></option> <option value="mbu5" <% if (param_bu.equals("mbu5")){out.println("selected");} %>><%=recemp.getField("bu5").getDescription()%></option> </select> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <label class="control-label label-right"><%=recemp.getField("employeeid").getDescription()%> </label> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <div class="input-group"> <input type="text" name="__employeeid" value="<%=myemployeeid%>" class="form-control"> <a class="input-group-addon" href="javascript:goHelp('MEMPLOYEEHELP','__employeeid');"> <i class="fa fa-search"></i> </a> </div> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <input type="text" name="__employeename" value="<%=myempname%>" class="form-control"> </div> </div><!-- end form-group --> <div class="form-group"> <div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div> <div class="col-sm-2 col-md-2 col-lg-2"> <label class="control-label label-right" swlang code="SW000800">Month </label> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <select name="__month" class="form-control"> <option value="01" <% if (mymonth.equals("01")) { %> selected <%}%> swlang code='SW012039'>January</option> <option value="02" <% if (mymonth.equals("02")) { %> selected <%}%> swlang code='SW001840'>February</option> <option value="03" <% if (mymonth.equals("03")) { %> selected <%}%> swlang code='SW001841'>March</option> <option value="04" <% if (mymonth.equals("04")) { %> selected <%}%> swlang code='SW001842'>April</option> <option value="05" <% if (mymonth.equals("05")) { %> selected <%}%> swlang code='SW001843'>May</option> <option value="06" <% if (mymonth.equals("06")) { %> selected <%}%> swlang code='SW001844'>June</option> <option value="07" <% if (mymonth.equals("07")) { %> selected <%}%> swlang code='SW001845'>July</option> <option value="08" <% if (mymonth.equals("08")) { %> selected <%}%> swlang code='SW012040'>August</option> <option value="09" <% if (mymonth.equals("09")) { %> selected <%}%> swlang code='SW001847'>September</option> <option value="10" <% if (mymonth.equals("10")) { %> selected <%}%> swlang code='SW012041'>October</option> <option value="11" <% if (mymonth.equals("11")) { %> selected <%}%> swlang code='SW011910'>November</option> <option value="12" <% if (mymonth.equals("12")) { %> selected <%}%> swlang code='SW001850'>December</option> </select> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <label class="control-label label-right" swlang code="SW000717">Year </label> </div> <div class="col-sm-2 col-md-2 col-lg-2"> <select name="__year" class="form-control"> <option value=<%=calen.getYear()-1%> <% if(myyear==calen.getYear()-1){out.println("selected");}%>><%=calen.getYear()-1%></option> <option value=<%=calen.getYear()%> <% if(myyear==calen.getYear()){out.println("selected");}%>><%=calen.getYear()%></option> <option value=<%=calen.getYear()+1%> <% if(myyear==calen.getYear()+1){out.println("selected");}%>><%=calen.getYear()+1%></option> </select> </div> </div><!-- end form-group--> </div><!-- end row--> <div class="form-group"> <div class="center"> <a href="Javascript:GoSearch();" class="btn btn-primary" swlang code="SW003537"><script type="text/javascript">swapLang("Search")</script></a> </div> </div> </div><!-- end csc-block--> <div class="csc-block-white"> <div class="list-event"> <div class="list-block-event"> <div class="title-list-event" swlang code='SW000727'>List of Employee</div> <div class="class-list"> <% if (mybu.recCount()>0){ while (mybu.next()){ empfilter = empbufield+"='"+mybu.getString(bufield)+"' AND companyid ='"+mypro.get("companyid")+"'"; myemp.setFilter(empfilter); myemp.refresh(); if (myemp.recCount()>0){ %> <div class="body-event"><div class="mydivision"><i class="fa fa-plus open-icon"></i><%=mybu.getString("tdesc")%></div> <div class="all-list"> <% while (myemp.next()){ %> <a class="listof-body-event" data-empid="<%=myemp.getString("employeeid")%>"><%=myemp.getString("fullname")%></a> <% } %> </div> </div> <% } } } %> </div><!-- end class-list--> </div><!-- end list-block-event--> </div><!-- end list-event--> <div class="mylist-event"> <div class="mtime-block"> <span class="title-list-event title-listbox" swlang code='SW012517'>List of Shift</span><span class="title-list-event title-searchbox"> <span class="focus"> <div class="input-group input-groupsearch"> <input type="text" class="mysearch form-control" name="__searchtime0" placeholder="<%=myswlang.getInstance().get(mypro,"SW003537")%>"> <div class="input-group-addon"><i class="fa fa-search myicon"></i></div> <div class="blocksearch focus-search"> </div> </div> </span> </span> <div class="fc-event-list"> <% while (mtimeinq.next()){ workDesc.put(mtimeinq.getString("time0id"),mtimeinq.getString("tdesc")); %> <div class='fc-event'><%=mtimeinq.getString("time0id")%> : <%=mtimeinq.getString("tdesc")%></div> <% } %> </div> </div><!--mtime-block--> </div><!-- end mylist-event--> <div id="MyCalendar" class="full-calendar"></div> <div class="submit-block"> <div class="center"><a class="btn btn-primary" href="javascript:GoSave()" swlang code='SW000117'>Save</a></div> </div> </div><!-- end csc-block-white--> </form> </div><!-- end container--> </section> <script type="text/javascript"> setLang('<%=mypro.get("lang")%>'); $(document).ready(function(){ var statuscode = <%=status%>; if (statuscode == true){ alert(MyCode[48]); } var employeeSelect = "<%=myemployeeid%>"; console.log(employeeSelect); var nowdate = new Date($("select[name='__year']").val()+"-"+$("select[name='__month']").val()+"-"+"01"); var mylang ="<%=mypro.get("lang")%>"; var myevent = []; var mystartdate =""; var datestr=""; var eventClick=""; setCalendarLang(mylang); if (mylang=="tha"){ mylang="th"; }else{ mylang="en"; } <% if (myemployeeid.equals("")==false && wstmp !=null){ for (Iterator<?> IT = wstmp.keySet().iterator(); IT.hasNext();) { String key = (String) IT.next(); DayShift dShift = (DayShift) wstmp.get(key); for (Iterator<?> IT1 = dShift.keySet().iterator(); IT1.hasNext();) { String dkey = (String) IT1.next(); Shift sh = (Shift) dShift.get(dkey); %> datestr = "<%=sh.getShiftDate().getYYYYMMDD()%>"; myevent.push({ title : "<%=sh.getTimeCode()%> : <%=workDesc.get(sh.getTimeCode())%>", start : datestr, allDay : true }); <% } } } %> $(".mydivision").click(function(){ var checkAllList = $(this).parent().find(".all-list").css("display"); if (checkAllList=="none"){ $(".open-icon").removeClass("fa-minus"); $(".open-icon").addClass("fa-plus"); $(".all-list").css("display","none"); $(this).parent().find(".all-list").css("display","block"); $("body,html").animate({ scrollTop:$(this).offset().top },800); if ($(this).find(".open-icon").hasClass("fa-plus")){ $(this).find(".open-icon").removeClass("fa-plus"); $(this).find(".open-icon").addClass("fa-minus"); } }else if(checkAllList=="block"){ $(".all-list").css("display","none"); $(".open-icon").removeClass("fa-minus"); $(".open-icon").addClass("fa-plus"); } }); $("#MyCalendar").fullCalendar({ header: { left: 'today', center: 'title', right: 'month' }, yearColumns: 3, droppable: true, events: myevent, lang: mylang, drop : function (event,ui){ $.checkMyData(event._d); }, dayClick : function (event){ $.addMyEvent(event._d); $.checkMyData(event._d); } }); $.checkMyData=function(targetdate){ var mystrgetdate = targetdate; var i=1; var tmpdate=""; var delid=""; $("#MyCalendar").fullCalendar('clientEvents',function(ev){ tmpdate = ev.start._d; if ((tmpdate.getFullYear() == mystrgetdate.getFullYear()) && (tmpdate.getMonth() == mystrgetdate.getMonth()) && (nowdate.getMonth()==tmpdate.getMonth()) && (tmpdate.getDate() == mystrgetdate.getDate()) && (i==1)){ delid = ev._id; i++; }else if ((tmpdate.getFullYear() == mystrgetdate.getFullYear()) && (tmpdate.getMonth() == mystrgetdate.getMonth()) && (nowdate.getMonth()==tmpdate.getMonth()) && (tmpdate.getDate() == mystrgetdate.getDate()) && (i!=1)){ i=0; }else if (nowdate.getMonth()!=tmpdate.getMonth()){ delid = ev._id; $("#MyCalendar").fullCalendar('removeEvents',delid); } }); if (i==0){ $("#MyCalendar").fullCalendar('removeEvents',delid); } } $.addMyEvent = function(targetdate){ if (eventClick!=""){ var ev ={ title : eventClick.title, stick : true, start : targetdate , allDay : true } $("#MyCalendar").fullCalendar('renderEvent',ev); } } $('.fc-event').each(function() { $(this).data('event', { title: $.trim($(this).text()), stick: true }); $(this).draggable({ zIndex: 999, revert: true, revertDuration: 0, scroll: false }); }); $(".fc-event-list .fc-event").click(function(){ if ($(this).hasClass("ui-selected")){ $(this).removeClass("ui-selected"); eventClick=""; }else{ $(".fc-event").removeClass("ui-selected"); $(this).addClass("ui-selected"); eventClick = { title : $.trim($(this).text()), stick : true } } }); $.moveFormSearch = function(){ $('.fc-event').each(function() { $(this).data('event', { title: $.trim($(this).text()), stick: true }); $(this).draggable({ zIndex: 999, revert: true, revertDuration: 0, scroll: false }); }); } $("a.listof-body-event").click(function(){ $("input[name='__employeeid']").val($(this).data("empid")); $("input[name='__employeename']").val($(this).html()); search(); }); $("#MyCalendar").fullCalendar('gotoDate',nowdate); $("input[name='__searchtime0']").keyup(function(){ var txt=""; var alltxt =""; $(".blocksearch").html(""); $(".fc-event").each(function(){ txt = $(this).text(); if (txt.indexOf($("input[name='__searchtime0']").val())>-1){ alltxt +="<div class='fc-event focus-search'>"+txt+"</div>"; } }); $(".blocksearch").html(alltxt); $.moveFormSearch(); $(".blocksearch").css("display","block"); }); $("input[name='__searchtime0']").focus(function(){ $(".blocksearch").css("display","block"); }); $("input[name='__searchtime0']").click(function(){ $(".blocksearch").css("display","block"); }); $(".focus-search").mouseleave(function(ev){ $(".blocksearch").css("display","none"); }); if (employeeSelect!=""){ $(".listof-body-event").each(function(){ if (employeeSelect==$(this).data("empid")){ $(this).parent().css("display","block"); $(this).parents(".body-event").find(".open-icon").removeClass("fa-plus"); $(this).parents(".body-event").find(".open-icon").addClass("fa-minus"); $(this).addClass("listof-body-event-hover"); $("body,html").animate({ scrollTop:$(".mtime-block").offset().top },800); } }); } }); function showHover(MyId){ } function disableHover(){ } function goHelp(helpName,inputName){ with(document.cscform){ var helpReturn=""; if (inputName=="__employeeid") { helpReturn = inputName+":employeeid,__employeename:fullname" linkHelp_Return(helpName,helpReturn); } __fixCon.value = ""; } } function GoSearch(){ with(document.cscform){ search(); } } function GoSave(){ var mystring=""; var datestr=""; with(document.cscform){ if (__employeeid.value!=""){ $("#MyCalendar").fullCalendar('clientEvents',function(ev){ mystring = ev.title; mystring = mystring.substring(0,mystring.indexOf(":")-1); datestr += ","+checkDay(ev.start._d.getDate())+"-"+checkMonth(ev.start._d.getMonth())+"-"+ev.start._d.getFullYear()+"#"+mystring; }); datestr = datestr.substring(1,datestr.length); $("input[name='__timelist']").val(datestr); submit(); }else{ alert(MyCode[0]); } } } function checkMonth(param_month){ var tmpMonth = param_month; tmpMonth++; if (tmpMonth<=9){ tmpMonth = "0"+tmpMonth; } return tmpMonth; } function checkDay(param_day){ var tmpDay = param_day; if (tmpDay<=9){ tmpDay ="0"+tmpDay; } return tmpDay; } </script> <jsp:include page="FOOTER.jsp" flush="true" /> </body> </html> <%! public void saveWorkShift(UProfile upf, String emp, String datalist){ try { String raw[] = datalist.split(","); for(int i=0; i < raw.length; i++){ String rdate[] = raw[i].split("#"); DbRecord db = new InitialRecord(upf).getDbRecord("MEMPL_TIME0TRANS"); db.set("employeeid", emp); db.set("companyid", (String) upf.get("companyid")); db.set("time0id", rdate[1]); db.set("start_date", rdate[0]); db.set("end_date", rdate[0]); db.save(); } }catch(Exception e){ e.printStackTrace(); } } public void delWorkShift(UProfile upf, String emp, String startdate, String enddate){ try { DbInquiry inq = new InitialInquiry(upf).getDbInquiry("MEMPL_TIME0TRANS"); inq.setColumn("*"); inq.setFilter("employeeid = '" + emp + "' and start_date between '" + startdate + "' and '" + enddate + "'"); inq.refresh(); while(inq.next()){ DbRecord db = inq.getCurrentDbRecord().cloneRecord(true); db.delete(); } }catch(Exception e){ e.printStackTrace(); } } %>