Added dimension entries in delivery and invoice forms
[fa-stable.git] / sales / includes / sales_db.inc
index 5c9d1142a9b79d475957f4769036236b7a4ab4f4..f653c24a6b038ebf995601f50e7884d8a3575208 100644 (file)
@@ -7,6 +7,7 @@ include_once($path_to_root . "/sales/includes/db/sales_credit_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_invoice_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_delivery_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
+include_once($path_to_root . "/sales/includes/db/sales_points_db.inc");
 include_once($path_to_root . "/sales/includes/db/custalloc_db.inc");
 include_once($path_to_root . "/sales/includes/db/cust_trans_db.inc");
 include_once($path_to_root . "/sales/includes/db/cust_trans_details_db.inc");
@@ -52,9 +53,9 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu
        if ($date == null)
            $date = Today();
 
-       if ($factor == null) 
+       if ($factor === null) 
        {
-               $myrow = get_sales_type(get_post('sales_type_id'));
+               $myrow = get_sales_type($sales_type_id);
                $factor = $myrow['factor'];
        }
            
@@ -125,7 +126,7 @@ function set_document_parent($cart)
        if (count($cart->src_docs) == 1) {
 
        // if this child document has only one parent - update child link
-       $del_no = key($cart->src_docs);
+       $del_no = reset(array_keys($cart->src_docs));
 
        $sql = 'UPDATE '.TB_PREF.'debtor_trans SET trans_link = ' . $del_no .
                ' WHERE type='.$cart->trans_type.' AND trans_no='. $inv_no ;
@@ -169,7 +170,7 @@ function update_parent_line($doc_type, $line_id, $qty_dispatched)
 {
        $doc_type = get_parent_type($doc_type);
 
-       //echo "update line: $line_id, $doc_type, $qty_dispatch";
+//     echo "update line: $line_id, $doc_type, $qty_dispatched";
        if ($doc_type==0)
                return false;
        else {
@@ -239,7 +240,8 @@ function read_sales_trans($doc_type, $trans_no, &$cart)
                $cart->trans_link = $myrow["trans_link"];
                $cart->due_date = sql2date($myrow["due_date"]);
                $cart->document_date = sql2date($myrow["tran_date"]);
-
+               $cart->dimension_id = $myrow['dimension_id']; // added 2.1 Joe Hunt 2008-11-12
+               $cart->dimension2_id = $myrow['dimension2_id'];
                $cart->Comments = '';
                foreach ( $trans_no as $trans ) {
                        $coms =  get_comments($doc_type,$trans);