<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.*,java.io.*"%>
<%@page import="com.csc.library.util.download.*"%>
<%@page import="com.csc.library.util.ManageDocument"%>
<%@page import="com.csc.library.databean.util.FileUtil"%>
<%@page import="com.csc.library.approve.*,com.csc.library.databean.*"%>
<%@page import="com.csc.library.entry.*,com.csc.library.utilities.*"%>
<%@page import="com.csc.library.session.*"%>

<%request.setCharacterEncoding("UTF-8");%>

<!-- Begin useBean -->

<jsp:useBean id="TEMPLATE_WORKFLOW" class="com.csc.library.system.Task" scope="page"/>
<jsp:setProperty name="TEMPLATE_WORKFLOW" property="classauthen" value="WorkflowUIAuthen" />

<%
	TEMPLATE_WORKFLOW.setChannel(request,response);
	TEMPLATE_WORKFLOW.checkProfile();
	if( TEMPLATE_WORKFLOW.getUProfile() != null ){
		TEMPLATE_WORKFLOW.getUProfile().set("appname","TA");
		UIManager screenSingle = (UIManager) TEMPLATE_WORKFLOW.process("SingleEntry","TEMPLATE_WORKFLOW");

		/*boolean isStep1 = false;
		boolean isStep2 = false;
		boolean isStep3 = false;
		boolean isStepCancel = false;
		boolean isStepComment = false;
		boolean isSte
		turn = false;
		boolean isStepCopy = false;*/

		String wf = null;
		CheckNull chkNull = new CheckNull(); 
		Organization og = new Masfactor(screenSingle.getUProfile());
		String subject = null;
		String remark = null;
		String step_type = null;
		String emp_fullname = null;
		String bossid = og.getBoss(screenSingle.getUProfile().get("employeeid"),screenSingle.getUProfile().get("job")).get(0).toString();
		String bossjob = bossid.substring(bossid.indexOf(":")+1);
		CscCalendar calendar = new CscCalendar();
		long attach_time = Long.parseLong(chkNull.chkNullString(request.getParameter("attach_time"),String.valueOf(calendar.getTimeInMillis())));
		ManageDocument md = new ManageDocument();
		md.setUProfile(screenSingle.getUProfile());
		md.setRequest(request);
		md.setScreen(screenSingle);

		if( !chkNull.chkNullString(request.getParameter("__cmd")).equals("save") ){
			subject = chkNull.chkNullString(request.getParameter("subject"));
			remark = chkNull.chkNullString(request.getParameter("__remark"));
			emp_fullname = chkNull.chkNullString(request.getParameter("emp_fullname"));
		}else if( chkNull.chkNullString(request.getParameter("__cmd")).equals("save") ){
			/*	if( chkNull.chkNullString(request.getParameter("__checkPage")).equals("true") ){
			response.sendRedirect("../MYNOTE/SENT_COMPLETE.jsp");
		}else{
			response.sendRedirect("../MYNOTE/INBOX.jsp");
		}*/
		if(chkNull.chkNullString(request.getParameter("isAdminEdit")).equals("true")){
			response.sendRedirect("../WORKFLOW_ADMIN/ADMIN_EDIT.jsp");
		}else if(chkNull.chkNullString(request.getParameter("isAdminCancel")).equals("true")){
			response.sendRedirect("../WORKFLOW_ADMIN/ADMIN_CANCEL.jsp");
		}else	if(chkNull.chkNullString(request.getParameter("isAdminClean")).equals("true")){
			response.sendRedirect("../WORKFLOW_ADMIN/ADMIN_CLEAN.jsp");
		}else if(chkNull.chkNullString(request.getParameter("isAdminDelete")).equals("true")){
			response.sendRedirect("../WORKFLOW_ADMIN/ADMIN_DELETE.jsp");
		}else{
			response.sendRedirect("../MYNOTE/SENT_COMPLETE.jsp");
		}
		//response.sendRedirect("../MYNOTE/SENT_COMPLETE.jsp");
		}else{
			subject = "";
			remark = "";
			emp_fullname = "";
		}

		bossid = bossid.substring(0,bossid.indexOf(":"));
		DbRecord memployee_dr = new InitialRecord(screenSingle.getUProfile()).getDbRecord("Memployee");
		memployee_dr.setColumn("*");
		memployee_dr.set("COMPANYID",screenSingle.getUProfile().get("companyid"));
		memployee_dr.set("EMPLOYEEID",bossid);
		memployee_dr.search();
		//WF_STATUS 1 = รอการอนุมัติ
		//          3 = ยกเลิกการอนุมัติ
		//          4 = อนุมัติแล้ว
		//          5 = ไม่อนุมัติ
		//          6 = แก้ไขโดย HR
		//          7 = ส่งกลับ
		//          8 = ยกเลิกเอกสาร
		//          9 = ประวัติ

		if( (request.getParameter("__runno") == null || request.getParameter("__runno").equals("")) && 
		(request.getParameter("__help") == null || request.getParameter("__help").equals("")) ){
			screenSingle.clean();
		}

		if( (!screenSingle.getDataLabel("WF_STATUS").equals("1")) && (!screenSingle.getDataLabel("WF_STATUS").equals("4")) &&
		(!screenSingle.getDataLabel("WF_STATUS").equals("7")) ){
			wf = "false";
		}else{
			wf = "true";
		}

	if( request.getParameter("downfile") != null ){
		ThaiUtilities tu = new ThaiUtilities();
		String filePath = request.getParameter("downfile");
		File f = new File(tu.ASCII2Unicode(filePath));
		String fileName = f.getName();
		String fileType = fileName.substring(fileName.indexOf(".")+1,fileName.length());
		if ( f.exists() && f.canRead() ) {
			response.setContentType("application/octet-stream");
			response.setHeader("Content-Disposition", "attachment; filename="+tu.Unicode2ASCII(f.getName()));
			response.setHeader("cache-control", "no-cache");
			response.setContentLength((int) f.length());
			BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(f));
			byte buffer[] = new byte[8 * 1024];
			out.clearBuffer();
			OutputStream out_s = response.getOutputStream();
			CopyStreams.copyStreamsWithoutClose(fileInput, out_s, buffer);
			out_s.flush();
			out_s.close();
			fileInput.close();
		}
	}

	String cur_empid =  chkNull.chkNullString(request.getParameter("__wf__employeeid"),screenSingle.getUProfile().get("employeeid"));
%>
<!-- End useBean -->
<HTML>
	<HEAD>
		<TITLE>myNOTE : Business Process Management Service</TITLE>
		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
		<!-- Begin Link -->
		<LINK HREF="../CSS/MYNOTE.css" REL="stylesheet" TYPE="text/css">
		<LINK HREF="../CSS/MYNOTE_MENU.css" REL="stylesheet" TYPE="text/css">
		<!-- End Link -->
		<!-- Begin Import Script -->
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/MYNOTE_SCREEN.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/MYNOTE_MENU.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/SCREEN.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/DATEINPUT.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/VIEWCALENDAR.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/ICONSMENU.js'></SCRIPT>
		<SCRIPT LANGUAGE="JavaScript">setLang('<%=screenSingle.getUProfile().get("lang")%>');</SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../TA/JS/TA_SCREEN.js'></SCRIPT>
		<!-- End Import Script -->
		<!--DWR INCLUDE-->
		<script type='text/javascript' src='/hr/dwr/interface/SearchDWR.js'></script>
		<script type='text/javascript' src='/hr/dwr/engine.js'></script>
		<script type='text/javascript' src='/hr/dwr/util.js'></script>
		<script type="text/javascript" src="/hr/dwr/interface/SystemCode.js"></script>
		<script type="text/javascript" src="/hr/dwr/interface/CscCalendar.js"></script>
		<script type="text/javascript" src="/hr/dwr/interface/Tabsent_nstda_dwr.js"></script>
		<!--DWR INCLUDE-->
		<SCRIPT LANGUAGE="JavaScript" TYPE="text/JavaScript">
		<!--
			var isNoSebject = false;
			function preSubmit(){ 
				with( document.cscform ){
				var stDate = __wf__start_date.value.split("-");
				var enDate = __wf__end_date.value.split("-");
				/*
				if(__wf__type_absent == undefined || __wf__type_absent.value == ""){
				alert("กำลังโหลดข้อมูลการลา กรุณารอสักครู่"); 
				document.location.reload(true);
				return false;
				}*/
				/* กบข ให้โอนลงหลังบ้านตั้งแต่ step แรก ดังนั้นการเช็คลาซ้ำในวันเดียวกันจึงไม่ต้องใช้
				DWREngine.beginBatch();
				Tabsent_nstda_dwr.chkDuplicateLeave(new Array(__absentid.value,__wf__employeeid.value,"100",
				stDate[2]+"-"+stDate[1]+"-"+stDate[0],__wf__start_time.value,
				enDate[2]+"-"+enDate[1]+"-"+enDate[0],__wf__end_time.value), isApproved); 
				DWREngine.endBatch({ async:false });
				*/
				GoWF();
				}				
			}
			var isApproved = function(data){
				if(data == true){
					with(document.cscform){
						wf_command[1].checked = true;
						comments.value = "ไม่สามารถอนุมัติเอกสารนี้ได้ เนื่องจากได้มีการขอลาไปแล้วในวันนี้";
					}
					alert("ไม่สามารถอนุมัติเอกสารนี้ได้ เนื่องจากได้มีการขอลาไปแล้วในวันนี้");
					GoWF();
				} else {
					GoWF();
				}
			}; 
			function preGoWF(){
				with( document.cscform ){
					var subj = "Leave Request Form";
					var tsubj = "ใบขอลาหยุดงาน ";
					var esubj = "Leave Request Form";
					if(__language.value == "tha") subj="ใบขอลาหยุดงาน ";
					
					dwr.engine.beginBatch();
					dwr.util.setValue("subject",subj + " ( " + __wf__type_absent.options[__wf__type_absent.selectedIndex].text+" ) ");
					dwr.util.setValue("tha_subject",tsubj + " ( " + __wf__type_absent.options[__wf__type_absent.selectedIndex].attributes.tdesc.value + " ) ");
					dwr.util.setValue("eng_subject",esubj + " ( " + __wf__type_absent.options[__wf__type_absent.selectedIndex].attributes.edesc.value +" ) ");
					dwr.engine.endBatch({
						async:false,timeout:1000
					});
					if( chkSummitCal() && chk_calculate.value != '' && !chk_ChgCondition()){
						if(chk_Time() && chk_Time2() && chkAttachFile()){
							
							 setMailConfigWorkflow();
							 GoWF();
						}
					}else{
						if(__language.value == "tha") {alert("กรุณากดปุ่ม Calculate เพื่อคำนวณสิทธิ์การลา !!");}
						else{alert("Please Click Button Calculate !!");}
					}
				
					//getLeaveUsed();
				}				
			}
		
			function processtime(){
				with( document.cscform ){
					//alert("xxxxx==="+used.value);
					var result_used =used.value.substring(0,1);
					type_absent.value=__wf__type_absent.value;

					if(chk_Time() && chk_Time2() && fullHours(__wf__start_time.value,__wf__end_time.value) && chkAttachFile()){
						if (result_used=='5' || result_used=='7') {
							alert(used.value.substring(1,used.value.length));
						} else {
							if(chkSummitCal()){
									if(alertError(result_used)){
										//alert(limitleave.value);
										getParam();
										__wfcmd.value=true;
										setLimitLeave();
										if(__wf__cause_absent.value!=""){
											GoWF();
										}else alert("กรุณากรอกเหตุผลการลา !!");
									}
								}else{alert("กรุณากดปุ่ม Calculate เพื่อคำนวณสิทธิ์การลา !!");}
						}
					}// unused
				}
			}
			
			function alertError(errorid,dayLimit){
				var error = new Array();
				if ( errorid == "0" ) {
					return true;
				} else {
					error[0] = "Not Have Working Time  "; 
					error[1] = "Already took leave for today.";
					error[2] = "Has no right to request.";
					error[3] = "Times of leave are excess the limit.";
					//error[4] = "ln form leave less than advance limit days.";
					error[4] = "This system not request to be past. Please contact HR";
					error[5] = "Please finish all preriquisite leave first.";
					error[6] = "Cannot take leave for today.";
					error[7] = "Insufficient remaining leave.";
					error[8] = "Sex is not match with leave type.";
					error[9] = "Please Request Before 13.00";
					error[11] = "Employee code is not match";

					if (errorid == "A"){
						alert(swap2String(error[0]));
					}else if (errorid == "B"){
						alert(swap2String(error[11]));
					}else if (errorid == "P"){
						alert("ไม่สามารถลา ย้อนหลัง ได้เกินกว่าที่กำหนดไว้ \n[ระบบกำหนดไว้ที่ "+dayLimit+" วัน]");
					}else if (errorid == "F"){
						alert("ไม่สามารถลา ล่วงหน้า ได้เกินกว่าที่กำหนดไว้ \n[ระบบกำหนดไว้ที่ "+dayLimit+" วัน]");
					}else if( errorid != "" ){
						alert(swap2String(error[errorid]));
					}else{
						alert(swap2String(error[4]));
					}
					return false;
				}
			}

			function openHelp(){
				with( document.cscform ){
					//window.open("../TA/HELP/Leave.pdf","Help","left=150,top=150,width=700,height=570,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}
		
			function goHelp(helpName,inputName,condition){
				with( document.cscform ){
					var helpReturn;
					var temp;
					if( inputName == "sendto" ){
						temp = __fixCon.value;
						if( condition.indexOf(",") > -1 ){
							condition = condition.replace(/,/g,"','");
						}
						__fixCon.value="EMPLOYEEID IN ('"+condition+"')";
					 	helpReturn="wf_next_actor:EMPLOYEEID,sendto:MEMPLOYEE@FULLNAME";
						linkHelp_SendToReturn(helpName,helpReturn);
						__fixCon.value=temp;
					}else if( inputName == "cc" ){
						temp = __fixCon.value;
						__fixCon.value = "STATUS in ('A','V')";
						helpReturn="wf_cc_actor:EMPLOYEEID,cc:MEMPLOYEE@FULLNAME";
						linkHelp_SendToReturn(helpName,helpReturn);
						__fixCon.value=temp;
					} else if(inputName=="__wf__abroadid" ){
						temp = __fixCon.value;
						__fixCon.value = "";
						helpReturn=inputName+":countryid,MCOUNTRY@TDESC";
						linkHelp_Return(helpName,helpReturn);
						__fixCon.value=temp;
					} else if(inputName=="__wf__employeeid"){
						temp = __fixCon.value;
						__fixCon.value = "((EMPLOYEEID = '<%=screenSingle.getUProfile().get("employeeid")%>') OR (BOSSID = '<%=screenSingle.getUProfile().get("employeeid")%>') OR (BOSSID IN (SELECT EMPLOYEEID FROM MEMPLOYEE WHERE BOSSID = '<%=screenSingle.getUProfile().get("employeeid")%>'))) AND STATUS != 'Y'";
						helpReturn=inputName+":employeeid,MEMPLOYEE@FULLNAME,__wf__old_shift:time0";
						linkHelp_Return_CallFunction(helpName,helpReturn,"searchEmp");
						__fixCon.value=temp;						
					}else if( inputName=="__employeeid" ){
						temp = __fixCon.value;
						__fixCon.value = "";
						helpReturn="__employeeid:EMPLOYEEID,MEMPLOYEE@FULLNAME,emp_fullname:MEMPLOYEE.FULLNAME";
						linkHelp_Return(helpName,helpReturn);
						__fixCon.value=temp;
					}else if( inputName.indexOf("__wf__emp_request") > -1 ){
						temp = __fixCon.value;
						helpReturn=inputName+":employeeid,MEMPLOYEE@FULLNAME"+inputName.substring(inputName.indexOf("$"), inputName.length);
						linkHelp_Return(helpName,helpReturn);
						__fixCon.value=temp;
					}else if( inputName.indexOf("__wf__auto_ass_empid") > -1 ){
						temp = __fixCon.value;
						helpReturn=inputName+":employeeid,__wf__auto_ass_empiddesc:MEMPLOYEE.FULLNAME";
						linkHelp_Return(helpName,helpReturn);
						__fixCon.value=temp;
					}
				}
			}
			
			function linkHelp_SendToReturn(help,input){
				with( document.cscform ){
					var param = "BROWSE_USER.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+__fixCon.value+"&__checkVerify=off&__langOn=off";
					window.open(param,"Help","left=150,top=150,width=530,height=370,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}

			function linkHelp_Return(help,input){
				with( document.cscform ){
					var param="BROWSE_HELP.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+__fixCon.value+"&__checkVerify=off&__langOn=off";
					window.open(param,"Help","left=150,top=150,width=530,height=370,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}
			
			function linkHelpWF(help,input){
				with(document.cscform){
					var temp = __fixCon.value;
					var fix = "wf_id='"+wf_id.value+"' and wf_ver='"+wf_ver.value+"' and initiator='<%=screenSingle.getUProfile().get("actor")%>' and (wf_status<>'4' and wf_status<>'6' and wf_status<>'3' and wf_status<>'8' and wf_status<>'A' and wf_status<>'B')";
					var param="BROWSE_HELP.jsp?__helpName="+help+"&__fieldSearch="+input+"&__pageCall="+__screen.value+"&__fixCon="+fix;
					//alert("param is:"+param);
					window.open(param,"Help","left=150,top=150,width=530,height=370,resizable=yes,scrollbars=yes,toolbar=no,status=yes");
					__fixCon.value = temp;
				}
			}
			
		function initiframe(empid){
			var source="";
			with( document.cscform ){
				source = "about:blank";
				if (empid != null && empid != "") {
					source="../TA/SHOWNLEAVE_WF_GPF.jsp?__employeeid="+empid+"&__fixCon="+__fixCon.value;		 
				}
				setcframe(source,"viewframe");
			}
		}

		function setcframe(source,mframe){
			var vframe=document.getElementById(mframe); 
			vframe.src=source;		  
		}

		function chk_Time(){
			var count=0;
			with(document.cscform){
				for (j=0;j<elements.length; j++){
					if(elements[j].name.indexOf("__wf__start_date") > -1){
						if(!isValidDate(elements[j].value)){
							count+=1;
							elements[j].focus();
							elements[j].select();
							break;
						}
					}
					if(elements[j].name.indexOf("__wf__end_date") > -1){
						if(!isValidDate(elements[j].value)){
							count+=1;
							elements[j].focus();
							elements[j].select();
							break;
						}
					}
					if(elements[j].name.indexOf("__wf__start_time") > -1){
						if(!isValidTime(elements[j].value)){
							count+=1;
							elements[j].focus();
							elements[j].select();
							break;
						}
					}
					if(elements[j].name.indexOf("__wf__end_time") > -1){
						if(!isValidTime(elements[j].value)){
							count+=1;
							elements[j].focus();
							elements[j].select();
							break;
						}
					}
				}//for
				if(count>0){
					return false;
				}else{
					return true;
				}
			}
		}
		
		function chk_Time2(){	
			with(document.cscform){
				return datetimeDifference(eval("__wf__start_date.value"),eval("__wf__end_date.value"),
					eval("__wf__start_time.value"),eval("__wf__end_time.value"));
			}
		}
		
		function setLimitLeave(){
			with(document.cscform){
				//alert(used.value);
				var digit = used.value.indexOf("#");
				__wf__limitleave.value = used.value.substring(0, digit);
				__wf__limitleave.value = __wf__limitleave.value+"_0";
				//alert(limitleave.value);
			}
		}

		function fullHours(sTime,eTime){
		 	/*with(document.cscform){
				if(__wf__format_leave[3].checked){
					var min = 0;
					sTime = sTime.split(".");
					eTime = eTime.split(".");
					min = sTime[1]-eTime[1];
					if(min != 0){
						alert(MyCode[147]);
						return false;
					}else return true;
				}else return true;
			}*/
			return true;
		}

		//=========================== Nuiss Code =====================
		/*
		*Author : Nuiss
		*Date : 11/05/2552
		*Logic : แสดง Description ของการลาประเภทนั้นๆ แจ้งให้ User ทราบ
		*เช่น การลาพักร้อน ต้องลาล่วงหน้า 7 วัน
		*หมายเหตุ Code ที่ใช้ check ใช้ที่ Honda เท่านั้น
		*ใช้ timer ในการหน่วงเวลาไว้ 2 วินาที เพราะ page มันอาจจะ create element
		*ไม่เสร็จ
		*/

		function setLeaveDescritption_withDelay(){
			InitializeTimer();
		}

		function setLeaveDescritption_withoutDelay(){
			//alert("in setLeaveDescritption");
			var pagesObj = document.getElementById("__wf__type_absent"); 
			//alert("pagesObj is: "+pagesObj );
			if(pagesObj==null){
			}else{
				//alert(pagesObj.options[pagesObj.selectedIndex].value);
				switch(pagesObj.options[pagesObj.selectedIndex].value){
					case "AN":
						document.getElementById("leaveDescription").innerText ="ลาหยุดพักผ่อนประจำปี(ลาพักร้อน) ต้องลาล่วงหน้าอย่างน้อย 7 วัน";
						break;
					default :
						document.getElementById("leaveDescription").innerText ="";
						break;
				}//end switch
			}
		}//end function

		var secs
		var timerID = null
		var timerRunning = false
		var delay = 1000

		function InitializeTimer(){
			// Set the length of the timer, in seconds
			secs = 2
			StopTheClock()
			StartTheTimer()
		}

		function StopTheClock(){
			if(timerRunning){
				clearTimeout(timerID)
				timerRunning = false
			}
		}

		function StartTheTimer(){
			if (secs==0){
				StopTheClock()
				//alert("You have just wasted 2 seconds before goto setLeaveDescritption_withDelay()")
				setLeaveDescritption_withoutDelay();
			}else{
				//self.status = secs
				secs = secs - 1
				timerRunning = true
				timerID = self.setTimeout("StartTheTimer()", delay)
			}
		}

		function viewPages(helppage){
				 var  pam=helppage+".jsp?__fixCon=employeeid='<%= TEMPLATE_WORKFLOW.getUProfile().get("employeeid") %>'";
				window.open(pam,"Help","left=150,top=150,width=800,height=500,toolbar=no,status=yes,scrollbars=yes");
		}
		function goPages(helppage,welid,budid){	
			 var  pam=helppage+".jsp?__fixCon=welid='"+welid+"' and budyear = '"+budid+"' and employeeid='<%= TEMPLATE_WORKFLOW.getUProfile().get("employeeid") %>'";	
			window.open(pam,"Help","left=150,top=150,width=700,height=500,toolbar=no,status=yes,scrollbars=yes");
		}

		var showfullname = function(data1){
			var empid="";
			//alert(data1[1][0]);
			with(document.cscform){
				for(j=0; j<data1.length; j++){
						empid+=data1[j][0];
				}
				dwr.util.setValue('MEMPLOYEE@FULLNAME',empid);
			}
		}

		function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);
		}

		var getLeave = function(data1){
			view_leave.innerHTML=data1;
		}

		function showLeave() {
			with (document.cscform) {
				if(__wf__employeeid.value != ""){
					var fl = "0";
					for(f=0; f<__wf__format_leave.length; f++){
						if(__wf__format_leave[f].checked){
							fl=__wf__format_leave[f].value;
						}
					}

					Tabsent_nstda_dwr.getDWRDataService(new Array(__wf__employeeid.value,__wf__type_absent.value,
						__wf__start_date.value,__wf__start_time.value,
						__wf__end_date.value,__wf__end_time.value,__wf__leave_day.value,fl,__wf__leave_hours.value,"", __absentid.value), getLeave);
				} else alert(MyCode[15]);
			}
		}

		function goView() {
			with(document.cscform){
				if(__wf__employeeid.value=="" || __wf__type_absent.value=="" || __wf__start_date.value==""
					|| __wf__start_time.value=="" || __wf__end_date.value=="" || __wf__end_time.value==""){
					alert(MyCode[0]);
				}else if(chk_Time() && chk_Time2()){
					showLeave();
				}
			}
		}

		var leaveUsed = function(data1){
			document.cscform.used.value=data1;
			processtime();
		}

		function getLeaveUsed() {
			with (document.cscform) {
				if(__wf__employeeid.value != ""){
					var fl = "0";
					var hl = "0";
					for(f=0; f<__wf__format_leave.length; f++){
						if(__wf__format_leave[f].checked){
							fl=__wf__format_leave[f].value;
						}
					}
					var used_leave = "";
					for(i=0; i<elements.length; i++){
						if(elements[i].name.indexOf("__wf__type_absent") > -1){
							//alert(elements[i].value);
							var fl = "0";
							var hl = "0";
							for(f=0; f<__wf__format_leave.length; f++){
								if(__wf__format_leave[f].checked){
									fl=__wf__format_leave[f].value;
								}
							}
							used_leave = eval("detail1.document.cscform.L"+elements[i].value+"_USED.value");
						}
					}
					Tabsent_nstda_dwr.getDWRLeave(new Array(__wf__employeeid.value,__wf__type_absent.value,
						__wf__start_date.value,__wf__start_time.value,
						__wf__start_date.value,__wf__end_time.value,__wf__leave_day.value,fl,hl,used_leave,"", __absentid.value), {callback:leaveUsed,async:true});
				}else alert(MyCode[15]);
			}
		}

		function calculateEDate(){
			with(document.cscform){
				if (detail1.document.cscform.__screen.value=="SHOWLEAVE"){		
					imgCalc.style.display = "none";
					imgSubmit.style.display = "none";
					if(__wf__employeeid.value != ""){
						var fl = "0";
						
						var used_leave = "";
						for(i=0; i<elements.length; i++){
							if(elements[i].name.indexOf("__wf__type_absent") > -1){
								//alert(elements[i].value);
								var fl = "0";
								var hl = "0";
								for(f=0; f<__wf__format_leave.length; f++){
									if(__wf__format_leave[f].checked){
										fl=__wf__format_leave[f].value;
									}
								}
								used_leave = eval("detail1.document.cscform.L"+elements[i].value+"_USED.value");
							}
						}
						//alert(fl+" "+__wf__leave_day.value);
						//Tabsent_nstda_dwr.getDWRLeave(new Array(__wf__employeeid.value,__wf__type_absent.value, __wf__start_date.value, __wf__start_time.value, __wf__end_date.value, __wf__end_time.value, __wf__leave_day.value, fl, __wf__leave_hours.value, used_leave,"", __absentid.value), enddateLeave);

						/* หน้าจอพิเศษ จะส่งค่าพารามิเตอร์มากกว่าปกติ */
						var stp = (__wf__st_period[0].checked)?0:1;
						var etp = (__wf__en_period[0].checked)?0:1;

						Tabsent_nstda_dwr.getDWRLeave(new Array(__wf__employeeid.value,__wf__type_absent.value, __wf__start_date.value
							, __wf__start_time.value, __wf__end_date.value, __wf__end_time.value, __wf__leave_day.value
							, "4", __wf__leave_hour.value, used_leave,"true", "0", stp, etp), enddateLeave);
					}else{
						alert(MyCode[15]);
					}
				} else {
					var err = "Please back to leave statistic page";
					if(__language.value == "tha") err="กรุณากลับไปยังหน้าสถิติการลาก่อน ";
					alert(err);
				}
			} //end with
		}

		var enddateLeave = function(data){
			//alert(data);
			var result_enddate="<%=new CscCalendar().getDDMMYYYY()%>";
			var result_calc="0";
			result_enddate = data.split("#");
			result_calc = data.substring(0,1);
			//alert(data);
			if (result_calc=='5' || result_calc=='7') {
				alert(data.substring(4,data.length));
				document.cscform.imgCalc.style.display = "";
				document.cscform.imgSubmit.style.display = "";
			} else {
				if(alertError(result_calc,result_enddate[1])){
					copyCondition();	/* keep cal value */
					dwr.util.setValue("__wf__start_date",result_enddate[1]);
					dwr.util.setValue("__wf__end_date",result_enddate[2]);
					dwr.util.setValue("__wf__start_time",result_enddate[3]);
					dwr.util.setValue("__wf__end_time",result_enddate[4]);
					dwr.util.setValue("__wf__leave_day",result_enddate[5]);
					dwr.util.setValue("__wf__leave_hour",parseFloat(result_enddate[6]).toFixed(2));
					dwr.util.setValue("chk_calculate","cal");
					document.cscform.imgCalc.style.display = "";
					document.cscform.imgSubmit.style.display = "";
				}else{
					document.cscform.imgCalc.style.display = "";
				}
			}
		}

		function copyCondition(){
			with(document.cscform){
				st_date_cpy.value = __wf__start_date.value;
				en_date_cpy.value = __wf__end_date.value;

				if(__wf__st_period[0].checked){
					st_period_cpy.value = __wf__st_period[0].value;
				}else{
					st_period_cpy.value = __wf__st_period[1].value;
				}

				if(__wf__en_period[0].checked){
					en_period_cpy.value = __wf__en_period[0].value;
				}else{
					en_period_cpy.value = __wf__en_period[1].value;
				}
			}
		}

		function chk_ChgCondition(){
			with(document.cscform){
				var stp = "";
				if(__wf__st_period[0].checked){
					stp = __wf__st_period[0].value;
				}else{
					stp = __wf__st_period[1].value;
				}

				var enp = "";
				if(__wf__en_period[0].checked){
					enp = __wf__en_period[0].value;
				}else{
					enp = __wf__en_period[1].value;
				}

				if(st_date_cpy.value != __wf__start_date.value || en_date_cpy.value != __wf__end_date.value
					|| st_period_cpy.value != stp ||  en_period_cpy.value != enp){
					return true;
				}else{
					return false;
				}
			}
		}
		function overZero(obj){
			with(document.cscform){
				if(obj.value == "0"){
					obj.value = "1";
					obj.focus();
					obj.select();
				}
			}
		}

		function setValueEnddate(startdate){
			with(document.cscform){
				__wf__end_date.value = startdate.value;
			}
		}

		function chkGuarantee(obj_event){
			with(document.cscform){
				SearchDWR.searchAll(new Array("meventgrp","eventgrpid,companyid,tdesc,edesc,guarantee,guarantee_date",
					"eventgrpid='"+obj_event.value+"'","eventgrpid","langon"),
					function(data1){
						if(data1.length > 0){
							dwr.util.setValue('__attach_value',data1[0][4]);
							dwr.util.setValue('__guarantee_date',data1[0][5]);
						}//end if
					}// end function
				);
			}
		}

		function getListTypeAbsent(eventgrpid,dis){
			var ev = "";
			var selectDefault = ""; //ลาป่วย

			SearchDWR.searchAll(new Array("meventgrp","eventgrpid,companyid,tdesc,edesc,daytype","daytype!='1' and daytype !='5' and daytype !='6' and daytype !='9' and (eventgrpid<>'J')","display_order",""),{callback:
			function(data1){
				var str="";
				var lang = "2";
				
				if(document.getElementById("__language").value == "eng"){
					lang = "3";
				}
				for(i=0;i<data1.length;i++){
					if(eventgrpid == ""){	// first time enter this page
						eventgrpid = data1[i][0];
						ev = "selected";
						setLeaveSubject(data1[i][2],data1[i][3]);
					}else if(data1[i][0]==eventgrpid){
						ev = "selected";
						setLeaveSubject(data1[i][2],data1[i][3]);
					}else if(selectDefault!="" && data1[i][0] == selectDefault){
						ev="selected"
					}else{
						ev="";
					}
					if(data1[i][4] == "7") dwr.util.setValue("__type_holiday",dwr.util.getValue("__type_holiday")+","+data1[i][0]);
					
					str = str +  "<option value='"+data1[i][0]+"' "+ev+" tdesc='"+data1[i][2]+"' edesc='"+data1[i][3]+"'>"+data1[i][lang]+"</option>";
				}
				document.getElementById("__eventgrp").innerHTML="<select  id='__wf__type_absent' name=\"__wf__type_absent\" onChange='setLimitLeave();chkLeaveTime(this);chkGuarantee(this);setLeaveDescritption_withoutDelay();' "+dis+">"+str+"</select>";
			},async:true});
		}

		function chkLeaveTime(eventgrp){
			//alert("chkLeaveTime==>"+eventgrp);
			var ev = eventgrp.value;
			//alert(ev);
			with(document.cscform){
				var holiday = dwr.util.getValue("__type_holiday").split(",");
				var subj = "Absent Work Form";
				if(__language.value == "tha") subj="ใบขอลาหยุดงาน ";
				dwr.util.setValue("subject",subj + " (" + eventgrp.options[eventgrp.selectedIndex].text + ")");
			/*	for(i=1; i<holiday.length; i++){
					
				setLeaveTitle();
					if(ev == holiday[i]){
						__wf__format_leave[0].checked = true;
						disableTime(true); 
						menu2.disabled = true;
						break;
					}else{
						disableTime(false);
						menu2.disabled = false; 
					}
				}*/
				LeaveTime();
			}
		}

		function setLeaveTitle(){
			with(document.cscform){
				if(__language.value == "tha") subj="ใบลา";
				
				dwr.util.setValue("subject",subj + " (" + __wf__type_absent.options[__wf__type_absent.selectedIndex].text + ")");
			}
		}
		function disableTime(value){
			with(document.cscform){
				__wf__start_time.readOnly = value;
				__wf__end_time.readOnly = value;
			}
		}
  
		function LeaveTime(){
			with(document.cscform){
				chk_calculate.value='';
				/* ลาเต็มวัน */
				if(__wf__format_leave[0].checked){
				//	alert("0");
					if(__wf__leave_day.value == "0"){
						__wf__leave_day.value = "1";
					}//end 
					__wf__start_time.value="0.00";
					__wf__end_time.value="23.59";
					__wf__leave_hours.value = "0";
					disableTime(true);
					__wf__leave_day.disabled = false;
					__wf__leave_hours.disabled=true;

					__wf__list_hours.value = "0";
					__wf__list_min.value = "00";
					__wf__list_hours.disabled = true;
					__wf__list_min.disabled = true;

				/* ลาครึ่งวัน */
				}else if(__wf__format_leave[1].checked || __wf__format_leave[2].checked) {
					//alert("1 || 2");
						__wf__leave_day.value = "0";
					__wf__leave_hours.value = "0";
					disableTime(true);
					__wf__leave_day.disabled = true;
					__wf__leave_hours.disabled=true;

					__wf__list_hours.value = "0";
					__wf__list_min.value = "00";
					__wf__list_hours.disabled = true;
					__wf__list_min.disabled = true;

				}else if(__wf__format_leave[3].checked){
					//alert("3");
					disableTime(false);
					__wf__list_hours.disabled = false;
					__wf__list_min.disabled = false;
					__wf__leave_day.value="0";
					__wf__end_time.readOnly = true;
					__wf__leave_day.disabled = true;
					__wf__leave_hours.disabled=false;
					__wf__start_time.focus();


				}//end if 
			}//end with
		}//end function

		function searchEmp(){
			var condition = " AND (EMPLOYEEID IN (SELECT EMPLOYEEID FROM MEMPLOYEE WHERE BOSSID = (SELECT BOSSID FROM MEMPLOYEE WHERE EMPLOYEEID = '<%=screenSingle.getUProfile().get("employeeid")%>') ) OR BOSSID = '<%=screenSingle.getUProfile().get("employeeid")%>') AND STATUS != 'Y'";
			//var condition = " EMPLOYEEID IN ('<%=screenSingle.getUProfile().get("employeeid")%>')  AND STATUS != 'Y' ";
			searchDescEmp(document.cscform.__wf__employeeid,  'memployee.fullname:MEMPLOYEE@FULLNAME,mposition.tdesc:__position,mbu1.tdesc:__bu1,mbu2.tdesc:__bu2,mbu3.tdesc:__bu3,mbu4.tdesc:__bu4,mbu5.tdesc:__bu5,memployee.startdate:__startdate,memployee.tel_ext:__tel_ext,memployee.emp_every:__wf__emp_every', condition);
			//alert(dwr.util.getValue("__wf__employeeid"));
			initiframe(dwr.util.getValue("__wf__employeeid"));
		}


		function chkAttachFile(){
			with(document.cscform){
		//alert(__wf__emp_every.value);
				var msg = "Please Attach File";
				if(__language.value == "tha") msg = "กรุณาแนบไฟล์หนังสือรับรอง";
				//alert(__attach_value.value);
				if(__attach_value.value == "1"){ // garuntee
					if(__wf__emp_every.value == "D"){
								//alert("Check");
								if(!CheckAttachFile()){
									alert(msg);						
									return false;
								}else {
									
								return true
								};

					}else{
							if((parseInt(__wf__leave_day.value) >= parseInt(__guarantee_date.value)) && dwr.util.getValue("__wf__format_leave") == "0") {
								if(!CheckAttachFile()){
									alert(msg);						
									return false;
								}else {return true};
							
							}else{
								return true;
							}
					}
				}else{
						return true;
				}
			}
		}


		function getInputEventgrp(value, disable){
			SearchDWR.getInput(new Array("tabsent_nstda", "type_absent", "Name:wf__type_absent", "Disable:"+disable, "onChange:setLimitLeave();chkLeaveTime(this);chkGuarantee(this)"), function(data){
				dwr.util.setValue("__eventgrp", data[1]);
				dwr.util.setValue("__wf__type_absent", value);
				chkGuarantee(document.getElementById("__wf__type_absent"))
			});
		}

		function setListValue(fieldList){
			var list = fieldList.split(",");
			var get_value = "";
			
			for (var i = 0; i < list.length; i++) {
				get_value =  dwr.util.getValue("__temp_value")+","+dwr.util.getValue(list[i]);
				if (i==0) get_value = dwr.util.getValue(list[i]);
				dwr.util.setValue("__temp_value", get_value);
			}
		}

		function chkDeffValue(){
			var temp_list = dwr.util.getValue("__temp_value").split(",");
			var field_list = dwr.util.getValue("__field_list").split(",");
			var flag = dwr.util.getValue("__flag");
			var msg = swap2String("Please click calculate again.");

			if (flag == "1") {
				for (var i=0; i<temp_list.length; i++) {
					//alert(temp_list[i] +" : "+ dwr.util.getValue(field_list[i]));
					//alert(temp_list[i].toString() == dwr.util.getValue(field_list[i]).toString());
					if (temp_list[i].toString() != dwr.util.getValue(field_list[i]).toString()){
						alert(msg);
						return false;
					}
				}
			} else {
				alert(msg);
				return false;
			}
			return true;
		}

		function chkSummitCal(){// check ว่า กดปุ่ม Calculate หรื่อไม่
			with(document.cscform){  
					if(chk_calculate.value=='cal'){
						return true;
					}else{
						return false;
					}
				}
			}
			
		function getInitiatorLevel(){
			with(document.cscform){
					SearchDWR.searchAll(new Array("mjobcode","jobcode_level","jobcodeid='<%=screenSingle.getUProfile().get("job")%>'","jobcodeid","langon"),
					function(data1){
							if(data1.length > 0){
								dwr.util.setValue('__wf__initiator_level', data1[0][0]);
							}
						}// end function
					);
			}
		}

				function setMailConfigWorkflow(){
				  with(document.cscform){
					  var date , month , year;
					  var now =  new Date();
					  date =  now.getDate();
					  month = now.getMonth()+1;
					  year = now.getFullYear();
					  date = (date <10)?('0'+date):date;
					  month = (month<10)?('0'+month):month;
		 	           __wf__start_doc_date.value = date+'/'+month+'/'+year;
					 // alert(__wf__start_doc_date.value );
				  }
			}

			function setLeaveSubject(tdesc, edesc){
				with(document.cscform){
					if(isNoSebject){
						//no subject object
					}else{
						if(__language.value == "tha"){
							subject.value = subject.value +  " (" + tdesc + ")";
						}else{
							subject.value = subject.value +  " (" + edesc + ")";
						}
					}
				}
			}

			function setDisableObj(obj, status){
				obj.disabled = status;
			}

			function visibleObj(obj, status){
				if( obj && obj.style && obj.style.visibility){
					obj.style.visibility = status ;
				}
			}

				function setHidHours(){
				with(document.cscform){
					__wf__leave_hours.value = __wf__list_hours.value+"."+__wf__list_min.value;
					chk_calculate.value = "";
				}
			}

			function setDefaultDayHour(){
				with(document.cscform){
					chk_calculate.value = "";
					__wf__leave_hours.value = "0.00";
					__wf__leave_day.value = "0";
				}
			}
//-->
		</SCRIPT>
		<script type="text/javascript" src="../JS/jquery-1.3.2.min.js" ></script>
		<script type="text/javascript">
			$(function(){
				$(".column-label").css("width","25%");
			});
		</script>
		
		<script type="text/javascript" src="../JS/jquery-1.11.1.min.js" ></script>
		<script type="text/javascript">
			$(function(){
				$(".column-label").css("width","25%");	
				$("#imgSubmit").click(function(){
					$("#__wf__absent_tdesc").val($("#__wf__type_absent option:selected").attr("tdesc"));
					$("#__wf__absent_edesc").val($("#__wf__type_absent option:selected").attr("edesc"));
				});
			});
		</script>
		
	</HEAD>
	<BODY>
	<!-- ImageReady Slices (02.psd) -->
		<FORM NAME="cscform" METHOD="post" ACTION="TAU_CSCWF_001_GPF.jsp">
			<INPUT TYPE="hidden" NAME="__screen" VALUE="TAU_CSCWF_001_GPF">
			<INPUT TYPE="hidden" NAME="__cmd" VALUE="">
			<INPUT TYPE="hidden" NAME="__help" VALUE="">
			<INPUT TYPE="hidden" NAME="__fixCon" VALUE="">
			<INPUT TYPE="hidden" NAME="__notNull" VALUE="<%=screenSingle.getRequire()%>">
			<INPUT TYPE="hidden" NAME="__language" VALUE="<%=screenSingle.getUProfile().get("lang")%>">
			<INPUT TYPE="hidden" NAME="__companyid" VALUE="<%=screenSingle.getUProfile().get("companyid")%>">
			<INPUT TYPE="hidden" NAME="__calendar" VALUE="">
			
			<SCRIPT LANGUAGE="JavaScript">getInputFormatDate();</SCRIPT>

			<INPUT TYPE="hidden" NAME="wf_id" VALUE="8001">
			<INPUT TYPE="hidden" NAME="__wf_id" VALUE="8001">
			<INPUT TYPE="hidden" NAME="wf_ver" VALUE="<%=chkNull.chkNullString(request.getParameter("wf_ver"),"1")%>">
			<INPUT TYPE="hidden" NAME="__wf_ver" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf_ver"),"1")%>">
			<INPUT TYPE="hidden" NAME="wf_seq_no" VALUE="<%=chkNull.chkNullString(request.getParameter("wf_seq_no"),"0")%>">
			<INPUT TYPE="hidden" NAME="step_id" VALUE="<%=chkNull.chkNullString(request.getParameter("step_id"),"0")%>">
			<INPUT TYPE="hidden" NAME="step_seq_no" VALUE="<%=chkNull.chkNullString(request.getParameter("step_seq_no"),"0")%>">
			<INPUT TYPE="hidden" NAME="wf_return_actor" VALUE="IINIT">
			<!--INPUT TYPE="hidden" NAME="__oldDocumentID" VALUE="<%=screenSingle.getDataLabel("DOC_NO")%>">
			<INPUT TYPE="hidden" NAME="__oldWF" VALUE="<%=screenSingle.getDataLabel("WF_STATUS")%>"-->
			<input type="hidden" name="__oldDocumentID" value="<%=(!screenSingle.getDataLabel("DOC_NO").equals("0")?screenSingle.getDataLabel("DOC_NO"):chkNull.chkNullString(request.getParameter("__oldDocumentID"),"0"))%>">
			<input type="hidden" name="__oldWF" value="<%=(!screenSingle.getDataLabel("DOC_NO").equals("0")?screenSingle.getDataLabel("WF_STATUS"):chkNull.chkNullString(request.getParameter("__oldWF"),"0"))%>">
			<INPUT TYPE="hidden" NAME="__wf" VALUE="<%=wf%>">
			<INPUT TYPE="hidden" NAME="__wfcmd" VALUE="false">
			<INPUT TYPE="hidden" NAME="used" VALUE="">
			<INPUT TYPE="hidden" NAME="__wf__limitleave" VALUE="">
			<INPUT TYPE="hidden" NAME="remark" VALUE="<%=remark%>">
			<INPUT TYPE="hidden" NAME="type_absent" VALUE=""> 
			<INPUT TYPE="hidden" NAME="__employeeid" VALUE="<%=TEMPLATE_WORKFLOW.getUProfile().get("employeeid") %>">
			<INPUT TYPE="hidden" NAME="__attach_value" VALUE="0">
			<INPUT TYPE="hidden" NAME="__guarantee_date" VALUE="0"> 
            <INPUT TYPE="hidden" NAME="__type_holiday" VALUE="">
			<INPUT TYPE="hidden" NAME="__absentid" VALUE="0">	
			<INPUT TYPE="hidden" NAME="__wf__chkdaterequest" VALUE="">
			<INPUT TYPE="hidden" NAME="__wf__emp_every" VALUE="">
			<INPUT TYPE="hidden" NAME="__chkdaterequest" VALUE="">
			<INPUT TYPE="hidden" NAME="__leave_desc" VALUE="">
			<INPUT TYPE="hidden" NAME="wf_default_actor" VALUE="true">

			<INPUT TYPE="hidden" NAME="__flag" VALUE="<%=chkNull.chkNullString(request.getParameter("__flag"), "0")%>">
			<INPUT TYPE="hidden" NAME="__field_list" VALUE="__wf__employeeid,__wf__type_absent,__wf__start_date,__wf__start_time,__wf__start_date,__wf__end_time,__wf__leave_day,__wf__format_leave">
			<INPUT TYPE="hidden" NAME="__temp_value" VALUE="<%=chkNull.chkNullString(request.getParameter("__temp_value"))%>">

			<INPUT TYPE="hidden" NAME="draft_cmd" VALUE="">              
			<INPUT TYPE="hidden" NAME="draft_no" VALUE="<%=chkNull.chkNullString(request.getParameter("draft_no"),"0")%>">               
			<INPUT TYPE="hidden" NAME="admin_cmd" VALUE="">		
			<INPUT TYPE="hidden" NAME="__checkPage" VALUE="true">
            <INPUT TYPE="hidden" NAME="wf_default_actor" VALUE="true">

			<!-- Redirect Page -->
			 <INPUT TYPE="hidden" NAME="isAdminEdit" VALUE="<%=chkNull.chkNullString(request.getParameter("isAdminEdit"))%>">
			 <INPUT TYPE="hidden" NAME="isAdminCancel" VALUE="<%=chkNull.chkNullString(request.getParameter("isAdminCancel"))%>">
			 <INPUT TYPE="hidden" NAME="isAdminClean" VALUE="<%=chkNull.chkNullString(request.getParameter("isAdminClean"))%>">
			 <INPUT TYPE="hidden" NAME="isAdminDelete" VALUE="<%=chkNull.chkNullString(request.getParameter("isAdminDelete"))%>">
			
			 <!-- for checking calculate button status -->
			 <INPUT TYPE="hidden" NAME="st_date_cpy" VALUE="">
			 <INPUT TYPE="hidden" NAME="en_date_cpy" VALUE="">
			 <INPUT TYPE="hidden" NAME="st_period_cpy" VALUE="">
			 <INPUT TYPE="hidden" NAME="en_period_cpy" VALUE="">
			 
			<INPUT TYPE="hidden" NAME="__wf__absent_tdesc" ID="__wf__absent_tdesc" VALUE="">
			<INPUT TYPE="hidden" NAME="__wf__absent_edesc" ID="__wf__absent_edesc" VALUE="">
						 
			<%=screenSingle.InitialVariable()%>
			
			<DIV ID="toolTipLayer" STYLE="position:absolute; visibility: hidden"></DIV>
			<SCRIPT LANGUAGE="JavaScript">initToolTips();</SCRIPT>
			
			<TABLE WIDTH="950" BORDER="0" ALIGN="center" CELLPADDING=0 CELLSPACING=0  ID="wrapper">
				<jsp:include page="../MYNOTE/MYNOTE_HEAD.jsp" flush="true"/>
						<DIV ALIGN="center">
						<!-- Begin Step1 -->
<%=md.getStepDocument("8001","1")%>
<%=md.getHeadDocument()%>
                      <br>
<%=md.getHelpDocument2("Leave Request Form")%>
                      <br>
<%=md.getSendToDocumentNoSearch("Leave Request Form")%>
<%//=md.getSendToDocument("Leave Request Form")%>
					  <br>
						<!-- Begin Code -->
							<TABLE WIDTH="95%" BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0">
								<TR>
									<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-T-L.gif" WIDTH="5" HEIGHT="5"></TD>
									<TD HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/T.gif" WIDTH="100%" HEIGHT="5"></TD>
									<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-T-R.gif" WIDTH="5" HEIGHT="5"></TD>
								</TR>
								<TR>
									<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/L2.gif"></TD>
									<TD VALIGN="middle">
										<TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="1">
										<!-- Begin User Code -->
											<tr>
												<td colspan="2" class="column-title" ><script language="javascript">swapLang('Employee Details')</script></td>
											</tr>
										    <tr>
										      <INPUT TYPE="hidden" NAME="__subordinate" VALUE="<%=screenSingle.getUProfile().get("subordinateall")%>">
											  <INPUT TYPE="hidden" NAME="__wf__request_date" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__request_date"))%>">
											  <INPUT TYPE="hidden" NAME="__wf__request_time" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__request_time"))%>">
											  <INPUT TYPE="hidden" NAME="chk_calculate" VALUE=""> 
                                              <td class="column-label"><script language="javascript">swapLang('Employee Code')</script></td>
										      <td class="column-input">
										          <input name="__wf__employeeid" type="text" size="15" value="<%=cur_empid%>" onBlur="javascript:searchEmp()" CLASS="" READONLY>
                                                  <%//if(md.isStep1){%>
<!-- 												<A HREF="JavaScript:goHelp('MEMPLOYEEHELP2','__wf__employeeid');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('emp_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"> <IMG SRC="../IMAGES/BUTTON/MAIN/SEARCH20.gif" ALT="SEARCH" NAME="emp_image" WIDTH="20" HEIGHT="20" BORDER="0" ALIGN="absmiddle"></A> -->
										        <%//}%>
										        
										        <input name="MEMPLOYEE@FULLNAME" type="text" size="40" value="<%= chkNull.chkNullString(request.getParameter("MEMPLOYEE@FULLNAME"),"") %>" readonly class=""></td>
									      </tr>
										    <tr>
                                              <td width="25%" class="column-label"><script language="javascript">swapLang('Position')</script></td>
										      <td class="column-input"><input type="text" name="__position" value="<%= chkNull.chkNullString(request.getParameter("__position"),"") %>" size="52" readonly class=""></td>
									      </tr>
										    <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Business Unit 1')</script></td>
										      <td class="column-input"><input type="text" name="__bu1" value="<%= chkNull.chkNullString(request.getParameter("__bu1"),"") %>" size="52" readonly class=""></td>
									      </tr>
										    <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Business Unit 2')</script></td>
										      <td class="column-input"><input type="text" name="__bu2" value="<%= chkNull.chkNullString(request.getParameter("__bu2"),"") %>" size="52" readonly class=""></td>
									      </tr>
										    <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Business Unit 3')</script></td>
										      <td class="column-input"><input type="text" name="__bu3" value="<%= chkNull.chkNullString(request.getParameter("__bu3"),"") %>" size="52" readonly class=""></td>
									      </tr>
										    <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Business Unit 4')</script></td>
										      <td class="column-input"><input type="text" name="__bu4" value="<%= chkNull.chkNullString(request.getParameter("__bu4"),"") %>" size="52" readonly class=""></td>
									      </tr>
										    <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Business Unit 5')</script></td>
										      <td class="column-input"><input type="text" name="__bu5" value="<%= chkNull.chkNullString(request.getParameter("__bu5"),"") %>" size="52" readonly class=""></td>
									      </tr>
										  <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Assign Work')</script></td>
										      <td class="column-input">
												<input type="text" name="__wf__auto_ass_empid" value="<%= chkNull.chkNullString(request.getParameter("__wf__auto_ass_empid"),"") %>" size="15" readonly class="">
											  <%if(md.isStep1){%>
 												<A HREF="JavaScript:goHelp('MEMPLOYEEHELP2_TH','__wf__auto_ass_empid');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('emp_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"> <IMG SRC="../IMAGES/BUTTON/MAIN/SEARCH20.gif" ALT="SEARCH" NAME="emp_image" WIDTH="20" HEIGHT="20" BORDER="0" ALIGN="absmiddle"></A> 
										        <%}%>
												<input name="__wf__auto_ass_empiddesc" type="text" size="40" value="<%= chkNull.chkNullString(request.getParameter("__wf__auto_ass_empiddesc"),"") %>" readonly class="">
											  </td>
									      </tr>
										    <!--tr>
                                              <td class="column-label"><script language="javascript">swapLang('Start Date')</script></td>
										      <td class="column-input"><input type="text" name="__startdate" value="<%= chkNull.chkNullString(request.getParameter("__startdate"),"") %>" size="52" readonly class="disabled"></td>
									      </tr>
										    <tr>
                                              <td class="column-label"><script language="javascript">swapLang('Ext')</script></td>
                                               <td class="column-input">   <input type="text" name="__tel_ext" value="<%= chkNull.chkNullString(request.getParameter("__tel_ext"),"") %>" size="5" readonly class="disabled"></td>
									      </tr-->
										  <input type="hidden" name="__startdate" value="<%= chkNull.chkNullString(request.getParameter("__startdate"),"") %>">
										  <input type="hidden" name="__tel_ext" value="<%= chkNull.chkNullString(request.getParameter("__tel_ext"),"") %>">
										
										  <tr>
												<td colspan="2" class="column-title" ><script language="javascript">swapLang('Leave Details')</script></td>
										  </tr>
										<tr>
										  <td  class="column-label"><span id="__type_absent"></span><script language="javascript">swapLang('Leave Type')</script></td>
										  <td class="column-input"><span id="__eventgrp">
										   <select name="__wf__type_absent" id="__wf__type_absent" onChange="setLimitLeave();chkLeaveTime(this);chkGuarantee(this);setLeaveDescritption_withoutDelay();">
                                            <%
												String ev = "";
												String filter = "display = '1' and daytype!='1' and daytype !='5' and daytype !='6' and daytype !='9' and (eventgrpid<>'J') and BRANCHID = (select BRANCH from MEMPLOYEE where EMPLOYEEID = '" + cur_empid + "')";
												String lang = "edesc";
												if(screenSingle.getUProfile().get("lang").equals("tha")){
													lang = "tdesc";
												}
												DbInquiry mevent = new InitialInquiry(screenSingle.getUProfile()).getDbInquiry();
												mevent.setSchemaName(screenSingle.getUProfile().getSchemaName());
												mevent.initMyTable("meventgrp1", filter, "");
												mevent.setColumn("eventgrpid,companyid,tdesc,edesc,daytype,display_order,display,display_limit");
												mevent.referLangOff();
												mevent.setOrderBy("display_order");
												mevent.refresh();

												String tyabsent = "";
												if(!md.isStep1){
													tyabsent = chkNull.chkNullString(md.getWFDataValue("__wf__type_absent"));
												}else{
													tyabsent = chkNull.chkNullString(request.getParameter("__wf__type_absent"));
												}
												//out.println("tyabsent " + tyabsent);

												while(mevent.next()){
													if(chkNull.chkNullString(request.getParameter("__wf__type_absent"),"").equals(mevent.getString("eventgrpid"))){
														ev = " selected ";
													}else{
														ev = "";
													}	
											%>
                                            	<option value="<%=mevent.getString("eventgrpid")%>" <%=ev%> tdesc="<%=mevent.getString("tdesc")%>" edesc="<%=mevent.getString("edesc")%>"><%=mevent.getString(lang)%></option>
                                            <% } %>
									      </select>
										  <input type="hidden" id="__wf__format_leave" name="__wf__format_leave" value="4">
										  </span><div id='leaveDescription' style='color:red'></div><input name="__wf__emp_request" type="hidden" value="<%=screenSingle.getUProfile().get("actor")%>"><INPUT NAME="__wf__absentid" VALUE="0" TYPE="hidden"></td></tr>
										<tr>
											<td class="column-label"><script language="javascript">swapLang('Leave Cause')</script></td>
											<td class="column-input"> <input name="__wf__cause_absent" type="text" value="<%=chkNull.chkNullString(request.getParameter("__wf__cause_absent"))%>" size="50"/></td>
										</tr>
										<tr>
										  <td class="column-label"><script language="javascript">swapLang('Start Date')</script></td>
										  <td class="column-input"><span class="desc">
											  <input type="text" size="10" name="__wf__start_date" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__start_date"),new CscCalendar().getDDMMYYYY()) %>" class="txt01" onKeyup = "formatDate(this)" onBlur = "" onKeypress = "chkIntegerOfDate(this.value)">&nbsp;
											  </span><span class="desc"> 
											  <%if(md.isStep1){%>
											  <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1311','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image1311" width="20"  border="0" align="absmiddle" id="Image1311" onClick="viewCal('__wf__start_date')"></a>
											  <%}%>&nbsp;
											  <INPUT TYPE="radio" ID="__st_period1" NAME="__wf__st_period" VALUE="0"><SCRIPT LANGUAGE="javascript">swapLang('WF First Part')</SCRIPT>
											  &nbsp;&nbsp;
											  <INPUT TYPE="radio" ID="__st_period2" NAME="__wf__st_period" VALUE="1"><SCRIPT LANGUAGE="javascript">swapLang('WF Second Part')</SCRIPT>
											  </span>
											  <input type="hidden" id="__wf__start_time" name="__wf__start_time">
											  </td>
										</tr>
										<tr>
										  <td class="column-label"><script language="javascript">swapLang('End Date')</script></td>
										  <td class="column-input"><span class="desc">
											  <input type="text" size="10" name="__wf__end_date"  maxlength=10 value="<%=chkNull.chkNullString(request.getParameter("__wf__end_date"),new CscCalendar().getDDMMYYYY()) %>" class="txt01" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(__wf__start_date,this)" onKeypress = "chkIntegerOfDate(this.value)" >&nbsp;
											  </span>
											  
											  <span class="desc"> 
											  <%if(md.isStep1){%>
												<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1312','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)">
													<img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="Image1312" width="20"  border="0" align="absmiddle" id="Image1312" onClick="viewCal('__wf__end_date')">
												</a><%}%>&nbsp;
											  <INPUT TYPE="radio" ID="en_period1" NAME="__wf__en_period" VALUE="0">
											  <SCRIPT LANGUAGE="javascript">swapLang('WF First Part')</SCRIPT>
					    					  &nbsp;&nbsp;
											  <INPUT TYPE="radio" ID="en_period2" NAME="__wf__en_period" VALUE="1">
											  <SCRIPT LANGUAGE="javascript">swapLang('WF Second Part')</SCRIPT>
											  </span>
											  <input type="hidden" id="__wf__end_time" name="__wf__end_time">
											</td>
										</tr>

										<%if(md.isStep1){%>
										<tr>
										  <td class="column-label">&nbsp;</td>
										  <td class="column-input"><a href="javascript:calculateEDate()"><img src="../IMAGES/MYNOTE/BUTTON/BUTTON_CALCULATE.gif" id="imgCalc" border="0"></a></td>
										</tr>
										<%}%>
										<tr>
											<td class="column-label"><SCRIPT LANGUAGE="javascript">swapLang('Total leave')</SCRIPT>&nbsp;</td>
											<td class="column-input">
												<INPUT TYPE="text" ID="leave_day" NAME="__wf__leave_day" VAlUE="00" size="4" style="text-align: right" readonly>
												<SCRIPT LANGUAGE="javascript">swapLang('Day')</SCRIPT>
												<INPUT TYPE="text" ID="leave_hour" NAME="__wf__leave_hour" VALUE="00" size="4" style="text-align: right" readonly>
												<SCRIPT LANGUAGE="javascript">swapLang('Hours')</SCRIPT>
											</td>
										</tr>
										<!-- <tr>
										  <td class="column-label"><script language="javascript">swapLang('Leave Amount')</script></td>
										  <td class="column-input"><div align="right"><a  href="javascript:goView();"><img height=37 src="../IMAGES/MYNOTE/BUTTON/BUTTON_VIEW.gif" width=89 border=0></a></div></td>
										</tr> -->
										<!-- End User Code -->
										<tr>
											<td class="column-label"><script language="JavaScript">swapLang("Priority");</script></td>
											<td class="column-data"><div>
												<label><input type="radio" name="priority" value="0" checked />&nbsp;<script language="JavaScript">swapLang("Normal")</script></label>
												<label><input type="radio" name="priority" value="1" />&nbsp;<script language="JavaScript">swapLang("High")</script></label>
												<label><input type="radio" name="priority" value="2" />&nbsp;<script language="JavaScript">swapLang("Highest")</script></label>
											  </div></td>
										</tr>
										</TABLE>
								  </TD>
									<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/R2.gif"></TD>
								</TR>
								<TR>
									<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-B-L.gif" WIDTH="5" HEIGHT="5"></TD>
									<TD HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/B.gif" WIDTH="100%" HEIGHT="5"></TD>
									<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-B-R.gif" WIDTH="5" HEIGHT="5"></TD>
								</TR>
							</TABLE>
							<BR>
							 <!----- SHOW LEAVE ---->	
							 <TABLE WIDTH="95%" BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0">
							<TR>
								<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-T-L.gif" WIDTH="5" HEIGHT="5"></TD>
								<TD HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/T.gif" WIDTH="100%" HEIGHT="5"></TD>
								<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-T-R.gif" WIDTH="5" HEIGHT="5"></TD>
							</TR>
							<TR>
								<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/L2.gif"></TD>
								<TD VALIGN="middle">
									<TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="1" >
									<TR >
										<TD nowrap><iframe id="viewframe" src="" width="100%" height="300"  name="detail1" ></iframe></TD>
									</TR>
									</TABLE>
								</TD>
								<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/R2.gif"></TD>
							</TR>
							<TR>
								<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-B-L.gif" WIDTH="5" HEIGHT="5"></TD>
								<TD HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/B.gif" WIDTH="100%" HEIGHT="5"></TD>
								<TD WIDTH="5" HEIGHT="5"><IMG SRC="../IMAGES/MYNOTE/C-B-R.gif" WIDTH="5" HEIGHT="5"></TD>
							</TR>
							</TABLE>

							<!----- SHOW VIEW ---->	
							<BR>
							<span id="view_leave"></span>
							
							
						<!-- End Code -->
					  <br>
<%=md.getRemarkDocument()%>
                      <br>
<%=md.getWorkflowCommandDocument()%>
					<br>
<%=md.getReferenceNoteDocument()%>
					<br>
<%=md.getAttachFileDocument()%>
					<br>
                      <!-- Begin Workflow Button -->
                      <%
           				if( !md.isStep3 ){
           				%>
                      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <%
           						if(md.isStep1 || md.isDraft){
           				%>
                          <td><div align="right">
<!--                           			<A HREF="JavaScript:SaveDraft();">
                                    <IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_SAVE.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A>
									<A HREF="JavaScript:DelDraft();">
                                    <IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_CANCEL.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A> -->
									<a href="JavaScript:preGoWF();">
                                    <img src="../IMAGES/MYNOTE/BUTTON/BUTTON_SUBMIT.gif" width="89" height="37" border="0"  id="imgSubmit"></a></div></td>
       				      <%
           						}else if( md.isStepCancel || md.isAdminCancel){
           				%>
                          <td><div align="right"><!-- <a href="JavaScript:DelWF();"><img src="../IMAGES/MYNOTE/BUTTON/BUTTON_EDIT.gif" width="89" height="37" border="0"></a> --><a href="JavaScript:DelWF();"><img src="../IMAGES/MYNOTE/BUTTON/BUTTON_CANCEL.gif" width="89" height="37" border="0"></a></div></td>
       				      <%
           						}else if( md.isStep2 || md.isStepComment ){
           				%>
                          <td><div align="right"><a href="JavaScript:preSubmit();"><img id="btnsubmit" src="../IMAGES/MYNOTE/BUTTON/BUTTON_SUBMIT.gif" width="89" height="37" border="0"></a></div></td>
       				      <%
           						}else if( md.isStepReturn ){
           				%>
           							<TD><DIV ALIGN="right"><A HREF="JavaScript:EditWF();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_EDIT.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A><A HREF="JavaScript:DelWF();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_CANCEL.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A></DIV></TD>
           				<%
           						}else if( md.isStepCopy ){
           				%>
           							<TD><DIV ALIGN="right"><A HREF="JavaScript:CopyWF();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_EDIT.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A></DIV></TD>
						<%
           						}else if( md.isAdminEdit ){
           				%>
									<TD><DIV ALIGN="right"><A HREF="JavaScript:AdminEditWF();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_SAVE.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A></DIV></TD>
						<%
           						}else if( md.isAdminDelete ){
           				%>
									<TD><DIV ALIGN="right"><A HREF="JavaScript:AdminDeleteWF();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_DELETE.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A></DIV></TD>
						<%
           						}else if( md.isAdminClean ){
           				%>
									<TD><DIV ALIGN="right"><A HREF="JavaScript:AdminCleanWF();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_CLEAN.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A></DIV></TD>
						<%
           						}
           				%>
           			
                          </tr>
                        </table>
						<%}%>
   					    <br>
                      <!-- End Workflow Button -->
					
<%=md.getRoutingDocument()%>
					<br>
<%=md.getCommentDocument()%>						
						<!-- Begin Set Value -->
           				<%
           				if(md.isStep1){
           				%>
           					<!-- Begin Set Value Step1 -->
           					<SCRIPT LANGUAGE="JavaScript">
						 		getInitiatorLevel();
								initiframe("<%=chkNull.chkNullString(request.getParameter("__wf__employeeid"))%>");
								setValue('priority','<%=chkNull.chkNullString(request.getParameter("priority"),"0")%>');
           						setValue('comments','<%=chkNull.chkNullString(request.getParameter("comments"))%>');
           						setValue('chk_calculate','<%=chkNull.chkNullString(request.getParameter("chk_calculate"))%>');
           						setValue('__wf__emp_every','<%=chkNull.chkNullString(request.getParameter("__wf__emp_every"))%>');
								
								setValue('__wf__st_period','<%=chkNull.chkNullString(request.getParameter("__wf__st_period"),"0")%>');
								setValue('__wf__en_period','<%=chkNull.chkNullString(request.getParameter("__wf__en_period"),"1")%>');
								setValue('__wf__leave_hour','<%=chkNull.chkNullString(request.getParameter("__wf__leave_hour"),"0.00")%>');
								setValue('__wf__leave_day','<%=chkNull.chkNullString(request.getParameter("__wf__leave_day"),"0")%>');
								setValue('__wf__type_absent','<%=chkNull.chkNullString(request.getParameter("__wf__type_absent"))%>');
								
								setValue('__wf__absent_tdesc','<%=chkNull.chkNullString(request.getParameter("__wf__absent_tdesc"))%>');
           						setValue('__wf__absent_edesc','<%=chkNull.chkNullString(request.getParameter("__wf__absent_edesc"))%>');
								
								chkGuarantee(document.getElementById("__wf__type_absent"));
								
								//getListTypeAbsent('<%=chkNull.chkNullString(request.getParameter("__wf__type_absent"))%>','');
								searchEmp();
           					</SCRIPT>
           					<!-- End Set Value Step1 -->
           				<%
           				}else if(md.isStep2 || md.isStepCancel || md.isStepComment || md.isStepReturn || md.isStepCopy || md.isDraft){
							//out.print(md.isStep2+""+md.isStepCancel+""+md.isStepComment+""+md.isStepReturn+""+md.isStepCopy+""+md.isDraft);
           				%>
           					<!-- Begin Set Value Step2 -->
           					<SCRIPT LANGUAGE="JavaScript">
								hideSendTo('<%=step_type%>');
								visibleObj(document.getElementById("btnsubmit"), "hidden");

								setValue('priority','<%=screenSingle.getDataLabel("VW_INCIDENT","PRIORITY")%>');
								setValue('__wf__employeeid','<%=md.getWFDataValue("__wf__employeeid")%>');
								setValue('__wf__absentid','<%=md.getWFDataValue("__wf__absentid")%>');
								setValue('__wf__emp_request','<%=md.getWFDataValue("__wf__emp_request")%>');
								setValue('__wf__type_absent','<%=md.getWFDataValue("__wf__type_absent")%>');
								setValue('__wf__cause_absent','<%=md.getWFDataValue("__wf__cause_absent")%>');
								setValue('__wf__start_date','<%=md.getWFDataValue("__wf__start_date")%>');
								setValue('__wf__end_date','<%=md.getWFDataValue("__wf__end_date")%>');
								setValue('__wf__start_time','<%=md.getWFDataValue("__wf__start_time")%>');
								setValue('__wf__end_time','<%=md.getWFDataValue("__wf__end_time")%>');
								setValue('__wf__format_leave','<%=md.getWFDataValue("__wf__format_leave")%>');
								setValue('__wf__leave_hour','<%=md.getWFDataValue("__wf__leave_hour")%>');
								//setValue('__wf__leave_minute','<%=md.getWFDataValue("__wf__leave_minute")%>')
								setValue('__wf__leave_day','<%=md.getWFDataValue("__wf__leave_day")%>');
								setValue('__wf__limitleave','<%=md.getWFDataValue("__wf__limitleave")%>');
								
								//setValue('__wf__list_min','<%=md.getWFDataValue("__wf__list_min")%>');
								//setValue('__wf__list_hours','<%=md.getWFDataValue("__wf__list_hours")%>');
								setValue('__wf__emp_every','<%=md.getWFDataValue("__wf__emp_every")%>');

								setValue('__wf__st_period','<%=md.getWFDataValue("__wf__st_period")%>');
								setValue('__wf__en_period','<%=md.getWFDataValue("__wf__en_period")%>');
								setValue('__wf__type_absent','<%=md.getWFDataValue("__wf__type_absent")%>');

								/* auto assign workflow */
								setValue('__wf__auto_ass_empid','<%=md.getWFDataValue("__wf__auto_ass_empid")%>');
								setValue('__wf__auto_ass_empiddesc','<%=md.getWFDataValue("__wf__auto_ass_empiddesc")%>');

								setValue('__wf__absent_tdesc','<%=md.getWFDataValue("__wf__absent_tdesc")%>');
								setValue('__wf__absent_edesc','<%=md.getWFDataValue("__wf__absent_edesc")%>');
								
								setValue('chk_calculate','cal');
								initiframe("<%=md.getWFDataValue("__wf__employeeid")%>");
								searchDescEmp(document.cscform.__wf__employeeid,  'memployee.fullname:MEMPLOYEE@FULLNAME,mposition.tdesc:__position,mbu1.tdesc:__bu1,mbu2.tdesc:__bu2,mbu3.tdesc:__bu3,mbu4.tdesc:__bu4,mbu5.tdesc:__bu5,memployee.startdate:__startdate,memployee.tel_ext:__tel_ext,memployee.emp_every:__wf__emp_every', "");
							<%
								if(!md.isDraft){
							%>
								setDisabled(true);
								//setReadOnly2(true);
							<%
									}else{
							%>
								setValue('__checkPage','false');
							<%
							}
							%>
           						setReadOnlyOn('__remark'); 
								setTimeout( function() { 
									visibleObj(document.getElementById("btnsubmit"), "visible"); 
								}, 4000 );
           					</SCRIPT>
           					<!-- End Set Value Step2 -->
           				<%
           				}else if(md.isStep3 || md.isAdminEdit || md.isAdminCancel || md.isAdminDelete || md.isAdminClean || md.isArchive){
           				%>
           					<!-- Begin Set Value Step3 -->
           					<SCRIPT LANGUAGE="JavaScript">
								isNoSebject = true;

								//getListTypeAbsent('<%=md.getWFDataValue("__wf__type_absent")%>','disabled');
								setValue('__wf__employeeid','<%=md.getWFDataValue("__wf__employeeid")%>');
								setValue('__wf__absentid','<%=md.getWFDataValue("__wf__absentid")%>');
								setValue('__wf__emp_request','<%=md.getWFDataValue("__wf__emp_request")%>');
								setValue('__wf__cause_absent','<%=md.getWFDataValue("__wf__cause_absent")%>');
								setValue('__wf__start_date','<%=md.getWFDataValue("__wf__start_date")%>');
								setValue('__wf__end_date','<%=md.getWFDataValue("__wf__end_date")%>');
								setValue('__wf__start_time','<%=md.getWFDataValue("__wf__start_time")%>');
								setValue('__wf__end_time','<%=md.getWFDataValue("__wf__end_time")%>');
								setValue('__wf__format_leave','<%=md.getWFDataValue("__wf__format_leave")%>');
								setValue('__wf__leave_hour','<%=md.getWFDataValue("__wf__leave_hour")%>');
							//	setValue('__wf__leave_minute','<%=md.getWFDataValue("__wf__leave_minute")%>')
								setValue('__wf__leave_day','<%=md.getWFDataValue("__wf__leave_day")%>');
								setValue('__wf__limitleave','<%=md.getWFDataValue("__wf__limitleave")%>');

								//setValue('__wf__list_min','<%=md.getWFDataValue("__wf__list_min")%>');
								//setValue('__wf__list_hours','<%=md.getWFDataValue("__wf__list_hours")%>');
								setValue('__wf__emp_every','<%=md.getWFDataValue("__wf__emp_every")%>');

								setValue('__checkPage','false');
								setValue('priority','<%=screenSingle.getDataLabel("VW_INCIDENT","PRIORITY")%>');

								setValue('__wf__st_period','<%=md.getWFDataValue("__wf__st_period")%>');
								setValue('__wf__en_period','<%=md.getWFDataValue("__wf__en_period")%>');
								setValue('__wf__type_absent','<%=md.getWFDataValue("__wf__type_absent")%>');

								/* auto assign workflow */
								setValue('__wf__type_absent','<%=md.getWFDataValue("__wf__auto_ass_empid")%>');
								setValue('__wf__type_absent','<%=md.getWFDataValue("__wf__auto_ass_empiddesc")%>');

								setValue('__wf__absent_tdesc','<%=md.getWFDataValue("__wf__absent_tdesc")%>');
								setValue('__wf__absent_edesc','<%=md.getWFDataValue("__wf__absent_edesc")%>');
								
								initiframe("<%=md.getWFDataValue("__wf__employeeid")%>");
								searchDescEmp(document.cscform.__wf__employeeid,  'memployee.fullname:MEMPLOYEE@FULLNAME,mposition.tdesc:__position,mbu1.tdesc:__bu1,mbu2.tdesc:__bu2,mbu3.tdesc:__bu3,mbu4.tdesc:__bu4,mbu5.tdesc:__bu5,memployee.startdate:__startdate,memployee.tel_ext:__tel_ext,memployee.emp_every:__wf__emp_every', "");
								
							<%
								if(!md.isAdminEdit){
							%>
								setDisabled(true);
							<%
									}
							%>
								setLeaveTitle();
           					</SCRIPT>
           					<!-- End Set Value Step3 -->
           				<%
           				}
           				%>
           				<!-- End Set Value -->
						</DIV>
					</TD>
					<TD VALIGN="top" BACKGROUND="../IMAGES/MYNOTE/BPM_07.jpg">&nbsp;</TD>
				</TR>
				<TR>
					<TD COLSPAN="2" HEIGHT="20" BACKGROUND="../IMAGES/MYNOTE/BPM_09.jpg"><DIV ALIGN="center"><SPAN CLASS="txt02">&nbsp;</SPAN></DIV></TD>
				</TR>
			</TABLE>
			<%=screenSingle.endJSP()%>
			<SCRIPT LANGUAGE="JavaScript">setLeaveDescritption_withDelay();</SCRIPT>
            <INPUT TYPE="hidden" NAME="__wf__initiator_level" ID ="__wf__initiator_level" VALUE="<%=(!md.getWFDataValue("__wf__initiator_level").equals(""))?md.getWFDataValue("__wf__initiator_level"):request.getParameter("__wf__initiator_level")%>">
			<INPUT TYPE="hidden" NAME="__wf__start_doc_date" ID ="__wf__start_doc_date" VALUE="<%=(!md.getWFDataValue("__wf__start_doc_date").equals(""))?md.getWFDataValue("__wf__start_doc_date"):request.getParameter("__wf__start_doc_date")%>">
			<div style="display:NONE">
				<input type="radio" name="__wf__format_leave" value="0">
				<input type="radio" name="__wf__format_leave" value="1">
				<input type="radio" name="__wf__format_leave" value="2">
				<input type="radio" name="__wf__format_leave" value="3">
			</div>
		</FORM>		
	</BODY>
</HTML>
<%}%>