<%@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.HelpEntry, 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"%>

<jsp:useBean id="APP_EMV_HIS_KC" class="com.csc.library.system.Task" scope="page"/>
<%
	APP_EMV_HIS_KC.setChannel(request, response);
	HelpEntry screen = (HelpEntry) APP_EMV_HIS_KC.process("HelpEntry","APP_EMV_HIS");
	
	CheckNull chk = new CheckNull();
	int maxline = 10;

	String filter = "";
	String apsassessy = "";
	String apsassessor="";
	String bu1 = "";
	String bu2 = "";
	String year = "";
	String emp_position= "";
	
	
	String init_filter ="astid = 'AP30'";
	String init_filter_apsassessy ="astid = 'AP30'";
	String init_filter_apsassessor ="astid = 'AP30'";

	year = chk.chkNullString(request.getParameter("__year"));
	bu1 = chk.chkNullString(request.getParameter("bu1"));
	bu2 = chk.chkNullString(request.getParameter("bu2"));
	apsassessor = chk.chkNullString(request.getParameter("apsassessor"));
	apsassessy = chk.chkNullString(request.getParameter("apsassessy"));
	emp_position = chk.chkNullString(request.getParameter("emp_position"));
	
	filter = "astid = 'AP30'";

if(!year.equals("")){
	filter += " and apsid = '"+year+"' ";
}

if(!apsassessor.equals("")){
			filter += " and  (apsassessor = '"+apsassessor+"'  or apsapprove1 = '"+apsassessor+"' or apsapprove2 = '"+apsassessor+"') ";
	}

if(!apsassessy.equals("")){
			filter += " and apsassessy = '"+apsassessy+"' ";
	}

	if(!bu1.equals("")){
				filter += " and bu1 = '"+bu1+"' ";
	}


	if(!bu2.equals("")){
				filter += " and bu2 = '"+bu2+"' ";
	}

	if(!emp_position.equals("")){
			filter += " and emp_position = '"+emp_position+"' ";
	}

	
	screen.setMaxLine(maxline);
//	out.println("filter  : " + filter);
	screen.getInquiry().setFilter(filter);
	screen.process();
	CscCalendar  c_year = new CscCalendar();

		String dbtype =  ((CscConnection) StaticProperties.myConnection.getConnection(screen.getUProfile().get("dbname"), screen.getUProfile())).getVendor();

	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<link href="../CSS/bootstrap.css" rel="stylesheet"  type="text/css">
<link href="../CSS/bootstrap_csc_backend.css" rel="stylesheet"  type="text/css">
<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
<script type='text/javascript' src="../JS/bootstrap.js"></script>
<script type='text/javascript' src='../JS/SCREEN.js'></script>
<script type='text/javascript' src='../JS/ICONSMENU.js'></script>
<script language='javascript'>setLang('<%=screen.getUProfile().get("lang")%>');</script>

<script language="JavaScript" >
function goSearch(){
with(document.cscform){
		submit();
	}
}

function goClean(){
		with(document.cscform){
				cleanText();
		}
}

function cleanText(){
	with(document.cscform){
		for(i=0;i<elements.length;i++){
			if(elements[i].type=="text") {
				elements[i].value  = "";
			}
		}
	}
}

function goViewAps(apsid,apsassessor_,apsassessy_,isread){
		with(document.cscform){	
		//alert(apsid + " " + apsassessor + " " + apsassessy + " " +isread);
		var param="../EMPVIEW/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 goHelp(helpName,inputName){
	var helpReturn;
		 if(inputName=="bu1" ){
		 	helpReturn="bu1:bu1id,_bu1_tdesc:tdesc";
		 }else if(inputName=="bu2"){
				helpReturn="bu2:bu2id,_bu2_tdesc:tdesc";
		 }else if(inputName == "apsassessor"){
				helpReturn="apsassessor:employeeid,__apsassessor_name:fullname";
		 }else if(inputName=="apsassessy"){
				helpReturn="apsassessy:employeeid,__apsassessy_name:fullname";
		 }else if(inputName == "emp_position"){
				helpReturn="emp_position:positionid,_emp_position_tdesc:tdesc";
		 }
	     linkHelp_Return(helpName,helpReturn);
}

</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cscform" method="post" action="APP_EMV_HIS_KC.jsp">


<!----------BEGIN CSC INITIAL ZONE ------------------------>

<%=screen.InitialVariable()%>

<!----------END CSC INITIAL ZONE -------------------------->

<input type="hidden" name="__calendar">
  <script language="javascript">getInputFormatDate();</script>
  <input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
  <input type ="hidden" name="__cmd" value="">
  <input type="hidden" name="__fixCon" value="">
  <input type="hidden" name="__screen" value="APP_EMV_HIS_KC">
  <input type="hidden" name="__goPage" value ="">
  <input type="hidden" name="__jdesc" value="">
  <input type="hidden" name="__jobcode" value="">
  <div align="center">
  <table  cellpadding="0"  cellspacing="0">
    <tr> 
      <td class="header">APP_EMV_HIS_KC,<script language="javascript">swapLang('History_Of_Key_Competency_Assess');</script></td>
    </tr>
    <tr>
      <td><table  border="0" cellpadding="0" cellspacing="0" id="rsTable" name="rsTable"  class="maxsize">
          <TR> 
            <TD width="150" height="25"></TD>
            <TD width="379"></TD>
            <TD width="257"></TD>
          </TR>
			<tr>
				<td></td>
				<td colspan="2">
					<table  border="0" cellpadding="0" cellspacing="0" id="rsTable" name="rsTable"  class="maxsize ">
					<%
								String tdesc = (screen.getUProfile().get("lang").equals("tha"))?"tdesc":"edesc";
								DataSet condition = new DataSet();
								condition.setDbName((String)screen.getUProfile().get("dbname"));



								condition.setTableName("hapstran0");
								
								condition.setSql("select apsid,tdesc,edesc from hapstran0 where "+init_filter+"");
								condition.initConnection(screen.getUProfile()); %>
						<tr>
								<td><script language="javascript">swapLang("Year_of_Apprasial");</script></td>
								<td><select name="__year">
										<option value="" selected><script language="JavaScript">swapLang("All");</script></option>
										<%
										while(condition.next()){%>
												<option value="<%=condition.getString("apsid")%>" <% if(year.equals(condition.getString("apsid"))){ out.print(" selected "); } %> ><%=condition.getString(tdesc)%></option>			
											
										<%}%>
										
										</select></td>
						</tr>
						
							<tr>
								<td><script language="javascript">swapLang("BU1");</script></td>
								<td><input type="text" name="bu1" id="bu1" value="<%=bu1%>" size="10">
								<a onmouseover="MM_swapImage('__bu1id_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:goHelp('MBU1HELP','bu1');">
								<img name="__bu1id_image" width="20" height="20" align="absmiddle" alt="SEARCH" src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" border="0"/></a><input type="text" name="_bu1_tdesc" value="<%=chk.chkNullString(request.getParameter("_bu1_tdesc"))%>" size ="30" readonly></td>
						</tr>
					
						<tr>
								<td><script language="javascript">swapLang("BU2");</script></td>
								<td><input type="text" name="bu2" value="<%=bu2%>" size="10">
								<a onmouseover="MM_swapImage('__bu1id_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:goHelp('MBU2HELP','bu2');">
								<img name="__bu1id_image" width="20" height="20" align="absmiddle" alt="SEARCH" src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" border="0"/></a><input type="text" name="_bu2_tdesc" value="<%=chk.chkNullString(request.getParameter("_bu2_tdesc"))%>" size ="30" readonly></td>
						</tr>

							<tr>
								<td><script language="javascript">swapLang("position");</script></td>
								<td><input type="text" name="emp_position" value="<%=emp_position%>" size="10">
								<a onmouseover="MM_swapImage('__bu1id_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:goHelp('MPOSITIONHELP','emp_position');">
								<img name="__bu1id_image" width="20" height="20" align="absmiddle" alt="SEARCH" src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" border="0"/></a><input type="text" name="_emp_position_tdesc" value="<%=chk.chkNullString(request.getParameter("_emp_position_tdesc"))%>" size ="30" readonly></td>
						</tr>
						
						<tr>
								<td><script language="javascript">swapLang("Assessor");</script></td>
								<td><input type="text" name="apsassessor" value="<%=apsassessor%>" size="10">
								<a onmouseover="MM_swapImage('__bu1id_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:goHelp('MEMPLOYEEHELP','apsassessor');">
								<img name="__bu1id_image" width="20" height="20" align="absmiddle" alt="SEARCH" src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" border="0"/></a><input type="text" name="__apsassessor_name" value="<%=chk.chkNullString(request.getParameter("__apsassessor_name"))%>" size ="30" readonly></td>
										

								</tr>
						
							<tr>
								<td><script language="javascript">swapLang("assessy");</script></td>
								<td><input type="text" name="apsassessy" value="<%=apsassessy%>" size="10">
								<a onmouseover="MM_swapImage('__bu1id_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)" onmouseout="MM_swapImgRestore()" href="javascript:goHelp('MEMPLOYEEHELP','apsassessy');">
								<img name="__bu1id_image" width="20" height="20" align="absmiddle" alt="SEARCH" src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" border="0"/></a><input type="text" name="__apsassessy_name" value="<%=chk.chkNullString(request.getParameter("__apsassessy_name"))%>" size ="30" readonly>
								
								</td>

								</tr>

								<tr>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
								</tr>



						<tr>
							<td  class="buttonline" colspan="7"><div align="center">
								<button type="button" class="btn btn-primary width100" swlang code="SW013168" onClick="goSearch();">SEARCH</button>&nbsp;
								<button type="button" class="btn btn-primary width100" swlang code="SW013047" onClick="goClean();">CLEAR</button>
							</div>
							</td>
						</tr>

					</table>
				</td>
			  </tr>

          <TR> 
            <TD class="columnlabel" >&nbsp;<script language="JavaScript" type="text/javascript">swapLang("Found Data");</script> :&nbsp;<%=screen.getRecCount()%></TD>
            <TD colspan="2" nowrap><div align="right">&nbsp;&nbsp;<%=screen.getPageTag()%></div></TD>
          </TR>
          <TR> 
            <TD class="columnlabel" >&nbsp;</TD>
            <TD>&nbsp;</TD>
            <TD>&nbsp;</TD>
          </TR>
        </table>
        <table width="327" border="0" cellpadding="0" cellspacing="0" class="inframe tablewithborder" >
          
          <tr > 
					<td width="5%" class="row3"><div align="center"><script language="javascript">swapLang('Seq');</script></div></td>
					<td width="20%" class="row3"><div align="center"><script language="javascript">swapLang('Assessy');</script></div></td>
					<td width="18%" class="row3"><div align="center"><script language="javascript">swapLang('BU1');</script></div></td>
					<td width="18%" class="row3"><div align="center"><script language="javascript">swapLang('BU2');</script></div></td>
					<td width="18%" class="row3"><div align="center"><script language="javascript">swapLang('Position');</script></div></td>
					<td width="10%" class="row3"><div align="center"><script language="javascript">swapLang('Work Age');</script></div></td>
					<td width="7%" class="row3"><div align="center"><script language="javascript">swapLang('Age');</script></div></td>
									
          </tr>

		
		<%
								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 width="10%" class=""><div align="center"><%=inc%></div></td>
						
									<td width="20%" class="" ><div align="left"><a href="javascript:goViewAps('<%=screen.getString("apsid")%>','<%=screen.getString("apsassessor")%>','<%=screen.getString("apsassessy")%>','1')"><%=screen.getString("SIMEMP","fullname")%></a></div></td>
									<td width="18%" class=""><div align="center"><%=screen.getString("mbu1","tdesc")%></div></td>
									<td width="18%" class=""><div align="center"><%=screen.getString("mbu2","tdesc")%></div></td>
									<td width="18%" class=""><div align="center"><%=screen.getString("mposition","tdesc")%></div></td>
									<% String[] y = screen.getDataLabel("simemp","empworkages").split(" "); %>
									<td width="10%" class=""><div align="center"><%=y[0] %>&nbsp;<script language="javascript">swapLang('Year');</script></div></td>
									<td width="7%" class=""><div align="center"><%=screen.getString("SIMEMP","empages")%></div></td>
									
								</tr>
			
								<%
								
								inc++;
								}%>
		
		      
			<tr><td colspan="7" class="blankspace"></td></tr>
			<tr>
			 <td  class="bottom" colspan="7"></td>
		    </tr>
        </table></td>
    </tr>
	
	
  </table>
  </div>
  
</form>
</body>
</html>