From 868868163c0b556deed6ef55f9d3c4e68141fbd0 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Tue, 8 Nov 2016 20:06:56 +0000 Subject: [PATCH] Replace Appconfig->get with config->item to reduce database calls --- application/controllers/Config.php | 2 +- application/controllers/Items.php | 6 ++-- application/libraries/Barcode_lib.php | 32 ++++++++++----------- application/views/configs/info_config.php | 2 +- application/views/partial/print_receipt.php | 14 ++++----- application/views/receivings/receipt.php | 4 +-- application/views/sales/invoice_email.php | 4 +-- application/views/sales/receipt_default.php | 16 +++++------ application/views/sales/receipt_email.php | 16 +++++------ application/views/sales/receipt_short.php | 16 +++++------ 10 files changed, 56 insertions(+), 56 deletions(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index e07189a0e..e7a2cf7ac 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -193,7 +193,7 @@ class Config extends Secure_Controller { $data['stock_locations'] = $this->Stock_location->get_all()->result_array(); $data['support_barcode'] = $this->barcode_lib->get_list_barcodes(); - $data['logo_exists'] = $this->Appconfig->get('company_logo') != ''; + $data['logo_exists'] = $this->config->item('company_logo') != ''; $data = $this->xss_clean($data); diff --git a/application/controllers/Items.php b/application/controllers/Items.php index e31954b32..96cf176ac 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -172,8 +172,8 @@ class Items extends Secure_Controller if($item_id == -1) { - $data['default_tax_1_rate'] = $this->Appconfig->get('default_tax_1_rate'); - $data['default_tax_2_rate'] = $this->Appconfig->get('default_tax_2_rate'); + $data['default_tax_1_rate'] = $this->config->item('default_tax_1_rate'); + $data['default_tax_2_rate'] = $this->config->item('default_tax_2_rate'); $item_info->receiving_quantity = 0; $item_info->reorder_level = 0; @@ -269,7 +269,7 @@ class Items extends Secure_Controller $item = $this->xss_clean($item); // update the UPC/EAN/ISBN field if empty / NULL with the newly generated barcode - if(empty($item['item_number']) && $this->Appconfig->get('barcode_generate_if_empty')) + if(empty($item['item_number']) && $this->config->item('barcode_generate_if_empty')) { // get the newly generated barcode $barcode_instance = Barcode_lib::barcode_instance($item, $config); diff --git a/application/libraries/Barcode_lib.php b/application/libraries/Barcode_lib.php index d41b5012a..14cec5473 100644 --- a/application/libraries/Barcode_lib.php +++ b/application/libraries/Barcode_lib.php @@ -24,28 +24,28 @@ class Barcode_lib public function get_barcode_config() { - $data['company'] = $this->CI->Appconfig->get('company'); - $data['barcode_content'] = $this->CI->Appconfig->get('barcode_content'); - $data['barcode_type'] = $this->CI->Appconfig->get('barcode_type'); - $data['barcode_font'] = $this->CI->Appconfig->get('barcode_font'); - $data['barcode_font_size'] = $this->CI->Appconfig->get('barcode_font_size'); - $data['barcode_height'] = $this->CI->Appconfig->get('barcode_height'); - $data['barcode_width'] = $this->CI->Appconfig->get('barcode_width'); - $data['barcode_quality'] = $this->CI->Appconfig->get('barcode_quality'); - $data['barcode_first_row'] = $this->CI->Appconfig->get('barcode_first_row'); - $data['barcode_second_row'] = $this->CI->Appconfig->get('barcode_second_row'); - $data['barcode_third_row'] = $this->CI->Appconfig->get('barcode_third_row'); - $data['barcode_num_in_row'] = $this->CI->Appconfig->get('barcode_num_in_row'); - $data['barcode_page_width'] = $this->CI->Appconfig->get('barcode_page_width'); - $data['barcode_page_cellspacing'] = $this->CI->Appconfig->get('barcode_page_cellspacing'); - $data['barcode_generate_if_empty'] = $this->CI->Appconfig->get('barcode_generate_if_empty'); + $data['company'] = $this->CI->config->item('company'); + $data['barcode_content'] = $this->CI->config->item('barcode_content'); + $data['barcode_type'] = $this->CI->config->item('barcode_type'); + $data['barcode_font'] = $this->CI->config->item('barcode_font'); + $data['barcode_font_size'] = $this->CI->config->item('barcode_font_size'); + $data['barcode_height'] = $this->CI->config->item('barcode_height'); + $data['barcode_width'] = $this->CI->config->item('barcode_width'); + $data['barcode_quality'] = $this->CI->config->item('barcode_quality'); + $data['barcode_first_row'] = $this->CI->config->item('barcode_first_row'); + $data['barcode_second_row'] = $this->CI->config->item('barcode_second_row'); + $data['barcode_third_row'] = $this->CI->config->item('barcode_third_row'); + $data['barcode_num_in_row'] = $this->CI->config->item('barcode_num_in_row'); + $data['barcode_page_width'] = $this->CI->config->item('barcode_page_width'); + $data['barcode_page_cellspacing'] = $this->CI->config->item('barcode_page_cellspacing'); + $data['barcode_generate_if_empty'] = $this->CI->config->item('barcode_generate_if_empty'); return $data; } public function validate_barcode($barcode) { - $barcode_type = $this->CI->Appconfig->get('barcode_type'); + $barcode_type = $this->CI->config->item('barcode_type'); $barcode_instance = $this->get_barcode_instance($barcode_type); return $barcode_instance->validate($barcode); } diff --git a/application/views/configs/info_config.php b/application/views/configs/info_config.php index 663f6af7b..010f14781 100644 --- a/application/views/configs/info_config.php +++ b/application/views/configs/info_config.php @@ -25,7 +25,7 @@
<?php echo $this->lang->line('config_company_logo'); ?>
diff --git a/application/views/partial/print_receipt.php b/application/views/partial/print_receipt.php index bd1e8ee73..01d17ad88 100644 --- a/application/views/partial/print_receipt.php +++ b/application/views/partial/print_receipt.php @@ -8,12 +8,12 @@ function printdoc() if (window.jsPrintSetup) { // set top margins in millimeters - jsPrintSetup.setOption('marginTop', 'Appconfig->get('print_top_margin'); ?>'); - jsPrintSetup.setOption('marginLeft', 'Appconfig->get('print_left_margin'); ?>'); - jsPrintSetup.setOption('marginBottom', 'Appconfig->get('print_bottom_margin'); ?>'); - jsPrintSetup.setOption('marginRight', 'Appconfig->get('print_right_margin'); ?>'); + jsPrintSetup.setOption('marginTop', 'config->item('print_top_margin'); ?>'); + jsPrintSetup.setOption('marginLeft', 'config->item('print_left_margin'); ?>'); + jsPrintSetup.setOption('marginBottom', 'config->item('print_bottom_margin'); ?>'); + jsPrintSetup.setOption('marginRight', 'config->item('print_right_margin'); ?>'); - Appconfig->get('print_header')) + config->item('print_header')) { ?> // set page header @@ -22,7 +22,7 @@ function printdoc() jsPrintSetup.setOption('headerStrRight', ''); Appconfig->get('print_footer')) + if (!$this->config->item('print_footer')) { ?> // set empty page footer @@ -44,7 +44,7 @@ function printdoc() // clears user preferences always silent print value // to enable using 'printSilent' option jsPrintSetup.clearSilentPrint(); - Appconfig->get('print_silently')) + config->item('print_silently')) { ?> // Suppress print dialog (for this context only) diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php index 8a5f601af..0c55c2850 100644 --- a/application/views/receivings/receipt.php +++ b/application/views/receivings/receipt.php @@ -18,7 +18,7 @@ if (isset($error_message))
Appconfig->get('company_logo') == '') + if ($this->config->item('company_logo') == '') { ?>
config->item('company'); ?>
@@ -27,7 +27,7 @@ if (isset($error_message)) else { ?> -
company_logo
+
company_logo
diff --git a/application/views/sales/invoice_email.php b/application/views/sales/invoice_email.php index 3524f1dc7..5b7f96042 100644 --- a/application/views/sales/invoice_email.php +++ b/application/views/sales/invoice_email.php @@ -19,10 +19,10 @@ if (isset($error_message)) - + Appconfig->get('receipt_show_description')) + if($this->config->item('receipt_show_description')) { ?> @@ -67,7 +67,7 @@ } ?> Appconfig->get('receipt_show_serialnumber')) + if($this->config->item('receipt_show_serialnumber')) { ?> @@ -91,7 +91,7 @@ ?> Appconfig->get('receipt_show_total_discount') && $discount > 0) + if ($this->config->item('receipt_show_total_discount') && $discount > 0) { ?> @@ -107,7 +107,7 @@ ?> Appconfig->get('receipt_show_taxes')) + if ($this->config->item('receipt_show_taxes')) { ?> @@ -132,7 +132,7 @@ - Appconfig->get('receipt_show_taxes') && !($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)); ?> + config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?> diff --git a/application/views/sales/receipt_email.php b/application/views/sales/receipt_email.php index 97cc4bc42..4fefd339c 100644 --- a/application/views/sales/receipt_email.php +++ b/application/views/sales/receipt_email.php @@ -1,10 +1,10 @@
Appconfig->get('company_logo') != '') + if ($this->config->item('company_logo') != '') { ?> -
company_logo
+
company_logo
@@ -50,11 +50,11 @@
- + Appconfig->get('receipt_show_description')) + if($this->config->item('receipt_show_description')) { ?> @@ -62,7 +62,7 @@ } ?> Appconfig->get('receipt_show_serialnumber')) + if($this->config->item('receipt_show_serialnumber')) { ?> @@ -86,7 +86,7 @@ ?> Appconfig->get('receipt_show_total_discount') && $discount > 0) + if ($this->config->item('receipt_show_total_discount') && $discount > 0) { ?> @@ -102,7 +102,7 @@ ?> Appconfig->get('receipt_show_taxes')) + if ($this->config->item('receipt_show_taxes')) { ?> @@ -127,7 +127,7 @@ - Appconfig->get('receipt_show_taxes') && !($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)); ?> + config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?> diff --git a/application/views/sales/receipt_short.php b/application/views/sales/receipt_short.php index 69640260d..4ceed9648 100644 --- a/application/views/sales/receipt_short.php +++ b/application/views/sales/receipt_short.php @@ -1,10 +1,10 @@
Appconfig->get('company_logo') != '') + if ($this->config->item('company_logo') != '') { ?> -
company_logo
+
company_logo
@@ -56,11 +56,11 @@
- + Appconfig->get('receipt_show_description')) + if($this->config->item('receipt_show_description')) { ?> @@ -68,7 +68,7 @@ } ?> Appconfig->get('receipt_show_serialnumber')) + if($this->config->item('receipt_show_serialnumber')) { ?> @@ -92,7 +92,7 @@ ?> Appconfig->get('receipt_show_total_discount') && $discount > 0) + if ($this->config->item('receipt_show_total_discount') && $discount > 0) { ?> @@ -108,7 +108,7 @@ ?> Appconfig->get('receipt_show_taxes')) + if ($this->config->item('receipt_show_taxes')) { ?> @@ -133,7 +133,7 @@ - Appconfig->get('receipt_show_taxes') && !($this->Appconfig->get('receipt_show_total_discount') && $discount > 0)); ?> + config->item('receipt_show_taxes') && !($this->config->item('receipt_show_total_discount') && $discount > 0)); ?>
Appconfig->get('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?>config->item('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?>
lang->line('sales_total'); ?> Appconfig->get('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?>config->item('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?>
lang->line('sales_total'); ?>
Appconfig->get('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?>config->item('receipt_show_total_discount') ? 'total' : 'discounted_total')]); ?>
lang->line('sales_total'); ?>