<?php

function UpdateData() {
    global $objAxpDB;
   
    $objAxpDB->Allow_Update(false);
    switch($_REQUEST[mode]) {
         case "update":
           
            for($j=1; $j<count($_REQUEST['ftitem_codeD0']); $j++) {

               // if($_REQUEST['fcselling_priceD0'][$j]!=$_REQUEST['fcold_selling_priceD0'][$j]) {
                        $strSQL['Update Harga Jual Price'][]="  UPDATE tlselling_price SET 
                                                            fcold_selling_price=fcselling_price,
                                                            fcselling_price='".CCur($_REQUEST['fcselling_priceD0'][$j])."'
                                                            WHERE ftitem_code='{$_REQUEST['ftitem_codeD0'][$j]}' AND 
                                                                    ftcustomer_type_code='{$_REQUEST['ftcustomer_type_code']}' and
                                                                fcselling_price<>".CCur($_REQUEST['fcselling_priceD0'][$j]);
                    //    }
                // if($_REQUEST['ftship_addressD0'][$j]!=$_REQUEST['ffold_selling_discountD0'][$j]) {
                         $strSQL['Update Harga Jual Discount'][]="  UPDATE tlselling_price SET 
                                                            ffold_selling_discount=ffselling_discount,
                                                            ffselling_discount='".CCur($_REQUEST['ffselling_discountD0'][$j])."'
                                                            WHERE ftitem_code='{$_REQUEST['ftitem_codeD0'][$j]}' AND 
                                                                    ftcustomer_type_code='{$_REQUEST['ftcustomer_type_code']}'
                                                                    and ffselling_discount<>".CCur($_REQUEST['ffselling_discountD0'][$j]);
                       // }

                       //jika ada 2 in 2 harga nya disamain dengan bukan 2 in 1
                       
                       if(strlen($_REQUEST['ftitem_codeD0'][$j])==17) {
                        
                            $m=$_REQUEST['ftitem_codeD0'][$j];
                            
                           if($m[13]=="0") {

                                $ftitem_code=substr($m,0,13)."1".$m[14].$m[15].$m[16];

                                  // if($_REQUEST['fcselling_priceD0'][$j]!=$_REQUEST['fcold_selling_priceD0'][$j]) {
                                $strSQL['Update Harga Jual Price'][]="  UPDATE tlselling_price SET
                                                                    fcold_selling_price=fcselling_price,
                                                                    fcselling_price='".CCur($_REQUEST['fcselling_priceD0'][$j])."'
                                                                    WHERE ftitem_code='{$ftitem_code}' AND
                                                                            ftcustomer_type_code='{$_REQUEST['ftcustomer_type_code']}' and
                                                                        fcselling_price<>".CCur($_REQUEST['fcselling_priceD0'][$j]);
                            //    }
                        // if($_REQUEST['ftship_addressD0'][$j]!=$_REQUEST['ffold_selling_discountD0'][$j]) {
                                 $strSQL['Update Harga Jual Discount'][]="  UPDATE tlselling_price SET
                                                                    ffold_selling_discount=ffselling_discount,
                                                                    ffselling_discount='".CCur($_REQUEST['ffselling_discountD0'][$j])."'
                                                                    WHERE ftitem_code='{$ftitem_code}' AND
                                                                            ftcustomer_type_code='{$_REQUEST['ftcustomer_type_code']}'
                                                                            and ffselling_discount<>".CCur($_REQUEST['ffselling_discountD0'][$j]);
                               // }
                                   }
                       }


            }
            break;
    }
//    pr($strSQL);die("ss");
    return $strSQL;
} 


	
?>
