<?php  
    $objAxpDB->ViewName("Daftar laporan pembelian");
//    $objAxpDB->ViewTable("vPULaporanPembelian");
    $objAxpDB->ViewSQL("SELECT fnid,ftreport_code, ftreport_name FROM tlreport WHERE ftreport_group = 'pembelian' and fnstatus = 1 order by fnorder, ftreport_code");
    $objAxpDB->ViewCaption("ID,ftreport_code, Nama laporan");

    $objAxpDB->FormName("Laporan Pembelian");
    $objAxpDB->FormSQL("SELECT ftreport_name
                      FROM tlreport");
    $objAxpDB->FormCaption("Nama laporan");
    $objAxpDB->FormPosition("TL");
    $objAxpDB->LookupMagicQuotes(false);
    $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 "p101":
		//$objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' AS A,'SELURUH' AS B UNION ALL SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B", "A", "B", 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->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 'SELURUH' AS fnpo_type,
                                    '' as supplier_code,
                                    '' AS ftitem_code,
                                    '' AS ftpo_no,
                                    CONVERT('2018/01/01',date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO (Import/Local), Supplier, Barang, No PO, Date From, Date End");
                $objAxpDB->FormPosition("HD, TL, TL, TL, TR, TR");
                $objAxpDB->FormLocked("0,0,0,0,1,0");
                
                /* $report_script = "document.getElementById('supplier_code').value = 'SELURUH'
                                  document.getElementById('hidden_supplier_code').value = 'SELURUH';
                                  document.getElementById('span_supplier_code').innerHTML = 'SELURUH';"; */
                
                $objAxpDB->FormJS($report_script);
                
                break;
            
            case "p102":
                //$objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' AS A,'SELURUH' AS B UNION ALL SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B", "A", "B", -1,true);
                $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->Lookup("currency_code", "SELECT ftsimbol, ftdescription FROM txcurrency order by ftsimbol", "ftsimbol", "ftdescription", -1,true);
                $objAxpDB->FormSQL("SELECT 'SELURUH' AS fnpo_type,
                                        '' as supplier_code,
                                        '' as ftitem_code,
                                        '' AS ftsupplier_group,
                                        '' as currency_code,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end,
                                        '' AS ftpo_no                                        
                                    FROM tlreport");

                $objAxpDB->FormCaption("Tipe PO, Supplier, Barang, Supplier Group, Mata Uang, Date From, Date End, No PO");
                $objAxpDB->FormPosition("HD, TL, TL, TL, HD, TR, TR, TR");
                break;
            
            case "p123":
                $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->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 ftstock_group, '' as ftsupplier_group, 
                                        '' AS ftitem_code, '' AS fftotal_qty_min, '' AS fftotal_qty_max
                                    FROM tlreport");
                $objAxpDB->FormCaption("Group Barang, Supplier Group, Kode Barang, Total Qty Min, Total Qty Max");
                $objAxpDB->FormPosition("TL,TL,TR,TR,TR");
                break;
            
            case "p124":
                $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;
            
            
	   
	   case "p125":
                $objAxpDB->Lookup("po_type", "SELECT 'SELURUH' AS A,'SELURUH' AS B UNION ALL SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B", "A", "B", 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->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->Lookup("currency_code", "SELECT ftsimbol, ftdescription FROM tlcurrency_hdr order by ftsimbol", "ftsimbol", "ftdescription", -1,true);
                $objAxpDB->FormSQL("SELECT 'SELURUH' AS po_type,
                                  '' as supplier_code,
                                  '' as item_code,
                                  'IDR' as currency_code,
                                  CONVERT(null,date) as date_from,
                                  CONVERT(null,date) as date_end
                                  FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO (Import/Local), Supplier, Barang, Mata Uang, Date From,Date End");
                $objAxpDB->FormPosition("TL, TL, TL, TL, TR, TR");
                break;
           case "p126":
                $objAxpDB->Lookup("ftsupplier_code", "SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier", "ftsupplier_code", "ftsupplier_name", -1,false);
                $objAxpDB->Lookup("ftpo_no", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr WHERE fnstatus <> 3 and fnstatus <> 9 ", "ftpo_no", "fdtrans_date", -1,false,"' AND ftsupplier_code=\''+ document.getElementById('ftsupplier_code').value + '\' '");
                // $objAxpDB->Lookup( "ftdocument_no", "SELECT ftpo_no, fdtrans_date ,ftsupplier_code,fnpo_type3 FROM (SELECT distinct ftpo_no, fdtrans_date ,ftsupplier_code,fnpo_type3 FROM (SELECT b.ftitem_code, a.ftpo_no, a.fdtrans_date ,a.ftsupplier_code,a.fnpo_type3, COALESCE(SUM(b.fnqty_accept_base),0) AS ttlqtyaccept, CASE WHEN COALESCE(SUM(b.fnqty_limit),0) = 0 THEN SUM(b.fnqty_base) ELSE SUM(b.fnqty_limit) END AS ttlqtylimit FROM txpurchase_order_hdr a INNER JOIN txpurchase_order_det b ON a.ftpo_no = b.ftpo_no WHERE a.fnstatus=1 and a.fnhdr_category = 0 GROUP BY b.ftitem_code, a.ftpo_no, a.fdtrans_date ,a.ftsupplier_code,a.fnpo_type3 HAVING  ttlqtyaccept < ttlqtylimit) x ORDER BY ftpo_no) a where 0=0 ", "ftpo_no", "fdtrans_date", -1,false,"' AND fnpo_type3=\''+ document.getElementById('fnpo_type3').value + '\' AND ftsupplier_code=\''+ document.getElementById('ftstock_in_company').value + '\''");
                $objAxpDB->FormSQL("SELECT
                                  '' as ftsupplier_code,
                                  '' as ftpo_no
                                  FROM tlreport");
                $objAxpDB->FormCaption("Supplier, No. PO");
                $objAxpDB->FormPosition("TL, TL");
                break;
            case "p127":
                $objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' AS A,'SELURUH' AS B UNION ALL SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B", "A", "B", 1,true);
                
                $objAxpDB->FormSQL("SELECT 'SELURUH' AS fnpo_type,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO (Import/Local),Date From,Date End");
                $objAxpDB->FormPosition("TL,TR,TR");
            break;
        
            case "p128":
                $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 ftitem_code,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("Kode Barang,Date From,Date End");
                $objAxpDB->FormPosition("TL,TR,TR");
                break;
        
            /* Tidak digunakan
            case "p101_1":
		$objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' AS A,'SELURUH' AS B UNION ALL SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B", "A", "B", 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->Lookup("ftitem_code","SELECT DISTINCT ftitem_code, ftitem_name FROM (SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku WHERE fnstatus=1 UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr_setengah_jadi WHERE fnstatus=1 UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr_sparepart WHERE fnstatus=1 UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr WHERE fnstatus=1) x ", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT 'SELURUH' AS fnpo_type,
                                    '' as supplier_code,
                                    '' AS ftitem_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO (Import/Local), Supplier, Kode Barang, Date From, Date End");
                $objAxpDB->FormPosition("TL, TL, TL, TR, TR");
                break;
            case "p102_1":
                $objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' AS A,'SELURUH' AS B UNION ALL SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B", "A", "B", -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->Lookup("item_code","SELECT DISTINCT ftitem_code, ftitem_name FROM (SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr_setengah_jadi UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr_sparepart UNION ALL SELECT ftitem_code, ftitem_name FROM tlstock_hdr) x", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->Lookup("currency_code", "SELECT ftsimbol, ftdescription FROM txcurrency order by ftsimbol", "ftsimbol", "ftdescription", -1,true);
                $objAxpDB->FormSQL("SELECT 'SELURUH' AS fnpo_type,
                                      '' as supplier_code,
                                      CONVERT(null,date) as date_from,
                                      CONVERT(null,date) as date_end,
                                     '' as item_code,
                                     'IDR' as currency_code
                                    FROM tlreport");

                $objAxpDB->FormCaption("Tipe PO, Supplier, Date From, Date End, Barang, Mata Uang");
                $objAxpDB->FormPosition("TL, TL, TR, TR, TL, TL");
                break; 
            case "p103":
            case "p103_1":
                $objAxpDB->Lookup("fnpo_type", "SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B ", "A", "B", 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 fnpo_type,
                                    '' as supplier_code,
                                    CONVERT(null,date) as date_from ,
                                    CONVERT(null,date) as date_end 
                                    FROM tlreport");
                $objAxpDB->FormCaption(" Tipe PO(Import/Local),Supplier, Bulan,Bulan");
                $objAxpDB->FormPosition("TL,TL,TL,HD");
                break;
            case "p104":
                $objAxpDB->Lookup("fnpo_type", "SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B ", "A", "B", 1,true);
                $objAxpDB->Lookup("fnpo_typelpb", "SELECT 'SELURUH' AS fntrans_status_code,'SELURUH' AS fttrans_status_name UNION ALL SELECT '0|1|2|3|4|5|6' AS fntrans_status_code,'NON CASH' AS fttrans_status_name UNION ALL  SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 36", "fntrans_status_code", "fttrans_status_name", 0,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 fnpo_type, 'SELURUH' AS fnpo_typelpb,
                                    '' as supplier_code,
                                    CONVERT(null,date) as date_from ,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO(Import/Local),Tipe LPB,Supplier, Date From,Date End");
                $objAxpDB->FormPosition("TL,TL,TL,TL,TL");
                break;
            case "p104_1":
                $objAxpDB->Lookup("fnpo_type", "SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B ", "A", "B", 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 fnpo_type, 
									'' as supplier_code,
                                    CONVERT(null,date) as date_from ,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption(" Tipe PO(Import/Local),Supplier, Tgl 1,Tgl 2");
                $objAxpDB->FormPosition("TL,TL,TL,TL");
                break;
            case "p105":
                $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->Lookup("fnpo_type", "SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B ", "A", "B", 1,true);
                $objAxpDB->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->Lookup("fntax_code", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'PAJAK' AS B UNION ALL SELECT '1' AS A,'NON PAJAK' AS B ", "A", "B", 1,true);
                $objAxpDB->FormSQL("SELECT 'SELURUH' as fntax_code, 0 as fnpo_type,
                                    '' as supplier_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end,
                                     '' as item_code 
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO(Pajak/NonPajak),Tipe PO (Import/Local), supplier, Date From,Date End, Barang");
                $objAxpDB->FormPosition("TL,TL,TL, TL,TL,TL");
                break;
            case "p106":
                $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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
				$objAxpDB->FormSQL("SELECT
                                    '' as supplier_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end,
                                    '' as item_code
                                    FROM tlreport");
                $objAxpDB->FormCaption("supplier, Date From,Date End, Barang");
                $objAxpDB->FormPosition("TL,TL, TL,TL");
                break;
            case "p107":
                $objAxpDB->FormSQL("SELECT  '' as supplier_code,
                                    CONVERT(null,date) as date_from
                                    FROM tlreport");
                $objAxpDB->FormCaption("Supplier, Bulan");
                $objAxpDB->FormPosition("TL, TL");
                $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);
                break;
            case "p108":
                $objAxpDB->Lookup("fnpo_type", "SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B ", "A", "B", 1,true);
                $objAxpDB->Lookup("stockgroup", "SELECT \'SELURUH\' as ftstock_group_code,\'SELURUH\' AS ftstock_group_name UNION ALL   SELECT ftstock_group_code, ftstock_group_name FROM tlstock_group_bahan_baku", "ftstock_group_code", "ftstock_group_name", -1,false);
                $objAxpDB->Lookup("supplier_code", "SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier", "ftsupplier_code", "ftsupplier_name", -1,false);				       
                $objAxpDB->FormSQL("SELECT 0 as fnpo_type,
                                    '' as stockgroup,'' as supplier_code
                                    FROM tlreport");
                $objAxpDB->FormCaption("Import/Local,Group Barang, Supplier ");
                $objAxpDB->FormPosition("TL,TL,TL");
                break;
            case "p109":
                $objAxpDB->Lookup("fnpo_type", "SELECT 0 AS A,'LOCAL' AS B UNION ALL SELECT 1 AS A,'IMPORT' AS B ", "A", "B", 1,true);
                $objAxpDB->Lookup("stockgroup", "SELECT \'SELURUH\' as ftstock_group_code,\'SELURUH\' AS ftstock_group_name UNION ALL   SELECT ftstock_group_code, ftstock_group_name FROM tlstock_group_bahan_baku", "ftstock_group_code", "ftstock_group_name", -1,false);
                $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 fnpo_type,
                                    '' as stockgroup,'' as supplier_code
                                    FROM tlreport");
                $objAxpDB->FormCaption("Import/Local,Group Barang, Supplier ");
                     
                #$objAxpDB->FormCaption("Import/Local,Group Barang, Tanggal ");
                $objAxpDB->FormPosition("TL,TL,TL");
                break;
            case "p110":
                $objAxpDB->FormSQL("SELECT '' as subgroup_code
                              FROM tlreport");
                $objAxpDB->FormCaption("");
                $objAxpDB->FormPosition("HD");
                break;
            case "p111":
                $objAxpDB->FormSQL("SELECT 
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end,
                                     '' as ftpo_no1,'' as ftpo_no2,
                                           '' as  ftpo_no3,'' as ftpo_no4,
                                           '' as   ftpo_no5,'' as ftpo_no6,
                                               '' as  ftpo_no7,'' as ftpo_no8,
                                                     '' as ftpo_no9,'' as ftpo_no10
                                    FROM tlreport");
                $objAxpDB->Lookup("ftpo_no1", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no2", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no3", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no4", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no5", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no6", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no7", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no8", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no9", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("ftpo_no10", "SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->FormCaption(" Date From,Date End,
                                           No. PO 1,No. PO 2,
                                           No. PO 3,No. PO 4,
                                             No. PO 5,No. PO 6,
                                                No. PO 7,No. PO 8,
                                                     No. PO 9,No. PO 10");
                $objAxpDB->FormPosition("TL,TL,TR,TR,TR,TR,TR,TR,TR,TR,TR,TR");
                break;
            case "p112":
                $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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT
                                    '' as supplier_code,
                                    '' as item_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("supplier, Item, Date From,Date End");
                $objAxpDB->FormPosition("TL,TL,TR, TR");
                break;
            case "p113":
                $objAxpDB->Lookup("stock_group", "SELECT \'SELURUH\' as ftstock_group_code,\'SELURUH\' AS ftstock_group_name UNION ALL   SELECT ftstock_group_code, ftstock_group_name FROM tlstock_group_bahan_baku", "ftstock_group_code", "ftstock_group_name", -1,false);
                $objAxpDB->FormSQL("SELECT '' as stock_group 
                                    FROM tlreport");
                $objAxpDB->FormCaption("Group ");
                $objAxpDB->FormPosition("TL ");
                break;
            case "p113_1":
                $objAxpDB->Lookup("stock_group", "SELECT \'SELURUH\' as ftstock_group_code,\'SELURUH\' AS ftstock_group_name UNION ALL   SELECT ftstock_group_code, ftstock_group_name FROM tlstock_group_bahan_baku", "ftstock_group_code", "ftstock_group_name", -1,false);
                $objAxpDB->FormSQL("SELECT '' as stock_group
                                    FROM tlreport");
                $objAxpDB->FormCaption("Group ");
                $objAxpDB->FormPosition("HD");
                break;
            case "p113_2":
                $objAxpDB->Lookup("item_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT '' as item_code 
                                    FROM tlreport");
                $objAxpDB->FormCaption("Kode Barang");
                $objAxpDB->FormPosition("TL");
                break;    
            case "p114":
                $objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'LOCAL' AS B UNION ALL SELECT '1' AS A,'IMPORT' AS B", "A", "B", 1,true);
                $objAxpDB->Lookup("fnpo_typelpb", "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 = 36", "fntrans_status_code", "fttrans_status_name", 0,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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT 'SELURUH' AS fnpo_type,'SELURUH' as fnpo_typelpb,
                                    '' as supplier_code,
                                    '' as item_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO(Import/Local),Tipe LPB,supplier, Item, Date From,Date End");
                $objAxpDB->FormPosition("TL,TL,TL,TL,TL,TL");
                break;
            case "p115":

                $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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->Lookup("ftpo_no", "SELECT \'SELURUH\' as ftpo_no,\'SELURUH\' AS fdtrans_date UNION ALL   SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr WHERE (fnstatus=9 OR fnstatus=5)", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->Lookup("fnstatus", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 2 AND fntrans_status_code IN('5','9')", "fntrans_status_code", "fttrans_status_name", 0,true);
                
                $objAxpDB->FormSQL("SELECT
                                        '' as ftpo_no,
                                        '' as supplier_code,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end,
                                        '' as item_code,
                                        '' as fnstatus
                                        FROM tlreport");

                $objAxpDB->FormCaption("No. PO,  supplier, Date From,Date End, Barang, Status");
                $objAxpDB->FormPosition("TL, TL, TR, TR, TL, TL, TL");
                break;
            case "p116":
                $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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->FormSQL("SELECT 
                                    '' as supplier_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end,
                                    '' as item_code
                                    FROM tlreport");
                $objAxpDB->FormCaption(" supplier, Date From,Date End, Barang");
                $objAxpDB->FormPosition("TL,TL, TL,TL, TL,TL");
				break;
            case "p117":
                $objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'LOCAL' AS B UNION ALL SELECT '1' AS A,'IMPORT' AS B", "A", "B", 1,true);
                $objAxpDB->Lookup("fntax_code", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'PAJAK' AS B UNION ALL SELECT '1' AS A,'NON PAJAK' AS B ", "A", "B", 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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                //$objAxpDB->Lookup("fnpo_typelpb", "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 = 36", "fntrans_status_code", "fttrans_status_name", 0,true);
                $objAxpDB->FormSQL("SELECT 'SELURUH' as fntax_code,'SELURUH' AS fnpo_type,
                                    '' as supplier_code,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end,
                                    '' as item_code
                                    FROM tlreport");
                $objAxpDB->FormCaption("Tipe PO(Pajak/NonPajak), Tipe PO(Import/Local),Supplier, Date From,Date End, Barang");
                $objAxpDB->FormPosition("TL,TL,TL,TL,TL,TL");
                break;
            case "p118":
                $objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'LOCAL' AS B UNION ALL SELECT '1' AS A,'IMPORT' AS B", "A", "B", 1,true);
                $objAxpDB->Lookup("fnsupplier_lama", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'FALSE' AS B UNION ALL SELECT '1' AS A,'TRUE' AS B ", "A", "B", 0,true);
                $objAxpDB->FormSQL("SELECT 
                                    '0' as fnpo_type,
                                    '0' as fnsupplier_lama
                                    FROM tlreport");
                $objAxpDB->FormCaption("Import/Local,Supplier Lama");
                $objAxpDB->FormPosition("TL,TL");
                break; 
   		    case "p119":
                $objAxpDB->Lookup("ftpo_no", "SELECT \'SELURUH\' as ftpo_no,\'SELURUH\' AS fdtrans_date UNION ALL   SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr WHERE fnstatus=1", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->FormSQL("SELECT
                                    '' as ftpo_no,
                                    CONVERT(null,date) as date_from,
                                    CONVERT(null,date) as date_end 
                                    FROM tlreport");
                $objAxpDB->FormCaption(" No. PO, Date From,Date End");
                $objAxpDB->FormPosition("TL,TL, TL");
                break;
            case "p120":
                $objAxpDB->Lookup("ftstock_in_no", "SELECT ftstock_in_no, fdtrans_date FROM txstock_in_hdr_bahan_baku WHERE fnstatus=1", "ftstock_in_no", "fdtrans_date", -1,false);
                $objAxpDB->FormSQL("SELECT
                                    '' as ftstock_in_no 
                                    FROM tlreport");
                $objAxpDB->FormCaption(" No. LPB");
                $objAxpDB->FormPosition("TL");
                break;
            case "p121":
                $objAxpDB->Lookup("fnpo_type", "SELECT 'SELURUH' as A,'SELURUH' AS B UNION ALL SELECT '0' AS A,'LOCAL' AS B UNION ALL SELECT '1' AS A,'IMPORT' AS B", "A", "B", 1,true);
                $objAxpDB->FormSQL("SELECT
                                    'SELURUH' as fnpo_type
                                    FROM tlreport");
                $objAxpDB->FormCaption("Local/Import");
                $objAxpDB->FormPosition("TL");
                break;
            case "p122":
                $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->Lookup("item_code", "SELECT \'SELURUH\' as ftitem_code,\'SELURUH\' AS ftitem_name UNION ALL   SELECT ftitem_code, ftitem_name FROM tlstock_hdr_bahan_baku", "ftitem_code", "ftitem_name", -1,false);
                $objAxpDB->Lookup("ftpo_no", "SELECT \'SELURUH\' as ftpo_no,\'SELURUH\' AS fdtrans_date UNION ALL   SELECT ftpo_no, fdtrans_date FROM txpurchase_order_hdr WHERE fnstatus=1", "ftpo_no", "fdtrans_date", -1,false);
                $objAxpDB->FormSQL("SELECT
                                        '' as ftpo_no,
                                        '' as supplier_code,
                                        CONVERT(null,date) as date_from,
                                        CONVERT(null,date) as date_end,
                                        '' as item_code
                                        FROM tlreport");
                $objAxpDB->FormCaption("No. PO,  Supplier, Date From,Date End, Barang");
                $objAxpDB->FormPosition("TL,TL, TL,TL, TL,TL");
                break;
             */
        }
    }
 
    $objAxpDB->Process();
    if(!$_REQUEST['id']) {       
        $objAxpDB->WriteHtmlTable();
    }
    else {
         $objAxpDB->FormName($report_name);
         $objAxpDB->ButtonShow("generate_report,print_report,export_excel_report,export_pdf_report");
         $objAxpDB->reportData();
    }