<?php  
    $objAxpDB->ViewName("Daftar laporan ppic");
    $objAxpDB->ViewSQL("SELECT fnid,ftreport_code,   ftreport_name FROM tlreport WHERE ftreport_group = 'ppic' order by ftreport_code");
    $objAxpDB->ViewCaption("ID,Kode Laporan, Nama laporan");
    
    $objAxpDB->FormName(" laporan ppic");
    $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 "ppic01":
             $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_setengah_jadi", "ftitem_code", "ftitem_name", -1,false);
             $objAxpDB->FormSQL("SELECT '' as ftitem_code 
                            FROM tlreport");
            $objAxpDB->FormCaption("Kode Barang ");
            $objAxpDB->FormPosition("TL ");   
          break;
          case "ppic02":
              $objAxpDB->FormSQL("SELECT 
                            CONVERT(null,date) as date_from,
                            CONVERT(null,date) as date_end
                            FROM tlreport");
            $objAxpDB->FormCaption("Date From,Date End");
            $objAxpDB->FormPosition("TL, TL");
          break;
		   case "ppic03":
            $objAxpDB->FormSQL("SELECT 
                            CONVERT(null,date) as date_from,
                            CONVERT(null,date) as date_end
                            FROM tlreport");
            $objAxpDB->FormCaption("Date From,Date End");
            $objAxpDB->FormPosition("TL, TL");
          break;
        }
    }
    
   
     
    $objAxpDB->Process();
    if(!$_REQUEST['id']) {       
        $objAxpDB->WriteHtmlTable();
    }
    else {
         $objAxpDB->FormName("laporan ppic".$report_name);
         $objAxpDB->ButtonShow("generate_report,print_report");
        $objAxpDB->reportData();
    }