<%@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_1" class="com.csc.library.system.Task" scope="page" />
<%AS004_1.setChannel(request, response);%>
<%HelpEntry screen = (HelpEntry) AS004_1.process("HelpEntry","AS004_1_HR");%>

<%	CheckNull ck = new CheckNull(); 
  //       screen.process(); 
String employeeid=screen.getUProfile().get("employeeid");
String fullname=screen.getUProfile().get("fullname");
int  total_c=0;
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,sgro;
sbu1=ck.chkNullString(request.getParameter("__bu1"),"");
sbu2=ck.chkNullString(request.getParameter("__bu2"),"");
sbu3=ck.chkNullString(request.getParameter("__bu3"),"");
sgro=ck.chkNullString(request.getParameter("__gro"),"");
String filter = "";
String 	namelist="" ;
String data_namelist="";
String 	groupName="" ;
String 	groupArr="" ;
if(!sbu1.equals(""))filter =" and bu1='"+sbu1+"'";

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

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

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

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 apsassessor='"+employeeid+"' AND apsstatus !='A'");
total_c = screen.inq.recCount();
screen.inq.setFilter(dateExp+" AND astid='AP10' AND apsassessor='"+employeeid+"'"+filter);
if(!ck.chkNullString(request.getParameter("__orderBy"),"").equals("")){
	screen.inq.setOrderBy(request.getParameter("__orderBy"));
}else{
	screen.inq.setOrderBy("emp_group,apsstatus,apssumscore DESC,cast(APSASSDESC as int)");
}
((Simtapstran_kkb)screen.inq.getCurrentDbRecord()).approveConfirm();	
 String desc ="tdesc";
 if(!screen.getUProfile().get("lang").equals("tha"))desc="edesc";
 DataSet dsBu1 = new DataSet("Select Distinct APSASSESSOR,BU1 ,MBU1.TDESC AS TDESC, MBU1.EDESC AS EDESC from TAPSTRAN , MBU1 where  "+dateExp+" and TAPSTRAN.astid='AP10' and TAPSTRAN.bu1=MBU1.bu1id and  APSASSESSOR='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
dsBu1.initConnection(screen.getUProfile());

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

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


//EDESC from TAPSTRAN, MJOBGROUP, MJOBCODE  where  "+dateExp+" and TAPSTRAN.astid='AP10' and  TAPSTRAN.JOB=MJOBCODE.JOBCODEID AND  MJOBCODE.JOBGROUP=MJOBGROUP.JOBGROUPID  AND   APSASSESSOR='"+employeeid+"'",(String)screen.getUProfile().get("dbname"),"Tapstran");
//dsGro.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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
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";	
	 else if(inputName=="__bu3" )
		helpReturn="__bu3:bu3id,MBU3@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){
		__shown.value="1";
		submit();
	}
}
function goConfirm(){
	with(document.cscform){
		__status.value="A";
		__cmd.value="ack";		
		submit();
	
	}
}

function goConfirm2(){

	var returnVal = true;
	with(document.cscform){
		for(i=0;i<elements.length;i++){		
			if(elements[i].name.indexOf("__ch")>=0){	
					if(elements[i].checked){						
						var lin = document.getElementById(elements[i].lin);
						lin.disabled="";
						elements[i].checked=false;
					}else{
						var stat = document.getElementById(elements[i].stat);
						var lin = document.getElementById(elements[i].lin);
						stat.disabled='disabled';
						lin.disabled='disabled';
					}					
			}
		}
	}
	
	goConfirm();	
}
function goConfirm1(){
	
	var groupArr = document.getElementById("groupArr");
	var arr = groupArr.value.split(",");
	var returnVal = true;
	var count=0;
	for(i=0;i<arr.length;i++){

		var objSelected = document.getElementById(arr[i]);						if((objSelected.options[objSelected.selectedIndex].value=="")||((objSelected.selectedIndex==0))){
			alert("กรุณาเรียงลำดับให้ครบก่อน");
			returnVal = false;
			break;
		}else{
			count++;
			//alert(objSelected.options[objSelected.selectedIndex].value);
		}
	}
	if(returnVal){
		if(count<document.cscform.__total_c.value){
			alert("ยังเหลือพนักงานที่ต้องประเมินอีก "+(document.cscform.__total_c.value-count)+" คน");
		}
		//alert("goConfirm()");
		goConfirm2();
	}
}
function goCheck(emp_group,fieldName){
		with(document.cscform){
			var param="AS004_2C1.jsp?__emp_group="+emp_group+"&__fieldName="+fieldName+"&__bu1="+__bu1.value+"&__bu2="+__bu2.value;	
			win = window.open(param,"AS004_2C1","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=1&bu1="+__bu1.value+"&bu2="+__bu2.value+"&isread=0&emp="+__employeeid.value+"&order="+__orderBy.value+"&bu3="+__bu3.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=1&bu1="+__bu1.value+"&bu2="+__bu2.value+"&isread=1&emp="+__employeeid.value+"&order="+__orderBy.value+"&bu3="+__bu3.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 chkSelected(Obj){
	var arrSplit = Obj.name.split(":");
	var groupName = arrSplit[4];
	var elGroupName = document.getElementById(groupName);
	var arr = elGroupName.value.split(",");
	var elArr = new Array();
	var numArr = new Array();
	var num = 0;
	var valReturn = true;
	if((Obj.status=='W')||(Obj.status=='R')){
		for(i=0;i<arr.length;i++){		
			elArr[i] = arr[i].replace("'","").replace("'","");
		}
		for(i=0;i<elArr.length;i++){
			var objSelected = document.getElementById(elArr[i]);
			
			if(Obj.name!=objSelected.name){
				if(Obj.value==objSelected.options[objSelected.selectedIndex].value&&Obj.selectedIndex!=0){
					alert("ลำดับนี้ถูกเลือกแล้ว");
					Obj.selectedIndex=0;				
					break;
				}
			}
		}
	}else{
			if(Obj.status!='A'){
				alert("กรุณาประเมินผลในแบบฟอร์มก่อน โดยคลิกที่ชื่อพนักงาน");
				Obj.selectedIndex=0;		
			}
		}
}
function setOrder(field){
		var groupArr = document.getElementById("groupArr");
		if(groupArr!=null){
				var arr = groupArr.value.split(",");
				for(i=0;i<arr.length;i++){
						var objSelected = document.getElementById(arr[i]);
						var arrSel =objSelected.options[objSelected.selectedIndex].value.split(":");
						objSelected.options[objSelected.selectedIndex].value=arrSel[0]+":"+arrSel[1]+":"+arrSel[2]+":"+objSelected.status;
				}
				with(document.cscform){
					__orderBy.value="EMP_GROUP,"+field;
					__status.value="W";
					__cmd.value="ack";		
					fixSearch();
				}
		}
}
function chk(inbo){
	with(document.cscform){
			var group = inbo.value.split(":");
			for(i=0;i<elements.length;i++){	
				if(elements[i].name.indexOf('__ch')>=0){ 
					var eleGroup=elements[i].value.split(":");
					if(group[1]==eleGroup[1]){
						elements[i].checked=inbo.checked;
						if(inbo.checked){							
							//alert(document.getElementById(elements[i].stat));
							var stat = document.getElementById(elements[i].stat);
							var lin = document.getElementById(elements[i].lin);
							var tmp =lin.options[lin.selectedIndex].value.split(':');
							var tmp =lin.options[lin.selectedIndex].value.split(':');
							var data='';
							for(l=0;l<tmp.length;l++){
								if(l==tmp.length-1){
									data=data+stat.options[stat.selectedIndex].value;
								}else{
									data=data+tmp[l]+':';
								}							
							}
							lin.options[lin.selectedIndex].value=data;
							stat.disabled='disabled';
							lin.disabled='disabled';
						//	alert(lin.options[lin.selectedIndex].value);
						}else{
							var stat = document.getElementById(elements[i].stat);
							var lin = document.getElementById(elements[i].lin);
							stat.disabled='';
							lin.disabled='';
						}
					}
				}
			}
	}
}

function chgStatus(obj){
	with(document.cscform){
		var objName= obj.name.split(':');
		for(i=0;i<elements.length;i++){		
			var eleName=elements[i].name.split(':');
			if((elements[i].name.indexOf("__apsstatus")>=0)&&(eleName[4]==objName[4])){				
					elements[i].selectedIndex=obj.selectedIndex;
					elements[i].options[elements[i].selectedIndex].value=obj.options[obj.selectedIndex].value;
				
			}
		}			
	}
}

function genOpt(Obj){
	var arrSplit = Obj.name.split(":");
	var groupName = arrSplit[4];
	var elGroupName = document.getElementById(groupName);
	var arr = elGroupName.value.split(",");
	var elArr = new Array();
	var numArr = new Array();
	var num = 0;
	var valReturn = true;
	var chk = false;
	var data="";
		for(t=1;t<=arr.length;t++){
			chk =false; 
				for(i=0;i<arr.length;i++){		
					elArr[i] = arr[i].replace("'","").replace("'","");
					var objSelected = document.getElementById(elArr[i]);
					if((objSelected.options[objSelected.selectedIndex].value==( "apsassdesc:"+t+":apsstatus:A"))&&(Obj.name !=objSelected.name)){
							chk =true; 
							break;
					}
				}
				if(!chk){
					numArr[num++]=t;
				}
		}
	//	alert(numArr);
		data=Obj.options[Obj.selectedIndex].value;
		Obj.options.length = 1;
		var selObj=0;

		for (j = 1; j<= num; j++) {
				var 	optionObj = document.createElement("option");
				optionObj.value = "apsassdesc:"+numArr[j-1]+":apsstatus:A";
				optionObj.innerHTML = numArr[j-1];
		//		alert( "apsassdesc:"+numArr[j-1]+":apsstatus:A"+'======='+data);
				if(("apsassdesc:"+numArr[j-1]+":apsstatus:A")==data){selObj=j;
				}
				Obj.appendChild(optionObj);
		}  //End For j

		document.getElementById(Obj.name).appendChild(Obj);
		Obj.selectedIndex=selObj;

/*		for(i=0;i<elArr.length;i++){
			var objSelected = document.getElementById(elArr[i]);
			

				if(Obj.value==objSelected.options[objSelected.selectedIndex].value&&Obj.value!=0){
				
				}
			
		} */


}

function genOpt1(Obj){

	var arrSplit = Obj.name.split(":");
	var groupName = arrSplit[4];
	var elGroupName = document.getElementById(groupName);
	var arr = elGroupName.value.split(",");
	var elArr = new Array();
	var numArr = new Array();
	var num = 0;
	var valReturn = true;
	var chk = false;
	var data="";
		for(t=1;t<=arr.length;t++){
			chk =false; 
				for(i=0;i<arr.length;i++){		
					elArr[i] = arr[i].replace("'","").replace("'","");
					var objSelected = document.getElementById(elArr[i]);
					if((objSelected.options[objSelected.selectedIndex].value==( "apsassdesc:"+t+":apsstatus:A"))&&(Obj.name !=objSelected.name)){
							chk =true; 
							break;
					} 
				}
				if(!chk){
					numArr[num++]=t;
				}
		}

		data=Obj.options[Obj.selectedIndex].value;

		Obj.options.length = 1;
		var selObj=0;

		for (j = 1; j<= num; j++) {

Obj.options[Obj.options.length]=new Option(numArr[j-1],"apsassdesc:"+numArr[j-1]+":apsstatus:A");

				if(("apsassdesc:"+numArr[j-1]+":apsstatus:A")==data){
					selObj=j;
				}

		}  //End For j

		Obj.selectedIndex=selObj;
	Obj.options[Obj.selectedIndex].selected = true;


}
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #339933}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif')">
<form name="cscform" method="post" action="AS004_1_HR.jsp" >
  

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

<%=screen.InitialVariable()%>

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

<input type="hidden"name="__screen"  value="AS004_1_HR">
  <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,apsstatus,apssumscore DESC,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="APSSTATUS">
  <input type="hidden" name="__returnfield" value="">
  <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">
    <table  cellpadding="0"  cellspacing="0" class="large">
      <tr>
        <td  class="header">AS004_1,ประเมินผลระดับที่ 1
        
        &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="273">&nbsp;<strong><%=fullname%></strong></td>
                <td width="289"><strong>จำนวนผู้ถูกประเมิน :&nbsp;&nbsp;<%=screen.inq.recCount()%></strong></td>
                <td width="186"><!--<strong>ประจำปี :</strong>&nbsp;&nbsp;<strong><%=screen.getDataLabel("TAPSTRAN0","APSPERIODSTART")%></strong> --></td>
                <td width="100">&nbsp;</td>
      </tr>
              <tr>
                <td height="24"><div align="right"><%=screen.getLabel("bu1")%>&nbsp;</div></td>
                <td colspan="4">             <select name="__bu1" id="select">
                    <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;&nbsp;&nbsp;<a href="javascript:fixSearch();"><img src="../IMAGES/BUTTON/SEARCH.gif" border="0" align="absmiddle"></a></td>
              </tr>
              <tr>
                <td><div align="right"><%=screen.getLabel("bu2")%>&nbsp;</div></td>
                <td colspan="4">
                  <select name="__bu2" id="select">
                    <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"><script language="javascript">swapLang('BU3');</script>&nbsp;</div></td>
                <td colspan="4">
                  <select name="__bu3" id="select">
                    <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">
                  <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 width="87">&nbsp;</td>
                <td colspan="4"><INPUT TYPE="Button" name='xx' id='xx'  onClick="javaScript:setOrder('cast(APSASSDESC as int),APSSUMSCORE DESC')"  value="เรียงลำดับ">&nbsp;&nbsp;&nbsp;<!-- <INPUT TYPE="reset" name='xx1' id='xx1'  value="Clear"> --></td>
              </tr>
              <tr>
                <td width="87">&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.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");
			String A,W,R, _0;
			if(recCount>0){
				nextRec=true;
				end=true;
				int rowCount = 0;
				while(end){
					rowCount++;
					
		  %>      
                  <%//=screen.getDataLabel("apssumscore")%>
                  <table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#666666" class="largest">
                <tr>
                    <td colspan="13"><strong><script language="javascript">swapLang('Employee Group Code');</script>
                      &nbsp;&nbsp;:&nbsp;<%=screen.getDataLabel("mgroup","tdesc")%></strong></td>
                    </tr>
                  <tr>
                    <!--td class="title1" width="0"><div align="center">
                        <script language="javascript">swapLang('Select');</script>
                     </div></td-->
                   <td class="title1" width="21"> ยืนยัน</td>                     
                    <td class="title1" width="131"><div align="center">
                        <script language="javascript">swapLang('Status');</script>
                    </div></td>
 
                    <td class="title1" width="52"><div align="center">
                    <script language="javascript">swapLang('Sequencing');</script>
                    </div></td>
                    <td class="title1" width="35"><div align="center">
                        <script language="javascript">swapLang('Score');</script>
                    </div></td>
                    <td class="title1" width="139"><div align="center">
                        <script language="javascript">swapLang('assessy');</script>
                    </div></td>
                    <td class="title1" width="120"><div align="center">
                        <script language="javascript">swapLang('division');</script>
                    </div></td>
                    <td class="title1" width="108"><div align="center">
                        <script language="javascript">swapLang('position');</script>
                    </div></td>
                    <td class="title1" width="42"><div align="center">
                        <script language="javascript">swapLang('Service Year');</script>
                    </div></td>
					 <td class="title1" width="27"><div align="center">
						<script language="javascript">swapLang('Age');</script>
                    </div></td>
                    <td class="title1" width="39"><div align="center">
                        <script language="javascript">swapLang('WorkHour Day');</script>
                    </div></td>
                    <td class="title1" width="38"><div align="center">
                        <script language="javascript">swapLang('V2U');</script>
                    </div></td>
					<td class="title1" width="79"><div align="center">
                     
                   วินัย </div></td>    
					<%//if(screen.getDataLabel("apsappstatus2").equals("A")){%>
					    <td class="title1"><div align="center">สถานะผู้ถูกประเมิน</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;
				int countRow = 0;
			  	while(nextRec){
					countRow++;
					to_per++;
					to_per_t++;
					
					if(screen.inq.getString("apsgrade").indexOf("A")>=0){
						a_per++;
						a_per_t++;
					}else{
						if(screen.inq.getString("apsgrade").indexOf("B")>=0){
							b_per++;
							b_per_t++;
						}else{
							if(screen.inq.getString("apsgrade").indexOf("C")>=0){
								c_per++;
								c_per_t++;
							}
						}
					}
			  %>
                  <tr>
                    <!--td>&nbsp;</td-->                  
                    <td width="0">                    
<%//if(screen.getDataLabel("APSSTATUS").equals("R")||screen.getDataLabel("APSSTATUS").equals("W")){%>                                       
                      <input type="checkbox" name="__ch<%=(++running)%>:APSID:EMP_GROUP:APSASSESSOR:APSASSESSY:APSSTATUS" value="<%=screen.getDataLabel("APSID")+":"+screen.getDataLabel("EMP_GROUP")+":"+screen.getDataLabel("APSASSESSOR")+":"+screen.getDataLabel("APSASSESSY")+":"+screen.getDataLabel("APSSTATUS")%>" id="__ch<%=running++%>:APSID:EMP_GROUP:APSASSESSOR:APSASSESSY:APSSTATUS" align="absmiddle" stat='__apsstatus:<%=screen.getDataLabel("mbu1","bu1id")+":"+screen.getDataLabel("mbu2","bu2id")+":"+screen.getDataLabel("mbu3","bu3id")+":"+screen.inq.getString("emp_group")+":"+screen.inq.getString("APSASSESSY")+":"+screen.getDataLabel("runno") %>'   lin='__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") %>'   onChange="javaScript:chk(this);"> 
					
  
                    <%//}else{%>
                    &nbsp;
                    <%//}%>               
                      </td>
                    <td><div align="center">
                    

					<%//if((screen.getDataLabel("apsstatus").equals(""))||(screen.getDataLabel("apsstatus").equals("0"))||(screen.getDataLabel("apsstatus").equals("R"))){%>
			
					 <!--span class="style1"><%//=screen.inq.getCurrentDbRecord().getSystemCode("apsstatus")%></span-->
					<%//}else{
					//	if(screen.getDataLabel("apsstatus").equals("A")){%>
						 <!--span class="style2"><%//=screen.inq.getCurrentDbRecord().getSystemCode("apsstatus")%></span-->
						 <%//}else{%>
							<%//=screen.inq.getCurrentDbRecord().getSystemCode("apsstatus")%>
						<%//}
				//	 }
					 A=W=R=_0="";
					 	if(screen.getDataLabel("apsstatus").equals("A")){
							A="selected";
						}else
							if(screen.getDataLabel("apsstatus").equals("R")){
								R="selected";
					 }else
					 	if(screen.getDataLabel("apsstatus").equals("W")){
								W="selected";
						}else{
								_0="selected";
						}
						%>
							</div>
					  <select id="__apsstatus:<%=screen.getDataLabel("mbu1","bu1id")+":"+screen.getDataLabel("mbu2","bu2id")+":"+screen.getDataLabel("mbu3","bu3id")+":"+screen.inq.getString("emp_group")+":"+screen.getDataLabel("runno")%>" name="__apsstatus:<%=screen.getDataLabel("mbu1","bu1id")+":"+screen.getDataLabel("mbu2","bu2id")+":"+screen.getDataLabel("mbu3","bu3id")+":"+screen.inq.getString("emp_group")+":"+screen.inq.getString("APSASSESSY")+":"+screen.getDataLabel("runno")%>"  onchange='javaScript:chgStatus(this);'  status='<%=screen.getDataLabel("apsstatus")%>'>
					    <option value='A'  <%=A%>>ประเมินแล้ว</option>
					    <option value='W' <%=W%>>รอยืนยัน</option>
					    <option value='R'   <%=R%> >ต้องประเมินใหม่</option>
					    <option value='0'   <%=_0%>>ยังไม่ประเมิน</option>                        
                      </select></td>

                    <td><div align="center">					
					<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.inq.getString("APSASSESSY")+":"+screen.getDataLabel("runno") %>" status='<%=screen.getDataLabel("apsstatus")%>' >	
					<option value=""></option>
					</select>
					<%
					
						namelist += ",'__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")+"'";				
						data_namelist+=",'"+screen.getDataLabel("APSASSDESC")+"'";	
						groupArr+=",__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");	

						groupName = screen.inq.getString("emp_group");
						
					%>
					
					</div></td>
                    <td><div align="center"><%=screen.getDataLabel("apssumscore")%></div></td>
                    <td><%if(!screen.getDataLabel("APSSTATUS").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>
					<%
						workage=screen.getDataLabel("simemp","empworkages");
						String[] y = workage.split(" ");	
					%>
                    <td><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>
					<%//if(screen.getDataLabel("apsappstatus2").equals("A")){%>
					    <td><div align="center"><%
				//		if(((DbInquiry)screen.inq.getCurrentDbRecord().getChild("tassessy_agreement")).foundData()){
				//		out.println(((DbInquiry)screen.inq.getCurrentDbRecord().getChild("tassessy_agreement")).getCurrentDbRecord().getSystemCode("agree"));
			//		}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;
					
					
				 } // end while
				 %>
                         <tr>
                    <td colspan="4"><div align="right"><strong>จำนวนผู้ถูกประเมิน :&nbsp;&nbsp;<%=dc.format(to_per).replaceAll(".00", "")%>&nbsp;คน</strong></div>					</td>
                    <td colspan="9">&nbsp;
					
					<script language="javascript">
						var arr = new Array(<%=(namelist.length()>0)?namelist.substring(1):""%>);
						var data_arr = new Array(<%=(data_namelist.length()>0)?data_namelist.substring(1):""%>);
						var arrSize = arr.length;
						
						for(i=0;i<arrSize;i++){						
							var 	selectObj = document.getElementById(arr[i]);
									selectObj.onchange = function(){chkSelected(this);	}									
									selectObj.onblur=function(){genOpt(this);}
									selectObj.onmouseover=function(){genOpt1(this);}						
								for (j = 1; j<= arrSize; j++) {
									var 	optionObj = document.createElement("option");
											optionObj.value = "apsassdesc:"+j+":apsstatus:A";
											optionObj.innerHTML = j;
											selectObj.appendChild(optionObj);
								}  //End For j
								if(data_arr[i]!=''){
								//	alert(data_arr[i]);
									selectObj.selectedIndex= +data_arr[i];
							//		selectObj.disabled="disabled";
								}
							selectObj.options[0].value="apsassdesc:  :apsstatus:A";
							document.getElementById(arr[i]).appendChild(selectObj);
						}//End For i
						
						

					</script>
					
					<input type="hidden" name="<%=groupName%>" id="<%=groupName%>" value="<%=(namelist.length()>0)?namelist.substring(1):""%>">
					
					
					<% namelist = "";%>
					<% data_namelist = "";%>					</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 colspan="2">&nbsp;
					 <input type="hidden" name="groupArr" id="groupArr" value="<%//=groupArr.substring(1)%>">
					 </td>

                    </tr-->
					<input type="hidden" name="groupArr" id="groupArr" value="<%=(groupArr.length()>0)?groupArr.substring(1):""%>">
                   </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/SAVE.gif" border="0"></a></div>
        </div> <%}%></td> 
      </tr>
      <tr bordercolor="0069B3">
        <td  class="bottom"></td>
      </tr>
    </table>
  </div>
 </form>
</body>
</html>
