*** empty log message ***
[fa-stable.git] / inventory / includes / db / items_prices_db.inc
1 <?php
2
3 function add_item_price($stock_id, $sales_type_id, $curr_abrev, $price)
4 {
5         $sql = "INSERT INTO ".TB_PREF."prices (stock_id, sales_type_id, curr_abrev, price) 
6                 VALUES ('$stock_id', $sales_type_id, '$curr_abrev', $price)";
7         
8         db_query($sql,"an item price could not be added");              
9 }
10
11 function update_item_price($price_id, $sales_type_id, $curr_abrev, $price)
12 {
13         $sql = "UPDATE ".TB_PREF."prices SET sales_type_id=$sales_type_id, 
14                 curr_abrev='$curr_abrev', 
15                 price=$price 
16                 WHERE id=$price_id";
17         
18         db_query($sql,"an item price could not be updated");            
19 }
20
21 function delete_item_price($price_id)
22 {
23         $sql="DELETE FROM ".TB_PREF."prices WHERE id= $price_id";
24         db_query($sql,"an item price could not be deleted");                    
25 }
26
27 function get_prices($stock_id)
28 {
29         $sql = "SELECT ".TB_PREF."sales_types.sales_type, ".TB_PREF."prices.* 
30                 FROM ".TB_PREF."prices, ".TB_PREF."sales_types 
31                 WHERE ".TB_PREF."prices.sales_type_id = ".TB_PREF."sales_types.id 
32                 AND stock_id='$stock_id' ORDER BY curr_abrev, sales_type_id";   
33         
34         return db_query($sql,"item prices could not be retreived");
35 }
36
37 function get_stock_price($price_id)
38 {
39         $sql = "SELECT * FROM ".TB_PREF."prices WHERE id=$price_id";    
40         
41         $result = db_query($sql,"price could not be retreived");
42         
43         return db_fetch($result);
44 }
45
46 ?>