<?php
 session_cache_expire(1440);
session_start();
session_name("insys");
include "include/config.php";
include "include/functions.php";
//include "class/template_class.php";
include "include/report_generator.php";

$dir="report/hrd/print/";
$paramsx=array();

switch ($_REQUEST['form']) {
    case "cuti":
        $ssql="select ftleave_no from txleave where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        
        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftleave_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr01_leave",$paramsx);
        
    break;
     case "pembayaranuanglembur":
        $ssql="select ftovertime_money_no from txovertime_money_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        
        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftovertime_money_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr02_overtime_money",$paramsx);
    break;
     case "thr":
        $ssql="select ftthr_no from txthr_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        
        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftthr_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr03_thr",$paramsx);
    break;
	case "pinjaman":
        $ssql="select ftloan_no from txloan where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        
        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftloan_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr04_loan",$paramsx);
    break;
    case "pembayaranpinjaman":
        $ssql="select ftloan_payment_no from txloan_payment_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        
        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftloan_payment_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr05_loan_payment",$paramsx);
    break;
    case "slipgajitipe1":     
    case "slipgajitipe2":
    case "slipgajitipe3":
         if(isset($_REQUEST['fdtrans_date'])) {
            $ssql="select fdstart_date,fdend_date
                from txpayroll_slip_hdr 
                where fnsalary_type=0 AND fdtrans_date='".CDate($_REQUEST['fdtrans_date'])."'";

            $rs=mysql_query($ssql);
            $r=mysql_fetch_assoc($rs);
            $paramsx[]=array("name"=>"date_trans",
                              "value"=>CDate($_REQUEST['fdtrans_date'])." 00:00:00",
                              "type"=>"date");
                                        
             $paramsx[]=array("name"=>"date_from",
                              "value"=>$r['fdstart_date']." 00:00:00",
                              "type"=>"date");
                $paramsx[]=array("name"=>"date_end",
                          "value"=>$r['fdend_date']." 00:00:00",
                          "type"=>"date");
                                        
              $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
//             pr($paramsx);
            if($_REQUEST['fntype']=='0') {
                 show_report($dir."cr07_rekap_tipe1_2",$paramsx);
            }
            elseif($_REQUEST['fntype']=='1') {
                 show_report($dir."cr07_rekap_tipe1_pecahan_2",$paramsx);
            }
            else {
                 show_report($dir."cr06_slip_pecahan_gaji",$paramsx);
            }
            

        }
        else {
            $ssql="select ftpayroll_slip_no from txpayroll_slip_hdr where fnid='{$_REQUEST['id']}'";
            $rs=mysql_query($ssql);
            $r=mysql_fetch_assoc($rs);

            $paramsx[]=array("name"=>"trans_no",
                              "value"=>$r["ftpayroll_slip_no"],
                              "type"=>"string");
               $paramsx[]=array("name"=>"username",
                              "value"=>$_SESSION['username'],
                              "type"=>"string");
            #show_report($dir."cr06_slip_gaji",$paramsx);
             show_report($dir."cr06_slip_gaji2",$paramsx);
        }
    break;
    case "slipgajitipe1_cetak_slip_crosstab":
    case "slipgajitipe2_cetak_slip_crosstab":
    case "slipgajitipe3_cetak_slip_crosstab":
        $ssql="select ftpayroll_slip_no from txpayroll_slip_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftpayroll_slip_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr06_slip_gaji_crosstab2",$paramsx);
    break;
     case "perhitungantunjangantambahan_cetak_slip_crosstab":
        $ssql="select ftpayroll_slip_no from txpayroll_slip_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftpayroll_slip_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr06_tunjangan_tambahan_crosstab",$paramsx);
    break;
     case "perhitungantunjangantambahan":
        $ssql="select ftpayroll_slip_no from txpayroll_slip_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftpayroll_slip_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."cr06_tunjangan_tambahan",$paramsx);
    break;
    
     case "cetak_slip_lembur":
        $ssql="select ftpayroll_slip_no,fdstart_date_overtime,fdend_date_overtime from txpayroll_slip_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftpayroll_slip_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"date_from",
                          "value"=>($r['fdstart_date_overtime'])." 00:00:00",
                          "type"=>"date");
          $paramsx[]=array("name"=>"date_end",
                          "value"=>($r['fdend_date_overtime'])." 00:00:00",
                          "type"=>"date");
                                    
           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");

                                                         
        show_report($dir."cr06_slip_gaji_lembur2",$paramsx);
    break;
     case "cetak_slip_lembur_tertunda":
        $ssql="select ftpayroll_slip_no,fdstart_date_overtime,fdend_date_overtime from txpayroll_slip_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftpayroll_slip_no"],
                          "type"=>"string");
           $paramsx[]=array("name"=>"date_from",
                          "value"=>($r['fdstart_date_overtime'])." 00:00:00",
                          "type"=>"date");
          $paramsx[]=array("name"=>"date_end",
                          "value"=>($r['fdend_date_overtime'])." 00:00:00",
                          "type"=>"date");

           $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");


        show_report($dir."cr06_slip_gaji_lembur2_tertunda",$paramsx);
    break;

}