<?php  
    $objAxpDB->ViewName("Daftar laporan preproduksi");
    $objAxpDB->ViewTable("vPRLaporanPreproduksi");
    $objAxpDB->ViewSQL("SELECT fnid,ftreport_code,  ftreport_name FROM tlreport WHERE ftreport_group = 'preproduksi' order by ftreport_code");
    $objAxpDB->ViewCaption("ID,ftreport_code, Nama laporan");
    
    $objAxpDB->FormName(" laporan preproduksi");
    $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 "p01": //laporan outstanding mingguan
               $objAxpDB->Lookup("pfntrans_type", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 16", "fntrans_status_code", "fttrans_status_name", -1,true);
               $objAxpDB->FormSQL("SELECT
                                    '' as pfntrans_type,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");

                $objAxpDB->FormCaption("Cara Kirim,Date From,Date End");
                $objAxpDB->FormPosition("TL,TR, TR");
                break;
            case "p02": //laporan MPOR
           
                $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;
            break;
           
            case "p03": //laporan mrp produksi
            
            break;
            case "p04": //laporan production request
             $objAxpDB->FormSQL("SELECT
                        CONVERT(null,date) as date_from,
                        CONVERT(null,date) as date_end ,
						'' as ftstock_group_code,
						'' as ftcolor_code,
						'' as ftsize_code,
						'' as ftkaca_helm_code
                        FROM tlreport");
				$objAxpDB->Lookup("ftstock_group_code", "SELECT \'SELURUH\' AS ftstock_group_code, \'SELURUH\' AS ftstock_group_name UNION ALL SELECT ftstock_group_code,ftstock_group_name FROM tlstock_group", "ftstock_group_code", "ftstock_group_name", -1,false);
				$objAxpDB->Lookup("ftcolor_code", "SELECT  \'SELURUH\' AS ftcolor_code,  \'SELURUH\' AS ftcolor_name UNION ALL SELECT ftcolor_code, ftcolor_name FROM tlcolor", "ftcolor_code", "ftcolor_name", -1,false);
				$objAxpDB->Lookup("ftsize_code", "SELECT \'SELURUH\' AS ftsize_code, \'SELURUH\' AS ftsize_name  UNION ALL SELECT ftsize_code, ftsize_name FROM tlsize", "ftsize_code", "ftsize_name", -1,false);
				$objAxpDB->Lookup("ftkaca_helm_code", "SELECT \'SELURUH\' AS ftkaca_helm_code, \'SELURUH\' AS ftkaca_helm_name UNION ALL SELECT ftkaca_helm_code, ftkaca_helm_name FROM tlkaca_helm", "ftkaca_helm_code", "ftkaca_helm_name", -1,false);

                $objAxpDB->FormCaption("Date From,Date End, Group, Warna, Size, Kaca");
                $objAxpDB->FormPosition("TL, TL,TR, TR,TR, TR,TR, TR");
            break;
            case "p05": //laporan production sheet
             $objAxpDB->FormSQL("SELECT
                        CONVERT(null,date) as date_from,
                        CONVERT(null,date) as date_end ,
						'' as ftstock_group_code,
						'' as ftcolor_code,
						'' as ftsize_code,
						'' as ftkaca_helm_code
                        FROM tlreport");
				$objAxpDB->Lookup("ftstock_group_code", "SELECT \'SELURUH\' AS ftstock_group_code, \'SELURUH\' AS ftstock_group_name UNION ALL SELECT ftstock_group_code,ftstock_group_name FROM tlstock_group", "ftstock_group_code", "ftstock_group_name", -1,false);
				$objAxpDB->Lookup("ftcolor_code", "SELECT  \'SELURUH\' AS ftcolor_code,  \'SELURUH\' AS ftcolor_name UNION ALL SELECT ftcolor_code, ftcolor_name FROM tlcolor", "ftcolor_code", "ftcolor_name", -1,false);
				$objAxpDB->Lookup("ftsize_code", "SELECT \'SELURUH\' AS ftsize_code, \'SELURUH\' AS ftsize_name  UNION ALL SELECT ftsize_code, ftsize_name FROM tlsize", "ftsize_code", "ftsize_name", -1,false);
				$objAxpDB->Lookup("ftkaca_helm_code", "SELECT \'SELURUH\' AS ftkaca_helm_code, \'SELURUH\' AS ftkaca_helm_name UNION ALL SELECT ftkaca_helm_code, ftkaca_helm_name FROM tlkaca_helm", "ftkaca_helm_code", "ftkaca_helm_name", -1,false);

                $objAxpDB->FormCaption("Date From,Date End, Group, Warna, Size, Kaca");
                $objAxpDB->FormPosition("TL, TL,TR, TR,TR, TR,TR, TR");
            break;
          case "p06":
               $objAxpDB->Lookup("pftcustomer_code", "SELECT \'SELURUH\' as ftcustomer_code,\'SELURUH\' AS ftcustomer_name UNION ALL   SELECT ftcustomer_code, ftcustomer_name FROM tlcustomer", "ftcustomer_code", "ftcustomer_name", -1,false);
               $objAxpDB->FormSQL("SELECT
                                    '' as pftcustomer_code,
                                    CONVERT(null,date) as date_from
                                    FROM tlreport");

                $objAxpDB->FormCaption("Customer,Date From");
                $objAxpDB->FormPosition("TL,TL");
            break;
                
        }
        $objAxpDB->FormName("laporan preproduksi".$report_name);
          $objAxpDB->ButtonShow("generate_report,print_report"); 
    }
    
  
     
    $objAxpDB->Process();
    if(!$_REQUEST['id']) {
       
        $objAxpDB->WriteHtmlTable();
    }
    else {
        $objAxpDB->reportData();
    }
    
?>
