<?php
    if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
             case "transno":
                $fttrans_no=$_REQUEST['fttrans_no'];
                if(RetRstField("SELECT ftcustomer_code FROM tlcustomer_support_hdr WHERE ftcustomer_code='{$fttrans_no}'")) {
                    echo "alert('Kode Barang  sudah di pakai ...');";
                }
                else {
                    ?>
                    submitbutton('Simpan','','','','');
                    <?php
                }

                break;
        }
        die("");
    }

    Getsecurity('customer_support');

    $objAxpDB->LookupMagicQuotes(True);
    $objAxpDB->ViewName("Daftar Customer Support");

    $objAxpDB->ViewSQL("SELECT a.fnid, a.ftcustomer_code, b.ftcustomer_name FROM tlcustomer_support_hdr a INNER JOIN tlcustomer b ON a.ftcustomer_code=b.ftcustomer_code GROUP BY a.ftcustomer_code");

    $objAxpDB->ViewCaption("ID, Customer Code, Customer Name, Support Code");

    $objAxpDB->FormName("Customer Support");
    $objAxpDB->FormSQL("SELECT ftcustomer_code FROM tlcustomer_support_hdr");
    $objAxpDB->FormCaption("Customer Code, Customer Name");
    $objAxpDB->FormPosition(" TL,TL,TL");
    $objAxpDB->SetStatus("id");

    // Pemanggilan Grid0
        $objAxpDB->GridSQL(0, "SELECT fnindex, ftsupport_code FROM tlcustomer_support_det");
        $objAxpDB->GridCaption(0, "No., Kode Support");

        // GridHidden : Kolom Grid dihide atau tidak : 1 = hide, 0 = tidak hide
        $objAxpDB->GridHidden(0,'0,0');

     // GridDelJS : Script yang dijalankan apabila baris dari grid ada yang dihapus
    $objAxpDB->GridDelJS(0,"StockMasukRecalQty();");

    if ($objAxpDB->GetStatus("id") == "") {

        $objAxpDB->ButtonShow("baru,  cetak_daftar, export_excel ,tutup");
    }
    elseif ($objAxpDB->GetStatus("id") == 0) {
        
        $objAxpDB->GridAllowAddNew(0,true);
        $objAxpDB->GridAllowDelete(0,true);
        $objAxpDB->Lookup("ftcustomer_code","SELECT ftcustomer_code, ftcustomer_name FROM tlcustomer","ftcustomer_code","ftcustomer_name", 0,false);
        $objAxpDB->Lookup("ftsupport_code","SELECT ftsupport_code, ftsupport_name FROM tlsupport","ftsupport_code","ftsupport_name", 0,false);

        $objAxpDB->ButtonShow("reset, simpan, tutup");
        $objAxpDB->FormLocked("0,0,0");
    }
    elseif ($objAxpDB->GetStatus("id") != 0) {

        $objAxpDB->GridAllowAddNew(0,true);
        $objAxpDB->GridAllowDelete(0,true);
        $objAxpDB->Lookup("ftcustomer_code","SELECT ftcustomer_code, ftcustomer_name FROM tlcustomer","ftcustomer_code","ftcustomer_name", 0,false);
        $objAxpDB->Lookup("ftsupport_code","SELECT ftsupport_code, ftsupport_name FROM tlsupport","ftsupport_code","ftsupport_name", 0,false);
        $objAxpDB->FormLocked("0,0,0");

        $objAxpDB->ButtonShow("update, cetak, tutup");
        $objAxpDB->FormLocked("1,1,1");
    }

    $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();

?>

