<?php
    $id=$_REQUEST['idd'];
    $m=$_REQUEST['m'];
    $module= "hrd";
   
    $objAxpDB->ViewName("Daftar laporan $module");
    $objAxpDB->ViewSQL("SELECT fnid,  ftreport_name FROM tlreport WHERE ftreport_group = 'hrd' order by ftreport_code");
    $objAxpDB->ViewCaption("ID, Nama laporan");

    $objAxpDB->FormName(" laporan $module :: Cetakan");

    if(($m=='slipgajitipe1')&&($id=='')) {
        $ssql="SELECT MAX(fdtrans_date) AS fdtrans_date
            FROM txpayroll_slip_hdr
            WHERE fnsalary_type=0 AND
                fnstatus<>9";
        $fdtrans_date=RetRstField($ssql);
        if($fdtrans_date!='') {
            $fdtrans_date="'{$fdtrans_date}'";
        }
        else {
            $fdtrans_date="null";
        }
         $objAxpDB->FormSQL("SELECT  CONVERT($fdtrans_date,date) as fdtrans_date,0 AS fntype,ftreport_name, '$id' as id,'$m' as form
                             FROM tlreport");
          $objAxpDB->Lookup("fntype", "SELECT 0 AS A,'BIASA' AS B UNION ALL SELECT 1 AS A,'PEMBULATAN DAN PECAHAN' AS B UNION ALL SELECT 2 AS A,'SLIP PECAHAN' AS B", "A", "B", 1,true);

        $objAxpDB->FormCaption("Tgl. Gajian, TYPE");
        $objAxpDB->FormPosition("TL,TL,HD,HD,HD");

    }
    else {
         $objAxpDB->FormSQL("SELECT  ftreport_name, '$id' as id,'$m' as form
                      FROM tlreport");
        $objAxpDB->FormCaption(" Nama laporan");
        $objAxpDB->FormPosition("HD,HD,HD");
    }

    $js="document.getElementById('iframe_laporan').style.display='';document.getElementById('iframe_laporan').src='$module.print.php?form=$m&id=$id';";
    if($id) {
          $objAxpDB->FormJS("$js");
    }

    $objAxpDB->Process();
    if(!$_REQUEST['id']) {
        $objAxpDB->WriteHtmlTable();
    }
    else {
         $objAxpDB->FormName("laporan $n".$report_name);
         $objAxpDB->ButtonShow("generate_report, print_report");
        $objAxpDB->reportData();
    }