query("SELECT * FROM outlets WHERE is_deleted = 0 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 = ? AND o.is_deleted = 0 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 WHERE is_deleted = 0 ORDER BY sort_order")->fetchAll(); $all_products = $pdo->query("SELECT p.*, c.name as category_name, c.name_ar as category_name_ar FROM products p JOIN categories c ON p.category_id = c.id WHERE p.is_deleted = 0 AND c.is_deleted = 0")->fetchAll(); $payment_types = $pdo->query("SELECT * FROM payment_types WHERE is_active = 1 AND is_deleted = 0 ORDER BY id")->fetchAll(); // Fetch variants $variants_raw = $pdo->query("SELECT * FROM product_variants WHERE is_deleted = 0 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 = null; foreach ($outlets as $o) { if ($o['id'] == $outlet_id) { $current_outlet = $o; break; } } if (!$current_outlet && count($outlets) > 0) { $current_outlet = $outlets[0]; } // 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]; } $vat_rate = (float)($settings['vat_rate'] ?? 0); ?> <?= htmlspecialchars($settings['company_name']) ?> - POS
1): ?>
<?= htmlspecialchars($product['name']) ?>
> > >
Loyalty Points
0 pts

No Items

Subtotal
VAT (%)
Total