<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@page import="com.csc.library.entry.UIManager, com.csc.library.utilities.CheckNull, com.csc.library.database.DataSet"%>
<%@page import="com.csc.library.databean.MyDataList, com.csc.library.databean.Simtapstran_result, com.csc.library.databean.MyDataRec,com.csc.library.download.FileDownloadUtils2"  %>
<%@page import="com.csc.library.database.StaticProperties, com.csc.library.database.CscConnection,com.csc.library.database.*,com.csc.library.session.*"%>
<%@ include file="../CHECKPROFILE.jsp" %>
<% request.setCharacterEncoding("UTF-8"); %>

<jsp:useBean id="APP_EMV010_1" class="com.csc.library.system.Task" scope="page"/>
<%
	CheckNull chk=new CheckNull();
	APP_EMV010_1.setChannel(request,response);
	UIManager screen = (UIManager) APP_EMV010_1.process("SingleEntry","APP_EMV010_1");
	
	String isRead = chk.chkNullString(request.getParameter("isread"));
	String ass_Level = chk.chkNullString(request.getParameter("ass_level"));
	String bPage = chk.chkNullString(request.getParameter("bpage"));

	if(chk.chkNullString(request.getParameter("__cmd")).equals("")){
		screen.getRecord().set("apsid",chk.chkNullString(request.getParameter("apsid")));
		screen.getRecord().set("apsassessor",chk.chkNullString(request.getParameter("apsassessor")));
		screen.getRecord().set("apsassessy",chk.chkNullString(request.getParameter("apsassessy")));
		screen.getRecord().set("companyid",screen.getUProfile().get("companyid"));
		screen.getRecord().search();
	}
	screen.referLangOn();

	String dbtype =  ((CscConnection) StaticProperties.myConnection.getConnection(screen.getUProfile().get("dbname"), screen.getUProfile())).getVendor();
	String isnull = (dbtype.equalsIgnoreCase("ORACLE"))?"nvl":"isnull";
%>

<!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" />

		<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/jquery-2.1.3.min.js"></script>
		<script type="text/javascript" src="../JS/UTILITIES.js"></script>
		<script type="text/javascript" src="../JS/EVENTS.js"></script>
		<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> 
			setLang("<%=screen.getUProfile().get("lang")%>");
			var swap = new swaplang();
            var titlename = swap.swap2String("SW012105");
			setPageTitle(titlename);

			function goResult(apsid, apsassessy, apsassessor, type){
				var page = 'APP_EMV010_2';
				if(type == 'AP30'){
					page = 'APP_EMV010_3';
				}
				var param = page+".jsp?apsid="+apsid+"&apsassessor="+apsassessor+"&apsassessy="+apsassessy+"&bpage=&ass_level=0&bu1=&bu2=&isread=1&astid="+type;	

				with(document.cscform){
					window.open(param,"Assess_Form"+type,"left=150,top=150,width=1100,height=700,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}
			function copyForm(){
				with(document.cscform){
					__copyform.value = '1';
					submit();
				}
			}
			function goHistory(type){
				with(document.cscform){
					var param = "APP_EMV010_4.jsp?astid="+type+"&apsassessy="+__apsassessy.value;	
					window.open(param,"History"+type,"left=50,top=50,width=960,height=350,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}
		</script>
	</head>
	<body>
		<div class="bg-com"></div>
	
		<section>
			<div class="container csc-content">
				<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
				<form name="cscform" class="form-horizontal" method="post" action="APP_EMV010_1.jsp">
					<%=screen.InitialVariable()%>
					<input type="hidden" name="__screen" value="APP_EMV010_1">
					<input type="hidden" name="__fixCon" value="">
					<input type="hidden" name="__help" value="">
					<input type="hidden" name="__cmd" value="">
					<input type="hidden" name="__calendar">
					<input type="hidden" name="__childFilter">
					<input type="hidden" name="__notNull">
					<script language="javascript">getInputFormatDate();</script>
					<input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__user" value="<%=screen.getUProfile().getUserId()%>">
					<input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
					<input type="hidden" name="__sysisedit" value = "false">

					<input type="hidden" name="__apsid" value="<%=screen.getDataLabel("apsid")%>">
					<input type="hidden" name="__astid" value="<%=screen.getDataLabel("astid")%>">
					<input type="hidden" name="__apsassessor" value="<%=screen.getDataLabel("apsassessor")%>">
					<input type="hidden" name="__apsassessy" value="<%=screen.getDataLabel("apsassessy")%>">
					<input type="hidden" name="__emp_group" value="<%=screen.getDataLabel("emp_group")%>">

					<input type="hidden" name="apsid" value="<%=chk.chkNullString(request.getParameter("apsid"))%>">
					<input type="hidden" name="apsassessor" value="<%=chk.chkNullString(request.getParameter("apsassessor"))%>">
					<input type="hidden" name="apsassessy" value="<%=chk.chkNullString(request.getParameter("apsassessy"))%>">
					<input type="hidden" name="bu1" value="<%=chk.chkNullString(request.getParameter("bu1"))%>">
					<input type="hidden" name="bu2" value="<%=chk.chkNullString(request.getParameter("bu2"))%>">
					<input type="hidden" name="isread" value="<%=isRead%>">
					<input type="hidden" name="bpage" value="<%=bPage%>">
					<input type="hidden" name="ass_level" value="<%=ass_Level%>">

					<input type="hidden" name="__apsstatus" value="<%=screen.getDataLabel("apsstatus")%>">
					<input type="hidden" name="__apsappstatus1" value="<%=screen.getDataLabel("apsappstatus1")%>">
					<input type="hidden" name="__apsappstatus2" value="<%=screen.getDataLabel("apsappstatus2")%>">
					<input type="hidden" name="__apsappstatus3" value="<%=screen.getDataLabel("apsappstatus3")%>">
					<input type="hidden" name="__apsappstatus4" value="<%=screen.getDataLabel("apsappstatus4")%>">
					<input type="hidden" name="__apsappstatus5" value="<%=screen.getDataLabel("apsappstatus5")%>">

					<input type="hidden" name="__apsapprove1" value="<%=screen.getDataLabel("apsapprove1")%>">
					<input type="hidden" name="__apsapprove2" value="<%=screen.getDataLabel("apsapprove2")%>">
					<input type="hidden" name="__apsapprove3" value="<%=screen.getDataLabel("apsapprove3")%>">
					<input type="hidden" name="__apsapprove4" value="<%=screen.getDataLabel("apsapprove4")%>">
					<input type="hidden" name="__apsapprove5" value="<%=screen.getDataLabel("apsapprove5")%>">
					<input type="hidden" name="__apsasssource" value="<%=screen.getDataLabel("apsasssource")%>">

					<input type="hidden" name="__copyform" value="">
				
				
					<div class="csc-block-white">
						<div class="center">
							<h3>
								<span swlang code='SW012105'>Result of Assess</span> <span swlang code='SW000717'>Year</span> <%=screen.getDataLabel("tapstran0","apsstartdate").split("-")[2]%>
							</h3>
						</div>
						<%
							MyDataList emp = ((Simtapstran_result)screen.getRecord()).getMyDataList("mytastran_emp");
							emp.next();
							FileDownloadUtils2 utils = new FileDownloadUtils2();
							utils.setUploadField("memployee", "picture");
							utils.setFilename(emp.getString("picture"));
							String url = utils.getViewUrl();
						%>

						<%
				           DbInquiry memployee = new InitialInquiry(screen.getUProfile()).getDbInquiry("memployee");
				           memployee.setColumn("employeeid,companyid,bu1,bu2,bu3,bu4,bu5");
				           memployee.refresh();

				           DbRecord mbu = memployee.getCurrentDbRecord();
				         %>
<!--begin asssessy detail-->				
						
						<div class="container csc-content">
							<div class="csc-block">
								<div class="form-horizontal">
									<div class="center">
										<img class="img-thumbnail" id="employeepic" src="<%=url%>" width="100" height="100" >
									</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='SW001984'>Fullname</label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=emp.getString("mprefix","tdesc")+emp.getString("fname")+" "+emp.getString("lname")%></label>
											</div>
												
											<div class="col-md-2 col-sm-2 col-xs-2">
												<label class="control-label  label-right" swlang code='SW000274'>Employee ID</label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=screen.getUProfile().get("employeeid")%></label>
											</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 co2-sm-2 col-xs-2">
												<label class="control-label  label-right" swlang code='SW000057'>Position</label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=emp.getString("mposition","tdesc")%></label>
											</div>
												
											<div class="col-md-2 co2-sm-2 col-xs-2">
												<label class="control-label  label-right"><%=mbu.getField("bu1").getDescription()%></label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=emp.getString("mbu1","tdesc")%></label>
											</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"><%=mbu.getField("bu2").getDescription()%></label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=emp.getString("mbu2","tdesc")%></label>
											</div>
												
											<div class="col-md-2 col-sm-2 col-xs-2">
												<label class="control-label  label-right"><%=mbu.getField("bu3").getDescription()%></label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=emp.getString("mbu3","tdesc")%></label>
											</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='SW000314'>Branch</label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=emp.getString("mbranch","tdesc")%></label>
											</div>
												
											<div class="col-md-2 col-sm-2 col-xs-2">
												<label class="control-label  label-right" swlang code='SW000019'>Status</label>
											</div>
											<div class="col-md-3 co2-sm-3 col-xs-3">
												<label class="control-label "><%=screen.getRecord().getSystemCode("apsstatus_last")%></label>
											</div>
										</div>
									</div>
								</div>
							</div>
						
						
<!--begin list asssessor-->						
						
							<div class="table-responsive">	
								<table class="table table-head table-hover table-bordered table-title-left table-content-center">
									<thead>
										<tr>
											<th class="table-title" colspan=7 swlang code='SW000020'>Assessor</th>
										</tr>
										<tr>
											<th swlang code='SW000021'>Assessy</th>
											<%
												String assessor[] = {"apsapprove1","apsapprove2","apsapprove3","apsapprove4","apsapprove5"};
												for(int i=0; i<5 && !screen.getDataLabel(assessor[i]).equals(""); i++){	
													if(i<4 && !screen.getDataLabel(assessor[i+1]).equals("")){
											%>
											<th><span swlang code='SW001142'>Assessor LV</span> <%=i+1%></th>
											<%
												}else{
											%>
											<th swlang code='SW012307'>Assess Approve Result</th>
											<%
													}
												}
											%>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td><%=emp.getString("mprefix","tdesc")+emp.getString("fname")+" "+emp.getString("lname")%><br><%=emp.getString("mposition","tdesc")%></td>
											<%
												for(int i=0; i<5 && !screen.getDataLabel(assessor[i]).equals(""); i++){	
											%>
											<td><%=screen.getDataLabel(assessor[i]+"_desc").replace(" (","<br>(")%></td>
											<%
												}
											%>
										</tr>
									</tbody>
								</table>
							</div>
			<!--begin link page-->			
							
							<div class="table-responsive">	
								<table class="table table-head table-hover table-bordered table-title-left table-content-center">
									<thead>
										<tr>
											<th class="table-title" colspan=7 swlang code='SW012105'>Result of Assess</th>
										</tr>
									</thead>
									<tbody>
										<%
											String astid = "";
											MyDataList kc = ((Simtapstran_result)screen.getRecord()).getMyDataList("mytastran_kc");
											DataSet ds = new DataSet();
											while(kc.next()){
												if(kc.getString("astid").equals("AP10")){
													if(!astid.equals(kc.getString("astid"))){
										%>
										<tr>
											<th swlang code='SW012107'>Result of KPI Assess</th>
											<th swlang code='SW012108'>Self Assess Result</th>
											<th swlang code='SW012109'>Approve Result</th>			
											<th swlang code='SW012109'>Approve Result</th>
											<th swlang code='SW000286'>History</th>
										</tr>
										<%
												astid = kc.getString("astid");
											}
										%>
										<tr>
											<td class="table-title">
												<a href="javascript:goResult('<%=kc.getString("apsid")%>','<%=kc.getString("tapstran","apsassessy")%>','<%=kc.getString("tapstran","apsassessor")%>','AP10');">
													<span swlang code='SW012102'>Round</span>&nbsp;<%=kc.getString("apsid")%>
													<span swlang code='SW012110'>Assess Date</span> <%=kc.getString("apsstartdate")%> <span swlang code='SW002095'>to</span> <%=kc.getString("apsenddate")%>
												</a>
											</td>
											<td><%=kc.getInt("tapstran","apssumscore")%></td>
											<td><%=kc.getInt("tapstran","apsasydesc")%></td>
											<td><%=kc.getInt("tapstran","apssumscore_last")%></td>
											<td><a href="javascript:goHistory('AP10');" swlang code='SW001034'>History Assess</a></td>
										</tr>
										<%
											}
												if(kc.getString("astid").equals("AP30")){
													if(!astid.equals(kc.getString("astid"))){
										%>
										<tr>
											<th swlang code='SW012322'>Result of Competency Assess</th>
											<th swlang code='SW012111'>Comparable Standard</th>
											<th swlang code='SW012112'>Upper Standard</th>					
											<th swlang code='SW012113'>Lower Standard</th>
											<th swlang code='SW000286'>History</th>
										</tr>
										<%
														astid = kc.getString("astid");
													}
													ds.setInfo(
														"	select "+isnull+"(sum(case when asrmaxscore = asrscore then 1 else 0 end), 0) as target "+
														"		, "+isnull+"(sum(case when asrmaxscore < asrscore then 1 else 0 end), 0) as up "+
														"		, "+isnull+"(sum(case when asrmaxscore > asrscore then 1 else 0 end), 0) as low "+
														"	from tastran "+
														"	where apsassessy = '"+kc.getString("tapstran","apsassessy")+"' and apsassessor = '"+kc.getString("tapstran","apsassessor")+"' and apsid = '"+kc.getString("apsid")+"'"
														, screen.getUProfile().get("dbname"), "tastran");
													ds.initConnection(screen.getUProfile());
													ds.next();
										%>
										<tr>
											<td>
												<a href="javascript:goResult('<%=kc.getString("apsid")%>','<%=kc.getString("tapstran","apsassessy")%>','<%=kc.getString("tapstran","apsassessor")%>','AP30');">
													<span swlang code='SW012102'>Round</span> <%=kc.getString("apsid")%> 
													<span swlang code='SW012110'>Assess Date</span> <%=kc.getString("apsstartdate")%> <span swlang code='SW002095'>to</span> <%=kc.getString("apsenddate")%>
												</a>
											</td>
											<td><%=ds.getString("target")%></td>
											<td><%=ds.getString("up")%></td>
											<td><%=ds.getString("low")%></td>
											<td><a href="javascript:goHistory('AP30');" swlang code='SW001034'>History Assess</a></td>
										</tr>
										<%
												}
											}
											ds.closeConnection();
										%>
									</tbody>
								</table>
							</div>
							<%=screen.endJSP()%>
						</div>
					</div>
				</form>
			</div>
		</section>
	</body>
</html>