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 ***********************************************************************/
13 //--------------------------------------------------------------------------------------
15 function add_shipper($shipper_name, $contact, $phone, $phone2, $address)
17 begin_transaction(__FUNCTION__, func_get_args());
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) . ")";
26 db_query($sql,"The Shipping Company could not be added");
27 $result = db_insert_id();
33 //--------------------------------------------------------------------------------------
35 function update_shipper($selected_id, $shipper_name, $contact, $phone, $phone2, $address)
37 begin_transaction(__FUNCTION__, func_get_args());
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);
46 db_query($sql,"The shipping company could not be updated");
51 //--------------------------------------------------------------------------------------
53 function delete_shipper($selected_id)
55 begin_transaction(__FUNCTION__, func_get_args());
57 $sql="DELETE FROM ".TB_PREF."shippers WHERE shipper_id=".db_escape($selected_id);
59 db_query($sql,"could not delete shipper");
64 //--------------------------------------------------------------------------------------
66 function get_shippers($show_inactive)
68 $sql = "SELECT * FROM ".TB_PREF."shippers";
69 if (!$show_inactive) $sql .= " WHERE !inactive";
70 $sql .= " ORDER BY shipper_id";
72 return db_query($sql,"could not get shippers");
75 //--------------------------------------------------------------------------------------
77 function get_shipper($selected_id)
79 $sql = "SELECT * FROM ".TB_PREF."shippers WHERE shipper_id=".db_escape($selected_id);
81 $result = db_query($sql, "could not get shipper");
82 return db_fetch($result);