<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<jsp:useBean id="TAU124_NEW_KKB" class="com.csc.library.system.Task" scope="page"/>
<%
	TAU124_NEW_KKB.setChannel(request ,response);
   	ProcessEntry screen=(ProcessEntry)TAU124_NEW_KKB.process("ProcessEntry","Process");
   	screen.process();
%>
<html ng-app="myHR">
<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 src="../JS/angular-1.3.15/angular.js" type="text/javascript"></script>	
<script src="../JS/ANGULAR/SCREEN_ANGULAR.js" type="text/javascript"></script>
<script language="javascript" src='../JS/DATEINPUT.js'></script>
<script language="javascript" src='../JS/VIEWCALENDAR.js'></script>
<script language="javascript" src='./JS/PROCESS.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 setCondition_Nuiss(){
	var obj_bu1List=document.cscform.bu1List;	
    for(i=obj_bu1List.length;i >0;i--){
		document.cscform.__condition$bu1Select.value+=obj_bu1List.options[i-1].value+",";			
	}
	var obj_bu2List=document.cscform.bu2List;	
    for(i=obj_bu2List.length;i >0;i--){
		document.cscform.__condition$bu2Select.value+=obj_bu2List.options[i-1].value+",";
	}
	var obj_bu3List=document.cscform.bu3List;	
    for(i=obj_bu3List.length;i >0;i--){
		document.cscform.__condition$bu3Select.value+=obj_bu3List.options[i-1].value+",";
	}
	var obj_bu4List=document.cscform.bu4List;	
    for(i=obj_bu4List.length;i >0;i--){
		document.cscform.__condition$bu4Select.value+=obj_bu4List.options[i-1].value+",";
	}
	/*	var obj_bu5List=document.cscform.bu5List;	
    for(i=obj_bu5List.length;i >0;i--){
		document.cscform.__condition$bu5Select.value+=obj_bu5List.options[i-1].value+",";
	}*/
	var obj_employeeList=document.cscform.employeeList;	
    for(i=obj_employeeList.length;i >0;i--){
		document.cscform.__condition$employeeSelect.value+=obj_employeeList.options[i-1].value+",";
	}
	var obj_positionList=document.cscform.positionList;	
    for(i=obj_positionList.length;i >0;i--){
		document.cscform.__condition$positionSelect.value+=obj_positionList.options[i-1].value+",";
	}
	/*	var obj_branchList=document.cscform.branchList;	
    for(i=obj_branchList.length;i >0;i--){
		document.cscform.__condition$branchSelect.value+=obj_branchList.options[i-1].value+",";
	}*/
	var obj_salatypeList=document.cscform.salatypeList;	
    for(i=obj_salatypeList.length;i >0;i--){
		document.cscform.__condition$salatypeSelect.value+=obj_salatypeList.options[i-1].value+",";
	}
	/*	var obj_workareaList=document.cscform.workareaList;	
    for(i=obj_workareaList.length;i >0;i--){
		document.cscform.__condition$workareaSelect.value+=obj_workareaList.options[i-1].value+",";
	}
	var obj_emp_levelList=document.cscform.emp_levelList;	
    for(i=obj_emp_levelList.length;i >0;i--){
		document.cscform.__condition$emp_levelSelect.value+=obj_emp_levelList.options[i-1].value+",";
	}*/
	var obj_time0List=document.cscform.time0List;	
    for(i=obj_time0List.length;i >0;i--){
		document.cscform.__condition$time0Select.value+=obj_time0List.options[i-1].value+",";
	}
 
	with(document.cscform){
		for(i=0;i<elements.length;i++){
			if(elements[i].type=="checkbox"){
				if (elements[i].checked){
					elements[i].value="1";
				} else elements[i].value="0";
		   	}
		}
	}	
			
	//check (empStart-empEnd)+employeeSelect
	if ((document.cscform.empStart.value.length>0)&&(document.cscform.empEnd.value.length>0)){
		document.cscform.__condition$employeeBetween.value = "(memployee.employeeid between '"+document.cscform.empStart.value+"' and '"+document.cscform.empEnd.value+"')";
	} else if ((document.cscform.empStart.value.length>0)&&(document.cscform.empEnd.value.length==0)){
		document.cscform.__condition$employeeBetween.value = "(memployee.employeeid between '"+document.cscform.empStart.value+"' and '"+document.cscform.empStart.value+"')";
	} else if ((document.cscform.empStart.value.length==0)&&(document.cscform.empEnd.value.length>0)){
		document.cscform.__condition$employeeBetween.value = "(memployee.employeeid between '"+document.cscform.empEnd.value+"' and '"+document.cscform.empEnd.value+"')";
	}	

	//check during year flag
	if(document.cscform.__condition$isCalculateV0Flag.checked == true){
		document.cscform.__condition$isCalculateV0.value = "true";
	}else{
		document.cscform.__condition$isCalculateV0.value = "false";
	}
}

function process(pValue) {
		clearCondition();
		setCondition_Nuiss();
		if(chkCondition()){
			with(document.cscform){
				if (pValue=='Calulate Vacation') {
					__condition$cmdValue.value = "process";
					__ptype.value="TA19";
					__prclass.value="CalculateVacation_New";
				} 
				
				if(empStart.value <= empEnd.value){
					bCon=confirm(MyCode[168]+pValue);
					if (bCon==true)	{
						__cmd .value = "save";							
						submit();
					}//end if bCon
				}else alert(MyCode[101]);
			}
		}
	}
 

//-->
</script>
</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="">


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

<%=screen.InitialVariable()%>

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

<input type="hidden" name="__screen"  value="TAU124">
	<input type="hidden" name="__fixCon"  value="">
	<input type="hidden" name="__cmd"  value="">
	<input type="hidden" name="__help"  value="">
	<input type="hidden" name="__user" value="<%=screen.getUProfile().getUserId()%>">
	<input type="hidden" name="__companyid" value='<%=screen.getUProfile().get("companyid")%>'>
	<input type="hidden" name="__tname" value="ระบบเวลาการทำงาน">
	<input type="hidden" name="__ename" value="Time Attendance">
	<input type="hidden" name="__ptype" value="">
	<input type="hidden" name="__prclass" value="Time_process">
	<input type="hidden" name="__calendar" value="">
	<script language="javascript">getInputFormatDate();</script>
	<input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>">		
	<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
  	<script language="javascript">initToolTips();</script>
	<input type="hidden" name="__condition$employeeProcess" value='<%=screen.getUProfile().get("employeeid")%>'>
	<input type="hidden" name="__condition$employeeBetween" value="">
	<input type="hidden" name="__condition$employeeSelect" value="">
	<input type="hidden" name="__condition$positionSelect" value="">
	<input type="hidden" name="__condition$bu1Select" value="">
	<input type="hidden" name="__condition$bu2Select" value="">
	<input type="hidden" name="__condition$bu3Select" value="">
	<input type="hidden" name="__condition$bu4Select" value="">
	<input type="hidden" name="__condition$bu5Select" value="">
	<input type="hidden" name="__condition$branchSelect" value="">
	<input type="hidden" name="__condition$salatypeSelect" value="">
	<input type="hidden" name="__condition$workareaSelect" value="">
	<input type="hidden" name="__condition$emp_levelSelect" value="">
	<input type="hidden" name="__condition$time0Select" value="">
	<input type="hidden" name="__condition$cmdValue" value="">
	<input type="hidden" name="__condition$isManualProcess" value="1">
	<input type="hidden" name="__condition$isCalculateV0" value="0">
 	<br>
  	<div align="center">
    <table  cellpadding="0"  cellspacing="0">
    <tr >
    	<td  class="header" colspan="4"> TAU124,&nbsp;<span swlang code="SW012356">Calulate Vacation</span>&nbsp;</td>
   	</tr>
	<tr>
    	<td colspan="4" class="blankspace"  ></td>
    </tr>
	<tr>
		<td colspan="4" >
		  <div align="center">
					
				  <%=(screen.getUProfile().get("lang").equals("tha"))?"โดยคำนวณสิทธิใช้ไปตั้งแต่":"Calculate vacation for begining budget year"%>
				  <input type="text" name="__condition$startDate" size="10" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,__condition$endDate)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันเริ่มต้น(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onClick="viewCal('__condition$startDate')"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image1" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;-&nbsp;<script language="javascript">swapLang("End Date");</script>&nbsp;
		  	<input type="text" name="__condition$endDate" size="10" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(__condition$startDate,this)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันสิ้นสุด(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onClick="viewCal('__condition$endDate')"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
			</div>
		</td>
	</tr>
	<tr>
    	<td colspan="4" class="blankspace"  ></td>
    </tr>
	<tr>
		<td colspan="4" >
		  <div align="center">
			<%=(screen.getUProfile().get("lang").equals("tha"))?"วันที่คำนวณสิทธิ":"Calculate vacation date"%>
			<input type="text" name="__condition$caldate" size="10" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate(this,__condition$endDate)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันเริ่มต้น(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)" onClick="viewCal('__condition$startDate')"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image1" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;&nbsp;
			<INPUT TYPE="checkbox" NAME="__condition$isCalculateV0Flag" value="1"><%=(screen.getUProfile().get("lang").equals("tha"))?"คำนวณสิทธิพักร้อนยกมา ":"Calculate vacation"%></div>&nbsp;&nbsp;&nbsp;&nbsp;
		</td>
	</tr>	

	<tr>
		<td colspan="4">
			<div align="center"><script language="javascript">swapLang("Employee ID");</script>&nbsp;&nbsp;
			<input type="text" name="empStart" size="15">
			<a href="javascript:goHelp('MEMPLOYEEHELP','empStart','')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image3" width="20" height="20" border="0" align="absmiddle"></a>
			&nbsp;&nbsp;-&nbsp;&nbsp;
			<input type="text" name="empEnd" size="15">
			<a href="javascript:goHelp('MEMPLOYEEHELP','empEnd','')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image4" width="20" height="20" border="0" align="absmiddle"></a>
			</div>
		</td>	
	</tr>
    <tr >
    	<td colspan="4">
			<table width="100%" border="0">
			<tr>
            	<td colspan="2" class="blankspace"  ></td>
            </tr>
			<tr>
        		<td width="50%" align="center"><script language="javascript">swapLang("Employee");</script>&nbsp;<input type="button" name="__employeeid" value="click" onClick="javascript:goHelp('MEMPLOYEEHELP','employee','employeeList')"/></td>
                <td width="50%" align="center"><script language="javascript">swapLang("Position");</script>&nbsp;<input type="button" name="__positionid" value="click" onClick="javascript:goHelp('MPOSITIONHELP','position','positionList')"/></td>
         	</tr>
     		<tr>
            	<td align="center">
					<select name="employeeList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.employeeList);">					
               	    </select>
				</td>
				<td align="center">
					<select name="positionList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.positionList);">					
               	    </select>
				</td>
            </tr>
            <tr>
            	<td colspan="2" class="blankspace"  ></td>
            </tr>
			<%
				DbInquiry memployee = new InitialInquiry(screen.getUProfile()).getDbInquiry("memployee");
				memployee.setColumn("employeeid,companyid,bu1,bu2,bu3,bu4,bu5");
				memployee.refresh();

				DbRecord mbu = memployee.getCurrentDbRecord();
			%>
            <tr>
        		<td width="50%" align="center"><%=mbu.getField("bu1").getDescription()%>&nbsp;<input type="button" name="__bu1id" value="click" onClick="javascript:goHelp('MBU1HELP','bu1','bu1List')"/></td>
                <td width="50%" align="center"><%=mbu.getField("bu2").getDescription()%>&nbsp;<input type="button" name="__bu2id" value="click" onClick="javascript:goHelp('MBU2HELP','bu2','bu2List')"/></td>
         	</tr>
     		<tr>
            	<td align="center">
					<select name="bu1List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu1List);">
               	    </select>
				</td>
				<td align="center">
					<select name="bu2List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu2List);">>					
               	    </select>
				</td>
            <tr>                          
            <td colspan="2" class="blankspace"  ></td>
            </tr> 			
            <tr>
        		<td width="50%" align="center"><%=mbu.getField("bu3").getDescription()%>&nbsp;<input type="button" name="__bu3id" value="click" onClick="javascript:goHelp('MBU3HELP','bu3','bu3List')"/></td>
                <td width="50%" align="center"><%=mbu.getField("bu4").getDescription()%>&nbsp;<input type="button" name="__bu4id" value="click" onClick="javascript:goHelp('MBU4HELP','bu4','bu4List')"/></td>
         	</tr>
     		<tr>
            	<td align="center">
					<select name="bu3List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu3List);">
               	    </select>
				</td>
				<td align="center">
					<select name="bu4List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu4List);">
               	    </select>
				</td>
            <tr>            
			<tr>                          
            <td colspan="2" class="blankspace"  ></td>
            </tr> 			
            <tr>
        		<td width="50%" align="center"><%=mbu.getField("bu5").getDescription()%>&nbsp;<input type="button" name="__bu5id" value="click" onClick="javascript:goHelp('MBU5HELP','bu5','bu5List')"/></td>
              <td width="50%" align="center"><script language="javascript">swapLang("Branch");</script>&nbsp;
                <input type="button" name="__branchid" value="click" onClick="javascript:goHelp('MBRANCHHELP','branch','branchList')"/></td>
            </tr>
     		<tr>
            	<td align="center">
					<select name="bu5List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu5List);">
               	    </select>
				</td>
				<td align="center">
					<select name="branchList" size="20" multiple class="large" style="width:250; height:100"onDblClick="listDblClick(this.form.branchList);">
               	    </select>
				</td>
            <tr>                          
            <td colspan="2" class="blankspace"  ></td>
            </tr> 
			<tr>
				<td width="50%" align="center"><script language="javascript">swapLang("Employee Level");</script>&nbsp;<input type="button" name="__emp_levelid" value="click" onClick="javascript:goHelp('MLEVELHELP','emp_level','emp_levelList')"/></td>
        		<td width="50%" align="center"><script language="javascript">swapLang("Workarea");</script>&nbsp;<input type="button" name="__workareaid" value="click" onClick="javascript:goHelp('MWORKAREAHELP','workarea','workareaList')"/></td>
            </tr> 
     		<tr>
            	<td align="center">
					<select name="emp_levelList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.emp_levelList);">
                    </select>
				</td> 
			  	<td align="center">
					<select name="workareaList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.workareaList);">
              		</select>					
				</td>
			</tr>
			<tr>
				<td colspan="2" class="blankspace"  ></td>
            </tr> 
			<tr>
        		<td width="50%" align="center"><script language="javascript">swapLang("Salatype");</script>&nbsp;<input type="button" name="__salatypeid" value="click" onClick="javascript:goHelp('MSALATYPE0HELP','salatype','salatypeList')"/></td>
        		<td width="50%" align="center"><script language="javascript">swapLang("Time0");</script>&nbsp;<input type="button" name="__time0id" value="click" onClick="javascript:goHelp('MTIME0HELP','time0','time0List')"/></td>
         	</tr>			
			<tr> 
				<td align="center">
					<select name="salatypeList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.salatypeList);">
               	    </select>
				</td>					                        
           		<td align="center">
					<select name="time0List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.time0List);">
               	</select></td>
            </tr> 			
            <tr>
        		<td align="center" colspan="2"><script language="javascript">swapLang("Remark");</script></td>
         	</tr>
     		<tr>
            	<td align="center" colspan="2">
                  <textarea name="__remark" cols="70" rows="5"></textarea>
				</td>
            <tr>    
			<tr>                          
            	<td colspan="2" class="blankspace"></td>
            </tr> 

				<tr>
					<td  class="buttonline" colspan="7"><div align="center">
						<button type="button" class="btn btn-primary width100" swlang code="SW013173" onClick="process('Calulate Vacation');">PROCESS</button>
					</div>
					</td>
				</tr>
			 <tr>
              	<td colspan="2" class="blankspace"  ></td>
            </tr>
          	</table> 
		</td>
    </tr>
  	<tr>
		<td  class="bottom" colspan="2"></td>
    </tr>
	</table>
  </div>
</form>
</body>
</html>