<?php  
    $objAxpDB->ViewName("Daftar laporan absensi");
    $objAxpDB->ViewTable("vHRAbsensiLaporan");
    $objAxpDB->ViewSQL("SELECT fnid,   ftreport_name FROM tlreport WHERE ftreport_group = 'absensi' order by ftreport_code");
    $objAxpDB->ViewCaption("ID, Nama laporan");
    
    $objAxpDB->FormName(" laporan absensi");
    $objAxpDB->FormSQL("SELECT ftreport_name
                      FROM tlreport");
    $objAxpDB->FormCaption("Nama laporan");
    $objAxpDB->FormPosition("TL");
     $objAxpDB->lengt_object=false;
    if($_REQUEST['id']) {
        $ssql="select * from tlreport where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        $code=$r['ftreport_code'];
        $report_name=" :: ".$r['ftreport_name'];
        switch ($code) {
          case "ab01":
             $objAxpDB->Lookup("employee_code", "SELECT \'SELURUH\' as ftemployee_code,\'SELURUH\' AS ftemployee_name UNION ALL   SELECT ftemployee_code, ftemployee_name FROM tlemployee", "ftemployee_code", "ftemployee_name", -1,false);
             $objAxpDB->FormSQL("SELECT '' as employee_code,
                            CONVERT(null,date) as date_from, 
                            CONVERT(null,date) as date_end 
                            FROM tlreport");
            $objAxpDB->FormCaption("Pegawai, Date From,Date End");
            $objAxpDB->FormPosition("TL, TR,TR");   
          break;
          case "ab02":
             $objAxpDB->Lookup("employee_code", "SELECT \'SELURUH\' as ftemployee_code,\'SELURUH\' AS ftemployee_name UNION ALL   SELECT ftemployee_code, ftemployee_name FROM tlemployee", "ftemployee_code", "ftemployee_name", -1,false);
             $objAxpDB->FormSQL("SELECT '' as employee_code,
                            CONVERT(null,date) as date_from,
                            CONVERT(null,date) as date_end
                            FROM tlreport");
            $objAxpDB->FormCaption("Pegawai, Date From,Date End");
            $objAxpDB->FormPosition("TL, TR,TR");
          break;
        }
    }
    
   
     
    $objAxpDB->Process();
    if(!$_REQUEST['id']) {       
        $objAxpDB->WriteHtmlTable();
    }
    else {
         $objAxpDB->FormName("laporan absensi".$report_name);
         $objAxpDB->ButtonShow("generate_report,print_report");
        $objAxpDB->reportData();
    }