<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.csc.library.system.*,com.csc.library.databean.*,com.csc.library.process.*,com.csc.library.processmanager.*,com.csc.library.utilities.*,java.util.*"%>
<%@ page import="com.csc.library.database.*,com.csc.library.session.*,com.csc.library.formula.*,com.csc.library.session.*,com.csc.library.taxcalculation.*"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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">getTitleName();</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function nlogin(){
	with(document.cscform){
		submit();
	}
}

function clear(){
	with(document.cscform){
		__user.value = "";
	}
}

function MM_preloadimagess() { //v3.0
  var d=document; if(d.imagess){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadimagess.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new images; d.MM_p[j++].src=a[i];}}
}
function goRun(){
	va
}
//-->
</script>
</head>

<body leftmargin="0" topmargin="0">
<div class="centered">
<table class="head1" cellspacing="0">
	<tr>
		<td rowspan="2" class="logo"></td>
		<td colspan="2" class="appname"></td>
		<td class="usernane"></td>
	</tr>
	<tr>
		<td class="beforprogramname"></td>
		<td class="programname"></td>
		<td class="datelogin"></td>
	</tr>
</table>

<form name="testform" method="post" action="" >


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

<%=screen.InitialVariable()%>

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

<table align="center" class="width500" cellpadding="0" cellspacing="0">
	<tr>
		<td colspan="4"><img src="IMAGES/BORDER1.jpg" width="500" height="20"></td>
	</tr>
	<tr>
		<td colspan="4" class="blankspace"></td>
	</tr>
	<tr>
		<td colspan="4" class="row1">
		<div align="center">Please Input Data</div>
		</td>
	</tr>
	<tr>
		<td colspan="3" align="center">
		<%
	
	String empid = request.getParameter("empid");
	
	String companyid = request.getParameter("companyid");
	String dbname = request.getParameter("dbname");
	UProfile up = new UProfile();
	if (dbname==null){
			up.setDbName("MYHRDBS");	
	}else up.setDbName(dbname);
	//up.setSchemaName("PR");
	up.setUserName("M01");
	up.set("companyid",companyid);
	up.set("salary","1");
	up.set("lang","eng");
	up.set("appname","payroll");

	
	if(request.getParameter("ok") != null){
		out.print("<P>Employee id is:"+empid+"</P><BR>");
	 /*
		Simtaxmemployee emp = (Simtaxmemployee)new InitialRecord(up).getDbRecord("Simtaxmemployee");
		emp.set("employeeid",empid);
		emp.set("companyid",companyid);
		DbInquiry emp_pvf = new InitialInquiry(up).getDbInquiry("Mempl_pvf",false);
		emp_pvf.setColumn("*");
		emp.putChild(emp_pvf);
		
		DbInquiry pemp_taxm = new InitialInquiry(up).getDbInquiry("Pmempl_taxm",false);
		emp_pvf.setColumn("*");
		emp.putChild(pemp_taxm);
		
		DbInquiry sala0 = new InitialInquiry(up).getDbInquiry("Msalatype0",false);
		sala0.setColumn("*");
		DbInquiry sala1 = new InitialInquiry(up).getDbInquiry("Msalatype1",false);
		sala1.setColumn("*");
		sala0.putChild(sala1);
		emp.putChild(sala0);
		emp.search();
		
		Tpytran0 tran0 = (Tpytran0)new InitialRecord(up).getDbRecord("Tpytran0");
		tran0.setFetchCompensationTax(true);
		tran0.set("employeeid",empid);
		tran0.set("companyid",companyid);
		
		MyHashMap hm = new MyHashMap(false);
		MyHashMap result = new MyHashMap(false);
		result.put("F0001","150");
		result.put("W001","10000");
		result.put("OT1N","500");
		
		hm.put("SalaryProcess", result);
		tran0.setParam(hm);
		tran0.setEmpTax((EmployeeForTax)emp);
		tran0.initialTaxProcess();

		WithHoldingTaxPayer wtax  = (WithHoldingTaxPayer)tran0;
		
		out.print("WithHoldingTaxPayer <BR>");
		
		out.print("getCurrentMonth:"+wtax.getCurrentMonth()+"<BR>");
		out.print("getCurrentPeriod:"+wtax.getCurrentPeriod()+"<BR>");
		out.print("getEvery:"+wtax.getEvery()+"<BR>");
		
		
		out.print("getPTDPVF:"+wtax.getPTDPVF()+"<BR>");
		out.print("getMTDPVF:"+wtax.getMTDPVF()+"<BR>");
		out.print("getYTDPVF:"+wtax.getYTDPVF()+"<BR>");
		out.print("getOLDPVF:"+wtax.getOLDPVF()+"<BR><BR>");	
		
	
		out.print("getPTDSocialSecurity:"+wtax.getPTDSocialSecurity()+"<BR>");
		out.print("getMTDSocialSecurity:"+wtax.getMTDSocialSecurity()+"<BR>");
		out.print("getYTDSocialSecurity:"+wtax.getYTDSocialSecurity()+"<BR>");
		out.print("getOLDSocialSecurity:"+wtax.getOLDSocialSecurity()+"<BR><BR>");	
		
		out.print("getPTDIncome:"+wtax.getPTDIncome()+"<BR>");
		out.print("getMTDIncome:"+wtax.getMTDIncome()+"<BR>");
		out.print("getYTDIncome:"+wtax.getYTDIncome()+"<BR>");
		out.print("getOLDIncome:"+wtax.getOLDIncome()+"<BR><BR>");
		
		out.print("getMTDTax:"+wtax.getMTDTax()+"<BR>");
		out.print("getYTDTax:"+wtax.getYTDTax()+"<BR>");
		out.print("getOLDTax:"+wtax.getOLDTax()+"<BR>");
		
		out.print("getPTDCompensation:"+wtax.getPTDCompensation()+"<BR>");
		out.print("getMTDCompensation:"+wtax.getMTDCompensation()+"<BR>");
		out.print("getYTDCompensation:"+wtax.getYTDCompensation()+"<BR>");
				
		out.print("getMTDCompensationTax:"+wtax.getMTDCompensationTax()+"<BR>");
		out.print("getYTDCompensationTax:"+wtax.getYTDCompensationTax()+"<BR>");
		
		out.print("getMTDCompensationTot:"+wtax.getMTDCompensationTOT()+"<BR>");
		out.print("getYTDCompensationTot:"+wtax.getYTDCompensationTOT()+"<BR>");
		
		out.println("<BR><BR>");
				
		TaxPayer taxpayer = wtax.getTaxPayer();
		
		out.print("TaxPayer<BR>");

		out.print("getSocialID:"+taxpayer.getSocialID()+"<BR>");		
		out.print("getTaxID:"+taxpayer.getTaxID()+"<BR>");
		out.print("getYearlyIncome:"+taxpayer.getYearlyIncome()+"<BR>");
		out.print("getPVF_ID:"+taxpayer.getPVF_ID()+"<BR>");
		out.print("getMaritalStatus:"+taxpayer.getMaritalStatus()+"<BR>");
		out.print("getMaritalRegister:"+taxpayer.getMaritalRegister()+"<BR>");
		out.print("getSpouseIncome:"+taxpayer.getSpouseIncome()+"<BR>");		
		out.print("getYearOfMarried:"+taxpayer.getYearOfMarried()+"<BR>");
		out.print("getEducationChild:"+taxpayer.getEducationChild()+"<BR>");
		out.print("getUnEducationChild:"+taxpayer.getUnEducationChild()+"<BR>");
		out.print("getAssurrance:"+taxpayer.getAssurrance()+"<BR>");
		out.print("getSpouseAssurrance:"+taxpayer.getSpouseAssurrance()+"<BR>");
		out.print("getSocialSecurity:"+taxpayer.getSocialSecurity()+"<BR>");		
		out.print("getProvidentFund:"+taxpayer.getProvidentFund()+"<BR>");
		
		WithHoldingTaxCalculation wtaxcal = new WithHoldingTaxCalculation(up);
        wtaxcal.setWithHoldingTaxPayer((WithHoldingTaxPayer)tran0);
        //wtaxcal.calculation();
        out.print("get Estimate SocialSecurity:"+wtaxcal.getSocialSecurity()+"<BR>");
		out.print("get Estimate ProvidentFund:"+wtaxcal.getProvidentFund()+"<BR>");
			
		out.print("getInterestHousing:"+taxpayer.getInterestHousing()+"<BR>");		
		out.print("getDonation:"+taxpayer.getDonation()+"<BR>");
		out.print("getRMF:"+taxpayer.getRMF()+"<BR>");
		out.print("getKorBorKhor:"+taxpayer.getKorBorKhor()+"<BR>");
		out.print("getMortgageHouse:"+taxpayer.getMortgageHouse()+"<BR>");
		out.print("getServiceYearCompensation:"+taxpayer.getServiceYearCompensation()+"<BR>");
		out.print("getServiceYearGratuity:"+taxpayer.getServiceYearGratuity()+"<BR>");
		out.print("getCompensation_A:"+taxpayer.getCompensation_A()+"<BR>");
		out.print("getCompensation_B:"+taxpayer.getCompensation_B()+"<BR>");
		out.print("getCompensation_C:"+taxpayer.getCompensation_C()+"<BR>");
		out.print("getCompensation_D:"+taxpayer.getCompensation_D()+"<BR>");
		out.print("getPension:"+taxpayer.getPension()+"<BR>");
		out.print("getAverageSalary:"+taxpayer.getAverageSalary()+"<BR>");
		out.print("getLastSalary:"+taxpayer.getLastSalary()+"<BR>");	
		
		out.print("LTF:"+taxpayer.LTF()+"<BR>");
		out.print("FTHIDCARD:"+taxpayer.FTHIDCARD()+"<BR>");
		out.print("MTHIDCARD:"+taxpayer.MTHIDCARD()+"<BR>");
		out.print("FTHMRYIDCARD:"+taxpayer.FTHMRYIDCARD()+"<BR>");
		out.print("MTHMRYIDCARD:"+taxpayer.MTHMRYIDCARD()+"<BR>");
		out.print("FTHYN:"+taxpayer.FTHYN()+"<BR>");
		out.print("MTHYN:"+taxpayer.MTHYN()+"<BR>");
		out.print("FTHMRYYN:"+taxpayer.FTHMRYYN()+"<BR>");
		out.print("MTHMRYYN:"+taxpayer.MTHMRYYN()+"<BR>");

		out.print("<BR><BR>");
		out.print("Income Per Hour:"+emp.getIncH()+"<BR>");
		out.print("Income Per Day:"+emp.getIncD()+"<BR>");
		out.print("Income Per Week:"+emp.getIncW()+"<BR>");
		out.print("Income Per Month:"+emp.getIncM()+"<BR>");
		out.print("Old Income Per Hour:"+emp.getOldIncH()+"<BR>");
		out.print("Old Income Per Day:"+emp.getOldIncD()+"<BR>");
		out.print("Old Income Per Week:"+emp.getOldIncW()+"<BR>");
		out.print("Old Income Per Month:"+emp.getOldIncM()+"<BR>");
	*/
	}else if(request.getParameter("ok2") != null){
	
	  	String formula  = request.getParameter("formula");
	  	String filter = "employeeid='" + empid + "' and companyid='" + companyid + "'";
		DbRecord emp = new InitialRecord(up).getDbRecord("Simempsalaprocess");
		emp.set("employeeid",empid);
		emp.set("companyid",companyid);
		emp.search();
		
		
		DbInquiry    inqTtime1 = new InitialInquiry(up).getDbInquiry("Tptime_current1", filter, "dateid", false);
	    inqTtime1.setColumn("*");
	    inqTtime1.refresh();
	    inqTtime1.next();
	 	DbRecord inqTtime0 = new InitialRecord(up).getDbRecord("Tptime_current"); 
	 		inqTtime0.set("time0id", inqTtime1.getString("time0id"));
           	inqTtime0.set("dateid",inqTtime1.getString("dateid"));
           	inqTtime0.set("employeeid", inqTtime1.getString("employeeid"));
           	inqTtime0.set("companyid", inqTtime1.getString("companyid"));
           	inqTtime0.search();
	 	TimeCurrentInquiry timeInq = new TimeCurrentInquiry(inqTtime0,inqTtime1);
 /*
		DbRecord inqTtime0 = new InitialRecord(up).getDbRecord("Tptime_current"); 
		TimeCurrentInquiry timeInq = new TimeCurrentInquiry(inqTtime0,inqTtime1);
			inqTtime0.set("time0id", timeInq.getString("time0id"));
           	inqTtime0.set("dateid", timeInq.getString("dateid"));
           	inqTtime0.set("employeeid", timeInq.getString("employeeid"));
           	inqTtime0.set("companyid", timeInq.getString("companyid"));
           	inqTtime0.search();
                        
*/ 
           	
		MmInquiry inqTextend = (MmInquiry)new InitialInquiry(up).getDbInquiry("Textend", filter, true);

			
		EmployeeForFormula femp = (EmployeeForFormula)emp;
		MyFormula dj = new MyFormula();
		String result = "";   
		dj.defineVariable("result",result);
		dj.defineVariable("emp",emp);	
		dj.defineVariable("util",(FormulaUtilityManager)new FormulaUtility(up));
		dj.defineVariable("var",new MyHashMap());
		dj.defineVariable("ttime", (MmInquiry)timeInq);
		//dj.defineVariable("htime", (Tptime_current)inqTtime0);
		dj.defineVariable("textend",inqTextend);
		Object obj = dj.interpret(formula,"fact1");
		out.print("Employee id is:   "+empid+"<BR>");
		out.print("Interpret String is:   "+formula+"<BR><BR>");
		if((obj != null) && (result==null || result.equals("")))
			out.print("Result ==>> "+obj.toString()+"<BR>");
		else
			out.print("Result ==>> "+dj.getVariable("result")+"<BR>");
		out.print("Message:"+dj.getError());
	}
	%>
	</td></tr>
	<tr>
		<td width="176" align="right">	Emp ID:&nbsp;</td><td width="326"><INPUT type="text" name="empid" value="<%=request.getParameter("empid")%>"></td>
	</tr>
	<tr>
		<td align="right">Company ID:&nbsp;</td><td><INPUT type="text" name="companyid" value="10"></td>
	</tr>
	<tr>
		<td align="right">DataBase Name:&nbsp;</td><td><INPUT type="text" name="dbname" value="<%=request.getParameter("dbname")%>"></td>
	</tr>
	<td  colspan="3" align="center">	<INPUT type="submit" name="ok" value="ok">
	</td>
	</tr>
	<tr ><td  colspan="3" align="center">	
	Test Formula
	</td>	</tr>
	
	<tr><td colspan="3" align="center">
      <textarea rows="5" cols="50" name="formula"></textarea>	</td>
	</tr>
	<tr>
		<td colspan="3" align="center">		
		<INPUT type="submit" name="ok2" value="ok" src="IMAGES/BUTTON/OK.gif" height="20" border="0">&nbsp; 
		<INPUT type="reset" src="IMAGES/BUTTON/CANCEL.gif" height="20" border="0"></P>
		<input  type="button" name="run" value="run" onclick="javascript:goRun();">
		</td>		
	</tr>
	<tr>
		<td colspan="4" class="blankspace"></td>
	</tr>
	<tr>
		<td colspan="4"><img src="IMAGES/BORDER-BOTTOM1.jpg" width="500"
			height="20"></td>
	</tr>
</table>

<table width="755" border="0" cellspacing="0" cellpadding="0"
	align="center">
	<tr>
		<td width="95%" background="IMAGES/TPC-WHT-BG.gif">&nbsp;</td>
		<td width="1%"><img src="IMAGES/TPC-WHT-END.gif" width="30"
			height="45"></td>
	</tr>
</table>
</form>
<br>
<div align="center"><font color="0069B3" size="1"
	face="Microsoft Sans Serif, AngsanaUPC"> Human Resource System
Copyright &copy; 2003 Tisco. All Rights Reserved.</font></div>
</div>
</body>
</html>