<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Core\Auth; use App\Core\Database;
Auth::requireRole(['admin','staff']);
$pageTitle = 'Pro POS Control Center | Admin';
$today = Database::fetchOne('SELECT COUNT(*) sales, COALESCE(SUM(total_amount),0) total FROM pos_sales WHERE DATE(created_at)=CURDATE()') ?: ['sales'=>0,'total'=>0];
$registers = db_count('pos_registers');
$shifts = Database::fetchOne('SELECT COUNT(*) total FROM pos_shifts WHERE status="open"') ?: ['total'=>0];
$sync = Database::fetchOne('SELECT COUNT(*) total FROM pos_sync_queue WHERE status="pending"') ?: ['total'=>0];
require_once ROOT_PATH . '/app/Layouts/admin_header.php';
?>
<div class="d-flex justify-content-between align-items-start flex-wrap gap-3 mb-3"><div><h1 class="h3 mb-1">Pro POS Control Center</h1><p class="text-muted mb-0">Mobile-first PWA POS for vendors, POS managers, cashiers, barcode scanners, phone-camera scanning, thermal receipt printing and shift control.</p></div><div class="d-flex gap-2"><a class="btn btn-primary" href="<?= url('pos/register.php') ?>" target="_blank">Launch POS</a><a class="btn btn-outline-secondary" href="<?= url('admin/pos-settings.php') ?>">Settings</a></div></div>
<div class="row g-3 mb-4"><div class="col-md-3"><div class="stat-tile"><div class="small text-muted">Today POS Sales</div><strong><?= number_format((int)$today['sales']) ?></strong></div></div><div class="col-md-3"><div class="stat-tile"><div class="small text-muted">Today POS Revenue</div><strong><?= money($today['total']) ?></strong></div></div><div class="col-md-3"><div class="stat-tile"><div class="small text-muted">Registers</div><strong><?= number_format($registers) ?></strong></div></div><div class="col-md-3"><div class="stat-tile"><div class="small text-muted">Open Shifts</div><strong><?= number_format((int)$shifts['total']) ?></strong></div></div></div>
<div class="row g-3"><div class="col-lg-8"><div class="card module-card"><div class="card-body"><h5>Professional POS capabilities</h5><div class="option-grid mt-3"><span class="feature-pill">Vendor-wise registers</span><span class="feature-pill">Role-based cashiers</span><span class="feature-pill">PWA installable app</span><span class="feature-pill">Phone camera barcode scan</span><span class="feature-pill">USB/Bluetooth scanner input</span><span class="feature-pill">Cash drawer open/close</span><span class="feature-pill">Hold/resume carts</span><span class="feature-pill">Split payments</span><span class="feature-pill">Cash/bKash/Nagad/card/wallet</span><span class="feature-pill">Thermal receipt print</span><span class="feature-pill">Barcode label print</span><span class="feature-pill">Offline local queue + sync</span><span class="feature-pill">Refunds/exchanges</span><span class="feature-pill">X/Z shift reports</span><span class="feature-pill">Stock movement ledger</span></div></div></div></div><div class="col-lg-4"><div class="card module-card"><div class="card-header bg-white"><strong>POS Admin Modules</strong></div><div class="list-group list-group-flush"><a class="list-group-item" href="<?= url('admin/pos-registers.php') ?>">Registers & Terminals</a><a class="list-group-item" href="<?= url('admin/pos-shifts.php') ?>">Shifts / Cash Drawer</a><a class="list-group-item" href="<?= url('admin/pos-sales.php') ?>">POS Sales</a><a class="list-group-item" href="<?= url('admin/pos-refunds.php') ?>">Refunds</a><a class="list-group-item" href="<?= url('admin/pos-staff.php') ?>">Role-based POS Staff</a><a class="list-group-item" href="<?= url('admin/pos-sync.php') ?>">Offline Sync Queue <span class="badge bg-warning text-dark"><?= (int)$sync['total'] ?></span></a></div></div></div></div>
<?php require_once ROOT_PATH . '/app/Layouts/admin_footer.php'; ?>
