Autoreturn to Sale page after receipt printing (#1966)

This commit is contained in:
FrancescoUK
2018-05-01 20:46:18 +01:00
parent 455e39260d
commit 9d149ad4f3
8 changed files with 83 additions and 39 deletions

View File

@@ -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,

View File

@@ -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";

View File

@@ -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";

View File

@@ -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');

View File

@@ -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'))); ?>
<span class="input-group-addon input-sm">px</span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_print_delay_autoreturn'), 'print_delay_autoreturn', array('class' => 'control-label col-xs-2 required')); ?>
<div class='col-xs-2'>
<div class="input-group">
<?php echo form_input(array(
'type' => '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'))); ?>
<span class="input-group-addon input-sm">s</span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_email_receipt_check_behaviour'), 'email_receipt_check_behaviour', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-8'>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
</div>
</div>
@@ -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'))); ?>
<span class="input-group-addon input-sm">px</span>
</div>
</div>
@@ -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'))); ?>
<span class="input-group-addon input-sm">px</span>
</div>
</div>
@@ -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'))); ?>
<span class="input-group-addon input-sm">px</span>
</div>
</div>
@@ -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'))); ?>
<span class="input-group-addon input-sm">px</span>
</div>
</div>
@@ -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:"<?php echo $this->lang->line('config_receipt_font_size_required'); ?>",
number:"<?php echo $this->lang->line('config_receipt_font_size_number'); ?>"
},
print_delay_autoreturn:
{
required:"<?php echo $this->lang->line('config_print_delay_autoreturn_required'); ?>",
number:"<?php echo $this->lang->line('config_print_delay_autoreturn_number'); ?>"
}
}
}));

View File

@@ -62,16 +62,21 @@ function printdoc()
}
}
<?php
<?php
if($print_after_sale)
{
?>
$(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 = "<?php echo site_url('sales'); ?>";
}, <?php echo $this->config->item('print_delay_autoreturn') * 1000; ?>);
});
<?php
}
?>
</script>
</script>

View File

@@ -9,34 +9,33 @@ if (isset($error_message))
?>
<?php if(!empty($customer_email)): ?>
<script type="text/javascript">
$(document).ready(function()
{
var send_email = function()
<script type="text/javascript">
$(document).ready(function()
{
$.get('<?php echo site_url() . "/sales/send_receipt/" . $sale_id_num; ?>',
function(response)
{
$.notify(response.message, { type: response.success ? 'success' : 'danger'} );
}, 'json'
);
};
var send_email = function()
{
$.get('<?php echo site_url() . "/sales/send_receipt/" . $sale_id_num; ?>',
function(response)
{
$.notify(response.message, { type: response.success ? 'success' : 'danger'} );
}, 'json'
);
};
$("#show_email_button").click(send_email);
$("#show_email_button").click(send_email);
<?php if(!empty($email_receipt)): ?>
send_email();
<?php endif; ?>
});
</script>
<?php if(!empty($email_receipt)): ?>
send_email();
<?php endif; ?>
});
</script>
<?php endif; ?>
<?php $this->load->view('partial/print_receipt', array('print_after_sale'=>$print_after_sale, 'selected_printer'=>'receipt_printer')); ?>
<div class="print_hide" id="control_buttons" style="text-align:right">
<a href="javascript:printdoc();"><div class="btn btn-info btn-sm", id="show_print_button"><?php echo '<span class="glyphicon glyphicon-print">&nbsp</span>' . $this->lang->line('common_print'); ?></div></a>
<?php /* this line will allow to print and go back to sales automatically.... echo anchor("sales", '<span class="glyphicon glyphicon-print">&nbsp</span>' . $this->lang->line('common_print'), array('class'=>'btn btn-info btn-sm', 'id'=>'show_print_button', 'onclick'=>'window.print();')); */ ?>
<?php if(isset($customer_email) && !empty($customer_email)): ?>
<?php if(!empty($customer_email)): ?>
<a href="javascript:void(0);"><div class="btn btn-info btn-sm", id="show_email_button"><?php echo '<span class="glyphicon glyphicon-envelope">&nbsp</span>' . $this->lang->line('sales_send_receipt'); ?></div></a>
<?php endif; ?>
<?php echo anchor("sales", '<span class="glyphicon glyphicon-shopping-cart">&nbsp</span>' . $this->lang->line('sales_register'), array('class'=>'btn btn-info btn-sm', 'id'=>'show_sales_button')); ?>
@@ -45,4 +44,4 @@ $(document).ready(function()
<?php $this->load->view("sales/" . $this->config->item('receipt_template')); ?>
<?php $this->load->view("partial/footer"); ?>
<?php $this->load->view("partial/footer"); ?>