<?php

if($_REQUEST['ajax']) {

  switch($_REQUEST['code']) {


    case "fntrans_group_code":

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

  }
    die("");
}


$ssql="SELECT MAX(fntrans_group_code) FROM tstransaction_status";


$urutan=RetRstField($ssql);
$urutan = $urutan+1;

$panjang="document.getElementById('fntrans_group_code').value='{$urutan}';";
$objAxpDB->FormJS($panjang);

$objAxpDB->ViewName("Daftar Status Transaksi");

$objAxpDB->ViewSQL("SELECT `fnid`,
                           `fntrans_group_code`,
                           `fntrans_status_code`,
                           `fttrans_group_name`,
                           `fttrans_status_name`,
                            case when fnactive_status=0 then 'Tidak Aktif' else 'Aktif' end as Status
                            FROM tstransaction_status order by fntrans_group_code desc");

$objAxpDB->ViewCaption("id,Kode Grup,Kode Status, Nama Grup Transaksi,Transaksi, Status");

$objAxpDB->FormName("Status Transaksi");

$objAxpDB->FormSQL("SELECT `fnid`,
                           `fntrans_group_code`,
                           `fntrans_status_code`,
                           `fttrans_group_name`,
                           `fttrans_status_name`,
                            fnactive_status
                            FROM tstransaction_status");

$objAxpDB->FormCaption("id,Kode Grup,Kode Status, Nama Grup Transaksi,Status Transaksi, Status");

$objAxpDB->FormPosition("HD,TL, TL, TL, TL, TL");

$objAxpDB->SetStatus("id");

$objAxpDB->Lookup('fnactive_status', '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);


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->Process();
$objAxpDB->WriteHtmlTable();
