<%@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.*,org.json.simple.*"  %>
<jsp:useBean id="AS103" class="com.csc.library.system.Task" scope="page" />
<%
	AS103.setChannel(request,response);
	UIManager screen = (UIManager) AS103.process("MultiEntry","AS103");
	screen.referLangOn();
	MultiLine multi = screen.getMultiLine("TAPSPERIOD_CONDITION1");
        if(request.getParameter("__cmd") == null){
			screen.getTable("TAPSPERIOD_CONDITION1").clearRecord();
        }
	multi.setLabelBox("check box");
	
	if((request.getParameter("__cmd")!=null)&&(request.getParameter("__cmd").equals("ack"))){		
		if((request.getParameter("__manyChild")!=null)&&(request.getParameter("__manyChild").equals("true"))){
			screen.getRecord().getString("gen");
		}else{
			screen.getTable("TAPSPERIOD_CONDITION1").goRec(screen.getTable("TAPSPERIOD_CONDITION1").recCount(),false);	
			DbRecord rec=screen.getTable("TAPSPERIOD_CONDITION1").getCurrentRecordManager();
			screen.getTable("TAPSPERIOD_CONDITION1").goRec(screen.getTable("TAPSPERIOD_CONDITION1").recCount()-1,false);	
			rec.set(screen.getTable("TAPSPERIOD_CONDITION1").getMinorKey(),screen.getTable("TAPSPERIOD_CONDITION1").getInt(screen.getTable("TAPSPERIOD_CONDITION1").getMinorKey())+1);	
			rec.set("CONDITIONID",screen.getTable("TAPSPERIOD_CONDITION1").getString("CONDITIONID"));
			rec.set("COMPANYID",screen.getUProfile().get("companyid"));
			rec.set("CONDITION_APPROVER",request.getParameter("__condition_approver"));
			rec.set("CONDITION_FIELD",request.getParameter("__condition_field"));
		}
	}
	
	if((request.getParameter("__cmd")!=null)&&(request.getParameter("__cmd").equals("addChild"))){		
		screen.getTable("TAPSPERIOD_CONDITION1").goRec(screen.getTable("TAPSPERIOD_CONDITION1").recCount(),false);		
		DbRecord rec=screen.getTable("TAPSPERIOD_CONDITION1").getCurrentRecordManager();
		screen.getTable("TAPSPERIOD_CONDITION1").goRec(screen.getTable("TAPSPERIOD_CONDITION1").recCount()-1,false);
		rec.set(screen.getTable("TAPSPERIOD_CONDITION1").getMinorKey(),screen.getTable("TAPSPERIOD_CONDITION1").getInt(screen.getTable("TAPSPERIOD_CONDITION1").getMinorKey())+1);	
		rec.set("CONDITIONID",screen.getTable("TAPSPERIOD_CONDITION1").getString("CONDITIONID"));
		rec.set("COMPANYID",screen.getUProfile().get("companyid"));
		rec.set("CONDITION_APPROVER",request.getParameter("__condition_approver"));
		rec.set("CONDITION_FIELD",request.getParameter("__condition_field"));
	}
	
	CheckNull chk=new CheckNull();
	ThaiUtilities thatUtils = new ThaiUtilities();
	
	String style ="";
	String __cmd  = chk.chkNullString(request.getParameter("__cmd"));

	if(screen.getTable("TAPSPERIOD_CONDITION1").recCount()==0){
		//out.println("<br>"+"33333");
		DbRecord rec1=screen.getTable("TAPSPERIOD_CONDITION1").getNewRecord();
		screen.getTable("TAPSPERIOD_CONDITION1").goRec(screen.getTable("TAPSPERIOD_CONDITION1").recCount(),false);	
		rec1.set(screen.getTable("TAPSPERIOD_CONDITION1").getMinorKey(),"1");
		rec1.set("CONDITION_APPROVER",request.getParameter("__condition_approver"));
		rec1.set("CONDITION_FIELD",request.getParameter("__condition_field"));
		screen.getTable("TAPSPERIOD_CONDITION1").putNewRecord(rec1);
	}
%>
<html ng-app="myHR">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../JS/SCREEN.js"></script>
<script language="javascript">setLang('<%=screen.getUProfile().get("lang")%>');</script>
<script type='text/javascript' src='../JS/jquery-1.11.1.min.js'></script>
<script type='text/javascript' src='../JS/jquery-ui-1.11.4.js'></script>
<script type='text/javascript' src='../JS/angular-1.3.15/angular.js'></script>
<script type='text/JavaScript' SRC='../JS/ANGULAR/SCREEN_ANGULAR.js'></script>
<script type='text/javascript' src='../JS/DATEINPUT.js'></script>
<script type='text/javascript' src='../JS/ICONSMENU.js'></script>
<script type='text/javascript' src='../JS/VIEWCALENDAR.js'></script>
<script language="JavaScript" src="../JS/DateTimeDiff.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" type="text/JavaScript">
<!--
function deleteMulti(){
	with(document.cscform){
		bCon=confirm(MyCode[4]);
	 	if (bCon==true)	{
			__cmd.value="DelChild";
			submit();
		}
	}
}

function saveChild(){
	with(document.cscform){
		__cmd.value="addChild";
		__ack.value="add";
		__clean.value = "1";
		action="AS103.jsp";
		submit();
	}
}

function saveManyChild(){
	with(document.cscform){
		__cmd.value="ack";
		__ack.value="ack";
		__manyChild.value="true";
		__clean.value = "1";
		action="AS103.jsp";
		submit();
	}
}

function childMulti(record){
	with(document.cscform){
		window.open(__childMulti.value+".jsp?__cmd=&__gorec="+record+"&__ack=edit&__codeid="+window.cscform.__codeid.value+"&__companyid="+window.cscform.__companyid.value);
		//submit();
	}
}

function hotLink(page){
	window.open(page,"Help","left=150,top=150,width=700,height=500,toolbar=no,status=no,scrollbars=yes");
}

function preGohelp(inputName,line_no){
	with(document.cscform){
		var helpName = "";
		if(__condition_field.value=="BU1"){
			helpName = "MBU1HELP";
		}else if(__condition_field.value=="BU2"){
			helpName = "MBU2HELP";
		}else if(__condition_field.value=="BU3"){
			helpName = "MBU3HELP";
		}
		goHelp(helpName,inputName,line_no);
	}
}

function goHelp(helpName,inputName,line_no) {
	var helpReturn;
	var fcon=document.cscform.__fixCon.value;
	if (inputName.indexOf("__TAPSPERIOD_CONDITION1$FIELDID$")==0) {
	 	if(helpName=="MBU1HELP"){
			helpReturn = inputName+":BU1ID,__TAPSPERIOD_CONDITION1$FIELDDESC$"+line_no+":EDESC";
		}else if(helpName=="MBU2HELP"){
			helpReturn = inputName+":BU2ID,__TAPSPERIOD_CONDITION1$FIELDDESC$"+line_no+":EDESC";
		}else if(helpName=="MBU3HELP"){
			helpReturn = inputName+":BU3ID,__TAPSPERIOD_CONDITION1$FIELDDESC$"+line_no+":EDESC";
		}
	}
	linkHelp_Return(helpName,helpReturn);
	document.cscform.__fixCon.value = fcon;
}

function showHelp1(page){
	with(document.cscform){
    	action=page;
	   	submit();
  	}
}

function setTextBox(str,obj){
	with(document.cscform){
    	for (j=0;j<elements.length; j++){
			if(elements[j].name.indexOf(str) != -1){
				//alert(eval(obj+".value"));
				elements[j].value = eval(obj+".value");
			}
		}
	}
}

function chBox(){
 	with (document.cscform){
  		if(checkval.checked){
			checkAll();
		}else{
			decheckAll();
		}
   	}
}

function GoSave(){	confirmSave(); }

function GoUpdate(){ update(); }

function GoDelete(){ edelete(); }
 
function GoSearch(){ search(); }

function beforeCalendar(mtxt,fname){
	var startdates="";
	var strtmp=fname;
    with(document.cscform){
		for(i=0;i<elements.length;i++){
			if(elements[i].type=="text"){
				if(elements[i].name.indexOf(strtmp)>-1){
					startdates+=","+elements[i].name;
					 //  alert(" mytxt : "+startdates +"name : "+elements[i].name);
				}
			}
		}
		viewCal(''+mtxt+startdates+'')
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function clearCondition(){
	with(document.cscform){
		bCon=confirm(MyCode[4]);
	 	if (bCon==true)	{
			var elements = document.getElementsByTagName("input");
			for(var i = 0; i < elements.length; i++) {
				if(elements[i].name.indexOf("__tapsperiod_condition1:")>-1){
					elements[i].checked = true;
				}
			}
			__cmd.value="DelChild";
			submit();
		}else{
			var elements = document.getElementsByTagName("input");
			for(var i = 0; i < elements.length; i++) {
				if(elements[i].name.indexOf("__TAPSPERIOD_CONDITION1$CONDITION_FIELD$")>-1){
					eval("__condition_field").value = elements[i].value;
				}
			}
		}
	}
}

function setConditionApprover(obj){
	with(document.cscform){
		var field = obj.name.toUpperCase().substring(2,obj.name.length);
		var elements = document.getElementsByTagName("input");
		for(var i = 0; i < elements.length; i++) {
			if(elements[i].name.indexOf(field)>-1){
				eval(elements[i].name).value = obj.value;
			}
		}
	}
}

//-->
</script>
</head>
<body onLoad="MM_preloadImages('../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif')" >
 <div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
<script language="javascript">initToolTips();</script>
<form name="cscform" method="post" action="AS103.jsp">
 

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

<%=screen.InitialVariable()%>

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

<input type="hidden" name="__screen" value="AS103">
  <input type="hidden" name="__help" value="">
  <input type="hidden" name="__cmd" value="">
  <input type="hidden" name="__notNull" value='<%=screen.getRequire()%>'>
  <input type="hidden" name="__childMulti" value="AS103">
  <input type="hidden" name="__gorec" value="">
  <input type="hidden" name="__ack" value="" >
  <input type="hidden" name="__calendar" value="">
  <input type="hidden" name="__clean" value="1">
  <script language="javascript">getInputFormatDate();</script>
  <input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>">  
  <input type="hidden" name="__multiTable" value="TAPSPERIOD_CONDITION1">
  <input type="hidden" name="__helpReturn" value="">
  <input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
  <% if (screen.getDataLabel("employeeid").equals("")) {%>
  <input type="hidden" name="__employeeid" value="<%=screen.getUProfile().get("actor")%>">
  <% } else {%>
  <input type="hidden" name="__employeeid" value="<%=screen.getDataLabel("employeeid")%>">
  <%}%>	
  <input type="hidden" name="__fixCon" value="">
  <input type="hidden" name="__cmdchild" value="">
  <input type="hidden" name="__autonum" value="CONDITIONID, ">  
  <input type="hidden" name="__wfcmd" value="false">
  <input type="hidden" name="__wf_status" value="<%=chk.chkNullString(request.getParameter("__wf_status"))%>">
  <input type="hidden" name="__maxrec" value="<%=screen.getTable("TAPSPERIOD_CONDITION1").recCount()%>">
  <input type="hidden" name="__lastrec" value="<%=screen.getTable("TAPSPERIOD_CONDITION1").recCount()%>">
  <input type="hidden" name="__manyChild" value="" >	 	 
  <input type="hidden" name="totaltime" value=""	>
  	<div align="center">
  	<script language="javascript"> 
		var swap = new swaplang();
	//var titlename = swap.swap2String("SW012692");
    //	document.write(Icons("AS103,"+titlename)); 
    	document.write(Icons("AS103,KPIs SetUp")); 
	</script>		
	<br>
	<table cellpadding="0"  cellspacing="0" class="maxsize">
    <tr >
    	<td class="header"> AS103,&nbsp;KPIs SetUp&nbsp;</td>
	</tr>
    <tr >
    	<td  colspan="2"> <div align="center">
        	<table  class="maxsize" cellpadding="0" cellspacing="0" >
            <tr>
            	<td  class="blankspace"> 
					<table class="maxsize" border="0" cellpadding="0" cellspacing="0" >
                		<tr>
                    		<td colspan="9" ><div align="center">
                        		<table class="maxsize"  border="1" align="center" cellpadding="0" cellspacing="0">
									<tr>
										<td width="15%" ><div align="right"><%=screen.getLabel("CONDITIONID")%>&nbsp;</div></td>
										<td width="30%"><span align="left"><%=screen.getInput("CONDITIONID")%></td>
									</tr>
									<tr>
										<td><div align="right"><%=screen.getLabel("CONDITION_APPROVER")%>&nbsp;</div></td>
										<td><span align="left"><%=screen.getInput("CONDITION_APPROVER")%></td>
									</tr>
									<tr>
										<td><div align="right"><%=screen.getLabel("CONDITION_FIELD")%>&nbsp;</div></td>
										<td><span align="left"><%=screen.getInput("CONDITION_FIELD")%></td>
									</tr>
									<tr>
										<td colspan="4" class="blankspace"></td>
									</tr>
                            </table>
                    	</div>
						</td>
                    </tr>
                    <tr>
						<td colspan="9"> 
					  		<table class="maxsize"  border="1" align="center" cellpadding="1" cellspacing="1" bgcolor="#666666">
								<tr>
									<td width="" align="center" valign="middle" class="title1"><input type="checkbox" name="checkval" value="all" onClick="chBox();" ></td>
									<td width="" class="title1"><div align="center">No.</div></td>
									<td width="" class="title1"><div align="center"><%=multi.getLabel("TAPSPERIOD_CONDITION1","FIELDID")%></div></td>
									<td width="" class="title1"><div align="center"><%=multi.getLabel("TAPSPERIOD_CONDITION1","CONDITION_STATUS")%></div></td>
								</tr>
						<%
						  	screen.getTable("TAPSPERIOD_CONDITION1").first();
							for(int i=1;!multi.eof();i++){
						%>
								<tr>
									<td><div align="center"><%=multi.getInputCheckBox()%><input name="__TAPSPERIOD_CONDITION1$CONDITIONID$<%=multi.getData("TAPSPERIOD_CONDITION1","LINE_NO")%>" value="<%=multi.getData("TAPSPERIOD_CONDITION1","CONDITIONID")%>" type="hidden"></div></td>
									<td><div align="center"><%=i%></div></td>
									<td><div align="center"><%=multi.getInput("TAPSPERIOD_CONDITION1","FIELDID")%>&nbsp;<a href="javascript:preGohelp('__TAPSPERIOD_CONDITION1$FIELDID$<%=multi.getData("TAPSPERIOD_CONDITION1","LINE_NO")%>','<%=multi.getData("TAPSPERIOD_CONDITION1","LINE_NO")%>')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image21','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image21" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;<%=multi.getInput("TAPSPERIOD_CONDITION1","FIELDDESC")%><span style="display:none"><%=multi.getInput("TAPSPERIOD_CONDITION1","CONDITION_APPROVER")%><%=multi.getInput("TAPSPERIOD_CONDITION1","CONDITION_FIELD")%></span></div></td>
									<td><div align="center"><%=multi.getInput("TAPSPERIOD_CONDITION1","CONDITION_STATUS")%></div></td>
								</tr>
						<%
								multi.next();
							}
						%>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <tr >
                <td class="blankspace"></td>
              </tr>     
            <tr >
 		<td class="blankspace" colspan="2"><div align="center"> 
			<a href='javascript:saveChild();'><img src="../IMAGES/BUTTON/ADD.gif"  border="0"></a>&nbsp;&nbsp;
            <a href='javascript:deleteMulti();'><img src="../IMAGES/BUTTON/DELETE.gif"  border="0"></a>
		</div></td>
   	</tr>
			<tr >
			  <td class="blankspace"></td>
			  </tr>
            </table>
          </div></td>
      </tr>
	    <%if(screen.getDataLabel("CREATE_BY")!=""){ %>
			<tr>
				<td align="right">
					<%
					String userNameID = "";
					String EmpID = "";
					String FULLname = "";
					DbInquiry inq = new InitialInquiry(screen.getUProfile()).getDbInquiry("Memployee", false);
					inq.setColumn("*");
					inq.setFilter("employeeid='"+screen.getDataLabel("CREATE_BY")+"' ");
					DbInquiry child = new InitialInquiry(screen.getUProfile()).getDbInquiry("Muser", false);
					child.setColumn("*");
					inq.putChild(child);
					inq.refresh();
					if(inq.next()){
						userNameID = chk.chkNullString(inq.getChild("muser").getString("usernameid"),"--");
						EmpID = chk.chkNullString(inq.getString("employeeid"),"--");
						FULLname = chk.chkNullString(inq.getString("fullname"),"--");
					}
					%>
					Create By : <%//=screen.getDataLabel("CREATE_BY")%> <%=userNameID%> , <%=EmpID%> , <%=FULLname%> : <%=screen.getDataLabel("CREATE_DATE")%> : <%=screen.getDataLabel("CREATE_TIME")%>
				</td>
			</tr>
		<%}%>
      <tr >
        <td  class="bottom"></td>
      </tr>
    </table>
  </div>	

<!----------BEGIN CSC ENDING ZONE ------------------------>

<%=screen.endJSP()%>

<!----------END CSC ENDING ZONE -------------------------->

</form>
</body>
</html>
