6eca60deab2d3c71dc38459940d0d38e20c3452e
[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         $sql = "INSERT INTO ".TB_PREF."shippers (shipper_name, contact, phone, phone2, address)
18                 VALUES (" . db_escape($shipper_name) . ", " .
19                 db_escape($contact). ", " .
20                 db_escape($phone). ", " .
21                 db_escape($phone2). ", " .
22                 db_escape($address) . ")";
23
24         db_query($sql,"The Shipping Company could not be added");
25 }
26
27 //--------------------------------------------------------------------------------------
28
29 function update_shipper($selected_id, $shipper_name, $contact, $phone, $phone2, $address)
30 {
31         $sql = "UPDATE ".TB_PREF."shippers SET shipper_name=" . db_escape($shipper_name). " ,
32                 contact =" . db_escape($contact). " ,
33                 phone =" . db_escape($phone). " ,
34                 phone2 =" . db_escape($phone2). " ,
35                 address =" . db_escape($address). "
36                 WHERE shipper_id = ".db_escape($selected_id);
37
38         db_query($sql,"The shipping company could not be updated");
39 }
40
41 //--------------------------------------------------------------------------------------
42
43 function delete_shipper($selected_id)
44 {
45         $sql="DELETE FROM ".TB_PREF."shippers WHERE shipper_id=".db_escape($selected_id);
46         
47         db_query($sql,"could not delete shipper");
48 }
49
50 //--------------------------------------------------------------------------------------
51
52 function get_shippers($show_inactive)
53 {
54         $sql = "SELECT * FROM ".TB_PREF."shippers";
55         if (!$show_inactive) $sql .= " WHERE !inactive";
56         $sql .= " ORDER BY shipper_id";
57         
58         return db_query($sql,"could not get shippers");
59 }
60
61 //--------------------------------------------------------------------------------------
62
63 function get_shipper($selected_id)
64 {
65         $sql = "SELECT * FROM ".TB_PREF."shippers WHERE shipper_id=".db_escape($selected_id);
66
67         $result = db_query($sql, "could not get shipper");
68         return db_fetch($result);
69 }
70