<?php

 function ValBatalPerhitunganLembur() {
       

    }

    
   if($_REQUEST[mode]=='update') $_REQUEST[mode]="simpan";
   function SaveData() {
        global $objAxpDB;
//        $objAxpDB->Allow_Save(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "simpan":
                $strSQL["DEL txovertime_hdr"][]="DELETE FROM txovertime_hdr WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";
                $strSQL["DEL txovertime_det"][]="DELETE FROM txovertime_det WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";

                break;
         }
    return $strSQL;
   }
   function SaveDataLast() {
        global $objAxpDB;
//        $objAxpDB->Allow_Save(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "simpan":
                $strSQL["DEL txovertime_hdr"][]="DELETE FROM txovertime_hdr WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";
                $strSQL["DEL txovertime_det"][]="DELETE FROM txovertime_det WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";

                 $strSQL["A"][]=" update txovertime_det  a,tlemployee b
                                set a.fnsalary_type=b.fnsalary_type,
                                a.ftdivision_code=b.ftdivision_code,
                                a.ftposition_code=b.ftposition_code ,
                                a.ftdepartment_code=b.ftdepartment_code
                                where a.ftemployee_code=b.ftemployee_code and
                                a.ftovertime_no='{$_REQUEST['ftovertime_no']}'";

                $strSQL["A"][]=" update txovertime_det  a
                                set a.fnsalary_type2=1
                                where exists(select b.fnid from tlemployee_salary_inc_plus2 b where a.ftemployee_code=b.ftemployee_code) and
                                a.ftovertime_no='{$_REQUEST['ftovertime_no']}'";

                $strSQL["A"][]=" update txovertime_det  a
                                set a.fnsalary_type2=0
                                where not exists(select b.fnid from tlemployee_salary_inc_plus2 b where a.ftemployee_code=b.ftemployee_code) and
                                a.ftovertime_no='{$_REQUEST['ftovertime_no']}'";


                break;
         }
    return $strSQL;
   }
    function UpdateData() {
        global $objAxpDB;
        $objAxpDB->Allow_Update(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "update":


             break;
         }
    return $strSQL;
   }

 function FinalData() {
        global $objAxpDB;
        $objAxpDB->Allow_Final(true);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "final":
                $_REQUEST['fnstatus']=1;
                $strSQL["DEL txovertime_hdr"][]="DELETE FROM txovertime_hdr WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";
                $strSQL["DEL txovertime_det"][]="DELETE FROM txovertime_det WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";
          break;
	 }
    return $strSQL;
   }
 function FinalDataLast() {
        global $objAxpDB;
        $objAxpDB->Allow_Final(true);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "final":
                $_REQUEST['fnstatus']=1;
                $strSQL["DEL txovertime_hdr"][]="DELETE FROM txovertime_hdr WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";
                $strSQL["DEL txovertime_det"][]="DELETE FROM txovertime_det WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";


                 $strSQL["A"][]=" update txovertime_det  a,tlemployee b
                                set a.fnsalary_type=b.fnsalary_type,
                                a.ftdivision_code=b.ftdivision_code,
                                a.ftposition_code=b.ftposition_code  ,
                                a.ftdepartment_code=b.ftdepartment_code
                                where a.ftemployee_code=b.ftemployee_code and
                                a.ftovertime_no='{$_REQUEST['ftovertime_no']}'";

                $strSQL["A"][]=" update txovertime_det  a
                                set a.fnsalary_type2=1
                                where exists(select b.fnid from tlemployee_salary_inc_plus2 b where a.ftemployee_code=b.ftemployee_code) and
                                a.ftovertime_no='{$_REQUEST['ftovertime_no']}'";

                $strSQL["A"][]=" update txovertime_det  a
                                set a.fnsalary_type2=0
                                where not exists(select b.fnid from tlemployee_salary_inc_plus2 b where a.ftemployee_code=b.ftemployee_code) and
                                a.ftovertime_no='{$_REQUEST['ftovertime_no']}'";

          break;
	 }
    return $strSQL;
   }

function CancelData() {
        ValBatalPerhitunganLembur();
        global $objAxpDB;
        $objAxpDB->Allow_Cancel(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
          case "batal":
              $strSQL["batal txovertime_hdr"][] =
                    "update txovertime_hdr
                            set ftmodified_user='{$_SESSION['username']}',fdmodified_date=now(),
                                fnstatus=9
                                WHERE ftovertime_no='{$_REQUEST['ftovertime_no']}'";



        break;
        }

        return $strSQL;
      }


?>
