<%@ 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.*"  %>
<% response.setHeader("X-XSS-Protection","0"); %>
<% request.setCharacterEncoding("UTF-8"); %>
<%@ include file="../CHECKPROFILE.jsp" %>
<jsp:useBean id="TREMP012H" class="com.csc.library.system.Task" scope="page" />
<jsp:setProperty name="TREMP012H" property="appname" value="empview" />
<%

	TREMP012H.setChannel(request,response);
	HelpEntry screen = (HelpEntry) TREMP012H.process("HelpEntry","TREMP012H");
	screen.setMaxLine(150);
	screen.process();

	screen.referLangOn();
	CheckNull chk = new CheckNull();
	String __trainingid = chk.chkNullString(request.getParameter("__trainingid"));
	String __orderIn = chk.chkNullString(request.getParameter("__listOrder"));
	String __searchIn = chk.chkNullString(request.getParameter("__searchBy"));
	String __conIn = chk.chkNullString(request.getParameter("__conSearch"));

%>
<!DOCTYPE html>
<html ng-app="myHR">
	<head>
		<title><%=screen.getInquiry().getCurrentDbRecord().getDescription()%></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/SCREEN.js"></script>
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.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 type="text/javascript" src="../JS/EVENTS.js"></script>

		<script type="text/javascript">setLang("<%=screen.getUProfile().get("lang")%>");</script>
		<script type="text/javascript">
			function addMulti(){
				with(document.cscform){
					window.location = "TREMP012W.jsp?newempid="+newempid.value+"&__trainingid="+__trainingid.value;
					//window.open("TREMP012W.jsp?newempid="+newempid.value,"RESERVER","left=150,top=150,width=150,height=100,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}
			function checkAll(){
				with(document.cscform){
					for(i=0;i<elements.length;i++){
						if(elements[i].type=="checkbox"&&elements[i].disabled!=true){
							elements[i].checked=true;
							setNewemp(elements[i].id,true);
						}
					}
				}
			}
			function decheckAll(){
				with(document.cscform){
					for(i=0;i<elements.length;i++){
						if(elements[i].type=="checkbox"&&elements[i].disabled!=true){
							elements[i].checked=false;
							setNewemp(elements[i].id,false);
						}
					}
				}
			}
			function search(){
				with(document.cscform){
					__cmd.value="search";
					submit();
				}
			}
			function setOrderby(){
				with(document.cscform){
					__orderBy.value=__listOrder.options[__listOrder.selectedIndex].value;
					submit();
				}
			}
			function goPage(page){
				with(document.cscform){
					__goPage.value=page;
					submit();
				}
			}
			function resDefemp(){
				with(document.cscform){
					if(defempid.value!=""){
						var tmp_emp = defempid.value.split(",");
						console.log(tmp_emp);
						for(i=0;i<tmp_emp.length;i++){
							if(document.getElementById(tmp_emp[i])!=null){
								document.getElementById(tmp_emp[i]).checked = true;
								document.getElementById(tmp_emp[i]).disabled = true;
							}
						}
					}
				}
			}
			function resNewemp(){
				with(document.cscform){
					if(newempid.value!=""){
						var tmp_emp = newempid.value.split(",");
						for(i=0;i<tmp_emp.length;i++){
							if(document.getElementById(tmp_emp[i])!=null){
								document.getElementById(tmp_emp[i]).checked = true;
							}
						}
					}
				}
			}
			function setNewemp(id,chk){
				var tmp_id = id;
				var tmp_chk = chk;
				with(document.cscform){
					var tmp_newemp = newempid.value;
					if(tmp_chk){
						if(tmp_newemp.indexOf(","+tmp_id+",")<0){
							newempid.value += tmp_id+",";
						}
					}else{
						if(tmp_newemp.indexOf(","+tmp_id+",")>0){
							newempid.value = tmp_newemp.replace(","+tmp_id+",",",");
						}
					}
				}
			}

			$(document).ready(function(){
				$("select").addClass("form-control");
				$("input").addClass("form-control");
				$("input:checkbox").removeClass("form-control");
			});
		</script>
	</head>
	<body>
		<div class="bg-com"></div>
		<section>
			<div class="container csc-content">
				<form name="cscform" method="post"  action="TREMP012H.jsp" mypage="TREMP012H">

					<%=screen.InitialVariable()%>
					<input type="hidden" name="__screen"  value="TREMP012H">
					<input type="hidden" name="__fixCon" value="bossid='<%=screen.getUProfile().get("employeeid")%>'">
					<input type="hidden" name="__cmd"  value="">
					<script language="javascript">getInputFormatDate();</script>
					<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
					<input type="hidden" name="__user" value="<%=screen.getUProfile().get("employeeid")%>">
					<input type="hidden" name="__companyid"  value="<%=screen.getUProfile().get("companyid")%>">
					<input type="hidden" name="__help"  value="">
					<input type="hidden" name="__trainingid" value="<%=request.getParameter("__trainingid")%>">
					<input type="hidden" name="__orderBy" value="">
					<input type="hidden" name="__goPage" value="">
					<input type="hidden" name="__pageCall" value="<%=request.getParameter("__screen")%>">
					<input type="hidden" name="defempid" value="<%=chk.chkNullString(request.getParameter("defempid"))%>">
					<input type="hidden" name="newempid" value="<%=chk.chkNullString(request.getParameter("newempid"))%>">

					<div class="csc-block-white-crystal">

						<div class="center">
							<h2><script>swapLang('Employee list');</script></h2>
						</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"><script type="text/javascript">swapLang("Order By");</script></label>
								</div>
								<div class="col-md-3 col-sm-3 col-xs-3">
									<%=screen.getTagOrder()%>
								</div>
								<div class="col-md-2 col-sm-2 col-xs-2">
									<label class="control-label label-right"><script type="text/javascript">swapLang("Search By");</script></label>
								</div>
								<div class="col-md-3 col-sm-3 col-xs-3">
									<%=screen.getTagSearchBy()%>
								</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"><script type="text/javascript">swapLang("Condition");</script></label>
								</div>
								<div class="col-md-3 col-sm-3 col-xs-3">
									<%=screen.getTagConSearch()%>
								</div>
								<div class="col-md-2 col-sm-2 col-xs-2">
									<label class="control-label label-right"><script type="text/javascript">swapLang("Key Value");</script></label>
								</div>
								<div class="col-md-3 col-sm-3 col-xs-3">
									<div class="input-group">
										<%=screen.getTagValueSearch()%>
										<a class="input-group-addon" href="javascript:search();">
											<i class="fa fa-search"></i>
										</a>
									</div>
								</div>
							</div>
						</div>
					</div><!-- end csc-block-white-crystal-->

					<div class="row">
						<div class="col-md-5 col-sm-5 col-xs-5">
							<span class="detail-table">
								<script language="JavaScript" type="text/javascript">swapLang("Found Data");</script> :&nbsp;&nbsp;<%=screen.getInquiry().recCount() %>&nbsp;
								<script language="JavaScript" type="text/javascript">swapLang("record(s)");</script>
							</span>
						</div>
						<div class="col-md-3 col-sm-3 col-xs-3"></div>
						<div class="col-md-4 col-sm-4 col-xs-4">
							<span class="detail-table label-right">
								<script language="JavaScript" type="text/javascript">swapLang("Page");</script>
								: <%=screen.getPageTag()%>
							</span>
						</div>
					</div>

					<table class="table table-head table-hover table-bordered">
						<thead>
							<tr>
								<th><script>swapLang('Select');</script></th>
								<th><script>swapLang('Employee ID');</script></th>
								<th><script>swapLang('Name');</script> (<script>swapLang('Thai');</script>)</th>
								<th><script>swapLang('Surname');</script> (<script>swapLang('Thai');</script>)</th>
								<th><script>swapLang('Name');</script> (<script>swapLang('Eng');</script>)</th>
								<th><script>swapLang('Surname');</script> (<script>swapLang('Eng');</script>)</th>
								<th><script>swapLang('Position');</script></th>

							</tr>
						</thead>
						<tbody>
						<%
							while(screen.nextRec()){
								if(screen.checkLinePage()){
						%>
									<tr>
										<td>
											<input name="empChk" type="checkbox" value = '<%=screen.getString("employeeid")%>' onclick="setNewemp(this.id,this.checked);" id="<%=screen.getString("employeeid")%>">
										</td>
										<td><%=screen.getString("EMPLOYEEID")%></td>
										<%screen.referLangOff();%>
										<td><%=screen.getString("FNAME")%></td>
										<td><%=screen.getString("LNAME")%></td>
										<td><%=screen.getString("EFNAME")%></td>
										<td><%=screen.getString("ELNAME")%></td>
										<%screen.referLangOn();%>
										<td><%=screen.getString("MPOSITION","TDESC")%></td>
									</tr>
						<%
								}
								if(screen.outLinePage()){ break; }
							}
						%>
						</tbody>
					</table>
					<script language="javascript">resDefemp();</script>
					<script language="javascript">resNewemp();</script>

					<div class="row">
						<div class="form-group">
							<div class="col-md-3 col-sm-1 col-xs-1">
							</div>
							<div class="col-md-8 col-sm-10 col-xs-10">
								<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:addMulti();" class="btn btn-primary" swlang code="SW012101">Add</a>
								<a href="javascript:window.close();" class="btn btn-primary" swlang code="SW012104">Close</a>
							</div>
						</div>
					</div>

					<div class="row">
						<div class="form-group">
						</div>
					</div>

				</form><!--end form-horizontal -->
			</div><!--  end container-->
		</section>
	</body>
</html>