PRI004_EXP.jsp 12.2 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
<!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,com.csc.library.database.*,java.rmi.RemoteException"%>
<%@page import="java.util.*,java.io.*,java.sql.*"%>
<%@ include file="../CHECKPROFILE.jsp" %>
<script src="//code.jquery.com/jquery-1.11.1.js"></script>
<%

	response.setHeader("Cache-Control","must-revalidate");
	response.setContentType("application/vnd.ms-excel; UTF-8");
	response.setHeader("Content-Disposition", "inline; filename=" + "export.xls");


	DecimalFormat num = new DecimalFormat("#,###");
	DecimalFormat dmfm = new DecimalFormat("#,##0.00");

	CheckNull chk = new CheckNull();
	
	String view = chk.chkNullString(request.getParameter("__view"));
	String date1 = chk.chkNullString(request.getParameter("__date1"));
	String date2 = chk.chkNullString(request.getParameter("__date2"));
	CscCalendar st = new CscCalendar(date1);
	CscCalendar en = new CscCalendar(date2);
	//int YY = Integer.parseInt(year)-543;
	//st.setYear(YY);
	//st.setMonth(0);
	st.setDate(1);
	//en.setYear(YY);
	en.setDate(1);
	//if(st.getYear() != new CscCalendar().getYear()){
	//	en.setMonth(11);
	//}
	
	//out.print("ST = "+st.getDDMMYYYY());

%>

<%!

	private int getMempl_movement(String bu5, String emp_position, String year, String month, UProfile uprofile)throws RemoteException, SQLException{
		CheckNull chk = new CheckNull();
		int yyyy = Integer.parseInt(year)-543;
		int num = 0;
		DataSet ds = null;
		
		ds = new DataSet(" select SUM(EVENT)num from MEMPL_MOVEMENT where BU5='"+bu5+"' and EMP_POSITION='"+emp_position+"' and EFF_DATE <='"+yyyy+"-"+month+"-31' " , uprofile.getDbName() , "MEMPL_MOVEMENT"); 
		ds.initConnection(uprofile);
		if(ds.next()){
			num = Integer.parseInt(chk.chkNullString(ds.getString("num"),"0"));
		}
		return num;
	}

	private int getSum_Mempl_movement(String emp_position, String year,String month, UProfile uprofile)throws RemoteException, SQLException{
		CheckNull chk = new CheckNull();
		int yyyy = Integer.parseInt(year)-543;
		int num = 0;
		DataSet ds = null;
		
		ds = new DataSet(" select SUM(EVENT)num from MEMPL_MOVEMENT where BU5 in (select BU5ID from MBU5) and EMP_POSITION='"+emp_position+"' and EFF_DATE <='"+yyyy+"-"+month+"-31' " , uprofile.getDbName() , "MEMPL_MOVEMENT"); 
		ds.initConnection(uprofile);
		if(ds.next()){
			num = Integer.parseInt(chk.chkNullString(ds.getString("num"),"0"));
		}
		return num;
	}
%>

<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 TYPE='text/JavaScript' SRC='../JS/DATEINPUT.js'></SCRIPT>
<SCRIPT TYPE='text/JavaScript' SRC='../JS/VIEWCALENDAR.js'></SCRIPT>
<script language="javascript">setLang('<%=uprofile.get("lang")%>');</script>
<script language="javascript">getTitleName();</script>


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

//-->
function back(unit){
	with(window.opener.document.cscform){
	        locateId.value =unit;
	}
	window.close();
}

//-->

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

//		__export.value = "1";
//		action = "PRU212_EXP.jsp";
//		target = "";
//		submit();
	}
}

function GoProcess(){
	with(document.cscform){
		submit();
	}
}
function GoView(){
	with(document.cscform){
		__view.value = "1"
		submit();
	}
}

</script>
</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="PRI004_EXP.jsp">


<!----------BEGIN CSC INITIAL ZONE ------------------------>

<%//=screen.InitialVariable()%>

<!----------END CSC INITIAL ZONE -------------------------->

<input type="hidden" name="__cmd" value="">
<input type="hidden" name="__screen" value="PRI004_EXP">
<input type="hidden" name="__help" value="">
<input type="hidden" name="__goPage" value="">
<input type="hidden" name="__language" value="<%=uprofile.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="__view" value="<%=request.getParameter("__view")%>">
<input type="hidden" name="__export" value=""> 
<input type="hidden" name="__calendar" value=""> 
<input type="hidden" name="__filter" value="<%//=sql%>"> 
<script language="javascript">getInputFormatDate()</script>

<br>
<div align="center">
<table class="large" cellpadding="0"  cellspacing="0"  >
	<!-- <tr> 
		<td   class="header">PRI004_EXP , รายงานเงินได้-ค่าเฉลี่ยต้นทุน</td>
	</tr>
	<tr>
		<td  class="blankspace"></td>
	</tr>
	<tr>
		<td  class="" align="center">
			กรุณาระบุช่วงวันที่
			<input name="__date1" onkeyup="formatDate(this)" onkeypress="chkIntegerOfDate(this.value)" onblur="chkInputDate2(this,__date2)" type="text" size="10" maxLength="8" value="<%//=chk.chkNullString(request.getParameter("__date1"))%>"/>
			<a onmouseover="MM_swapImage('calendar1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:;"><img name="calendar1" align="absmiddle" onclick="viewCal('__date1')" alt="Calendar" src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" border="0"/></a>
			-
			<input name="__date2" onkeyup="formatDate(this)" onkeypress="chkIntegerOfDate(this.value)" onblur="chkInputDate2(__date1,this)" type="text" size="10" maxLength="8" value="<%//=chk.chkNullString(request.getParameter("__date2"))%>"/>
			<a onmouseover="MM_swapImage('calendar2','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:;"><img name="calendar2" align="absmiddle" onclick="viewCal('__date2')" alt="Calendar" src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" border="0"/></a>
		</td>
	</tr>
	<tr>
		<td  class="blankspace"></td>
	</tr>
	<tr>
		<td>
			<table class="maxsize" align="center" cellpadding="0" cellspacing="0" class="large">
				<tr>
					 <td align="center"><div class="button"><a href="javascript:GoExport();"><img src="../IMAGES/BUTTON/EXPORT.gif"  border="0"/></a>&nbsp;&nbsp;
					 <a href="javascript:GoView();"><img src="../IMAGES/BUTTON/VIEW.gif"  border="0"/></a></div></td>
					 
				</tr>
			</table>
		</td>
    </tr> -->
	<%
	DataSet ds = null;
	String sql = "";
	if(true){
	do{
	%>
	<tr>
		<td  class="blankspace"></td>
	</tr>
	<tr> 
		<td class="" align="center"><b>เงินได้และสวัสดิการประจำฝ่าย เดือน <%=st.getThaiShortMonth()%>&nbsp;<%=st.getThaiYY()%><b></td>
	</tr>
	<tr> 
		<td>
			 <table height="" align="center" cellpadding="0" cellspacing="0" class="maxsize" border="1" width="100%">	
				<tr bgcolor="">
					<td> 
						<table class="maxsize" border="1" cellpadding="1" cellspacing="1" cols=11 bgcolor="">
							<tr> 
								<td nowrap class="" width="" align="center"><b>หน่วยงาน</b></td>
								<td nowrap class="" width="" align="center"><b>จำนวนพนักงาน</b></td>
								<td nowrap class="" width="" align="center"><b>เงินเดือน / ค่าจ้าง</b></td>
								<td nowrap class="" width="" align="center"><b>ค่าล่วงเวลา</b></td>
								<td nowrap class="" width="" align="center"><b>สวัสดิการต่างๆ<br>ไม่รวมค่ารักษาพยาบาล</b></td>
								<td nowrap class="" width="" align="center"><b>เงินสมทบ P/F</b></td>
								<td nowrap class="" width="" align="center"><font color="red"><b>Man Hour Lost</b></font></td>
								<td nowrap class="" width="" align="center"><b>รวม</b></td>
								<td nowrap class="" width="" align="center"><b>ค่าเฉลี่ยต้นทุนพนักงาน / คน</b></td>
							</tr>
						<%
							sql = "SELECT r.BU5,bu5.TDESC ";
							sql += ",COUNT(r.EMPLOYEEID)AMOUNT ";
							sql += ",r.GENMONTH ";
							sql += ",SUM(r.GROUP_1)GROUP_1 ";
							sql += ",SUM(r.GROUP_6)GROUP_6 ";
							sql += ",SUM(r.GROUP_W)GROUP_W ";
							sql += ",SUM(r.GROUP_L)GROUP_L ";
							sql += "FROM VW_INTELLIGENT_REPORT4 r ";
							sql += "LEFT JOIN MBU5 bu5 on r.BU5=bu5.BU5ID ";
							sql += "WHERE ISNULL(r.BU5,'')!='' ";
							sql += "AND r.GENMONTH = '"+st.getYear()+"-"+st.getMM()+"' ";
							sql += "GROUP BY r.BU5,bu5.TDESC,r.GENMONTH ";
							sql += "HAVING SUM(r.GROUP_1) > 0 OR SUM(r.GROUP_6) > 0 OR SUM(r.GROUP_W) > 0 OR SUM(r.GROUP_L) > 0 ";
							sql += "ORDER BY GENMONTH,BU5 ";
							ds = new DataSet(sql , uprofile.getDbName() , "VW_INTELLIGENT_REPORT4"); 
							ds.initConnection(uprofile);
							int sum_amount = 0;
							Double sum_group_1 = 0.0;
							Double sum_group_6 = 0.0;
							Double sum_group_w = 0.0;
							Double sum_group_l = 0.0;
							Double sum_total = 0.0;
							while(ds.next()){
								int amount = Integer.parseInt(chk.chkNullString(ds.getString("amount"),"0"));
								double  group_1 = Double.parseDouble(chk.chkNullString(ds.getString("group_1"),"0.00"));
								double  group_6 = Double.parseDouble(chk.chkNullString(ds.getString("group_6"),"0.00"));
								double  group_w = Double.parseDouble(chk.chkNullString(ds.getString("group_w"),"0.00"));
								double  group_l = Double.parseDouble(chk.chkNullString(ds.getString("group_l"),"0.00"));
								double  total = group_1+group_6+group_w+group_l;


								sum_amount += amount;
								sum_group_1 += group_1;
								sum_group_6 += group_6;
								sum_group_w += group_w;
								sum_group_l += group_l;
								sum_total += total;
						%>
							<tr> 
								<td nowrap class="" width="" align="center"><%=ds.getString("tdesc")%></td>
								<td nowrap class="" width="" align="center"><%=ds.getString("amount")%></td>
								<td nowrap class="" width="" align="center"><%=dmfm.format(group_1)%></td>
								<td nowrap class="" width="" align="center"><%=dmfm.format(group_6)%></td>
								<td nowrap class="" width="" align="center"><%=dmfm.format(group_w)%></td>
								<td nowrap class="" width="" align="center"><%=dmfm.format(group_l)%></td>
								<td nowrap class="" width="" align="center"></td>
								<td nowrap class="" width="" align="center"><%=dmfm.format(total)%></td>
								<td nowrap class="" width="" align="center"><%=dmfm.format(total / amount)%></td>
							</tr>
						<%
							}
							ds.closeConnection();
						%>
							<tr> 
								<td nowrap class="" width="" align="center"><b>Grand Total</b></td>
								<td nowrap class="" width="" align="center"><b><%=num.format(sum_amount)%></b></td>
								<td nowrap class="" width="" align="center"><b><%=dmfm.format(sum_group_1)%></b></td>
								<td nowrap class="" width="" align="center"><b><%=dmfm.format(sum_group_6)%></b></td>
								<td nowrap class="" width="" align="center"><b><%=dmfm.format(sum_group_w)%></b></td>
								<td nowrap class="" width="" align="center"><b><%=dmfm.format(sum_group_l)%></b></td>
								<td nowrap class="" width="" align="center"><b>&nbsp;</b></td>
								<td nowrap class="" width="" align="center"><b><%=dmfm.format(sum_total)%></b></td>
								<td nowrap class="" width="" align="center"><b><%=sum_amount==0?"0.00":dmfm.format(sum_total / sum_amount)%></b></td>
							</tr>
						</table>
					</td>

				</tr>
			</table>

		</td>
	</tr>
	<%
			st.incMonth(1);
			//out.print("ST : "+st.getDDMMYYYY()+"   EN : "+en.getDDMMYYYY());
		}while(!st.afterDate(en));
	}
	%>
	<tr>
		<td  class="blankspace"></td>
	</tr>

    <tr bordercolor="0069B3"> 
      <td  class="bottom"></td>
    </tr>
</table>
</form>
</body>
</html>