<?php
     if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
              if(RetRstField("SELECT fnid FROM txfood_money_hdr WHERE ftfood_money_no='{$_REQUEST['fttrans_no']}'")) {
                  ?>

                  alert('No. transaksi sudah dipakai...\n System akan mengenerate No. transaksi kembali ...\n Silahkan ulangi proses penyimpanan...  ');
                  OnChangeDate_fdtrans_date();
            <?php
              }
              else {
                    ?>


                  submitbutton('Simpan','','','','');

            <?php
              }
            break;
        }
        die("");
    }
    if(!$_REQUEST['id']) {
            $strAutoNumber1="ajax_do('query2.php?code=2&ftmodule_code=hrd006&thbln=' + document.getElementById(\"fdtrans_date\").value + '&field_name=ftfood_money_no&no_trans=ftfood_money_no&table_name=txfood_money_hdr');";

            $strAutoNumber0=" function OnChangeDate_fdtrans_date() {
                                           {$strAutoNumber1}

                                            fnpo_type
                                     }
                                     OnChangeDate_fdtrans_date();

                                ";

            $objAxpDB->FormJS($strAutoNumber0);
     }
    // Deklarasi UctVw
    $objAxpDB->ViewName("Daftar Uang Makan");
    $objAxpDB->ViewSQL("select fnid, ftfood_money_no, fdtrans_date, fdfood_start_date,fdfood_end_date,fnstatus from txfood_money_hdr order by ftfood_money_no desc, fdtrans_date desc ");
    $objAxpDB->ViewCaption("ID, No. Uang Makan, Tgl. Transaksi, Periode 1, Periode 2, Status ");
//    $objAxpDB->ViewPeriod(TRUE);

    // Deklarasi Header & Footer
    $objAxpDB->FormName("Uang Makan");
    $objAxpDB->FormSQL("select ftfood_money_no,fdtrans_date,fdfood_start_date,fdfood_end_date,ftnotes,fnstatus from txfood_money_hdr");
    $objAxpDB->FormCaption("No. Uang Makan, Tgl. Transaksi, Periode 1, Periode 2, Catatan, Status");
    $objAxpDB->FormPosition("TL, TL, TL, TL, BL, BR");
//    $objAxpDB->FormScript(0, "onChange=\"ajax_do('getdata.php?code=2&obj1=' + fdTrans_Date.value + '&obj2=ftPO_No&obj3=' + fnCategory.value);\"");
//    $objAxpDB->FormScript(4, "onFocus=\"ajax_do('getdata.php?code=2&obj1=' + fdTrans_Date.value + '&obj2=ftPO_No&obj3=' + fnCategory.value);\"");

    // Deklarasi Detail
    $objAxpDB->GridSQL(0, "select fnindex, ftemployee_code, fnworking_days, fcfood_money, fcfood_amount,  fcdeduction, fcamount, ftdescription from txfood_money_det");
    $objAxpDB->GridCaption(0, "No., Pegawai, Hari, Makan (hr), Ttl Makan, Penyesuaian, Total, Catatan  ");

    $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->Lookup("ftemployee_code", "SELECT ftemployee_code, ftemployee_name FROM tlemployee", "ftemployee_code", "ftemployee_name", -1, False);


    $objAxpDB->SetStatus("id, fnShipment_Status, fnStatus");
    if ($objAxpDB->GetStatus("id") == "") {
            $objAxpDB->ButtonShow("baru, cetak_daftar,  export_excel , tutup");
    } elseif ($objAxpDB->GetStatus("id") == 0) {
            $objAxpDB->ButtonShow("reset, simpan, tutup");
            $objAxpDB->FormLocked("0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1");
            $objAxpDB->GridLocked(0, "1, 0, 0, 1");

           

            $objAxpDB->GridAllowAddNew(0, TRUE);
            $objAxpDB->GridAllowDelete(0, TRUE);
    } elseif ($objAxpDB->GetStatus("fnStatus") == 1) {
            if($objAxpDB->GetStatus("fnShipment_Status") == 3)
                    $objAxpDB->ButtonShow("cetak, batal, tutup, baru");
            else
                    $objAxpDB->ButtonShow("cetak, final, batal, tutup, baru");

            $objAxpDB->FormLocked("1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->GridLocked(0, "1, 1, 1, 1");
    } elseif ($objAxpDB->GetStatus("fnStatus") == 9) {
            $objAxpDB->ButtonShow("tutup");
            $objAxpDB->FormLocked("1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->GridLocked(0, "1, 1, 1, 1");
    }

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


?>
