<?php
 
   function SaveData() {   
        global $objAxpDB;
        $objAxpDB->Allow_Save(false);
        $strSQL=array();
        switch($_REQUEST[mode]) {
        case "simpan":  
             
            if($_REQUEST['fnstatus_giro']!=0) {
                    $ssql="SELECT * 
                          FROM txgiro2_hist 
                          WHERE  fnstatus_giro<>'9' AND  ftgiro_no='{$_REQUEST['ftgiro_no']}' AND
                                ftdocument_no='{$_REQUEST['ftdocument_no']}'";
                 $rs=mysql_query($ssql);
                 $r=mysql_fetch_assoc($rs);
                 
                  $strSQL['Update GIRO'][]="UPDATE txgiro2_hist 
                                                SET fdgiro_cliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."',
                                                ftacc_no='{$_REQUEST['ftacc_no']}',
                                                 ftpf_no='{$_REQUEST['ftpf_no']}',
                                                fnstatus_giro='{$_REQUEST['fnstatus_giro']}' 
                                            WHERE ftgiro_no='{$_REQUEST['ftgiro_no']}' AND 
                                                  ftdocument_no='{$_REQUEST['ftdocument_no']}'";
               if($r['fttype']=='AP') {
                       $strSQL['Update txrecap_bank_voucher_det1'][]="
                          UPDATE txrecap_bank_voucher_det1 
                          SET fnstatus_giro='{$_REQUEST['fnstatus_giro']}' ,fdgiro_cliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."' 
                          WHERE ftcvs_no='{$_REQUEST['ftdocument_no']}' AND 
                                ftgiro_no='{$_REQUEST['ftgiro_no']}'";
                  }
                  elseif($r['fttype']=='BK') {
                      $strSQL['Update txbankpym_det'][]="
                          UPDATE txbankpym_det 
                          SET fnstatus_giro='{$_REQUEST['fnstatus_giro']}' ,fdgiro_cliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."'  
                          WHERE ftbankpym_no='{$_REQUEST['ftdocument_no']}' AND 
                                ftgiro_no='{$_REQUEST['ftgiro_no']}'";
                      
                  }
                  elseif($r['fttype']=='UM') {
                      $strSQL['Update txadvanced_payment'][]="
                          UPDATE txadvanced_payment
                          SET fngiro_status='{$_REQUEST['fnstatus_giro']}' ,fdcliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."'
                          WHERE fttrans_no='{$_REQUEST['ftdocument_no']}' AND ftgiro_no='{$_REQUEST['ftgiro_no']}'";
                  }
                 

            }    
         break;
        }
       # pr($strSQL);die("m");
        return $strSQL;
   }

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

           
                    $ssql="SELECT *
                          FROM txgiro2_hist
                          WHERE  fnstatus_giro<>'9' AND  ftgiro_no='{$_REQUEST['ftgiro_no']}' AND
                                ftdocument_no='{$_REQUEST['ftdocument_no']}'";
                 $rs=mysql_query($ssql);
                 $r=mysql_fetch_assoc($rs);

                  $strSQL['Update GIRO'][]="UPDATE txgiro2_hist
                                                SET fdgiro_cliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."',
                                                ftacc_no='{$_REQUEST['ftacc_no']}',
                                                 ftpf_no='{$_REQUEST['ftpf_no']}',
                                                fnstatus_giro='{$_REQUEST['fnstatus_giro']}'
                                            WHERE ftgiro_no='{$_REQUEST['ftgiro_no']}' AND
                                                  ftdocument_no='{$_REQUEST['ftdocument_no']}'";
               if($r['fttype']=='AP') {
                       $strSQL['Update txrecap_bank_voucher_det1'][]="
                          UPDATE txrecap_bank_voucher_det1
                          SET fnstatus_giro='{$_REQUEST['fnstatus_giro']}' ,fdgiro_cliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."'
                          WHERE ftcvs_no='{$_REQUEST['ftdocument_no']}' AND
                                ftgiro_no='{$_REQUEST['ftgiro_no']}'";
                  }
                  elseif($r['fttype']=='BK') {
                      $strSQL['Update txbankpym_det'][]="
                          UPDATE txbankpym_det
                          SET fnstatus_giro='{$_REQUEST['fnstatus_giro']}' ,fdgiro_cliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."'
                          WHERE ftbankpym_no='{$_REQUEST['ftdocument_no']}' AND
                                ftgiro_no='{$_REQUEST['ftgiro_no']}'";

                  }
                  elseif($r['fttype']=='UM') {
                      $strSQL['Update txadvanced_payment'][]="
                          UPDATE txadvanced_payment
                          SET fngiro_status='{$_REQUEST['fnstatus_giro']}' ,fdcliring_date='".CDate($_REQUEST['fdgiro_cliring_date'])."' 
                          WHERE fttrans_no='{$_REQUEST['ftdocument_no']}' AND ftgiro_no='{$_REQUEST['ftgiro_no']}'";
                  }


         
         break;
        }
       # pr($strSQL);die("m");
        return $strSQL;
   }
   
?>
