Old ineffective sql_trail superseded by new improved db_trail logging only calls...
[fa-stable.git] / admin / db / shipping_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
15 function add_shipper($shipper_name, $contact, $phone, $phone2, $address)
16 {
17         begin_transaction(__FUNCTION__, func_get_args());
18
19         $sql = "INSERT INTO ".TB_PREF."shippers (shipper_name, contact, phone, phone2, address)
20                 VALUES (" . db_escape($shipper_name) . ", " .
21                 db_escape($contact). ", " .
22                 db_escape($phone). ", " .
23                 db_escape($phone2). ", " .
24                 db_escape($address) . ")";
25
26         db_query($sql,"The Shipping Company could not be added");
27         $result = db_insert_id();
28
29         commit_transaction();
30         return $result;
31 }
32
33 //--------------------------------------------------------------------------------------
34
35 function update_shipper($selected_id, $shipper_name, $contact, $phone, $phone2, $address)
36 {
37         begin_transaction(__FUNCTION__, func_get_args());
38
39         $sql = "UPDATE ".TB_PREF."shippers SET shipper_name=" . db_escape($shipper_name). " ,
40                 contact =" . db_escape($contact). " ,
41                 phone =" . db_escape($phone). " ,
42                 phone2 =" . db_escape($phone2). " ,
43                 address =" . db_escape($address). "
44                 WHERE shipper_id = ".db_escape($selected_id);
45
46         db_query($sql,"The shipping company could not be updated");
47
48         commit_transaction();
49 }
50
51 //--------------------------------------------------------------------------------------
52
53 function delete_shipper($selected_id)
54 {
55         begin_transaction(__FUNCTION__, func_get_args());
56
57         $sql="DELETE FROM ".TB_PREF."shippers WHERE shipper_id=".db_escape($selected_id);
58         
59         db_query($sql,"could not delete shipper");
60
61         commit_transaction();
62 }
63
64 //--------------------------------------------------------------------------------------
65
66 function get_shippers($show_inactive)
67 {
68         $sql = "SELECT * FROM ".TB_PREF."shippers";
69         if (!$show_inactive) $sql .= " WHERE !inactive";
70         $sql .= " ORDER BY shipper_id";
71         
72         return db_query($sql,"could not get shippers");
73 }
74
75 //--------------------------------------------------------------------------------------
76
77 function get_shipper($selected_id)
78 {
79         $sql = "SELECT * FROM ".TB_PREF."shippers WHERE shipper_id=".db_escape($selected_id);
80
81         $result = db_query($sql, "could not get shipper");
82         return db_fetch($result);
83 }
84