diff --git a/app/views/foodcourt/addorders/detail.html.erb b/app/views/foodcourt/addorders/detail.html.erb index 63ead71d..b8f5ef16 100644 --- a/app/views/foodcourt/addorders/detail.html.erb +++ b/app/views/foodcourt/addorders/detail.html.erb @@ -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, diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 8a126b9a..a9d5ba25 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -479,7 +479,7 @@ <% if current_user.role != "waiter" && @status == "sale"%>
- + <%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');