<?php
       if($_REQUEST['ajax']) {
            switch($_REQUEST['code']) {
                case "transno":
                  if(RetRstField("SELECT fnid FROM thshift_change_hdr WHERE fttrans_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;
              
            }
       }
    $objAxpDB->ViewName("Daftar Shift Pegawai Kolektif");
    $objAxpDB->ViewTable("vHRPegawaiKolektif");
    $objAxpDB->ViewSQL("SELECT a.fnid,a.fttrans_no,a.fdtrans_date,
                            a.ftnotes 
                        FROM thshift_change_hdr a
                       ");
    $objAxpDB->ViewCaption("ID, No. Transaksi, Tgl. Transaksi, Catatan");
	$objAxpDB->ViewPeriod(TRUE);

    // Deklarasi Header & Footer
    $objAxpDB->FormName("Shift Pegawai Kolektif");
    $objAxpDB->FormSQL("SELECT  fttrans_no, fdtrans_date,                                    
                            ftnotes, fnstatus 
                            FROM thshift_change_hdr");
    $objAxpDB->FormCaption("No. Transaksi, Tgl. Transaksi,                            
                            Catatan, fnstatus");
    $objAxpDB->FormPosition("TL, 
                                TR,
                            BL, BR");
 // Deklarasi Detail
    $objAxpDB->GridSQL(0, "SELECT fnindex, ftdivision_code,ftdepartment_code, ftposition_code,ftshift_code_from,ftshift_code_to FROM thshift_change_det");
    $objAxpDB->GridCaption(0, "No., Divisi, Departement, Jabatan,  Shift Asal, Shft Tujuan");
     $objAxpDB->Lookup("ftposition_code", "select 'SELURUH' AS ftposition_code,'SELURUH' AS ftposition_name UNION ALL (SELECT ftposition_code, ftposition_name FROM tlposition   order by ftposition_code) ", "ftposition_code", "ftposition_name", -1, False);
    $objAxpDB->Lookup("ftdepartment_code", "select 'SELURUH' AS ftdepartment_code,'SELURUH' AS ftdepartment_name UNION ALL (select ftdepartment_code, ftdepartment_name from tldepartment order by ftdepartment_code) ", "ftdepartment_code", "ftdepartment_name", -1, False);
    $objAxpDB->Lookup("ftdivision_code", "select 'SELURUH' AS ftdivision_code,'SELURUH' AS ftdivision_name UNION ALL (select ftdivision_code, ftdivision_name from tldivision order by ftdivision_code) ", "ftdivision_code", "ftdivision_name", -1, False);
     $objAxpDB->Lookup("ftshift_code_from", "SELECT distinct ftshift_code, ftshift_name FROM tlshift", "ftshift_code", "ftshift_name", 0, True);
    $objAxpDB->Lookup("ftshift_code_to", "SELECT distinct ftshift_code, ftshift_name FROM tlshift", "ftshift_code", "ftshift_name", 0, True);
    $objAxpDB->Lookup("fnstatus", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 2", "fntrans_status_code", "fttrans_status_name",1, True);
   

        $objAxpDB->SetStatus("id, fnstatus");
       if(!$_REQUEST['id']) {
            $strAutoNumber1="ajax_do('query2.php?code=2&ftmodule_code=hrd010&thbln=' + document.getElementById(\"fdtrans_date\").value + '&field_name=fttrans_no&no_trans=fttrans_no&table_name=thshift_change_hdr');";

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

                                     }
                                     OnChangeDate_fdtrans_date();

                                ";

            $objAxpDB->FormJS($strAutoNumber0);
     }
     else {

            $objAxpDB->FormJS($strAutoNumber0);
     }
    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 ,1");
            $objAxpDB->GridLocked(0, "1, 0, 0, 0, 0, 0");

            $objAxpDB->GridAllowAddNew(0, TRUE);
            $objAxpDB->GridAllowDelete(0, TRUE);
    } elseif ($objAxpDB->GetStatus("fnstatus") == 1) {
             $objAxpDB->GridAllowAddNew(0, FALSE);
             $objAxpDB->GridAllowDelete(0, FALSE);
              $objAxpDB->ButtonShow(" tutup");

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