<?php
    if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
                if(RetRstField("SELECT fnid FROM tlwarehouse WHERE ftwarehouse_code='{$_REQUEST['fttrans_no']}'")) {
                    ?>
                    alert('Kode Gudang sudah dipakai... ');
                    <?php
                }
                else {
                    ?>
                    submitbutton('Simpan','','','','');
                    <?php
                }
                break;
        }       
        die("");
    }
    
    Getsecurity('gudang');
    $objAxpDB->ViewName("Daftar Gudang");
    //$objAxpDB->VIewTable("vIGudang");
    $objAxpDB->ViewSQL("SELECT a.fnid, ftwarehouse_code, ftwarehouse_name, fttrans_status_name, fnwarehouse_pos FROM tlwarehouse a inner join tstransaction_status b on a.fnwarehouse_type = b.fntrans_status_code WHERE b.fntrans_group_code = 55 and b.fnactive_status = 1 ORDER BY ftwarehouse_code, ftwarehouse_name");
    $objAxpDB->ViewCaption("ID, Kode Gudang, Nama Gudang, Tipe Gudang, Default Gudang");

    $objAxpDB->FormName("Gudang"); 
    $objAxpDB->FormSQL("SELECT ftwarehouse_code, ftwarehouse_name, fnwarehouse_type, fnwarehouse_pos, fnstatus FROM tlwarehouse");
    $objAxpDB->FormCaption("Kode Gudang, Nama Gudang, Tipe Gudang , Default Gudang, Status");
    $objAxpDB->FormPosition("TL, TL, TL, TL, TL");

    $objAxpDB->Lookup("fnwarehouse_type", "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", 0,true);
    $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");

    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, 0, 0, 0, 0");
    }

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

       
?>
