fix read modal and header
This commit is contained in:
@@ -331,35 +331,24 @@
|
|||||||
// Check Internet Connection status
|
// Check Internet Connection status
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
function updateConnectionStatus() {
|
function updateConnectionStatus() {
|
||||||
const statusTextEl = document.querySelector('.connection-status-text');
|
const $statusTextEl = $('.connection-status-text');
|
||||||
console.log('checking internet connection');
|
const $icon = $('#connection-status-item i');
|
||||||
if (!statusTextEl) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
statusTextEl.innerText = "Connecting";
|
if ($statusTextEl.length === 0) return;
|
||||||
statusTextEl.style.color = "white";
|
|
||||||
document.querySelector('#connection-status-item i').style.color = "white";
|
|
||||||
|
|
||||||
|
$statusTextEl.text("Connecting").css("color", "white");
|
||||||
|
$icon.css("color", "white");
|
||||||
|
|
||||||
|
const img = new Image();
|
||||||
fetch("https://www.google.com/generate_204?_=" + new Date().getTime(), {
|
img.onload = function () {
|
||||||
method: 'GET',
|
$statusTextEl.text("Online").css("color", "lightgreen");
|
||||||
mode: 'no-cors',
|
$icon.css("color", "lightgreen");
|
||||||
cache: 'no-store'
|
};
|
||||||
})
|
img.onerror = function () {
|
||||||
.then(function(res) {
|
$statusTextEl.text("Offline").css("color", "#ffcdd2");
|
||||||
console.log(res);
|
$icon.css("color", "#ffcdd2");
|
||||||
statusTextEl.innerText = "Online";
|
};
|
||||||
statusTextEl.style.color = "lightgreen";
|
img.src = "https://www.google.com/favicon.ico?_=" + new Date().getTime(); // avoid cache
|
||||||
document.querySelector('#connection-status-item i').style.color = "lightgreen";
|
|
||||||
})
|
|
||||||
.catch(function(e) {
|
|
||||||
console.log("error", e);
|
|
||||||
statusTextEl.innerText = "Offline";
|
|
||||||
statusTextEl.style.color = "#ffcdd2";
|
|
||||||
document.querySelector('#connection-status-item i').style.color = "#ffcdd2";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateConnectionStatus();
|
updateConnectionStatus();
|
||||||
|
|||||||
@@ -191,9 +191,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
let selectedPaymentMethodId = null;
|
let selectedPaymentMethodId = null;
|
||||||
let selectedPaymentMethodLabel = '';
|
let selectedPaymentMethodLabel = '';
|
||||||
const originalProceedButtonText = proceedButton.textContent.trim(); // Store original button text
|
const originalProceedButtonText = proceedButton.textContent.trim();
|
||||||
|
|
||||||
// Function to update the "Process" button's state and appearance
|
|
||||||
function styleProceedButton(enabled) {
|
function styleProceedButton(enabled) {
|
||||||
proceedButton.disabled = !enabled;
|
proceedButton.disabled = !enabled;
|
||||||
|
|
||||||
@@ -201,7 +199,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
proceedButton.style.borderColor = '#54A5AF'; // Active/theme color
|
proceedButton.style.borderColor = '#54A5AF'; // Active/theme color
|
||||||
proceedButton.style.color = '#54A5AF';
|
proceedButton.style.color = '#54A5AF';
|
||||||
proceedButton.textContent = `Process with ${selectedPaymentMethodLabel}`;
|
proceedButton.textContent = `Process with ${selectedPaymentMethodLabel}`;
|
||||||
// Opacity and cursor will be handled by :disabled CSS or browser defaults
|
|
||||||
} else {
|
} else {
|
||||||
// Reset to default styles (defined in CSS) when disabled
|
// Reset to default styles (defined in CSS) when disabled
|
||||||
proceedButton.style.borderColor = ''; // Reverts to stylesheet's .btn-proceed border-color
|
proceedButton.style.borderColor = ''; // Reverts to stylesheet's .btn-proceed border-color
|
||||||
@@ -272,54 +269,46 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initDynamicQrPay() {
|
function initDynamicQrPay() {
|
||||||
const paymentMethod = 'MMQR';
|
const paymentMethod = 'MMQR';
|
||||||
let table_id = $("#table_id").text();
|
const $serverMode = $('#server_mode');
|
||||||
let booking_id = $("#booking_id").text();
|
const $createOrderBtn = $('#create_order');
|
||||||
let customer_id = $("#customer_id").text();
|
const $createPayOrderBtn = $('#create_pay_order');
|
||||||
let second_display_lookup = $("#display_type").val();
|
|
||||||
|
|
||||||
let params = {
|
const params = {
|
||||||
order_source: "food_court",
|
order_source: "food_court",
|
||||||
order_type: "dine_in",
|
order_type: "dine_in",
|
||||||
customer_id: customer_id,
|
customer_id: $("#customer_id").text(),
|
||||||
guest_info: "",
|
guest_info: "",
|
||||||
table_id: table_id,
|
table_id: $("#table_id").text(),
|
||||||
order_items: JSON.stringify(get_order_item_rows()),
|
order_items: JSON.stringify(get_order_item_rows()),
|
||||||
create_type: "create_pay",
|
create_type: "create_pay",
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch('/foodcourt/addorders/create', {
|
$.ajax({
|
||||||
method: 'POST',
|
url: '/foodcourt/addorders/create',
|
||||||
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(params),
|
},
|
||||||
})
|
data: JSON.stringify(params),
|
||||||
.then(response => {
|
success: function(result) {
|
||||||
if (!response.ok) {
|
const booking_id = result.booking_id;
|
||||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
||||||
}
|
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
||||||
return response.json();
|
// customer_display_view(null, "reload");
|
||||||
})
|
}
|
||||||
.then(result => {
|
},
|
||||||
booking_id = result.booking_id;
|
error: function(xhr) {
|
||||||
console.log(result);
|
$('#oqs_loading_wrapper').hide();
|
||||||
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
$createOrderBtn.prop('disabled', false);
|
||||||
|
$createPayOrderBtn.prop('disabled', false);
|
||||||
|
|
||||||
if (document.getElementById("server_mode").value !== "cloud" && second_display_lookup === 2) {
|
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
||||||
// customer_display_view(null, "reload");
|
swal("Error", errorMsg, "error");
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
document.getElementById("oqs_loading_wrapper").style.display = "none";
|
|
||||||
document.getElementById("create_order").disabled = false;
|
|
||||||
document.getElementById("create_pay_order").disabled = false;
|
|
||||||
swal("Error", "Status: " + error.message, "error");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_order_item_rows(){
|
function get_order_item_rows(){
|
||||||
var order_items = [];
|
var order_items = [];
|
||||||
var item_row = $('.summary-items tbody tr');
|
var item_row = $('.summary-items tbody tr');
|
||||||
|
|||||||
Reference in New Issue
Block a user