*** empty log message ***
[fa-stable.git] / purchasing / includes / purchasing_db.inc
1 <?php
2
3 include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
4
5 include_once($path_to_root . "/includes/banking.inc");
6
7 include_once($path_to_root . "/includes/date_functions.inc");
8
9 include_once($path_to_root . "/includes/db/inventory_db.inc");
10
11 include_once($path_to_root . "/purchasing/includes/db/supp_trans_db.inc");
12 include_once($path_to_root . "/purchasing/includes/db/po_db.inc");
13 include_once($path_to_root . "/purchasing/includes/db/grn_db.inc");
14 include_once($path_to_root . "/purchasing/includes/db/invoice_db.inc");
15 include_once($path_to_root . "/purchasing/includes/db/suppalloc_db.inc");
16 include_once($path_to_root . "/purchasing/includes/db/supp_payment_db.inc");
17 include_once($path_to_root . "/purchasing/includes/db/suppliers_db.inc");
18
19 //-------------------------------------------------------------------------------------------------------------
20
21 // add a supplier-related gl transaction
22 // $date_ is display date (non-sql)
23 // $amount is in SUPPLIERS'S currency
24
25 function add_gl_trans_supplier($type, $type_no, $date_, $account, $dimension, $dimension2,  
26         $amount, $supplier_id, $err_msg="")
27 {
28         if ($err_msg == "")
29                 $err_msg = "The supplier GL transaction could not be inserted"; 
30                 
31         return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, "", 
32                 $amount, get_supplier_currency($supplier_id), 
33                 payment_person_types::supplier(), $supplier_id, $err_msg);
34 }
35
36 //----------------------------------------------------------------------------------------
37
38 function get_purchase_price($supplier_id, $stock_id)
39 {
40         $sql = "SELECT price, conversion_factor FROM ".TB_PREF."purch_data 
41                 WHERE supplier_id = '" . $supplier_id . "' 
42                 AND stock_id = '". $stock_id . "'";
43         $result = db_query($sql, "The supplier pricing details for " . $stock_id . " could not be retrieved");    
44
45         if (db_num_rows($result) == 1)
46         {
47                 $myrow = db_fetch($result);
48                 return $myrow["price"] / $myrow['conversion_factor'];
49         } 
50         else 
51         {
52                 return 0;
53         }       
54 }
55
56 //----------------------------------------------------------------------------------------
57
58
59 ?>