<?php
    if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "kodeperkiraan":

              if(RetRstField("SELECT fnid FROM tlcoa WHERE ftcoa_code='{$_REQUEST['ftcoa_code']}'")) {
                ?>
                  alert('Kode Perkiraan sudah dipakai...');
                <?php
              }
              else {
                ?>
                  submitbutton('Simpan','','','','');
                <?php
              }
            break;

        }
        die("");
    }

    Getsecurity('no_perkiraan');

    $objAxpDB->ViewName("Daftar No Perkiraan");
    $objAxpDB->ViewSQL("SELECT a.fnID, a.ftCOA_Code, a.ftCOA_Name, b.ftCOA_SubGroup_Name, c.ftTrans_Status_Name FROM tlcoa a LEFT JOIN tlcoa_subgroup b ON a.ftCOA_SubGroup_Code = b.ftCOA_SubGroup_Code LEFT JOIN tstransaction_status c ON a.fnStatus = c.fnTrans_Status_Code AND c.fnTrans_Group_Code = 9 ORDER BY a.ftCOA_Code");
    $objAxpDB->ViewCaption("ID, Kode Perkiraan, Nama Perkiraan, SubGroup Perkiraan, Status");
    $objAxpDB->ViewPeriod(FALSE);

    $objAxpDB->FormName("No Perkiraan");
    $objAxpDB->FormSQL("SELECT ftCOA_Code, ftCOA_Name, ftCOA_SubGroup_Code, fnStatus FROM tlcoa");
    $objAxpDB->FormCaption("Kode Perkiraan, Nama Perkiraan, Group Perkiraan, Status");
    $objAxpDB->FormPosition("TL, TL, TL, TL");
    
    $objAxpDB->Lookup("ftCOA_SubGroup_Code", "SELECT ftCOA_SubGroup_Code, ftCOA_SubGroup_Name FROM tlcoa_subgroup", "ftCOA_SubGroup_Code", "ftCOA_SubGroup_Name", -1, True);
    $objAxpDB->Lookup("fnStatus", "SELECT fnTrans_Status_Code, ftTrans_Status_Name FROM tstransaction_status WHERE fnTrans_Group_Code = 9", "fnTrans_Status_Code", "ftTrans_Status_Name", 1, True);

    $objAxpDB->SetStatus("id, fnStatus");
    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");
    }

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

