<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.databean.*,com.csc.library.session.*,com.csc.library.database.*,com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*,java.text.*"%>
<jsp:useBean id="AS004_6" class="com.csc.library.system.Task" scope="page" />
<%AS004_6.setChannel(request, response);%>
<%HelpEntry screen = (HelpEntry) AS004_6.process("HelpEntry","AS004_6");%>

<%	CheckNull ck = new CheckNull(); 
String employeeid=screen.getUProfile().get("employeeid");
String fullname=screen.getUProfile().get("fullname");
String sbu1,sbu2,sbu3,sbranch,sssy,stit,spos;  //APSASSESSOR
sbu1=ck.chkNullString(request.getParameter("__bu1"),"");
sbu2=ck.chkNullString(request.getParameter("__bu2"),"");
sbu3=ck.chkNullString(request.getParameter("__bu3"),"");
spos=ck.chkNullString(request.getParameter("__pos"),"");
sbranch=ck.chkNullString(request.getParameter("__branch"),"");
sssy=ck.chkNullString(request.getParameter("__ssy"),"");
stit=ck.chkNullString(request.getParameter("__tit"),"");



ThaiUtilities thai = new ThaiUtilities();

String filter = "";
if(!sbu1.equals(""))filter =" and bu1='"+sbu1+"'";

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

if(!sbu3.equals(""))filter =filter+" and bu3='"+sbu3+"'";

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

if(!sbranch.equals(""))filter =filter+" and branch='"+sbranch+"'";

if(!sssy.equals(""))filter =filter+" and simemp.fullname like '%"+sssy+"%'";

if(!stit.equals(""))filter =filter+" and job in ( select apsid from hapstran0 where apstitle='"+stit+"') ";
String dateExp = "SUPER.SUPERVISOR like '%,"+employeeid+",%'";

 String desc ="tdesc";
 if(!screen.getUProfile().get("lang").equals("tha"))desc="edesc";
 DataSet dsBu1 = new DataSet("Select Distinct BU1.TDESC as TDESC,HT.BU1 as BU1 from MSUPERVISOR as SUPER,MBU1 as BU1,HAPSTRAN as HT where  "+dateExp+" and HT.astid='AP10' and (SUPER.employeeid=HT.apsassessy) and (HT.bu1=BU1.bu1id)",(String)screen.getUProfile().get("dbname"),"Hapstran");
// "032299"+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsBu1.initConnection(screen.getUProfile());

 DataSet dsBu2 = new DataSet("Select Distinct BU2.TDESC as TDESC,HT.BU2 as BU2 from MSUPERVISOR as SUPER,MBU2 as BU2,HAPSTRAN as HT where  "+dateExp+" and HT.astid='AP10' and (SUPER.employeeid=HT.apsassessy) and (HT.bu2=BU2.bu2id)",(String)screen.getUProfile().get("dbname"),"Hapstran");
//"032299"+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsBu2.initConnection(screen.getUProfile()); 


DataSet dsBu3 = new DataSet("Select Distinct BU3.TDESC as TDESC,HT.BU3 as BU3 from MSUPERVISOR as SUPER,MBU3 as BU3,HAPSTRAN as HT where  "+dateExp+" and HT.astid='AP10' and (SUPER.employeeid=HT.apsassessy) and (HT.bu3=BU3.bu3id)",(String)screen.getUProfile().get("dbname"),"Hapstran");
dsBu3.initConnection(screen.getUProfile());

DataSet dsPos = new DataSet("Select Distinct POS.TDESC as TDESC,HT.EMP_POSITION as POSITION from MSUPERVISOR as SUPER,MPOSITION as POS,HAPSTRAN as HT where  "+dateExp+" and HT.astid='AP10' and (SUPER.employeeid=HT.apsassessy) and (HT.EMP_POSITION=POS.POSITIONID)",(String)screen.getUProfile().get("dbname"),"Hapstran");
dsPos.initConnection(screen.getUProfile());

DataSet dsBranch = new DataSet("Select Distinct BR.TDESC as TDESC,HT.BRANCH as BRANCH from MSUPERVISOR as SUPER,MBRANCH as BR,HAPSTRAN as HT where  "+dateExp+" and HT.astid='AP10' and (SUPER.employeeid=HT.apsassessy) and (HT.BRANCH=BR.BRANCHID)",(String)screen.getUProfile().get("dbname"),"Hapstran");
dsBranch.initConnection(screen.getUProfile());


DataSet dsTit = new DataSet("Select Distinct HT0.apstitle as TDESC from MSUPERVISOR as SUPER,hAPSTRAN0 as HT0,HAPSTRAN as HT where  "+dateExp+" and HT.astid='AP10' and (SUPER.employeeid=HT.apsassessy) and (HT.APSID=HT0.APSID)",(String)screen.getUProfile().get("dbname"),"Hapstran0");
dsTit.initConnection(screen.getUProfile());


screen.process();

%>
<!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">
<script  language="JavaScript" src="../JS/SCREEN.js"></script>

<script type='text/javascript' src='../JS/ICONSMENU.js'></script>
<script language='javascript' src='../JS/HOTKEY.js'></script>
<script language='javascript'>setLang('<%=screen.getUProfile().get("lang")%>');</script>

<script language="JavaScript" type="text/JavaScript">

function fixSearch(){
	with(document.cscform){
		var tmp = "apsassessy in(select employeeid from msupervisor where  SUPERVISOR like '%,"+__employeeid.value+",%')  and astid='AP10'";
		if(!__branch.value==""){
			tmp += ((tmp!="")?" and ":"")+"branch='"+__branch.value+"'";
		}
		if(!__bu1.value==""){
			tmp += ((tmp!="")?" and ":"")+"bu1='"+__bu1.value+"'";
		}
		if(!__bu2.value==""){
			tmp += ((tmp!="")?" and ":"")+"bu2='"+__bu2.value+"'";
		}
		if(!__bu3.value==""){
			tmp += ((tmp!="")?" and ":"")+"bu3='"+__bu3.value+"'";
		}
		if(!__pos.value==""){
			tmp += ((tmp!="")?" and ":"")+"emp_position='"+__pos.value+"'";
		}
		if(!__ssy.value==""){
			tmp += ((tmp!="")?" and ":"")+"apsassessy in(select employeeid from memployee where  fname like '%"+__ssy.value+"%' or lname like '%"+__ssy.value+"%')";
		}
		if(!__tit.value==""){
			tmp += ((tmp!="")?" and ":"")+"apsid in(select apsid from hapstran0 where  apstitle like '%"+__tit.value+"%')";
		}
	
		__shown.value="1";	
		__fixCon.value = tmp;
		submit();
	}
}
function viewData(apsid,apsassessor,apsassessy){
			//var apsassessy = window.document.cscform.__apsassessy.value;
			with(document.cscform){
				window.open("ASP704.jsp?apsid="+apsid+"&apsassessor="+apsassessor+"&apsassessy="+apsassessy+"&bpage=&ass_level=0&bu1=&bu2=&isread=1","Help2","");
			}
	}
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #339933}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cscform" method="post" action="AS004_6.jsp" >
  

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

<%=screen.InitialVariable()%>

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

<input type="hidden"name="__screen"  value="AS004_6">
  <input type="hidden" name="__help" value="">
  <input type="hidden" name="__cmd"  value="">
<input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>"> 
  <input type="hidden" name="__fixCon" value="">
 <!--  <input type="hidden" name="__orderBy" value="emp_group,apsappstatus1,apssumscore DESC,apsappstatus2,cast(APSASSDESC as int)"> -->
    <input type="hidden" name="__orderBy" value="<%=ck.chkNullString(request.getParameter("__orderBy"),"")%>">
  <input type="hidden" name="__tdesc" value="">
  <input type="hidden" name="__apsobjective" value="">
  <input type="hidden" name="__shown" value="<%=ck.chkNullString(request.getParameter("__shown"),"")%>">
      <input type="hidden" name="__updatefield" value="APSAPPSTATUS1">
  <input type="hidden" name="__returnfield" value="APSSTATUS">
  <input type="hidden" name="__status" value="">
  <input type="hidden" name="__employeeid" value="<%=screen.getUProfile().get("employeeid")%>">
    <input type="hidden" name="__update" value="">
<br>
<br>
        <div align="center">
  <div align="center">
    <table  cellpadding="0"  cellspacing="0" class="large">
      <tr >
        <td  class="header">AS004_6,ประวัติผลการประเมินผู้ใต้บังคับบัญชา
        &nbsp;</td></tr>
      <tr >
        <td  colspan="2">
        
    
			    <table align="center" cellpadding="0" cellspacing="0"  class="largest" >
              <tr>
                <td><div align="right"><strong><script language="javascript">swapLang('assessor');</script></strong>&nbsp;</div></td>
                <td width="285">&nbsp;<strong><%=fullname%></strong></td>
                <td width="305">&nbsp;</td>
                <td width="218"><!--<strong>ประจำปี :</strong>&nbsp;&nbsp;<strong><%=screen.getDataLabel("HAPSTRAN0","APSPERIODSTART")%></strong> --></td>
                <td width="125">&nbsp;</td>
      </tr>
	                <tr>
                <td><div align="right">บริษัท&nbsp;</div></td>
                <td colspan="4">&nbsp;
                  <select name="__branch" id="branch">
                    <option value=""></option>
                    <%while(dsBranch.next()){				
					%>
                    <option value="<%=dsBranch.getString("branch")%>" <%=(sbranch.equals(dsBranch.getString("branch")))?"selected":""%>><%=dsBranch.getString(desc)%></option>
                    <%}%>
                  </select>                  &nbsp;&nbsp;&nbsp;</td>
              </tr>
					<tr>
                <td><div align="right">สาย&nbsp;</div></td>
                <td colspan="4">&nbsp;
                  <select name="__bu1" id="bu1">
                    <option value=""></option>
                    <%while(dsBu1.next()){				
					%>
                    <option value="<%=dsBu1.getString("bu1")%>" <%=(sbu1.equals(dsBu1.getString("bu1")))?"selected":""%>><%=dsBu1.getString(desc)%></option>
                    <%}%>
                  </select>                  &nbsp;&nbsp;&nbsp;</td>
              </tr>
              <tr>
                <td><div align="right">ฝ่าย&nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__bu2" id="__bu2">
                    <option value=""></option>
                    <%while(dsBu2.next()){				
					%>
                    <option value="<%=dsBu2.getString("bu2")%>" <%=(sbu2.equals(dsBu2.getString("bu2")))?"selected":""%>><%=dsBu2.getString(desc)%></option>
                    <%}%>
                  </select></td>
              </tr>
              <tr>
                <td><div align="right">งาน&nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__bu3" id="__bu3">
                    <option value=""></option>
                    <%while(dsBu3.next()){				
					%>
                    <option value="<%=dsBu3.getString("bu3")%>" <%=(sbu3.equals(dsBu3.getString("bu3")))?"selected":""%>><%=dsBu3.getString(desc)%></option>
                    <%}%>
                  </select></td>
              </tr>
              <tr>
                <td><div align="right">ตำแหน่ง&nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__pos" id="__pos">
                    <option value=""></option>
                    <%while(dsPos.next()){				
					%>
                    <option value="<%=dsPos.getString("position")%>" <%=(spos.equals(dsPos.getString("position")))?"selected":""%>><%=dsPos.getString(desc)%></option>
                    <%}%>
                  </select></td>
              </tr>
              <tr>
                <td><div align="right">ชื่อ
                    &nbsp;</div></td>
                <td colspan="4">&nbsp; 
                  <label>
                  <input type="text" name="__ssy" value="<%=thai.ASCII2Unicode(ck.chkNullString(request.getParameter("__ssy"),""))%>">
                  </label></td>
              </tr>
			  <tr>
                <td><div align="right">ปี
                    &nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__tit" id="__tit">
                    <option value=""></option>
                    <%while(dsTit.next()){	
					if(dsTit.getString(desc).length()>0){		
					%>
                    <option value="<%=dsTit.getString(desc).substring(0,4)%>" <%=(stit.equals(dsTit.getString("apstitle")))?"selected":""%>><%=dsTit.getString(desc).substring(0,4)%></option>
                    <%}}%>
                  </select></td>
              </tr>
              <tr>
                <td width="217"><div align="right">&nbsp;</div></td>
                <td colspan="4"><a href="javascript:fixSearch();"><img src="../IMAGES/BUTTON/SEARCH.gif" border="0" align="absmiddle"></a></td>
              </tr>
              <tr>
                <td width="217">&nbsp;</td>
                <td colspan="4">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="5"  class="blankspace">
							<% 
		if(ck.chkNullString(request.getParameter("__shown"),"").equals("1")){
		
			
			//screen.inq.refresh();
			//out.print(thai.ASCII2Unicode(request.getParameter("__fixCon")));
		  %> 
		  <%//=screen.process()%>
		  <%//=screen.nextRec()%>
                <table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#666666" class="largest">
                  <tr>
                    <td class="title1" width="18%"><div align="center">
                        ชื่อ
                    - นามสกุล </div></td> 
                    <td class="title1" width="5%"><div align="center">
                        ปี
                    </div></td>
                    <td class="title1" width="7%"><div align="center">
                        เลขที่เอกสาร
                    </div></td>
                    <td class="title1" width="22%"><div align="center">รายละเอียด</div></td>
                    <td class="title1" width="16%"><div align="center">
                    ผลประเมินระหว่างวันที่</div></td>
                    <td class="title1" width="8%"><div align="center">
                        เกรด
                    </div></td>
                    <td class="title1" width="8%"><div align="center">                    
                    กลุ่มพนักงาน</div></td>
                    <td class="title1" width="8%"><div align="center">
                        หมายเหตุ
                    </div></td>
                  </tr>
	     

              <%
			while(screen.nextRec()){ 
			
			
			  %>
                  <tr>
                   <td><a href="javascript:viewData('<%=screen.getDataLabel("apsid")%>','<%=screen.getDataLabel("apsassessor")%>','<%=screen.getDataLabel("apsassessy")%>');"><%=screen.getDataLabel("simemp","fullname")%></a></td>    
                    <td><div align="center"><%=screen.getDataLabel("hapstran0","apstitle")%></div></td>
                    <td><div align="center"><%=screen.getDataLabel("hapstran0","apsid")%></div></td>
                    <td><div align="left"><%=screen.getDataLabel("hapstran0","tdesc")%></div></td>
                    <td><div align="center"><%=screen.getDataLabel("hapstran0","apsperiodstart")%> - <%=screen.getDataLabel("hapstran0","apsperiodend")%></div></td>
                    <td>
					<%
					if(!screen.getDataLabel("apsassessor").equals(employeeid))
					{
					%>
					<div align="center"><%=screen.getDataLabel("APSAPPGRADE2")%></div>
					<%
					}
					%>					</td>	
                    <td><%=screen.getDataLabel("mgroup","tdesc")%></td>
                    <td><div align="center"><%=screen.getInquiry().getCurrentDbRecord().getSystemCode("APSSYAGREESTAT")%></div></td>
                  </tr>
                 <%
				 } // while
				 %>
                </table>
                  <%		}// if%>                 </td>
              </tr>
            </table>
          </td> 
      </tr>
      <tr bordercolor="0069B3">
        <td  class="bottom"></td>
      </tr>
    </table>
  </div>
</form>
</body>
</html>
