From 9d149ad4f393c0b08a884479e1ece3f97aa6332f Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Tue, 1 May 2018 20:46:18 +0100 Subject: [PATCH] Autoreturn to Sale page after receipt printing (#1966) --- application/controllers/Config.php | 1 + application/language/en-GB/config_lang.php | 3 ++ application/language/en-US/config_lang.php | 3 ++ ...hp => 20180501100000_upgrade_to_3_2_1.php} | 0 .../migrations/sqlscripts/3.2.0_to_3.2.1.sql | 6 +++ application/views/configs/receipt_config.php | 53 ++++++++++++++----- application/views/partial/print_receipt.php | 17 +++--- application/views/sales/receipt.php | 39 +++++++------- 8 files changed, 83 insertions(+), 39 deletions(-) rename application/migrations/{20180429100000_upgrade_to_3_2_1.php => 20180501100000_upgrade_to_3_2_1.php} (100%) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index d7beefee9..a16458559 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -813,6 +813,7 @@ class Config extends Secure_Controller $batch_save_data = array ( 'receipt_template' => $this->input->post('receipt_template'), 'receipt_font_size' => $this->input->post('receipt_font_size'), + 'print_delay_autoreturn' => $this->input->post('print_delay_autoreturn'), 'email_receipt_check_behaviour' => $this->input->post('email_receipt_check_behaviour'), 'print_receipt_check_behaviour' => $this->input->post('print_receipt_check_behaviour'), 'receipt_show_company_name' => $this->input->post('receipt_show_company_name') != NULL, diff --git a/application/language/en-GB/config_lang.php b/application/language/en-GB/config_lang.php index 044bfdb08..81f73742b 100644 --- a/application/language/en-GB/config_lang.php +++ b/application/language/en-GB/config_lang.php @@ -194,6 +194,9 @@ $lang["config_phone_required"] = "Company phone is a required field"; $lang["config_print_bottom_margin"] = "Margin Bottom"; $lang["config_print_bottom_margin_number"] = "Default Bottom Margin must be a number"; $lang["config_print_bottom_margin_required"] = "Default Bottom Margin is a required field"; +$lang["config_print_delay_autoreturn"] = "Autoreturn to Sale delay"; +$lang["config_print_delay_autoreturn_required"] = "Autoreturn to Sale delay must be a number"; +$lang["config_print_delay_autoreturn_number"] = "Autoreturn to Sale delay is a required field"; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_left_margin"] = "Margin Left"; diff --git a/application/language/en-US/config_lang.php b/application/language/en-US/config_lang.php index 1ba77a526..7b39c5ae8 100644 --- a/application/language/en-US/config_lang.php +++ b/application/language/en-US/config_lang.php @@ -194,6 +194,9 @@ $lang["config_phone_required"] = "Company Phone is a required field."; $lang["config_print_bottom_margin"] = "Margin Bottom"; $lang["config_print_bottom_margin_number"] = "Margin Bottom must be a number."; $lang["config_print_bottom_margin_required"] = "Margin Bottom is a required field."; +$lang["config_print_delay_autoreturn"] = "Autoreturn to Sale delay"; +$lang["config_print_delay_autoreturn_required"] = "Autoreturn to Sale delay must be a number."; +$lang["config_print_delay_autoreturn_number"] = "Autoreturn to Sale delay is a required field."; $lang["config_print_footer"] = "Print Browser Footer"; $lang["config_print_header"] = "Print Browser Header"; $lang["config_print_left_margin"] = "Margin Left"; diff --git a/application/migrations/20180429100000_upgrade_to_3_2_1.php b/application/migrations/20180501100000_upgrade_to_3_2_1.php similarity index 100% rename from application/migrations/20180429100000_upgrade_to_3_2_1.php rename to application/migrations/20180501100000_upgrade_to_3_2_1.php diff --git a/application/migrations/sqlscripts/3.2.0_to_3.2.1.sql b/application/migrations/sqlscripts/3.2.0_to_3.2.1.sql index ac92db486..0baf01230 100644 --- a/application/migrations/sqlscripts/3.2.0_to_3.2.1.sql +++ b/application/migrations/sqlscripts/3.2.0_to_3.2.1.sql @@ -13,3 +13,9 @@ ALTER TABLE `ospos_customers` INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('enforce_privacy', '0'); + + +-- Add print receipt autoreturn delay + +INSERT INTO `ospos_app_config` (`key`, `value`) VALUES +('print_delay_autoreturn', '0'); diff --git a/application/views/configs/receipt_config.php b/application/views/configs/receipt_config.php index d7e665ebe..8c7bad56c 100644 --- a/application/views/configs/receipt_config.php +++ b/application/views/configs/receipt_config.php @@ -27,12 +27,29 @@ 'name' => 'receipt_font_size', 'id' => 'receipt_font_size', 'class' => 'form-control input-sm required', - 'value'=>$this->config->item('receipt_font_size'))); ?> + 'value' => $this->config->item('receipt_font_size'))); ?> px +
+ lang->line('config_print_delay_autoreturn'), 'print_delay_autoreturn', array('class' => 'control-label col-xs-2 required')); ?> +
+
+ 'number', + 'min' => '0', + 'max' => '30', + 'name' => 'print_delay_autoreturn', + 'id' => 'print_delay_autoreturn', + 'class' => 'form-control input-sm required', + 'value' => $this->config->item('print_delay_autoreturn'))); ?> + s +
+
+
+
lang->line('config_email_receipt_check_behaviour'), 'email_receipt_check_behaviour', array('class' => 'control-label col-xs-2')); ?>
@@ -94,7 +111,7 @@ 'name' => 'receipt_show_company_name', 'value' => 'receipt_show_company_name', 'id' => 'receipt_show_company_name', - 'checked'=>$this->config->item('receipt_show_company_name'))); ?> + 'checked' => $this->config->item('receipt_show_company_name'))); ?>
@@ -105,7 +122,7 @@ 'name' => 'receipt_show_taxes', 'value' => 'receipt_show_taxes', 'id' => 'receipt_show_taxes', - 'checked'=>$this->config->item('receipt_show_taxes'))); ?> + 'checked' => $this->config->item('receipt_show_taxes'))); ?> @@ -116,7 +133,7 @@ 'name' => 'receipt_show_total_discount', 'value' => 'receipt_show_total_discount', 'id' => 'receipt_show_total_discount', - 'checked'=>$this->config->item('receipt_show_total_discount'))); ?> + 'checked' => $this->config->item('receipt_show_total_discount'))); ?> @@ -127,7 +144,7 @@ 'name' => 'receipt_show_description', 'value' => 'receipt_show_description', 'id' => 'receipt_show_description', - 'checked'=>$this->config->item('receipt_show_description'))); ?> + 'checked' => $this->config->item('receipt_show_description'))); ?> @@ -138,7 +155,7 @@ 'name' => 'receipt_show_serialnumber', 'value' => 'receipt_show_serialnumber', 'id' => 'receipt_show_serialnumber', - 'checked'=>$this->config->item('receipt_show_serialnumber'))); ?> + 'checked' => $this->config->item('receipt_show_serialnumber'))); ?> @@ -149,7 +166,7 @@ 'name' => 'print_silently', 'id' => 'print_silently', 'value' => 'print_silently', - 'checked'=>$this->config->item('print_silently'))); ?> + 'checked' => $this->config->item('print_silently'))); ?> @@ -160,7 +177,7 @@ 'name' => 'print_header', 'id' => 'print_header', 'value' => 'print_header', - 'checked'=>$this->config->item('print_header'))); ?> + 'checked' => $this->config->item('print_header'))); ?> @@ -171,7 +188,7 @@ 'name' => 'print_footer', 'id' => 'print_footer', 'value' => 'print_footer', - 'checked'=>$this->config->item('print_footer'))); ?> + 'checked' => $this->config->item('print_footer'))); ?> @@ -207,7 +224,7 @@ 'name' => 'print_top_margin', 'id' => 'print_top_margin', 'class' => 'form-control input-sm required', - 'value'=>$this->config->item('print_top_margin'))); ?> + 'value' => $this->config->item('print_top_margin'))); ?> px @@ -224,7 +241,7 @@ 'name' => 'print_left_margin', 'id' => 'print_left_margin', 'class' => 'form-control input-sm required', - 'value'=>$this->config->item('print_left_margin'))); ?> + 'value' => $this->config->item('print_left_margin'))); ?> px @@ -241,7 +258,7 @@ 'name' => 'print_bottom_margin', 'id' => 'print_bottom_margin', 'class' => 'form-control input-sm required', - 'value'=>$this->config->item('print_bottom_margin'))); ?> + 'value' => $this->config->item('print_bottom_margin'))); ?> px @@ -258,7 +275,7 @@ 'name' => 'print_right_margin', 'id' => 'print_right_margin', 'class' => 'form-control input-sm required', - 'value'=>$this->config->item('print_right_margin'))); ?> + 'value' => $this->config->item('print_right_margin'))); ?> px @@ -343,6 +360,11 @@ $(document).ready(function() number:true }, receipt_font_size: + { + required:true, + number:true + }, + print_delay_autoreturn: { required:true, number:true @@ -375,6 +397,11 @@ $(document).ready(function() { required:"lang->line('config_receipt_font_size_required'); ?>", number:"lang->line('config_receipt_font_size_number'); ?>" + }, + print_delay_autoreturn: + { + required:"lang->line('config_print_delay_autoreturn_required'); ?>", + number:"lang->line('config_print_delay_autoreturn_number'); ?>" } } })); diff --git a/application/views/partial/print_receipt.php b/application/views/partial/print_receipt.php index 8f064976d..5ffe3ef3e 100644 --- a/application/views/partial/print_receipt.php +++ b/application/views/partial/print_receipt.php @@ -62,16 +62,21 @@ function printdoc() } } - - $(window).load(function() + $(window).load(function() { - // executes when complete page is fully loaded, including all frames, objects and images - printdoc(); - }); + // executes when complete page is fully loaded, including all frames, objects and images + printdoc(); + + // after a delay, return to sales view + setTimeout(function () { + window.location.href = ""; + }, config->item('print_delay_autoreturn') * 1000; ?>); + }); - \ No newline at end of file + diff --git a/application/views/sales/receipt.php b/application/views/sales/receipt.php index 72e6e0436..870f735f8 100644 --- a/application/views/sales/receipt.php +++ b/application/views/sales/receipt.php @@ -9,34 +9,33 @@ if (isset($error_message)) ?> - + + send_email(); + + }); + load->view('partial/print_receipt', array('print_after_sale'=>$print_after_sale, 'selected_printer'=>'receipt_printer')); ?>