<?php

if($_REQUEST['ajax']) {

  switch($_REQUEST['code']) {


    case "ftmodule_code":

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

  }
    die("");
}

$panjang="document.getElementById('fnlength').value='5';";
$objAxpDB->FormJS($panjang);

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

$objAxpDB->ViewSQL("SELECT `fnid` , `ftbranch_code` ,`ftmodule_code`, `ftmodule_name`, `ftcode`, `fnlength`, case when fnstatus=0 then 'Tidak Aktif' else 'Aktif' end as Status
   FROM tstransaction_number ORDER BY fdcreated_date DESC");

$objAxpDB->ViewCaption("id,Cabang,Kode Modul ,Nama Modul, Kode Transaksi , Panjang, Status ");

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

$objAxpDB->FormSQL("SELECT `fnid` , ftmodule_code, `ftmodule_name`, `ftcode`, `fnlength`, fnstatus FROM `tstransaction_number`");

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

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

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