package WEB-INF.classes.wenrgise.report.excel;

import java.util.ArrayList;
import wenrgise.report.excel.Heading;

public class ExcelReportInformation {
  private String reportName;
  
  private String reportQuery;
  
  private ArrayList reportHeader;
  
  public int TYPE_STRING = 1;
  
  public int TYPE_BIG_DECIMAL = 2;
  
  public ExcelReportInformation(String sReportName) {
    this.reportName = sReportName;
  }
  
  public String getReportQuery(String inputparam1, String inputparam2) {
    if (this.reportName.equalsIgnoreCase("EMP_REPORT")) {
      this.reportQuery = "SELECT EMP_NO,EMP_NAME FROM EMP_MAST";
    } else if (this.reportName.equalsIgnoreCase("PF_REPORT")) {
      this.reportQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("SELECT hep.emp_no EMP_NO,\n       decode(hep.emp_type,'D','DIRECT','S','SECONDED',hep.emp_type) EMP_TYPE,\n       hep.first_name || ' ' || hep.middle_name || ' ' || hep.last_name  EMP_NAME,\n       hep.pf_number PF_NUMBER,\n       hist.basic EMP_BASIC,\n       nvl(hist.pf_dedn, 0) EPF,\n       funcchecklimit(hist.basic,6500) COMPANY_BASIC,\n       nvl(hist.pf_dedn,0)- (case when add_months(hep.dob,58*12) >= to_date(").concat(String.valueOf(inputparam1))).concat(String.valueOf(",'yyyymm')\n"))).concat(String.valueOf("                                  then round(funcchecklimit(hist.basic,6500)*8.33/100)\n"))).concat(String.valueOf("                                  else 0 end) CPF,\n"))).concat(String.valueOf("       (case when add_months(hep.dob,58*12) >= to_date("))).concat(String.valueOf(inputparam1))).concat(String.valueOf(",'yyyymm')\n"))).concat(String.valueOf("             then round(funcchecklimit(hist.basic,6500)*8.33/100)\n"))).concat(String.valueOf("             else 0 end) FPF,\n"))).concat(String.valueOf("       2*nvl(hist.pf_dedn, 0) total\n"))).concat(String.valueOf("\n"))).concat(String.valueOf("  FROM hrm_emp_pers        hep,\n"))).concat(String.valueOf("       pay_last_12mth_hist hist,\n"))).concat(String.valueOf("       pay_emp_ytm_mast    peym,\n"))).concat(String.valueOf("       gen_site_mst        gsm\n"))).concat(String.valueOf(" WHERE hep.id = hist.e_per_dtl_id\n"))).concat(String.valueOf("   and hist.e_per_dtl_id = peym.e_per_dtl_id\n"))).concat(String.valueOf("   and hist.pf_dedn > 0\n"))).concat(String.valueOf("   AND hist.loc_code = gsm.code\n"))).concat(String.valueOf("   AND hist.yyyymm = "))).concat(String.valueOf(inputparam1))).concat(String.valueOf("\n"))).concat(String.valueOf("   and hep.emp_type='"))).concat(String.valueOf(inputparam2))).concat(String.valueOf("'\n"))).concat(String.valueOf("\n"))).concat(String.valueOf("order by hep.emp_type,to_number(hep.pf_number)"));
    } else if (this.reportName.equalsIgnoreCase("PAY_SUMMARY_REPORT")) {
      this.reportQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("SELECT\n  gsm.name as BRANCH,\n  case when gsm.id  in (100200500000001,\n  200200500000100,\n  100200500000039,\n  200200500000121,\n  200200500000146,\n  200200500000094,\n  200200500000112,\n  200200500000040,\n  200200500000042,\n  200200400000045) then\n  gsm.name else\n  pgsm.name end\n  as REGION,\n  H.EMP_NO EMP_NO,\n  h.FIRST_NAME || ' ' || h.MIDDLE_NAME || ' ' || h.LAST_NAME as EMPNAME,\n  h.emp_branch EMP_CATAGORY,\n  gm.name DEPARTMENT,\n  h.pf_number PF_NUMBER,\n  nvl(hist.basic, 0) AS BASIC,\n  hist.hra+hist.addl_hra AS HRA,\n  hist.conv_allow AS CONV_ALLOW,\n  hist.fixed_allow AS FIXED_ALLOW,\n  nvl(hist.misc_pay, 0) as INCENTIVE,\n  (case when hist.e_per_dtl_id in (select pi.e_per_dtl_id\n                                   from pay_image pi\n                                   where pi.yyyymm=").concat(String.valueOf(inputparam1))).concat(String.valueOf("\n"))).concat(String.valueOf("                                   and pi.pay_code_id in (select pc.id from pay_codes pc where pc.pay_code in(123))\n"))).concat(String.valueOf("                                   ) then\n"))).concat(String.valueOf("                                   (select pi.txn_amt\n"))).concat(String.valueOf("                                   from pay_image pi\n"))).concat(String.valueOf("                                   where pi.yyyymm="))).concat(String.valueOf(inputparam1))).concat(String.valueOf("\n"))).concat(String.valueOf("                                   and pi.pay_code_id in (select pc.id from pay_codes pc where pc.pay_code in(123))\n"))).concat(String.valueOf("                                   and pi.e_per_dtl_id=hist.e_per_dtl_id\n"))).concat(String.valueOf("                                   ) else 0.00 end) HRA_REIMB,\n"))).concat(String.valueOf("  hist.OUTSTATION_ALLOW as OUTSTATION_ALLOW,\n"))).concat(String.valueOf("  hist.HILL_STAN_ALLOW,\n"))).concat(String.valueOf("  hist.CHARGE_ALLOW,\n"))).concat(String.valueOf("  hist.flat_maint_allow AS FLAT_MAINT_ALLOW,\n"))).concat(String.valueOf("  hist.ENTERTAIN_ALLOW,\n"))).concat(String.valueOf("  nvl(hist.site_allow,0) as SITE_ALLOW,\n"))).concat(String.valueOf("  nvl(hist.special_allow,0) as SPECIAL_ALLOW,\n"))).concat(String.valueOf("  nvl(hist.lwp_days, 0) as LWP_DAYS,\n"))).concat(String.valueOf("  hist.gross_earning AS GROSSEARN,\n"))).concat(String.valueOf("\n"))).concat(String.valueOf("  hist.PF_DEDN as PF,\n"))).concat(String.valueOf("  hist.prof_tax AS PROFTAX,\n"))).concat(String.valueOf("  hist.ESI_DEDN as ESI,\n"))).concat(String.valueOf("  hist.LWF as LWF,\n"))).concat(String.valueOf("  nvl(hist.MTH_INC_TAX, 0) AS INCOMETAX,\n"))).concat(String.valueOf("  nvl(hist.pl_prin, 0) as PL_PRIN,\n"))).concat(String.valueOf("  nvl(hist.pl_int, 0) as PL_INT,\n"))).concat(String.valueOf("  nvl(hist.cdl_prin, 0) as CDL_PRIN,\n"))).concat(String.valueOf("  nvl(hist.cdl_int, 0) as CDL_INT,\n"))).concat(String.valueOf("  nvl(hist.hbl_prin, 0) as HBL_PRIN,\n"))).concat(String.valueOf("  nvl(hist.hbl_int, 0) as HBL_INT,\n"))).concat(String.valueOf("  nvl(hist.adv_rel, 0) as ADV_REL,\n"))).concat(String.valueOf("  hist.gross_deduction AS TOTALDEDN,\n"))).concat(String.valueOf("  hist.net_earning AS NETEARNING\n"))).concat(String.valueOf("\n"))).concat(String.valueOf("  FROM hrm_emp_pers h, pay_last_12mth_hist hist, pay_emp_ytm_mast mast,gen_wrkgrp_mst gm,\n"))).concat(String.valueOf("  (SELECT H.ID, D.NAME, D.CODE, D.ID AS GRADEID\n"))).concat(String.valueOf("          FROM HRM_CLASS_DTL     D,\n"))).concat(String.valueOf("               HRM_CLASS_MST     M,\n"))).concat(String.valueOf("               HRM_EMP_CLASS_MAP MAP,\n"))).concat(String.valueOf("               HRM_EMP_PERS      H\n"))).concat(String.valueOf("\n"))).concat(String.valueOf("         WHERE D.CLS_MST_ID = M.ID\n"))).concat(String.valueOf("           AND M.CODE = 20\n"))).concat(String.valueOf("           AND MAP.CLS_DT_ID = D.ID\n"))).concat(String.valueOf("           AND H.ID = MAP.E_PER_DTL_ID) GRADE,GEN_SITE_MST GSM,\n"))).concat(String.valueOf("       GEN_SITE_MST PGSM\n"))).concat(String.valueOf("\n"))).concat(String.valueOf(" where hist.E_PER_DTL_ID = H.ID\n"))).concat(String.valueOf("   and mast.e_per_dtl_id = h.id\n"))).concat(String.valueOf("   and h.id=GRADE.ID\n"))).concat(String.valueOf("   AND hist.loc_code = GSM.CODE(+)\n"))).concat(String.valueOf("   AND hist.dept_code = gm.code(+)\n"))).concat(String.valueOf("   AND GSM.Parent_Id=PGSM.ID\n"))).concat(String.valueOf("   AND hist.YYYYMM ="))).concat(String.valueOf(inputparam1))).concat(String.valueOf("\n"))).concat(String.valueOf("   and h.emp_type = '"))).concat(String.valueOf(inputparam2))).concat(String.valueOf("'\n"))).concat(String.valueOf("order by PGSM.Name,EMPNAME"));
    } 
    return this.reportQuery;
  }
  
  public ArrayList getReportHeader() {
    this.reportHeader = new ArrayList();
    if (this.reportName.equalsIgnoreCase("EMP_REPORT")) {
      this.reportHeader.add(new Heading("EMP_NO", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMP_NAME", this.TYPE_STRING));
    } else if (this.reportName.equalsIgnoreCase("PF_REPORT")) {
      this.reportHeader.add(new Heading("EMP_NO", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMP_TYPE", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMP_NAME", this.TYPE_STRING));
      this.reportHeader.add(new Heading("PF_NUMBER", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMP_BASIC", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("EPF", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("COMPANY_BASIC", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("CPF", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("FPF", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("TOTAL", this.TYPE_BIG_DECIMAL));
    } else if (this.reportName.equalsIgnoreCase("PAY_SUMMARY_REPORT")) {
      this.reportHeader.add(new Heading("BRANCH", this.TYPE_STRING));
      this.reportHeader.add(new Heading("REGION", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMP_NO", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMPNAME", this.TYPE_STRING));
      this.reportHeader.add(new Heading("EMP_CATAGORY", this.TYPE_STRING));
      this.reportHeader.add(new Heading("DEPARTMENT", this.TYPE_STRING));
      this.reportHeader.add(new Heading("PF_NUMBER", this.TYPE_STRING));
      this.reportHeader.add(new Heading("BASIC", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("HRA", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("CONV_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("FIXED_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("INCENTIVE", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("HRA_REIMB", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("OUTSTATION_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("HILL_STAN_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("CHARGE_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("FLAT_MAINT_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("ENTERTAIN_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("SITE_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("SPECIAL_ALLOW", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("LWP_DAYS", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("GROSSEARN", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("PF", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("PROFTAX", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("ESI", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("LWF", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("INCOMETAX", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("PL_PRIN", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("PL_INT", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("CDL_PRIN", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("CDL_INT", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("HBL_PRIN", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("HBL_INT", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("ADV_REL", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("TOTALDEDN", this.TYPE_BIG_DECIMAL));
      this.reportHeader.add(new Heading("NETEARNING", this.TYPE_BIG_DECIMAL));
    } 
    return this.reportHeader;
  }
}
