From ffbdcad7de5c5e20d74eae9aeabb449058e66156 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Wed, 26 Aug 2020 11:38:36 +0630 Subject: [PATCH] prevent sale void double click --- app/views/origami/home/show.html.erb | 2 +- app/views/origami/sales/show.html.erb | 56 ++++++++++++++------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 7e92ac0d..64b7b674 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -1265,7 +1265,7 @@ closeOnConfirm: false }, function (isConfirm) { if (isConfirm) { - $('.confirm').prop("disabled",true); + $('.confirm').prop("disabled", true); var sale_id = $("#sale_id").val();//"<%= @obj_sale.sale_id rescue "" %>" var ajax_url = "/origami/sale/" + sale_id + '/cashier/void'; var remark = $("#remark").val(); diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index c7b72553..c78a58a6 100755 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -478,35 +478,37 @@ $('#back').on('click',function(){ // }); $(document).on('click', '.access_modal', function(event){ - type = $(this).data("type"); - $(".ok").attr("data-action",type); - $('#AccessCodeModal').modal('show'); - }); - $('#void').on('click', function () { + type = $(this).data("type"); + $(".ok").attr("data-action",type); + $('#AccessCodeModal').modal('show'); +}); + +$('#void').on('click', function () { var access_code = localStorage.getItem("access_code"); - swal({ - title: "Alert", - text: "Are you sure want to Void?", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "Yes, void it!", - closeOnConfirm: false - }, function (isConfirm) { - if (isConfirm) { - var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id +'/'+'cashier'+ '/void'; - $.ajax({ - type: 'POST', - url: ajax_url, - data: {'access_code':access_code}, - success: function () { - window.location.href = '/origami/sale/'+sale_id; - } - }); + swal({ + title: "Alert", + text: "Are you sure want to Void?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, void it!", + closeOnConfirm: false + }, function (isConfirm) { + if (isConfirm) { + $('.confirm').prop("disabled", true); + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id +'/'+'cashier'+ '/void'; + $.ajax({ + type: 'POST', + url: ajax_url, + data: {'access_code':access_code}, + success: function () { + window.location.href = '/origami/sale/'+sale_id; } - }); - }); + }); + } + }); +}); function check_emp_access_code(access_code,type) { var url = "/origami/check_emp_access_code/" + access_code ;