PHP 8 rerun of number_format fix.
[fa-stable.git] / sales / includes / db / cust_trans_details_db.inc
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 //----------------------------------------------------------------------------------------
13
14 function get_customer_trans_details($debtor_trans_type, $debtor_trans_no)
15 {
16 if (!is_array($debtor_trans_no))
17         $debtor_trans_no = array( 0=>$debtor_trans_no );
18
19         $sql = "SELECT line.*,
20                 line.unit_price+line.unit_tax AS FullUnitPrice,
21         line.unit_price AS UnitPriceExTax,  
22                 line.description AS StockDescription,
23                 item.long_description AS StockLongDescription,
24                 item.units, item.mb_flag
25                 FROM "
26                         .TB_PREF."debtor_trans_details line,"
27                         .TB_PREF."stock_master item
28                 WHERE (";
29
30         $tr=array();
31         foreach ($debtor_trans_no as $trans_no)
32                 $tr[] = 'debtor_trans_no='.db_escape($trans_no);
33
34         $sql .= implode(' OR ', $tr);
35
36
37         $sql.=  ") AND debtor_trans_type=".db_escape($debtor_trans_type)."
38                 AND item.stock_id=line.stock_id
39                 ORDER BY id";
40         return db_query($sql, "The debtor transaction detail could not be queried");
41 }
42
43 //----------------------------------------------------------------------------------------
44
45 function void_customer_trans_details($type, $type_no)
46 {
47         $sql = "UPDATE ".TB_PREF."debtor_trans_details SET quantity=0, unit_price=0,
48                 unit_tax=0, discount_percent=0, standard_cost=0, src_id=0
49                 WHERE debtor_trans_no=".db_escape($type_no)."
50                 AND debtor_trans_type=".db_escape($type);
51
52         db_query($sql, "The debtor transaction details could not be voided");
53
54         // clear the stock move items
55         void_stock_move($type, $type_no);
56 }
57 //----------------------------------------------------------------------------------------
58
59 function write_customer_trans_detail_item($debtor_trans_type, $debtor_trans_no, $stock_id, $description,
60         $quantity, $unit_price, $unit_tax, $discount_percent, $std_cost, $src_id, $line_id=0)
61 {
62         if ($line_id!=0)
63                 $sql = "UPDATE ".TB_PREF."debtor_trans_details SET
64                         stock_id=".db_escape($stock_id).",
65                         description=".db_escape($description).",
66                         quantity=$quantity,
67                         unit_price=$unit_price,
68                         unit_tax=$unit_tax,
69                         discount_percent=$discount_percent,
70                         standard_cost=$std_cost,
71                         src_id=".db_escape($src_id)." WHERE
72                         id=".db_escape($line_id);
73         else
74                         $sql = "INSERT INTO ".TB_PREF."debtor_trans_details (debtor_trans_no,
75                                 debtor_trans_type, stock_id, description, quantity, unit_price,
76                                 unit_tax, discount_percent, standard_cost, src_id)
77                         VALUES (".db_escape($debtor_trans_no).", ".db_escape($debtor_trans_type).", ".db_escape($stock_id).
78                         ", ".db_escape($description).",
79                                 $quantity, $unit_price, $unit_tax, 
80                                 $discount_percent, $std_cost,".db_escape($src_id).")";
81
82         db_query($sql, "The debtor transaction detail could not be written");
83 }
84