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

<%	CheckNull ck = new CheckNull();  
int  total_c=0;
String employeeid=screen.getUProfile().get("employeeid");
String fullname=screen.getUProfile().get("fullname");
if(!ck.chkNullString(request.getParameter("__employeeid"),"").equals("")){
	employeeid= request.getParameter("__employeeid");
	DbInquiry emp_full = new InitialInquiry(screen.getUProfile()).getDbInquiry("MEMPLOYEE");
	emp_full.setColumn("employeeid,prefix,fname,lname");
	emp_full.setFilter("employeeid='"+employeeid+"'");

	emp_full.refresh();
	emp_full.next();
	fullname = emp_full.getString("fullname");
}
String sbu1,sbu2,sbu3,spos,ssor,sap1,sSwork,sEwork,sSage,sEage,sgro;  //apsapprove1
sbu1=ck.chkNullString(request.getParameter("__bu1"),"");
sbu2=ck.chkNullString(request.getParameter("__bu2"),"");
sbu3=ck.chkNullString(request.getParameter("__bu3"),"");
sgro=ck.chkNullString(request.getParameter("__gro"),"");
spos=ck.chkNullString(request.getParameter("__pos"),"");
ssor=ck.chkNullString(request.getParameter("__sor"),"");
sap1=ck.chkNullString(request.getParameter("__ap1"),"");


sSwork=ck.chkNullString(request.getParameter("__startWorkAge"),"");
sEwork=ck.chkNullString(request.getParameter("__endWorkAge"),"");

sSage=ck.chkNullString(request.getParameter("__startAge"),"");
sEage=ck.chkNullString(request.getParameter("__endAge"),"");

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(!ssor.equals(""))filter =filter+" and apsassessor='"+ssor+"'";

if(!sap1.equals(""))filter =filter+" and apsapprove1='"+sap1+"'";

if(!sgro.equals(""))filter =filter+" and job in ( select jobcodeid from mjobcode where jobgroup='"+sgro+"') ";

CscCalendar sEworkDate = new CscCalendar(sEwork);
sEworkDate= sEworkDate.decMonth(sEworkDate.getMonth()+(12-sEworkDate.getMonth()));
 sEworkDate.setDate(sEworkDate.getDayInMonth());
sEwork =sEworkDate.getYYYYMMDD();

if((!sSwork.equals(""))&&(!sEwork.equals(""))){
	filter =filter+" and  APSASSESSY in (select employeeid from memployee where startdate <='"+sSwork+"'  and startdate >='"+sEwork+"' and  status='A') ";

}

CscCalendar sEageDate = new CscCalendar(sEage);
//sEageDate = sEageDate.incYear(1);
sEageDate= sEageDate.decMonth(sEageDate.getMonth()+(12-sEageDate.getMonth()));
 sEageDate.setDate(sEageDate.getDayInMonth());
sEage =sEageDate.getYYYYMMDD();

if((!sSage.equals(""))&&(!sEage.equals(""))){
		filter =filter+" and  APSASSESSY in (select employeeid from memployee where BIRTHDAY <='"+sSage+"'  and BIRTHDAY >='"+sEage+"'  and  status='A') ";
}

CscCalendar cDate = new CscCalendar();
DbInquiry taps0 = new InitialInquiry(screen.getUProfile()).getDbInquiry("TAPSTRAN0");
taps0.setColumn("apsid,apsstartdate,apsenddate");
String f1="apsenddate >= '"+cDate.getYYYYMMDD()+"'   AND";
	f1+=" apsstartdate <='"+cDate.getYYYYMMDD()+"'  ";
taps0.setFilter(f1);

taps0.refresh();
String dateExp = "apsid=''";
while(taps0.next()){
	if(taps0.recNo()==1){
		dateExp = "(apsid='"+taps0.getString("apsid")+"'";
	}else{
		dateExp +=" OR apsid='"+taps0.getString("apsid")+"' ";
	}
}

if(!dateExp.equals("apsid=''")){dateExp+=")";}
screen.inq.setFilter(dateExp+" AND astid='AP10' AND APSAPPROVE2='"+employeeid+"' AND APSAPPSTATUS2 !='A'");
total_c = screen.inq.recCount();
screen.inq.setFilter(dateExp+"  AND astid='AP10'  AND APSAPPROVE2='"+employeeid+"' "+filter);
if(!ck.chkNullString(request.getParameter("__orderBy"),"").equals("")){
	screen.inq.setOrderBy(request.getParameter("__orderBy"));
}else{
	screen.inq.setOrderBy("emp_group,apsappstatus2,apsappgrade1,apsappgrade2");
}
((Simtapstran_kkb)screen.inq.getCurrentDbRecord()).approveConfirm();
 String desc ="tdesc";
  if(!screen.getUProfile().get("lang").equals("tha"))desc="edesc";
 DataSet dsBu1 = new DataSet("Select Distinct apsapprove2,BU1 ,MBU1.TDESC AS TDESC, MBU1.EDESC AS EDESC from TAPSTRAN , MBU1 where  "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.bu1=MBU1.bu1id and  apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
// "030099"+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsBu1.initConnection(screen.getUProfile());

 DataSet dsBu2 = new DataSet("Select Distinct apsapprove2,BU2,MBU2.TDESC AS TDESC, MBU2.EDESC AS EDESC from TAPSTRAN, MBU2 where  "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.bu2=MBU2.bu2id and  apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
//"030099"+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsBu2.initConnection(screen.getUProfile()); 


DataSet dsBu3 = new DataSet("Select Distinct apsapprove2,BU3,MBU3.TDESC AS TDESC, MBU3.EDESC AS EDESC from TAPSTRAN, MBU3 where  "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.bu3=MBU3.bu3id and  apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsBu3.initConnection(screen.getUProfile());


DataSet dsGro = new DataSet("Select Distinct apsapprove2, MJOBGROUP.JOBGROUPID,MJOBGROUP.TDESC AS TDESC, MJOBGROUP.EDESC AS EDESC from TAPSTRAN, MJOBGROUP, MJOBCODE  where  "+dateExp+" and TAPSTRAN.astid='AP10' and  TAPSTRAN.JOB=MJOBCODE.JOBCODEID AND  MJOBCODE.JOBGROUP=MJOBGROUP.JOBGROUPID  AND   apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsGro.initConnection(screen.getUProfile());

DataSet dsPos = new DataSet("Select Distinct apsapprove2,emp_position,POSITIONID,MPOSITION.TDESC AS TDESC, MPOSITION.EDESC AS EDESC from TAPSTRAN, MPOSITION where "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.emp_position=MPOSITION.POSITIONID and  apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsPos.initConnection(screen.getUProfile());


DataSet dsSor = new DataSet("Select Distinct apsapprove2,APSASSESSOR,MEMPLOYEE.FNAME AS TDESC, MEMPLOYEE.EFNAME AS EDESC from TAPSTRAN, MEMPLOYEE where  "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.APSASSESSOR=MEMPLOYEE.EMPLOYEEID and  apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsSor.initConnection(screen.getUProfile());

DataSet dsAp1 = new DataSet("Select Distinct apsapprove1 ,MEMPLOYEE.FNAME AS TDESC, MEMPLOYEE.EFNAME AS EDESC from TAPSTRAN, MEMPLOYEE where   "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.apsapprove1=MEMPLOYEE.EMPLOYEEID and  apsapprove2='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsAp1.initConnection(screen.getUProfile());
%>
<!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 MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function goHelp(helpName,inputName){
	var helpReturn;
	var temp_fixCon;
	if(inputName=="__bu1" )
		helpReturn="__bu1:bu1id,MBU1@TDESC";
	 else if(inputName=="__bu2" )
		helpReturn="__bu2:bu2id,MBU2@TDESC";	
	temp_fixCon = document.cscform.__fixCon.value;
	document.cscform.__fixCon.value="";
	linkHelp_Return(helpName,helpReturn);
	
	document.cscform.__fixCon.value=temp_fixCon;
	
	
}
function fixSearch(){
	with(document.cscform){
		chkDate(__workage1,__workage2,__startWorkAge,__endWorkAge);
		genDate(__workage1,__startWorkAge);
		genDate(__workage2,__endWorkAge); 

		chkDate(__age1,__age2,__startAge,__endAge);
		genDate(__age1,__startAge); 
		genDate(__age2,__endAge); 
		__shown.value="1";
		submit();
	}
}
function goConfirm(){
	with(document.cscform){
		__status.value="A";
		__cmd.value="ack";
		submit();
	
	}
}
function goReturn(){
	with(document.cscform){
		__status.value="R";
		__cmd.value="ack";			
		submit();
	}
}
function goCheck1(emp_group,fieldName){

	with(document.cscform){
		for(i=0;i<elements.length;i++){
				if(elements[i].name.indexOf("__lineg")>=0){				
					if(elements[i].options[elements[i].selectedIndex].value=="apsappgrade2:"){
						elements[i].disabled="disabled";
					}
				}
			}
		__status.value="W";
		__cmd.value="ack";	
		__gochk.value=emp_group+":"+fieldName;
		submit();
	}
}
function goCheck(emp_group,fieldName){
		with(document.cscform){
			var param="AS004_2C1.jsp?__emp_group="+emp_group+"&__fieldName="+fieldName+"&__appfield="+"APSAPPROVE2&__bu1="+__bu1.value+"&__bu2="+__bu2.value+"&__bu3="+__bu3.value+"&__gro="+__gro.value+"&__pos="+__pos.value+"&__sor="+__sor.value+"&__ap1="+__ap1.value+"&__startWorkAge="+__startWorkAge.value+"&__endWorkAge="+__endWorkAge.value+"&__startAge="+__startAge.value+"&__endAge="+__endAge.value+"&workage1="+__workage1.value+"&workage2="+__workage2.value+"&age1="+__age1.value+"&age2="+__age2.value;			
	//		alert(param);
			win = window.open(param,"AS004_3C1","left=150,top=150,width=600,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
			if(window.focus){win.focus();}
		}
}

function goASP700(apsid,apsassessor,apsassessy){
	with(document.cscform){
		action="ASP700.jsp?apsid="+apsid+"&apsassessor="+apsassessor+"&apsassessy="+apsassessy+"&bpage="+__screen.value+"&ass_level=3&bu1="+__bu1.value+"&bu2="+__bu2.value+"&isread=0&order="+__orderBy.value+"&bu3="+__bu3.value+"&gro="+__gro.value+"&pos="+__pos.value+"&sor="+__sor.value+"&ap1="+__ap1.value+"&startWorkAge="+__startWorkAge.value+"&endWorkAge="+__endWorkAge.value+"&startAge="+__startAge.value+"&endAge="+__endAge.value+"&workage1="+__workage1.value+"&workage2="+__workage2.value+"&age1="+__age1.value+"&age2="+__age2.value;			
		__orderBy.value="";
		submit();
	}

}
function goReASP700(apsid,apsassessor,apsassessy){
	with(document.cscform){
		action="ASP700.jsp?apsid="+apsid+"&apsassessor="+apsassessor+"&apsassessy="+apsassessy+"&bpage="+__screen.value+"&ass_level=3&bu1="+__bu1.value+"&bu2="+__bu2.value+"&isread=1&order="+__orderBy.value;+"&bu3="+__bu3.value+"&gro="+__gro.value+"&pos="+__pos.value+"&sor="+__sor.value+"&ap1="+__ap1.value+"&startWorkAge="+__startWorkAge.value+"&endWorkAge="+__endWorkAge.value+"&startAge="+__startAge.value+"&endAge="+__endAge.value;		
		__orderBy.value="";
		submit();
	}
}
function calAge(strDate){
	var currentYear = parseInt(new Date().getYear());
	var birthdateYear = parseInt(strDate.substring(6,10));
	var age = currentYear-birthdateYear;
	document.write(age);
}

function setOrder(field){
	with(document.cscform){	
		for(i=0;i<elements.length;i++){
				if(elements[i].name.indexOf("__lineg")>=0){				
					if(elements[i].options[elements[i].selectedIndex].value=="apsappgrade2:"){
						elements[i].disabled="disabled";
					}
				}
			}
		__orderBy.value="EMP_GROUP,"+field;
		__status.value="W";
		__cmd.value="ack";	
		__orderBy.value="emp_group,"+field;

		fixSearch();
	}
}
function chkBox(){
		with(document.cscform){
			for(i=0;i<elements.length;i++){
					if(elements[i].type=="checkbox"){
						if(elements[i].checked){														
								return true;	
						}
					}
			}//end for
			return false;
		}//end with
}//end function

function goConfirm1(){
	var count=0;
	var returnVal = true;
	if(chkBox()){
			with(document.cscform){

				for(i=0;i<elements.length;i++){
					if(elements[i].name.indexOf("__lineg")>=0){
						
						if(elements[i].options[elements[i].selectedIndex].value=="apsappgrade2:"){
							elements[i].disabled="disabled";
						}else{
								count++;
						}
					}
				}
			}
			if(count<document.cscform.__total_c.value){			
					alert("ยังเหลือพนักงานที่ต้องประเมินอีก "+(document.cscform.__total_c.value-count)+" คน");
			}	
			goConfirm();
	}else{
		alert("โปรดเลือกพนักงานก่อน");
	}
}

 function genDate(obj,nameOut){	
	with(document.cscform){
	var sYear,sMonth,sDate;
		var nDate= new Date();
		var outDate= new Date();
		sDate= nDate.getDate();

		sMonth=nDate.getMonth()+1;
		sYear=nDate.getFullYear();
		var sAge = obj.value.split(".");
		if(sAge[1]>sMonth){
			sYear = sYear-1; 
			sMonth = (sMonth+12)-sAge[1];
			sYear = sYear-sAge[0] ;
			outDate.setFullYear(sYear,sMonth-1,1);	
		}else{
			if(sAge[1]==sMonth){
				sYear = sYear-1; 
				sYear = sYear-sAge[0] ;
				outDate.setFullYear(sYear,12,1);	
			}else{
				sMonth =sMonth-sAge[1];
				sYear = sYear-sAge[0] ;			
				outDate.setFullYear(sYear,sMonth,1);				
			}
		}
		sMonth=outDate.getMonth();
		if(sMonth<10)sMonth='0'+sMonth;
		nameOut.value=outDate.getFullYear()+'-'+sMonth+'-0'+outDate.getDate();		

	}
}
function chMonth(sInput){
	with(document.cscform){
		var data = sInput.value.split(".");
		if(data[1]>11){
			sInput.value=data[0]+"."+"0"+data[1];
			sInput.value=sInput.value.substring(0,sInput.value.length-1)	;	
		}
	}
}
function chkDate(start,end,setStart,senEnd){
	with(document.cscform){
		if(!((start.value=='0.00')&&(end.value=='0.00'))){
				chMonth(start);
				chMonth(end);				
				if(start.value==end.value){
					start.value='0.00';
				}
		}else{
			setStart.disabled='disabled';
			senEnd.disabled='disabled';
		}

	}
}
function chk(inbo,grad){
	with(document.cscform){
	//	alert(inbo.value);
						var grad_1 ="";		
						for(i=0;i<elements.length;i++){	
							if(elements[i].name==grad){
								grad_1=elements[i].value.split(':')[1];
//								alert(grad_1);
								if(inbo.checked){
									if((elements[i].status=='W')||(elements[i].status=='R')){
											if((typeof grad_1)=="undefined"){						
													alert('  โปรดให้เกรดพนักงาน  ');
													inbo.checked='';
											}else{
											elements[i].disabled='disabled';
											}
									}else{
										alert("กรุณาให้คะแนนประเมิลผลก่อน");
										inbo.checked='';
									}
								}else{
									elements[i].disabled='';
								}
							}
						}				
			if((typeof grad_1)!="undefined"){						
				
			var tmp =inbo.value.split(':');
			var data='';
			for(i=0;i<tmp.length;i++){
					if(i==tmp.length-1){
					data=data+grad_1;
					}else{
						data=data+tmp[i]+':';
					}				
			}
		inbo.value=data;	
	//	alert(inbo.value);
		}
	}
}

	function checkAll(){
		with(document.cscform){
			for(i=0;i<elements.length;i++){
					if(elements[i].type=="checkbox"){
							elements[i].checked=true;
						//	chk(elements[i],'');
					}
			}//end for
		}//end with
	}//end function
	function viewHis(grade,apsassessy){
		with(document.cscform){
			var page = "ASP705.jsp?apsassessy="+apsassessy+"&grade="+grade+"&bpage="+__screen.value+"&bu1="+__bu1.value+"&bu2="+__bu2.value;
			window.open(page,"viewhis","left=150,top=150,width=750,height=500,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		}
	}
</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_3.jsp" >
  

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

<%=screen.InitialVariable()%>

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

<input type="hidden"name="__screen"  value="AS004_3">
  <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,apsappstatus2,apsappgrade1,apsappgrade2"> -->
  <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="APSAPPSTATUS2">
  <input type="hidden" name="__returnfield" value="APSAPPSTATUS1">
  <input type="hidden" name="__status" value="">
  <input type="hidden" name="__employeeid" value="<%=ck.chkNullString(request.getParameter("__employeeid"),"")%>">
  <input type="hidden" name="__update" value="">
  <input type="hidden" name="__total_c" value="<%=total_c%>">
  <br>

        <div align="center">
		<div id="element" style="width:100%;position:absolute;top:0;left:0"> 
		    <table  cellpadding="0"  cellspacing="0" class="large">
 
              <tr>
                <td  colspan="4" width="40">&nbsp;</td>
                <td colspan="4">เรียงลำดับ&nbsp; <INPUT TYPE="Button" name='xx' id='xx' onClick="javaScript:setOrder('APSAPPGRADE1,APSSUMSCORE DESC')"  value="เกรดลำดับ 2">&nbsp;&nbsp;&nbsp; <INPUT TYPE="Button" name='xx1' id='xx1' onClick="javaScript:setOrder('APSAPPGRADE2,APSSUMSCORE DESC')"  value="เกรดลำดับ 3"></td>
              </tr></table></div>

    <table  cellpadding="0"  cellspacing="0" class="large">
      <tr >
        <td  class="header">AS004_3,ประเมินผลระดับที่ 3
          <!-- <script language="javascript">swapLang('Save score');</script> -->
        &nbsp;</td></tr>
      <tr >
        <td  colspan="2">
        
          <div align="center">
            <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="176">&nbsp;<strong><%=fullname%></strong></td>
                <td width="242"><strong>จำนวนผู้ถูกประเมิน :&nbsp;&nbsp;<%=screen.inq.recCount()%></strong></td>
                <td width="155"><!--<strong>ประจำปี :</strong>&nbsp;&nbsp;<strong><%=screen.getDataLabel("TAPSTRAN0","APSPERIODSTART")%></strong> --></td>
                <td width="87">&nbsp;</td>
      </tr>
              <tr>
                <td><div align="right"><%=screen.getLabel("bu1")%>&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;</td>
              </tr>
              <tr>
                <td><div align="right"><%=screen.getLabel("bu2")%>&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"><%=screen.getLabel("bu3")%>&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="__gro" id="select">
                    <option value=""></option>
                    <%while(dsGro.next()){				
					%>
                    <option value="<%=dsGro.getString("jobgroupid")%>" <%=(sgro.equals(dsGro.getString("jobgroupid")))?"selected":""%>><%=dsGro.getString(desc)%></option>
                    <%}%>
                     </select></td>
              </tr>
              <tr>
                <td><div align="right"><%=screen.getLabel("emp_position")%>&nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__pos" id="__pos">
                    <option value=""></option>
                    <%while(dsPos.next()){				
					%>
                    <option value="<%=dsPos.getString("positionid")%>" <%=(spos.equals(dsPos.getString("positionid")))?"selected":""%>><%=dsPos.getString(desc)%></option>
                    <%}%>
                  </select></td>
              </tr>
              <tr>
                <td><div align="right"><script language="javascript">swapLang('assessor');</script>
                    &nbsp;1&nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__sor" id="__sor">
                    <option value=""></option>
                    <%while(dsSor.next()){				
					%>
                    <option value="<%=dsSor.getString("apsassessor")%>" <%=(ssor.equals(dsSor.getString("apsassessor")))?"selected":""%>><%=dsSor.getString(desc)%></option>
                    <%}%>
                  </select></td>
              </tr>
              <tr>
                <td><div align="right"><script language="javascript">swapLang('assessor');</script>
                    &nbsp;2&nbsp;</div></td>
                <td colspan="4">&nbsp; <select name="__ap1" id="__ap1">
                    <option value=""></option>
                    <%while(dsAp1.next()){				
					%>
                    <option value="<%=dsAp1.getString("apsapprove1")%>" <%=(sap1.equals(dsAp1.getString("apsapprove1")))?"selected":""%>><%=dsAp1.getString(desc)%></option>
                    <%}%>
                  </select></td>
              </tr>              
              <tr>
                <td width="154"><div align="right">&nbsp;อายุงาน</div></td>
                <td colspan="4">&nbsp;  <INPUT TYPE='text' Name='__workage1' id='__workage1' SIZE='6' MAXLENGTH='6' VALUE='<%=ck.chkNullString(request.getParameter("__workage1"),"0.00")%>'  onClick="" onChange=""  onKeyPress="checkWordNumber(this.value);" onKeyUp="sysIsEdit();checkComma(this,2);" dir="" onBlur="chkLengthFloat1(this,__workage2,90)" onFocus="callDelComma(this);" class="numeric" alt="อายุงาน" >&nbsp;-&nbsp;<INPUT TYPE='text' Name='__workage2'   id='__workage2' SIZE='6' MAXLENGTH='6' VALUE='<%=ck.chkNullString(request.getParameter("__workage2"),"0.00")%>'  onClick="" onChange=""  onKeyPress="checkWordNumber(this.value);" onKeyUp="sysIsEdit();checkComma(this,2);" dir="" onBlur="chkLengthFloat2(this,__workage1,90);" onFocus="callDelComma(this);" class="numeric" alt="อายุ"  >
                  <input type="hidden" name="__startWorkAge" id="__startWorkAge" value='<%=ck.chkNullString(request.getParameter("__startWorkAge"),"")%>'>
                <input type="hidden" name="__endWorkAge" id="__endWorkAge"  value='<%=ck.chkNullString(request.getParameter("__endWorkAge"),"")%>'> (YY.MM  ตัวอย่าง 1.11) </td>
              </tr>              
              <tr>
                <td width="154"><div align="right">&nbsp;อายุ</div></td>
                <td colspan="4">&nbsp;  <INPUT TYPE='text' Name='__age1' SIZE='6' MAXLENGTH='6' VALUE='<%=ck.chkNullString(request.getParameter("__age1"),"0.00")%>'  onClick="" onChange="javaScript:genDate(this,'__startWorkAge');"  onKeyPress="checkWordNumber(this.value);" onKeyUp="sysIsEdit();checkComma(this,2);" dir="" onBlur="chkLengthFloat1(this,__age2,90);" onFocus="callDelComma(this);" class="numeric" alt="อายุ"  >&nbsp;-&nbsp;<INPUT TYPE='text' Name='__age2' SIZE='6' MAXLENGTH='6' VALUE='<%=ck.chkNullString(request.getParameter("__age2"),"0.00")%>'  onClick="javaScript:genDate(this,'__endkAge');" onChange=""  onKeyPress="checkWordNumber(this.value);" onKeyUp="sysIsEdit();checkComma(this,2);" dir="" onBlur="chkLengthFloat2(this,__age1,90);" onFocus="callDelComma(this);" class="numeric" alt="อายุ"  >
                  <input type="hidden" name="__startAge" id="__startAge"  value='<%=ck.chkNullString(request.getParameter("__startAge"),"")%>'>
                <input type="hidden" name="__endAge" id="__endAge"  value='<%=ck.chkNullString(request.getParameter("__endAge"),"")%>'> (YY.MM  ตัวอย่าง  1.06)&nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:fixSearch();"><img src="../IMAGES/BUTTON/SEARCH.gif" border="0" align="absmiddle"></a></td>
              </tr>
             
              <tr>
                <td width="154">&nbsp;</td>
                <td colspan="4">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="5"  class="blankspace"><% 
		int  recCount=0;
		if(ck.chkNullString(request.getParameter("__shown"),"").equals("1")){
			//screen.inq.setFilter("APSAPPROVE2='"+"030099"+"'"+filter);
			screen.inq.refresh();
			screen.inq.next();
		  	int running=0;
		  	double a_per,b_per,c_per,to_per;
			a_per=0.00;
			b_per=0.00;
			c_per=0.00;
			to_per=0.00;
  			double a_per_t,b_per_t,c_per_t,to_per_t;
			a_per_t=0.00;
			b_per_t=0.00;
			c_per_t=0.00;
			to_per_t=0.00;					
			String old_group,cur_group;
				String workage="";
			boolean nextRec,end;
			recCount =screen.inq.recCount();
			DecimalFormat dc = new DecimalFormat();
			dc.applyPattern("#0.00");
			if(recCount>0){
				nextRec=true;
				end=true;
				while(end){
		  %>      
                <table width="0%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#666666" class="largest1">
                <tr>
                    <td colspan="18"><strong><script language="javascript">swapLang('Employee Group Code');</script>
                      &nbsp;&nbsp;:<%=screen.getDataLabel("mgroup","tdesc")%></strong></td>
                    </tr>
                  <tr>
                    <td class="title1" width="4%"><div align="center">
                        <script language="javascript">swapLang('Select');</script>
                    </div></td>
                    <td class="title1" width="5%"><div align="center">
                        <script language="javascript">swapLang('Status');</script>
                    </div></td>
                    <td class="title1" width="4%"><div align="center">
                        <script language="javascript">swapLang('grade');</script>
                    </div></td>
                    <td class="title1" width="5%"><div align="center">
                      <script language="javascript">swapLang('grade');</script>ลำดับ&nbsp;2</div></td>
                    <td class="title1" width="5%"><div align="center">
                      <script language="javascript">swapLang('grade');</script>ลำดับ&nbsp;1</div></td>
                    <td class="title1" width="5%"><div align="center"><script language="javascript">swapLang('Score');</script>
                    </div></td>
                    <td class="title1" width="5%"><div align="center">                    
                      ประเมิน &nbsp;2</div></td>
                    <td class="title1" width="5%"><div align="center">
                      <div align="center">                    
                      ประเมิน
                      &nbsp;1</div></div></td>
                    <td class="title1" width="6%"><div align="center">เกรด <%if(!screen.getDataLabel("APSASYDESC").equals("")){
						out.print(screen.getDataLabel("APSASYDESC").split(",")[0]);
					}%></div></td>
                    <td class="title1" width="8%"><div align="center">
                        <script language="javascript">swapLang('assessy');</script>
                    </div></td>
                    <td class="title1" width="7%"><div align="center">
                        <script language="javascript">swapLang('division');</script>
                    </div></td>
                    <td class="title1" width="7%"><div align="center">
                        <script language="javascript">swapLang('position');</script>
                    </div></td>
                    <td class="title1" width="4%"><div align="center">
                        <script language="javascript">swapLang('Service Year');</script>
                    </div></td>
                    <td class="title1" width="4%"><div align="center">อายุ</div></td>
                    <td class="title1" width="4%"><div align="center">
                        ช.ม.<br>ทำงาน<br>เฉลี่ย
                    </div></td>
                    <td class="title1" width="4%"><div align="center">
                        <script language="javascript">swapLang('V2U');</script>
                    </div></td>
					<td class="title1" width="4%"><div align="center">
                       <!--  <script language="javascript">swapLang('');</script> -->
                    </div>วินัย</td>   
					 <td  class="title1" width="4%"><div align="center">สถานะ<br>ผู้ถูก<br>ประเมิน</div></td>                 
                  </tr>

              <%
				old_group = screen.inq.getString("emp_group");	
			  	cur_group = screen.inq.getString("emp_group");	
			  	nextRec=true;
				a_per=0;
				b_per=0;
				c_per=0;
				to_per=0;
			  	while(nextRec){
					
					to_per++;
					to_per_t++;
					if(screen.inq.getString("apsappgrade2").indexOf("A")>=0){
						a_per++;
						a_per_t++;
					}else{
						if(screen.inq.getString("apsappgrade2").indexOf("B")>=0){
							b_per++;
							b_per_t++;
						}else{
							if(screen.inq.getString("apsappgrade2").indexOf("C")>=0){
								c_per++;
								c_per_t++;
							}
						}
					}
			  %>
                  <tr>
                    <td><%//=screen.getDataLabel("APSAPPSTATUS1")+"========="+screen.getDataLabel("APSAPPSTATUS2")%>
<%if((screen.getDataLabel("APSAPPSTATUS1").equals("A"))&&(screen.getDataLabel("APSAPPSTATUS2").equals("W"))){%>
<input type="checkbox" name="__ch<%=(++running)%>:APSID:APSASSESSOR:APSASSESSY:APSSTATUS:APSAPPGRADE2" value="<%=screen.getDataLabel("APSID")+":"+screen.getDataLabel("APSASSESSOR")+":"+screen.getDataLabel("APSASSESSY")+":"+screen.getDataLabel("APSSTATUS")+":"+screen.getDataLabel("APSAPPGRADE2")%>" id="__ch<%=running++%>:APSID:APSASSESSOR:APSASSESSY:APSSTATUS:APSAPPGRADE2" align="absmiddle"   onChange="chk(this,'__lineg:<%=screen.getDataLabel("mbu1","bu1id")+":"+screen.getDataLabel("mbu2","bu2id")+":"+screen.getDataLabel("mbu3","bu3id")+":"+screen.inq.getString("emp_group")+":"+screen.inq.getString("APSASSESSY")+":"+screen.getDataLabel("runno")%>')">


                    <%}else{%>
                    &nbsp;
                    <%}%>                    </td>
                    <td><div align="center"><%if((screen.getDataLabel("apsappstatus2").equals(""))||(screen.getDataLabel("apsappstatus2").equals("0"))||(screen.getDataLabel("apsappstatus1").equals("R"))){%>
			
					 <span class="style1"><%=screen.inq.getCurrentDbRecord().getSystemCode("apsappstatus2")%></span>
					<%}else{
						if(screen.getDataLabel("apsappstatus2").equals("A")){%>
						 <span class="style2"><%=screen.inq.getCurrentDbRecord().getSystemCode("apsappstatus2")%></span>
					   <%}else{%>
							<%=screen.inq.getCurrentDbRecord().getSystemCode("apsappstatus2")%>
					  <%}
					 }
						%></div> </td>
                    <td><div align="center">
					<%if((screen.getDataLabel("APSAPPSTATUS1").equals("A"))&&(screen.getDataLabel("APSAPPSTATUS2").equals("W"))){%>  

					<select id="__lineg:<%=screen.getDataLabel("mbu1","bu1id")+":"+screen.getDataLabel("mbu2","bu2id")+":"+screen.getDataLabel("mbu3","bu3id")+":"+screen.inq.getString("emp_group")+":"+screen.getDataLabel("runno") %>" name="__lineg:<%=screen.getDataLabel("mbu1","bu1id")+":"+screen.getDataLabel("mbu2","bu2id")+":"+screen.getDataLabel("mbu3","bu3id")+":"+screen.inq.getString("emp_group")+":"+screen.getDataLabel("runno") %>" status='<%=screen.getDataLabel("APSAPPSTATUS2")%>'>	
<%
String  select =""; //selected
String  A1,A2,A3,B1,B2,B3,B4,B5,C1,C2;
A1=A2=A3=B1=B2=B3=B4=B5=C1=C2="";
if(!(screen.getDataLabel("apsappgrade2").equals("")||screen.getDataLabel("apsappgrade2").equals("0"))){
	if(screen.getDataLabel("apsappgrade2").equals("A1")){
		A1="selected";
	}else
		if(screen.getDataLabel("apsappgrade2").equals("A2")){
		A2="selected";
	}else
		if(screen.getDataLabel("apsappgrade2").equals("A3")){
		A3="selected";
	}else	if(screen.getDataLabel("apsappgrade2").equals("B1")){
		B1="selected";
	}else
		if(screen.getDataLabel("apsappgrade2").equals("B2")){
		B2="selected";
	}else
		if(screen.getDataLabel("apsappgrade2").equals("B3")){
		B3="selected";
	}else
	if(screen.getDataLabel("apsappgrade2").equals("B4")){
		B4="selected";
	}else
		if(screen.getDataLabel("apsappgrade2").equals("B5")){
		B5="selected";
	}else
		if(screen.getDataLabel("apsappgrade2").equals("C1")){
		C1="selected";
	}else
	if(screen.getDataLabel("apsappgrade2").equals("C2")){
		C2="selected";
	}
}else{
	if(screen.getDataLabel("apsappgrade1").equals("A1")){
		A1="selected";
	}else
		if(screen.getDataLabel("apsappgrade1").equals("A2")){
		A2="selected";
	}else
		if(screen.getDataLabel("apsappgrade1").equals("A3")){
		A3="selected";
	}else	if(screen.getDataLabel("apsappgrade1").equals("B1")){
		B1="selected";
	}else
		if(screen.getDataLabel("apsappgrade1").equals("B2")){
		B2="selected";
	}else
		if(screen.getDataLabel("apsappgrade1").equals("B3")){
		B3="selected";
	}else
	if(screen.getDataLabel("apsappgrade1").equals("B4")){
		B4="selected";
	}else
		if(screen.getDataLabel("apsappgrade1").equals("B5")){
		B5="selected";
	}else
		if(screen.getDataLabel("apsappgrade1").equals("C1")){
		C1="selected";
	}else
	if(screen.getDataLabel("apsappgrade1").equals("C2")){
		C2="selected";
	}
}
%>							
						<option value="apsappgrade2:"></option>                       
						<option value="apsappgrade2:A1"   <%=A1%> >A1</option>
						<option value="apsappgrade2:A2"  <%=A2%>  >A2</option>
						<option value="apsappgrade2:A3"  <%=A3%> >A3</option>
						<option value="apsappgrade2:B1"  <%=B1%>  >B1</option>
						<option value="apsappgrade2:B2"   <%=B2%>  >B2</option>
						<option value="apsappgrade2:B3"   <%=B3%>  >B3</option>
						<option value="apsappgrade2:B4"  <%=B4%>>B4</option>
						<option value="apsappgrade2:B5"  <%=B5%> >B5</option>
						<option value="apsappgrade2:C1"  <%=C1%> >C1</option>
						<option value="apsappgrade2:C2"   <%=C2%> >C2</option>
					</select>
<%}else{%>		
					<%if((!screen.getDataLabel("apsappgrade2").equals(""))&&(!screen.getDataLabel("apsappgrade2").substring(0,1).equals(screen.getDataLabel("apsappgrade1").substring(0,1)))){%>
					<span class="style1"><%=screen.getDataLabel("apsappgrade2")%></span>
					<%}else{%>
                    	
							<%=screen.getDataLabel("apsappgrade2")%>
					<%}%>
<%}%>                    
					</div></td>
					<td><div align="center">
					<%if(screen.getDataLabel("apsappgrade1").indexOf(screen.getDataLabel("apsgrade"))<0){%>
					<span class="style1"><%=screen.getDataLabel("apsappgrade1")%></span>
					<%}else{%>
						<%=screen.getDataLabel("apsappgrade1")%>
					<%}%>
					</div></td>
                    <td><div align="center"><%if(screen.getDataLabel("apsappgrade1").indexOf(screen.getDataLabel("apsgrade"))<0){%>
					<span class="style1"><%=screen.getDataLabel("apsgrade")%></span>
					<%}else{%>
						<%=screen.getDataLabel("apsgrade")%>
					<%}%>
					</div></td>
                    <td><div align="center"><%=screen.getDataLabel("apssumscore")%></div></td>
                    <td><%=screen.getDataLabel("v1memployee","fname")%></td>
                    <td><%=screen.getDataLabel("memployee","fname")%></td>
                    <td><div align="center"><a href="javascript:viewHis('<%=screen.getDataLabel("apsasydesc")%>','<%=screen.getDataLabel("apsassessy")%>');"><%
						if(!screen.getDataLabel("APSASYDESC").equals("")){
						out.print(screen.getDataLabel("APSASYDESC").split(",")[1]);
					}%></a></div></td>
                    <td><%if((screen.getDataLabel("APSAPPSTATUS1").equals("A"))&&(!screen.getDataLabel("APSAPPSTATUS2").equals("A"))){%>
					<%="<A  href=\"javascript:goASP700('"+screen.getDataLabel("APSID")+"','"+screen.getDataLabel("APSASSESSOR")+"','"+screen.getDataLabel("APSASSESSY")+"');\">"+screen.getDataLabel("simemp","fullname")+"</A>"%>
					<%}else{%>
					<%="<A  href=\"javascript:goReASP700('"+screen.getDataLabel("APSID")+"','"+screen.getDataLabel("APSASSESSOR")+"','"+screen.getDataLabel("APSASSESSY")+"');\">"+screen.getDataLabel("simemp","fullname")+"</A>"%>
					<%}%></td>
                    <td><%=screen.getDataLabel("mbu2","tdesc")%></td>
                    <td><%=screen.getDataLabel("mposition","tdesc")%></td>
                    <td>	<%
						workage=screen.getDataLabel("simemp","empworkages");
						String[] y = workage.split(" ");	
					%>
                    <div align="center"><%=y[0]+"/"+y[2] %></div></td>
                    <td><div align="center"><script language="javascript">calAge("<%=screen.getDataLabel("simemp","birthday")%>");</script></div></td>
                    <td><div align="center"><%=screen.getDataLabel("other1")%></div></td>
                    <td><div align="center"><%=screen.getDataLabel("other2")%></div></td>
                    <td><div align="center">
					<%if(screen.getDataLabel("other3").equals("Y")){%>
                    <span class="style1"><%=screen.getDataLabel("other3")%></span>
                    <%}else{%>
                    <%=screen.getDataLabel("other3")%>
                    <%}%>
                    </div></td>
					<td><div align="center"><%
						if(!screen.getDataLabel("apssyagreestat").equals("")){
						if(screen.getDataLabel("apssyagreestat").equals("0")){							
							out.println("<span class=\"style1\">"+screen.inq.getCurrentDbRecord().getSystemCode("apssyagreestat")+"</span>");						
						}else{
							if(screen.getDataLabel("apssyagreestat").equals("0")){								
								out.println("<span class=\"style2\">"+screen.inq.getCurrentDbRecord().getSystemCode("apssyagreestat")+"</span>");							
							}else{
								out.println(screen.inq.getCurrentDbRecord().getSystemCode("apssyagreestat"));
							}
						}
			
					}else{
						out.println("รอดำเนินการ");
					}
						%></div></td>
                  </tr>
                 <%
				 	if(!screen.inq.next()){
						end=false;
						nextRec = false;
					}
					cur_group= screen.inq.getString("emp_group");
				 	if(!cur_group.equals(old_group))nextRec = false;
				 } // while
				 %>
                          <tr>
                    <td colspan="5"><div align="right"><strong>จำนวนผู้ถูกประเมิน :&nbsp;&nbsp;<%=dc.format(to_per).replaceAll(".00", "")%>&nbsp;คน</strong></div></td>

                    <td colspan="3"><div align="right"><strong>รวมผล</strong></div></td>
                    <td colspan="10">
                      <div align="right"><strong>A&nbsp;=&nbsp;<%=dc.format((a_per/to_per)*100)%>&nbsp;%&nbsp;&nbsp;&nbsp;&nbsp;B&nbsp;=&nbsp;<%=dc.format((b_per/to_per)*100)%>&nbsp;%&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;=&nbsp;<%=dc.format((c_per/to_per)*100)%>&nbsp;%&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:goCheck('<%=old_group%>','apsappgrade2');"><img src="../IMAGES/BUTTON/CHECK.gif" alt="" border="0"></a></div></td>
                    </tr>
                </table>
                <%			
					
				} // while
			}// if
				%>
<!--table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#666666" class="largest">
                	<tr>
                    <td width="25%"><div align="right"><strong>จำนวนผู้ถูกประเมินทั้งหมด :&nbsp;&nbsp;<%//=dc.format(to_per_t).replaceAll(".00", "")%></strong></div></td>                     
                     <td width="20%"><div align="right"><strong>รวมผลทั้งหมด</strong></div></td>
                     <td width="55%"><div align="center"><strong>A&nbsp;=&nbsp;<%//=dc.format((a_per_t/to_per_t)*100)%>&nbsp;%&nbsp;&nbsp;&nbsp;&nbsp;B&nbsp;=&nbsp;<%//=dc.format((b_per_t/to_per_t)*100)%>&nbsp;%&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;=&nbsp;<%//=dc.format((c_per_t/to_per_t)*100)%>&nbsp;%&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
                    </tr>
                   </table-->
                  <%		}// if%></td>
              </tr>
            </table>
            <% if((ck.chkNullString(request.getParameter("__shown"),"").equals("1"))&&(recCount>0)){%>
<div align="center">								
								<a href="#" onClick="checkAll()"><img src="../IMAGES/BUTTON/SELECTALL.gif" border="0"></a>&nbsp;&nbsp;
								    <a href="#" onClick="decheckAll()"><img src="../IMAGES/BUTTON/DESELECTALL.gif" border="0"></a>&nbsp;&nbsp;
								    <a href="javascript:goConfirm1();"><img src="../IMAGES/BUTTON/CONFIRM.gif" border="0"></a>&nbsp;&nbsp;
								    <a href="javascript:goReturn();"><img src="../IMAGES/BUTTON/ROUTE_BACK.gif" border="0"></a></div>
        </div> <%}%></td> 
      </tr>
      <tr bordercolor="0069B3">
        <td  class="bottom"></td>
      </tr>
    </table>
  </div>
    	  <input type="hidden" name="__gochk" value="">
	  <%
	  if(!ck.chkNullString(request.getParameter("__gochk")).equals("")){	  	
		  String[]   gochk = ck.chkNullString(request.getParameter("__gochk")).split(":");

			  %>
			  <script language="javascript">goCheck1('<%=gochk[0]%>','<%=gochk[1]%>');</script>
	  <%}%>
 </form>
</body>
</html>