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) {
|
||||
url = '../../../../foodcourt/customer_view';
|
||||
url = '../../../../origami/customer_view';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
|
||||
@@ -479,7 +479,7 @@
|
||||
<% if current_user.role != "waiter" && @status == "sale"%>
|
||||
<hr>
|
||||
<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%>
|
||||
|
||||
<% if @status != "sale"%>
|
||||
@@ -606,47 +606,56 @@
|
||||
|
||||
if(dynamicQR) {
|
||||
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
||||
document.getElementById('fullpage-loading').style.display = 'flex';
|
||||
|
||||
setTimeout(function() {
|
||||
document.getElementById('fullpage-loading').style.display = 'none';
|
||||
}, 5000);
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const pending_id = urlParams.get('pending_id');
|
||||
|
||||
if (pending_id && pending_id.startsWith('SAL')) {
|
||||
window.location.href = `/foodcourt/${pending_id}/qrpay/precreate`;
|
||||
} else {
|
||||
initDynamicQrPay();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// function precreateDynamicQrPay() {
|
||||
// var sale_id = $("#sale_id").text() || 0;
|
||||
// window.location.href = `/foodcourt/${sale_id}/qrpay/precreate`;
|
||||
// }
|
||||
|
||||
|
||||
function initDynamicQrPay() {
|
||||
const paymentMethod = 'MMQR';
|
||||
const $serverMode = $('#server_mode');
|
||||
const $createOrderBtn = $('#create_order');
|
||||
const $createPayOrderBtn = $('#create_pay_order');
|
||||
const paymentMethod = 'MMQR';
|
||||
const $serverMode = $('#server_mode');
|
||||
const $createOrderBtn = $('#create_order');
|
||||
const $createPayOrderBtn = $('#create_pay_order');
|
||||
|
||||
$.ajax({
|
||||
url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
||||
method: 'GET',
|
||||
success: function(result) {
|
||||
console.log(result);
|
||||
if(! result.status) {
|
||||
alert('Something went wrong');
|
||||
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");
|
||||
$.ajax({
|
||||
url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
||||
method: 'GET',
|
||||
success: function(result) {
|
||||
console.log(result);
|
||||
if(! result.status) {
|
||||
alert('Something went wrong');
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user