<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@ page import="java.util.HashMap" %>
<%@ include file="../CHECKPROFILE.jsp" %>
<% response.setHeader("X-XSS-Protection","0"); %>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="TREMP012" class="com.csc.library.system.Task" scope="page" />
<jsp:setProperty name="TREMP012" property="appname" value="empview" />
<%
	TREMP012.setChannel(request,response);
	UIManager screen = (UIManager) TREMP012.process("MultiEntry","TREMP012");
	//if(screen.getDataLabel("GRPID").equals(null)||screen.getDataLabel("GRPID").equals("")){multi.getTable().clear();}

	screen.getRecord().getChild("TRESERVER").setFilter("reserverid in (select employeeid from msupervisor where supervisor like '%"+screen.getUProfile().get("employeeid")+"%')");
	screen.getRecord().setRequireFoundTable("TRESERVER");

	CheckNull chknull = new CheckNull();
	String isfromaddpage = chknull.chkNullString(request.getParameter("__fromaddemp"));

	if(!isfromaddpage.equals("true")){
		screen.getRecord().search();
	}

	MultiLine multi = screen.getMultiLine("TRESERVER");

	multi.setLabelBox("check box");
	multi.goFirst();

	HashMap hmSub = getSubordinateList(screen.getUProfile());	/* get subordinate */

%>
<!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/EVENTS.js"></script>
		<script type="text/javascript" src="../JS/DDMENU.js"></script>
		<script type="text/javascript" src="../JS/UTILITIES.js"></script>
		<script type="text/javascript" src="../JS/ACTIVE_OBJECT.js"></script>
		<script type="text/javascript" src="../JS/SCREEN.js"></script>
		<script type="text/javascript" src="../JS/DATEINPUT.js"></script>
		<script type="text/javascript" src="../JS/VIEWCALENDAR.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>

		<style>
			label{
				font-weight:none !important;
			}
		</style>

		<script type="text/javascript">
			setLang("<%=screen.getUProfile().get("lang")%>");
			var swap = new swaplang();
            var titlename = swap.swap2String("SW000694");
			setPageTitle(titlename);

			function GoSave(){confirmSave();}
			function viewCourse(courseid){
				var tmp = courseid;
				with(document.cscform){
					window.open("TREMP007.jsp?__fixCon=crsid='"+tmp+"'","COURSE","left=150,top=150,width=700,height=700,toolbar=no,status=no,scrollbars=yes,resizable=yes");
				}
			}

			function viewTtraining_Time(trainingid){
				var tmp = trainingid;
				with(document.cscform){
					window.open("TREMP011.jsp?__fixCon=trainingid='"+tmp+"'","TTRAININGTIME","left=150,top=150,width=700,height=300,toolbar=no,status=no,scrollbars=yes,resizable=yes");
				}
			}
			function addMultiCustom(){
				console.log('hi');
				with(document.cscform){
					var tmp_bossid = '<%=screen.getUProfile().get("employeeid")%>';
					var filter = "employeeid in (select employeeid from msupervisor where supervisor like '%25" + tmp_bossid + "%25')";
					window.open("TREMP012H.jsp?defempid="+getEmpid()+"&__fixCon="+filter+"&__trainingid="+__trainingid.value,"RESERVER","left=150,top=150,width=700,height=700,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}
			function getEmpid(){
				var tmp_emp = ",";
				with(document.cscform){
					if(typeof empid!="undefined"){
						if(typeof empid.length!="undefined"){
							for(i=0;i<empid.length;i++){
								tmp_emp += empid[i].value+",";
							}
						}else{
							tmp_emp = empid+",";
						}
					}
				}
				return tmp_emp;
			}

			function showHi(){
				console.log('hi');
			}
			$(document).ready(function(){
				var myhtml=$(".key").html();
				myhtml=myhtml.replace("<b>","");
				myhtml=myhtml.replace("</b>","");
				$(".key").html(myhtml);
			});

		</script>
	</head>
	<body>
		<div class="bg-com"></div>
		<jsp:include page="EMV_HEADMENU.jsp" flush="true" />
		<section>
			<div class="container csc-content">
				<form name="cscform" method="post" action="TREMP012.jsp" mypage="TREMP012H">
					<!-- BEGIN CSC INITIAL ZONE -->
					<%=screen.InitialVariable()%>
					<!-- END CSC INITIAL ZONE -->
					<input type='hidden' name='__confirm' value=''/>
					<input type="hidden" name="__cmd" value="">
					<input type="hidden" name="__calendar">
					<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__screen" value="TREMP012">
					<input type="hidden" name="__multiTable" value="TRESERVER">
					<input type="hidden" name="__helpReturn" value="">
					<input type="hidden" name="__help" value="<%=chknull.chkNullString(request.getParameter("__help"))%>">
					<input type="hidden" name="__childMulti" value="TREMP012C">
					<input type="hidden" name="__gorec" value="">
					<input type="hidden" name="__ack" value="">
					<input type="hidden" name="__headMulti" value="TREMP012">
					<input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
					<input type="hidden" name="__fixCon" value="">
					<input type="hidden" name="__notNull" value="">
					<input type="hidden" name="__referPage" value="">
					<input type="hidden" name="__fromaddemp" value="true">
					<input type='hidden' name="__trainingid" value="<%=chknull.chkNullString(request.getParameter("__trainingid"), screen.getDataLabel("TRAININGID"))%>" />
					<script type="text/javascript">getInputFormatDate();</script>

					<div class="csc-block-white-crystal">
						<div class="center">
							<h4 swlang code="SW000694">Training Reserve</h4>
						</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("TRAININGID")%> </label>
								</div>

								<div class="col-md-3 col-sm-3 col-xs-3">
									<p class="control-label"><%=screen.getDataLabel("TRAININGID")%> : <%=screen.getDataLabel("TRTITLE")%></p>
								</div>

								<div class="col-md-2 col-sm-2 col-xs-2">
									<label class="control-label label-right" swlang code='SW012269'>Course ID</label>
								</div>

								<div class="col-md-3 col-sm-3 col-xs-3">
									<p class="control-label"><%=screen.getDataLabel("CRSID")%></p>
								</div>
							</div>
						</div>
						<%screen.referLangOff();%>
						<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("MCOURSE","CRSDESC")%> </label>
								</div>

								<div class="col-md-3 col-sm-3 col-xs-3">
									<p class="control-label"><%=screen.getDataLabel("MCOURSE","CRSDESC")%></p>
								</div>

								<div class="col-md-2 col-sm-2 col-xs-2">
									<label class="control-label label-right"><%=screen.getLabel("MCOURSE","CRSEDESC")%>  </label>
								</div>

								<div class="col-md-3 col-sm-3 col-xs-3">
									<p class="control-label"><%=screen.getDataLabel("MCOURSE","CRSEDESC")%></p>
								</div>
							</div>
						</div>
						<%screen.referLangOn();%>
						<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("CLASSDATEFRM")%> </label>
								</div>

								<div class="col-md-3 col-sm-3 col-xs-3">
									<p class="control-label"><a href="javascript:viewTtraining_Time('<%=screen.getDataLabel("TRAININGID")%>');"><%=screen.getDataLabel("CLASSDATEFRM")%> </a></p>
								</div>

								<div class="col-md-2 col-sm-2 col-xs-2">
									<label class="control-label label-right"><%=screen.getLabel("CLASSDATETO")%> </label>
								</div>

								<div class="col-md-3 col-sm-3 col-xs-3">
									<p class="control-label"><a href="javascript:viewTtraining_Time('<%=screen.getDataLabel("TRAININGID")%>');"><%=screen.getDataLabel("CLASSDATETO")%> </a></p>
								</div>
							</div>
						</div>

					</div><!--end csc-block-white-crystal -->

					<div class="csc-block-white">
						<div class="container">
						<div class="center">
							<h3 swlang code="SW001974">Reserver List</h3>
						</div>
						<table class="table table-head table-hover- table-bordered">
							<thead>
								<tr>
									<th swlang code="SW000289"><script>swapLang('Del');</script></th>
									<th swlang code="SW000274"><script>swapLang('Employee ID');</script></th>
									<th swlang code="SW007745"><script>swapLang('Name Surname');</script></th>
									<th swlang code="SW000057"><script>swapLang('Position');</script></th>
									<th swlang code="SW000019"><script>swapLang('Status');</script></th>
								</tr>
							</thead>
							<tbody>
								<%
									String empid = "";
									for(int i=1;!multi.eof();multi.next(),i++){
										empid = multi.getDataLabel("TRESERVER","RESERVERID");
										if(hmSub.containsKey(empid)){
								%>
										<tr>
											<input type="hidden" name="empid" value="<%=multi.getDataLabel("TRESERVER","RESERVERID")%>">
											<td><input type="checkbox" name="__treserver:<%=multi.getDataLabel("TRESERVER","RESERVERID")%>" value="<%=multi.getDataLabel("TRESERVER","RESERVERID")%>" <%=(multi.getDataLabel("TRESERVER","STATUS").equals("2"))?"disabled":""%>></td>
											<td><%=multi.getDataLabel("TRESERVER","RESERVERID")%></td>
											<td><%=multi.getDataLabel("MEMPLOYEE","FULLNAME") %></td>
											<td><%=multi.getDataLabel("MPOSITION","TDESC") %></td>
											<td><%=multi.getTable().getCurrentRecordManager().getSystemCode("STATUS") %></td>

										</tr>
								<%
										}
									}
								%>
							</tbody>
						</table>

						<div class="row">
							<div class="form-group">
								<div class="col-md-2 col-sm-2 col-xs-2">
								</div>
								<div class="col-md-8 col-sm-8 col-xs-8">
									<a href="javascript:checkAll();" class="btn btn-primary" swlang code="SW002185">Select All</a>
									<a href="javascript:decheckAll();" class="btn btn-primary" swlang code="SW012097">Deselect All</a>
									<a href="javascript:GoSave();" class="btn btn-primary" swlang code="SW012098">Submit</a>
									<a href="javascript:addMultiCustom();" class="btn btn-primary" swlang code="SW012101">Add</a>
									<a href="javascript:deleteMulti();" class="btn btn-primary" swlang code="SW000123">Delete</a>
								</div>
							</div>
						</div>

						<div class="row">
							<div class="form-group">
							</div>
						</div>
					</div><!-- end csc-block-white -->
						<!-- BEGIN CSC ENDING ZONE -->
						<%screen.endJSP();%>
						<!-- END CSC ENDING ZONE -->
				</form>
			</div>
		</section>
		<jsp:include page="FOOTER.jsp" flush="true" />
	</body>


	<%!
	private HashMap getSubordinateList(UProfile upf){
		HashMap hm = new HashMap();
		try {
			DbInquiry inq = new InitialInquiry(upf).getDbInquiry("Memployee");
			inq.setFilter("employeeid in (select employeeid from msupervisor where supervisor like '%" + (String) upf.get("employeeid")  + "%')");
			inq.refresh();

			while(inq.next()){
				hm.put(inq.getString("employeeid"),"");
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return hm ;
	}
	%>
</html>