272 lines
9.1 KiB
PHP
272 lines
9.1 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Customer Display</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
<style>
|
|
body {
|
|
background-color: var(--bg);
|
|
color: var(--text);
|
|
height: 100vh;
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
transition: background-color 0.3s, color 0.3s;
|
|
}
|
|
.header {
|
|
background: var(--surface);
|
|
padding: 1rem 2rem;
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.logo {
|
|
font-size: 1.5rem;
|
|
font-weight: bold;
|
|
color: var(--accent);
|
|
}
|
|
.content {
|
|
flex: 1;
|
|
display: flex;
|
|
overflow: hidden;
|
|
}
|
|
.items-section {
|
|
flex: 2;
|
|
padding: 2rem;
|
|
overflow-y: auto;
|
|
border-right: 1px solid var(--border);
|
|
background: var(--surface);
|
|
}
|
|
.totals-section {
|
|
flex: 1;
|
|
padding: 2rem;
|
|
background: var(--bg);
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
}
|
|
.cart-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 1rem;
|
|
border-bottom: 1px solid var(--border);
|
|
margin-bottom: 0.5rem;
|
|
background: var(--surface);
|
|
border-radius: var(--radius);
|
|
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
|
}
|
|
.item-name {
|
|
font-size: 1.2rem;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
}
|
|
.item-details {
|
|
color: var(--text-muted);
|
|
font-size: 0.9rem;
|
|
}
|
|
.item-price {
|
|
font-size: 1.2rem;
|
|
font-weight: bold;
|
|
color: var(--accent);
|
|
}
|
|
.total-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 1rem;
|
|
font-size: 1.2rem;
|
|
color: var(--text-muted);
|
|
}
|
|
.grand-total {
|
|
background: var(--accent);
|
|
color: white;
|
|
padding: 2rem;
|
|
border-radius: 12px;
|
|
text-align: center;
|
|
margin-top: auto;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.grand-total-label {
|
|
font-size: 1.2rem;
|
|
text-transform: uppercase;
|
|
opacity: 0.9;
|
|
}
|
|
.grand-total-amount {
|
|
font-size: 3.5rem;
|
|
font-weight: 800;
|
|
line-height: 1.2;
|
|
}
|
|
.welcome-screen {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100%;
|
|
text-align: center;
|
|
color: var(--text-muted);
|
|
}
|
|
.welcome-icon {
|
|
font-size: 5rem;
|
|
margin-bottom: 1rem;
|
|
color: var(--border);
|
|
opacity: 0.5;
|
|
}
|
|
/* Custom scrollbar */
|
|
::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
::-webkit-scrollbar-track {
|
|
background: var(--bg);
|
|
}
|
|
::-webkit-scrollbar-thumb {
|
|
background: var(--border);
|
|
border-radius: 4px;
|
|
}
|
|
::-webkit-scrollbar-thumb:hover {
|
|
background: var(--text-muted);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<div class="logo">
|
|
<i class="bi bi-cart4 me-2"></i>Customer Display
|
|
</div>
|
|
<div id="customerName" class="badge bg-light text-dark fs-6 fw-normal border">
|
|
Welcome
|
|
</div>
|
|
</div>
|
|
|
|
<div id="activeCart" class="content" style="display: none;">
|
|
<div class="items-section" id="itemsList">
|
|
<!-- Items will be injected here -->
|
|
</div>
|
|
|
|
<div class="totals-section">
|
|
<div class="total-row">
|
|
<span>Subtotal</span>
|
|
<span id="displaySubtotal">OMR 0.000</span>
|
|
</div>
|
|
<div id="displayDiscountRow" class="total-row text-danger" style="display: none;">
|
|
<span>Discount</span>
|
|
<span id="displayDiscount">- OMR 0.000</span>
|
|
</div>
|
|
<div id="displayLoyaltyRow" class="total-row text-success" style="display: none;">
|
|
<span>Loyalty Redeemed</span>
|
|
<span id="displayLoyalty">- OMR 0.000</span>
|
|
</div>
|
|
<div id="displayTaxRow" class="total-row text-muted" style="display: none;">
|
|
<small>VAT Included</small>
|
|
<small id="displayTax">OMR 0.000</small>
|
|
</div>
|
|
|
|
<div class="grand-total">
|
|
<div class="grand-total-label">Total to Pay</div>
|
|
<div class="grand-total-amount" id="displayTotal">OMR 0.000</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="welcomeScreen" class="welcome-screen">
|
|
<div class="welcome-icon">
|
|
<i class="bi bi-shop"></i>
|
|
</div>
|
|
<h1 class="display-4 fw-bold" style="color: var(--text)">Welcome</h1>
|
|
<p class="lead">Next customer, please.</p>
|
|
</div>
|
|
|
|
<script>
|
|
function formatMoney(amount) {
|
|
return 'OMR ' + parseFloat(amount).toFixed(3);
|
|
}
|
|
|
|
function updateDisplay(data) {
|
|
// Update Theme
|
|
if (data.theme) {
|
|
document.body.className = data.theme;
|
|
}
|
|
|
|
if (!data || !data.items || data.items.length === 0) {
|
|
document.getElementById('activeCart').style.display = 'none';
|
|
document.getElementById('welcomeScreen').style.display = 'flex';
|
|
document.getElementById('customerName').innerText = 'Welcome';
|
|
return;
|
|
}
|
|
|
|
document.getElementById('welcomeScreen').style.display = 'none';
|
|
document.getElementById('activeCart').style.display = 'flex';
|
|
|
|
// Update Customer Name
|
|
if (data.customerName && data.customerName !== 'Walk-in Customer' && data.customerName !== 'عميل عابر') {
|
|
document.getElementById('customerName').innerHTML = '<i class="bi bi-person me-1"></i> ' + data.customerName;
|
|
} else {
|
|
document.getElementById('customerName').innerText = 'Welcome';
|
|
}
|
|
|
|
// Update Items
|
|
const itemsList = document.getElementById('itemsList');
|
|
itemsList.innerHTML = data.items.map(item => `
|
|
<div class="cart-item">
|
|
<div>
|
|
<div class="item-name">${item.name}</div>
|
|
<div class="item-details">
|
|
${item.qty} x ${formatMoney(item.price)}
|
|
</div>
|
|
</div>
|
|
<div class="item-price">
|
|
${formatMoney(item.qty * item.price)}
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
|
|
// Scroll to bottom of list
|
|
itemsList.scrollTop = itemsList.scrollHeight;
|
|
|
|
// Update Totals
|
|
document.getElementById('displaySubtotal').innerText = formatMoney(data.subtotal);
|
|
|
|
if (data.discount > 0) {
|
|
document.getElementById('displayDiscountRow').style.display = 'flex';
|
|
document.getElementById('displayDiscount').innerText = '- ' + formatMoney(data.discount);
|
|
} else {
|
|
document.getElementById('displayDiscountRow').style.display = 'none';
|
|
}
|
|
|
|
if (data.loyalty > 0) {
|
|
document.getElementById('displayLoyaltyRow').style.display = 'flex';
|
|
document.getElementById('displayLoyalty').innerText = '- ' + formatMoney(data.loyalty);
|
|
} else {
|
|
document.getElementById('displayLoyaltyRow').style.display = 'none';
|
|
}
|
|
|
|
document.getElementById('displayTotal').innerText = formatMoney(data.total);
|
|
}
|
|
|
|
// Listen for storage events
|
|
window.addEventListener('storage', (e) => {
|
|
if (e.key === 'pos_cart_update') {
|
|
try {
|
|
const data = JSON.parse(e.newValue);
|
|
updateDisplay(data);
|
|
} catch (err) {
|
|
console.error('Error parsing cart data', err);
|
|
}
|
|
}
|
|
});
|
|
|
|
// Initial check
|
|
const stored = localStorage.getItem('pos_cart_update');
|
|
if (stored) {
|
|
try {
|
|
updateDisplay(JSON.parse(stored));
|
|
} catch (e) {}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|