show card balance when insufficient error occurred
This commit is contained in:
@@ -30,6 +30,11 @@ function member_card(cardNo) {
|
||||
success: function(data) {
|
||||
if (data[0].customer_id == false) {
|
||||
swal("Alert!", data[0].message, "error");
|
||||
if ($("#order-items-table tr").length > 1){
|
||||
$("#create_pay_order").prop("disabled", false);
|
||||
$("#create_order").prop("disabled", false);
|
||||
}
|
||||
$("#oqs_loading_wrapper").hide();
|
||||
}else{
|
||||
g_customer_id = data[0].customer_id;
|
||||
g_customer_name = data[0].name;
|
||||
@@ -115,40 +120,22 @@ function update_sale(membership_id, customer_id, customer_name, sale_id) {
|
||||
if(customer_name != ""){
|
||||
customer = '(' + customer_name + ')';
|
||||
}
|
||||
|
||||
swal({
|
||||
title: "Confirmation !",
|
||||
text: 'Are you sure to assign this customer' + customer + '!',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "green",
|
||||
confirmButtonText: "Yes!",
|
||||
cancelButtonClass: 'btn btn-danger customer_assign_cancel',
|
||||
closeOnConfirm: true,
|
||||
}, function (inputValue) {
|
||||
if (inputValue===false) {
|
||||
if ($("#order-items-table tr").length > 1){
|
||||
$("#create_pay_order").prop("disabled", false);
|
||||
$("#create_order").prop("disabled", false);
|
||||
$("#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/';
|
||||
}
|
||||
} 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/';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ class Foodcourt::CustomersController < BaseFoodcourtController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||
end
|
||||
@out = membership_data
|
||||
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]})
|
||||
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"], :balance => membership_data["balance"]})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -375,6 +375,12 @@ class Customer < ApplicationRecord
|
||||
rescue SocketError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
case response.code
|
||||
when 404
|
||||
response = {"status" => false, "message" => "Not Found "}
|
||||
when 500...600
|
||||
response = {"status" => false, "message" => response.message}
|
||||
end
|
||||
Rails.logger.debug "--------Search Paypar Account No response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
return response
|
||||
|
||||
@@ -738,6 +738,7 @@ $(document).ready(function(){
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.status == true) {
|
||||
var customer_card_balance= data.balance;
|
||||
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
|
||||
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
|
||||
$.ajax({
|
||||
@@ -788,6 +789,7 @@ $(document).ready(function(){
|
||||
allowOutsideClick: false
|
||||
},
|
||||
function (isConfirm) {
|
||||
$("#loading_wrapper").show();
|
||||
$('.confirm').attr("disabled","disabled");
|
||||
window.location.href = "<%= foodcourt_food_court_path %>";
|
||||
});
|
||||
@@ -800,9 +802,10 @@ $(document).ready(function(){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
} else {
|
||||
var insufficient_message = result.message + '<br> Card balance : ' + customer_card_balance
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: result.message,
|
||||
text: insufficient_message,
|
||||
type: 'warning',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
@@ -827,6 +830,7 @@ $(document).ready(function(){
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
|
||||
});
|
||||
$("#loading_wrapper").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -842,6 +846,7 @@ $(document).ready(function(){
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
|
||||
});
|
||||
$("#loading_wrapper").hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,35 +944,25 @@ $(document).ready(function(){
|
||||
if(customer_name != ""){
|
||||
customer = '(' + customer_name + ')';
|
||||
}
|
||||
$("#loading_wrapper").show();
|
||||
|
||||
swal({
|
||||
title: "Confirmation !",
|
||||
text: 'Are you sure to assign this customer' + customer + '!',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "green",
|
||||
confirmButtonText: "Yes!",
|
||||
cancelButtonClass: 'btn btn-danger',
|
||||
closeOnConfirm: true,
|
||||
}, function () {
|
||||
$("#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{
|
||||
swal("Alert!", "Record not found!", "error");
|
||||
location.reload();
|
||||
}
|
||||
$.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{
|
||||
swal("Alert!", "Record not found!", "error");
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user