Fixed CSRF warning after retrying password change.
[fa-stable.git] / includes / ui / items_cart.inc
index a526852af00021dffd601b979dd8e82b22062307..a5e15fdbf4a524d1c7ded60d06f48ed4b6a75372 100644 (file)
@@ -1,5 +1,14 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 include_once($path_to_root . "/includes/prefs/sysprefs.inc");
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
@@ -9,12 +18,8 @@ class items_cart
        var $line_items;
        var $gl_items;
 
-       var $gl_item_count;
-
        var     $order_id;
 
-       var $editing_item, $deleting_item;
-
        var $from_loc;
        var $to_loc;
        var $tran_date;
@@ -23,7 +28,9 @@ class items_cart
        var $memo_;
        var $person_id;
        var $branch_id;
-
+       var $reference;
+       var $original_amount;
+       
        function items_cart($type)
        {
                $this->trans_type = $type;
@@ -44,7 +51,7 @@ class items_cart
                else
                {
                        // shouldn't come here under normal circumstances
-                       display_db_error("unexpected - adding an invalid item or null quantity", "", true);
+                       display_error("unexpected - adding an invalid item or null quantity", "", true);
                }
 
                return false;
@@ -93,38 +100,35 @@ class items_cart
                if (isset($code_id) && $code_id != "" && isset($amount) && isset($dimension_id)  &&
                        isset($dimension2_id))
                {
-                       $this->gl_items[$this->gl_item_count] = new gl_item($this->gl_item_count,
-                               $code_id, $dimension_id, $dimension2_id, $amount, $reference, $description);
-                       $this->gl_item_count++;
+                       $this->gl_items[] = new gl_item($code_id, $dimension_id, $dimension2_id, $amount, $reference, $description);
                        return true;
                }
                else
                {
                        // shouldn't come here under normal circumstances
-                       display_db_error("unexpected - adding an invalid item or null quantity", "", true);
+                       display_error("unexpected - invalid parameters in add_gl_item($code_id, $dimension_id, $dimension2_id, $amount,...)", "", true);
                }
 
                return false;
        }
 
-       function update_gl_item($index, $dimension_id, $dimension2_id, $amount, $reference, $description=null)
+       function update_gl_item($index, $code_id, $dimension_id, $dimension2_id, $amount, $reference, $description=null)
        {
-               $this->gl_items[$index]->index = $index;
+           $this->gl_items[$index]->code_id = $code_id;
                $this->gl_items[$index]->dimension_id = $dimension_id;
                $this->gl_items[$index]->dimension2_id = $dimension2_id;
                $this->gl_items[$index]->amount = $amount;
                $this->gl_items[$index]->reference = $reference;
-               if ($description != null)
+               if ($description == null)
+                       $this->gl_items[$index]->description = get_gl_account_name($code_id);
+               else
                        $this->gl_items[$index]->description = $description;
 
        }
 
        function remove_gl_item($index)
        {
-               if (isset($index))
-               {
-                       array_splice($this->gl_items, $line_no, 1);
-               }
+               array_splice($this->gl_items, $index, 1);
        }
 
        function count_gl_items()
@@ -171,7 +175,6 @@ class items_cart
 
        unset($this->gl_items);
                $this->gl_items = array();
-               $this->gl_item_count = 1;
 
        }
 }
@@ -194,7 +197,7 @@ class line_item
                $item_row = get_item($stock_id);
 
                if ($item_row == null)
-                       display_db_error("invalid item added to order : $stock_id", "");
+                       display_error("invalid item added to order : $stock_id", "");
 
                $this->mb_flag = $item_row["mb_flag"];
                $this->units = $item_row["units"];
@@ -217,7 +220,9 @@ class line_item
 
        function check_qoh($location, $date_, $reverse)
        {
-       if (!sys_prefs::allow_negative_stock())
+               global $SysPrefs;
+               
+       if (!$SysPrefs->allow_negative_stock())
        {
                        if (has_stock_holding($this->mb_flag))
                        {
@@ -245,7 +250,6 @@ class line_item
 class gl_item
 {
 
-       var $index;
        var $code_id;
        var $dimension_id;
        var $dimension2_id;
@@ -253,7 +257,7 @@ class gl_item
        var $reference;
        var $description;
 
-       function gl_item($index, $code_id, $dimension_id, $dimension2_id, $amount, $reference,
+       function gl_item($code_id, $dimension_id, $dimension2_id, $amount, $reference,
                $description=null)
        {
                //echo "adding $index, $code_id, $dimension_id, $amount, $reference<br>";
@@ -263,7 +267,6 @@ class gl_item
                else
                        $this->description = $description;
 
-               $this->index = $index;
                $this->code_id = $code_id;
                $this->dimension_id = $dimension_id;
                $this->dimension2_id = $dimension2_id;