<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@page import="com.csc.library.entry.EmvHelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@ include file="../CHECKPROFILE.jsp" %>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="EMV" class="com.csc.library.system.Task" scope="page"/>
<jsp:setProperty name="EMV" property="appname" value="empview" />
<%
	EMV.setChannel(request, response);
	EmvHelpEntry screen = (EmvHelpEntry) EMV.process("EmvHelpEntry","WEL_EMV001");
	String	lang = screen.getUProfile().get("lang");
	screen.getInquiry().clearSubFilter();
	
	CheckNull chk=new CheckNull();
	CscCalendar cs=new CscCalendar();

	ThaiUtilities thail = new ThaiUtilities();
	java.text.DecimalFormat df=new java.text.DecimalFormat("#,###,##0.00");	
	String condition=thail.ASCII2Unicode(chk.chkNullString(request.getParameter("__fixCon")));  
	int years=Integer.parseInt(chk.chkNullString(request.getParameter("__year"),String.valueOf(cs.getYear()-1)));  
	String welid1=thail.ASCII2Unicode(chk.chkNullString(request.getParameter("__welid1")));  
	String welid2=thail.ASCII2Unicode(chk.chkNullString(request.getParameter("__welid2")));  
	String stdate=chk.chkNullString(request.getParameter("__startdate"));  
	String endate=chk.chkNullString(request.getParameter("__enddate"));  
	if(years>0){
			((DbInquiry)screen.getInquiry().getChild("MWELFARE")).setFilter("budid",""+years,"","between");
	}
	if(welid1.length()>0){
		screen.getInquiry().setFilter("welid",welid1,welid2,"between");
	}
	
	if(stdate.length()>0){
		screen.getInquiry().setFilter("approvedate",stdate,endate,"between");
	}
	
	String filter="";
	filter="status='1'  and approvestatus<>'2' and  employeeid='"+screen.getUProfile().get("employeeid")+"' and budyear='"+years+"' ";
	screen.getInquiry().setFilter(filter);
	screen.process();

%>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myHR">
	<head>

		<title>Employee View</title>

		<meta http-equiv="Content-Type" content="text/html; charset=TIS620" />

	</head>
	<body>
		<div class="bg-com"></div>
		<jsp:include page="EMV_HEADMENU.jsp" flush="true" />
		
		<script language="javascript">
			setLang("<%=screen.getUProfile().get("lang")%>");
			var swap = new swaplang();
            var titlename = swap.swap2String("SW000548");
			setPageTitle(titlename);

			
			function goHelp(helpName,inputName){
			var helpReturn;
			var fcon="";
				if(inputName=="__welid1" ){
					helpReturn="__welid1:WELID,MWELFARE@WELID";
				}else 		if(inputName=="__welid2" ){
					helpReturn="__welid2:WELID,MWELFARE@WELID";
				}else 		if(inputName=="__year" ){
							 helpReturn="__year:years";		
							 }			
				 helpPageCon(helpName,helpReturn,fcon);
			 
			}

			function GoSearch(){
					search();
			}

			function goPages(page,complainid,caseid){
					with(document.cscform){
								action=page;
								method="post";
								__complainid.value=complainid;
								__caseid.value=caseid;
								__cmd.value="search";
								submit();
					}
			}
			
			$(document).ready(function(){
				$("select").addClass("form-control");
				$("#listpage").removeClass("form-control");
				
				//datepicker function
				var myLang='<%=screen.getUProfile().get("lang")%>';
				if (myLang=="tha"){
					$.datepicker.setDefaults($.datepicker.regional['tha']); 
				}
				
				$("input[name=__startdate]").hover(function(){
					$("input[name=__startdate]").datepicker({
						dateFormat:"dd-mm-yy",
						maxDate:0,
						defaultDate:-1,
						changeMonth: true,
						changeYear: true
					});
					$("input[name=__enddate]").datepicker("destroy");
				});
				
				
				$("input[name=__enddate]").change(function(){
					if ($("input[name=__startdate]").val()>$("input[name=__enddate]").val()){
						$("input[name=__startdate]").val($("input[name=__enddate]").val());
					} else if ($("input[name=__startdate]").val()==""){
						$("input[name=__startdate]").val($("input[name=__enddate]").val());
					}
				});
				
				
				$("input[name=__enddate]").hover(function(){
					$("input[name=__enddate]").datepicker({
						minDate: new Date(ConvertDate($("input[name=__startdate]").val())),
						dateFormat:"dd-mm-yy",
						changeMonth: true,
						changeYear: true
					});
				});
			}); 
			
		</script>

		<section>
			<div class="container csc-content">
				<form name="cscform" class="form-horizontal" method="post" action="WEL_EMV001.jsp">
					<input name="__cmd" type="hidden" value="">
					<input type="hidden" name="__calendar">
					<script language="javascript">getInputFormatDate();</script>
					<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__help" value="">
					<input type="hidden" name="__goPage" value="">
					<input type="hidden" name="__orderBy" value="">
					<input type="hidden" name="__helpReturn" value="">
					<input type="hidden" name="__helpName" value="">
					<input type="hidden" name="__pageCall" value="">
					<input type="hidden" name="__referPage" value="">
					<input type="hidden" name="__lockPage" value="">
					<input type="hidden" name="__complainid" value="">
					<input type="hidden" name="__caseid" value="">
					<input type="hidden" name="__calendar" value="">	
					<input type="hidden" name="__companyid"  value="<%=screen.getUProfile().get("companyid")%>">
					<input type="hidden" name="__fixCon" value="">
					<input name="__screen" type="hidden" value="WEL_EMV001">	
					
					<div class="csc-block">
						<div class="center">
							<h2 class="csc-block-head" swlang code='SW000548'>History of Welfare Using</h2>
						</div>
						
						<div class="form-horizontal">
							<div class="row">
								<div class="form-group">
									<div class="col-md-1 col-sm-1 col-xs-1"></div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW000586'>Budget Year</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-3">
										<select class="form-control" name="__year">
											<% for(int i=(cs.getYear()-5);i<(cs.getYear()+1);i++){%>
												<option value="<%=i%>" <%=(i==years)?"selected":""%>><%=i%></option>
											<%}%>
										</select>
									</div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW002014'>Order by</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-3">
										<%=screen.getTagOrder()%>
									</div>
								</div>
							</div>
							
							<div class="row">
								<div class="form-group">
									<div class="col-md-1 col-sm-1 col-xs-1"></div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right"><%=screen.getLabel("welid")%></label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-3">
										<div class="input-group">
											<input class="form-control" name="__welid1" type="text" size="15" value="<%=welid1%>" />
											<a class="input-group-addon" href="javascript:goHelp('MWELFAREHELP','__welid1');">
												<i class="fa fa-search"></i>
											</a>
										</div>
									</div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW005755'>To</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-3">
										<div class="input-group"> 
											<input class="form-control" name="__welid2" type="text" size="15" value="<%=welid2%>" />
											<a class="input-group-addon" href="javascript:goHelp('MWELFAREHELP','__welid2');">
												<i class="fa fa-search"></i>
											</a>
										</div>
									</div>
								</div>
							</div>
							
							<div class="row">
								<div class="form-group">
									<div class="col-md-1 col-sm-1 col-xs-1"></div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW001033'>Date</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-3">
										<input class="form-control" name="__startdate" type="text" size="10"  maxlength="8" value="<%=stdate%>" onkeypress="chkInteger()" onkeyup="formatDate(this)" onblur="chkInputDate2(this,__enddate)" />
									</div>
									<div class="col-md-2 col-sm-2 col-xs-2">
										<label class="control-label label-right" swlang code='SW002095'>To</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-3">
										<input class="form-control" name="__enddate" type="text" size="10" maxlength="8" value="<%=endate%>" onkeypress="chkInteger()" onkeyup="formatDate(this)" onblur="chkInputDate2(__startdate,this)" />
									</div>
								</div>
							</div>
							
							<div class="center">
								<a class="btn btn-primary" href="javascript:GoSearch();" swlang code='SW003537'>Search</a>
							</div>
						</div>
					</div>
					
					<span class="detail-table">
						<span swlang code='SW001771'>Found Data</span> :&nbsp;&nbsp;<%= screen.getInquiry().recCount() %>&nbsp;
						<span swlang code='SW001780'>records</span> 
					</span>
					<span class="detail-table label-right">
						<span swlang code='SW001120'>Page</span> : <%=screen.getPageTagNew()%> 
					</span>
				
					<div class="table-responsive">
						<table class="table table-head table-hover table-bordered table-title-left table-content-center">
							<thead>
								<tr>
									<th><%=screen.getLabel("COMPLAINID")%></th>
									<th><%=screen.getLabel("CASEID")%></th>
									<th><%=screen.getLabel("WELID")%></th>
									<th><%=screen.getLabel("occurdate")%></th>
									<th><%=screen.getLabel("REQCOST")%></th>
									<th><%=screen.getLabel("COST")%></th>
									<th><%=screen.getLabel("STATUS")%></th>
									<th><%=screen.getLabel("APPROVESTATUS")%></th>
								</tr>
							</thead>
							<tbody>
								<%
									while (screen.nextRec()) {
									if(screen.checkLinePage()){
								%>
								<tr>
									<td><a href="javascript:goPages('WEL_EMV002.jsp','<%=screen.getString("complainid")%>','<%=screen.getString("caseid")%>')"><%=screen.getString("complainid")%></a></td>
									<td><%=screen.getString("caseid")%></td>
									<td><%=screen.getString("welid")%></td>
									<td><%=screen.getString("occurdate")%></td>
									<td><%=screen.getString("reqcost")%></td>
									<td><%=screen.getString("cost")%></td>
									<td><%=screen.getInquiry().getCurrentDbRecord().getSystemCode("STATUS")%></td>
									<td><%=screen.getInquiry().getCurrentDbRecord().getSystemCode("APPROVESTATUS")%></td>
								</tr>
								 <% 
										}
									if(screen.outLinePage()){ break; }
								 }%>
							</tbody>
						</table>
					</div>
				</form>
			</div>
			<a href="#top" id="top-button">
				<i class="fa fa-angle-up"></i>
				<div class="top-word">Back to top</div>
			</a>	
		</section>
		<jsp:include page="FOOTER.jsp" flush="true" />
	</body>
</html>