From c57d8ef536552821081f7c375d7cb359a0d9951a Mon Sep 17 00:00:00 2001 From: Erastus Date: Mon, 3 Sep 2018 00:51:34 -0500 Subject: [PATCH] discount in item_kits --- application/controllers/Item_kits.php | 9 ++-- application/controllers/Sales.php | 2 +- application/language/en-US/item_kits_lang.php | 4 ++ application/language/es/item_kits_lang.php | 4 ++ application/models/Item_kit.php | 4 +- application/views/item_kits/form.php | 47 +++++++++++-------- 6 files changed, 44 insertions(+), 26 deletions(-) diff --git a/application/controllers/Item_kits.php b/application/controllers/Item_kits.php index 31fdcf638..050689ae6 100644 --- a/application/controllers/Item_kits.php +++ b/application/controllers/Item_kits.php @@ -37,8 +37,9 @@ class Item_kits extends Secure_Controller } } - $discount_fraction = bcdiv($item_kit->kit_discount_percent, 100); - $item_kit->total_unit_price = $item_kit->total_unit_price - round(bcadd(bcmul($item_kit->total_unit_price, $discount_fraction),bcmul($item_kit->kit_discount_fixed,$total_quantity)), totals_decimals(), PHP_ROUND_HALF_UP); + $discount_fraction = bcdiv($item_kit->kit_discount, 100); + + $item_kit->total_unit_price = $item_kit->total_unit_price - round(($item_kit->kit_discount_type == PERCENT)?bcmul($item_kit->total_unit_price, $discount_fraction): $item_kit->kit_discount, totals_decimals(), PHP_ROUND_HALF_UP); return $item_kit; } @@ -131,8 +132,8 @@ class Item_kits extends Secure_Controller $item_kit_data = array( 'name' => $this->input->post('name'), 'item_id' => $this->input->post('kit_item_id'), - 'kit_discount_percent' => $this->input->post('kit_discount_percent'), - 'kit_discount_fixed' => $this->input->post('kit_discount_fixed'), + 'kit_discount' => $this->input->post('kit_discount'), + 'kit_discount_type' => $this->input->post('kit_discount_type') == NULL ? PERCENT : $this->input->post('kit_discount_type'), 'price_option' => $this->input->post('price_option'), 'print_option' => $this->input->post('print_option'), 'description' => $this->input->post('description') diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index dffb26d81..754e0861d 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -413,7 +413,7 @@ class Sales extends Secure_Controller if($item_kit_info->kit_discount != 0 && $item_kit_info->kit_discount > $discount) { $discount = $item_kit_info->kit_discount; - $discount_type = $item_kit_info->discount_type; + $discount_type = $item_kit_info->kit_discount_type; } $price = NULL; diff --git a/application/language/en-US/item_kits_lang.php b/application/language/en-US/item_kits_lang.php index ba6bae908..a6ef53155 100644 --- a/application/language/en-US/item_kits_lang.php +++ b/application/language/en-US/item_kits_lang.php @@ -30,3 +30,7 @@ $lang["item_kits_successful_adding"] = "You have successfully added Item Kit"; $lang["item_kits_successful_deleted"] = "You have successfully deleted"; $lang["item_kits_successful_updating"] = "You have successfully updated Item Kit"; $lang["item_kits_update"] = "Update Item Kit"; +$lang["item_kits_discount"] = "Discount"; +$lang["item_kits_discount_type"] = "Discount Type"; +$lang["item_kits_discount_fixed"] = "Fixed Discount"; +$lang["item_kits_discount_percent"] = "Percentage Discount"; diff --git a/application/language/es/item_kits_lang.php b/application/language/es/item_kits_lang.php index 9c7fa4b1f..fc2bb6a58 100644 --- a/application/language/es/item_kits_lang.php +++ b/application/language/es/item_kits_lang.php @@ -30,3 +30,7 @@ $lang["item_kits_successful_adding"] = "Has agregado satisfactoriamente un Kit d $lang["item_kits_successful_deleted"] = "Has borrado satisfactoriamente"; $lang["item_kits_successful_updating"] = "Has actualizado satisfactoriamente un Kit de Artículos"; $lang["item_kits_update"] = "Actualizar Kit de Artículos"; +$lang["item_kits_discount"] = "Descuento"; +$lang["item_kits_discount_type"] = "Tipo de Descuento"; +$lang["item_kits_discount_fixed"] = "Descuento Fijo"; +$lang["item_kits_discount_percent"] = "Descuento en Porcentaje"; diff --git a/application/models/Item_kit.php b/application/models/Item_kit.php index 96aca7b05..06c3ed9dc 100644 --- a/application/models/Item_kit.php +++ b/application/models/Item_kit.php @@ -58,8 +58,8 @@ class Item_kit extends CI_Model item_kits.description, items.description as item_description, item_kits.item_id as kit_item_id, - kit_discount_percent, - kit_discount_fixed, + kit_discount, + kit_discount_type, price_option, print_option, category, diff --git a/application/views/item_kits/form.php b/application/views/item_kits/form.php index 711c35350..bf7c80f3b 100644 --- a/application/views/item_kits/form.php +++ b/application/views/item_kits/form.php @@ -34,32 +34,41 @@
- lang->line('item_kits_discount_percent'), 'kit_discount_percent', array('class' => 'control-label col-xs-3')); ?> -
-
- 'kit_discount_percent', - 'size'=>'5', - 'maxlength'=>'5', - 'id'=>'kit_discount_percent', - 'class'=>'form-control input-sm', - 'value'=>$item_kit_info->kit_discount_percent) - );?> - % -
+ lang->line('item_kits_discount_type'), 'kit_discount_type', array('class'=>'control-label col-xs-3')); ?> +
+ +
- +
+ +
+ lang->line('item_kits_discount'), 'kit_discount', array('class' => 'control-label col-xs-3')); ?>
- config->item('currency_symbol'); ?> 'kit_discount_fixed', + 'name'=>'kit_discount', 'size'=>'5', 'maxlength'=>'5', - 'id'=>'kit_discount_fixed', + 'id'=>'kit_discount', 'class'=>'form-control input-sm', - 'value'=>$item_kit_info->kit_discount_fixed) - );?> + 'value'=>$item_kit_info->kit_discount) + );?>