From e23982c07856cce32ef7ccf88548f3f5b0d9a3e5 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 23 May 2018 17:31:11 +0630 Subject: [PATCH] First Bill Click Alert --- app/views/origami/home/show.html.erb | 49 +++++++++++++++++----------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index e1b88f85..5f24494f 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -759,30 +759,41 @@ return false; }); }); + // Print for first bill $("#first_bill").on('click', function () { - var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; - var server_mode = - $.ajax({ - type: "GET", - url: ajax_url, - success: function (result) { - receipt_no = ($("#receipt_no").html()).trim(); - if((receipt_no!=undefined) && (receipt_no!="")) - createReceiptNoInFirstBillData(receipt_no,""); + swal({ + title: "Alert", + text: "Are you sure want to print First Bill?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, print it!", + closeOnConfirm: false + }, function (isConfirm) { + if (isConfirm) { + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + var server_mode = - // For Server Print - from jade - if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); - } - - // console.log(result); - // code2lab.printBill(result.filepath, result.printer_model, result.printer_url); - location.reload(); + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no,""); + + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + location.reload(); } - }); + }); + } + }); }); // click select option icon for add