577 lines
28 KiB
PHP
577 lines
28 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . '/includes/functions.php';
|
|
|
|
require_permission('pos_view');
|
|
|
|
$pdo = db();
|
|
$currentUser = get_logged_user();
|
|
|
|
// Fetch outlets based on user assignment
|
|
if (has_permission('all')) {
|
|
$outlets = $pdo->query("SELECT * FROM outlets ORDER BY name")->fetchAll();
|
|
} else {
|
|
$stmt = $pdo->prepare("
|
|
SELECT o.* FROM outlets o
|
|
JOIN user_outlets uo ON o.id = uo.outlet_id
|
|
WHERE uo.user_id = ?
|
|
ORDER BY o.name
|
|
");
|
|
$stmt->execute([$currentUser['id']]);
|
|
$outlets = $stmt->fetchAll();
|
|
}
|
|
|
|
$outlet_id = isset($_GET['outlet_id']) ? (int)$_GET['outlet_id'] : (count($outlets) > 0 ? (int)$outlets[0]['id'] : 1);
|
|
|
|
// Security check: ensure user has access to this outlet
|
|
if (!has_permission('all')) {
|
|
$has_access = false;
|
|
foreach ($outlets as $o) {
|
|
if ($o['id'] == $outlet_id) {
|
|
$has_access = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!$has_access && count($outlets) > 0) {
|
|
$outlet_id = (int)$outlets[0]['id'];
|
|
}
|
|
}
|
|
|
|
$categories = $pdo->query("SELECT * FROM categories ORDER BY sort_order")->fetchAll();
|
|
$all_products = $pdo->query("SELECT p.*, c.name as category_name FROM products p JOIN categories c ON p.category_id = c.id")->fetchAll();
|
|
$payment_types = $pdo->query("SELECT * FROM payment_types WHERE is_active = 1 ORDER BY id")->fetchAll();
|
|
|
|
// Fetch variants
|
|
$variants_raw = $pdo->query("SELECT * FROM product_variants ORDER BY price_adjustment ASC")->fetchAll();
|
|
$variants_by_product = [];
|
|
foreach ($variants_raw as $v) {
|
|
$variants_by_product[$v['product_id']][] = $v;
|
|
}
|
|
|
|
$table_id = $_GET['table'] ?? '1'; // Default table
|
|
$settings = get_company_settings();
|
|
$order_type = $_GET['order_type'] ?? 'takeaway';
|
|
|
|
$current_outlet_name = 'Unknown Outlet';
|
|
foreach ($outlets as $o) {
|
|
if ($o['id'] == $outlet_id) {
|
|
$current_outlet_name = $o['name'];
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Fetch Loyalty Settings
|
|
$loyalty_stmt = $pdo->query("SELECT * FROM loyalty_settings WHERE id = 1");
|
|
$loyalty_settings = $loyalty_stmt->fetch(PDO::FETCH_ASSOC);
|
|
if (!$loyalty_settings) {
|
|
$loyalty_settings = ['is_enabled' => 0, 'points_per_order' => 0, 'points_for_free_meal' => 0];
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title><?= htmlspecialchars($settings['company_name']) ?> - POS</title>
|
|
<?php if (!empty($settings['favicon_url'])): ?>
|
|
<link rel="icon" href="<?= htmlspecialchars($settings['favicon_url']) ?>">
|
|
<?php endif; ?>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Noto+Sans+Arabic:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<style>
|
|
body { height: 100vh; overflow: hidden; font-family: 'Inter', 'Noto Sans Arabic', sans-serif; } /* Fix body for scrolling areas */
|
|
.scrollable-y { overflow-y: auto; height: 100%; scrollbar-width: thin; }
|
|
.category-sidebar { height: calc(100vh - 60px); background: #f8f9fa; }
|
|
.product-area { height: calc(100vh - 60px); background: #fff; }
|
|
.cart-sidebar { height: calc(100vh - 60px); background: #fff; border-left: 1px solid #dee2e6; display: flex; flex-direction: column; }
|
|
.product-card { transition: transform 0.1s; cursor: pointer; }
|
|
.product-card:active { transform: scale(0.98); }
|
|
.category-btn { text-align: left; border: none; background: none; padding: 10px 15px; width: 100%; display: block; border-radius: 8px; color: #333; font-weight: 500; font-size: 0.95rem; }
|
|
.category-btn:hover { background-color: #e9ecef; }
|
|
.category-btn.active { background-color: #0d6efd; color: white; }
|
|
.search-dropdown { position: absolute; width: 100%; z-index: 1000; max-height: 200px; overflow-y: auto; display: none; }
|
|
.payment-btn { height: 70px; font-size: 1.05rem; font-weight: bold; }
|
|
.btn-lg { font-size: 1.1rem; padding: 0.75rem 1rem; }
|
|
|
|
/* Print Styles */
|
|
@media print {
|
|
.no-print { display: none !important; }
|
|
.print-only { display: block !important; }
|
|
body { overflow: visible !important; height: auto !important; }
|
|
}
|
|
.print-only { display: none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- Print Container for QR codes, etc. -->
|
|
<div class="print-only" id="print-section"></div>
|
|
|
|
<div class="container-fluid p-0 no-print">
|
|
<!-- Header/Navbar -->
|
|
<nav class="navbar navbar-expand-lg border-bottom px-3 py-2 bg-white sticky-top">
|
|
<div class="container-fluid p-0">
|
|
<a class="navbar-brand fw-bold d-flex align-items-center" href="pos.php">
|
|
<?php if (!empty($settings['logo_url'])): ?>
|
|
<img src="<?= htmlspecialchars($settings['logo_url']) ?>" alt="Logo" height="30" class="me-2">
|
|
<?php endif; ?>
|
|
<span><?= htmlspecialchars($settings['company_name']) ?></span>
|
|
<span class="badge bg-primary ms-2 fs-6 fw-normal"><?= htmlspecialchars($current_outlet_name) ?></span>
|
|
</a>
|
|
|
|
<div class="ms-auto d-flex align-items-center gap-3">
|
|
<!-- Outlet Selector in Header -->
|
|
<div class="dropdown me-2">
|
|
<button class="btn btn-outline-secondary btn-sm dropdown-toggle rounded-pill px-3" type="button" data-bs-toggle="dropdown">
|
|
<i class="bi bi-shop me-1"></i> Switch Outlet
|
|
</button>
|
|
<ul class="dropdown-menu dropdown-menu-end shadow border-0 mt-2">
|
|
<?php foreach ($outlets as $o): ?>
|
|
<li>
|
|
<a class="dropdown-item <?= $o['id'] == $outlet_id ? 'active' : '' ?>" href="?outlet_id=<?= $o['id'] ?>">
|
|
<?= htmlspecialchars($o['name']) ?>
|
|
</a>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
|
|
<a href="kitchen.php" class="btn btn-outline-primary btn-sm rounded-pill px-3">
|
|
<i class="bi bi-fire me-1"></i> Kitchen
|
|
</a>
|
|
<a href="admin/orders.php" class="btn btn-outline-secondary btn-sm rounded-pill px-3">
|
|
<i class="bi bi-receipt me-1"></i> Current Orders
|
|
</a>
|
|
<button class="btn btn-outline-warning btn-sm rounded-pill px-3" onclick="openRecallOrderModal()">
|
|
<i class="bi bi-arrow-counterclockwise me-1"></i> Recall Bill
|
|
</button>
|
|
<button class="btn btn-outline-info btn-sm rounded-pill px-3" onclick="showRatingQR()">
|
|
<i class="bi bi-qr-code me-1"></i> Rating QR
|
|
</button>
|
|
|
|
<div class="vr mx-2 h-25"></div>
|
|
|
|
<div class="dropdown">
|
|
<button class="btn btn-light btn-sm rounded-circle p-1 border" type="button" data-bs-toggle="dropdown">
|
|
<img src="<?= !empty($currentUser['profile_pic']) ? htmlspecialchars($currentUser['profile_pic']) : 'https://ui-avatars.com/api/?name=' . urlencode($currentUser['username']) ?>" alt="User" width="30" height="30" class="rounded-circle">
|
|
</button>
|
|
<ul class="dropdown-menu dropdown-menu-end shadow border-0 mt-2">
|
|
<li class="px-3 py-2 border-bottom">
|
|
<div class="fw-bold small"><?= htmlspecialchars($currentUser['username']) ?></div>
|
|
<div class="text-muted" style="font-size: 0.7rem;">Logged in as <?= htmlspecialchars($currentUser['group_name'] ?? 'User') ?></div>
|
|
</li>
|
|
<?php if (has_permission('dashboard_view')): ?>
|
|
<li><a class="dropdown-item py-2" href="admin/index.php"><i class="bi bi-speedometer2 me-2"></i> Dashboard</a></li>
|
|
<?php endif; ?>
|
|
<li><a class="dropdown-item py-2 text-danger" href="logout.php"><i class="bi bi-box-arrow-right me-2"></i> Logout</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="row g-0">
|
|
<!-- Left Sidebar: Categories -->
|
|
<div class="col-md-1 col-3 category-sidebar border-end scrollable-y p-2">
|
|
<button class="category-btn active mb-2" data-category="all">
|
|
<i class="bi bi-grid d-block fs-4 mb-1"></i>
|
|
<span style="font-size: 0.75rem;">All Items</span>
|
|
</button>
|
|
<?php foreach ($categories as $cat): ?>
|
|
<button class="category-btn mb-2" data-category="<?= $cat['id'] ?>">
|
|
<?php if (!empty($cat['image_url'])): ?>
|
|
<img src="<?= htmlspecialchars($cat['image_url']) ?>" alt="<?= htmlspecialchars($cat['name']) ?>" class="rounded d-block mb-1 mx-auto" style="width: 32px; height: 32px; object-fit: cover;">
|
|
<?php else: ?>
|
|
<i class="bi bi-tag d-block fs-4 mb-1"></i>
|
|
<?php endif; ?>
|
|
<span class="d-block text-truncate text-center" style="font-size: 0.75rem;"><?= htmlspecialchars($cat['name']) ?></span>
|
|
</button>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<!-- Center Area: Product Grid -->
|
|
<div class="col-md-8 col-9 product-area d-flex flex-column">
|
|
<!-- Search Bar -->
|
|
<div class="p-3 border-bottom bg-light">
|
|
<div class="position-relative">
|
|
<span class="position-absolute top-50 start-0 translate-middle-y ms-3 text-muted">
|
|
<i class="bi bi-search"></i>
|
|
</span>
|
|
<input type="text" id="product-search" class="form-control form-control-lg ps-5 border-0 shadow-sm rounded-pill" placeholder="Search products by name or SKU...">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Grid Container -->
|
|
<div class="flex-grow-1 scrollable-y p-3">
|
|
<div class="row g-3" id="product-grid">
|
|
<?php foreach ($all_products as $product): ?>
|
|
<?php $has_variants = !empty($variants_by_product[$product['id']]); ?>
|
|
<div class="col-xl-3 col-lg-4 col-md-6 col-6 product-item"
|
|
data-category="<?= $product['category_id'] ?>"
|
|
data-name="<?= strtolower($product['name']) ?>"
|
|
data-sku="<?= strtolower($product['sku'] ?? '') ?>"
|
|
onclick='handleProductClick(<?= json_encode($product) ?>, <?= json_encode($variants_by_product[$product['id']] ?? []) ?>)'>
|
|
<div class="card h-100 border-0 shadow-sm product-card rounded-4 overflow-hidden">
|
|
<?php if (!empty($product['image_url'])): ?>
|
|
<img src="<?= htmlspecialchars($product['image_url']) ?>" class="card-img-top" alt="<?= htmlspecialchars($product['name']) ?>" style="height: 120px; object-fit: cover;">
|
|
<?php else: ?>
|
|
<div class="bg-light d-flex align-items-center justify-content-center" style="height: 120px;">
|
|
<i class="bi bi-image text-muted opacity-25 fs-1"></i>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="card-body p-2 text-center">
|
|
<h6 class="card-title fw-bold mb-1 text-truncate" style="font-size: 0.9rem;"><?= htmlspecialchars($product['name']) ?></h6>
|
|
<div class="text-primary fw-bold mb-1" style="font-size: 1rem;"><?= format_currency((float)$product['price']) ?></div>
|
|
<?php if (!empty($product['name_ar'])): ?>
|
|
<div class="text-primary small fw-semibold text-truncate mb-1" dir="rtl" style="font-size: 0.8rem;"><?= htmlspecialchars($product['name_ar']) ?></div>
|
|
<?php endif; ?>
|
|
<p class="card-text small text-muted text-truncate mb-0"><?= htmlspecialchars($product['category_name']) ?></p>
|
|
<?php if ($has_variants): ?>
|
|
<span class="badge bg-light text-secondary border mt-1">Options</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Right Sidebar: Cart & Order Info -->
|
|
<div class="col-md-3 col-12 cart-sidebar border-start p-0 d-flex flex-column">
|
|
|
|
<!-- Top Section: Customer & Type -->
|
|
<div class="p-3 border-bottom bg-white">
|
|
<!-- Order Type -->
|
|
<div class="btn-group w-100 mb-3" role="group">
|
|
<input type="radio" class="btn-check" name="order_type" id="ot-takeaway" value="takeaway" <?= $order_type === 'takeaway' ? 'checked' : '' ?>>
|
|
<label class="btn btn-outline-primary btn-sm" for="ot-takeaway">Takeaway</label>
|
|
|
|
<input type="radio" class="btn-check" name="order_type" id="ot-dine-in" value="dine-in" <?= $order_type === 'dine-in' ? 'checked' : '' ?>>
|
|
<label class="btn btn-outline-primary btn-sm" for="ot-dine-in">Dine-In</label>
|
|
|
|
<input type="radio" class="btn-check" name="order_type" id="ot-delivery" value="delivery" <?= $order_type === 'delivery' ? 'checked' : '' ?>>
|
|
<label class="btn btn-outline-primary btn-sm" for="ot-delivery">Delivery</label>
|
|
</div>
|
|
|
|
<!-- Customer Search -->
|
|
<div class="position-relative">
|
|
<div class="input-group input-group-sm">
|
|
<span class="input-group-text bg-white border-end-0"><i class="bi bi-person"></i></span>
|
|
<input type="text" class="form-control border-start-0 ps-0" id="customer-search" placeholder="Search Customer..." autocomplete="off">
|
|
<button class="btn btn-outline-secondary d-none" type="button" id="clear-customer"><i class="bi bi-x"></i></button>
|
|
<button class="btn btn-outline-primary" type="button" data-bs-toggle="modal" data-bs-target="#addCustomerModal" title="Add New Customer">
|
|
<i class="bi bi-plus-lg"></i>
|
|
</button>
|
|
</div>
|
|
<div class="list-group shadow-sm search-dropdown" id="customer-results"></div>
|
|
<input type="hidden" id="selected-customer-id">
|
|
|
|
<div id="customer-info" class="small text-success mt-1 d-none">
|
|
<i class="bi bi-check-circle-fill me-1"></i> <span id="customer-name-display"></span>
|
|
</div>
|
|
|
|
<!-- Loyalty Section (Hidden if disabled) -->
|
|
<?php if ($loyalty_settings['is_enabled']): ?>
|
|
<div id="loyalty-section" class="d-none mt-2 p-2 bg-warning-subtle rounded border border-warning">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<span class="d-block fw-bold small text-warning-emphasis">Loyalty Points</span>
|
|
<span id="loyalty-points-display" class="fw-bold fs-5">0</span>
|
|
</div>
|
|
<div class="d-flex flex-column gap-1">
|
|
<button id="redeem-loyalty-btn" class="btn btn-sm btn-success shadow-sm" disabled>
|
|
<i class="bi bi-gift-fill me-1"></i> Redeem
|
|
</button>
|
|
<button id="view-points-history-btn" class="btn btn-sm btn-outline-primary border-0 shadow-none p-0 text-decoration-underline" style="font-size: 0.7rem;">
|
|
<i class="bi bi-clock-history"></i> View History
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div id="loyalty-message" class="small text-muted mt-1 fst-italic" style="font-size: 0.75rem;"></div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Cart Items (Flex Grow) -->
|
|
<div class="flex-grow-1 overflow-auto p-3 bg-white" id="cart-items">
|
|
<div class="text-center text-muted mt-5">
|
|
<i class="bi bi-basket3 fs-1 text-light"></i>
|
|
<p class="mt-2">Cart is empty</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bottom: Totals & Action -->
|
|
<div class="p-3 border-top bg-light mt-auto">
|
|
<div class="d-flex justify-content-between mb-2">
|
|
<span class="text-muted">Subtotal</span>
|
|
<span class="fw-bold" id="cart-subtotal"><?= format_currency(0) ?></span>
|
|
</div>
|
|
|
|
<!-- VAT Field -->
|
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
<span class="text-muted">VAT (<?= htmlspecialchars((string)($settings['vat_rate'] ?? 0)) ?>%)</span>
|
|
<div class="input-group input-group-sm w-50">
|
|
<span class="input-group-text bg-white border-end-0 text-muted">+</span>
|
|
<input type="number" id="cart-vat-input" class="form-control border-start-0 text-end bg-white" value="0" step="0.01" readonly>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between mb-3">
|
|
<span class="fs-5 fw-bold">Total</span>
|
|
<span class="fs-4 fw-bold text-primary" id="cart-total-price"><?= format_currency(0) ?></span>
|
|
</div>
|
|
|
|
<?php if (has_permission('pos_add')): ?>
|
|
<div class="mb-2">
|
|
<button class="btn btn-outline-danger w-100 py-2 fw-bold mb-2 btn-sm" onclick="clearCart()">
|
|
<i class="bi bi-trash me-1"></i> CLEAR CART
|
|
</button>
|
|
<div class="d-flex gap-2">
|
|
<button class="btn btn-primary w-50 btn-lg shadow-sm fw-bold" id="quick-order-btn" disabled>
|
|
QUICK ORDER <i class="bi bi-lightning-fill ms-1"></i>
|
|
</button>
|
|
<button class="btn btn-warning w-50 btn-lg shadow-sm text-white fw-bold" id="place-order-btn" disabled>
|
|
PLACE ORDER <i class="bi bi-clock ms-1"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="alert alert-warning small py-2 mb-0 text-center">
|
|
<i class="bi bi-info-circle me-1"></i> View Only Mode
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="text-center mt-3 text-muted small" style="font-size: 0.7rem;">
|
|
Powered By Abidarcafe @2026
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal components wrapped in no-print -->
|
|
<div class="no-print">
|
|
<!-- Toast Container -->
|
|
<div class="toast-container position-fixed bottom-0 start-50 translate-middle-x p-3" id="toast-container" style="z-index: 1060;"></div>
|
|
|
|
<!-- Recall Order Modal -->
|
|
<div class="modal fade" id="recallOrderModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title fw-bold">Recall Unpaid Bill</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body bg-light">
|
|
<div id="recall-orders-list" class="list-group">
|
|
<!-- Orders injected via JS -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Table Selection Modal -->
|
|
<div class="modal fade" id="tableSelectionModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title fw-bold" id="tableSelectionModalLabel">Select Table</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" id="close-table-modal" style="display:none;"></button>
|
|
</div>
|
|
<div class="modal-body bg-light">
|
|
<div id="table-list-container" class="row g-3"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Variant Selection Modal -->
|
|
<div class="modal fade" id="variantSelectionModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="variantModalTitle">Select Option</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div id="variant-list" class="list-group">
|
|
<!-- Variants injected by JS -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add Customer Modal -->
|
|
<div class="modal fade" id="addCustomerModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered modal-sm">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title fs-6 fw-bold">Add New Customer</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label for="new-customer-name" class="form-label small text-muted">Customer Name</label>
|
|
<input type="text" class="form-control form-control-sm" id="new-customer-name" placeholder="Enter name">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="new-customer-phone" class="form-label small text-muted">Phone Number</label>
|
|
<input type="text" class="form-control form-control-sm" id="new-customer-phone" placeholder="Enter phone">
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="button" class="btn btn-primary btn-sm" id="save-new-customer">Save Customer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Points History Modal -->
|
|
<div class="modal fade" id="pointsHistoryModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title fw-bold">Points History</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th class="ps-3">Date</th>
|
|
<th>Action</th>
|
|
<th class="text-end pe-3">Points</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="points-history-body">
|
|
<!-- History rows injected via JS -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="points-history-empty" class="text-center py-4 text-muted d-none">
|
|
<i class="bi bi-calendar-x fs-2"></i>
|
|
<p class="mt-2">No history found</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Payment Selection Modal -->
|
|
<div class="modal fade" id="paymentSelectionModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title fw-bold">Select Payment Method</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="row g-3" id="payment-methods-container">
|
|
<!-- Injected via JS -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Rating QR Modal -->
|
|
<div class="modal fade" id="ratingQRModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title fw-bold">Rating & Feedback QR</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body text-center p-4">
|
|
<p class="text-muted mb-4">Ask your customers to scan this QR code to rate your service and staff.</p>
|
|
<div id="rating-qr-container" class="mb-4">
|
|
<!-- QR Code will be generated here -->
|
|
<div class="bg-light p-4 rounded-4 d-inline-block shadow-sm">
|
|
<?php
|
|
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
|
|
$host = $_SERVER['HTTP_HOST'];
|
|
$ratingUrl = $protocol . "://" . $host . "/rate.php";
|
|
|
|
// Using a public QR generator for simplicity
|
|
$qrUrl = "https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=" . urlencode($ratingUrl);
|
|
?>
|
|
<img src="<?= $qrUrl ?>" alt="Rating QR Code" class="img-fluid" style="width: 200px; height: 200px;">
|
|
</div>
|
|
</div>
|
|
<div class="alert alert-info small py-2">
|
|
<i class="bi bi-link-45deg me-1"></i> URL: <a href="<?= $ratingUrl ?>" target="_blank" class="text-decoration-none"><?= $ratingUrl ?></a>
|
|
</div>
|
|
<button class="btn btn-primary w-100 rounded-pill py-2 fw-bold" onclick="printQRCode('<?= $qrUrl ?>', 'Rating & Feedback QR')">
|
|
<i class="bi bi-printer me-2"></i> Print QR Code
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
|
|
<!-- Global POS Variables -->
|
|
<script>
|
|
const COMPANY_SETTINGS = <?= json_encode($settings) ?>;
|
|
const PRODUCT_VARIANTS = <?= json_encode($variants_by_product) ?>;
|
|
const PAYMENT_TYPES = <?= json_encode($payment_types) ?>;
|
|
const BASE_URL = '<?= get_base_url() ?>';
|
|
const CURRENT_OUTLET = { id: <?= $outlet_id ?>, name: '<?= addslashes($current_outlet_name) ?>' };
|
|
const CURRENT_USER = { id: <?= $currentUser['id'] ?>, name: '<?= addslashes($currentUser['username']) ?>' };
|
|
const LOYALTY_SETTINGS = <?= json_encode($loyalty_settings) ?>;
|
|
</script>
|
|
|
|
<script src="assets/js/main.js?v=<?= time() ?>"></script>
|
|
<script>
|
|
function showRatingQR() {
|
|
const modal = new bootstrap.Modal(document.getElementById('ratingQRModal'));
|
|
modal.show();
|
|
}
|
|
|
|
function printQRCode(url, title) {
|
|
const win = window.open('', '_blank', 'width=600,height=600');
|
|
win.document.write(`
|
|
<html>
|
|
<head>
|
|
<title>${title}</title>
|
|
<style>
|
|
body { text-align: center; padding: 50px; font-family: sans-serif; }
|
|
img { width: 300px; height: 300px; margin-bottom: 20px; }
|
|
h2 { margin-bottom: 10px; }
|
|
@media print {
|
|
body { padding: 0; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h2>${title}</h2>
|
|
<img src="${url}" alt="QR Code">
|
|
<p>Scan to Rate Us</p>
|
|
<script>
|
|
window.onload = function() {
|
|
window.print();
|
|
setTimeout(function() { window.close(); }, 500);
|
|
}
|
|
<\/script>
|
|
</body>
|
|
</html>
|
|
`);
|
|
win.document.close();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|