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 ('$stock_id', $sales_type_id, '$curr_abrev', $price)";
17 db_query($sql,"an item price could not be added");
20 function update_item_price($price_id, $sales_type_id, $curr_abrev, $price)
22 $sql = "UPDATE ".TB_PREF."prices SET sales_type_id=$sales_type_id,
23 curr_abrev='$curr_abrev',
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= $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='$stock_id' ORDER BY curr_abrev, sales_type_id";
43 return db_query($sql,"item prices could not be retreived");
46 function get_stock_price($price_id)
48 $sql = "SELECT * FROM ".TB_PREF."prices WHERE id=$price_id";
50 $result = db_query($sql,"price could not be retreived");
52 return db_fetch($result);