<?php

switch($_REQUEST[mode]) {
case "hapus":
         if(RetRstField("SELECT fnid FROM tlemployee WHERE ftshift_code='{$_REQUEST['ftshift_code']}'")) {
             echo "<script>
                    alert('data tidak dapat di delete karena sudah digunakan dalam transaksi ...');
                    window.history.back();
                </script>";
                die("");
         }

    break;
 }


   function SaveData() {
        global $objAxpDB;
        $objAxpDB->Allow_Save(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "simpan":             
                for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
                    $strSQL['Insert tlshift'][]="INSERT INTO tlshift (ftshift_code,ftshift_name,fnindex,ftshift_day,fdshift_in,fdshift_out,
                                                      ftcreated_user,fdcreated_date)
                                                      VALUES ('{$_REQUEST['ftshift_code']}','{$_REQUEST['ftshift_name']}','{$_REQUEST['fnindexD0'][$j]}','{$_REQUEST['ftshift_dayD0'][$j]}','{$_REQUEST['fdshift_inD0'][$j]}','{$_REQUEST['fdshift_outD0'][$j]}',
                                                      '{$_SESSION['username']}',now())";
                }                
          
                break;
         }
    return $strSQL;
   }
    function UpdateData() {
        global $objAxpDB;
        $objAxpDB->Allow_Update(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "update":
                for($j=1; $j<count($_REQUEST['fnindexD0']); $j++) {
                    $strSQL['update tlshift'][]="UPDATE tlshift
                                                            SET ftshift_name='{$_REQUEST['ftshift_name']}',
                                                                    fdshift_in='{$_REQUEST['fdshift_inD0'][$j]}',fdshift_out='{$_REQUEST['fdshift_outD0'][$j]}',
                                                                    ftmodified_user= '{$_SESSION['username']}',fdmodified_date=now() 
                                                    WHERE ftshift_code='{$_REQUEST['ftshift_code']}' AND
                                                            ftshift_day='{$_REQUEST['ftshift_dayD0'][$j]}'";
                }

                break;
         }
    return $strSQL;
   }

 function DeleteData() {
        global $objAxpDB;
        $objAxpDB->Allow_Delete=false;
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "hapus":                     
			$strSQL['DELETE tlshift'][]="DELETE FROM tlshift WHERE ftshift_code='".$_REQUEST['ftshift_code']."'";
		
            break;
	 }
    return $strSQL;
   }



?>
