<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.*,com.csc.library.system.*,com.csc.library.session.*,com.csc.library.utilities.*,java.text.DecimalFormat,com.csc.library.database.*"%>
<%@page import="java.util.*,java.io.*,java.sql.*"%>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="COBRANCHLIST_PRE_EXPORT" class="com.csc.library.system.Task" scope="page" />
<%
	COBRANCHLIST_PRE_EXPORT.setChannel(request,response);
	HelpEntry screen = (HelpEntry) COBRANCHLIST_PRE_EXPORT.process("HelpEntry","MEMPLOYEEHELP");
	
	CheckNull chk = new CheckNull();

	String cmd = chk.chkNullString(request.getParameter("__cmd"));
	String branch = chk.chkNullString(request.getParameter("__branch"));
	String position = chk.chkNullString(request.getParameter("__position"));
	String bu1id = chk.chkNullString(request.getParameter("__bu1"));
	String bu2id = chk.chkNullString(request.getParameter("__bu2"));
	String bu3id = chk.chkNullString(request.getParameter("__bu3"));
	String bu4id = chk.chkNullString(request.getParameter("__bu4"));
	String bu5id = chk.chkNullString(request.getParameter("__bu5"));
	String include_emp = chk.chkNullString(request.getParameter("__include_emp"));
	String branchdesc = chk.chkNullString(request.getParameter("MBRANCH@TDESC"));
	String jobdesc = chk.chkNullString(request.getParameter("MJOBCODE@TDESC"));
	String mbudesc1 = chk.chkNullString(request.getParameter("MBU1@TDESC"));
	String mbudesc2 = chk.chkNullString(request.getParameter("MBU2@TDESC"));
	String mbudesc3 = chk.chkNullString(request.getParameter("MBU3@TDESC"));
	String mbudesc4 = chk.chkNullString(request.getParameter("MBU4@TDESC"));
	String mbudesc5 = chk.chkNullString(request.getParameter("MBU5@TDESC"));
	
	String cf_last_bu = "";
	DbInquiry inqconfig_gohelp = new InitialInquiry(screen.getUProfile()).getDbInquiry("config_gohelp");
	inqconfig_gohelp.setColumn("*");
	inqconfig_gohelp.refresh();
	if(inqconfig_gohelp.next()){
		cf_last_bu = inqconfig_gohelp.getString("last_bu");
	} else {
		cf_last_bu = "BU5";
		out.println("Can't Export Becuase No Data Last BU in config_gohelp table");
	}
	inqconfig_gohelp.closeConnection();
	int last_bu_int = Integer.valueOf(cf_last_bu.replaceAll("BU",""));
	
%>
<%!
	private String chkfilter(String str){
		if(!str.equals("")){
			str += " AND ";
		}
		return str;
	}
%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<link href="../CSS/bootstrap.css" rel="stylesheet"  type="text/css">
<link href="../CSS/bootstrap_csc_backend.css" rel="stylesheet"  type="text/css">
<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
<script type='text/javascript' src="../JS/bootstrap.js"></script>
<script language="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 language="javascript">setLang('<%=screen.getUProfile().get("lang")%>');</script>
<script language="JavaScript" type="text/JavaScript">

function goHelp(helpName,inputName){
	if (inputName=="__position" ) {
	 	helpReturn="__position:jobcodeid,MJOBCODE@TDESC";
	}else if (inputName=="__branch" ){
		helpReturn="__branch:branchid,MBRANCH@TDESC";
	}else if (inputName=="__bu1" ){
		helpReturn="__bu1:bu1id,MBU1@TDESC";
	}else if (inputName=="__bu2" ){
		helpReturn="__bu2:bu2id,MBU2@TDESC";
	}else if (inputName=="__bu3" ){
		helpReturn="__bu3:bu3id,MBU3@TDESC";
	}else if (inputName=="__bu4" ){
		helpReturn="__bu4:bu4id,MBU4@TDESC";
	}else if (inputName=="__bu5" ){
		helpReturn="__bu5:bu5id,MBU5@TDESC";
	}
	linkHelp_Return(helpName, helpReturn);
}

function back(unit){
	with(window.opener.document.cscform){
	        locateId.value =unit;
	}
	window.close();
}

function GoExport(){
	with( document.cscform){
		var include_emp = "";
		if(__include_emp.checked){
			include_emp = __include_emp.value;
		}
		var con = "__branch="+__branch.value+"&__bu1="+__bu1.value+"&__bu2="+__bu2.value+
					"&__bu3="+__bu3.value+"&__bu4="+__bu4.value+"&__bu5="+__bu5.value+
					"&__position="+__position.value+"&__include_emp="+include_emp;
		window.open("COBRANCHLIST_EXPORT.jsp?&"+con);
		window.close();
	}
}

/*function GoProcess(){
	with( document.cscform){
		__cmd.value = "search"
		submit();
	}
}*/

</script>
</head>
<style>
	td.rowex {
		background: #3399cc;
		border: #cccccc;
		color: #000000;
		font-weight: bold;
		height: 45px;
	}
</style>

<body leftmargin="0" topmargin="0">
<form name="cscform" method="post" action="COBRANCHLIST_PRE_EXPORT.jsp">


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

<%//=screen.InitialVariable()%>

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

<input type="hidden" name="__cmd" value="">
<input type="hidden" name="__screen" value="COBRANCHLIST_PRE_EXPORT">
<input type="hidden" name="__help" value="">
<input type="hidden" name="__goPage" value="">
<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
<input type="hidden" name="__orderBy" value="<%=request.getParameter("__orderBy")%>">
<input type="hidden" name="__helpName" value="<%=request.getParameter("__helpName")%>">
<input type="hidden" name="__pageCall" value="<%=request.getParameter("__screen")%>">
<input type="hidden" name="__fixCon" value="<%=request.getParameter("__fixCon")%>">
<input type="hidden" name="__export" value=""> 
<input type="hidden" name="__calendar" value=""> 
<input type="hidden" name="__filter" value="">
<script language="javascript">getInputFormatDate()</script>

<br>
<div align="center">
<table class="large" cellpadding="0"  cellspacing="1"  >
<tr> 
	<td  colspan=2 class="header">COBRANCHLIST_PRE_EXPORT, <script language="javascript">swapLang('Pre Company Branch List Report')</script>&nbsp;&nbsp;</td>
</tr>
<tr> 
    <td colspan=2>
		<table border="0" cellpadding="0" cellspacing="1"   align="center" class="largest">

	<tr>
		<td colspan=2 class="blankspace"></td>
	</tr>
	<tr>
		<td width="30%" align="right"><%=screen.getLabel("branch") %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__branch" value="<%=branch%>">&nbsp;<a href="javascript:goHelp('MBRANCHHELP','__branch')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MBRANCH@TDESC" value="<%=branchdesc%>" readonly="true"></td>
	</tr>
	<tr <%if(last_bu_int < 1){%>style="display:none"<%}%>>
		<td width="30%" align="right"><%=screen.getLabel("bu1") %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__bu1" value="<%=bu1id%>">&nbsp;<a href="javascript:goHelp('MBU1HELP','__bu1')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MBU1@TDESC" value="<%=mbudesc1%>" readonly="true"></td>
	</tr>
	<tr <%if(last_bu_int < 2){%>style="display:none"<%}%>>
		<td width="30%" align="right"><%=screen.getLabel("bu2") %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__bu2" value="<%=bu2id%>">&nbsp;<a href="javascript:goHelp('MBU2HELP','__bu2')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MBU2@TDESC" value="<%=mbudesc2%>" readonly="true"></td>
	</tr>
	<tr <%if(last_bu_int < 3){%>style="display:none"<%}%>>
		<td width="30%" align="right"><%=screen.getLabel("bu3") %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__bu3" value="<%=bu3id%>">&nbsp;<a href="javascript:goHelp('MBU3HELP','__bu3')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MBU3@TDESC" value="<%=mbudesc3%>" readonly="true"></td>
	</tr>
	<tr <%if(last_bu_int < 4){%>style="display:none"<%}%>>
		<td width="30%" align="right"><%=screen.getLabel("bu4") %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__bu4" value="<%=bu4id%>">&nbsp;<a href="javascript:goHelp('MBU4HELP','__bu4')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MBU4@TDESC" value="<%=mbudesc4%>" readonly="true"></td>
	</tr>
	<tr <%if(last_bu_int < 5){%>style="display:none"<%}%>>
		<td width="30%" align="right"><%=screen.getLabel("bu5") %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__bu5" value="<%=bu5id%>">&nbsp;<a href="javascript:goHelp('MBU5HELP','__bu5')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MBU5@TDESC" value="<%=mbudesc5%>" readonly="true"></td>
	</tr>
	<tr>
		<td width="30%" align="right"><%=screen.getUProfile().get("lang").equalsIgnoreCase("tha")?"ตำแหน่ง":"Position" %>&nbsp;</td>
		<td width="70%" ><input type="text" size="10" name="__position" value="<%=position%>">&nbsp;<a href="javascript:goHelp('MJOBCODEHELP','__position')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<input type="text" size="30" name="MJOBCODE@TDESC" value="<%=jobdesc%>" readonly="true"></td>
	</tr>
	<tr>
		<td width="30%" align="right">&nbsp;</td>
		<td width="70%" ><input type="checkbox" name="__include_emp" value="1" <%if(include_emp.equals("1")){%>checked<%}%>>&nbsp;Include Employee</td>
	</tr>
	
			<tr>
				<td  class="buttonline" colspan="7"><div align="center">
					<button type="button" class="btn btn-primary width100" swlang code="SW013178" onClick="GoExport();">EXPORT</button>
				</div>
				</td>
			</tr>
	</table>
	</td></tr>
    <tr bordercolor="0069B3"> 
      <td colspan=2 class="bottom"></td>
    </tr>
  </table>
</form>
</body>
</html>