<?php  
    $objAxpDB->ViewName("Daftar laporan inventory");
    #$objAxpDB->ViewTable("vILaporan");
    $objAxpDB->ViewSQL("SELECT fnid, ftreport_code, ftreport_name FROM tlreport WHERE ftreport_group = 'inventory' and fnstatus = 1 ORDER BY ftreport_code");
    $objAxpDB->ViewCaption("ID, Nama laporan");
    
    $objAxpDB->FormName(" laporan inventory");
    $objAxpDB->FormSQL("SELECT ftreport_name FROM tlreport");
    $objAxpDB->FormCaption("Nama laporan");
    $objAxpDB->FormPosition("TL");
    $objAxpDB->lengt_object=false;
    
    $objAxpDB->LookupMagicQuotes(TRUE);
    // $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name,ftpart_no", "ftitem_code", "ftitem_name",-1,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 "i00":
                // $objAxpDB->Lookup("ftitem_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr WHERE fnstatus=1", "ftitem_code", "ftitem_name", -1,false);
                // $objAxpDB->Lookup("ftitem_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),\' PART NO: \',ftpart_no) as ftitem_name  FROM tlstock_hdr  WHERE fnstatus=1 ORDER BY ftitem_name,ftpart_no ", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name", "ftitem_code", "ftitem_name",-1,false);
                $objAxpDB->Lookup("ftstock_group", "SELECT 'SELURUH' as ftstock_group_code,'SELURUH' AS ftstock_group_name UNION ALL SELECT ftstock_group_code, ftstock_group_name FROM tlstock_group ORDER BY ftstock_group_code ", "ftstock_group_code", "ftstock_group_name", -1,false);
                
                $objAxpDB->FormSQL("SELECT '' as ftitem_code, '' AS ftstock_group FROM tlreport");
                $objAxpDB->FormCaption("Kode Barang, Stock Group");
                $objAxpDB->FormPosition("TL,TR");
                break;
            
            case "i00_1":
                $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("HD, HD");
                break;
            
            case "i01":
                $objAxpDB->Lookup("ftstock_group", "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("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
                // $objAxpDB->Lookup("ftitem_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr WHERE fnstatus=1", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT '' as ftstock_group, '' as ftitem_code,
                                CONVERT(null,date) as date_from, 
                                CONVERT(null,date) as date_end 
                                FROM tlreport");
                $objAxpDB->FormCaption("Stock Group, Kode Barang, Date From, Date End");
                $objAxpDB->FormPosition("TL,TL,TR,TR");   
                break;
          
            case "i05":
                $objAxpDB->Lookup("ftwarehouse", "SELECT 'SELURUH' as ftwarehouse_code,'SELURUH' AS ftwarehouse_name UNION ALL SELECT ftwarehouse_code, ftwarehouse_name FROM tlwarehouse WHERE fnstatus = 1 ", "ftwarehouse_code", "ftwarehouse_name", -1,true);  
                $objAxpDB->Lookup("ftlocation", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name UNION ALL SELECT ftlocation_code, ftlocation_name FROM tllocation WHERE fnstatus = 1", "ftlocation_code", "ftlocation_name", -1,true);  
                //$objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
                $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(IFNULL(ftpart_no,'')) != '' THEN ' ,PART NO: ' ELSE '' END,IFNULL(ftpart_no,'')) as ftitem_name  FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_code ", "ftitem_code", "ftitem_name", -1,false);
                
    
                $objAxpDB->FormSQL("SELECT '' as ftwarehouse,'' as ftlocation,'' as ftitem_code, 
                            CONVERT(null,date) as date_from, 
                            CONVERT(null,date) as date_end 
                            FROM tlreport");
                $objAxpDB->FormCaption("Gudang,Lokasi,Barang,Date From,Date End");
                $objAxpDB->FormPosition("TL,TL,TL,TR,TR");
                break;
            
         case "i06":
            $objAxpDB->Lookup("ftlocation_from", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name UNION ALL   SELECT ftlocation_code, ftlocation_name FROM tllocation", "ftlocation_code", "ftlocation_name", -1,true);
            $objAxpDB->Lookup("ftlocation_to", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name UNION ALL   SELECT ftlocation_code, ftlocation_name FROM tllocation", "ftlocation_code", "ftlocation_name", -1,true);
            
            $objAxpDB->FormSQL("SELECT 
                            CONVERT(null,date) as date_from, 
                            CONVERT(null,date) as date_end,
                            'SELURUH' as ftlocation_from, 'SELURUH' as ftlocation_to
                            FROM tlreport");
            $objAxpDB->FormCaption("Date From,Date End, Location From, Location To");
            $objAxpDB->FormPosition("TL, TL, TR, TR");   
          break;
           case "i07":
            $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 "i08":
            $objAxpDB->Lookup("warehouse", "SELECT 'SELURUH' as ftwarehouse_code,'SELURUH' AS ftwarehouse_name UNION ALL   SELECT ftwarehouse_code, ftwarehouse_name FROM tlwarehouse", "ftwarehouse_code", "ftwarehouse_name", -1,true);  
            $objAxpDB->FormSQL("SELECT '' as warehouse,
                                CONVERT(null,date) as date_from, 
                                CONVERT(null,date) as date_end 
                                FROM tlreport");
            $objAxpDB->FormCaption("Gudang, Date From,Date End");
            $objAxpDB->FormPosition("TL, TR,TR");   
          break;
        
        case "i09":
            $objAxpDB->Lookup("fnwarehouse_type", "SELECT 'SELURUH' as fntrans_status_code,'SELURUH' AS fttrans_status_name UNION ALL  SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 55 and fnactive_status = 1 ", "fntrans_status_code", "fttrans_status_name", -1,true);  
            $objAxpDB->Lookup("ftwarehouse", "SELECT 'SELURUH' as ftwarehouse_code,'SELURUH' AS ftwarehouse_name UNION ALL   SELECT ftwarehouse_code, ftwarehouse_name FROM tlwarehouse", "ftwarehouse_code", "ftwarehouse_name", -1,true);  
            $objAxpDB->Lookup("ftlocation", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name UNION ALL   SELECT ftlocation_code, ftlocation_name FROM tllocation", "ftlocation_code", "ftlocation_name", -1,true);
            $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
            $objAxpDB->FormSQL("SELECT '' AS fnwarehouse_type, '' as ftwarehouse, '' as ftlocation, '' as ftitem_code,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end
                                FROM tlreport");
            $objAxpDB->FormCaption("Tipe Gudang, Gudang, Lokasi,Kode Barang, Date From,Date End");
            $objAxpDB->FormPosition("TL, TL,TL,TL,TR,TR");
            break;
        
        case "i10":
            $objAxpDB->Lookup("stock", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
            $objAxpDB->FormSQL("SELECT '' as stock FROM tlreport");
            $objAxpDB->FormCaption("Barang");
            $objAxpDB->FormPosition("TL");   
            break;

        case "i11":
            $objAxpDB->Lookup("ftcategory_code", "SELECT 'SELURUH' as ftcategory_code,'SELURUH' AS ftcategory_name UNION ALL SELECT fntrans_status_code AS ftcategory_code, fttrans_status_name AS ftcategory_name FROM tstransaction_status WHERE fntrans_group_code = 4 AND fnactive_status=1 ", "ftcategory_code", "ftcategory_name", -1,true);
            $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
            $objAxpDB->Lookup("ftlocation_code", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name  UNION ALL   SELECT ftlocation_code, ftlocation_code FROM tllocation", "ftlocation_code", "ftlocation_name", -1,false);

            $objAxpDB->FormSQL("SELECT
                                '' as ftcategory_code,
                                '' as ftitem_code,
                                '' as ftlocation_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Kategori, Barang, Lokasi,Date From,Date End");
            $objAxpDB->FormPosition("TL,TL,TL, TR,TR");
            break;

        
        case "i12":
            $objAxpDB->Lookup("ftcategory_code", "SELECT 'SELURUH' as ftcategory_code,'SELURUH' AS ftcategory_name UNION ALL SELECT fntrans_status_code AS ftcategory_code, fttrans_status_name AS ftcategory_name FROM tstransaction_status WHERE fntrans_group_code = 3 AND fnactive_status=1 ", "ftcategory_code", "ftcategory_name", -1,true);
            $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
            $objAxpDB->Lookup("ftlocation_code", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name  UNION ALL   SELECT ftlocation_code, ftlocation_code FROM tllocation", "ftlocation_code", "ftlocation_name", -1,false);

            $objAxpDB->FormSQL("SELECT
                                '' as ftcategory_code,
                                '' as ftitem_code,
                                '' as ftlocation_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Kategori, Barang, Lokasi,Date From,Date End");
            $objAxpDB->FormPosition("TL,TL,TL,TR,TR");
            break;
        case "i13":
            $objAxpDB->Lookup("subgroup_code", "SELECT 'SELURUH' as ftstock_subgroup_code,'SELURUH' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);
            $objAxpDB->FormSQL("SELECT
                                '' as subgroup_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Subgroup,Date From,Date End");
            $objAxpDB->FormPosition("TL,TR, TR");
              break;
        case "i14":
            $objAxpDB->Lookup("area_code", "SELECT 'SELURUH' as ftarea_code,'SELURUH' AS ftarea_name UNION ALL   SELECT ftarea_code, ftarea_name FROM tlarea", "ftarea_code", "ftarea_name", -1,true);
            $objAxpDB->FormSQL("SELECT
                                '' as area_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Wilayah,Date From,Date End");
            $objAxpDB->FormPosition("TL,TR, TR");
            break;
        
        case "i15":
                $objAxpDB->Lookup("subgroup_code", "SELECT 'SELURUH' as ftstock_subgroup_code,'SELURUH' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);
    
                $objAxpDB->Lookup("customer_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 customer_code, '' as subgroup_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");

                $objAxpDB->FormCaption("Customer,Subgroup,Date From,Date End");
                $objAxpDB->FormPosition("TL,TL,TR, TR");
              break;
          
        case "i16":
               
            $objAxpDB->FormSQL("SELECT CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");

            $objAxpDB->FormCaption("Subgroup,Date From,Date End");
            $objAxpDB->FormPosition("TL,TR, TR");
            break;
          
        case "i17":

            $objAxpDB->Lookup("customer_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 customer_code, 
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Customer, Date From,Date End");
            $objAxpDB->FormPosition("TL,TL,TL");
            break;
               
        case "i18":

            $objAxpDB->Lookup("subgroup_code", "SELECT 'SELURUH' as ftstock_subgroup_code,'SELURUH' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);

            $objAxpDB->FormSQL("SELECT
                                '' as subgroup_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Subgroup,Date From,Date End");
            $objAxpDB->FormPosition("TL,TL,TL, TL");
            break;
			  
        case "i19":

            $objAxpDB->Lookup("subgroup_code", "SELECT \'SELURUH\' as ftstock_subgroup_code,\'SELURUH\' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);
            $objAxpDB->FormSQL("SELECT
                                '' as subgroup_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Subgroup,Date From,Date End");
            $objAxpDB->FormPosition("TL,TL,TL, TL");
            break;
        
        case "i20":
            $objAxpDB->Lookup( "fncategory_code", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 3", "fntrans_status_code", "fttrans_status_name", -1,true);
            $objAxpDB->Lookup("supplier_code", "SELECT \'SELURUH\' as ftsupplier_code,\'SELURUH\' AS ftsupplier_name UNION ALL   SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier", "ftsupplier_code", "ftsupplier_name",-1,false);
            $objAxpDB->FormSQL("SELECT
                                0 as fncategory_code,
                                '' as supplier_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");
// , '' as pftcategory_code, '' as pftsupplier_code
            $objAxpDB->FormCaption("Kategory, Supplier/Customer,Date From,Date End");
            $objAxpDB->FormPosition("TL,TL, TL, TL");
            break;
            
        case "i21":
            $objAxpDB->Lookup("subgroup_code", "SELECT \'SELURUH\' as ftstock_subgroup_code,\'SELURUH\' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);

            $objAxpDB->FormSQL("SELECT
                                '' as subgroup_code
                                FROM tlreport");

            $objAxpDB->FormCaption("Subgroup");
            $objAxpDB->FormPosition("TL");		  
            break;
            
        case "i22":
            $objAxpDB->Lookup("ftassembly_no", "SELECT 'SELURUH' as ftassembly_no,'SELURUH' AS fdtrans_date UNION ALL   SELECT ftassembly_no, fdtrans_date FROM txassembly_hdr WHERE fnstatus=1", "ftassembly_no", "fdtrans_date", -1,false);
            $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
            
            $objAxpDB->FormSQL("SELECT '' as ftassembly_no,
                                '' as ftitem_code,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");
            $objAxpDB->FormCaption("No. Assembly, Kode Barang, Date From, Date End");
            $objAxpDB->FormPosition("TL, TL, TR, TR");
            break;
        
        case "i23":
                $objAxpDB->Lookup("ftdisassembly_no", "SELECT 'SELURUH' as ftdisassembly_no,'SELURUH' AS fdtrans_date UNION ALL   SELECT ftdisassembly_no, fdtrans_date FROM txdisassembly_hdr WHERE fnstatus=1", "ftdisassembly_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftitem_code", "SELECT 'SELURUH' as ftitem_code,'SELURUH' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(TRIM(ftitem_name),CASE WHEN TRIM(ftpart_no) != '' THEN ' PART NO: ' ELSE '' END,ftpart_no) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name ", "ftitem_code", "ftitem_name",-1,false);
            
                $objAxpDB->FormSQL("SELECT '' as ftdisassembly_no,
                                    '' as ftitem_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("No. Disssembly, Kode Barang, Date From, Date End");
                $objAxpDB->FormPosition("TL, TL, TR, TR");
                break;
            
            case "i24":
                // Filternya nama barang pakai like saja, bebas ketik  
                // $objAxpDB->Lookup("ftitem_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr WHERE fnstatus=1", "ftitem_code", "ftitem_name", -1,false);
                
                $objAxpDB->Lookup("ftlocation_code", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name  UNION ALL   SELECT ftlocation_code, ftlocation_code FROM tllocation", "ftlocation_code", "ftlocation_name", -1,false);

                $objAxpDB->FormSQL("SELECT '' as ftitem_code,'' AS ftlocation_code, 
                            CONVERT(null,date) as date_from, 
                            CONVERT(null,date) as date_end 
                            FROM tlreport");
                $objAxpDB->FormCaption("Nama Barang (Keyword),Kode Lokasi,Date From,Date End");
                $objAxpDB->FormPosition("TL,TL,HD,TR");
                break;
            
            case "i25":
                // Filternya nama barang pakai like saja, bebas ketik  
                $objAxpDB->Lookup("ftlocation", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name  UNION ALL   SELECT ftlocation_code, ftlocation_code FROM tllocation", "ftlocation_code", "ftlocation_name", -1,false);
              
                $objAxpDB->FormSQL("SELECT '' as ftitem_name,'' AS ftlocation FROM tlreport");
                $objAxpDB->FormCaption("Nama Barang (Keyword),Kode Lokasi");
                $objAxpDB->FormPosition("TL,TL");
                break;
            
            case "i26":
                // Filternya nama barang pakai like saja, bebas ketik  
                $objAxpDB->Lookup("ftlocation", "SELECT 'SELURUH' as ftlocation_code,'SELURUH' AS ftlocation_name  UNION ALL   SELECT ftlocation_code, ftlocation_code FROM tllocation", "ftlocation_code", "ftlocation_name", -1,false);

                $objAxpDB->FormSQL("SELECT '' as ftitem_name,'' AS ftlocation FROM tlreport");
                $objAxpDB->FormCaption("Nama Barang (Keyword),Kode Lokasi");
                $objAxpDB->FormPosition("TL,TL");
                break;
        
            case "i28":
                $objAxpDB->Lookup("supplier_code", "SELECT \'SELURUH\' as ftsupplier_code,\'SELURUH\' AS ftsupplier_name UNION ALL   SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier WHERE fnstatus = 1 ", "ftsupplier_code", "ftsupplier_name", -1,false);
                $objAxpDB->Lookup("ftitem_code", "SELECT DISTINCT ftitem_code, ftitem_name FROM (SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL SELECT ftitem_code, CONCAT(ftitem_name,\' PART NO: \',ifnull(ftpart_no,\'\')) AS ftitem_name FROM tlstock_hdr WHERE fnstatus=1 ORDER BY ftitem_name) x ", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT '' as supplier_code,
                                        '' as ftitem_code,
                                        '' AS ftpo_no,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end
                                    FROM tlreport");

                $objAxpDB->FormCaption("Supplier, Barang, No PO, Date From, Date End");
                $objAxpDB->FormPosition("TL, TL, TL, TR, TR");
                break;
            
        
            /* Tidak digunakan saat ini
            case "i02":
             $objAxpDB->Lookup("stock_subgroup", "SELECT \'SELURUH\' as ftstock_subgroup_code,\'SELURUH\' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);
             $objAxpDB->FormSQL("SELECT '' as stock_subgroup,
                            CONVERT(null,date) as date_from, 
                            CONVERT(null,date) as date_end 
                            FROM tlreport");
            $objAxpDB->FormCaption("Stock SubGroup, Date From,Date End");
            $objAxpDB->FormPosition("TL, TR,TR");   
          break;
           case "i02_2":
             $objAxpDB->Lookup("stock_subgroup", "SELECT \'SELURUH\' as ftstock_subgroup_code,\'SELURUH\' AS ftstock_subgroup_name UNION ALL   SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);
             $objAxpDB->FormSQL("SELECT '' as stock_subgroup,
                            CONVERT(null,date) as date_from,
                            CONVERT(null,date) as date_end
                            FROM tlreport");
            $objAxpDB->FormCaption("Stock SubGroup, Date From,Date End");
            $objAxpDB->FormPosition("TL, HD,TL");
          break;
          case "i03":
             $objAxpDB->Lookup("stock", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr where ftstock_category_code=\'inv\' ", "ftitem_code", "ftitem_name", -1,false);
             $objAxpDB->FormSQL("SELECT '' as stock,
                            CONVERT(null,date) as date_from, 
                            CONVERT(null,date) as date_end 
                            FROM tlreport");
            $objAxpDB->FormCaption("Barang, Date From,Date End");
            $objAxpDB->FormPosition("TL, TR,TR");   
          break; 
             
        case "i11_2":
            $objAxpDB->Lookup("customer_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->Lookup("ftdelivery_method", "SELECT 'SELURUH' as fntrans_status_code,'SELURUH' AS fttrans_status_name  UNION ALL   SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 7", "fntrans_status_code", "fttrans_status_name", -1,TRUE);
            $objAxpDB->Lookup("ftstock_category_code", "SELECT ftstock_type_code, ftstock_type_name FROM tlstock_type", "ftstock_type_code", "ftstock_type_name", 0,true);
       
            $objAxpDB->Lookup("stock_subgroup", "SELECT SELURUH' as ftstock_subgroup_code,'SELURUH' AS ftstock_subgroup_name UNION ALL SELECT ftstock_subgroup_code, ftstock_subgroup_name FROM tlstock_subgroup", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false);

            $objAxpDB->FormSQL("SELECT
                                '' as customer_code,
                                '' as ftdelivery_method,
                                '' as ftstock_category_code,
                                '' as stock_subgroup,
                                CONVERT(null,date) as date_from,
                                CONVERT(null,date) as date_end
                                FROM tlreport");

            $objAxpDB->FormCaption("Customer,Metode Pengiriman,Category Stock,Subgroup, Date From,Date End");
            $objAxpDB->FormPosition("TL,TL,TL,TL,TR, TR");
            break;
             * 
             */
        }
    }
    
     
    $objAxpDB->Process();
    if(!$_REQUEST['id']) {       
        $objAxpDB->WriteHtmlTable();
    }
    else {
        $objAxpDB->FormName("laporan inventory".$report_name);
        $objAxpDB->ButtonShow("generate_report,print_report,export_excel_report,export_pdf_report");
        $objAxpDB->reportData();
    }