<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@ page import="com.csc.library.databean.*,java.text.DecimalFormat"  %>
<jsp:useBean id="TRA0122_PHATRA" class="com.csc.library.system.Task" scope="page"/>
<%
	TRA0122_PHATRA.setChannel(request,response);
	UIManager screen = (UIManager) TRA0122_PHATRA.process("MultiEntry","TRA012_PHATRA",true);
	screen.referLangOn();

	MultiLine multi = screen.getMultiLine("TTRAINEXP");
	CheckNull chk = new CheckNull();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html ng-app="myHR">
<head>
<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 type='text/javascript' src='../JS/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>
<script language="javascript">setLang('<%=screen.getUProfile().get("lang")%>');</script>
<script language="JavaScript" >
function goSave() {confirmSave();}
function goSearch() {search();}
function goDelete() {edelete();}
function goUpdate() {update();}
function checkCF() {checkConfirm();}

function childMulti(record){
	with(document.cscform){
	 window.open(__childMulti.value+".jsp?__cmd=&__gorec="+record+"&__ack=edit"+
			 "&__trainingid="+__trainingid.value+
			  "&__headMulti="+__screen.value,"trainExp","left=150,top=150,width=700,height=280,toolbar=no,status=no,scrollbars=yes,resizable=yes");
	 	}
}
function addMulti(){
	if(notBlankOnParentPage()){
		with(document.cscform){
			 window.open(__childMulti.value+".jsp?__gorec=&__ack=add"+
			 "&__RecNo="+__maxrec.value+
			 "&__trainingid="+__trainingid.value+
			  "&__headMulti="+__screen.value,"trainExp","left=150,top=150,width=700,height=280,toolbar=no,status=no,scrollbars=yes,resizable=yes");
		}
	}
}
function deleteMulti(){
	with(document.cscform){
      bCon=confirm("ต้องการลบข้อมูลหรือไม่ ?");
      if (bCon==true)	{
		__cmd.value="DelChild";
		submit();
	}
	}
}
function refreshMyPage(){
	with(document.cscform){
      submit();
	}
}
function genExp(){
	if(window.parent.document.cscform.__trainingid.value!=""){
		window.document.cscform.__trainingid.value = window.parent.document.cscform.__trainingid.value;
		window.document.cscform.__roomid.value = window.parent.document.cscform.__roomid.value;
		window.document.cscform.__locid.value = window.parent.document.cscform.__locid.value;
		with(document.cscform){
			__cmd.value = "ack";
			__isgen.value = "1";
			window.parent.restTabPages();
			submit();
		}
	}else{
		alert(MyCode[0]);
		window.parent.document.cscform.__trainingid.selected();
	}
}
</script>
</head>
<body  leftmargin="0" topmargin="0"  onLoad="" >
<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
<script language="javascript">initToolTips();</script>
<form name="cscform" method="post" action="TRA0122_PHATRA.jsp">

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

<%=screen.InitialVariable()%>

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

  <input type="hidden" name="__confirm" value="">
  <input type="hidden" name="__cmd" value="">
  <input type="hidden" name="__screen" value="TRA012_PHATRA">
  <input type="hidden" name="__help" value="">
  <input type="hidden" name="__childMulti" value="TRA0122E_PHATRA">
  <input type="hidden" name="__gorec" value="">
  <input type="hidden" name="__ack" value="">
  <input type="hidden" name="__trainingid" value="<%=screen.getDataLabel("trainingid")%>">
  <input type="hidden" name="__multiTable" value="TTRAINEXP">
  <input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
  <input type="hidden" name="__maxrec" value="<%=screen.getTable("TTRAINEXP").recCount()%>">
  <input type="hidden" name="__notNull" value="<%=screen.getRequire()%>">
  <input type="hidden" name="__isgen" value="0">
  <input type="hidden" name="__roomid" value="<%=screen.getDataLabel("roomid")%>">
  <input type="hidden" name="__locid" value="<%=screen.getDataLabel("locid")%>">

  <table cellpadding="0" cellspacing="0" class="maxsize">
    <tr >
        <td class="header"> TRA0122_PHATRA,
          <script language="javascript">swapLang('Expense');</script> &nbsp;</td>
	</tr>
    <tr>
      <td>
	  <table border="0" cellpadding="0" cellspacing="1" id="rsTable" name="rsTable" bgcolor="#333333" class="maxsize tablewithborder" cols="6">
          <tr >
      <td width="7%" class="row3"><div align="center"><script language='javascript'>swapLang('Del');</script></div></td>
      <td width="13%" class="row3"><div align="center"><a href="javascript:sortTable(1, rsTable);"><%=multi.getLabel("TTRAINEXP","EXPID")%></a></div></td>
      <td width="30%"  class="row3"><div align="center"><a href="javascript:sortTable(2, rsTable);"><script language='javascript'>swapLang('Expense Description');</script></a></div></td>
      <td width="20%"  class="row3"><div align="center"><a href="javascript:sortTable(4, rsTable);"><script language="javascript">swapLang('Expense Group');</script></a></div></td>
			<td style="display:<%=screen.getUProfile().get("dbname").equalsIgnoreCase("NAMTHEUN")?"none":""%>" width="10%"  class="row3"><div align="center"><a href="javascript:sortTable(3, rsTable);"><%=multi.getLabel("TTRAINEXP","EXPENSEPERCAPITA")%></a></div></td>
			<td width="10%"  class="row3"><div align="center"><a href="javascript:sortTable(3, rsTable);"><%=multi.getLabel("TTRAINEXP","ESTIMATE")%></a></div></td>
      <td width="10%"  class="row3"><div align="center"><a href="javascript:sortTable(4, rsTable);"><%=multi.getLabel("TTRAINEXP","USED")%></a></div></td>
          </tr>
		<%
			String isgen = chk.chkNullString(request.getParameter("__isgen"));
			if(isgen.equals("1")){
				Simttraining training = (Simttraining)screen.getRecord("Ttraining");
				training.genExpenseFormRoom();
				training.genExpenseFormTrainer();
			}
			multi.setLabelBox("check box");
			multi.goFirst();
			for(int i=1;!multi.eof();multi.next(),i++){
				multi.getTable().referLangOn();
		%>
          <tr>
      <td class="inframe"><div align="center"><%=multi.getInputCheckBox()%></div></td>
      <td class="inframe"><div align="center"><%=multi.getScript("childMulti", multi.getData("TTRAINEXP","EXPID"))%></div></td>
      <td class="inframe"><div align="center"><%=multi.getData("MEXPENSE","EXPEDESC")%></div></td>
      <td class="inframe"><div align="center"><%=multi.getData("MEXPGRP","EXPGRPDESC")%></div></td>
      <td class="inframe" style="display:<%=screen.getUProfile().get("dbname").equalsIgnoreCase("NAMTHEUN")?"none":""%>"><div align="right"><%=multi.getData("TTRAINEXP","EXPENSEPERCAPITA")%>&nbsp;</div></td>
      <td class="inframe"><div align="right"><%=multi.getData("TTRAINEXP","ESTIMATE")%>&nbsp;</div></td>
      <td class="inframe"><div align="right"><%=multi.getData("TTRAINEXP","USED")%>&nbsp;</div></td>
          </tr>
		<%
			}
		%>
        </table></td>
    </tr>
    <tr>
      <td  class="blankspace"></td>
    </tr>

    <tr>
      <td  class="buttonline" colspan="7"><div align="center">
        <button type="button" class="btn btn-primary width100" swlang code="SW013163" onClick="checkAll();">Select All</button>&nbsp;
        <button type="button" class="btn btn-primary width100" swlang code="SW013164" onClick="decheckAll();">Deselect All</button>&nbsp;
        <!--<button type="button" class="btn btn-primary width100" swlang code="SW013176" onClick="genExp();">GENDATA</button>&nbsp;-->
        <button type="button" class="btn btn-primary width100" swlang code="SW013162" onClick="addMulti();">Add</button>&nbsp;
        <button type="button" class="btn btn-primary width100" swlang code="SW013166" onClick="deleteMulti();">Delete</button>
      </div>
      </td>
    </tr>
    <tr>
      <td  class="blankspace"></td>
    </tr>
  </table>
  <script language="javascript">window.parent.setTabPages();</script>
</form>
</body>
</html>