<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*,com.csc.library.formula.*"%>
<%@page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@page import="com.csc.library.timeattendance.MyBudgetYear" %>
<%@page import="java.text.DecimalFormat"%>
<jsp:useBean id="TAU_PHALLOWANCE" class="com.csc.library.system.Task" scope="page"/>
<%
try {
	ThaiUtilities thaicode = new ThaiUtilities();
	DecimalFormat df = new DecimalFormat("#0.00");

	CheckNull chk = new CheckNull();
	FormulaString fs = new FormulaString();

	String empName = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__empName")));
	String empID = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__empID")));
	String yearid = chk.chkNullString(request.getParameter("__yearid"),"0");
	String ldesc = thaicode.ASCII2Unicode(chk.chkNullString(request.getParameter("__ldesc")));
	String fixcon = chk.chkNullString(request.getParameter("__fixCon"),"0");
	

	TAU_PHALLOWANCE.setChannel(request,response);
	HelpEntry screen = (HelpEntry) TAU_PHALLOWANCE.process("HelpEntry","TAU_PHALLOWANCEHELP");
	screen.referLangOff();

	MyBudgetYear mby = new MyBudgetYear(screen.getUProfile());
	CscCalendar cs[] = mby.getBudgetYearPeriod(Integer.parseInt(yearid));

	String holid = "";
	DbRecord empdb = new InitialRecord(screen.getUProfile()).getDbRecord("Memployee");
	empdb.setParam("rsc_skip","true");
	empdb.setColumn("employeeid,companyid,time0");
	empdb.set("employeeid", empID);
	if(empdb.search() == 1){
		DbRecord mdb = new InitialRecord(screen.getUProfile()).getDbRecord("Mtime0");
		mdb.setColumn("time0id,companyid,holidaycode");
		mdb.set("time0id", empdb.getString("time0"));
		if(mdb.search() == 1){
			holid = mdb.getString("holidaycode");
		}
	}
	
	screen.inq.setFilter("holidayid = '" + holid+ "' and hdate between '" + cs[0].getYYYYMMDD() + "' and '" + cs[1].getYYYYMMDD() + "'");
	//out.print("holidaycode = '" + holid+ "' and dateid between '" + cs[0].getYYYYMMDD() + "' and '" + cs[1].getYYYYMMDD() + "'");
	screen.process();

	String lang = screen.getUProfile().get("lang") ;



%>
<!DOCTYPE HTML>
<html ng-app="myHR">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Employee View</title>
		
		<link rel="stylesheet" href="<%=request.getContextPath()%>/CSS/font-awesome.css">
		<link rel="stylesheet" type="text/css" href="../CSS/Bootstrap/css/bootstrap.css" />
		<link rel="stylesheet" type="text/css" href="../CSS/EMPVIEW_LAYOUT.min.css" />
		
		<script type="text/javascript" src="../JS/SCREEN.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 type="text/javascript" src="../JS/VIEWCALENDAR.js"></script>		
		
		<script language="javascript">
		
			setLang('<%=screen.getUProfile().get("lang")%>');
		<!--
			function MM_swapImgRestore() { //v3.0
			  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
			}

			function MM_preloadImages() { //v3.0
			  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
				var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
			}

			function MM_findObj(n, d) { //v4.01
			  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
				d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
			  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			  if(!x && d.getElementById) x=d.getElementById(n); return x;
			}

			function MM_swapImage() { //v3.0
			  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
			   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
			}
		//-->
		</script>

	</head>
	<body>
		<div class="bg-com"></div>
		
		<div class="container csc-content">
			<form name="cscform" method="post" >
 

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

				<%=screen.InitialVariable()%>

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

				<input type="hidden"name="__screen"  value="TAU_PHALLOWANCE">
				<input type="hidden" name="__fixCon" value="<%=request.getParameter("__fixCon")%>">
				<input type="hidden" name="__cmd"  value="">
				<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
				<input name="__companyid" type="hidden" value='<%=screen.getUProfile().get("companyid")%>'>
				<input type="hidden" name="__employeeid" value="<%=empID%>">
				<input type="hidden" name="__referPage" value="">
				<input type="hidden" name="__childFilter">
				<input type="hidden" name="__date_start" value="<%=cs[0].getYYYYMMDD()%>">
				<input type="hidden" name="__date_end" value="<%=cs[1].getYYYYMMDD()%>">
				<input type="hidden" name="date_start" value="<%=cs[0].getYYYYMMDD()%>">
				<input type="hidden" name="date_end" value="<%=cs[0].getYYYYMMDD()%>">
				<input type="hidden" name="__pageCall" value="<%=request.getParameter("__screen")%>">
				<input type="hidden" name="__gorec">
	
				<div class="csc-block">
					<div class="center">
						<h3 class="csc-block-head">Leave allowance</h3>
					</div></br>
					
					<div class="row">
						<div class="form-group">
							<div class="col-md-3 col-sm-3 col-xs-3">
								<label class="control-label label-right" swlang code='SW000274'>Employee ID</label>
							</div>
							<div class="col-md-2 col-sm-2 col-xs-2">
								<label class="control-label"><%=empID%></label>
							</div>
							<div class="col-md-3 col-sm-3 col-xs-3">
								<label class="control-label label-right" swlang code='SW000195'>Name</label>
							</div>
							<div class="col-md-3 col-sm-3 col-xs-3">
								<label class="control-label"><%=empName%></label>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="form-group">
							<div class="col-md-3 col-sm-3 col-xs-3">
								<label class="control-label label-right" swlang code='SW005161'>Leave Description</label>
							</div>
							<div class="col-md-2 col-sm-2 col-xs-2">
								<label class="control-label"><%=ldesc%></label>
							</div>
							<div class="col-md-3 col-sm-3 col-xs-3">
								<label class="control-label label-right" swlang code='SW000702'>Date Between</label>
							</div>
							<div class="col-md-3 col-sm-3 col-xs-3">
								<label class="control-label"><%=cs[0].getDDMMYYYY()%>&nbsp;-&nbsp;<%=cs[1].getDDMMYYYY()%></label>
							</div>
						</div>
					</div></br>
				</div>
				
				<table class="table table-head table-hover table-bordered table-title-left table-content-center">
					<thead>
						<tr>
							<th swlang code='SW000193'>Seq</th>
							<th swlang code='SW001033'>Date</th>
							<th swlang code='SW000012'>Description</th>
						</tr>
					</thead>
					<tbody>
						<% 
							screen.inq.first(); 
							int i=0;	
							while (screen.inq.next()) {	
								i++;		 
							try {
							
						%>
						<tr>
							<td><%=i%></td>
							<td><%=screen.getString("hdate")%></td>
							<td><%=lang.equals("TH")?screen.getString("tdesc"):screen.getString("edesc")%></td>
						</tr>
						<%
								}catch(Exception e){
									e.printStackTrace();
								}
							}
						%>
					</tbody>
				</table>
				
				<div class="center">
					<a href="javascript:close();" class="btn btn-primary" swlang code='SW012104'>Close</a>
				</div>
			</form>
		</div>
		<%
			screen.referLangOff();
			}catch(Exception e){
				e.printStackTrace();
			}
		%>
	</body>
</html>