<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Core\PosService;
PosService::requireAccess();
$vendorId = PosService::currentVendorId();
$register = PosService::defaultRegister($vendorId);
$shift = $register ? PosService::currentShift((int)$register['id'], (int)(current_user()['id'] ?? 0)) : null;
$products = PosService::searchProducts($_GET['q'] ?? '', $vendorId, 60);
$pageTitle = 'Barcode Label Print | Pro POS';
require_once __DIR__ . '/partials/header.php';
?>
<form class="row g-2 mb-3"><div class="col-md-8"><input class="form-control" name="q" value="<?= e($_GET['q'] ?? '') ?>" placeholder="Search products for labels"></div><div class="col-md-2 d-grid"><button class="btn btn-primary">Search</button></div><div class="col-md-2 d-grid"><button class="btn btn-outline-dark" type="button" onclick="window.print()">Print Labels</button></div></form>
<div class="label-sheet"><?php foreach($products as $p): ?><div class="pos-label"><strong><?= e(mb_strimwidth($p['name'],0,28,'...')) ?></strong><span><?= e($p['sku'] ?? '') ?></span><div class="label-barcode">*<?= e($p['barcode'] ?: $p['sku']) ?>*</div><span><?= money($p['sale_price'] ?: $p['regular_price']) ?></span></div><?php endforeach; ?></div>
<?php require_once __DIR__ . '/partials/footer.php'; ?>
