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 //----------------------------------------------------------------------------------------
14 function get_customer_trans_details($debtor_trans_type, $debtor_trans_no)
16 if (!is_array($debtor_trans_no))
17 $debtor_trans_no = array( 0=>$debtor_trans_no );
19 $sql = "SELECT line.*,
20 line.unit_price+line.unit_tax AS FullUnitPrice,
21 line.description As StockDescription,
22 item.units, item.mb_flag
24 .TB_PREF."debtor_trans_details line,"
25 .TB_PREF."stock_master item
29 foreach ($debtor_trans_no as $trans_no)
30 $tr[] = 'debtor_trans_no='.db_escape($trans_no);
32 $sql .= implode(' OR ', $tr);
35 $sql.= ") AND debtor_trans_type=".db_escape($debtor_trans_type)."
36 AND item.stock_id=line.stock_id
38 return db_query($sql, "The debtor transaction detail could not be queried");
41 //----------------------------------------------------------------------------------------
43 function void_customer_trans_details($type, $type_no)
45 $sql = "UPDATE ".TB_PREF."debtor_trans_details SET quantity=0, unit_price=0,
46 unit_tax=0, discount_percent=0, standard_cost=0, src_id=0
47 WHERE debtor_trans_no=".db_escape($type_no)."
48 AND debtor_trans_type=".db_escape($type);
50 db_query($sql, "The debtor transaction details could not be voided");
52 // clear the stock move items
53 void_stock_move($type, $type_no);
55 //----------------------------------------------------------------------------------------
57 function write_customer_trans_detail_item($debtor_trans_type, $debtor_trans_no, $stock_id, $description,
58 $quantity, $unit_price, $unit_tax, $discount_percent, $std_cost, $src_id, $line_id=0)
61 $sql = "UPDATE ".TB_PREF."debtor_trans_details SET
62 stock_id=".db_escape($stock_id).",
63 description=".db_escape($description).",
65 unit_price=$unit_price,
67 discount_percent=$discount_percent,
68 standard_cost=$std_cost,
69 src_id=".db_escape($src_id)." WHERE
70 id=".db_escape($line_id);
72 $sql = "INSERT INTO ".TB_PREF."debtor_trans_details (debtor_trans_no,
73 debtor_trans_type, stock_id, description, quantity, unit_price,
74 unit_tax, discount_percent, standard_cost, src_id)
75 VALUES (".db_escape($debtor_trans_no).", ".db_escape($debtor_trans_type).", ".db_escape($stock_id).
76 ", ".db_escape($description).",
77 $quantity, $unit_price, $unit_tax,
78 $discount_percent, $std_cost,".db_escape($src_id).")";
80 db_query($sql, "The debtor transaction detail could not be written");