<!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.*" %>
<%
	response.setHeader("Cache-Control","must-revalidate");
	response.setContentType("application/vnd.ms-excel; UTF-8");
	response.setHeader("Content-Disposition", "inline; filename=" + "export.xls");

	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 filter = chk.chkNullString(request.getParameter("__filter"));
	String cmd = chk.chkNullString(request.getParameter("__cmd"));

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

<html>
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<!-- <link href="../CSS/TISCO.css" rel="stylesheet" type="text/css"> -->
		<script language="JavaScript" src="../JS/SCREEN.js"></script>
		<script language="javascript">setLang('<%=up.get("lang")%>');</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="__filter" value="<%=filter%>">

			<input type="hidden" name="__calendar" value="">
			<script language="javascript">getInputFormatDate()</script>
			<br>
			<table class="maxsize table table-bordered " border="1" cellpadding="0" cellspacing="1" cols=12 >
				</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><%=new CscCalendar(inqemp.getString("startdate")).getDDMMYYYY()%></td>
					<td class='center'><%=inqsourcejob.getString("tdesc")%></td>
					<td class='center'></td> 		<!--รอ Ma Jung-->
				</tr>
				<%
					}
				%>
			</table>
		</form>
	</body>
</html>