Fixing price formatting of left to allocate
[fa-stable.git] / sales / includes / cart_class.inc
index 991139121954c66d6be78e232dc34bf40a840e08..ce885a3285e12ce72f53a91f4670d322353cc9b2 100644 (file)
@@ -17,7 +17,7 @@ class cart
        var $trans_type; // invoice, order, delivery note ...
        var $trans_no = array();// array (num1=>ver1,..) or 0 for new
        var $so_type = 0;               // for sales order: simple=0 template=1
-
+       var $cart_id;           // used to detect multi-tab edition conflits
        var $line_items;  //array of objects of class line_details
 
        var $src_docs = array();        // array of arrays(num1=>ver1,...) or 0 for no src
@@ -61,6 +61,8 @@ class cart
        var $cash_account;
        var $account_name;
        var $cash_discount;     // not used as of FA 2.1
+       var $dimension_id;
+       var $dimension2_id;
        //-------------------------------------------------------------------------
        //
        //  $trans_no==0 => open new/direct document
@@ -72,7 +74,10 @@ class cart
                $this->line_items = array();
                $this->sales_type = "";
                $this->trans_type = 30;
+               $this->dimension_id = 0;
+               $this->dimension2_id = 0;
                $this->read($type, $trans_no, $view );
+               $this->cart_id = uniqid('');
        }
 
        //-------------------------------------------------------------------------
@@ -141,6 +146,27 @@ class cart
                                if (!is_date_in_fiscalyear($this->document_date))
                                        $this->document_date = end_fiscalyear();
                                $this->reference = references::get_next($this->trans_type);
+                               if ($type != 30) // Added 2.1 Joe Hunt 2008-11-12
+                               {
+                                       $dim = get_company_pref('use_dimension');
+                                       if ($dim > 0)
+                                       {
+                                               if ($this->customer_id == '')
+                                                       $this->dimension_id = 0;
+                                               else
+                                               {
+                                                       $cust = get_customer($this->customer_id);
+                                                       $this->dimension_id = $cust['dimension_id'];
+                                               }       
+                                               if ($dim > 1)
+                                               {
+                                                       if ($this->customer_id == '')
+                                                               $this->dimension2_id = 0;
+                                                       else
+                                                               $this->dimension2_id = $cust['dimension2_id'];
+                                               }               
+                                       }               
+                               }       
                                if ($type == 10) {
                                  $this->due_date =
                                        get_invoice_duedate($this->customer_id, $this->document_date);
@@ -154,7 +180,7 @@ class cart
                                if ($this->cash) {
                                        $this->Location = $pos['pos_location'];
                                        $this->location_name = $pos['location_name'];
-                                       $this->cash_account = $pos['account_code'];
+                                       $this->cash_account = $pos['pos_account'];
                                        $this->account_name = $pos['bank_account_name'];
                                }
                                } else
@@ -281,7 +307,7 @@ class cart
 
        function remove_from_cart($line_no)
        {
-               unset($this->line_items[$line_no]);
+               array_splice($this->line_items, $line_no, 1);
        }
 
        function clear_items()