<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.UIManager, com.csc.library.utilities.CheckNull"%>
<%@page import="com.csc.library.entry.EmvHelpEntry, com.csc.library.utilities.CscCalendar"%>
<%@page import="com.csc.library.session.DbInquiry, com.csc.library.session.InitialInquiry"%>
<%@page import="com.csc.library.database.DataSet, com.csc.library.components.ListBox, com.csc.library.report.ReportUDF"%>
<%@page import="com.csc.library.database.StaticProperties, com.csc.library.database.CscConnection"%>
<%@ include file="../CHECKPROFILE.jsp" %>
<jsp:useBean id="APP_EMV011_04" class="com.csc.library.system.Task" scope="page" />
<% 
	
	APP_EMV011_04.setChannel(request, response);
	EmvHelpEntry screen = (EmvHelpEntry) APP_EMV011_04.process("EmvHelpEntry","APP_EMV011_01");
	CheckNull chk = new CheckNull();
	int maxline = 15;
	String year = chk.chkNullString(request.getParameter("__year")); 
	String filter = "apsassessor = apsassessy and apsassessy = '"+screen.getUProfile().get("employeeid")+"' and astid = 'AP30' ";
	if(!year.equals("")){
			filter += " and apsid ='"+year+"' ";
	}
	//out.println("filter : " +filter);
	screen.setMaxLine(maxline);
	screen.getInquiry().setFilter(filter);
	int beginRow=((Integer.parseInt(screen.goPage)-1)*screen.maxLine)+1;
    int endRow=(Integer.parseInt(screen.goPage))*screen.maxLine;
    screen.getInquiry().setBetween(beginRow, endRow);
	screen.process();
	CscCalendar  c_year = new CscCalendar();


	//out.println(screen.getInquiry().getCurrentDbRecord().getChildTable());
	
%>
<!DOCTYPE html>
<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" />

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


			/*function goViewAps(apsid,apsassessor,apsassessy_,isread){
					with(document.cscform){	
					//alert(apsid + " " + apsassessor + " " + apsassessy + " " +isread);
					var param="APP_EMV706_HIS.jsp?apsid="+apsid+"&apsassessor="+apsassessor+"&apsassessy="+apsassessy_+"&bpage="+__screen.value+"&ass_level=1&bu1=&bu2=&isread="+isread+"&__type=KC";	
					window.open(param,"Assess_Pages","left=150,top=150,width=750,height=750,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				
				}
			}*/

			function calAge(strDate){
				var currentYear = parseInt(new Date().getYear());
				var birthdateYear = parseInt(strDate.substring(6,10));
				var age = currentYear-birthdateYear;
				document.write(age);
			}

			function GoSearch(){
						with(document.cscform){	
								submit();
						}
			}

		</script>
		
		<section>
			<div class="container csc-content">
				<form name="cscform" class="form-horizontal" method="post" action="APP_EMV011_04.jsp">
					<input type="hidden" name="__screen"  value="APP_EMV011_04">
					<input type="hidden" name="__help" value="">
					<input type="hidden" name="__cmd"  value="">
					<input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>"> 
					<input type="hidden" name="__fixCon" value="">
					<input type="hidden" name="issearch" value="">
					<input type="hidden" name="isall" value="">
					<input type="hidden" name="__goPage" value="">
					<input type="hidden" name="__employeeid" value="">
					
						
					<div class="csc-block">
						<div class="center">
							<h2 class="csc-block-head" swlang code='SW012370'>History of Self Appraisal (KC)</h2>
						</div>
						
						<div class="form-horizontal">
							<div class="row">
								<div class="form-group">
									<div class="col-md-4 col-sm-4 col-xs-2"></div>
									<div class="col-md-2 col-sm-2 col-xs-4">
										<label class="control-label label-right" swlang code='SW012262'>Year of Apprasial</label>
									</div>

									<div class="col-md-2 col-sm-2 col-xs-4">
										<%
											DataSet condition = new DataSet();
											condition.setDbName((String)screen.getUProfile().get("dbname"));
											condition.setTableName("hapstran0");
											
											condition.setSql("select apsid,tdesc from hapstran0 where astid = 'AP30'");
											condition.initConnection(screen.getUProfile());
										%>
										<select class="form-control" name="__year">
												<%
													while(condition.next()){
												%>
												<option value="<%=condition.getString("apsid")%>"><%=condition.getString("tdesc")%></option>
												<%}%>
										</select>
									</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 swlang code='SW000193'>Seq</th>
									<th swlang code='SW000021'>Assessy</th>
									<th><%=screen.getLabel("memployee","bu1")%></th>
									<th><%=screen.getLabel("memployee","bu2")%></th>
									<th swlang code='SW000057'>Position</th>
									<th swlang code='SW000230'>Service Year</th>
									<th swlang code='SW000172'>Age</th>
								</tr>
							</thead>
							<tbody>
								<%
									String goPage = chk.chkNullString(request.getParameter("__goPage"),"+0");
									String page_ = goPage.substring(goPage.indexOf("+")+1,goPage.length());
									int numberPage = Integer.parseInt(page_);
									//out.println("numberPage "  + numberPage);
									int inc=1;
									int inc_cout = 1;
									if(numberPage > 1){
										inc_cout = maxline * (numberPage-1);
										inc += inc_cout;
									}
									while(screen.nextRec()){
								%>	
								<tr>
									<td><%=inc%></td>
									<td><%=screen.getString("SIMEMP","fullname")%></td>
									<td><%=screen.getString("mbu1","tdesc")%></td>
									<td><%=screen.getString("mbu2","tdesc")%></td>
									<td><%=screen.getString("mposition","tdesc")%></td>
									<% String[] y = screen.getDataLabel("simemp","empworkages").split(" "); %>
									<td><%=y[0]%>  <span swlang code='SW000717'>Year</span></td>
									<td><%=screen.getString("SIMEMP","empages")%></td>
								</tr>
								<%
										inc++;
									}
								%>
							</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>