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

<jsp:useBean id="CKLC" class="com.csc.library.system.Task" scope="page"/>
<%
	CheckNull chk=new CheckNull();

	CKLC.setChannel(request,response);

	String empid = "";

	if (!chk.chkNullString(request.getParameter("__emp"),"").equalsIgnoreCase("")){
		empid =chk.chkNullString(request.getParameter("__emp"));
	}else{
		empid = CKLC.getUProfile().get("employeeid");
	}
%>
<html ng-app="CKLC">
	<head>
		<title>Employee View</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<style>
			section{
				height: auto !important;
			}
			.bg-com{
				z-index:0 !important;
			}
			.table{
				table-layout: inherit !important;
			}
			.datacklc tr{
				font-size:16px;
			}
			.myred{
				color: #ff1a1a ;
			}
		</style>
	</head>
	<body>
		<!-- <div class="bg-com"></div> -->
		<script src="JS/APP_CKLC/ModuleCKLC.controller.js"></script>
		<script src="JS/APP_CKLC/services.js"></script>
		<script src="JS/APP_CKLC/ObjectiveCKLC.controller.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				var scope = angular.element($("form[name=cscform]")).scope();
				
				$.getTotalScore = function(){
					scope.$apply(function(){
						scope.getTotalScore();
					});
				}
			});
		</script>
		<section>
			<div class="container container-98 csc-content">
				<form name="cscform" class="form-horizontal" method="post" ng-controller="ObjectiveCKLC">
					<div class="csc-block-white">
						<div class="center">
						<%
							DbInquiry ty = new InitialInquiry(CKLC.getUProfile()).getDbInquiry("tapstran0");
							ty.setColumn("*");
							ty.setFilter("apsid LIKE '%CKLC%' ");
							ty.refresh();
							ty.referLangOn();
							String desc="";
								
							if(ty.next()){
								desc = ty.getString("edesc");
							}
						%>
						
							<h4>
								<%=desc%>
							</h4>
						</div>
						
						<div class="container container-98 csc-content">

							<span ng-if="item[0].employeeid != '<%=CKLC.getUProfile().get("employeeid")%>' && (item[0].apsstate =='' || item[0].apsstate == 0)" class="myred">** Don't self assess</span>
							<table class="table table-head table-hover table-bordered table-title-left">
								<tr>
									<th class="table-title">Reviewer</th>
									<td colspan="3">Name : <%=CKLC.getUProfile().get("fullname")%></td>
								</tr>
								<tr>
									<th class="table-title">Reviewee</th>
									<td>Dept : {{empdata[0].department}}</td>
									<td>ID No : {{empdata[0].employeeid}}</td>
									<td>Name : {{empdata[0].fullname}}</td>
								</tr>
								<tr>
									<th class="table-title">Grade</th>
									<td colspan="3"></td>
								</tr>
							</table>

							<table class="table table-head table-bordered table-title-left datacklc" ng-repeat="form in formitem">
								<thead>
									<tr>
										<th colspan="9">{{form.formdesc}}</th>
									</tr>
									<tr>
										<th colspan="9">Competency</th>
									</tr>
									<tr>
										<th rowspan="2">Score</th>
										<th rowspan="2"colspan="2">Expected Behaviors</th>
										<th colspan="2">Self Appraisal</th>
										<th colspan="2">Reviewer Appraisal</th>
										<!-- <th colspan="2">Comment</th> -->
									</tr>
									<tr>
										<th>Score</th>
										<th>Self comment</th>
										<th>Score</th>
										<th>Review comment</th>
									</tr>
								</thead>
								<tbody ng-repeat="rowitem in item | filter:{asfid:form.formid}" class="repeatcklc" ng-init="myemp = '<%=CKLC.getUProfile().get("employeeid")%>'">
									<tr>
										<td colspan="7">{{ rowitem.topicgroup }}</td>
									</tr>
									<tr>
										<td colspan="7">{{ rowitem.detailgroup }}</td>
									</tr>
									<tr>
										<td class="center">{{rowitem.score[0].ansscore}}</td>
										<td>{{rowitem.score[0].anstopic}}</td>
										<td>{{rowitem.score[0].ansdetail}}</td>
										<!-- <td class="center"><input type="radio" name="__{{rowitem.asgid}}@self" value={{rowitem.score[0].ansscore}} ng-model="rowitem.selfscore" ng-click="checkdata()" ng-disabled ="rowitem.employeeid != myemp || (rowitem.employeeid == myemp && rowitem.apsstate > 0)" ng-if="rowitem.employeeid == myemp || rowitem.reviewerid == myemp"></td>
										<td class="center"><input type="radio" name="__{{rowitem.asgid}}@review" value={{rowitem.score[0].ansscore}} ng-model="rowitem.reviewscore" ng-click="checkdata()" ng-if="rowitem.reviewerid == myemp" ng-disabled="rowitem.reviewerid == myemp && rowitem.apsstate >1"></td>
										<td rowspan="{{rowitem.score.length}}"><textarea ng-model="rowitem.selfcomment" ng-disabled="rowitem.employeeid != myemp || (rowitem.employeeid == myemp && rowitem.apsstate > 0)"></textarea></td>
										<td rowspan="{{rowitem.score.length}}"><textarea ng-model="rowitem.reviewcomment" ng-if="rowitem.reviewerid == myemp"></textarea></td> -->
										<td class="center"><input type="radio" name="__{{rowitem.asgid}}@self" value={{rowitem.score[0].ansscore}} ng-model="rowitem.selfscore" ng-click="checkdata()" ng-disabled ="rowitem.timetype == false || (rowitem.employeeid != myemp || (rowitem.employeeid == myemp && rowitem.apsstate > 0))" ng-if="rowitem.permittype == 'self' || rowitem.permittype == 'approve' || rowitem.permittype == 'review' "></td>

										<td rowspan="{{rowitem.score.length}}"><textarea ng-model="rowitem.selfcomment" ng-disabled="rowitem.timetype == false || rowitem.employeeid != myemp || (rowitem.employeeid == myemp && rowitem.apsstate > 0)" ng-if="rowitem.permittype == 'self' || rowitem.permittype == 'approve' || rowitem.permittype == 'review'"></textarea></td>

										<td class="center"><input type="radio" name="__{{rowitem.asgid}}@review" value={{rowitem.score[0].ansscore}} ng-model="rowitem.reviewscore" ng-click="checkdata()" ng-if="rowitem.permittype == 'approve' || rowitem.permittype == 'review' " ng-disabled="rowitem.timetype == false || (rowitem.reviewerid != myemp || (rowitem.reviewerid == myemp && rowitem.apsstate >1))"></td>

										<td rowspan="{{rowitem.score.length}}"><textarea ng-model="rowitem.reviewcomment" ng-disabled="rowitem.timetype == false || rowitem.reviewerid != myemp || (rowitem.reviewerid == myemp && rowitem.apsstate >1)" ng-if="rowitem.permittype == 'approve' || rowitem.permittype == 'review'"></textarea></td>
									</tr>
									<tr ng-repeat="rowscore in rowitem.score | orderBy : 'ansscore'" ng-if="$index!=0">
										<td class="center">{{rowscore.ansscore}}</td>
										<td>{{rowscore.anstopic}}</td>
										<td>{{rowscore.ansdetail}}</td>
										<td class="center"><input type="radio" name="__{{rowitem.asgid}}@self" value={{rowscore.ansscore}} ng-model="rowitem.selfscore" ng-disabled ="rowitem.timetype == false || (rowitem.employeeid != myemp || (rowitem.employeeid == myemp && rowitem.apsstate > 0))" ng-if="rowitem.permittype == 'self' || rowitem.permittype == 'approve' || rowitem.permittype == 'review' "></td>
										<td class="center"><input type="radio" name="__{{rowitem.asgid}}@review" value={{rowscore.ansscore}} ng-model="rowitem.reviewscore" ng-if="rowitem.permittype == 'approve' || rowitem.permittype == 'review' " ng-disabled="rowitem.timetype == false || (rowitem.reviewerid != myemp || (rowitem.reviewerid == myemp && rowitem.apsstate >1))"></td>
									</tr>
								</tbody>
							</table>
						
							<div class="form-horizontal">
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form"><b>1. CKLC Appraisal </b></label>
											</div>
										</div>
									</div>	
									<div class="row">
										<div class="form-group">
											<div class="col-md-5 col-sm-5 col-xs-5">
												<table class="table table-head table-hover table-bordered table-title-left ">
													<tr>
														{{ getTotalScore() }}
														<td align="center">{{ getSelfScore() }}</td>
														<td align="center" ng-if="item[0].employeeid == <%=CKLC.getUProfile().get("employeeid")%>"></td>
														<!-- <td>{{ getTotalScore() }}</td> -->
														<!-- <td class="trash"> {{itemtapstran.totalscore}}</td> -->
														<td align="center" ng-if="item[1].employeeid != <%=CKLC.getUProfile().get("employeeid")%>" >{{ totalscore }}</td>
														<td>The Total of {{item.length}} Item</td>
													</tr>
												</table>
											</div>
										</div>
									</div></br>
									
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form"><b>2. Other Appraisal Items</b></label>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form">
													<li class="tab-li">Compliance</li>
													<li class="tab-li">Change of Job</li>
													<li class="tab-li">Contribution Except CKLC</li>
												</label>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												 <textarea rows="2" cols="100" ng-model="itemtapstran.othcomment" ng-disabled="item[0].permittype != 'approve' || (item[0].permittype == 'approve' && item[0].apsstate > 1)"></textarea> 
											</div>
										</div>
									</div></br>
									
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form"><b>3. Overall Result</b></label>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form">
													<li class="tab-li">CKLC Appraisal + Other Appraisal Items</li>
												</label>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<div class="col-md-5 col-sm-5 col-xs-5">
												 <input class="form-control" type="text" ng-model="itemtapstran.overscore" ng-disabled="item[0].permittype != 'approve' || (item[0].permittype == 'approve' && item[0].apsstate > 1)"/>
											</div>
										</div>
									</div></br>

									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form"><b>4. Overall Comments</b></label>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												<label class="control-label control-label-form">
													<li class="tab-li">Reviewer Comments</li>
												</label>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="form-group">
											<div class="col-md-12 col-sm-12 col-xs-12">
												 <textarea rows="2" cols="100" ng-model="itemtapstran.overcomment" ng-disabled="item[0].permittype != 'approve' || (item[0].permittype == 'approve' && item[0].apsstate > 1)"></textarea>
											</div>
										</div>
									</div>
							</div>
							<div class="center">
								<!-- <div class="btn btn-primary" ng-click="save('2')" ng-if="item[0].permittype == 'self' " ng-disabled="item[0].permittype=='self' && item[0].apsstate > 0">Submit</div>
								<div class="btn btn-primary" ng-click="save('2')" ng-if="item[0].permittype == 'approve' " ng-disabled="item[0].permittype == 'approve' && item[0].apsstate > 1 " >Submit</div> -->

								<div class="btn btn-primary" ng-click="save('1')" ng-if="item[0].permittype == 'self' " ng-disabled="item[0].permittype=='self' && item[0].apsstate > 0">Save</div>
								<div class="btn btn-primary" ng-click="save('1')" ng-if="item[0].permittype == 'approve' " ng-disabled="item[0].permittype == 'approve' && item[0].apsstate > 1 ">Save</div>

								<div class="btn btn-primary" ng-click="clear(<%=CKLC.getUProfile().get("employeeid")%>)" ng-if="item[0].permittype == 'self' " ng-disabled="item[0].permittype=='self' && item[0].apsstate > 0">Reset</div>	
								<div class="btn btn-primary" ng-click="clear(<%=CKLC.getUProfile().get("employeeid")%>)" ng-if="item[0].permittype == 'approve' " ng-disabled="item[0].permittype == 'approve' && item[0].apsstate > 1 ">Reset</div>
							</div>	
						</div>
					</div>
				</form>
			<!-- </div> -->
		</section>
	</body>
</html>