fix layout
This commit is contained in:
@@ -195,10 +195,6 @@
|
|||||||
</tfooter>
|
</tfooter>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div> -->
|
|
||||||
<!-- <INPUT TYPE="Button" class='btn btn-primary' VALUE="Reprint" onClick="" style='width:120px'/>
|
|
||||||
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="foodcourt/index" style='width:120px'/> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -255,107 +251,106 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script defer type="text/javascript">
|
<script defer type="text/javascript">
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
$(document).ready(function() {
|
||||||
const paymentWaiting = document.querySelector('.payment-waiting');
|
const $paymentWaiting = $('.payment-waiting');
|
||||||
let amountToReceive = <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i) %>;
|
const amountToReceive = <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i) %>;
|
||||||
const receipt_no = document.querySelector('#receipt_no').textContent;
|
const $receiptNo = $('#receipt_no');
|
||||||
const ws = new WebSocket("wss://juicecorner-0mo.sx-fc.app/cable");
|
const ws = new WebSocket("wss://juicecorner-0mo.sx-fc.app/cable");
|
||||||
|
|
||||||
|
ws.onopen = function() {
|
||||||
|
console.log("Nagato channel connected");
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
command: "subscribe",
|
||||||
|
identifier: JSON.stringify({
|
||||||
|
channel: "TestChannel",
|
||||||
|
receipt_no: $receiptNo.text()
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onmessage = function(e) {
|
||||||
|
const msg = JSON.parse(e.data);
|
||||||
|
console.log("Received:", msg);
|
||||||
|
|
||||||
ws.onopen = () => {
|
if (msg.type === 'confirm_subscription') {
|
||||||
console.log("Nagato channel connected");
|
console.log("This world shall know pain");
|
||||||
|
}
|
||||||
|
|
||||||
ws.send(JSON.stringify({
|
if (msg?.message?.status === "PAY_SUCCESS") {
|
||||||
command: "subscribe",
|
$paymentWaiting.html(`
|
||||||
identifier: JSON.stringify({
|
<img src="/image/mmqr.webp" alt="MMQR Payment" style="max-width: 120px; margin-bottom: 10px;">
|
||||||
channel: "TestChannel",
|
<div class="payment-success text-center">
|
||||||
// receipt_no: receipt_no
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.onmessage = (e) => {
|
|
||||||
const msg = JSON.parse(e.data);
|
|
||||||
console.log("Received:", msg)
|
|
||||||
|
|
||||||
if(msg.type === 'confirm_subscription') {
|
|
||||||
console.log("This world shall know pain");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(msg?.message?.status === "PAY_SUCCESS") {
|
|
||||||
paymentWaiting.innerHTML = `
|
|
||||||
<img src="/image/mmqr.webp" alt="MMQR Payment" style="max-width: 120px; margin-bottom: 10px;">
|
|
||||||
<div class="payment-success text-center">
|
|
||||||
<i class="material-icons" style="font-size: 50px; color: #4CAF50;">check_circle</i>
|
<i class="material-icons" style="font-size: 50px; color: #4CAF50;">check_circle</i>
|
||||||
<h3 class="m-t-20" style="color: #4CAF50;">Payment Successful!</h3>
|
<h3 class="m-t-20" style="color: #4CAF50;">Payment Successful!</h3>
|
||||||
<p>Amount Received: ${amountToReceive}</p>
|
<p>Amount Received: ${amountToReceive}</p>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`);
|
||||||
|
|
||||||
fetch('/foodcourt/qrpay/process_payment', {
|
$.ajax({
|
||||||
method: 'POST',
|
url: '/foodcourt/qrpay/process_payment',
|
||||||
headers: {
|
method: 'POST',
|
||||||
'Content-Type': 'application/json',
|
contentType: 'application/json',
|
||||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content,
|
headers: {
|
||||||
},
|
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
|
||||||
body: JSON.stringify({ sale_id: "<%= @sale_data.sale_id %>" })
|
},
|
||||||
}).then((res) => res.json())
|
data: JSON.stringify({ sale_id: "<%= @sale_data.sale_id %>" }),
|
||||||
.then((data) => {
|
success: function(data) {
|
||||||
if(data.status) {
|
if (data.status) {
|
||||||
customer_display_view({msg: "Payment Successful", paid_amount: amountToReceive,receipt_no:receipt_no}, "pay_success");
|
customer_display_view({
|
||||||
setTimeout(() => {
|
msg: "Payment Successful",
|
||||||
window.location.href = "/";
|
paid_amount: amountToReceive,
|
||||||
}, 3000)
|
receipt_no: $receiptNo.text()
|
||||||
}else {
|
}, "pay_success");
|
||||||
console.log("error:", data);
|
|
||||||
}
|
|
||||||
}).catch((e) => console.log(e))
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.onerror = (e) => {
|
setTimeout(function() {
|
||||||
console.log(error)
|
window.location.href = "/";
|
||||||
}
|
}, 3000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.log("Error:", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onerror = function(e) {
|
||||||
|
console.error("WebSocket error:", e);
|
||||||
|
};
|
||||||
|
|
||||||
function customer_display_view(data, status) {
|
function customer_display_view(data, status) {
|
||||||
let url = '/foodcourt/customer_view';
|
$.post('/foodcourt/customer_view', {
|
||||||
|
data: data,
|
||||||
console.log(data);
|
status: status
|
||||||
|
}, function(result) {
|
||||||
$.ajax({
|
// Optional success handler
|
||||||
type: "POST",
|
}, 'json');
|
||||||
url: url,
|
|
||||||
data: { data: data, status: status },
|
|
||||||
dataType: "json",
|
|
||||||
success:function(result){
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cancel order
|
// Cancel order
|
||||||
document.querySelector('#cancel-btn').addEventListener('click', function(e) {
|
$('#cancel-btn').on('click', function(e) {
|
||||||
const data = {
|
const postData = {
|
||||||
sale_id: "<%= @sale_data.sale_id %>",
|
sale_id: "<%= @sale_data.sale_id %>"
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch('/foodcourt/qrpay/cancel', {
|
$.ajax({
|
||||||
method: 'POST',
|
url: '/foodcourt/qrpay/cancel',
|
||||||
headers: {
|
method: 'POST',
|
||||||
'Content-Type': 'application/json',
|
contentType: 'application/json',
|
||||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content,
|
headers: {
|
||||||
},
|
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
|
||||||
body: JSON.stringify(data)
|
},
|
||||||
}).then(function(res) {
|
data: JSON.stringify(postData),
|
||||||
customer_display_view(null,"reload");
|
success: function(data) {
|
||||||
return res.json();
|
if (data.status) {
|
||||||
}).then(function(data) {
|
customer_display_view(null, "reload");
|
||||||
if(data.status) {
|
window.location.href = "/";
|
||||||
|
}
|
||||||
window.location.href = "/";
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.log("Error:", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
<p class="text-muted">Use your mobile wallet app</p>
|
<p class="text-muted">Use your mobile wallet app</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="qr-payment-container" class="mx-auto text-center p-3 bg-white rounded border" style="max-width: 400px;">
|
<div id="qr-payment-container" class="mx-auto text-center p-3 bg-white rounded border" style="max-width: 300px;">
|
||||||
<!-- Added mx-auto to center this block within its col-6 parent -->
|
<!-- Added mx-auto to center this block within its col-6 parent -->
|
||||||
<div id="qr-code" class="mb-2">
|
<div id="qr-code" class="mb-2">
|
||||||
<div id="qrpay_svg">
|
<div id="qrpay_svg">
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
.then(result => {
|
.then(result => {
|
||||||
booking_id = result.booking_id;
|
booking_id = result.booking_id;
|
||||||
console.log(result);
|
console.log(result);
|
||||||
window.location.href = `/foodcourt/${result.sale_id}/qrpay/dynamic_init`;
|
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
||||||
|
|
||||||
if (document.getElementById("server_mode").value !== "cloud" && second_display_lookup === 2) {
|
if (document.getElementById("server_mode").value !== "cloud" && second_display_lookup === 2) {
|
||||||
// customer_display_view(null, "reload");
|
// customer_display_view(null, "reload");
|
||||||
|
|||||||
Reference in New Issue
Block a user