RRC029_EXP.jsp 14.3 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
<!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.api.recruit.*" %>
<%@ page import="com.csc.library.databean.Simmcandidatewithgson" %>
<%@ page import="com.csc.library.databean.Simmappointmentwithgson" %>
<%@ page import="com.csc.library.databean.Simmapplicanthisotherwithgson" %>
<%@ page import="com.csc.library.utilities.gsonmapping.*" %>
<%@ page import="com.csc.library.database.MyHashMap" %>
<%@ page import="com.csc.library.database.DataSet" %>
<%
	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 submitdate = chk.chkNullString(request.getParameter("__submitdate"));
	String submitdate2 = chk.chkNullString(request.getParameter("__submitdate2"));
	String jobid = chk.chkNullString(request.getParameter("__job"));
	String sourcejob = chk.chkNullString(request.getParameter("__selectoption"));
	String job_desc = chk.chkNullString(request.getParameter("__job_desc"));
	String filter = chk.chkNullString(request.getParameter("__filter"));
	String filter2 = chk.chkNullString(request.getParameter("__filter2"));
	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="RRC029.jsp">
			<!----------BEGIN CSC INITIAL ZONE ------------------------>
			<%/*=screen.InitialVariable()*/%>
			<!----------END CSC INITIAL ZONE -------------------------->
			<input type="hidden" name="__cmd" value="">
			<input type="hidden" name="__screen" value="RRC029">
			<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="__filter2" value="<%=filter2%>">
			<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=10 >
				</tr>
					<td class="row1 center"style="text-align:center" colspan='7'><%=lang.equalsIgnoreCase("tha")?"รายงานสรุปการสรรหาพนักงานแบ่งตามแหล่งที่มา":"Recruiting Analysis by Channel"%></td>
				</tr>
				<tr>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"แหล่งที่มา":"Channel"%></td>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"ผู้สมัครที่ถูกคัดเลือก":"Shortlisted"%></td>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"ผู้สมัครที่รับข้อเสนอ":"Offer Accepted"%></td>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"บัญชีดำ":"Blacklist"%></td>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"ตำแหน่งที่ได้รับความนิยมอันดับ 1":"Position Name Ranking No.1"%></td>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"ตำแหน่งที่ได้รับความนิยมอันดับ 2":"Position Name Ranking No.2"%></td>
					<td class="row1 center"style="text-align:center"><%=lang.equalsIgnoreCase("tha")?"ตำแหน่งที่ได้รับความนิยมอันดับ 3":"Position Name Ranking No.3"%></td>
				</tr>
				<%
					// >>>>>>>>>>>>  Current Zone  <<<<<<<<<<<<
					DecimalFormat DFO = new DecimalFormat("#,###.##");
					DbInquiry inqcan = new InitialInquiry(up).getDbInquiry("Simmcandidatewithgson");
					DbInquiry inqpre = new InitialInquiry(up).getDbInquiry("mprefix");
					DbInquiry inqrequest = new InitialInquiry(up).getDbInquiry("mrequest");
					DbInquiry inqjob = new InitialInquiry(up).getDbInquiry("mjobcode");
					DbInquiry inqsourcejob = new InitialInquiry(up).getDbInquiry("msourcejob");
					DbInquiry inqstat = new InitialInquiry(up).getDbInquiry("mstatus");
					DbInquiry inqcandidate = new InitialInquiry(up).getDbInquiry("mcandidate");
					DbInquiry inqcandidate_his = new InitialInquiry(up).getDbInquiry("inqcandidate_his");	
					inqcan.setColumn("*");

					inqcan.putChild(inqjob);
					inqcan.putChild(inqcandidate);
					inqcan.putChild(inqrequest);
					inqcan.putChild(inqsourcejob);
					inqcan.putChild(inqstat);

					DbInquiry inqapphis = new InitialInquiry(up).getDbInquiry("Simmapplicanthisotherwithgson");
					DbInquiry inqemp2 = new InitialInquiry(up).getDbInquiry("memployee");
					inqemp2.setColumn("*");
				//	inqcan.putChild(inqcandidate_his);
					inqapphis.putChild(inqjob);
					inqapphis.putChild(inqemp2);
					inqapphis.putChild(inqstat);
					inqapphis.putChild(inqsourcejob);
					inqapphis.setColumn("*");

					String sim3="";
					String sim4="";
					//out.print(filter);
					inqsourcejob.setFilter(filter);
					inqsourcejob.refresh();
					int recCount = inqsourcejob.recCount();
					int arr0 = 0;
					int arr1 = 0;
					int numall = 0;
					int numBlacklist=0,hire=0,pass=0,other = 0;
					int[] Ranking1 = new int[3];
					int alldata = 0;
					int alldatahis = 0;
					MyHashMap TOP1 = new MyHashMap();
					String[][] Loopdata = new String[recCount][1000];		
					inqcandidate.refresh();
						while(inqsourcejob.next()){	
						inqcan.setFilter(filter2);
						inqcan.refresh();
						inqapphis.setFilter(filter2);
						inqapphis.refresh();
							while(inqcan.next()){	
							Simmcandidatewithgson simmcandidatewithgson = (Simmcandidatewithgson) inqcan.getCurrentDbRecord();
								if(simmcandidatewithgson.mcandidateOther.sourcejob.equals(inqsourcejob.getString("msourcejob","sourcejobid"))){
								numall++;
								if(inqcan.getString("status").equals("14")){
									numBlacklist++;									
								}else if(inqcan.getString("status").equals("8") || inqcan.getString("status").equals("9")){
									hire++;
								}else if(inqcan.getString("status").equals("1") || inqcan.getString("status").equals("2") || inqcan.getString("status").equals("3") ||
										inqcan.getString("status").equals("4") || inqcan.getString("status").equals("5") || inqcan.getString("status").equals("6") ||
										inqcan.getString("status").equals("7") || inqcan.getString("status").equals("10") || inqcan.getString("status").equals("11") ||
										inqcan.getString("status").equals("12") || inqcan.getString("status").equals("13") ){
									pass++;
								}else {
									other++;
								}
									arr0++;								
							}
							alldata = numall;
							//fix error data/0
							if(alldata == 0){
								alldata =1;
							}
							if(String.valueOf(arr1+1).equals(simmcandidatewithgson.mcandidateOther.sourcejob)){
								Loopdata[arr1][3] = DFO.format(Double.valueOf(numBlacklist * 100/alldata )).toString()+"%";
								Loopdata[arr1][2] = DFO.format(Double.valueOf(hire * 100/alldata )).toString()+"%";		
								Loopdata[arr1][1] = DFO.format(Double.valueOf(pass * 100/alldata )).toString()+"%";								
								TOP1.putToSum(inqcan.getString("mjobcode","jobcodeid"),1); 
							}									
						}
						//HISTORY from inqcandidate_his
						inqapphis.refresh();
							while(inqapphis.next()){	
							Simmapplicanthisotherwithgson simmapplicanthisotherwithgson = (Simmapplicanthisotherwithgson) inqapphis.getCurrentDbRecord();
								if(simmapplicanthisotherwithgson.mapplicanthisother.sourcejob.equals(inqsourcejob.getString("msourcejob","sourcejobid"))){
									alldatahis++;
								if(inqapphis.getString("status").equals("14")){
									numBlacklist++;
								}else if(inqapphis.getString("status").equals("8") || inqapphis.getString("status").equals("9")){
									hire++;
								}else if(inqapphis.getString("status").equals("1") || inqapphis.getString("status").equals("2") || inqapphis.getString("status").equals("3") ||
								inqapphis.getString("status").equals("4") || inqapphis.getString("status").equals("5") || inqapphis.getString("status").equals("6") ||
								inqapphis.getString("status").equals("7") || inqapphis.getString("status").equals("10") || inqapphis.getString("status").equals("11") ||
								inqapphis.getString("status").equals("12") || inqapphis.getString("status").equals("13") ){
									pass++;
								}else {
									other++;
								}
									arr0++;							
							}
							alldata = numall +alldatahis; // summary
							//fix error data/0
							if(alldata == 0){
								alldata =1;
							}
							if(String.valueOf(arr1+1).equals(simmapplicanthisotherwithgson.mapplicanthisother.sourcejob)){
								Loopdata[arr1][3] = DFO.format(Double.valueOf(numBlacklist * 100/alldata )).toString()+"%";
								Loopdata[arr1][2] = DFO.format(Double.valueOf(hire * 100/alldata )).toString()+"%";		
								Loopdata[arr1][1] = DFO.format(Double.valueOf(pass * 100/alldata )).toString()+"%";	
								TOP1.putToSum(inqcan.getString("mjobcode","jobcodeid"),1); 
							}	
						}
					String sql_sourcejob = inqsourcejob.getString("msourcejob","sourcejobid");
					String sql_count = "select count(*) as count from mcandidate";
					String dbName = up.getDbName();
					String dbtype = up.getDbType();
				
						String sql = " WITH query1 AS (SELECT COUNT(MCAN.JOBID) AS COUNT,MCAN.JOBID,JOB.TDESC "+
								" FROM MCANDIDATE MCAN "+
								" INNER JOIN MJOBCODE JOB ON  JOB.JOBCODEID = MCAN.JOBID "+ 
								" WHERE "+filter2+" AND OTHER LIKE '%\"sourcejob\":\""+sql_sourcejob+"\"%' "+
								" GROUP BY JOBID,JOB.TDESC "+
								" UNION ALL "+
								" SELECT COUNT(MHIS.JOBID) AS COUNT,MHIS.JOBID,JOB.TDESC "+
								" FROM MAPPLICANT_HIS MHIS "+
								" INNER JOIN MJOBCODE JOB ON  JOB.JOBCODEID = MHIS.JOBID "+
								" WHERE "+filter2+" AND OTHER LIKE '%\"sourcejob\":\""+sql_sourcejob+"\"%' "+
								" GROUP BY JOBID,JOB.TDESC )"+
								" SELECT sum(count) as count2,jobid,tdesc "+ 
								" from query1 " +
								" GROUP BY count,jobid,tdesc "+
								" ORDER BY count2 desc,jobid ";
					int old0 = 0, new0 = 0;
					String old1 = "",new1 = "";
					String tableName = "MCANDIDATE&MAPPLICANT_HIS";
					DataSet dataset1 = new DataSet(sql_count, dbName, tableName ); //หาจำนวนบรรทัด
					dataset1.initConnection(up);
					dataset1.next();
					String index1 = chk.chkNullString(dataset1.getString("jobid"));
					dataset1.closeConnection();	
					dataset1.setSql(sql); // หา Record
					dataset1.initConnection(up);
					int loop = 4; // setArray[][4]
					int addloop = 0; // Set if oldCount==newCount to same column
					int countdataset = 0;
					while(dataset1.next()){
						
						if(addloop == 0){
						new0 = Integer.valueOf(dataset1.getString("count2"));
						new1 = dataset1.getString("tdesc");
						Loopdata[arr1][loop+addloop] = new1;
						}
						else{
						old0 = new0;
						old1 = new1;
						new0 = Integer.valueOf(dataset1.getString("count2"));
						new1 = dataset1.getString("tdesc");
						if(old0 == new0){ // if oldCount == newCount get to same column
							addloop--;
							Loopdata[arr1][loop+addloop] +=", " + dataset1.getString("tdesc");
						}else{
							//if blank  :some no tdesc or jobcodeid
							Loopdata[arr1][loop+addloop] = dataset1.getString("tdesc");
						}
					}	
					addloop++;
					countdataset++;
					}
					dataset1.closeConnection();

					Loopdata[arr1][0] = inqsourcejob.getString("msourcejob","tdesc");
					%>
					<tr>
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][0])%></td>	
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][1],"0%")%></td>	
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][2],"0%")%></td>	
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][3],"0%")%></td>
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][4],"-")%></td>
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][5],"-")%></td>
						<td class='center'style="text-align:center"><%=chk.chkNullString(Loopdata[arr1][6],"-")%></td>
					</tr>
				<%
					numall=0;
					arr1++;
					numBlacklist=0;
					hire=0;
					pass=0;
					arr0=0;
					alldata=0;
					alldatahis=0;
					TOP1.clear();// To Check Data in Table
					}		
				%>
			</table>
		</form>
	</body>
</html>