fix: add qr flow in add order
This commit is contained in:
@@ -743,7 +743,7 @@ $(document).on('click', '#clear_all', function(event){
|
|||||||
});
|
});
|
||||||
|
|
||||||
function customer_display_view(data,status) {
|
function customer_display_view(data,status) {
|
||||||
url = '../../../../foodcourt/customer_view';
|
url = '../../../../origami/customer_view';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
|
|||||||
@@ -479,7 +479,7 @@
|
|||||||
<% if current_user.role != "waiter" && @status == "sale"%>
|
<% if current_user.role != "waiter" && @status == "sale"%>
|
||||||
<hr>
|
<hr>
|
||||||
<button type="button" id="void" class="btn btn-block bg-red waves-effect" >VOID</button>
|
<button type="button" id="void" class="btn btn-block bg-red waves-effect" >VOID</button>
|
||||||
<button type="button" id="pay" class="btn bg-blue btn-block" data-toggle="modal" data-target="#read_modal">Pay</button>
|
<button type="button" id="pay" class="btn bg-blue btn-block" data-toggle="modal" data-target="#payment_modal">Pay</button>
|
||||||
<%end%>
|
<%end%>
|
||||||
|
|
||||||
<% if @status != "sale"%>
|
<% if @status != "sale"%>
|
||||||
@@ -606,47 +606,56 @@
|
|||||||
|
|
||||||
if(dynamicQR) {
|
if(dynamicQR) {
|
||||||
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
||||||
document.getElementById('fullpage-loading').style.display = 'flex';
|
|
||||||
|
|
||||||
setTimeout(function() {
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
document.getElementById('fullpage-loading').style.display = 'none';
|
const pending_id = urlParams.get('pending_id');
|
||||||
}, 5000);
|
|
||||||
|
if (pending_id && pending_id.startsWith('SAL')) {
|
||||||
|
window.location.href = `/foodcourt/${pending_id}/qrpay/precreate`;
|
||||||
|
} else {
|
||||||
initDynamicQrPay();
|
initDynamicQrPay();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function precreateDynamicQrPay() {
|
||||||
|
// var sale_id = $("#sale_id").text() || 0;
|
||||||
|
// window.location.href = `/foodcourt/${sale_id}/qrpay/precreate`;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
function initDynamicQrPay() {
|
function initDynamicQrPay() {
|
||||||
const paymentMethod = 'MMQR';
|
const paymentMethod = 'MMQR';
|
||||||
const $serverMode = $('#server_mode');
|
const $serverMode = $('#server_mode');
|
||||||
const $createOrderBtn = $('#create_order');
|
const $createOrderBtn = $('#create_order');
|
||||||
const $createPayOrderBtn = $('#create_pay_order');
|
const $createPayOrderBtn = $('#create_pay_order');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
if(! result.status) {
|
if(! result.status) {
|
||||||
alert('Something went wrong');
|
alert('Something went wrong');
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
|
||||||
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
|
||||||
// customer_display_view(null, "reload");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr) {
|
|
||||||
$('#oqs_loading_wrapper').hide();
|
|
||||||
$createOrderBtn.prop('disabled', false);
|
|
||||||
$createPayOrderBtn.prop('disabled', false);
|
|
||||||
|
|
||||||
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
|
||||||
swal("Error", errorMsg, "error");
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
window.location.href = `/foodcourt/${result.sale_id}/qrpay/precreate`;
|
||||||
|
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
||||||
|
// customer_display_view(null, "reload");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
$('#oqs_loading_wrapper').hide();
|
||||||
|
$createOrderBtn.prop('disabled', false);
|
||||||
|
$createPayOrderBtn.prop('disabled', false);
|
||||||
|
|
||||||
|
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
||||||
|
swal("Error", errorMsg, "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// const cancelButton = document.querySelector('.btn-cancel');
|
// const cancelButton = document.querySelector('.btn-cancel');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user