Changed license type to GPLv3 in top of 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 ('$stock_id', $sales_type_id, '$curr_abrev', $price)";
16         
17         db_query($sql,"an item price could not be added");              
18 }
19
20 function update_item_price($price_id, $sales_type_id, $curr_abrev, $price)
21 {
22         $sql = "UPDATE ".TB_PREF."prices SET sales_type_id=$sales_type_id, 
23                 curr_abrev='$curr_abrev', 
24                 price=$price 
25                 WHERE id=$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= $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='$stock_id' ORDER BY curr_abrev, sales_type_id";   
42         
43         return db_query($sql,"item prices could not be retreived");
44 }
45
46 function get_stock_price($price_id)
47 {
48         $sql = "SELECT * FROM ".TB_PREF."prices WHERE id=$price_id";    
49         
50         $result = db_query($sql,"price could not be retreived");
51         
52         return db_fetch($result);
53 }
54
55 ?>