update receipt pdf view

This commit is contained in:
Aung Myo
2018-06-01 10:24:53 +06:30
parent 8e9e286965
commit bc9ac00cfe
3 changed files with 60 additions and 59 deletions

View File

@@ -185,6 +185,10 @@ For MoveTablePdf in print settings
3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal }
/* Tax Profile Group Types in lookups */
/*Receipt Pdf View in lookups */
1) settings/lookups => { type:ReceiptPdfView, name: Receipt Pdf View, value:1 or 0 }
=> 1 is active and 0 is in-active
Add Kitchen Role of Employee
=> 1) settings/lookups => { type:employee_roles, name: Kitchen, value:kitchen }

View File

@@ -242,7 +242,11 @@ class Origami::PaymentsController < BaseOrigamiController
@table_no = ''
@dining = ''
@other_payment = 0.0
@pdf_view = nil
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
end
@shop = Shop.first #show shop info
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")

View File

@@ -622,6 +622,8 @@
var cashier_type = "<%= @cashier_type %>";
var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>";
var pdf_view = '<%=@pdf_view%>';
console.log(pdf_view)
$(document).ready(function(){
setHeaderBreadCrumb(_PAYMENTS_);
//start customer modal popup
@@ -765,8 +767,8 @@ var customer_name = "<%= @customer.name %>";
calculate_member_discount(sale_id,tax_type);
}
$("#pdfModal").on('shown.bs.modal', function () {
$('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
// $("#pdfModal").on('shown.bs.modal', function () {
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
@@ -794,8 +796,6 @@ var customer_name = "<%= @customer.name %>";
$("#filename").val(result.filename);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", pdfPath);
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Sale Completed");
$("#changed_amount").text("");
if($('#balance').text() < 0){
<% if precision.to_i > 0 %>
@@ -804,40 +804,14 @@ var customer_name = "<%= @customer.name %>";
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
<% end %>
}
//PDF lightbox data
// if($('#balance').text() < 0){
// swal({
// title: "Payment Successful!",
// text: 'Changed amount ' + $('#balance').text() * (-1),
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function () {
// if (cashier_type=="cashier") {
// window.location.href = '/origami';
// }else{
// window.location.href = '/origami/quick_service';
// }
// });
// }else{
// $('#pay').text("Pay");
// swal({
// title: "Payment Successful!",
// text: 'Thank You !',
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function () {
// if (cashier_type=="cashier") {
// window.location.href = '/origami';
// }else{
// window.location.href = '/origami/quick_service';
// }
// });
// }
if (pdf_view == 1) {
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Sale Completed");
}else{
//PDF lightbox data
print_receipt();
}
}
});
}
@@ -1075,22 +1049,16 @@ var customer_name = "<%= @customer.name %>";
//print pdf function
// $(".print_receipt").on('click',function(){
$(document).on('touchstart click', '.print_receipt', function(event){
print_receipt();
});
function print_receipt() {
var sale_id = $('#sale_id').text();
var filename = $("#filename").val();
var printer_name = $("#printer_name").val();
var receipt_no = $("#sale_receipt_no").val();
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
// swal({
// title: "Alert",
// text: "Are you sure want to print?",
// type: "warning",
// showCancelButton: true,
// confirmButtonColor: "#DD6B55",
// confirmButtonText: "Print",
// closeOnConfirm: false
// }, function (isConfirm) {
// if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
@@ -1100,18 +1068,43 @@ var customer_name = "<%= @customer.name %>";
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
}
if (pdf_view ==1) {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
}
}else{
var title = "Payment Successful!";
if($('#balance').text() < 0){
var text = 'Changed amount ' + $('#balance').text() * (-1);
}else{
$('#pay').text("Pay");
var text = 'Thank You !';
}
swal({
title: "Payment Successful!",
text: text,
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
}
});
}
}
});
// }
// });
});
}
$(".btn_pdf_close").on('click',function(){