X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fitems_cart.inc;h=25101807d61c6b26b04448e5ce2a7b3b1e871edc;hb=50606312fee0bb0dbe984e2c08af53b7dab229bd;hp=8afd898103fb39ad8d3bae8c0b1df1974987d6fc;hpb=a4db318fa0c84e099e0970ca82e36215782d661e;p=fa-stable.git diff --git a/includes/ui/items_cart.inc b/includes/ui/items_cart.inc index 8afd8981..25101807 100644 --- a/includes/ui/items_cart.inc +++ b/includes/ui/items_cart.inc @@ -1,13 +1,13 @@ . + See the License here . ***********************************************************************/ include_once($path_to_root . "/includes/prefs/sysprefs.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); @@ -18,21 +18,18 @@ 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; var $transfer_type; var $increase; var $memo_; - var $person_id; var $branch_id; - + var $reference; + var $original_amount; + function items_cart($type) { $this->trans_type = $type; @@ -53,7 +50,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; @@ -97,43 +94,51 @@ class items_cart // ----------- GL item functions - function add_gl_item($code_id, $dimension_id, $dimension2_id, $amount, $reference, $description=null) + function add_gl_item($code_id, $dimension_id, $dimension2_id, $amount, $reference, $description=null, $person_id=null) { 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, $person_id); return true; } else { // shouldn't come here under normal circumstances - display_db_error("unexpected - invalid parameters in add_gl_item($code_id, $dimension_id, $dimension2_id, $amount,...)", "", 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, $person_id=null) { - $this->gl_items[$index]->index = $index; + $this->gl_items[$index]->code_id = $code_id; + $this->gl_items[$index]->person_id = $person_id; + + $gl_type = is_subledger_account($code_id, $person_id); + if ($gl_type) + { + $this->gl_items[$index]->person_type_id = $gl_type > 0 ? PT_CUSTOMER : PT_SUPPLIER; + $this->gl_items[$index]->person_name = get_subaccount_name($code_id, $person_id); + } else + { + $this->gl_items[$index]->person_type_id = $this->gl_items[$index]->person_name = ''; + } $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() @@ -180,9 +185,20 @@ class items_cart unset($this->gl_items); $this->gl_items = array(); - $this->gl_item_count = 1; } + // + // Check if cart contains virtual subaccount (AP/AR) postings + // + function has_sub_accounts() + { + foreach ($this->gl_items as $gl_item) + { + if ($gl_item->person_id) + return true; + } + return false; + } } //-------------------------------------------------------------------------------------------- @@ -203,7 +219,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"]; @@ -226,7 +242,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)) { @@ -254,16 +272,18 @@ class line_item class gl_item { - var $index; var $code_id; var $dimension_id; var $dimension2_id; var $amount; var $reference; var $description; + var $person_id; + var $person_type_id; + var $person_name; - function gl_item($index, $code_id, $dimension_id, $dimension2_id, $amount, $reference, - $description=null) + function gl_item($code_id, $dimension_id, $dimension2_id, $amount, $reference, + $description=null, $person_id=null) { //echo "adding $index, $code_id, $dimension_id, $amount, $reference
"; @@ -272,8 +292,14 @@ class gl_item else $this->description = $description; - $this->index = $index; $this->code_id = $code_id; + $this->person_id = $person_id; + $gl_type = is_subledger_account($code_id, $person_id); + if ($gl_type) + { + $this->person_type_id = $gl_type > 0 ? PT_CUSTOMER : PT_SUPPLIER; + $this->person_name = get_subaccount_name($code_id, $person_id); + } $this->dimension_id = $dimension_id; $this->dimension2_id = $dimension2_id; $this->amount = $amount;