<?php

 if($_REQUEST['ajax']) {
        switch($_REQUEST['code']) {
            case "transno":
              if(RetRstField("SELECT fnid FROM txproduction_order_request_hdr WHERE ftpor_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
              }
               die("");
            break;

        }

    }


 Getsecurity(32);
  $objAxpDB->LookupMagicQuotes(True);
$objAxpDB->ViewName("Daftar Production Order Request(Custom)");
$objAxpDB->ViewSQL("SELECT A.fnid, A.ftpor_no, A.ftmpor_no, A.fdtrans_date, A.fdfinished_date,A.ftstock_group_code,C.ftstock_group_name, A.ftnotes, B.fttrans_status_name FROM txproduction_order_request_hdr
                        A INNER JOIN tstransaction_status B ON a.fnstatus=b.fntrans_status_code AND B.fntrans_group_code=2
                            LEFT JOIN tlstock_group c on a.ftstock_group_code=c.ftstock_group_code
                            WHERE IFNULL(A.fntype,0)=1
                        ORDER BY  A.ftpor_no DESC, A.fdtrans_date DESC");

$objAxpDB->ViewCaption("ID, No. POR, No. MPOR, Tanggal,  Tanggal Selesai,Kode Group, Group, Catatan, Status");
$objAxpDB->ViewPeriod(TRUE);

$objAxpDB->FormName("Production Order Request Custom");
$objAxpDB->FormSQL("SELECT  ftpor_no,fntype, ftmpor_no,fdtrans_date, fdfinished_date,ftstock_group_code, ftnotes, fnstatus FROM txproduction_order_request_hdr");
$objAxpDB->FormCaption("No. POR,Temp No. POR,  No.MPOR, Tanggal, Tanggal Selesai, Jenis Produk, Catatan, Status");
  $objAxpDB->FormPosition(" TL, HD,TL,TL, TR, TR,BL, BR");
$objAxpDB->SetStatus("id, fnstatus");

	
$objAxpDB->GridSQL(0, "SELECT fnindex,
                       ftstock_group_code, ftstock_subgroup_code, ftdecal_code,
                       ftcolor_code, ffqty_mpor,ftsize_code, ffqty
                        from txproduction_order_request_det

            "); 
$objAxpDB->GridCaption(0, "No, Group, Sub Group, Decal, Warna,Qty(Per Type & Warna),Size, Qty Rak");

if($objAxpDB->GetStatus("id") ==0) {
         $strAutoNumber1=" ajax_do('query2.php?code=2&ftmodule_code=tn103_1&thbln=' + document.getElementById(\"fdtrans_date\").value + '&field_name=ftpor_no&no_trans=ftpor_no&table_name=txproduction_order_request_hdr');";
         $strAutoNumber0=" function OnChangeDate_fdtrans_date() {
                                                                   {$strAutoNumber1}
                                                         }
                                                 OnChangeDate_fdtrans_date();

                                                ";
        $objAxpDB->FormJS($strAutoNumber0);
}
 
$objAxpDB->Lookup("fnstatus", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 2", "fntrans_status_code", "fttrans_status_name", 0,true);
$objAxpDB->Lookup("ftstock_group_code", "SELECT ftstock_group_code, ftstock_group_name FROM tlstock_group", "ftstock_group_code", "ftstock_group_name", 0,false);
$objAxpDB->Lookup("ftdecal_code", "SELECT ftdecal_code, ftdecal_name FROM tldecal", "ftdecal_code", "ftdecal_name", -1,false);
$objAxpDB->Lookup("ftstock_subgroup_code", "SELECT ftstock_subgroup_code,ftstock_subgroup_name,ftstock_group_code FROM tlstock_subgroup ", "ftstock_subgroup_code", "ftstock_subgroup_name", -1,false,"' AND  ftstock_group_code=\''+ document.getElementById('ftstock_group_codeD0_N_').value + '\''");
$objAxpDB->Lookup("ftcolor_code", "SELECT ftcolor_code, ftcolor_name FROM tlcolor", "ftcolor_code", "ftcolor_name", -1,false);
$objAxpDB->Lookup("ftsize_code", "SELECT ftsize_code, ftsize_name FROM tlsize", "ftsize_code", "ftsize_name", -1,false);

$objAxpDB->GridSize(0, ",
                       10, 10, 10,
                       10, 10,10, 10
            ");
if ($objAxpDB->GetStatus("id") == "") {
        $objAxpDB->ButtonShow(" baru, cetak_daftar, export_excel , tutup");
}
elseif ($objAxpDB->GetStatus("id") ==0) {
     $objAxpDB->ButtonShow("simpan, tutup");
     $objAxpDB->FormLocked("0,0,0, 0,0, 0, 0,1");
     $objAxpDB->GridLocked(0, "1,
                       0, 0, 0,
                       0, 0,0, 0");
   
     $objAxpDB->GridAllowAddNew(0,true);
     $objAxpDB->GridAllowDelete(0,true);
}
elseif ($objAxpDB->GetStatus("fnstatus") ==0) {
         $objAxpDB->ButtonShow("final, update, tutup");
        $objAxpDB->FormLocked("1,1,1, 0,0, 1, 0,1");
       $objAxpDB->GridLocked(0, "1,
                       0, 0, 0,
                       0, 0,0, 0");
        $objAxpDB->GridAllowAddNew(0,true);
     $objAxpDB->GridAllowDelete(0,true);
//         $objAxpDB->FormJS(" ValCalOrderRequest(); ");  

} elseif ($objAxpDB->GetStatus("fnstatus") == 1) {
        $objAxpDB->ButtonShow("cetak,tutup");
        $objAxpDB->FormLocked("1,1,1, 1,1, 1, 1,1");
        $objAxpDB->GridLocked(0," 1,
                               1, 1,1,
                               1, 1,1, 1");
}
$objAxpDB->Process();
$objAxpDB->WriteHtmlTable();

?>
