add order button disable enable

This commit is contained in:
yarzar_code
2020-08-10 17:35:48 +06:30
parent 0c4a2e1761
commit d6f6e51e6f
3 changed files with 63 additions and 43 deletions

View File

@@ -1085,6 +1085,8 @@ $(function() {
// Create Order // Create Order
$("#create_order").on('click', function(e){ $("#create_order").on('click', function(e){
$(this).prop("disabled", true);
$("#create_pay_order").prop("disabled", true);
e.preventDefault(); e.preventDefault();
name_list = '' name_list = ''
count = 0; count = 0;
@@ -1113,17 +1115,17 @@ $(function() {
}, function (isConfirm) { }, function (isConfirm) {
if (isConfirm) { if (isConfirm) {
create_order($(this)) create_order($(this))
}else{
$("#create_order").prop("disabled", false);
$("#create_pay_order").prop("disabled", false);
} }
}); });
} else { } else {
create_order($(this)) create_order($(this))
} }
}); });
function create_order(data) { function create_order(data) {
data.attr('disabled', 'disabled');
$("#oqs_loading_wrapper").show(); $("#oqs_loading_wrapper").show();
var cashier_type = $("#link_type").val(); var cashier_type = $("#link_type").val();
localStorage.setItem('cashier_type',cashier_type); localStorage.setItem('cashier_type',cashier_type);
@@ -1165,38 +1167,46 @@ $(function() {
url: ajax_url, url: ajax_url,
data: params, data: params,
dataType: "json", dataType: "json",
success:function(result){ success: function(result){
if (type == "quick_service" || type=="food_court") { if (type == "quick_service" || type=="food_court") {
module_name = window.location.href.includes('foodcourt') ? 'foodcourt' : 'origami' module_name = window.location.href.includes('foodcourt') ? 'foodcourt' : 'origami'
window.location.href = "/"+module_name+"/"+type; window.location.href = "/"+module_name+"/"+type;
}else{ }else{
if(table_type == "Table"){ if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id; window.location.href = "/origami/table/" + table_id;
}
else {
window.location.href = "/origami/room/" + table_id;
}
} }
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){ else {
customer_display_view(null,"reload"); 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 // Pay Discount for Payment
$("#create_pay_order").on('click', function(e){ $("#create_pay_order").on('click', function(e){
$(this).prop("disabled", true);
$("#create_order").prop("disabled", true);
$("#sxModal").show(); $("#sxModal").show();
$("#sxModal").attr('data-for', 'member'); $("#sxModal").attr('data-for', 'member');
$(this).attr('disabled', 'disabled');
e.preventDefault(); e.preventDefault();
getCardNo(); getCardNo();
}); });
$("#sxModal .btn_cancel").on('click',function(){ $("#sxModal .btn_cancel").on('click',function(){
if($("#order-items-table tr").length > 1){ if ($("#order-items-table tr").length > 1){
$( "#create_pay_order" ).prop( "disabled", false ); $("#create_pay_order").prop("disabled", false);
$("#create_order").prop("disabled", false);
} }
$("#sxModal").hide(); $("#sxModal").hide();
}); });

View File

@@ -124,24 +124,31 @@ function update_sale(membership_id, customer_id, customer_name, sale_id) {
confirmButtonText: "Yes!", confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger customer_assign_cancel', cancelButtonClass: 'btn btn-danger customer_assign_cancel',
closeOnConfirm: true, closeOnConfirm: true,
}, function () { }, function (inputValue) {
$("#oqs_loading_wrapper").show(); if (inputValue===false) {
$.ajax({ if ($("#order-items-table tr").length > 1){
type: "POST", $("#create_pay_order").prop("disabled", false);
url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" , $("#create_order").prop("disabled", false);
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/';
}
} }
}); } 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/';
}
}
});
}
}); });
} }

View File

@@ -260,12 +260,15 @@ class Foodcourt::OrdersController < BaseFoodcourtController
sale_id = booking.sale_id sale_id = booking.sale_id
end end
end end
respond_to do |format|
format.json { render :json => { :status => @status, :sale_id => sale_id } }
end
else else
@status = false respond_to do |format|
@error_message = "No Current Open Shift for This Employee" format.json {
end render :json => { :status => false, :error_message => "No Current Open Shift for This Employee" } }
if ["quick_service", "food_court"].include? order.source end
render :json => { :status => true, :sale_id => sale_data.sale_id }
end end
# #
end end