From a99f326bb8bc311c53ef8440fdf31dd509500b34 Mon Sep 17 00:00:00 2001 From: Steve Ireland Date: Tue, 31 Jan 2017 09:03:36 -0500 Subject: [PATCH] Generate low inventory message if at least one of the item kit items added to a sale are below the reorder level. --- application/controllers/Sales.php | 9 ++++++++- application/libraries/Sale_lib.php | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index f221bc802..ec05d0af5 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -310,11 +310,18 @@ class Sales extends Secure_Controller } } + + // Add item kit items to order - if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $price_option, $kit_print_option)) + $stock_warning = null; + if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $price_option, $kit_print_option, $stock_warning)) { $data['error'] = $this->lang->line('sales_unable_to_add_item'); } + elseif ($stock_warning != null) + { + $data['warning'] = $stock_warning; + } } else diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index 8710c06b0..21545008f 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -498,7 +498,7 @@ class Sale_lib $this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id); } - public function add_item_kit($external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option) + public function add_item_kit($external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option, &$stock_warning) { //KIT # @@ -542,6 +542,10 @@ class Sale_lib } $result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, $price, null, null, null, $print_option); + + if ($stock_warning == null) { + $stock_warning = $this->out_of_stock($item_kit_item['item_id'], $item_location); + } } return $result;