diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 03a2e708..02638ca6 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1085,6 +1085,8 @@ $(function() { // Create Order $("#create_order").on('click', function(e){ + $(this).prop("disabled", true); + $("#create_pay_order").prop("disabled", true); e.preventDefault(); name_list = '' count = 0; @@ -1113,17 +1115,17 @@ $(function() { }, function (isConfirm) { if (isConfirm) { create_order($(this)) + }else{ + $("#create_order").prop("disabled", false); + $("#create_pay_order").prop("disabled", false); } }); - - } else { create_order($(this)) } }); function create_order(data) { - data.attr('disabled', 'disabled'); $("#oqs_loading_wrapper").show(); var cashier_type = $("#link_type").val(); localStorage.setItem('cashier_type',cashier_type); @@ -1165,38 +1167,46 @@ $(function() { url: ajax_url, data: params, dataType: "json", - success:function(result){ - if (type == "quick_service" || type=="food_court") { - module_name = window.location.href.includes('foodcourt') ? 'foodcourt' : 'origami' - window.location.href = "/"+module_name+"/"+type; - }else{ - if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id; - } - else { - window.location.href = "/origami/room/" + table_id; - } + success: function(result){ + if (type == "quick_service" || type=="food_court") { + module_name = window.location.href.includes('foodcourt') ? 'foodcourt' : 'origami' + window.location.href = "/"+module_name+"/"+type; + }else{ + if(table_type == "Table"){ + window.location.href = "/origami/table/" + table_id; } - if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){ - customer_display_view(null,"reload"); + else { + window.location.href = "/origami/room/" + table_id; } - } + } + if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){ + customer_display_view(null,"reload"); + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + $("#oqs_loading_wrapper").hide(); + $("#create_order").prop("disabled", false); + $("#create_pay_order").prop("disabled", false); + swal("Error", "Status: " + textStatus, "error"); + } }); } // Pay Discount for Payment $("#create_pay_order").on('click', function(e){ + $(this).prop("disabled", true); + $("#create_order").prop("disabled", true); $("#sxModal").show(); $("#sxModal").attr('data-for', 'member'); - $(this).attr('disabled', 'disabled'); e.preventDefault(); getCardNo(); }); $("#sxModal .btn_cancel").on('click',function(){ - if($("#order-items-table tr").length > 1){ - $( "#create_pay_order" ).prop( "disabled", false ); + if ($("#order-items-table tr").length > 1){ + $("#create_pay_order").prop("disabled", false); + $("#create_order").prop("disabled", false); } $("#sxModal").hide(); }); diff --git a/app/assets/javascripts/foodcourt/addorder.js b/app/assets/javascripts/foodcourt/addorder.js index 4fa66ab0..448c5fc7 100644 --- a/app/assets/javascripts/foodcourt/addorder.js +++ b/app/assets/javascripts/foodcourt/addorder.js @@ -124,24 +124,31 @@ function update_sale(membership_id, customer_id, customer_name, sale_id) { confirmButtonText: "Yes!", cancelButtonClass: 'btn btn-danger customer_assign_cancel', closeOnConfirm: true, - }, function () { - $("#oqs_loading_wrapper").show(); - $.ajax({ - type: "POST", - url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" , - data: {customer_id:customer_id,sale_id:sale_id}, - dataType: "json", - success: function(data) { - if(data.status == true) - { - //change customer detail - $("#customer_name").html(customer_name); - $("#membership_id").html(membership_id); - window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/'; - }else{ - window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/'; - } + }, function (inputValue) { + if (inputValue===false) { + if ($("#order-items-table tr").length > 1){ + $("#create_pay_order").prop("disabled", false); + $("#create_order").prop("disabled", false); } - }); + } else { + $("#oqs_loading_wrapper").show(); + $.ajax({ + type: "POST", + url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" , + data: {customer_id:customer_id,sale_id:sale_id}, + dataType: "json", + success: function(data) { + if(data.status == true) + { + //change customer detail + $("#customer_name").html(customer_name); + $("#membership_id").html(membership_id); + window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/'; + }else{ + window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/'; + } + } + }); + } }); } diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 882de5c3..65d53d15 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -260,12 +260,15 @@ class Foodcourt::OrdersController < BaseFoodcourtController sale_id = booking.sale_id end end + + respond_to do |format| + format.json { render :json => { :status => @status, :sale_id => sale_id } } + end else - @status = false - @error_message = "No Current Open Shift for This Employee" - end - if ["quick_service", "food_court"].include? order.source - render :json => { :status => true, :sale_id => sale_data.sale_id } + respond_to do |format| + format.json { + render :json => { :status => false, :error_message => "No Current Open Shift for This Employee" } } + end end # end