<%@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.ManageDocumentService"%>
<%@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.*"%>
<%@page import="com.csc.library.components.*"%>

<%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="appname" value="welfare" />
<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 isStepReturn = 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())));
	ManageDocumentService md = new ManageDocumentService();
	md.setUProfile(screenSingle.getUProfile());
	md.setRequest(request);
	md.setScreen(screenSingle);
	md.setTableSize("100%");

	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 if(chkNull.chkNullString(request.getParameter("draft_cmd")).equals("save") || chkNull.chkNullString(request.getParameter("draft_cmd")).equals("delete")){
			response.sendRedirect("../EMPVIEW/INDEX.jsp");
		}else{
			response.sendRedirect("../EMPVIEW/INDEX.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();
		}
	}
%>
<!-- End useBean -->

<HTML>
	<HEAD>
		<TITLE>myNOTE : Business Process Management Service</TITLE>
		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
		<!-- Begin Link -->
		<!-- Begin CSS Links -->
		<LINK REL="stylesheet" TYPE="text/css" HREF="../CSS/DDMENU.css" />
		<LINK REL="stylesheet" TYPE="text/css" HREF="../CSS/EMV_DEFAULT.css" />
		<LINK REL="stylesheet" TYPE="text/css" HREF="../CSS/EMV_LAYOUT.css" />
		<LINK REL="stylesheet" TYPE="text/css" HREF="../CSS/EMV_LAYOUT_TWO.css" />
		<LINK REL="stylesheet" TYPE="text/css" HREF="../CSS/EMV_TEXT.css" />
		<LINK HREF="../CSS/MYNOTE.css" REL="stylesheet" TYPE="text/css">

<!-- 		<LINK REL="stylesheet" TYPE="text/css" HREF="../CSS/MYNOTE_SME.css" /> -->
		<!-- End CSS Links -->
		<!-- End Link -->
		<!-- Begin Import Script -->
		<!-- Begin script for Dropdown Menu -->
		<!-- DO NOT EDIT -->
		<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="../JS/EVENTS.js"></SCRIPT>
		<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="../JS/DDMENU.js"></SCRIPT>
		<!--[if lt IE 7]><script language="JavaScript" type="text/javascript" src="../JS/IEHOVER-FIX.js"></script><![endif]-->
		<!-- DO NOT EDIT -->
		<!-- End script for Dropdown Menu -->
		<SCRIPT LANGUAGE="JavaScript" TYPE='text/JavaScript' SRC='../JS/UTILITIES.js'></SCRIPT>
		<SCRIPT LANGUAGE="JavaScript" TYPE='text/JavaScript' SRC='../JS/ACTIVE_OBJECT.js'></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 src="../JS/PRINTPAGE.js"></script>							
		<SCRIPT LANGUAGE="JavaScript">setLang('<%=screenSingle.getUProfile().get("lang")%>');</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/ManageDocumentDWR.js"></script>
		<script type='text/javascript' src='/hr/dwr/interface/Borrow.js'> </script>  
		<!--DWR INCLUDE-->
		<SCRIPT LANGUAGE="JavaScript" TYPE="text/JavaScript">
		<!--
			ThaiCode[314]="กรุณาระบุข้อมูลรายละเอียดการยืมเงิน";
			EngCode[314]="Please input detail";		
			ThaiCode[315]="จำนวนเงินยืมมากกว่าจำนวนเงินที่ขออนุมัติ";
			EngCode[315]="Borrow money over money approve";		
			ThaiCode[316]="เงินยืม";
			EngCode[316]="Borrow money";		
			ThaiCode[317]="เงินที่ขออนุมัติ";
			EngCode[317]="Approve money";		
			ThaiCode[318]="(ปฏิบัติงานบนแท่น)";
			EngCode[318]="(pedestal cost)";		
			ThaiCode[319]="(ค่าเบี้ยเลี้ยง)";
			EngCode[319]="(allowance cost)";		
			ThaiCode[320]="(ค่าที่พัก)";
			EngCode[320]="accommodation cost";		
			ThaiCode[321]="(ค่าพาหนะ)";
			EngCode[321]="(vehicle cost)";		
			ThaiCode[322]="(ค่าเครื่องบิน)";
			EngCode[322]="(plane cost)";		
			ThaiCode[323]="(ค่าชุดเครื่องแบบ)";
			EngCode[323]="(dress cost)";		
			ThaiCode[324]="(ค่าเรือ)";
			EngCode[324]="(boat cost)";		
			ThaiCode[325]="(ค่าธรรมเนียมอบรม)";
			EngCode[325]="(train cost)";		
			ThaiCode[326]="(ค่าแท็กซี่)";
			EngCode[326]="(taxi cost)";		
			ThaiCode[327]="(ค่าเสี่ยงภัย)";
			EngCode[327]="(spacial cost)";		
			ThaiCode[328]="(ค่ารถทัวร์)";
			EngCode[328]="(coachbus cost)";		
			

		    var msg="";
			
			setPageTitle(swap2String("Travel borrowed and expend"));			
			function alertError(errorid){
				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 != "" ){
						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="job='"+condition+"'";
						__fixCon.value="EMPLOYEEID IN ('"+condition+"')";
					 	helpReturn="wf_next_actor:EMPLOYEEID,sendto:FULLNAME";
						//linkHelp_SendToReturn(helpName,helpReturn);
						linkHelp_Return(helpName,helpReturn);
						__fixCon.value=temp;
					}else if( inputName == "cc" ){
						temp = __fixCon.value;
						helpReturn="wf_cc_actor:EMPLOYEEID,cc:FULLNAME";
						linkHelp_SendToReturn(helpName,helpReturn);
						//linkHelp_Return(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=="__wf__expendid"){
							temp = __fixCon.value;
							__fixCon.value="expendid in (select  expendid from texpend_emp where employeeid='"+__wf__employeeid.value+"' and bstatus!='1')";
							helpReturn=inputName+":expendid";
							linkHelp_Return_search(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="EMV_PRU084.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_search(help,input){
				with( document.cscform ){
					var param="BROWSE_WELFAREHELP.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="EMV_PRU084.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 searchEmp(){
				var condition = " AND STATUS not in('X','Y','Z')";
				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,mjobcode.jobgroup:__wf__jobgroupid,mjobcode.tdesc:__wf__jobgroupdesc,memployee.tel_ext:__wf__phone,memployee.mobile:__wf__mobile', condition);
			}
			function chkAttachFile(){
				with(document.cscform){
					var msg = "Please Attach File";
					if(__language.value == "tha") msg = "กรุณาแนบไฟล์หนังสือรับรอง";
					if((parseInt(__wf__leave_day.value) >= parseInt(__guarantee_date.value)) && dwr.util.getValue("__wf__format_leave") == "0" &&(__attach_value.value == "1")) {
						if(!CheckAttachFile()){
							alert(msg);						
							return true;
						}else return true;
					}else{
						return true;
					}
				}
			}
			function showRouting(show){
				with(document.cscform){
					ManageDocumentDWR.getRouting(new Array(__wf_id.value,__wf_ver.value,wf_seq_no.value,1,1,__wf__employeeid.value,'ALLBJOBSUPERVISOR'),
						function(data){
							__wf__document_routing.value = data[1];
							__wf__document_command_line.value = data[2];
							if( show == true ){
								viewrouting.innerHTML=data[0];
							}else{
								GoWF();
								}
						}
					);
				}
			}
			function searchDescEmp(empid, desc, condition){
				var splitDesc="",getField="",setField="";
				splitDesc = desc.split(",");
				for(var i = 0; i < splitDesc.length; i++){
					if(splitDesc[i].indexOf("@") > -1 && splitDesc[i].indexOf(":") == -1){
						if(splitDesc[i].indexOf("$") > -1) {
							var newDesc = splitDesc[i].substring(0,splitDesc[i].indexOf("$"));
							getField += newDesc.replace(/@/g,".");
						}else{
							getField += splitDesc[i].replace(/@/g,".");
						}
						setField += splitDesc[i];
					}else{
						getField += splitDesc[i].substring(0,splitDesc[i].indexOf(":"));
						setField += splitDesc[i].substring(splitDesc[i].indexOf(":")+1,splitDesc[i].length);
					}
					if(i+1 == splitDesc.length){
						break;
					}else{
						getField+=",";
						setField+=",";
					}
				}
				SearchDWR.searchDBXMLAll(new Array("MEMPLOYEEHELP3", getField, "memployee:employeeid = '"+empid.value+"' "+condition, "false", "langOn"), function(data){
					setField = setField.split(",");
					if(data.length > 0){
						for(i=0;i<setField.length;i++){
							dwr.util.setValue(setField[i],data[0][i]);
						}
					}else{
						empid.value ="";
						for(i=0;i<setField.length;i++){
							dwr.util.setValue(setField[i],"");
						}
					}
				});
			}
			function toolTip(data){
			}
			function setTrav_type(){
				with(document.cscform){
					if(trav_type.checked){
						__wf__trav_type.value = "1";
					}else{
						__wf__trav_type.value = "0";
					}
				}
			}
			function chkTravelType(){
				with(document.cscform){
					if(__wf__trav_type.value=="1"){
						trav_type.disabled = false;
					}else{
						trav_type.checked = false;
						trav_type.disabled = true;
						setTrav_type();
					}
				}
			}

function editChild(dateid)
{
	if(document.cscform.__wf__expendid.value.length>0){
		    var generator=window.open("WELEXP002C_INT.jsp?employeeid="+document.cscform.__wf__employeeid.value+"&dateid="+dateid+"&expendid="+document.cscform.__wf__expendid.value+"&isstep1="+document.cscform.isstep1.value,'name','height=530,width=600,scrollbars=yes,resizable=yes,status=yes');
	  }else{
	  		alert(MyCode[0]);
			document.cscform.__wf__expendid.focus();
	  }
}


function addNewChild()
{
	if(document.cscform.__wf__expendid.value.length>0){
		  var generator=window.open("WELEXP002C_INT.jsp?employeeid="+document.cscform.__wf__employeeid.value+"&expendid="+document.cscform.__wf__expendid.value+"&isstep1="+document.cscform.isstep1.value,'name','height=530,width=600,scrollbars=yes,resizable=yes,status=yes');
	  }else{
	  	alert(MyCode[0]);
		document.cscform.__wf__expendid.focus();
	  }
  
}			

function postReturn(){
	with(document.cscform){
	var getField="texpend.expendid,texpend.employeeid,texpend.exp_type,texpend.location_type,texpend.countryid,texpend.provinceid,texpend.startdate,texpend.enddate,texpend.costcenter,texpend.budget,texpend.phone,texpend.mobile,texpend.trav_by,texpend.trav_type,texpend.trav_reason,texpend.totalcost,texpend.oilcost,texpend.travcost,texpend.vehiclecost,texpend.receptioncost,texpend.trainingcost,texpend.other,texpend.othercost,texpend.refdoc,mcostcenter0.tdesc,mbudget_ptt.tdesc";
	var setField="__wf__expendid,__wf__expend_employeeid,__wf__exp_type,__wf__location_type,__wf__countryid,__wf__provinceid,__wf__startdate,__wf__enddate,__wf__costcenter,__wf__budget,__wf__phone,__wf__mobile,__wf__trav_by,__wf__trav_type,__wf__trav_reason,__wf__totalcost,__wf__oilcost,__wf__travcost,__wf__vehiclecost,__wf__receptioncost,__wf__trainingcost,__wf__other,__wf__othercost,__wf__refdoc,mcostcenter0_tdesc,mbudget_ptt_tdesc";
	SearchDWR.searchDBXMLAll(new Array("TEXPENDHELP", getField, "texpend:expendid = '"+__wf__expendid.value+"' ", "false", "langOn"), function(data){
 		setField = setField.split(",");
  		if(data.length > 0){
						for(i=0;i<setField.length;i++){
							dwr.util.setValue(setField[i],data[0][i]);
						}
		}else{
					empid.value ="";
					for(i=0;i<setField.length;i++){
						dwr.util.setValue(setField[i],"");
					}
				}
				if(__wf__trav_type.value){
						trav_type.checked=true;
				}
				if(__wf__employeeid.value==__wf__expend_employeeid.value){
					$("exptr1").style.display = "";
					$("exptr2").style.display = "";
					$("exptr3").style.display = "";
					$("exptr4").style.display = "";
					$("exptr5").style.display = "";
				}else{
					__wf__oilcost.value="0.00";
					__wf__vehiclecost.value="0.00";
					__wf__trainingcost.value="0.00";
					__wf__receptioncost.value="0.00";
					__wf__othercost.value="0.00";
				}
				var summary=parseFloat(__wf__borrow_cost.value.replace(",",""))+parseFloat(__wf__oilcost.value.replace(",",""))+parseFloat(__wf__vehiclecost.value.replace(",",""))+parseFloat(__wf__trainingcost.value.replace(",",""))+parseFloat(__wf__receptioncost.value.replace(",",""))+parseFloat(__wf__othercost.value.replace(",",""));
				dwr.util.setValue("__wf__summarycost",formatCurrency(summary.toFixed(2)));
			    __wf__exp_typedesc.value = __wf__exp_type.options(__wf__exp_type.options.selectedIndex).text;
			 	__wf__location_typedesc.value = __wf__location_type.options(__wf__location_type.options.selectedIndex).text;
				__wf__provincename.value = __wf__provinceid.options(__wf__provinceid.options.selectedIndex).text;
				__wf__countryname.value = __wf__countryid.options(__wf__countryid.options.selectedIndex).text;				
			});
	}
}
	
			function formatCurrency(num) {
					num = num.toString().replace(/\|\,/g,'');
					if(isNaN(num))
						num = "0";
						sign = (num == (num = Math.abs(num)));
						num = Math.floor(num*100+0.50000000001);
						cents = num%100;
						num = Math.floor(num/100).toString();
					if(cents<10)
						cents = "0" + cents;
					for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
						num = num.substring(0,num.length-(4*i+3))+','+
						num.substring(num.length-(4*i+3));
						return (((sign)?'':'-') +  num + '.' + cents);
			}
					
		function init() {
		  dwr.util.useLoadingMessage();
		  fillTable();
		}
		
		var peopleCache = { };
		
		function fillTable() {
		   resetSum();	
		  peopleCache = { };
		  Borrow.getSmallCrowd(function(borrow) {
			// Delete all the rows except for the "pattern" row
			dwr.util.removeAllRows("peoplebody", { filter:function(tr) {
			  return (tr.id != "pattern");
			}}); 
			var borrower, id; 
			var borrowcost=0;
			var __wf__list_record = document.cscform.__wf__list_record;
			var sumnoplane = 0;
			__wf__list_record.value = "";			
			var isstep1= document.cscform.isstep1.value;	
			borrow.sort(function(p1, p2) { return p1.dateid.localeCompare(p2.dateid); });	
			for (var i = 0; i < borrow.length; i++) {
			  borrower = borrow[i];
			  id = borrower.dateid;
			  dwr.util.cloneNode("pattern", { idSuffix:id });
			   if(isstep1=="true")
					 $("__selected"+id).innerHTML="<input type=\"checkbox\" id=\"deleteItem\" value="+borrower.dateid+">";
			   else
					 $("__selected"+id).innerHTML="";
			 $("__dateid"+id).innerHTML="<a href=\"javascript:editClicked('"+borrower.dateid+"')\">"+borrower.dateid+"</a>";
			dwr.util.setValue("totalcost"+id,borrower.totalcost);
		    //sumnoplane+=parseFloat(borrower.totalcost.replace(",",""))-parseFloat(borrower.planecost.replace(",",""));
			borrowcost+=parseFloat(borrower.totalcost.replace(",",""));
			with(document.cscform){
					__wf__sum_pedestalcost.value=parseFloat(__wf__sum_pedestalcost.value)+parseFloat(borrower.pedestalcost.replace(",",""));
					__wf__sum_allowancecost.value=parseFloat(__wf__sum_allowancecost.value)+parseFloat(borrower.allowancecost.replace(",",""));
					__wf__sum_accommodationcost.value=parseFloat(__wf__sum_accommodationcost.value)+parseFloat(borrower.accommodationcost.replace(",",""));
					__wf__sum_vehiclecost.value=parseFloat(__wf__sum_vehiclecost.value)+parseFloat(borrower.vehiclecost.replace(",",""));
					__wf__sum_planecost.value=parseFloat(__wf__sum_planecost.value)+parseFloat(borrower.planecost.replace(",",""));
					__wf__sum_dresscost.value=parseFloat(__wf__sum_dresscost.value)+parseFloat(borrower.dresscost.replace(",",""));
					__wf__sum_boatcost.value=parseFloat(__wf__sum_boatcost.value)+parseFloat(borrower.boatcost.replace(",",""));
					__wf__sum_traincost.value=parseFloat(__wf__sum_traincost.value)+parseFloat(borrower.traincost.replace(",",""));
					__wf__sum_taxicost.value=parseFloat(__wf__sum_taxicost.value)+parseFloat(borrower.taxicost.replace(",",""));
					__wf__sum_spacialcost.value=parseFloat(__wf__sum_spacialcost.value)+parseFloat(borrower.spacialcost.replace(",",""));
					__wf__sum_coachbuscost.value=parseFloat(__wf__sum_coachbuscost.value)+parseFloat(borrower.coachbuscost.replace(",",""));
			}
			for(key in borrower){
					if(key != "$dwrClassName"){
						$(key+id).value = eval("borrower."+key);
						$(key+id).name = "__wf__texpend_borrow_emp$"+key+"$"+id;
					}    
			}
		
		
			 document.getElementById("pattern" + id).style.display = "";  // officially we should use table-row, but IE prefers "" for some reason
			 peopleCache[id] = borrower;
			 __wf__list_record.value += ((__wf__list_record.value != "")?",":"")+id;
			}
			document.cscform.__wf__totaldate.value=borrow.length;
			document.cscform.__wf__borrow_cost.value=formatCurrency(borrowcost);
			sumnoplane=borrowcost;
			document.cscform.__wf__borrow_cost_noplane.value=sumnoplane;
			var summ=sumTotalCost();
			document.cscform.__wf__borrow_cost_noplane.value=formatCurrency(sumnoplane+summ);	
		  });
		}

		function sumTotalCost(){
			with(document.cscform){
				var ocost=parseFloat(__wf__oilcost.value.replace(",",""));
				var bcost=parseFloat(__wf__borrow_cost.value.replace(",",""));
				var vcost=parseFloat(__wf__vehiclecost.value.replace(",",""));
				var trcost=parseFloat(__wf__trainingcost.value.replace(",",""));
				var reccost=parseFloat(__wf__receptioncost.value.replace(",",""));
				var otcost=parseFloat(__wf__othercost.value.replace(",",""));	
				var noplane=parseFloat(__wf__borrow_cost_noplane.value.replace(",",""));	
				var sum=ocost+vcost+trcost+reccost+otcost;				
				__wf__summarycost.value=formatCurrency(bcost+sum);	
				return sum;
				}
		}		
		
		function writeBorrow(borrower) {
		  dwr.engine.beginBatch();
		  Borrow.setBorrower(borrower);
		  fillTable();
		  dwr.engine.endBatch();
		}
		
		function clearBorrower() {
		  dwr.engine.beginBatch();
		  Borrow.clear();
		  dwr.engine.endBatch();
		}
		
		
		function editClicked(eleid) {
		  editChild(eleid);
		}
		
		function deleteClicked(eleid) {
		  var borrower = peopleCache[eleid.substring(6)];
		  if (confirm("Are you sure you want to delete " + borrower.dateid + "?")) {
			dwr.engine.beginBatch();
			Borrow.deleteBorrower(borrower.dateid);
			fillTable();
			dwr.engine.endBatch();
		  }
		}
		
		function deleteed(eleid) {
		  var borrower = peopleCache[eleid]; 
			dwr.engine.beginBatch();
			Borrow.deleteBorrower(borrower.dateid);
			fillTable();
			dwr.engine.endBatch();
		}
		
		function deleteItems(){
				var dellist= new Array();
				if (confirm("Are you sure you want to delete ?")) {
				with(document.cscform){
						for(var i=0;i<elements.length;i++){ 
							 if(elements[i].id=="deleteItem" && elements[i].checked){
										dellist[dellist.length]=elements[i].value;
								   }
							 }
						}				
				}
				for(var i=0;i<dellist.length;i++){
						deleteed(dellist[i]);
				}
		}
		
		function loadData(dateid){
			  var borrower = peopleCache[dateid]; 
			  return 	borrower;
		}
		
		function checkValid(){
						with(document.cscform){
								if(__wf__expendid.value.length==0){
										alert(MyCode[0]);
										__wf__expendid.focus();
										return false;
								}else if(parseFloat(__wf__othercost.value.replace(",",""))>0 &&__wf__other.value.length==0){
										alert(MyCode[0]);
										__wf__other.focus();
										return false;										
								}
								var blank=true;
										for( key in peopleCache){
												blank=false;
										}
										if(blank){
												alert(MyCode[314]);
												return false;
										}
								
						}
					return true;
		}
				
		function GoWF1(){
				if(checkValid()){		
					dwr.engine.beginBatch();					
					getBorrowed();					
					dwr.engine.endBatch();
				}	
		}
		
			function getBorrowed(){
			msg="";
			with(document.cscform){			
			SearchDWR.searchDBXMLAll(new Array("TEXPEND_EMPHELP", "texpend_emp.budget_cost,texpend_emp.pedestalcost,texpend_emp.allowancecost,texpend_emp.accommodationcost,texpend_emp.vehiclecost,texpend_emp.planecost,texpend_emp.dresscost,texpend_emp.boatcost,texpend_emp.traincost,texpend_emp.taxicost,texpend_emp.spacialcost,texpend_emp.coachbuscost", "texpend_emp:employeeid = '"+__wf__employeeid.value+"' and expendid='"+__wf__expendid.value+"'", "false", "langOn"), function(data){
							var summ=sumTotalCost();
							var sumnoplane=parseFloat(__wf__borrow_cost_noplane.value.replace(",",""));
							var sumall=sumnoplane+summ;
							if(data.length>0){
									/*if(parseFloat(data[0][0].replace(",",""))<parseFloat(__wf__summarycost.value.replace(",",""))){
													msg=MyCode[315]+"\n"+MyCode[316]+"  "+formatCurrency(sumall)+"\n"+MyCode[317]+"  "+formatCurrency(data[0][0].replace(",",""))+"\n";
									}*/
									msg+=checkbyItem("__wf__sum_pedestalcost",parseFloat(data[0][1]),318);
									msg+=checkbyItem("__wf__sum_allowancecost",parseFloat(data[0][2]),319);
									msg+=checkbyItem("__wf__sum_accommodationcost",parseFloat(data[0][3]),320);
									msg+=checkbyItem("__wf__sum_vehiclecost",parseFloat(data[0][4]),321);
									msg+=checkbyItem("__wf__sum_planecost",parseFloat(data[0][5]),322);
									msg+=checkbyItem("__wf__sum_dresscost",parseFloat(data[0][6]),323);
									msg+=checkbyItem("__wf__sum_boatcost",parseFloat(data[0][7]),324);
									msg+=checkbyItem("__wf__sum_traincost",parseFloat(data[0][8]),325);
									msg+=checkbyItem("__wf__sum_taxicost",parseFloat(data[0][9]),326);
									msg+=checkbyItem("__wf__sum_spacialcost",parseFloat(data[0][10]),327);
									msg+=checkbyItem("__wf__sum_coachbuscost",parseFloat(data[0][11]),328);
									
							}
							if(msg.length==0){
								alert("เมื่อท่านทำการยืมเงินท่านจะไม่สามารถทำการออกรายงานเป็นกลุ่มได้ \n กรุณาออกใบเสร็จแยก");
								__wf__borrow_cost_noplane.value=formatCurrency(sumnoplane+summ);			
								showRouting(false);											
							}else{
								alert(MyCode[315]+"\n---------------------------------\n"+msg);
							}
					});
				}
			}
		
		function checkbyItem(fieldname,fdata,pos){
				with(document.cscform){
						if(parseFloat(eval(fieldname+".value"))>fdata){
								return MyCode[pos]+"\n"+MyCode[316]+"  "+formatCurrency(eval(fieldname+".value"))+"   "+MyCode[317]+"  "+formatCurrency(fdata)+"\n----------------------------------\n";
						}else{
								return "";
						}
						
				}
		}
		
		function resetSum(){
			with(document.cscform){
					__wf__sum_pedestalcost.value="0";
					__wf__sum_allowancecost.value="0";
					__wf__sum_accommodationcost.value="0";
					__wf__sum_vehiclecost.value="0";
					__wf__sum_planecost.value="0";
					__wf__sum_dresscost.value="0";
					__wf__sum_boatcost.value="0";
					__wf__sum_traincost.value="0";
					__wf__sum_taxicost.value="0";
					__wf__sum_spacialcost.value="0";
					__wf__sum_coachbuscost.value="0";
			}		
		}
				
//-->
		</SCRIPT>
	</HEAD>
	<BODY onLoad="init();">


		<FORM NAME="cscform" METHOD="post" ACTION="WELEXP002_INT.jsp">
			<INPUT TYPE="hidden" NAME="__screen" VALUE="WELEXP002_INT">
			<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="3102">
			<INPUT TYPE="hidden" NAME="__wf_id" VALUE="3102">
			<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").equals("")?screenSingle.getDataLabel("DOC_NO"):chkNull.chkNullString(request.getParameter("__oldDocumentID"),"0"))%>">
			<input type="hidden" name="__oldWF" value="<%=(!screenSingle.getDataLabel("DOC_NO").equals("")?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="remark" VALUE="<%=remark%>">
			<INPUT TYPE="hidden" NAME="__employeeid" VALUE="<%=TEMPLATE_WORKFLOW.getUProfile().get("employeeid") %>">
			<INPUT TYPE="hidden" NAME="__attach_value" VALUE="0">
			<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">

			<!-- 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"))%>">

			<INPUT TYPE="hidden" NAME="__wf__document_routing" VALUE="">
			<INPUT TYPE="hidden" NAME="__wf__document_command_line" VALUE="">
		 <input type="hidden" name="__wf__outoflimit" value="0">
		 <input type="hidden" name="__wf__exp_typedesc">
		 <input type="hidden" name="__wf__provincename">
		 <input type="hidden" name="__wf__countryname">
		 <input type="hidden" name="__wf__location_typedesc">
		 <input type="hidden" name="__wf__jobgroupid" value="<%= chkNull.chkNullString(request.getParameter("__wf_jobgroupid"),"") %>">
		 <input type="hidden" name="__wf__jobgroupdesc" value="<%= chkNull.chkNullString(request.getParameter("__wf__jobgroupdesc"),"") %>">										 
		 <input type="hidden" name="__wf__expend_employeeid">
		<input type="hidden" name="__wf__sum_pedestalcost" value="0">
		<input type="hidden" name="__wf__sum_allowancecost" value="0">
		<input type="hidden" name="__wf__sum_accommodationcost" value="0">
		<input type="hidden" name="__wf__sum_vehiclecost" value="0">
		<input type="hidden" name="__wf__sum_planecost" value="0">
		<input type="hidden" name="__wf__sum_dresscost" value="0">
		<input type="hidden" name="__wf__sum_boatcost" value="0">
		<input type="hidden" name="__wf__sum_traincost" value="0">
		<input type="hidden" name="__wf__sum_taxicost" value="0">
		<input type="hidden" name="__wf__sum_spacialcost" value="0">
		<input type="hidden" name="__wf__sum_coachbuscost" value="0">
			
			<input type="hidden" id="toDay" name="toDay" value="<%=new CscCalendar().getYYYYMMDD()%>">
			<INPUT TYPE="hidden" NAME="__wf__list_record" VALUE="">

			<%=screenSingle.InitialVariable()%>
						 <div id="popmenu" class="menuskin" onMouseover="clearhidemenu();highlightmenu(event,'on')" onMouseout="highlightmenu(event,'off');dynamichide(event)">
</div>

			<DIV ID="toolTipLayer" STYLE="position:absolute; visibility: hidden"></DIV>
			<SCRIPT LANGUAGE="JavaScript">initToolTips();</SCRIPT>
			<TABLE WIDTH="700" BORDER=0 ALIGN="center" CELLPADDING=0 CELLSPACING=0     onMouseover="showmenu(event,linkset[0])" onMouseout="delayhidemenu()">
			<tr>
			<td>			
									<!-- Begin Step1 -->
<%=md.getStepDocument("3102","1")%>
<INPUT TYPE="hidden" NAME="isstep1" VALUE="<%=md.isStep1%>">
<%=md.getHeadDocument()%>
                      <br>
<%=md.getHelpDocument("Travel borrowed and expend")%>
                      <br>
<%=md.getSendToDocument("Travel borrowed and expend")%>
					  <br>
						<!-- Begin Code -->
							<TABLE WIDTH="100%" 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"))%>">
                                              <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="<%= chkNull.chkNullString(request.getParameter("__wf__employeeid"),screenSingle.getUProfile().get("employeeid"))%>"  readonly class="disabled">
										         &nbsp;
										        <input name="MEMPLOYEE@FULLNAME" type="text" size="40" value="<%= chkNull.chkNullString(request.getParameter("MEMPLOYEE@FULLNAME"),"") %>" readonly class="disabled"></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="disabled"></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="disabled"></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="disabled"></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="disabled"></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="disabled"></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="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"),"") %>">
										  
											<%
													DbRecord db_texpend=new InitialRecord(TEMPLATE_WORKFLOW.getUProfile()).getDbRecord("TEXPEND");
													ListBox listbox = new ListBox();
													listbox.setUProfile(TEMPLATE_WORKFLOW.getUProfile());													
											%>
										  <tr>
												<td colspan="2" class="column-title" ><script language="javascript">swapLang('Request_Approve_Detail')</script></td>
										  </tr>
										  <tr>
                                              <td class="column-label"><%=db_texpend.getField("expendid").getDescription()%></td>
										      <td class="column-input">
															<input type="text" name="__wf__expendid" size="20" maxlength="20" value="<%=chkNull.chkNullString(request.getParameter("__wf__expendid"))%>" onKeyPress="chkSpecialStr(event);" onBlur="trimValue(this);"   readonly class="disabled"/>
															<%if(md.isStep1||md.isDraft){%><a href="javascript:goHelp('TEXPENDHELP','__wf__expendid');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__wf__expendid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__wf__expendid_image" width="20" height="20" border="0" align="absmiddle"  ><%}%></a>											  </td>
									      </tr>										  
										   <%
													listbox.setName("wf__exp_type");
													listbox.setValidCode(db_texpend.getField("EXP_TYPE").getValidCode());
													listbox.setDisable("true");
										  %>
										  <tr>
                                              <td class="column-label"><%=db_texpend.getField("EXP_TYPE").getDescription()%></td>
										      <td class="column-input"><%=listbox.process()%></td>
									      </tr>
										   <%
													listbox.setName("wf__location_type");
													listbox.setValidCode(db_texpend.getField("LOCATION_TYPE").getValidCode());
										  %>
										  <tr>
                                              <td class="column-label"><%=db_texpend.getField("LOCATION_TYPE").getDescription()%></td>
										      <td class="column-input"><%=listbox.process()%></td>
									      </tr>
										  <%
													listbox.setName("wf__provinceid");
													listbox.setTable("MPROVINCEHELP","PROVINCEID","LONG_TNAME","","LONG_TNAME","PROVINCEID");
													listbox.setBlank(true);
										  %>
										  <tr>
                                              <td class="column-label"><%=db_texpend.getField("PROVINCEID").getDescription()%></td>
									        <td class="column-input"><%=listbox.process()%></td>
									      </tr>
										  <%
													listbox.setName("wf__countryid");
													listbox.setTable("MCOUNTRYHELP","COUNTRYID","TDESC","","TDESC","COUNTRYID");
													listbox.setBlank(true);
										  %>
										  <tr>
                                              <td class="column-label"><%=db_texpend.getField("COUNTRYID").getDescription()%></td>
										      <td class="column-input"><%=listbox.process()%></td>
									      </tr>
										<tr>
											<td class="column-label"><%=db_texpend.getField("STARTDATE").getDescription()%></td>
										  <td class="column-input">
												<input type="text" name="__wf__startdate" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__startdate"),new CscCalendar().getDDMMYYYY())%>" onKeyPress="chkIntegerOfDate(this.value,event);" onKeyUp="sysIsEdit();formatDate(this);" onBlur="chkInputDate2(this,__wf__enddate);"  readonly class="disabled"/>
											  <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)"></a>											</td>
										</tr>
										<tr>
											<td class="column-label"><%=db_texpend.getField("ENDDATE").getDescription()%></td>
										  <td class="column-input">
												<input type="text" name="__wf__enddate" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__enddate"),new CscCalendar().getDDMMYYYY())%>" onKeyPress="chkIntegerOfDate(this.value,event);" onKeyUp="sysIsEdit();formatDate(this);" onBlur="chkInputDate2(__wf__startdate,this);"  readonly class="disabled"/>											</td>
										</tr>
										<tr>
                                              <td class="column-label"><%=db_texpend.getField("COSTCENTER").getDescription()%></td>
										      <td class="column-input">
												<input type="text" name="__wf__costcenter" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__costcenter"))%>" onKeyPress="chkSpecialStr(event);" onBlur="trimValue(this);" readonly class="disabled"/>												
												<input type="text" name="mcostcenter0_tdesc" size="60" value="<%=chkNull.chkNullString(request.getParameter("mcostcenter0_tdesc"))%>" readonly class="disabled"></td>
									     </tr>
										 <tr style="display:none">
                                              <td class="column-label"><%= db_texpend.getField("BUDGET").getDescription()%></td>
										      <td class="column-input">
												<input type="text" name="__wf__budget" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__budget"))%>" onKeyPress="chkSpecialStr(event);" onBlur="trimValue(this);"  readonly class="disabled"/>
												<a href="javascript:goHelp('MBUDGET_PTTHELP','__budget');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__budget_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"></a>
												<input type="text" name="mbudget_ptt_tdesc" size="60" value="<%=chkNull.chkNullString(request.getParameter("mbudget_ptt_tdesc"))%>"  readonly class="disabled"></td>
									     </tr>
										 <tr>
                                              <td class="column-label"><%= db_texpend.getField("PHONE").getDescription()%></td>
										      <td class="column-input"><input type="text" name="__wf__phone" value="" readonly class="disabled"></td>
									     </tr>
										 <tr>
                                              <td class="column-label"><%= db_texpend.getField("MOBILE").getDescription()%></td>
										      <td class="column-input"><input type="text" name="__wf__mobile" value="" readonly class="disabled"></td>
									     </tr>
										 <%
													listbox.setName("wf__trav_by");
													listbox.setValidCode(db_texpend.getField("TRAV_BY").getValidCode());
													listbox.setonChange("chkTravelType();");
										  %>
										  <tr>
                                            <td class="column-label"><%=db_texpend.getField("TRAV_BY").getDescription()%></td>
										    <td class="column-input"><%=listbox.process()%>
                                                <input type="checkbox" name="trav_type" value="<%=chkNull.chkNullString(request.getParameter("trav_type"))%>"  onclick="setTrav_type();"  disabled>
										      <%= db_texpend.getField("TRAV_TYPE").getDescription()%></td>
										    <input type="hidden" name="__wf__trav_type" value="<%=chkNull.chkNullString(request.getParameter("__wf__trav_type"))%>">
                                          </tr>
										  <tr>
                                              <td class="column-label"><%=db_texpend.getField("exchangerate").getDescription()%></td>
										      <td class="column-input"><INPUT TYPE="text" NAME="__wf__exchangerate" id="__wf__exchangerate" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__exchangerate"),"0.00")%>" MAXLENGTH="10" SIZE="10" class="numeric" onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);" onFocus="callDelComma(this);"><script language="javascript">swapLang('baht per dollar')</script></td>
									     </tr>
										 <!--script language="javascript"> postReturn();</script--->
										 <tr>
										   <td colspan="2" class="column-input">
										   <br>
													   <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" ID="tbChild">
																		  <TR class="row-header">
																			<TD width="9%" ><input type="checkbox" name="chBox" value=""></TD>
																			<TD width="35%" class="column-header" ><script language="javascript">swapLang("Date");</script></TD>
																			<TD width="56%" class="column-header"><script language="javascript">swapLang("Expend cost");</script></TD>
																		  </TR>
																		  <tbody id="peoplebody">
																			<tr id="pattern" style="display:none;">
																			  <td class="columnobject1"><span id="__selected"/> </td>
																			  <td class="columnobject1"><span id="__dateid"></span></td>
																			  <td class="columnobject1"><span id="totalcost"></span> </td>
																				  <input type="hidden" id="expendid">
																				  <input type="hidden" id="employeeid">
																				  <input type="hidden" id="companyid">
																				  <input type="hidden" id="vehiclecost">
																				  <input type="hidden" id="dateid">
																				  <input type="hidden" id="costcenter">
																				  <input type="hidden" id="budget">
																				  <input type="hidden" id="pedestalcost">
																				  <input type="hidden" id="pedestaltype">
																				  <input type="hidden" id="allowancecost">
																				  <input type="hidden" id="accommodationcost">
																				  <input type="hidden" id="accommodationtype">
																				  <input type="hidden" id="budgetdesc">
																				  <input type="hidden" id="costcenterdesc">
																				  <input type="hidden" id="locate_from">
																				  <input type="hidden" id="locate_to">
																				  <input type="hidden" id="locate_fromdesc">
																				  <input type="hidden" id="locate_todesc">
																				  <input type="hidden" id="vehicletype">
																				  <input type="hidden" id="oneway">
																				  <input type="hidden" id="planecost">
																				  <input type="hidden" id="dresscost">
																				  <input type="hidden" id="boatcost">
																				  <input type="hidden" id="traincost">
																				  <input type="hidden" id="taxicost">
																				  <input type="hidden" id="spacialcost">
																				  <input type="hidden" id="coachbuscost">	
																				  <input type="hidden" id="totalcost">																			  
																			</tr>
																		  </tbody>
																		</TABLE></TD>
																		<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/R2.gif"></TD>
																	  </TR>
																	  <TR>
																		<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/L2.gif"></TD>
																		<TD CLASS="column-data" align="center"><BR>
																					<div align="center">
																							<A HREF="javascript:addNewChild()">
																							<%if(md.isStep1||md.isDraft){%>
																							<IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_ADD.gif" WIDTH="89" HEIGHT="37" BORDER="0" ALT="Add" ></A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="javascript:deleteItems()"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_DELETE.gif" WIDTH="89" HEIGHT="37" BORDER="0" ALT="Delete"></A> <%}%><BR>
																		  </div>																					</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>										   </td>
									      </tr>
										 <tr>
                                              <td class="column-label">
                                                <script language="javascript">swapLang('Total day')</script>
                                              </td>
										      <td class="column-input"><input type="text" name="__wf__totaldate" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__totaldate"),"0")%>" onKeyPress="chkInteger(event);" onBlur="checkNumInt(this,0,900000000);" onFocus="callDelComma(this);" readonly class="disabled"/>&nbsp;<script language="javascript">swapLang('Date')</script></td>
									     </tr>
										 <tr>
                                              <td class="column-label"><%= db_texpend.getField("TOTALCOST").getDescription()%></td>
										      <td class="column-input"><input type="hidden" name="__wf__totalcost" value="<%=chkNull.chkNullString(request.getParameter("__wf__totalcost"),"0.00")%>"><input type="text" name="__wf__borrow_cost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__borrow_cost"),"0.00")%>" onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);" onFocus="callDelComma(this);" readonly class="disabled"/>&nbsp;<script language="javascript">swapLang('Bath')</script><input type="hidden" name="__wf__borrow_cost_noplane"  value="<%=chkNull.chkNullString(request.getParameter("__wf__borrow_cost_noplane"),"0.00")%>" /></td>
									     </tr>
										 <tr id="exptr1" style="display:none">
                                              <td class="column-label"><%= db_texpend.getField("OILCOST").getDescription()%></td>
										      <td class="column-input"><input type="text" name="__wf__oilcost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__oilcost"),"0.00")%>"  onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);sumTotalCost();" onFocus="callDelComma(this);" />&nbsp;<script language="javascript">swapLang('Bath')</script></td>
									     </tr>
										 <tr  id="exptr2" style="display:none">
                                              <td class="column-label"><%= db_texpend.getField("VEHICLECOST").getDescription()%></td>
										      <td class="column-input"><input type="text" name="__wf__vehiclecost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__vehiclecost"),"0.00")%>"  onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);sumTotalCost();" onFocus="callDelComma(this);" />&nbsp;<script language="javascript">swapLang('Bath')</script></td>
									     </tr>
										 <tr id="exptr3" style="display:none">
                                              <td class="column-label"><%= db_texpend.getField("trainingcost").getDescription()%></td>
										      <td class="column-input"><input type="text" name="__wf__trainingcost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__trainingcost"),"0.00")%>"  onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);sumTotalCost();" onFocus="callDelComma(this);" />&nbsp;<script language="javascript">swapLang('Bath')</script></td>
									     </tr>
										 <tr id="exptr4" style="display:none">
                                              <td class="column-label"><%= db_texpend.getField("RECEPTIONCOST").getDescription()%></td>
										      <td class="column-input"><input type="text" name="__wf__receptioncost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__receptioncost"),"0.00")%>" onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);sumTotalCost();" onFocus="callDelComma(this);" />&nbsp;<script language="javascript">swapLang('Bath')</script></td>
									     </tr>
										 <tr id="exptr5" style="display:none">
                                           <td class="column-label" nowrap><%= db_texpend.getField("OTHERCOST").getDescription()%>
                                               <input type="text" name="__wf__other"  size="30"></td>
										   <td class="column-input"><input type="text" name="__wf__othercost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__othercost"),"0.00")%>"  onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);sumTotalCost();" onFocus="callDelComma(this);" />
										     &nbsp;<script language="javascript">swapLang('Bath')</script></td>
									      </tr>
										 <tr>
										   <td class="column-label" nowrap>&nbsp;<script language="javascript">swapLang("total expend")</script></td>
										   <td class="column-input"><input type="text" name="__wf__summarycost" size="10" maxlength="10" value="<%=chkNull.chkNullString(request.getParameter("__wf__summarycost"),"0.00")%>" onKeyPress="checkWordNumber(this.value,event);" onKeyUp="sysIsEdit();checkComma(this,2);" onBlur="checkNumFloat(this,0,900000000);" onFocus="callDelComma(this);"readonly class="disabled" /></td>
									      </tr>
										  <input type="hidden" name="priority" value="0">
									<!-- End User Code -->
										</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>
							
							<%if(md.isStep1|| md.isDraft){%>
							<BR>
							<TABLE WIDTH="100%" 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>
											<TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="1" CLASS="txt01">
											<TR>
														<TD class="column-label" width="25%"><script language="javascript">swapLang('Find Workfow Routing')</script>
														</TD>
														<TD class="column-input right"><A HREF="javascript:showRouting(true);"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_PROCESS.gif" WIDTH="89" HEIGHT="37" BORDER="0" ALT="Process"></A>
														</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>
							<span id="viewrouting"></span>
							<%}%>
							
						<!-- End Code -->
					  <br>
<%=md.getRemarkDocument()%>
                      <br>
<%=md.getWorkflowCommandDocument()%>
					<br>
<%=md.getReferenceNoteDocument()%>
					<br>
<%=md.getAttachFileDocument()%>
					<br>
                      <!-- Begin Workflow Button -->
                      <%
           				if( !md.isStep3 ){
           				%>
                      <table width="100%" 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:GoWF1();">
                                    <img src="../IMAGES/MYNOTE/BUTTON/BUTTON_SUBMIT.gif" width="89" height="37" border="0"  id="imgSubmit"></a>
									<%if(md.isDraft){%><A HREF="JavaScript:DelDraft();">
                                    <IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_CANCEL.gif" WIDTH="89" HEIGHT="37" BORDER="0"></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:GoWF();"><img 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">
								if(document.cscform.__wf__expendid.value.length==0){
									clearBorrower();
								}
           						setValue('comments','<%=chkNull.chkNullString(request.getParameter("comments"))%>');
								searchEmp();
								postReturn();
           					</SCRIPT>
           					<!-- End Set Value Step1 -->
           				<%
           				}else if(md.isStep2 || md.isStepCancel || md.isStepComment || md.isStepReturn || md.isStepCopy || md.isDraft){
           				%>
           					<!-- Begin Set Value Step2 -->
           					<SCRIPT LANGUAGE="JavaScript">
								clearBorrower();
								setValue('__wf__employeeid','<%=md.getWFDataValue("__wf__employeeid")%>');
								searchEmp();
								dwr.util.setValue("__wf__expendid","<%=md.getWFDataValue("__wf__expendid")%>");
								dwr.util.setValue("__wf__list_record","<%=md.getWFDataValue("__wf__list_record")%>");
								postReturn();
								dwr.util.setValue("__wf__exp_typedesc","<%=md.getWFDataValue("__wf__exp_typedesc")%>");
								dwr.util.setValue("__wf__location_typedesc","<%=md.getWFDataValue("__wf__location_typedesc")%>");
								dwr.util.setValue("__wf__provincename","<%=md.getWFDataValue("__wf__provincename")%>");
								dwr.util.setValue("__wf__countryname","<%=md.getWFDataValue("__wf__countryname")%>");
								setValue('__wf__exchangerate','<%=md.getWFDataValue("__wf__exchangerate")%>');
								dwr.util.setValue('__wf__document_routing','<%=md.getWFDataValue("__wf__document_routing")%>');
								dwr.util.setValue('__wf__document_command_line','<%=md.getWFDataValue("__wf__document_command_line")%>');																
								dwr.util.setValue('__wf__borrow_cost_noplane','<%=md.getWFDataValue("__wf__borrow_cost_noplane")%>');																
						 <%
								String list[] = md.getWFDataValue("__wf__list_record").split(",");
								String wf_t = "__wf__texpend_borrow_emp";
								for(int i=0; i<list.length; i++){
							%>
							var borrower = { expendid:'<%=md.getWFDataValue(wf_t+"$expendid$"+list[i])%>', employeeid:'<%=md.getWFDataValue(wf_t+"$employeeid$"+list[i])%>', companyid:'<%=md.getWFDataValue(wf_t+"$companyid$"+list[i])%>', dateid:'<%=md.getWFDataValue(wf_t+"$dateid$"+list[i])%>', costcenter:'<%=md.getWFDataValue(wf_t+"$costcenter$"+list[i])%>' , budget:'<%=md.getWFDataValue(wf_t+"$budget$"+list[i])%>', pedestalcost:'<%=md.getWFDataValue(wf_t+"$pedestalcost$"+list[i])%>', pedestaltype:'<%=md.getWFDataValue(wf_t+"$pedestaltype$"+list[i])%>', allowancecost:'<%=md.getWFDataValue(wf_t+"$allowancecost$"+list[i])%>', accommodationcost:'<%=md.getWFDataValue(wf_t+"$accommodationcost$"+list[i])%>', accommodationtype:'<%=md.getWFDataValue(wf_t+"$accommodationtype$"+list[i])%>', budgetdesc:'<%=md.getWFDataValue(wf_t+"$budgetdesc$"+list[i])%>', costcenterdesc:'<%=md.getWFDataValue(wf_t+"$costcenterdesc$"+list[i])%>', locate_from:'<%=md.getWFDataValue(wf_t+"$locate_from$"+list[i])%>', locate_to:'<%=md.getWFDataValue(wf_t+"$locate_to$"+list[i])%>', locate_fromdesc:'<%=md.getWFDataValue(wf_t+"$locate_fromdesc$"+list[i])%>', locate_todesc:'<%=md.getWFDataValue(wf_t+"$locate_todesc$"+list[i])%>', vehicletype:'<%=md.getWFDataValue(wf_t+"$vehicletype$"+list[i])%>', oneway:'<%=md.getWFDataValue(wf_t+"$oneway$"+list[i])%>', vehiclecost :'<%=md.getWFDataValue(wf_t+"$vehiclecost$"+list[i])%>', planecost:'<%=md.getWFDataValue(wf_t+"$planecost$"+list[i])%>', dresscost:'<%=md.getWFDataValue(wf_t+"$dresscost$"+list[i])%>', 	boatcost:'<%=md.getWFDataValue(wf_t+"$boatcost$"+list[i])%>', traincost:'<%=md.getWFDataValue(wf_t+"$traincost$"+list[i])%>', taxicost:'<%=md.getWFDataValue(wf_t+"$taxicost$"+list[i])%>', spacialcost:'<%=md.getWFDataValue(wf_t+"$spacialcost$"+list[i])%>', coachbuscost:'<%=md.getWFDataValue(wf_t+"$coachbuscost$"+list[i])%>',totalcost:'<%=md.getWFDataValue(wf_t+"$totalcost$"+list[i])%>'};
							Borrow.setBorrower(borrower);
							<%
								}
							%>
							<%
								if(!md.isDraft){
							%>
								setDisabled(true);
							<%
									}else{
							%>
								setValue('__checkPage','false');
							<%
							}
							%>
								dwr.util.setValue("__wf__oilcost","<%=md.getWFDataValue("__wf__oilcost")%>");
								dwr.util.setValue("__wf__travcost","<%=md.getWFDataValue("__wf__travcost")%>");
								dwr.util.setValue("__wf__vehiclecost","<%=md.getWFDataValue("__wf__vehiclecost")%>");
								dwr.util.setValue("__wf__receptioncost","<%=md.getWFDataValue("__wf__receptioncost")%>");
								dwr.util.setValue("__wf__trainingcost","<%=md.getWFDataValue("__wf__trainingcost")%>");
								dwr.util.setValue("__wf__other","<%=md.getWFDataValue("__wf__other")%>");
								dwr.util.setValue("__wf__othercost","<%=md.getWFDataValue("__wf__othercost")%>");
           						setReadOnlyOn('__remark');           						
           					</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">
								clearBorrower();
								setValue('__wf__employeeid','<%=md.getWFDataValue("__wf__employeeid")%>');
								searchEmp();
								dwr.util.setValue("__wf__expendid","<%=md.getWFDataValue("__wf__expendid")%>");
								dwr.util.setValue("__wf__list_record","<%=md.getWFDataValue("__wf__list_record")%>");
								postReturn();
								dwr.util.setValue("__wf__exp_typedesc","<%=md.getWFDataValue("__wf__exp_typedesc")%>");
								dwr.util.setValue("__wf__location_typedesc","<%=md.getWFDataValue("__wf__location_typedesc")%>");
								dwr.util.setValue("__wf__provincename","<%=md.getWFDataValue("__wf__provincename")%>");
								dwr.util.setValue("__wf__countryname","<%=md.getWFDataValue("__wf__countryname")%>");								
								setValue('__wf__exchangerate','<%=md.getWFDataValue("__wf__exchangerate")%>');
								var borrowcost=0;
							<%
								String list[] = md.getWFDataValue("__wf__list_record").split(",");
								String wf_t = "__wf__texpend_borrow_emp";
								for(int i=0; i<list.length; i++){
							%>
							var borrower = { expendid:'<%=md.getWFDataValue(wf_t+"$expendid$"+list[i])%>', employeeid:'<%=md.getWFDataValue(wf_t+"$employeeid$"+list[i])%>', companyid:'<%=md.getWFDataValue(wf_t+"$companyid$"+list[i])%>', dateid:'<%=md.getWFDataValue(wf_t+"$dateid$"+list[i])%>', costcenter:'<%=md.getWFDataValue(wf_t+"$costcenter$"+list[i])%>' , budget:'<%=md.getWFDataValue(wf_t+"$budget$"+list[i])%>', pedestalcost:'<%=md.getWFDataValue(wf_t+"$pedestalcost$"+list[i])%>', pedestaltype:'<%=md.getWFDataValue(wf_t+"$pedestaltype$"+list[i])%>', allowancecost:'<%=md.getWFDataValue(wf_t+"$allowancecost$"+list[i])%>', accommodationcost:'<%=md.getWFDataValue(wf_t+"$accommodationcost$"+list[i])%>', accommodationtype:'<%=md.getWFDataValue(wf_t+"$accommodationtype$"+list[i])%>', budgetdesc:'<%=md.getWFDataValue(wf_t+"$budgetdesc$"+list[i])%>', costcenterdesc:'<%=md.getWFDataValue(wf_t+"$costcenterdesc$"+list[i])%>', locate_from:'<%=md.getWFDataValue(wf_t+"$locate_from$"+list[i])%>', locate_to:'<%=md.getWFDataValue(wf_t+"$locate_to$"+list[i])%>', locate_fromdesc:'<%=md.getWFDataValue(wf_t+"$locate_fromdesc$"+list[i])%>', locate_todesc:'<%=md.getWFDataValue(wf_t+"$locate_todesc$"+list[i])%>', vehicletype:'<%=md.getWFDataValue(wf_t+"$vehicletype$"+list[i])%>', oneway:'<%=md.getWFDataValue(wf_t+"$oneway$"+list[i])%>', vehiclecost :'<%=md.getWFDataValue(wf_t+"$vehiclecost$"+list[i])%>', planecost:'<%=md.getWFDataValue(wf_t+"$planecost$"+list[i])%>', dresscost:'<%=md.getWFDataValue(wf_t+"$dresscost$"+list[i])%>', 	boatcost:'<%=md.getWFDataValue(wf_t+"$boatcost$"+list[i])%>', traincost:'<%=md.getWFDataValue(wf_t+"$traincost$"+list[i])%>', taxicost:'<%=md.getWFDataValue(wf_t+"$taxicost$"+list[i])%>', spacialcost:'<%=md.getWFDataValue(wf_t+"$spacialcost$"+list[i])%>', coachbuscost:'<%=md.getWFDataValue(wf_t+"$coachbuscost$"+list[i])%>',totalcost:'<%=md.getWFDataValue(wf_t+"$totalcost$"+list[i])%>'};
							Borrow.setBorrower(borrower);
							<%
								}
							%>
								dwr.util.setValue("__wf__oilcost","<%=md.getWFDataValue("__wf__oilcost")%>");
								dwr.util.setValue("__wf__travcost","<%=md.getWFDataValue("__wf__travcost")%>");
								dwr.util.setValue("__wf__vehiclecost","<%=md.getWFDataValue("__wf__vehiclecost")%>");
								dwr.util.setValue("__wf__receptioncost","<%=md.getWFDataValue("__wf__receptioncost")%>");
								dwr.util.setValue("__wf__trainingcost","<%=md.getWFDataValue("__wf__trainingcost")%>");
								dwr.util.setValue("__wf__other","<%=md.getWFDataValue("__wf__other")%>");
								dwr.util.setValue("__wf__othercost","<%=md.getWFDataValue("__wf__othercost")%>");
							    dwr.util.setValue("__wf__summarycost","<%=md.getWFDataValue("__wf__summarycost")%>");
							<%
								if(!md.isAdminEdit){
							%>
								setDisabled(true);
							<%
									}
							%>
           					</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()%>
				</FORM>
				</TD>
			  </TR>				
		  </TABLE>	
	</BODY>
</HTML>
<%
}
%>