<?php

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


   function SaveDataLast() {
        global $objAxpDB;
       
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "simpan":             
                if($_REQUEST['hidden_flag']=='1') {
					if($_REQUEST['fnsalary_type']=='0') {						
							$ssql="INSERT INTO  tlemployee_salary_inc(
									ftbranch_code,fnindex,ftemployee_code,ftsalary_code,
									fcamount,fnsalary_period,fnpayroll_slip,ftcreated_user,
									fdcreated_date,ftmodified_user,fdmodified_date)		
								SELECT a.ftbranch_code,MAX(b.fnindex)+1 AS fnindex,a.ftemployee_code,'yyy1' AS ftsalary_code,
									'70000.00' AS fcamount,'1' AS fnsalary_period,'1' AS fnpayroll_slip,
									'ADMIN' AS ftcreated_user,NOW() AS fdcreated_date,
							'ADMIN' AS ftmodified_user,NOW() AS fdmodified_date  
								FROM tlemployee a,tlemployee_salary_inc b
								WHERE a.ftemployee_code=b.ftemployee_code
								GROUP BY a.ftbranch_code,a.ftemployee_code";
								
					}
					else {
						$ssql="INSERT INTO  tlemployee_salary_dec(
									ftbranch_code,fnindex,ftemployee_code,ftsalary_code,
									fcamount,fnsalary_period,fnpayroll_slip,ftcreated_user,
									fdcreated_date,ftmodified_user,fdmodified_date)		
								SELECT a.ftbranch_code,MAX(b.fnindex)+1 AS fnindex,a.ftemployee_code,'yyy1' AS ftsalary_code,
									'70000.00' AS fcamount,'1' AS fnsalary_period,'1' AS fnpayroll_slip,
									'ADMIN' AS ftcreated_user,NOW() AS fdcreated_date,
							'ADMIN' AS ftmodified_user,NOW() AS fdmodified_date  
								FROM tlemployee a,tlemployee_salary_dec b
								WHERE a.ftemployee_code=b.ftemployee_code
								GROUP BY a.ftbranch_code,a.ftemployee_code";
						
					}
					$strSQL['tlemployee_salary'][]=$ssql;
				}
				     
                break;
         }
    return $strSQL;
   }





?>
