<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.system.*,com.csc.library.session.*,com.csc.library.utilities.*,java.text.DecimalFormat"%>
<%@ page import="java.util.*,java.io.*,java.sql.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.Date" %>
<%@ page import="com.csc.library.components.*" %>
<%@ page import="com.csc.library.report.ReportUDF" %>
<%@ page import="com.csc.library.databean.Simmapplicanthisotherwithgson" %>
<%@ page import="com.csc.library.utilities.gsonmapping.*" %>
<%
	CheckNull chk = new CheckNull();
	CscCalendar c = new CscCalendar();
	ReportUDF udf = new ReportUDF();
	UProfile up = null;

	if (session !=null){
		up = (UProfile)session.getAttribute("userprofile");
	}

	String lang = up.get("lang");
	String startdate = chk.chkNullString(request.getParameter("__startdate"));
	String startdate2 = chk.chkNullString(request.getParameter("__startdate2"));
	String jobid = chk.chkNullString(request.getParameter("__job"));
	String job_desc = chk.chkNullString(request.getParameter("__job_desc"));
	String bu1 = chk.chkNullString(request.getParameter("__bu1"));
	String bu2 = chk.chkNullString(request.getParameter("__bu2"));
	String bu3 = chk.chkNullString(request.getParameter("__bu3"));
	String bu4 = chk.chkNullString(request.getParameter("__bu4"));
	String bu1_desc = chk.chkNullString(request.getParameter("__bu1_desc"));
	String bu2_desc = chk.chkNullString(request.getParameter("__bu2_desc"));
	String bu3_desc = chk.chkNullString(request.getParameter("__bu3_desc"));
	String bu4_desc = chk.chkNullString(request.getParameter("__bu4_desc"));

	String cmd = chk.chkNullString(request.getParameter("__cmd"));
	String isprocess =chk.chkNullString(request.getParameter("__isprocess"));

	String filter = "1=1";

	if(!jobid.equals("")){
		filter += " and job='"+jobid+"'";
	}
	if(!bu1.equals("")){
		filter += " and bu1='"+bu1+"'";
	}
	if(!bu2.equals("")){
		filter += " and bu2='"+bu2+"'";
	}
	if(!bu3.equals("")){
		filter += " and bu3='"+bu3+"'";
	}
	if(!bu4.equals("")){
		filter += " and bu4='"+bu4+"'";
	}
	if(!startdate.equals("")){
		filter += " and startdate between '"+c.setCscCalendar(startdate).getYYYYMMDD()+"' and '"+c.setCscCalendar(startdate2).getYYYYMMDD()+"'";
	}

	DbRecord dbrec = new InitialRecord(up).getDbRecord("memployee");
	dbrec.setColumn("*");
%>

<html ng-app="myHR">
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
		<link href="../CSS/bootstrap.css" rel="stylesheet">
		<script language="JavaScript" src="../JS/SCREEN.js"></script>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/DATEINPUT.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/VIEWCALENDAR.js'></SCRIPT>
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
		<script src="../JS/bootstrap.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 language="javascript">setLang('<%=up.get("lang")%>');</script>
		<script language="JavaScript" type="text/JavaScript">

			function GoExport(){
				with(document.cscform){
					// alert(__filter.value);
					var param = "RCR024_EXP.jsp?__filter="+__filter.value;
					window.open(param);
				}
			}

			function GoProcess(){
				with( document.cscform){
          __cmd.value = "search"
          __isprocess.value = "1"
          submit();
				}
			}

			function goHelp(helpName,inputName){
				var helpReturn;
				var fixcon;

				if(inputName=="__job"){
					helpReturn = inputName+":jobcodeid,"+inputName+"_desc:tdesc";
				}else if(inputName=="__bu1"){
					helpReturn = inputName+":bu1id,"+inputName+"_desc:edesc";
				}else if(inputName=="__bu2"){
					helpReturn = inputName+":bu2id,"+inputName+"_desc:edesc";
				}else	if(inputName=="__bu3"){
					helpReturn = inputName+":bu3id,"+inputName+"_desc:edesc";
				}else if(inputName=="__bu4"){
					helpReturn = inputName+":bu4id,"+inputName+"_desc:edesc";
				}
				fixcon="";
				linkHelp_Return(helpName,helpReturn,fixcon);
			}

			$(function() {
		    	  $('#export').click(function() {
		    		  GoExport();
		    	  });

		    	  $('#search').click(function() {
		    		  GoProcess();
		    	  });
			});



		</script>
		<style>
			img[height="20"] {
				padding: 0px;
			}
			.center{
				text-align: center;
			}
			.wd-40{
				width:40%;
			}
		</style>
	</head>
	<%
		String helpReturn="";
		if(request.getParameter("__helpReturn")!=null){
		  helpReturn=request.getParameter("__helpReturn");
		}
		String fieldSearch="";
		if(request.getParameter("__fieldSearch")!=null){
		  fieldSearch=request.getParameter("__fieldSearch");
		}
	%>
	<body leftmargin="0" topmargin="0">
		<form name="cscform" method="post" action="RCR024.jsp">
			<!----------BEGIN CSC INITIAL ZONE ------------------------>
			<%//=screen.InitialVariable()%>
			<!----------END CSC INITIAL ZONE -------------------------->
			<input type="hidden" name="__cmd" value="">
			<input type="hidden" name="__screen" value="RCR024">
			<input type="hidden" name="__help" value="">
			<input type="hidden" name="__goPage" value="">
			<input type="hidden" name="__language" value="<%=up.get("lang")%>">
			<input type="hidden" name="__orderBy" value="<%=request.getParameter("__orderBy")%>">
			<input type="hidden" name="__helpReturn" value="<%=helpReturn%>">
			<input type="hidden" name="__fieldSearch" value="<%=fieldSearch%>">
			<input type="hidden" name="__helpName" value="<%=request.getParameter("__helpName")%>">
			<input type="hidden" name="__pageCall" value="<%=request.getParameter("__screen")%>">
			<input type="hidden" name="__fixCon" value="<%=request.getParameter("__fixCon")%>">
			<input type="hidden" name="__export" value="">
			<input type="hidden" name="__isprocess" value="0">
			<input type="hidden" name="__filter" value="<%=filter%>">
			<input type="hidden" name="__calendar" value="">
			<script language="javascript">getInputFormatDate()</script>

			<br>
			<div align="center">
				<table class="large" cellpadding="0"  cellspacing="1"  >
					<tr>
						<td  colspan=2 class="header">RCR024, รายงานสรุปผลการเริ่มงานของพนักงาน</td>
					</tr>
					<tr>
						<td colspan=2>
							<table border="0" cellpadding="0" cellspacing="1"   align="center" class="largest">
								<tr>
									<td colspan=2 class="blankspace"></td>
								</tr>
								<tr>
									<td width="40%" align="right"><%=lang.equalsIgnoreCase("tha")?"วันที่ส่งใบสมัคร":"Submit Date"%></td>
									<td style="text-align: left;">
										<input type="text" id="startdate" name="__startdate" value="<%=startdate%>" size="15" maxlength="10" onkeypress="chkIntegerOfDate(this.value,event);" onkeyup="sysIsEdit();formatDate(this);" onblur="chkInputDate(this);" onfocus="this.select();">
										<a href="javascript:;" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onClick="viewCal('startdate')"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image1" width="20" height="20" border="0" style="vertical-align: middle"></a>
										-
										<input type="text" id="startdate2" name="__startdate2" value="<%=startdate2%>" size="15" maxlength="10" onkeypress="chkIntegerOfDate(this.value,event);" onkeyup="sysIsEdit();formatDate(this);" onblur="chkInputDate(this);" onfocus="this.select();">
										<a href="javascript:;" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onClick="viewCal('startdate2')"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image2" width="20" height="20" border="0" style="vertical-align: middle"></a>
									</td>
								</tr>
								<tr>
								  <td class='wd-40' align="right" swlang code='SW012911'>job &nbsp; </td>
								  <td><input type="text" name="__job" size="15" value="<%=jobid%>">
									<a href="javascript:goHelp('MJOBCODEHELP','__job')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgjob','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="imgjob"  border="0" align="absmiddle"></a>
									<input name="__job_desc" type="text" id="__job_desc" value="<%=job_desc%>" size="50" readonly="">      </td>
								</tr>
								<tr>
								  <td align="right"><%=dbrec.getField("bu1").getDescription()%>&nbsp; </td>
								  <td colspan="3"><input type="text" name="__bu1" size="15" value="<%=bu1%>">
									<a href="javascript:goHelp('MBU1HELP','__bu1')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgBu1','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="imgBu1"  border="0" align="absmiddle"></a>
									<input name="__bu2_desc" type="text" id="__bu1_desc" value="<%=bu1_desc%>" size="50" readonly="">      </td>
								</tr>
								<tr>
								  <td align="right"><%=dbrec.getField("bu2").getDescription()%>&nbsp; </td>
								  <td colspan="3"><input type="text" name="__bu2" size="15" value="<%=bu2%>">
									<a href="javascript:goHelp('MBU2HELP','__bu2')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgBu2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="imgBu2"  border="0" align="absmiddle"></a>
									<input name="__bu2_desc" type="text" id="__bu2_desc" value="<%=bu2_desc%>" size="50" readonly="">      </td>
								</tr>
								<tr>
								  <td align="right"><%=dbrec.getField("bu3").getDescription()%>&nbsp;</td>
								  <td colspan="3"><input type="text" name="__bu3" size="15" value="<%=bu3%>">
									<a href="javascript:goHelp('MBU3HELP','__bu3')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgBu3','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="imgBu3"  border="0" align="absmiddle"></a>
									<input name="__bu3_desc" type="text" value="<%=bu3_desc%>" size="50" readonly="">        </td>
								</tr>
								<tr>
								  <td align="right"><%=dbrec.getField("bu4").getDescription()%>&nbsp; </td>
								  <td colspan="3"><input type="text" name="__bu4" size="15" value="<%=bu4%>">
									<a href="javascript:goHelp('MBU4HELP','__bu4')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgBu4','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="imgBu4"  border="0" align="absmiddle"></a>
									<input name="__bu4_desc" type="text" id="__bu4_desc" value="<%=bu4_desc%>" size="50" readonly="">      </td>
								</tr>
								<tr>
									<td colspan=2 class="blankspace"></td>
								</tr>
								<tr>
									<td colspan="2" style="text-align: center;">
										<div id="search" class="btn btn-primary btn-sm" style="padding-top: 2px;">
											 Search
										</div>&nbsp;&nbsp;
										<%
											if(isprocess.equals("1")){
										%>
										<div id="export" class="btn btn-primary btn-sm" style="padding-top: 2px;">
											 Export
										</div>
										<%
											}
										%>
									</td>
								</tr>
							</table>

							<%
								if(isprocess.equals("1")){
							%>
							<table class="maxsize table table-bordered " border="1" cellpadding="0" cellspacing="1" cols=12 bgcolor="#CCCCCC">
								</tr>
									<td class="row1 center" colspan='12'>รายงานสรุปผลการเริ่มงานของพนักงาน</td>
								</tr>
								<tr>
									<td class="row1 center">ลำดับ</td>
									<td class="row1 center">รหัสพนักงาน</td>
									<td class="row1 center">ชื่อ-นามสกุล</td>
									<td class="row1 center">ตำแหน่ง</td>
									<td class="row1 center">ระดับพนักงาน</td>
									<td class="row1 center"><%=dbrec.getField("bu1").getDescription()%></td>
									<td class="row1 center"><%=dbrec.getField("bu2").getDescription()%></td>
									<td class="row1 center"><%=dbrec.getField("bu3").getDescription()%></td>
									<td class="row1 center"><%=dbrec.getField("bu4").getDescription()%></td>
									<td class="row1 center">วันที่เริ่มงาน</td>
									<td class="row1 center">แหล่งที่มา</td>
									<td class="row1 center">คะแนนสอบ</td>
								</tr>
								<%
									int i = 0;
									DbInquiry inqapp_his = new InitialInquiry(up).getDbInquiry("Simmapplicanthisotherwithgson");
									DbInquiry inqemp = new InitialInquiry(up).getDbInquiry("memployee");
									DbInquiry inqpos = new InitialInquiry(up).getDbInquiry("mposition");
									DbInquiry inqbu1 = new InitialInquiry(up).getDbInquiry("mbu1");
									DbInquiry inqbu2 = new InitialInquiry(up).getDbInquiry("mbu2");
									DbInquiry inqbu3 = new InitialInquiry(up).getDbInquiry("mbu3");
									DbInquiry inqbu4 = new InitialInquiry(up).getDbInquiry("mbu4");
									DbInquiry inqjob = new InitialInquiry(up).getDbInquiry("mjobcode");
									DbInquiry inqsourcejob = new InitialInquiry(up).getDbInquiry("msourcejob");

									inqemp.putChild(inqpos);
									inqemp.putChild(inqbu1);
									inqemp.putChild(inqbu2);
									inqemp.putChild(inqbu3);
									inqemp.putChild(inqbu4);
									inqemp.putChild(inqjob);
									inqemp.setColumn("*");

									inqemp.setFilter(filter +" and employeeid in (select employeeid from mapplicant_his)");
									inqemp.refresh();

									while(inqemp.next()){
										i++;
										inqapp_his.setFilter("employeeid = '"+inqemp.getString("employeeid")+"'");
										inqapp_his.refresh();
										inqapp_his.next();
										Simmapplicanthisotherwithgson simmapplicanthisotherwithgson = (Simmapplicanthisotherwithgson) inqapp_his.getCurrentDbRecord();
										inqsourcejob.setFilter("sourcejobid = '"+simmapplicanthisotherwithgson.mapplicanthisother.sourcejob+"'");
										inqsourcejob.refresh();
										inqsourcejob.next();

										//out.print("");

								%>
								<tr>
									<td class='center'><%=i%></td>
									<td class='center'><%=inqemp.getString("employeeid")%></td>
									<td><%=inqemp.getString("fullname")%></td>
									<td><%=inqemp.getString("mjobcode","tdesc")%></td>
									<td><%=inqemp.getString("mposition","tdesc")%></td>
									<td><%=inqemp.getString("mbu1","tdesc")%></td>
									<td><%=inqemp.getString("mbu2","tdesc")%></td>
									<td><%=inqemp.getString("mbu3","tdesc")%></td>
									<td><%=inqemp.getString("mbu4","tdesc")%></td>
									<td><%=c.setCscCalendar(inqemp.getString("startdate")).getDDMMYYYY()%></td>
									<td class='center'><%=inqsourcejob.getString("tdesc")%></td>
									<td class='center'></td> 		<!--รอ Ma Jung-->
								</tr>
								<%
									}
								%>
							</table>
							<%
								}
							%>
						</td>
					</tr>
					<tr>
						<td colspan=2 class="blankspace"></td>
					</tr>
					<tr>
						<td colspan=2 class="blankspace"></td>
					</tr>
					<tr bordercolor="0069B3">
						<td colspan=2 class="bottom"></td>
					</tr>
				</table>
			</div>
		</form>
	</body>
</html>