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_item_price($stock_id, $sales_type_id, $curr_abrev, $price)
14 $sql = "INSERT INTO ".TB_PREF."prices (stock_id, sales_type_id, curr_abrev, price)
15 VALUES (".db_escape($stock_id).", ".db_escape($sales_type_id)
16 .", ".db_escape($curr_abrev).", ".db_escape($price).")";
18 db_query($sql,"an item price could not be added");
21 function update_item_price($price_id, $sales_type_id, $curr_abrev, $price)
23 $sql = "UPDATE ".TB_PREF."prices SET sales_type_id=".db_escape($sales_type_id).",
24 curr_abrev=".db_escape($curr_abrev).",
25 price=".db_escape($price)." WHERE id=".db_escape($price_id);
27 db_query($sql,"an item price could not be updated");
30 function delete_item_price($price_id)
32 $sql="DELETE FROM ".TB_PREF."prices WHERE id= ".db_escape($price_id);
33 db_query($sql,"an item price could not be deleted");
36 function get_prices($stock_id)
38 $sql = "SELECT ".TB_PREF."sales_types.sales_type, ".TB_PREF."prices.*
39 FROM ".TB_PREF."prices, ".TB_PREF."sales_types
40 WHERE ".TB_PREF."prices.sales_type_id = ".TB_PREF."sales_types.id
41 AND stock_id=".db_escape($stock_id)
42 ." ORDER BY curr_abrev, sales_type_id";
44 return db_query($sql,"item prices could not be retreived");
47 function get_stock_price($price_id)
49 $sql = "SELECT * FROM ".TB_PREF."prices WHERE id=".db_escape($price_id);
51 $result = db_query($sql,"price could not be retreived");
53 return db_fetch($result);
56 function get_stock_price_type_currency($stock_id, $type, $currency)
58 $sql = "SELECT * FROM ".TB_PREF."prices WHERE stock_id=".db_escape($stock_id)."
59 AND sales_type_id=".db_escape($type)."
60 AND curr_abrev=".db_escape($currency);
62 $result = db_query($sql,"price could not be retreived");
64 return db_fetch($result);