Old ineffective sql_trail superseded by new improved db_trail logging only calls...
[fa-stable.git] / purchasing / includes / db / suppliers_db.inc
index c031cede6d186e36703592b81dce2819e7f8ef9b..2648ff60e0a635667a1e009157d82bfdad5ff74f 100644 (file)
@@ -15,6 +15,7 @@ function add_supplier($supp_name, $supp_ref, $address, $supp_address, $gst_no,
        $curr_code, $payment_terms, $payable_account, $purchase_account, $payment_discount_account, 
        $notes, $tax_group_id, $tax_included)
 {
+       begin_transaction(__FUNCTION__, func_get_args());
        $sql = "INSERT INTO ".TB_PREF."suppliers (supp_name, supp_ref, address, supp_address, gst_no, website,
                supp_account_no, bank_account, credit_limit, dimension_id, dimension2_id, curr_code,
                payment_terms, payable_account, purchase_account, payment_discount_account, notes, 
@@ -40,6 +41,7 @@ function add_supplier($supp_name, $supp_ref, $address, $supp_address, $gst_no,
                .db_escape($tax_included). ")";
 
        db_query($sql,"The supplier could not be added");
+       commit_transaction();
 }
 
 function update_supplier($supplier_id, $supp_name, $supp_ref, $address, $supp_address, $gst_no, 
@@ -47,6 +49,7 @@ function update_supplier($supplier_id, $supp_name, $supp_ref, $address, $supp_ad
        $curr_code, $payment_terms, $payable_account, $purchase_account, $payment_discount_account, 
        $notes, $tax_group_id, $tax_included)
 {
+       begin_transaction(__FUNCTION__, func_get_args());
        $sql = "UPDATE ".TB_PREF."suppliers SET supp_name=".db_escape($supp_name) . ",
                supp_ref=".db_escape($supp_ref) . ",
                address=".db_escape($address) . ",
@@ -69,12 +72,15 @@ function update_supplier($supplier_id, $supp_name, $supp_ref, $address, $supp_ad
                ." WHERE supplier_id = ".db_escape($supplier_id);
 
        db_query($sql,"The supplier could not be updated");
+       commit_transaction();
 }
 
 function delete_supplier($supplier_id)
 {
+       begin_transaction(__FUNCTION__, func_get_args());
        $sql="DELETE FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
        db_query($sql,"check failed");
+       commit_transaction();
 }
 
 function get_supplier_details($supplier_id, $to=null, $all=true)
@@ -93,7 +99,7 @@ function get_supplier_details($supplier_id, $to=null, $all=true)
     else       
        $value = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_BANKDEPOSIT."
        OR (trans.type=".ST_JOURNAL." AND (trans.ov_amount + trans.ov_gst + trans.ov_discount)>0), 1, -1)*
-               ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) - trans.alloc)";
+               ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) - trans.alloc";
 
        $due = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_SUPPCREDIT.",trans.due_date,trans.tran_date)";
     $sql = "SELECT supp.supp_name, supp.curr_code, ".TB_PREF."payment_terms.terms,
@@ -149,7 +155,7 @@ function get_supplier_name($supplier_id)
 
 function get_supplier_accounts($supplier_id)
 {
-       $sql = "SELECT payable_account,purchase_account,payment_discount_account FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
+       $sql = "SELECT payable_account,purchase_account,payment_discount_account, dimension_id, dimension2_id FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
 
        $result = db_query($sql, "could not get supplier");