Old ineffective sql_trail superseded by new improved db_trail logging only calls...
[fa-stable.git] / sales / includes / db / credit_status_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 function add_credit_status($description, $disallow_invoicing)
13 {
14         begin_transaction(__FUNCTION__, func_get_args());
15         $sql = "INSERT INTO ".TB_PREF."credit_status (reason_description, dissallow_invoices) 
16                 VALUES (".db_escape($description).",".db_escape($disallow_invoicing).")";
17
18         db_query($sql, "could not add credit status");
19         $result = db_insert_id();
20
21         commit_transaction();
22         return $result;
23 }
24
25 function update_credit_status($status_id, $description, $disallow_invoicing)
26 {
27         begin_transaction(__FUNCTION__, func_get_args());
28         $sql = "UPDATE ".TB_PREF."credit_status SET reason_description=".db_escape($description).",
29                 dissallow_invoices=".db_escape($disallow_invoicing)." WHERE id=".db_escape($status_id);
30
31         db_query($sql, "could not update credit status");
32         commit_transaction();
33 }
34
35 function get_all_credit_status($all=false)
36 {
37         $sql = "SELECT * FROM ".TB_PREF."credit_status";
38         if (!$all) $sql .= " WHERE !inactive";
39
40         return db_query($sql, "could not get all credit status");
41 }
42
43 function get_credit_status($status_id)
44 {
45         $sql = "SELECT * FROM ".TB_PREF."credit_status WHERE id=".db_escape($status_id);
46
47         $result = db_query($sql, "could not get credit status");
48
49         return db_fetch($result);
50 }
51
52 function delete_credit_status($status_id)
53 {
54         begin_transaction(__FUNCTION__, func_get_args());
55         $sql="DELETE FROM ".TB_PREF."credit_status WHERE id=".db_escape($status_id);
56
57         db_query($sql, "could not delete credit status");
58         commit_transaction();
59 }
60