Cleanup: removed all closing tags in php files.
[fa-stable.git] / inventory / includes / db / items_prices_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 function add_item_price($stock_id, $sales_type_id, $curr_abrev, $price)
13 {
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).")";
17         
18         db_query($sql,"an item price could not be added");              
19 }
20
21 function update_item_price($price_id, $sales_type_id, $curr_abrev, $price)
22 {
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);
26         
27         db_query($sql,"an item price could not be updated");            
28 }
29
30 function delete_item_price($price_id)
31 {
32         $sql="DELETE FROM ".TB_PREF."prices WHERE id= ".db_escape($price_id);
33         db_query($sql,"an item price could not be deleted");                    
34 }
35
36 function get_prices($stock_id)
37 {
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"; 
43         
44         return db_query($sql,"item prices could not be retreived");
45 }
46
47 function get_stock_price($price_id)
48 {
49         $sql = "SELECT * FROM ".TB_PREF."prices WHERE id=".db_escape($price_id);
50         
51         $result = db_query($sql,"price could not be retreived");
52         
53         return db_fetch($result);
54 }
55
56 function get_stock_price_type_currency($stock_id, $type, $currency)
57 {
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);
61         
62         $result = db_query($sql,"price could not be retreived");
63         
64         return db_fetch($result);
65 }