<%@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.Simttraining"  %>
<%@page import="com.csc.library.formula.FormulaString"  %>
<jsp:useBean id="TRA0125" class="com.csc.library.system.Task" scope="page"/>
<%
TRA0125.setChannel(request,response);
UIManager screen = (UIManager) TRA0125.process("MultiEntry","TRA012",true);
screen.referLangOn();

CheckNull chk = new CheckNull();

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<script type='text/javascript' src='../JS/SCREEN.js'></script>
<script language="javascript">setLang('<%=screen.getUProfile().get("lang")%>');
function goSave() {
	confirmSave();
	goSearch();
}
function goSearch() {search();}
function goDelete() {edelete();}
function goUpdate() {
	update();
	goSearch();
}

function childMulti(record){
	with(document.cscform){
	 window.open(__childMulti.value+".jsp?__cmd=&__gorec="+record+"&__ack=edit"+
			 "&__trainingid="+__trainingid.value+
			 "&__headMulti="+__screen.value,"trainTime","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?__cmd=&__gorec=&__ack=add"+
			 "&__RecNo="+__maxrec.value+
			 "&__trainingid="+__trainingid.value+
			  "&__headMulti="+__screen.value,"trainTime","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 genTime(){
	if(window.parent.document.cscform.__trainingid.value!=""){
		window.document.cscform.__trainingid.value = window.parent.document.cscform.__trainingid.value;
		window.document.cscform.__classdatefrm.value = window.parent.document.cscform.__classdatefrm.value;
		window.document.cscform.__classdateto.value =  window.parent.document.cscform.__classdateto.value;
		window.document.cscform.__timestart.value=  window.parent.document.cscform.__timestart.value;
		window.document.cscform.__timestop.value =  window.parent.document.cscform.__timestop.value;
		window.document.cscform.__timebreak.value =  window.parent.document.cscform.__timebreak.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="TRA0125.jsp">

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

<%=screen.InitialVariable()%>

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

  <input type="hidden" name="__confirm" value="">
  <input type="hidden" name="__cmd" value="multi">
  <input type="hidden" name="__screen" value="TRA012">
  <input type="hidden" name="__help" value="">
  <input type="hidden" name="__childMulti" value="TRA0125E">
  <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="TTRAININGTIME">
  <input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
  <input type="hidden" name="__maxrec" value="<%=screen.getTable("TTRAININGTIME").recCount()%>">
  <input type="hidden" name="__notNull" value="<%=screen.getRequire()%>">

  <input type="hidden" name="__isgen" value="0">
  <input type="hidden" name="__classdatefrm" value="<%=screen.getDataLabel("classdatefrm")%>">
  <input type="hidden" name="__classdateto" value="<%=screen.getDataLabel("classdateto")%>">
  <input type="hidden" name="__timestart" value="<%=screen.getDataLabel("timestart")%>">
  <input type="hidden" name="__timestop" value="<%=screen.getDataLabel("timestop")%>">
  <input type="hidden" name="__timebreak" value="<%=screen.getDataLabel("timebreak")%>">
  
  <table cellpadding="0" cellspacing="0" class="maxsize">
    <tr >	       	
        <td class="header"> TRA0125, 
          <script language="javascript">swapLang('Date');</script>&nbsp;-&nbsp;<script language="javascript">swapLang('Training Time');</script>&nbsp;&nbsp;</td>
	</tr>
    <tr> 
      <td>
	  <table border="0" cellpadding="0" cellspacing="1" id="rsTable" name="rsTable" bgcolor="#333333" class="maxsize" cols="5">   
        <tr >
          <td width="7%"  class="row3"><div align="center"><strong>
              <script language='javascript'>swapLang('Del');</script>
          </strong></div></td>
          <td width="30%"  class="row3"><div align="center"><script language='javascript'>swapLang('Date');</script></a></div></td>
          <td width="10%"  class="row3"><div align="center"><script language="JavaScript">swapLang("Time")</script></a></div></td>
          <td width="20%"  class="row3"><div align="center"><script language="JavaScript">swapLang("Relax Hour")</script></a></div></td>
          <td width="23%"  class="row3"><div align="center"><script language="javascript">swapLang('Total Hour');</script></div></td>
        </tr>
		<%
				String isgen = chk.chkNullString(request.getParameter("__isgen"));
				if(isgen.equals("1")){
					Simttraining ttraining = (Simttraining)screen.getRecord("Ttraining");
					ttraining.genTrainingTime();
				}
				MultiLine multi = screen.getMultiLine("TTRAININGTIME");
				multi.setLabelBox("check box");
				multi.goFirst();	
				FormulaString f = new FormulaString();
				int hourM = 0;
				for(int i=1;!multi.eof();multi.next(),i++){ 			
					hourM += f.Tm_To_Min(Double.parseDouble(multi.getData("TTRAININGTIME","T_HOUR")));
		%>
				<tr>
				  <td class="inframe"><div align="center"> <%=multi.getInputCheckBox()%> </div></td>
				  <td class="inframe">
						<div align="center">
							<%=multi.getScript("childMulti", multi.getTable().getCurrentRecordManager().getCscCalendar("START_DATE").getDDMMYYYY())%>
						</div>
					</td>
				  <td class="inframe"><div align="center"><%=multi.getData("TTRAININGTIME","START_TIME")%> - <%=multi.getData("TTRAININGTIME","END_TIME")%></div></td>
				  <td class="inframe"><div align="center"><%=multi.getData("TTRAININGTIME","TIMEBREAK")%>
				  <td class="inframe"><div align="center"><%=multi.getData("TTRAININGTIME","T_HOUR")%>
				  </div></td>
				</tr>
        <%	
				}
		%>
				<script language='javascript'>
					window.parent.document.getElementById("classhour").innerHTML = '<%=f.Min_to_tm(hourM)%>';
				</script>
      </table></td>
    </tr>
    <tr> 
      <td  class="blankspace"></td>
    </tr>
    <tr>
      <td  class="buttonline" colspan="7"><div align="center">
			<a href="javascript:checkAll();"><img src="../IMAGES/BUTTON/SELECTALL.gif" border="0" align="middle"></a>&nbsp;&nbsp;
			<a href="javascript:decheckAll();"><img src="../IMAGES/BUTTON/DESELECTALL.gif" border="0" align="middle"></a>&nbsp;&nbsp;
			<a href="javascript:genTime();"><img src="../IMAGES/BUTTON/GENDATA.gif" border="0" align="absbottom"></a>&nbsp;&nbsp;
			<a href="javascript:addMulti();" ><img src="../IMAGES/BUTTON/ADD.gif" border="0" align="middle"></a>&nbsp;&nbsp;
			<a href="javascript:deleteMulti();"><img src="../IMAGES/BUTTON/DELETE.gif" border="0" align="middle"></a>
		</div></td>
    </tr>
    <tr> 
      <td  class="blankspace"></td>
    </tr>
  </table>
  <script language="javascript">window.parent.setTabPages();</script>
</form>
</body>
</html>