<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="com.csc.library.database.*,com.csc.library.session.*,com.csc.library.utilities.*,com.csc.library.utility.*"  %>
<%@ include file="../CHECKPROFILE.jsp" %>
<% request.setCharacterEncoding("UTF-8"); %>
<%
	CheckNull chk = new CheckNull();
	CscCalendar now = new CscCalendar();

	UProfile up = null;
	if (session != null){
		up = (UProfile)session.getAttribute("userprofile");
	}

	if (up == null){
		return ;
	}

%>

<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=UTF-8" />
		<link rel="stylesheet" href="<%=request.getContextPath()%>/EMPVIEW/css/APP_UP/style_apsup.css" />
	</head>
	<body ng-controller='WorkTimeDataForm'>
		<div class='bg-com'></div>
		<div class="emv-headmenu"><jsp:include page="EMV_HEADMENU.jsp" flush="true" /></div>
		
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
		<script type='text/javascript' src="../JS/bootstrap.js"></script>
		<script type="text/javascript" src="../JS/SCREEN.js"></script>
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
		<script type='text/javascript' src="../public/lib/angular-resource/angular-resource.min.js"></script>
		<script type='text/javascript' src='JS/TIME_DATA_TKS/Module.Controller.js'></script>
		<script type='text/javascript' src='JS/TIME_DATA_TKS/services.js'></script>
		<script type='text/javascript' src='JS/TIME_DATA_TKS/WorkTimeDataForm.Controller.js'></script>
		<script type='text/javascript'>setLang('<%=up.get("lang")%>')</script>
<style>
table {
	display: block;
	overflow-x: auto;
	white-space: nowrap;
	width: 100%;
	background: rgba(84, 163, 255, 0.85);
}
.csc-block-tks {
  display: block;
  float: left;
  width: 100%;
  height: inherit;
  border: 2px solid rgba(84, 163, 255, 0.85);
  background: rgba(84, 163, 255, 0.85);
  margin-bottom: 20px; }
</style>
		<script type='text/javascript'>
		
			function goHelp(helpName,inputName){
				var helpReturn;
			//	var actid = "<%//=actorid%>";
				//var con = "employeeid = '1000180'";
			//	var con = "employeeid = '" + actid + "' or employeeid in (select employeeid from msupervisor where supervisor like ',%25"+actid+"%25,')";
				var con = "";
				helpReturn="employeeid:employeeid,MEMPLOYEE@FULLNAME";
				linkHelp_Return(helpName,helpReturn,con);
			}
		
		</script>
		
		<section>
			<div class="container csc-content">
				<form name="cscform" class="form-horizontal" method="post" >
					<input type="hidden" name="__cmd" value="">
					<input type="hidden" name="__screen"  value="TIME_DATA_TKS">
					<input type="hidden" name="__help" value="">
					<input type="hidden" name="__goPage" value="">
					<input type="hidden" name="__helpReturn" value="">
					<input type="hidden" name="__helpName" value="">
					<input type="hidden" name="__pageCall" >
					<input type="hidden" name="__referPage" value="">
					<input type="hidden" name="__calendar">
					<script language="javascript">getInputFormatDate();</script>
					<input type="hidden" name="__companyid"  value="<%=up.get("companyid")%>">
					<input type="hidden" name="__fixCon" value="">
					<input type="hidden" name="__language" value="<%=up.get("lang")%>">
					<input type="hidden" name="__childFilter" >

					<div>
						<div class='loading-page'>
							<div class='spiner'></div>
						</div>
						
						<div class="form-horizontal">
							<table class="table">
								<tr>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">Working Report (Voucher)</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">
											<input class="form-control" ng-model='employeeid' name="employeeid" readonly value='<%=up.get("employeeid")%>' size="7">
										</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">
											<input class="form-control" name='fullname' readonly value='<%=up.get("fullname")%>' size="25">
										</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">From</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">
											 <input class="form-control" ng-model='startdate' name="startdate" value='21-09-2017' size="7">
											<a class="input-group-addon" href="javascript:viewCal('startdate')">
												<i class="fa fa-calendar"></i>
											</a>
										</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">To</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">
											<input class="form-control" ng-model='enddate' name="enddate" value='20-10-2017' size="7">
											<a class="input-group-addon" href="javascript:viewCal('enddate')">
												<i class="fa fa-calendar"></i>
											</a>
										</div>
									</th>
									<th font-size='9px' bgcolor='#4B95E6' padding='5px' max-width='100%'> 
										<div class="input-group">
											<button type="button" class="btn btn-primary search-button" ng-click="search()">Search</button>
										</div>
									</th>
								</tr>
							</table>
						</div>

						<div class="form-horizontal">
							<table class="table table-head table-bordered table-title-left" >
								<tbody>
									<tr>
										<th rowspan='2' align='center'>No.</th>
										<th rowspan='2' align='center'>Km.</th>
										<th rowspan='2' align='center'>Project<br>No.<br>(Budget)</th>
										<th align='center'>Site Name<br>(Work Description)</th>
										<th align='center'>Date</th>
										<th ng-repeat='WorkTime in WorkTime'>{{ WorkTime.date }}</th>
										<th rowspan='2' align='center'>Total</th>
									</tr>
									<tr>
										<th align='right'>Address</th>
										<th align='right'>Start:<br>Finish:</th>
										<td ng-repeat='WorkTime in WorkTime'><div align='right'>{{ WorkTime.time_in }}<br>{{ WorkTime.time_out }}</div></td>
									</tr>
								</tbody>
								<tbody ng-repeat='Workplace in Workplace'>
									<tr>
										<td rowspan='4'>{{ Workplace.no }}</td>
										<td rowspan='4'>
											<label><input type="radio" ng-model="Workplace.type" ng-disabled='true' value="A">A</label><br>
											<label><input type="radio" ng-model="Workplace.type" ng-disabled='true' value="B">B</label><br>
											<label><input type="radio" ng-model="Workplace.type" ng-disabled='true' value="C">C</label><br>
											<label><input type="radio" ng-model="Workplace.type" ng-disabled='true' value="D">D</label>
										</td>
										<td rowspan='4' align='center'>{{ Workplace.workplaceid }}</td>
										<td rowspan='4' align='center'>{{ Workplace.sitename }}<br>{{ Workplace.location }}</td>
										<th>Normal</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div ng-if='chkShow(workPlaceDaily.workplaceid, Workplace.workplaceid)' align='center'>{{ chkZero(workPlaceDaily.hour_d, '-') }}</div></td>
										<td align='right'>{{ getTotal(Workplace, 'hour_d') }}</td>
									</tr>
									<tr>
										<th>OT1</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div ng-if='chkShow(workPlaceDaily.workplaceid, Workplace.workplaceid)' align='center'>{{ chkZero(workPlaceDaily.ot1, '-') }}</div></td>
										<td align='right'>{{ getTotal(Workplace, 'ot1') }}</td>
									</tr>
									<tr>
										<th>OT1.5</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div ng-if='chkShow(workPlaceDaily.workplaceid, Workplace.workplaceid)' align='center'>{{ chkZero(workPlaceDaily.ot5, '-') }}</div></td>
										<td align='right'>{{ getTotal(Workplace, 'ot5') }}</td>
									</tr>
									<tr>
										<th>OT3</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div ng-if='chkShow(workPlaceDaily.workplaceid, Workplace.workplaceid)' align='center'>{{ chkZero(workPlaceDaily.ot3, '-') }}</div></td>
										<td align='right'>{{ getTotal(Workplace, 'ot3') }}</td>
									</tr>
								</tbody>
								<tbody>
									<tr>
										<th colspan='4' rowspan='5'><div align='right'>Working Hour</div></th>
										<th>Normal</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>{{ chkZero(workPlaceDaily.hour_d, '-') }}</div></td>
										<td align='right'>{{ getSumTotal(Workplace, 'hour_d') }}</td>
									</tr>
									<tr>
										<th>OT1</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>{{ chkZero(workPlaceDaily.ot1, '-') }}</div></td>
										<td align='right'>{{ getSumTotal(Workplace, 'ot1') }}</td>
									</tr>
									<tr>
										<th>OT1.5</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>{{ chkZero(workPlaceDaily.ot5, '-') }}</div></td>
										<td align='right'>{{ getSumTotal(Workplace, 'ot5') }}</td>
									</tr>
									<tr>
										<th>OT3</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>{{ chkZero(workPlaceDaily.ot3, '-') }}</div></td>
										<td align='right'>{{ getSumTotal(Workplace, 'ot3') }}</td>
									</tr>
									<tr>
										<th>Total</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>{{ getTotalWorkPlaceDaily(workPlaceDaily) }}</div></td>
										<td align='right'>{{ getSumTotalWorkPlaceDaily(Workplace) }}</td>
									</tr>
								</tbody>
								<tbody>
									<tr>
										<th colspan='5'><div align='right'>Approve Status</div></th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>
											<label><input type="radio" ng-model="workPlaceDaily.approve_status" ng-disabled='true' value="0">No&nbsp;</label><br>
											<label><input type="radio" ng-model="workPlaceDaily.approve_status" ng-disabled='true' value="1">Yes</label>
										</div></td>
										<td align='right'></td>
									</tr>
								</tbody>
								<tbody>
									<tr>
										<th colspan='5'><div align='right'>Direct Construction Allowance</div></th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center'>{{ chkZero(workPlaceDaily.direct_con, '-') }}</div></td>
										<td align='right'>{{ getSumTotal(workPlaceDaily, 'direct_con') }}</td>
									</tr>
								</tbody>
								<tbody>
									<tr>
										<th colspan='4' rowspan='3'><div align='right'>Up Country Allowance</div></th>
										<th>100 - 300 Km.</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.type=="B"'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.up_country'/></div></td>
										<td rowspan='3' align='right'>{{ getSumTotal(workPlaceDaily, 'up_country') }}</td>
									</tr>
									<tr>
										<th>301 - 600 Km.</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.type=="C"'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.up_country'/></div></td>
									</tr>
									<tr>
										<th>Over 600 Km.</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.type=="D"'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.up_country'/></div></td>
									</tr>
								</tbody>
								<tbody>
									<tr>
										<th colspan='4' rowspan='6'><div align='right'>Car Expense</div></th>
										<th>Date</th>
										<th ng-repeat='WorkTime in WorkTime'>{{ WorkTime.date }}</th>
										<td align='center'>Total</td>
									</tr>
									<tr>
										<th>Gasoline (Baht)</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.distance>0'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.gas_b'/></div></td>
										<td align='right'>{{ getSumTotal(workPlaceDaily, 'gas_b') }}</td>
									</tr>
									<tr>
										<th>Gasoline (L)</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.distance>0'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.gas_l'/></div></td>
										<td align='right'>{{ getSumTotal(workPlaceDaily, 'gas_l') }}</td>
									</tr>
									<tr>
										<th>Express Way</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.distance>0'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.express_way'/></div></td>
										<td align='right'>{{ getSumTotal(workPlaceDaily, 'express_way') }}</td>
									</tr>
									<tr>
										<th>Parking</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.distance>0'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.parking'/></div></td>
										<td align='right'>{{ getSumTotal(workPlaceDaily, 'parking') }}</td>
									</tr>
									<tr>
										<th>KM</th>
										<td ng-repeat='workPlaceDaily in workPlaceDaily'><div align='center' ng-if='workPlaceDaily.hour_d>0 && workPlaceDaily.distance>0'><input type='text' size='1' ng-disabled='workPlaceDaily.approve_status=="1"' ng-model='workPlaceDaily.km'/></div></td>
										<td align='right'>{{ getSumTotal(workPlaceDaily, 'km') }}</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div align='center'><button type="button" class="btn btn-primary save-button" ng-click="save()">Save</button></div>
						<div class='spece-bot'></div>
					</div>
				</form>
				<a href="#top" id="top-button"><i class="fa fa-angle-up"></i><div class="top-word">Back to top</div></a>
			</div>
		</section>
		<div><jsp:include page="FOOTER.jsp" flush="true" /></div>
	</body>
</html>