PSRN001_EXP.jsp 14.8 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.csc.library.entry.HelpEntry,com.csc.library.system.Task"%>
<%@ page import="com.csc.library.database.*,com.csc.library.session.*"  %>
<%@ page import="com.csc.library.utilities.CheckNull"%>
<%@ page import="com.csc.library.utilities.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*"%>
<% //request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="PSR002" class="com.csc.library.system.Task" scope="page"/>
<%
	//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 cc = new CscCalendar();
	PSR002.setChannel(request, response);
	HelpEntry screen = (HelpEntry) PSR002.process("HelpEntry","MEMPLOYEEREPORTHELP");
	screen.setMaxLine(20);
    screen.getInquiry().setParam("__active_on", "off");
	String statusFirst = chk.chkNullString(request.getParameter("statusFirst"), "false");
	String branch = chk.chkNullString(request.getParameter("branch"));
	String branchDesc = chk.chkNullString(request.getParameter("MBRANCH@TDESC"));
	String startdate = chk.chkNullString(request.getParameter("startdate"), cc.getDDMMYYYY());
	String enddate = chk.chkNullString(request.getParameter("enddate"), cc.getDDMMYYYY());
	String view = chk.chkNullString(request.getParameter("__view"));
	String filter = chk.chkNullString(request.getParameter("__filter"),"1=1");
	String allbranch = chk.chkNullString(request.getParameter("allbranch"));
	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 bu5 = chk.chkNullString(request.getParameter("__bu5"));
	String workarea = chk.chkNullString(request.getParameter("__workarea"));
	UProfile uprofile = screen.getUProfile();
	CscCalendar st = new CscCalendar(startdate);
	CscCalendar en = new CscCalendar(enddate);
	screen.process();

	if(!allbranch.equals("")){
		filter += allbranch;
	}

	if(!branch.equals("")){
		filter += " and branch = '"+branch+"'";
	}

	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(!bu5.equals("")){
		filter += " and bu5 = '"+bu5+"'";
	}

	if(!workarea.equals("")){
		filter += " and workarea = '"+workarea+"'";
	}

	if(!startdate.equals("")){
		filter += " and startdate between '"+st.getYYYYMMDD()+"' and '"+en.getYYYYMMDD()+"'";
	}
%>

<%!
public static int daysBetween(CscCalendar d1, CscCalendar d2) {
  return (int) ((d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24))+1;
 }
%>
<%!
  private boolean chkZero(String val) {
  	return val.equals("0000000")?true:false;
  }

  private boolean chkBlank(String val) {
  	return val.equals("")?true:false;
  }

  private String getDescBu(String table, String bu, String buid,UProfile up) {
  	String val = "";
  	try {
  		DbInquiry mbu = new InitialInquiry(up).getDbInquiry(table);
  		mbu.setColumn("tdesc");
  		mbu.clearOldCondition();
  		mbu.setFilter(bu + "='"+ buid +"'");
  		mbu.refresh();
		if (mbu.next()) {
			val = mbu.getString("tdesc");
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
  	return val;
  }

private String getDescPosition(String table, String po,UProfile up) {
  	String val = "";
  	try {
  		DbInquiry mbu = new InitialInquiry(up).getDbInquiry(table);
  		mbu.setColumn("tdesc");
  		mbu.clearOldCondition();
  		mbu.setFilter("positionid='"+ po +"'");
  		mbu.refresh();
		if (mbu.next()) {
			val = mbu.getString("tdesc");
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
  	return val;
}
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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"> -->
<!-- <link href="../CSS/bootstrap.css" rel="stylesheet"> -->
<script src="../JS/jquery-1.11.3.min.js"></script>
 <!-- <script src="../JS/bootstrap.min.js"></script> -->
<script type="text/javascript" language="javascript" src="../JS/SCREEN.js"></script>
<script type="text/javascript" language="javascript" src="../JS/VIEWCALENDAR.js"></script>
<script language="javascript"  src="../JS/DATEINPUT.js"></script>
<script language="javascript">setLang("<%=screen.getUProfile().get("lang")%>");</script>

<script language="JavaScript" type="text/JavaScript">

function goHelp(helpName,inputName) {
	var helpReturn = "";
	helpReturn = inputName+":branchid,MBRANCH@TDESC";
	linkHelp_Return(helpName,helpReturn);
}

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

	}
}

function GoPrint(){
	with(document.cscform){
	var param = "PSR001_PDF.jsp";
	window.open(param);
		submit();
	}
}
function GoView(){
	with(document.cscform){
		__view.value = "1"
		submit();
	}
}

function checkBox(){
	with(document.cscform){
		if(allbranch.checked==true){
			allbranch.value=" and BRANCH in (select branchid from MBRANCH) ";
			//alert(allbranch.value);
		}else{
			allbranch.value="";
			//alert(allbranch.value);
		}
	}
}

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

	$('#preview').click(function() {
		 GoView();
	});

	$('#print').click(function() {
		GoPrint();
	});

	});



</script>
<style>
	.table-condensed > tbody > tr > td {
		padding: 4px;
		border: 0px solid #ddd;
	}
	img[height="20"] {
		padding: 0px;
	}
	.table-bordered th {
		text-align: center;
		vertical-align: middle;
	}
	.eiei {
		overflow: scroll;
		height: 100%;
	}
	.format_text{
	  mso-number-format:"\@";/*force text*/
	}
</style>
</head>
<body leftmargin="0" topmargin="0">
	<form name="cscform" method="post">
		<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
		<input type="hidden" name="__fixCon" value="">
		<input type="hidden" name="__cmd" value="">
		<input type="hidden" name="__view" value="">
		<input type="hidden" name="__screen" value="PSR020">
		<input type="hidden" name="__goPage" value ="">
		<input type="hidden" name="__employeeid" value="">
		<input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
		<input type="hidden" name="__orderBy" value="">
		<input type="hidden" name="__empview" value="">
		<input type="hidden" name="__calendar" value="">
		<input type="hidden" name="__filter" value="<%=request.getParameter("__filter")%>">
		<input type="hidden" name="branch" value="<%=request.getParameter("branch")%>">
		<input type="hidden" name="startdate" value="<%=request.getParameter("startdate")%>">
		<input type="hidden" name="startdate" value="<%=request.getParameter("enddate")%>">
		<input type="hidden" name="allbranch" value="<%=request.getParameter("allbranch")%>">
		<script language="javascript">getInputFormatDate();</script>
		<table class="table table-bordered maxsize" border="1">
		<%
			DbRecord emp_rec = new InitialRecord(screen.getUProfile()).getDbRecord("memployee");
			DbInquiry op = new InitialInquiry(screen.getUProfile()).getDbInquiry("COLOPTION");
			op.setColumn("*");
			op.setFilter("optionid = '22' ");
			op.refresh();
			op.next();

			Map<Integer, Integer> linkmap = new LinkedHashMap<Integer, Integer>();
			for(int i=1;i<=6;i++){
				String chknum = op.getString("chk"+i);
				if(chknum.equals("1")){
					//out.print(i+"</br>");
					linkmap.put(i,Integer.valueOf(op.getString("col"+i)));
				}
			}
			int colspan = 5+linkmap.size() ;

        	SimpleDateFormat df = new SimpleDateFormat("hh:mm a", Locale.ENGLISH);
        	GregorianCalendar gc= new GregorianCalendar();

            boolean langthai = screen.getUProfile().get("lang").equalsIgnoreCase("THA");
            String str_reportname = "", str_perioddate = "", str_printdate = "", str_printby = "", str_refer = "";
            if(langthai){
                str_reportname = "รายงาน :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;รายงานรายชื่อพนักงานเข้าใหม่และการคำนวณ Probation";
                str_perioddate = "ช่วงวันที่ :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+startdate+" ถึง "+enddate;
                str_printdate = "วันที่พิมพ์ :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;วัน"+cc.getLongThiDOW()+"ที่ "+cc.getDate()+ " " + cc.getThaiLongMonth() + " พ.ศ. "+ cc.getThaiYYYY() +
              			" " +cc.getHHMM() + " น.";
                str_printby = "พิมพ์โดย :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+screen.getUProfile().get("tfullname");
                str_refer = "อ้างอิง # RPI2100";
            } else {
                str_reportname = "Report Name :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New Employee List And Probation Calulation Report";
                str_perioddate = "Period Date :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+startdate+" To "+enddate;
                str_printdate = "Print Date :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+cc.getEngFull()+ " " + df.format((Date)gc.getTime());
                str_printby = "Print By :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+screen.getUProfile().get("efullname");
                str_refer = "Ref # RPI2100";
            }

		%>
			<thead>
				<tr>
					<td colspan="<%=colspan+2%>" style="font-size: 150%;"><b><%=screen.getUProfile().get("companyname") %></b></td>
				</tr>
				<tr>
					<td colspan="2"><b><%=langthai?"รายงาน :":"Report Name :"%></b></td>
					<td colspan="<%=colspan%>"><%=langthai?"รายงานรายชื่อพนักงานเข้าใหม่และการคำนวณ Probation":"New Employee List And Probation Calulation Report"%></td>
				</tr>
				<tr>
					<td colspan="2"><b><%=langthai?"ช่วงวันที่ :":"Period Date :"%></b></td>
					<td colspan="<%=colspan%>"><%=langthai?startdate+" ถึง "+enddate:startdate+" To "+enddate%></td>
				</tr>
				<tr>
					<td colspan="2"><b><%=langthai?"วันที่พิมพ์ :":"Print Date :"%></b></td>
					<td colspan="<%=colspan%>"><%=langthai?"วัน"+cc.getLongThiDOW()+"ที่ "+cc.getDate()+ " " + cc.getThaiLongMonth() + " พ.ศ. "+ cc.getThaiYYYY() +
	              			" " +cc.getHHMM() + " น.":cc.getEngFull()+ " " + df.format((Date)gc.getTime())%></td>
				</tr>
				<tr>
					<td colspan="2"><b><%=langthai?"พิมพ์โดย :":"Print By :"%></td>
					<td colspan="<%=colspan-2%>"><%=screen.getUProfile().get("fullname")%></td>
					<td colspan="2" style="vertical-align: right;"><%=langthai?"อ้างอิง # RPI2100":"Ref # RPI2100"%></td>
				</tr>
				<tr>
					<th rowspan="2" style="vertical-align: middle;"><%=langthai?"ลำดับ":"No."%></th>
					<th rowspan="2" style="vertical-align: middle;"><%=langthai?"รหัสพนักงาน":"Employee ID"%></th>
					<th rowspan="2" style="vertical-align: middle;"><%=langthai?"ชื่อ-นามสกุล":"Name-Surname"%></th>
					<th rowspan="2" style="vertical-align: middle;"><%=emp_rec.getField("bu1").getDescription()%></th>
					<th rowspan="2" style="vertical-align: middle;"><%=emp_rec.getField("bu2").getDescription()%></th>
					<th rowspan="2" style="vertical-align: middle;"><%=emp_rec.getField("bu3").getDescription()%></th>
					<th rowspan="2" style="vertical-align: middle;"><%=langthai?"วันที่เริ่มต้น":"Start Date"%></th>
					<% if(linkmap.size() != 0){ %>
					<th colspan="<%=linkmap.size()%>" style="vertical-align: middle;"><%=langthai?"วันที่ครบกำหนดทดลองงาน":"Probation Date"%></th>
					<% } %>
				</tr>
				<tr>
					<%
						for(Integer key : linkmap.keySet()){
					%>
						<th style="vertical-align: middle;">
							<%=langthai?"ครบ&nbsp;"+linkmap.get(key)+"&nbsp;วัน":linkmap.get(key)+"&nbsp;Day(s)"%>
						</th>
					<%
						}
					%>
				</tr>
			</thead>
			<tbody>
		<%
		int no = 1;
		String DbType = screen.getUProfile().getDbType().toUpperCase();
		String strJoiner = "+";
		if(DbType.equals("PGSQL") || DbType.equals("ORACLE")){
			strJoiner = "||";
		}

		String sql="";
		if(screen.getUProfile().get("lang").equals("eng")){
			 sql = "select me.EMPLOYEEID,pre.EDESC"+strJoiner+"me.EFNAME"+strJoiner+"' '"+strJoiner+"me.ELNAME as fullname,b1.EDESC as bu1,b2.EDESC as bu2,b3.EDESC as bu3,STARTDATE from MEMPLOYEE me left join MPREFIX pre on me.EMP_PREFIX = pre.PREFIXID left join MBU3 b3 on me.BU3 = b3.BU3ID left join MBU2 b2 on me.BU2 = b2.BU2ID left join MBU1 b1 on me.BU1 = b1.BU1ID where "+filter+" ORDER BY me.bu1,me.bu2,me.bu3,me.bu4,me.bu5";
		}else{
			 sql = "select me.EMPLOYEEID,pre.TDESC"+strJoiner+"me.FNAME"+strJoiner+"' '"+strJoiner+"me.LNAME as fullname,b1.TDESC as bu1,b2.TDESC as bu2,b3.TDESC as bu3,STARTDATE from MEMPLOYEE me left join MPREFIX pre on me.EMP_PREFIX = pre.PREFIXID left join MBU3 b3 on me.BU3 = b3.BU3ID left join MBU2 b2 on me.BU2 = b2.BU2ID left join MBU1 b1 on me.BU1 = b1.BU1ID where "+filter+" ORDER BY me.bu1,me.bu2,me.bu3,me.bu4,me.bu5";
		}
		//out.print(sql);
		try{
			DataSet ds = new DataSet(sql,screen.getUProfile().get("dbname"),"Memployee");
			ds.initConnection(screen.getUProfile());
			while (ds.next()) {
				CscCalendar stDate = new CscCalendar(chk.chkNullString(ds.getString("startdate")));

		%>
				<tr>
					<td align="center"><div style="width: 50px;"><%=no%></div></td>
					<td align="center"><div style="width: 150px;" class="format_text"><%=chk.chkNullString(ds.getString("employeeid"))%></div></td>
					<td align="left"><div style="width: 300px;"><%=chk.chkNullString(ds.getString("fullname"))%></div></td>
					<td align="left"><div style="width: 200px;"><%=chk.chkNullString(ds.getString("bu1"))%></div></td>
					<td align="left"><div style="width: 200px;"><%=chk.chkNullString(ds.getString("bu2"))%></div></td>
					<td align="left"><div style="width: 200px;"><%=chk.chkNullString(ds.getString("bu3"))%></div></td>
					<td align="center"><div style="width: 100px;"><%=stDate.getDDMMYYYY()%></div></td>
					<%
						for (Integer key : linkmap.keySet()){
					%>
						<td align="center"><div style="width: 100px;"><%=new CscCalendar(chk.chkNullString(ds.getString("startdate"))).incDate(linkmap.get(key)).getDDMMYYYY()%></div></td>
					<%
						}
					%>
				</tr>
		<%
				no++;
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
		%>
			</tbody>
		</table>
		<!----------BEGIN CSC ENDING ZONE ------------------------>
		<%=screen.endJSP()%>
		<!----------END CSC ENDING ZONE -------------------------->
	</form>
</body>
</html>