<%@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.*"%>

<%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="TA" />
<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);

//out.print(screenSingle.getUProfile());

	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();
		}
	}
%>
<!-- 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 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 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/Tforgetcard_nstda_dwr.js"></script>
		<!--DWR INCLUDE-->

	<style type=text/css>
		.displayNone{
			display: NONE;
		}
			
	</style>

	<SCRIPT LANGUAGE="JavaScript" TYPE="text/JavaScript">
	<!--
		setPageTitle(swap2String("Swipe Time Request Form"));

		function preGoWF(){
			with( document.cscform ){
				if(__wf__employeeid.value != "" && 
					__wf__start_date.value != "" && 
					__wf__end_date.value != "" && 
					!chkNullValue2("$forget_date$") && 
					!chkNullValue2("$forget_time$")){
					if(!chkIsDupShift()){
						GoWF();
					} else alert(swap2String("Can't Change Shift"));
				} else alert(MyCode[0]);
			}
		}

		function chkIsDupShift(){
			with(document.cscform){
				for(var i=0; i<elements.length; i++){
					if(elements[i].name.indexOf("__wf__tforgetcard1$old_shift$") > -1){
						var line = elements[i].name.substring(elements[i].name.lastIndexOf("$")+1,elements[i].name.length);
						var new_shift = document.getElementById("__wf__tforgetcard1$new_shift$"+line);
						if(elements[i].value == "" || new_shift.value == ""){
							new_shift.focus();
							new_shift.select();
							return true;
						}else{
							if (elements[i].value == new_shift.value){
								new_shift.focus();
								new_shift.select();
								return true;
							}else{
								return false;
							}
						}
					}
				}// end for
			}
		}

		/**
			Create By	: Hunter
			Edit Date	: 29/1/2551
			Description	: Check null value and focus in input.
			Param		: value (ex. 90 min >>> 1.30 hr.)
			Return		: true, false.
		*/
		function chkNullValue2(inputName){
			with(document.cscform) {
				for (i=0; i<elements.length; i++) {
					if (elements[i].name.indexOf(inputName) > -1 && elements[i].value == "") {
						elements[i].focus();
						return true;
					}
				}
			}
		}

		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;
					//__fixCon.value="job='"+condition+"'";
					if( condition.indexOf(",") > -1 ){
						condition = condition.replace(/,/g,"','");
					}
					__fixCon.value="EMPLOYEEID IN ("+condition+")";
				 	helpReturn="wf_next_actor:EMPLOYEEID,sendto:__wf__fullname";
					linkHelp_SendToReturn(helpName,helpReturn);
					__fixCon.value=temp;
				}else if( inputName == "cc" ){
					temp = __fixCon.value;
					helpReturn="wf_cc_actor:EMPLOYEEID,cc:__wf__fullname";
					linkHelp_SendToReturn(helpName,helpReturn);
					__fixCon.value=temp;
				} else if(inputName=="__wf__employeeid"){
						temp = __fixCon.value;
						//__fixCon.value="employeeid = '"+__initiator.value+"'";
						if(__subordinate.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'";
							//__fixCon.value = "employeeid in ("+__subordinate.value+") 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,__wf__fullname,emp_fullname:MEMPLOYEE.FULLNAME";
					linkHelp_Return(helpName,helpReturn);
					__fixCon.value=temp;
				}else if( inputName.indexOf("__reason") > -1 ){
					temp = __fixCon.value;
					__fixCon.value = "";
					helpReturn=inputName+":reasonchangeid,__wf__tforgetcard1$remark"+inputName.substring(inputName.lastIndexOf("$"),inputName.length)+":tdesc";
					linkHelp_Return(helpName,helpReturn);
					__fixCon.value=temp;
				}else if(inputName == "__mreasonid"){
					temp = __fixCon.value;
					__fixCon.value = "";
					helpReturn=inputName+":reasonchangeid,MREASONCHANGE@TDESC";
					linkHelp_Return(helpName,helpReturn);
					__fixCon.value=temp;						
					}
				}
			}

			function goHelp2(helpName,inputName,condition){
				with( document.cscform ){
					var helpReturn;
					var temp;
					if( inputName == "sendto" ){
						temp = __fixCon.value;
						//__fixCon.value="job='"+condition+"'";
						if( condition.indexOf(",") > -1 ){
							condition = condition.replace(/,/g,"','");
						}
						//__fixCon.value="EMPLOYEEID IN ("+condition+")";
						__fixCon.value=condition + " AND STATUS <> 'Y'";
					 	helpReturn="wf_next_actor:EMPLOYEEID,sendto:__wf__fullname";
						linkHelp_SendToReturn(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<>'6' and wf_status<>'3' and wf_status<>'8' and wf_status<>'A' and wf_status<>'B' and wf_status<>'')";
					var param="BROWSE_HELP.jsp?__helpName="+help+"&__fieldSearch="+input+"&__pageCall="+__screen.value+"&__fixCon="+fix;
					window.open(param,"Help","left=150,top=150,width=530,height=370,resizable=yes,scrollbars=yes,toolbar=no,status=yes");
					__fixCon.value = temp;
				}
			}
			
			function linkHelp_Return_CallFunction(help,input,newFunction){
				with( document.cscform ){
					var param="BROWSE_TIMEHELP.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+__fixCon.value+"&__checkVerify=off&__langOn=off&__callFunction="+newFunction;
					window.open(param,"Help","left=150,top=150,width=530,height=370,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
				}
			}			
			
			function chk_Time(){
			var count=0;
				with(document.cscform){
					for (j=0;j<elements.length; j++){
						if(elements[j].name.indexOf("__wf__tforgetcard1$forget_date") > -1){
							if(!isValidDate(elements[j].value)){
								count+=1;
								elements[j].focus();
								elements[j].select();
								break;
							}
						}
						if(elements[j].name.indexOf("__wf__tforgetcard1$forget_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;
					}
				}
			}
				
		-->
	</SCRIPT>
	<script language="javascript">
	<!--
		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");
		}

		function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);
		}
		
		function goView() {
			with (document.cscform) {
				view.innerHTML = "";
				Tforgetcard_nstda_dwr.getDWRDataTtimeErrorService(new Array(__wf__employeeid.value,__wf__start_date.value,__wf__end_date.value), 
				function(data1){
					view.innerHTML=data1;
				});
			}
		}

		function searchEmp(){
			//alert(document.cscform.__subordinate.value);
			//var condition = "and employeeid in("+document.cscform.__subordinate.value+")";  เปิดแล้วมันเจ้ง เทสโฟล์ก่อนค่อยเปิด
			var condition = "";
			searchDescEmp(document.cscform.__wf__employeeid,  'memployee.fullname:__wf__fullname,mposition.tdesc:__wf__position,mbu1.tdesc:__wf__bu1,mbu2.tdesc:__wf__bu2,mbu3.tdesc:__wf__bu3,mbu4.tdesc:__wf__bu4,mbu5.tdesc:__wf__bu5,memployee.startdate:__wf__startdate,memployee.tel_ext:__wf__tel_ext', condition);
		}

		function addRow(line, isStep){
			var tbody = document.getElementById("tbChild").tBodies[0];
			var tr = document.createElement("TR");
			tr.align = "center";
			var tbName = "tforgetcard1";
			
			var cell1 = document.createElement("TD");
			cell1.className = "row-data";
			var spanId = document.createElement("SPAN");
			spanId.id = "line$"+line;
			spanId.innerHTML = line;
			spanId.className = "displayNone";
			var inputLineNo = document.createElement("INPUT");
			inputLineNo.name = "__wf__"+tbName+"$line_no$"+line;
			inputLineNo.id = inputLineNo.name;
			inputLineNo.type = "hidden";
			inputLineNo.value = line;			
			var inputChkBox = document.createElement("INPUT");
			inputChkBox.name = "__wf__"+tbName+"$chk_box$"+line;
			inputChkBox.id = inputLineNo.name;
			inputChkBox.type = "checkbox";
			inputChkBox.value = line;			
			cell1.appendChild(spanId);
			cell1.appendChild(inputLineNo);
			cell1.appendChild(inputChkBox);

			var cell2 = document.createElement("TD");
			cell2.className = "row-data";
			var span2 = document.createElement("SPAN");
			span2.innerHTML = "&nbsp;";
			var inputForgetDate = document.createElement("INPUT");
			inputForgetDate.name = "__wf__"+tbName+"$forget_date$"+line;
			inputForgetDate.id = inputForgetDate.name;
			inputForgetDate.className = "txt01";
			inputForgetDate.type = "text";
			inputForgetDate.size = 10;
			inputForgetDate.maxLength = 10;
			inputForgetDate.onblur = function(){chkInputDate(this)};
			inputForgetDate.onkeyup = function(){formatDate(this)};
			inputForgetDate.onkeypress = function(){chkIntegerOfDate(this.value)};
			var linkCal1 = document.createElement("A");
			linkCal1.href = "javascript:;";
			var imgCal1 = document.createElement("IMG");
			imgCal1.src = "../IMAGES/BUTTON/MAIN/CALENDAR20.gif";
			imgCal1.alt = "Calendar";
			imgCal1.name = "startdate"+line;
			imgCal1.id = "startdate"+line;
			imgCal1.border = 0;
			imgCal1.align = "absmiddle";
			imgCal1.onclick = function(){viewCal(inputForgetDate.name)};
			linkCal1.onmouseout = function(){MM_swapImgRestore()};
			linkCal1.onmouseover = function(){MM_swapImage(imgCal1.name,'','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1);};
			linkCal1.appendChild(imgCal1);
			cell2.appendChild(inputForgetDate);
			if(isStep) { 
				cell2.appendChild(span2);
				cell2.appendChild(linkCal1);
			}

			var cell3 = document.createElement("TD");
			cell3.className = "row-data";
			var inputForgetTime = document.createElement("INPUT");
			inputForgetTime.name = "__wf__"+tbName+"$forget_time$"+line;
			inputForgetTime.id = inputForgetTime.name;
			inputForgetTime.className = "right";
			inputForgetTime.type = "text";
			inputForgetTime.size = 5;
			inputForgetTime.onblur = function(){chkTime(this)};
			inputForgetTime.onkeypress = function(){chkInteger()};
			var labelTime = document.createElement("SPAN");
			labelTime.id = "labelTime$"+line;
			labelTime.innerHTML = "&nbsp;"+"HH.MM";
			cell3.appendChild(inputForgetTime);
			cell3.appendChild(labelTime);

			var cell4 = document.createElement("TD");
			cell4.className = "row-data";
			var span4 = document.createElement("SPAN");
			span4.innerHTML = "&nbsp;";
			var inputReason = document.createElement("INPUT");
			inputReason.name = "__reasonid$"+line;
			inputReason.id = inputReason.name;
			inputReason.type = "hidden";
			var inputRemark = document.createElement("INPUT");
			inputRemark.name = "__wf__"+tbName+"$remark$"+line;
			inputRemark.id = inputRemark.name;
			inputRemark.className = "txt01";
			inputRemark.type = "text";
			inputRemark.size = 70;
			inputRemark.maxLength = 100;
			var linkHelp = document.createElement("A");
			linkHelp.href = "javascript:;";
			var imgHelpReason = document.createElement("IMG");
			imgHelpReason.src = "../IMAGES/BUTTON/MAIN/SEARCH20.gif";
			imgHelpReason.alt = "SEARCH";
			imgHelpReason.align = "absmiddle";
			imgHelpReason.name = "searchReason"+line;
			imgHelpReason.id = "searchReason"+line;
			imgHelpReason.border = 0;
			imgHelpReason.onclick = function(){goHelp("MREASONCHANGEHELP", inputReason.name)};
			imgHelpReason.onmouseover = function(){ MM_swapImage(imgHelpReason.name,'','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1);};
			imgHelpReason.onmouseout = function(){MM_swapImgRestore()};
			linkHelp.appendChild(imgHelpReason);
			cell4.appendChild(inputReason);
			cell4.appendChild(inputRemark);
			if(isStep) { 
				cell4.appendChild(span4);
				cell4.appendChild(linkHelp);
			}

			/*var cell5 = document.createElement("TD");
			cell5.className = "columnobjectcenter";
			var btn = document.createElement("INPUT");
			btn.name = "del$"+line;
			btn.id = btn.name;
			btn.type = "button";
			btn.value = " - ";
			btn.className = "txt01";
			btn.onclick = function(){deleteRow(this)};
			cell5.appendChild(btn);*/

			// appendChild To Row
			tr.appendChild(cell1);
			tr.appendChild(cell2);
			tr.appendChild(cell3);
			tr.appendChild(cell4);
			//if(isStep) tr.appendChild(cell5);
			tbody.appendChild(tr);
			
		}

		function addRowToTable(isStep){
			var line = setValueList();
			//alert(line);
			addRow(line, isStep);
			resetLine();
		}

		function getTimeIn(date,line) {
			with (document.cscform) {
				Tforgetcard_nstda_dwr.getWorkingTime(new Array(__wf__employeeid.value,date.value), 
				function(data1){
					DWRUtil.setValue("__wf__tforgetcard1$forget_time$"+line,data1);
				});
			}
		}
		
		function setValueList(){
			var last_record = document.getElementById("__wf__last_record");
			var list_record = document.getElementById("__wf__list_record");
			var line = last_record.value;
			line++;
			list_record.value += ","+line; 
			last_record.value = parseInt(last_record.value)+1;
			return line;
		}

		function genDate(){
			var employeeid = document.getElementById("__wf__employeeid");
			var listRecord = document.getElementById("__wf__list_record");
			var stDate = document.getElementById("__wf__start_date");
			var enDate = document.getElementById("__wf__end_date");
			var lastRecord = document.getElementById("__wf__last_record");
			//var stDay = stDate.value.split("-");
			//var newDate = new Date(stDay[2], (stDay[1]-1), stDay[0]);
			var endAtLine = parseInt(lastRecord.value);
			var tbName = "tforgetcard1";
			//listRecord.value = "";
			SearchDWR.searchAll(new Array("ttime_current1","employeeid,time0id,dateid,companyid,c_dt_bg,c_dt_en,c_tm_bg,c_tm_en,warn00,warn01",
				"employeeid='"+employeeid.value+"' and (dateid between '"+getYYYYMMDD(stDate.value)+"' and '"+getYYYYMMDD(enDate.value)+"') and (warn00<>'' or warn01<>'')",
				"dateid","langon"),function(data){
					if(data.length > 0){
						//deleteAll();
						delAllRowInTable();						
						for(var i = 0; i<data.length; i++){
							var notswipein = data[i][8];
							var notswipeout = data[i][9];
							//alert(notswipein+" "+notswipeout)
							if (notswipein!="") {
								addRowToTable(true);	
								var last_record = document.getElementById("__wf__last_record");
								DWRUtil.setValue("__wf__"+tbName+"$forget_date$"+last_record.value, data[i][4]);
								DWRUtil.setValue("__wf__"+tbName+"$forget_time$"+last_record.value, data[i][6]);								
							} 
							if (notswipeout!="") {
								addRowToTable(true);	
								var last_record = document.getElementById("__wf__last_record");
								DWRUtil.setValue("__wf__"+tbName+"$forget_date$"+last_record.value, data[i][5]);
								DWRUtil.setValue("__wf__"+tbName+"$forget_time$"+last_record.value, data[i][7]);
							} 	
						}
					}else alert(MyCode[6]);
				}
			);
		}

		function deleteAll(){
			var list = document.getElementById("__wf__list_record");
			var tbody = document.getElementById("tbChild").tBodies[0];
			var sub = list.value.split(",");
			for(var i=1; i<=sub.length; i++){
				var del = document.getElementById("del$"+sub[i]);
				if (tbody.rows.length > 1) tbody.deleteRow(1);
			}
			DWRUtil.setValue("__wf__last_record", 0);			
		}

		function resetLine(){
			var list = document.getElementById("__wf__list_record");
			var sub_list = list.value.split(",");
			for(var i=1; i<sub_list.length; i++){
				var line = document.getElementById("line$"+sub_list[i]);
				line.innerHTML = i;
			}
		}

		function delAllRowInTable() {
			with (document.cscform) {
				for(i=0; i<elements.length; i++){
					if ((elements[i].type=="checkbox") && (elements[i].name!="chBox")) {
						deleteRow(elements[i]);
					}
				}			
			}
		}

		function delRowInTable() {
			var con = confirm(MyCode[4]);
			if (con) {
				with (document.cscform) {
					for(i=0; i<elements.length; i++){
						if ((elements[i].type=="checkbox") && (elements[i].checked==true) && (elements[i].name!="chBox")) {
							deleteRow(elements[i]);
						}
					}
				}
			}
		}

		function deleteRow(btn) {
			var cell, row, sect;
			if((cell = btn.parentNode) && (row = cell.parentNode)&& (sect = row.parentNode) && sect.removeChild){
				row.parentNode.removeChild(cell.parentNode);
				var list_record = document.getElementById("__wf__list_record");
				var line = btn.name.substring(btn.name.lastIndexOf("$")+1, btn.name.length);
				var split_list = list_record.value.split(",");
				for(i = 1; i<split_list.length; i++){
					if(split_list[i] == line)
						list_record.value = list_record.value.replace(","+line,"");			
				}
			}
			resetLine();
		}
		
		function chkBox(checkval){
			with (document.cscform){
				if(checkval.checked){
						for(i=0;i<elements.length;i++){
							if(elements[i].type=="checkbox")
									elements[i].checked=true;
						}//end for
				}else{
					for(i=0;i<elements.length;i++){
						if(elements[i].type=="checkbox")
								elements[i].checked=false;
					}//end for
				}			
			}
		}
//-->
		</SCRIPT>
	</HEAD>
	<BODY>
		<DIV ID="wrapper">
			<DIV ID="header"><jsp:include page="../EMPVIEW/EMV_HEADER.jsp" flush="true" /></DIV>
			<DIV ID="topnav"><jsp:include page="../EMPVIEW/EMV_TOPMENU.jsp" flush="true" /></DIV>
			<DIV ID="container">
				<DIV ID="sidebar"><jsp:include page="../EMPVIEW/EMV_SIDEBAR.jsp" flush="true" /></DIV>
				<DIV ID="content"><jsp:include page="../EMPVIEW/EMV_HELPBAR.jsp" flush="true" />

		<FORM NAME="cscform" METHOD="post" ACTION="TAU_SMEWF_005.jsp">
			<INPUT TYPE="hidden" NAME="__screen" VALUE="TAU_SMEWF_005.jsp">
			<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="8005">
			<INPUT TYPE="hidden" NAME="__wf_id" VALUE="8005">
			<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="<%=chkNull.chkNullString(request.getParameter("__oldDocumentID"),screenSingle.getDataLabel("DOC_NO"))%>">
			<INPUT TYPE="hidden" NAME="__oldWF" VALUE="<%=chkNull.chkNullString(request.getParameter("__oldWF"),screenSingle.getDataLabel("WF_STATUS"))%>">
			
			<INPUT TYPE="hidden" NAME="__wf" VALUE="<%=wf%>">
			<INPUT TYPE="hidden" NAME="__wfcmd" VALUE="false">		
			<INPUT TYPE="hidden" NAME="remark" VALUE="<%=remark%>">
	
			<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"))%>">
			
			<%=screenSingle.InitialVariable()%>
			
			<DIV ID="toolTipLayer" STYLE="position:absolute; visibility: hidden"></DIV>
			<SCRIPT LANGUAGE="JavaScript">initToolTips();</SCRIPT>
			
<%=md.getStepDocument("8005","1")%>
<%=md.getHeadDocument()%>
                      <br>
<%=md.getHelpDocument("Swipe Time Request Form")%>
                      <br>
<%=md.getSendToDocument("Swipe Time 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" CLASS="txt01">
										<!-- Begin User Code -->
											<INPUT TYPE="hidden" NAME="__wf__fscardid" VALUE="0">
											<INPUT TYPE="hidden" NAME="__wf__source" VALUE="5">
											<INPUT TYPE="hidden" NAME="__wf__last_record" ID = "__wf__last_record" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__last_record"),"1")%>">
											<INPUT TYPE="hidden" NAME="__wf__list_record" ID = "__wf__list_record" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__list_record"),",1")%>">
											<INPUT TYPE="hidden" NAME="__subordinate" VALUE="<%=screenSingle.getUProfile().get("subordinateall")%>">
											<INPUT TYPE="hidden" NAME="list_shift" VALUE="<%=chkNull.chkNullString(request.getParameter("list_shift"))%>">
											<INPUT TYPE="hidden" NAME="__wf__emp_request" VALUE="<%=screenSingle.getUProfile().get("actor")%>">
											<tr>
												<td colspan="2" class="column-title"><script language="javascript">swapLang('Employee Details')</script></td>
											</tr>
										  <tr>
											<td width="25%" class="column-label"><script language="javascript">swapLang('Employee Code')</script></td>
											<td width="75%" class="column-input"><input name="__wf__employeeid" id="__wf__employeeid" type="text" size="15" value="<%= chkNull.chkNullString(request.getParameter("__wf__employeeid"),screenSingle.getUProfile().get("employeeid"))%>"  onBlur="javascript:searchEmp()" 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>
												<%}%>
												&nbsp;<input name="__wf__fullname" type="text" size="40" value="<%= chkNull.chkNullString(request.getParameter("__wf__fullname"),"") %>" class="disabled" readonly></td></tr>
										  <tr>
											<td class="column-label"><script language="javascript">swapLang('Position')</script></td>
											<td class="column-input"><input type="text" name="__wf__position" value="<%= chkNull.chkNullString(request.getParameter("__wf__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="__wf__bu1" value="<%= chkNull.chkNullString(request.getParameter("__wf__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="__wf__bu2" value="<%= chkNull.chkNullString(request.getParameter("__wf__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="__wf__bu3" value="<%= chkNull.chkNullString(request.getParameter("__wf__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="__wf__bu4" value="<%= chkNull.chkNullString(request.getParameter("__wf__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="__wf__bu5" value="<%= chkNull.chkNullString(request.getParameter("__wf__bu5"),"") %>" size="52" readonly class="disabled"></td>
										</tr>
										<input type="hidden" name="__wf__startdate" value="<%= chkNull.chkNullString(request.getParameter("__wf__startdate"),"") %>" >
										<input type="hidden" name="__wf__tel_ext" value="<%= chkNull.chkNullString(request.getParameter("__wf__tel_ext"),"") %>">										
									     
										<!-- End User Code -->
											
											<TR>
												<TD COLSPAN="2" CLASS="column-title"><SCRIPT LANGUAGE="javascript">swapLang('Swipe Time Details')</SCRIPT></TD>
								</TR>
								<TR>
												<INPUT TYPE="hidden" NAME="__wf__otid" VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__otid"))%>">
												<TD CLASS="column-label"><SCRIPT LANGUAGE="javascript">swapLang('Start Date')</SCRIPT></TD>
												<TD CLASS="column-input">
												<INPUT TYPE="text" SIZE="8" NAME="__wf__start_date" ID="__wf__start_date" MAXLENGTH=10 VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__start_date"), "01-"+calendar.getMM()+"-"+calendar.getYear()) %>" class="txt01" onKeyup = "formatDate(this)" onBlur = "chkInputDate(this)" onKeypress = "chkIntegerOfDate(this.value)"><%if(md.isStep1){%> 
												<A HREF="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('startdate','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)">
												<IMG SRC="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" ALT="Calendar" NAME="startdate" WIDTH="20"  BORDER="0" ALIGN="absmiddle" ID="Image1311" onClick="viewCal('__wf__start_date')"></A><%}%>
												</TD>
								</TR>
							<TR>
												<TD CLASS="column-label"><SCRIPT LANGUAGE="javascript">swapLang('End Date')</SCRIPT></TD>
												<TD CLASS="column-input">
												<INPUT TYPE="text" SIZE="8" NAME="__wf__end_date" ID="__wf__end_date" MAXLENGTH=10 VALUE="<%=chkNull.chkNullString(request.getParameter("__wf__end_date"), calendar.getDDMMYYYY()) %>" class="txt01" onKeyup = "formatDate(this)" onBlur = "chkInputDate(this)" onKeypress = "chkIntegerOfDate(this.value)"><%if(md.isStep1){%>
												<A HREF="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('enddate','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)">
												<IMG SRC="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" ALT="Calendar" NAME="enddate" WIDTH="20"  BORDER="0" ALIGN="absmiddle" ID="Image1312" onClick="viewCal('__wf__end_date')"></A><%}%>
												</TD>
							</TR>
									<TR>
									<%if(md.isStep1){%>
										<TD CLASS="column-label"><script language="JavaScript">swapLang('Reason')</script></TD>
												<TD CLASS="column-input">
												<INPUT TYPE="text" NAME="__mreasonid" VALUE="<%=chkNull.chkNullString(request.getParameter("__mreasonid"))%>" SIZE="10" MAXLENGTH="15" CLASS="txt01" onBlur="searchDWRData('MREASONCHANGE', 'reasonchangeid', this)"><%if(md.isStep1){%> <A HREF="javascript:goHelp('MREASONCHANGEHELP','__mreasonid');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('image01','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><IMG SRC="../IMAGES/BUTTON/MAIN/SEARCH20.gif" ALT="SEARCH" NAME="image01" WIDTH="20" HEIGHT="20" BORDER="0" ALIGN="absmiddle"></A>
												<%}%>
												<INPUT TYPE="text" NAME="MREASONCHANGE@TDESC" VALUE="<%=chkNull.chkNullString(request.getParameter("MREASONCHANGE@TDESC"))%>" SIZE="60" maxlength="200" class="txt01">
												<A HREF="javascript:copy('$remark$', DWRUtil.getValue('MREASONCHANGE@TDESC'));"><IMG HEIGHT=20 SRC="../IMAGES/BUTTON/MAIN/COPY20.gif" ID="copy"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('copy','','../IMAGES/BUTTON/SWAP/COPY_SWAP20.gif',1)" WIDTH=20 ALIGN=absMiddle BORDER=0></A></TD></TR>
											<%}%>
									<%if(md.isStep1){ //สร้างปุ่ม View และ Generate%>
											<TR>
												<TD CLASS="column-label"><SCRIPT LANGUAGE="javascript">swapLang('View Unrecorded Time')</SCRIPT></TD>
												<TD CLASS="column-input"><A HREF="javascript:goView();"><IMG HEIGHT=37 SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_VIEW.gif" WIDTH=89 BORDER=0></A></TD>
											</TR>
											<TR>
												<TD CLASS="column-label"><SCRIPT LANGUAGE="javascript">swapLang('Generate Forgot Time')</SCRIPT></TD>
												<TD CLASS="column-input"><A HREF="javascript:genDate();"><IMG HEIGHT=37 SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_GEN.gif" WIDTH=89 BORDER=0></A></TD>
										  </TR>
											<%}%>
											<TR >
												<TD CLASS="column-label"><SCRIPT LANGUAGE="javascript">swapLang("Priority");</SCRIPT></TD>
												<TD CLASS="column-input"><INPUT TYPE="radio" NAME="priority" VALUE="0">
													<SCRIPT LANGUAGE="JavaScript">swapLang("Normal")</SCRIPT>
													<INPUT TYPE="radio" NAME="priority" VALUE="1">
													<SCRIPT LANGUAGE="JavaScript">swapLang("High")</SCRIPT>
													<INPUT TYPE="radio" NAME="priority" VALUE="2">
                                                <SCRIPT LANGUAGE="JavaScript">swapLang("Highest")</SCRIPT></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>
								
							<!-- ////////////// CHILD TABLE ////////////-->
							<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" CLASS="txt01" ID="tbChild">
									<TR class="row-header">
										<TD width="5%"><input type="checkbox" name="chBox" value="" onClick="chkBox(this)"></TD>
										<TD width="20%"><SCRIPT LANGUAGE="JavaScript">swapLang('Date')</SCRIPT></TD>
										<TD width="15%"><SCRIPT LANGUAGE="JavaScript">swapLang('Time In Out')</SCRIPT></TD>
										<TD width="50%"><SCRIPT LANGUAGE="JavaScript">swapLang('OT Cause')</SCRIPT></TD>
										<%//if(isStep1){%><!--TD><SCRIPT LANGUAGE="JavaScript">swapLang('Delete')</SCRIPT></TD--><%//}%>
									</TR>
									</TABLE>
								</TD>
								<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/R2.gif"></TD>
							</TR>
							<%if(md.isStep1){%>
									<TR>
									<TD WIDTH="5" BACKGROUND="../IMAGES/MYNOTE/L2.gif"></TD>
									<TD CLASS="column-data" align="center"><BR>
										<A HREF="javascript:addRowToTable('<%=md.isStep1%>');"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_ADD.gif" WIDTH="89" HEIGHT="37" BORDER="0" ALT="Add"></A>
										&nbsp;&nbsp;&nbsp;
										<A HREF="javascript:delRowInTable();"><IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_DELETE.gif" WIDTH="89" HEIGHT="37" BORDER="0" ALT="Delete"></A>
									<BR>&nbsp;</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>		
							
							<!-- ////////////// VIEW ////////////-->
							<BR><SPAN ID="view"></SPAN>
							

						<!-- End Code -->
					  <br>
<%=md.getRemarkDocument()%>
                      <br>
<%=md.getWorkflowCommandDocument()%>
					<br>
<%=md.getReferenceNoteDocument()%>
					<br>
<%=md.getAttachFileDocument()%>				

					  <!-- 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: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( request.getParameter("sendto") != null && request.getParameter("wf_next_actor") != null ){
						%>
								setValue('sendto','<%=chkNull.chkNullString(request.getParameter("sendto"),"")%>');
								setValue('wf_next_actor','<%=chkNull.chkNullString(request.getParameter("wf_next_actor"),"")%>');
						<%
								}
						%>
								setValue('priority','<%=chkNull.chkNullString(request.getParameter("priority"),"0")%>');
								searchEmp();
								<%
								String lsRecord = chkNull.chkNullString(request.getParameter("__wf__list_record"),",1");
								String spValue[] = lsRecord.split(",");
								for(int i=1; i<spValue.length; i++){
								%>
									addRow('<%=spValue[i]%>', '<%=md.isStep1%>');
									DWRUtil.setValue("__wf__tforgetcard1$line_no$<%=spValue[i]%>", '<%=spValue[i]%>');
									DWRUtil.setValue("__wf__tforgetcard1$forget_date$<%=spValue[i]%>",'<%=chkNull.chkNullString(request.getParameter("__wf__tforgetcard1$forget_date$"+spValue[i]))%>');
									DWRUtil.setValue("__wf__tforgetcard1$forget_time$<%=spValue[i]%>", '<%=chkNull.chkNullString(request.getParameter("__wf__tforgetcard1$forget_time$"+spValue[i]))%>');
									DWRUtil.setValue("__wf__tforgetcard1$remark$<%=spValue[i]%>", '<%=chkNull.chkNullString(request.getParameter("__wf__tforgetcard1$remark$"+spValue[i]))%>');
								<%
								}
								%>
								resetLine();

           					</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">
								setValue('priority','<%=screenSingle.getDataLabel("VW_INCIDENT","PRIORITY")%>');
								DWRUtil.setValue("__wf__list_record",'<%=md.getWFDataValue("__wf__list_record")%>');
								DWRUtil.setValue("__wf__last_record",'<%=md.getWFDataValue("__wf__last_record")%>');
								DWRUtil.setValue("__wf__employeeid",'<%=md.getWFDataValue("__wf__employeeid")%>');
								DWRUtil.setValue("__wf__start_date",'<%=md.getWFDataValue("__wf__start_date")%>');
								DWRUtil.setValue("__wf__end_date",'<%=md.getWFDataValue("__wf__end_date")%>');
								
								searchDescEmp(document.getElementById("__wf__employeeid"),  'memployee.fullname:__wf__fullname,mposition.tdesc:__wf__position,mbu1.tdesc:__wf__bu1,mbu2.tdesc:__wf__bu2,mbu3.tdesc:__wf__bu3,mbu4.tdesc:__wf__bu4,mbu5.tdesc:__wf__bu5', "");
								<%
								String lsRecord = chkNull.chkNullString(md.getWFDataValue("__wf__list_record"),",1");
								String spValue[] = lsRecord.split(",");
								for(int i=1; i<spValue.length; i++){
									String empid = md.getWFDataValue("__wf__tforgetcard1$employeeid$"+i);
								%>
										addRow('<%=spValue[i]%>', false);
										DWRUtil.setValue("__wf__tforgetcard1$line_no$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$line_no$"+spValue[i])%>');
										DWRUtil.setValue("__wf__tforgetcard1$forget_date$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$forget_date$"+spValue[i])%>');
										DWRUtil.setValue("__wf__tforgetcard1$forget_time$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$forget_time$"+spValue[i])%>');
										DWRUtil.setValue("__wf__tforgetcard1$remark$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$remark$"+spValue[i])%>');
								<%
								}%>
								<%
									if(!md.isDraft){
								%>
								setDisabled(true);
								<%
								}else{
								%>
									setValue('__checkPage','false');
								<%
								}
								%>
								resetLine();

           					</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">
								setValue('__checkPage','false');
								setValue('priority','<%=screenSingle.getDataLabel("VW_INCIDENT","PRIORITY")%>');
								DWRUtil.setValue("__wf__list_record",'<%=md.getWFDataValue("__wf__list_record")%>');
								DWRUtil.setValue("__wf__last_record",'<%=md.getWFDataValue("__wf__last_record")%>');
								DWRUtil.setValue("__wf__employeeid",'<%=md.getWFDataValue("__wf__employeeid")%>');
								DWRUtil.setValue("__wf__start_date",'<%=md.getWFDataValue("__wf__start_date")%>');
								DWRUtil.setValue("__wf__end_date",'<%=md.getWFDataValue("__wf__end_date")%>');
								
								searchDescEmp(document.getElementById("__wf__employeeid"),  'memployee.fullname:__wf__fullname,mposition.tdesc:__wf__position,mbu1.tdesc:__wf__bu1,mbu2.tdesc:__wf__bu2,mbu3.tdesc:__wf__bu3,mbu4.tdesc:__wf__bu4,mbu5.tdesc:__wf__bu5', "");
								<%
								String lsRecord = chkNull.chkNullString(md.getWFDataValue("__wf__list_record"),",1");
								String spValue[] = lsRecord.split(",");
								for(int i=1; i<spValue.length; i++){
									String empid = md.getWFDataValue("__wf__tforgetcard1$employeeid$"+i);
								%>
										addRow('<%=spValue[i]%>', false);
										DWRUtil.setValue("__wf__tforgetcard1$line_no$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$line_no$"+spValue[i])%>');
										DWRUtil.setValue("__wf__tforgetcard1$forget_date$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$forget_date$"+spValue[i])%>');
										DWRUtil.setValue("__wf__tforgetcard1$forget_time$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$forget_time$"+spValue[i])%>');
										DWRUtil.setValue("__wf__tforgetcard1$remark$<%=spValue[i]%>", '<%=md.getWFDataValue("__wf__tforgetcard1$remark$"+spValue[i])%>');
								<%
								}%>
								<%
									if(!md.isAdminEdit){
								%>
								setDisabled(true);
							<%
								}
							%>
								resetLine();
           					</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>
				</DIV>
			</DIV>
			<DIV ID="footer"><jsp:include page="../EMPVIEW/EMV_FOOTER.jsp" flush="true" /></DIV>
			</DIV>
		</DIV>
</BODY>
</HTML>
<%
}
%>