<?php
     if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
              if(RetRstField("SELECT fnid FROM tllocation WHERE ftlocation_code='{$_REQUEST['fttrans_no']}'")) {
                  ?>
                  
                  alert('Kode Lokasi sudah dipakai... ');
            <?php
              }
              else {
                    ?>
                   
                    
                  submitbutton('Simpan','','','','');
                   
            <?php
              }
            break;
        }       
        die("");
    }
    
    Getsecurity('lokasi');
    $objAxpDB->ViewName("Daftar Lokasi");
    //$objAxpDB->ViewTable("vILokasi");
    $objAxpDB->ViewSQL("SELECT a.fnid, ftlocation_code, ftlocation_name, ftwarehouse_name FROM tllocation a inner join tlwarehouse b on a.ftwarehouse_code = b.ftwarehouse_code ORDER BY  ftlocation_code, ftlocation_name");
    $objAxpDB->ViewCaption("ID, Kode Lokasi, Nama Lokasi, Nama Gudang");

    $objAxpDB->FormName("Lokasi");
    $objAxpDB->FormSQL("SELECT ftlocation_code, ftlocation_name, ftwarehouse_code, fnlocation_pos, fnstatus FROM tllocation");
    $objAxpDB->FormCaption("Kode Lokasi, Nama Lokasi, Kode Gudang, Default Lokasi, Status");
    $objAxpDB->FormPosition("TL,TL,TL,HD,TL"); 

    $objAxpDB->Lookup( "ftwarehouse_code", "SELECT ftwarehouse_code, ftwarehouse_name FROM tlwarehouse", "ftwarehouse_code", "ftwarehouse_name", -1,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->Lookup("fnlocation_pos", "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", 0,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");
    }
    
    $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();
		
?>
