<?php
    GetSecurity('tipe_customer');

    if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
                if(RetRstField("SELECT fnid FROM tlcustomer_type WHERE ftcustomer_type_code='{$_REQUEST['fttrans_no']}'")) {
                    ?>
                    alert('Kode Tipe Customer sudah dipakai...');
                    OnChangeDate_fdtrans_date();
                    <?php
                } 
                else {
                    ?>
                    submitbutton('Simpan','','','','');
                    <?php
                }
                break;

        }       
        die("");
    }

    $objAxpDB->ViewName("Daftar Tipe Customer");
//    $objAxpDB->ViewTable("vSATipeCustomer");
    $objAxpDB->ViewSQL("SELECT fnid, ftcustomer_type_code, ftcustomer_type_name,
                        case when fnstatus=0 then 'tidak aktif' else 'aktif' end as fnstatus FROM tlcustomer_type");
    $objAxpDB->ViewCaption("ID, Kode Tipe Customer, Nama Tipe Customer, Status");
      
    $objAxpDB->FormName("Tipe Customer");
    $objAxpDB->FormSQL("SELECT ftcustomer_type_code, ftcustomer_type_name, fnstatus FROM tlcustomer_type");
    $objAxpDB->FormCaption("Kode Tipe Customer, Nama Tipe Customer, Status");

    $objAxpDB->Lookup('fnstatus', 'SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status where fntrans_status_code<>2 and fntrans_group_code=9', 'fntrans_status_code', 'fttrans_status_name', 1,true);
    
    $objAxpDB->SetStatus("id");    
    $objAxpDB->FormPosition("TL, TL, TL"); 
    if ($objAxpDB->GetStatus("id") == "") {
            $objAxpDB->ButtonShow("baru");

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

    }
    elseif ($objAxpDB->GetStatus("id") != 0) {
            $objAxpDB->ButtonShow("update, hapus, tutup"); 
            $objAxpDB->FormLocked("1");
    }
    $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();	

