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

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

<!-- Begin useBean -->

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

<%
TEMPLATE_WORKFLOW.setChannel(request,response);
TEMPLATE_WORKFLOW.checkProfile();

if( TEMPLATE_WORKFLOW.getUProfile() != null ){
	TEMPLATE_WORKFLOW.getUProfile().set("appname","TA");
	UIManager screenSingle = (UIManager) TEMPLATE_WORKFLOW.process("SingleEntry","TEMPLATE_WORKFLOW");
	
	/*boolean isStep1 = false;
	boolean isStep2 = false;
	boolean isStep3 = false;
	boolean isStepCancel = false;
	boolean isStepComment = false;
	boolean isStepReturn = false;
	boolean isStepCopy = false;*/
	String lang = screenSingle.getUProfile().get("lang");
	String wf = null;
	CheckNull chkNull = new CheckNull();
	Organization og = new Masfactor(screenSingle.getUProfile());
	String subject = null;
	String remark = null;
	String step_type = null;
	String emp_fullname = null;
	String bossid = og.getBoss(screenSingle.getUProfile().get("employeeid"),screenSingle.getUProfile().get("job")).get(0).toString();
	String bossjob = bossid.substring(bossid.indexOf(":")+1);
	CscCalendar calendar = new CscCalendar();
	long attach_time = Long.parseLong(chkNull.chkNullString(request.getParameter("attach_time"),String.valueOf(calendar.getTimeInMillis())));
	ManageDocument md = new ManageDocument();
	md.setUProfile(screenSingle.getUProfile());
	md.setRequest(request);
	md.setScreen(screenSingle);

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

	bossid = bossid.substring(0,bossid.indexOf(":"));
	DbRecord memployee_dr = new InitialRecord(screenSingle.getUProfile()).getDbRecord("Memployee");
	memployee_dr.setColumn("*");
	memployee_dr.set("COMPANYID",screenSingle.getUProfile().get("companyid"));
	memployee_dr.set("EMPLOYEEID",bossid);
	memployee_dr.search();

	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 ng-app="myHR">
	<HEAD>
		<TITLE>myNOTE : Business Process Management Service</TITLE>
		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
		<!-- Begin Link -->
		<LINK HREF="../CSS/MYNOTE.css" REL="stylesheet" TYPE="text/css">
		<LINK HREF="../CSS/MYNOTE_MENU.css" REL="stylesheet" TYPE="text/css">
		<!-- End Link -->
		<!-- Begin Import Script -->
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/MYNOTE_SCREEN.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/MYNOTE_MENU.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/SCREEN.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/DATEINPUT.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/VIEWCALENDAR.js'></SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../JS/ICONSMENU.js'></SCRIPT>
		<SCRIPT LANGUAGE="JavaScript">setLang('<%=screenSingle.getUProfile().get("lang")%>');</SCRIPT>
		<SCRIPT TYPE='text/JavaScript' SRC='../TA/JS/TA_SCREEN.js'></SCRIPT>
		<script src="../JS/angular-1.3.15/angular.js" type="text/javascript"></script>
		<script src="../JS/ANGULAR/SCREEN_ANGULAR.js" type="text/javascript"></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/Tchangeshift_nstda_dwr.js"></script>
        <script type="text/javascript" src="/hr/dwr/interface/Tchholiday_dwr.js"></script>

		<!--DWR INCLUDE-->
		<SCRIPT LANGUAGE="JavaScript" TYPE="text/JavaScript">
		<!--		
			function preGoWF(){
				var msg="Date is Duplicate.";
				with( document.cscform ){
					__wf__change_date2.value = __wf__holiday_list.value.split("#")[0];
					__wf__holiday_type.value = __wf__holiday_list.value.split("#")[1];
					if(__language.value == "tha") {msg="วันที่ต้องการเปลี่ยนซ้ำ";}
					if(__wf__employeeid.value != "" && __wf__change_date1.value != "" && __wf__change_date2.value != ""){
						if(__wf__change_date1.value != __wf__change_date2.value){
							//if(__wf__chkHoliday.value == "true"){
							__wf__chkHoliday.value = true;
							setMailConfigWorkflow();
							GoWF();
						}else alert(msg);
					}else alert(MyCode[0]);
				}				
			}
			
			/* check condition is correct before submit form */
			function matchCondition(){
				with(document.cscform){
					if(__isHolidayOK.value == "true" && __isWorkdayOK.value == "true"){
						return true;
					}else{
						return false;
					}
				}
			}

			function chkAdjtime(){
				Tchholiday_dwr.chkChHoliday(new Array(document.cscform.__wf__employeeid.value,document.cscform.__wf__change_date2.value,document.cscform.__wf__change_date1.value),{callback:
					function(data){
						if(data){
							GoWF();
						}else{
							document.cscform.imgSubmit.style.display = "";
							document.cscform.__chkHoliday.value = false;
							var error_mes = "Can Not Change Day Off DetailsBecause This Day is Request Leave or OT";
							if(document.cscform.__language.value == "tha"){ error_mes = "ไม่สามารถเปลี่ยนวันหยุดได้ เนื่องจากได้มีการลา หรือ มีการขอโอที ในวันดังกล่าวแล้ว";}
							alert(error_mes);
							return false;
						}
					},async: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:MEMPLOYEE@FULLNAME";
						linkHelp_SendToReturn(helpName,helpReturn);
						__fixCon.value=temp;
					}else if( inputName == "cc" ){
						temp = __fixCon.value;
						helpReturn="wf_cc_actor:EMPLOYEEID,cc:MEMPLOYEE@FULLNAME";
						linkHelp_SendToReturn(helpName,helpReturn);
						__fixCon.value=temp;
					} else if(inputName=="__wf__employeeid"){
						temp = __fixCon.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+")";
						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;
					}
				}
			}
			
			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 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 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 chk_Time(){
			var count=0;
				with( document.cscform ){
				for (j=0;j<elements.length; j++){
					if(elements[j].name.indexOf("__wf__change_date1") > -1){
						if(!isValidDate(elements[j].value)){
							count+=1;
							elements[j].focus();
							elements[j].select();
							break;
						}
					}
					if(elements[j].name.indexOf("__wf__change_date2") > -1){
						if(!isValidDate(elements[j].value)){
							count+=1;
							elements[j].focus();
							elements[j].select();
							break;
						}
					}
				}//for
				if(count>0){
					return false;
				}else{
					return true;
				}
			}
		}
		
		function chk_Time2(){	
			with(document.cscform){
				return dateDifference(eval("__wf__change_date1.value"),eval("__wf__change_date2.value"));
			}
		}
		
		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 goView() {
			with(document.cscform){
				Tchangeshift_nstda_dwr.getDWRData(new Array(__wf__employeeid.value,__wf__change_date1.value,__wf__change_date2.value,__wf__old_shift.value,__wf__change_date2.value),{callback:
					function(data){
						view.innerHTML=data;
					},async:true});
			}
		}

		function searchEmp(){
			//condition = " and employeeid in ("+document.cscform.__subordinate.value+")";
			var condition ="";
			searchDescEmp(eval('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', "");
			//realShift();
		}


		
		function chkIsHoliday(date, isBoolean){
			var imgSubmit = document.getElementById("imgSubmit");
			with(document.cscform){
				imgSubmit.style.display = "none";
				Tchangeshift_nstda_dwr.isHoliday(new Array(__wf__employeeid.value,date.value),{callback:
					function(data){
						if(data == isBoolean){
							imgSubmit.style.display = "";
							__wf__chkHoliday.value = true;
							
							/* update condition before submit */							
							if(isBoolean){
								__isHolidayOK.value = "true";
							}else{
								__isWorkdayOK.value = "true";
							}

							return true;
						}else{
							imgSubmit.style.display = "";
							__wf__chkHoliday.value = false;
							alert(swap2String("Can't Change"));
							
							if(isBoolean){
								__isHolidayOK.value = "false";
							}else{
								__isWorkdayOK.value = "false";
							}
							return false;
						}
					},async:true});
			}
		}
		
		function setMailConfigWorkflow(){
				  with(document.cscform){
					  var date , month , year;
					  var now =  new Date();
					  date =  now.getDate();
					  month = now.getMonth()+1;
					  year = now.getFullYear();
					  date = (date <10)?('0'+date):date;
					  month = (month<10)?('0'+month):month;
		 	           __wf__start_doc_date.value = date+'/'+month+'/'+year;
					 // alert(__wf__start_doc_date.value );
				  }
			}
	
	//-->
		</SCRIPT>
		<script type="text/javascript" src="../JS/jquery-1.3.2.min.js"></script>
		<script type="text/javascript" >
			$(function(){
				$(".column-label").css("width","25%");
			});
		</script>
		<style>
			.FontRed {color: red;}
		</style>
	</HEAD>
	<BODY>
	<jsp:include page="../MYNOTE_HEAD.jsp" flush="true"/>
	<div align="center">
	<!--<div align="center" name="wf_detail">
	<!-- ImageReady Slices (02.psd) -->
		<FORM NAME="cscform" METHOD="post" ACTION="TAU_CSCWF_008_STD.jsp">
			<INPUT TYPE="hidden" NAME="__screen" VALUE="TAU_CSCWF_008_STD">
			<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="8108">
			<INPUT TYPE="hidden" NAME="__wf_id" VALUE="8108">
			<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("0")?screenSingle.getDataLabel("DOC_NO"):chkNull.chkNullString(request.getParameter("__oldDocumentID"),"0"))%>">
		  <input type="hidden" name="__oldWF" value="<%=(!screenSingle.getDataLabel("DOC_NO").equals("0")?screenSingle.getDataLabel("WF_STATUS"):chkNull.chkNullString(request.getParameter("__oldWF"),"0"))%>">
       
			<INPUT TYPE="hidden" NAME="__wf" VALUE="<%=wf%>">
			<INPUT TYPE="hidden" NAME="__wfcmd" VALUE="false">		
			<INPUT TYPE="hidden" NAME="remark" VALUE="<%=remark%>">
			<INPUT TYPE="hidden" NAME="wf_default_actor" VALUE="true">

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

			<!-- used for checking condition is correct -->
			 <INPUT TYPE="hidden" NAME="__isHolidayOK" VALUE="<%=chkNull.chkNullString(request.getParameter("__isHolidayOK"))%>">
			 <INPUT TYPE="hidden" NAME="__isWorkdayOK" VALUE="<%=chkNull.chkNullString(request.getParameter("__isWorkdayOK"))%>">

			<%=screenSingle.InitialVariable()%>
			
			<DIV ID="toolTipLayer" STYLE="position:absolute; visibility: hidden"></DIV>
			<SCRIPT LANGUAGE="JavaScript">initToolTips();</SCRIPT>
			
			<TABLE WIDTH=950 BORDER=0 ALIGN="center" CELLPADDING=0 CELLSPACING=0 id="wrapper">
						<DIV ALIGN="right">
<%=md.getStepDocument("8108","1")%>
<%=md.getHeadDocument()%>
                      <br>
<%=md.getHelpDocument("WF8108")%>
                      <br>
<%=md.getSendToDocument("WF8108")%>
					  <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__chholidayid" VALUE="0">
											<INPUT TYPE="hidden" NAME="__chkHoliday" VALUE="<%=chkNull.chkNullString(request.getParameter("__chkHoliday"),"false")%>" ID="__chkHoliday">
											<tr>
												<td colspan="2" class="column-title"><span swlang code="SW001141">Employee Details</span></td> 
											</tr>
										  <tr>
										    <td width="25%"  class="column-label"><span swlang code="SW011939">Employee Code</span></td> 
										    <INPUT TYPE="hidden" NAME="__subordinate" VALUE="<%=screenSingle.getUProfile().get("subordinateall")%>"><INPUT TYPE="hidden" NAME="list_shift" VALUE="<%=chkNull.chkNullString(request.getParameter("list_shift"))%>">
											<td width="75%" class="column-input"></span><input name="__wf__employeeid" type="text" value="<%= chkNull.chkNullString(request.getParameter("__wf__employeeid"),screenSingle.getUProfile().get("employeeid"))%>" size="15" onBlur="javascript:searchEmp();" readonly class="disabled">
											<%//if(md.isStep1){%>
												<!--A HREF="javascript:goHelp('MEMPLOYEEHELP2','__wf__employeeid');" 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-->
											<%//}%>&nbsp;<input name="MEMPLOYEE@FULLNAME" type="text" size="40" value="<%= chkNull.chkNullString(request.getParameter("MEMPLOYEE@FULLNAME"),"") %>" class="disabled" readonly></td></tr>
										  <tr>
										    <td class="column-label"><span swlang code="SW000057">Position</span></td>
											<td class="column-input"><input type="text" name="__position" value="<%= chkNull.chkNullString(request.getParameter("__position"),"") %>" size="61" readonly class="disabled"></td></tr>
										  <tr>
											<%
												DbInquiry memployee = new InitialInquiry(screenSingle.getUProfile()).getDbInquiry("memployee");
												memployee.setColumn("employeeid,companyid,bu1,bu2,bu3,bu4,bu5");
												memployee.refresh();

												DbRecord mbu = memployee.getCurrentDbRecord();
											%>
										    <td class="column-label"><%=mbu.getField("bu1").getDescription()%></td>
											<td class="column-input"><input type="text" name="__bu1" value="<%= chkNull.chkNullString(request.getParameter("__bu1"),"") %>" size="61" readonly class="disabled"></td></tr>
										  <tr>
										    <td class="column-label"><%=mbu.getField("bu2").getDescription()%></td>
											<td class="column-input"><input type="text" name="__bu2" value="<%= chkNull.chkNullString(request.getParameter("__bu2"),"") %>" size="61" readonly class="disabled"></td></tr>
										  <tr>
										    <td class="column-label"><%=mbu.getField("bu3").getDescription()%></td>
											<td class="column-input"><input type="text" name="__bu3" value="<%= chkNull.chkNullString(request.getParameter("__bu3"),"") %>" size="61" readonly class="disabled"></td></tr>
										  <tr>
										    <td class="column-label"><%=mbu.getField("bu4").getDescription()%></td>
											<td class="column-input"><input type="text" name="__bu4" value="<%= chkNull.chkNullString(request.getParameter("__bu4"),"") %>" size="61" readonly class="disabled"></td></tr>
										  <tr>
										    <td class="column-label"><%=mbu.getField("bu5").getDescription()%></td>
											<td class="column-input">
											<input type="text" name="__bu5" value="<%= chkNull.chkNullString(request.getParameter("__bu5"),"") %>" size="61" readonly class="disabled"></td>
											</tr>
											<input type="hidden" name="__startdate" value="<%= chkNull.chkNullString(request.getParameter("__startdate"),"") %>">
											<input type="hidden" name="__tel_ext" value="<%= chkNull.chkNullString(request.getParameter("__tel_ext"),"") %>" >																  										  
										  <tr>
												<td colspan="2" class="column-title" ><span swlang code="SW009000">Change Day-Off Details</span></td>
										  </tr>
                                            <tr>
											<td class="column-label"><span swlang code="SW008843">Holiday_Date</span></td>
											<td CLASS="column-input">
												<select name="__wf__holiday_list" id="__wf__holiday_list" class="<%=(!md.isStep1)?"disabled":""%>">
											<%
												String select = "";
												String type_desc = "";
												String type = "";
												if(md.isStep1){
													boolean used = false;
													GenHolidayList gh = new GenHolidayList(TEMPLATE_WORKFLOW.getUProfile());
													gh.setEmployeeid(TEMPLATE_WORKFLOW.getUProfile().get("employeeid"));
													ArrayList ar = gh.getListWithoutNoneWorkingDaySTD();

													/* create holiday key */
													HashMap hmHdate = getHolidayKey(ar);
														for(int i = 0;i<ar.size();i++){
															CscCalendar point = new CscCalendar(ar.get(i).toString().split("#")[0]);
															String date = point.getDDMMYYYY();
															String val = ar.get(i).toString();

															type = ar.get(i).toString().split("#")[1];
															
															int ch = (Integer) hmHdate.get(point.getYYYYMMDD());
															if(ch > 1){
																val += "0";
															}

															if(type.equals("H")){
																type_desc = (lang.equals("tha"))?"วันหยุดประจำสัปดาห์":"Day off";
															}else if(type.equals("I")){
																type_desc = (lang.equals("tha"))?"วันหยุดนักขัตฤกษ์":"Holiday";
															}
															
															if(used){
																select = "";
															}
															if(calendar.getMM().equals(point.getMM()) && point.beforeDate(calendar) && !used){
																select = "selected";
																used = true;
															}
											%>
															<option value='<%=val%>' <%=select%>><%=date+" ("+type_desc+")"%></option>
											<%
														}
													}else{
														type = md.getWFDataValue("__wf__holiday_type");
														if(type.equals("H")){
															type_desc = (lang.equals("tha"))?"วันหยุดประจำสัปดาห์":"Day off";
														}else if(type.equals("I")){
															type_desc = (lang.equals("tha"))?"วันหยุดนักขัตฤกษ์":"Holiday";
														}
												%>
														<option value='<%=md.getWFDataValue("__wf__change_date2")%>'><%=new CscCalendar(md.getWFDataValue("__wf__change_date2")).getDDMMYYYY()+" ("+type_desc+")"%></option>
											<%
													}
											%>
												</select>
												<%
													String remarkday = (TEMPLATE_WORKFLOW.getUProfile().get("lang").equals("eng"))?"*To show the record when you have punch In-Out on your holidays only.":"*แสดงข้อมูลวันที่บันทึกเวลาในวันหยุดเท่านั้น";
												%>
												<span class="FontRed">
													<%=remarkday%>
												</span>
												<input type="hidden" size="10" name="__wf__change_date2" id="__wf__change_date2" value="<%=md.getWFDataValue("__wf__change_date2")%>" />
												<input type="hidden" size="10" name="__wf__holiday_type" id="__wf__holiday_type" value="<%=md.getWFDataValue("__wf__holiday_type")%>" />
											<!-- <input type="text" size="10" name="__wf__change_date2" id="__wf__change_date2" maxlength=10 value="<%=chkNull.chkNullString(request.getParameter("__wf__change_date2"), new CscCalendar().getDDMMYYYY()) %>" class="txt01" onKeyup = "formatDate(this)" onKeypress = "chkIntegerOfDate(this.value)" onBlur = "chkInputDate(this);chkIsHoliday(this,true)">&nbsp;<%if(md.isStep1){%><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('chdate2','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="chdate2" width="20"  border="0" align="absmiddle" id="Image1312" onClick="viewCal('__wf__change_date2')"></a> <% } %>-->
											</td></tr>
										  <tr>
											<td class="column-label"><span swlang code="SW008842">working Date</span></td>
											<td class="column-input"><input type="text" size="10" name="__wf__change_date1" id="__wf__change_date1" maxlength=10 value="<%=chkNull.chkNullString(request.getParameter("__wf__change_date1"), new CscCalendar().getDDMMYYYY()) %>" class="txt01" onKeyup = "formatDate(this)" onKeypress = "chkIntegerOfDate(this.value)" onBlur = "chkInputDate(this)">&nbsp;<%if(md.isStep1){%><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('chdate1','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/CALENDAR20.gif" alt="Calendar" name="chdate1" width="20"  border="0" align="absmiddle" id="Image1311" onClick="viewCal('__wf__change_date1')"></a><% } %></td></tr>
										
										  <tr>
                                            <td class="column-label"><span swlang code="SW009001">Change Day-Off Reason</span></td> 
										    <td class="column-input"><textarea name="__wf__remarks" rows="5" cols="70"><%=chkNull.chkNullString(request.getParameter("__wf__remarks"))%></textarea></td>
									      </tr>
										 <tr>
											<td class="column-label"><span swlang code="SW000302">Remark</span></td> 
                                            <%
													if(screenSingle.getUProfile().get("lang").equals("eng")){
											%>
											<td class="column-input">For weekdays and weekends must be approved by the President before using this form.</td>
                                            <%
													}else{
											%>
                                            <td class="column-input">การขอสลับวันทำงานและวันหยุดต้องได้รับการอนุมัติจากผู้จัดการก่อน จึงจะใช้แบบฟอร์มนี้ได้</td>
                                            <%
													}
											%>
										</tr>
											<%=md.getWF_Remark("8108",screenSingle.getUProfile().get("companyid"))%>
										<!--
										<TR BGCOLOR=#EFEFEF>
                                             <td class="column-label"><span swlang code="SW001105">Priority</span></TD>
										    <TD BGCOLOR="#EFEFEF"><INPUT TYPE="radio" NAME="priority" VALUE="0">
                                                <span swlang code="SW001106">Normal</span>
                                                <INPUT TYPE="radio" NAME="priority" VALUE="1">
                                                <span swlang code="SW001107">High</span> 
                                          </TD>
									      </TR> -->
										<input type="hidden" name="priority" value="0">
										<!-- End User Code -->
										</TABLE>
									</FONT></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>

						<!-- End Code -->
					  <br>
<%=md.getRemarkDocument()%>
                      <br>
<%=md.getWorkflowCommandDocument()%>
					<br>
<%=md.getReferenceNoteDocument()%>
					<br>
<%=md.getAttachFileDocument()%>
					<br>
					<!-- Begin Workflow Button -->
           				<%
           				if( !md.isStep3 ){
           				%>
           					<TABLE WIDTH="95%" BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0">
           						<TR>
           				<%
           						if( md.isStep1 || md.isDraft){
           				%>
           							<TD><DIV ALIGN="right">
<!--                                     <A HREF="JavaScript:SaveDraft();">
                                    <IMG SRC="../IMAGES/MYNOTE/BUTTON/BUTTON_SAVE.gif" WIDTH="89" HEIGHT="37" BORDER="0"></A>
						<%   //   if( md.isDraft ){%>
									<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_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 -->
					<br>
<%=md.getRoutingDocument()%>
					<br>
<%=md.getCommentDocument()%>
<!-- Begin Set Value -->
           				<%
           			
           				if( md.isStep1 ){
           				%>
           					<!-- Begin Set Value Step1 -->
           					<SCRIPT LANGUAGE="JavaScript">
								setValue('priority','<%=chkNull.chkNullString(request.getParameter("priority"),"0")%>');
								searchEmp();

           					</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">
								hideSendTo('<%=step_type%>');
								dwr.util.setValue("__wf__employeeid",'<%=md.getWFDataValue("__wf__employeeid")%>');
								dwr.util.setValue("__wf__change_date1",'<%=md.getWFDataValue("__wf__change_date1")%>');
								dwr.util.setValue("__wf__change_date2",'<%=md.getWFDataValue("__wf__change_date2")%>');
								dwr.util.setValue("__wf__remarks",'<%=md.getWFDataValue("__wf__remarks")%>');
								dwr.util.setValue("__wf__chkHoliday",'<%=md.getWFDataValue("__wf__chkHoliday")%>');
								dwr.util.setValue("__wf__holiday_type",'<%=md.getWFDataValue("__wf__holiday_type")%>');
								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', "");

								setValue('priority','<%=screenSingle.getDataLabel("VW_INCIDENT","PRIORITY")%>');
								<%
									if(!md.isDraft){
								%>
								setDisabled(true);
								<%
								}else{
								%>
									setValue('__checkPage','false');
								<%
									}
								%>
           					</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">
								dwr.util.setValue("__wf__employeeid",'<%=md.getWFDataValue("__wf__employeeid")%>');
								dwr.util.setValue("__wf__change_date1",'<%=md.getWFDataValue("__wf__change_date1")%>');
								dwr.util.setValue("__wf__change_date2",'<%=md.getWFDataValue("__wf__change_date2")%>');
								dwr.util.setValue("__wf__remarks",'<%=md.getWFDataValue("__wf__remarks")%>');
								dwr.util.setValue("__wf__chkHoliday",'<%=md.getWFDataValue("__wf__chkHoliday")%>');
								dwr.util.setValue("__wf__holiday_type",'<%=md.getWFDataValue("__wf__holiday_type")%>');
								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', "");
								setValue('__checkPage','false');
								setValue('priority','<%=screenSingle.getDataLabel("VW_INCIDENT","PRIORITY")%>');
								<%
									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>
             <INPUT TYPE="hidden" NAME="__wf__chkHoliday" ID ="__wf__chkHoliday" VALUE="<%=(!md.getWFDataValue("__wf__chkHoliday").equals(""))?md.getWFDataValue("__wf__chkHoliday"):chkNull.chkNullString(request.getParameter("__wf__chkHoliday"),"false")%>">
            <INPUT TYPE="hidden" NAME="__wf__start_doc_date" ID ="__wf__start_doc_date" VALUE="<%=(!md.getWFDataValue("__wf__start_doc_date").equals(""))?md.getWFDataValue("__wf__start_doc_date"):request.getParameter("__wf__start_doc_date")%>">
			<%=screenSingle.endJSP()%>
		</FORM>
	</BODY>
	</div>
</HTML>
<%
}
%>
<%!
	public HashMap getHolidayKey(ArrayList ar){
		HashMap hmHdate = new HashMap();
		try {
			/* keep key */
			for(int i = 0;i<ar.size();i++){
									
				CscCalendar point = new CscCalendar(ar.get(i).toString().split("#")[0]);
				if(hmHdate.containsKey(point.getYYYYMMDD())){
					int co = (Integer) hmHdate.get(point.getYYYYMMDD());
					hmHdate.put(point.getYYYYMMDD(),co+1);
				}else{
					hmHdate.put(point.getYYYYMMDD(),1);
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		System.out.print("!!!!!!!!!!!!!!! >> " + hmHdate);
		return hmHdate ;
	}
%>