84 lines
2.7 KiB
PHP
84 lines
2.7 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/includes/layout.php';
|
|
|
|
ensure_tables();
|
|
|
|
$storeId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|
$store = $storeId ? get_store($storeId) : null;
|
|
|
|
if (!$store) {
|
|
render_header('Store not found');
|
|
?>
|
|
<div class="content-card">
|
|
<h4 class="mb-2">Store not found</h4>
|
|
<p class="text-muted mb-3">The store you requested does not exist. Return to the directory to pick another.</p>
|
|
<a class="btn btn-dark" href="/stores.php">Back to stores</a>
|
|
</div>
|
|
<?php
|
|
render_footer();
|
|
exit;
|
|
}
|
|
|
|
$products = get_products($storeId, 10);
|
|
|
|
render_header($store['name'], 'Store catalog overview and quick access to products.');
|
|
?>
|
|
|
|
<section class="content-card mb-4">
|
|
<div class="d-flex flex-wrap justify-content-between gap-3">
|
|
<div>
|
|
<p class="text-muted small mb-1">Store profile</p>
|
|
<h3 class="mb-1"><?= h($store['name']) ?></h3>
|
|
<p class="text-muted mb-0">Slug: <?= h($store['slug']) ?> · Currency: <?= h($store['currency']) ?></p>
|
|
</div>
|
|
<div class="d-flex gap-2">
|
|
<a class="btn btn-outline-dark" href="/products.php?store_id=<?= h((string)$store['id']) ?>">View products</a>
|
|
<a class="btn btn-dark" href="/products.php">Add product</a>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="content-card">
|
|
<div class="d-flex align-items-center justify-content-between mb-3">
|
|
<div>
|
|
<h4 class="mb-1">Recent products</h4>
|
|
<p class="text-muted small mb-0">Latest inventory updates for this store.</p>
|
|
</div>
|
|
<span class="badge text-bg-light border"><?= h((string)count($products)) ?> items</span>
|
|
</div>
|
|
|
|
<?php if (empty($products)): ?>
|
|
<div class="empty-state">
|
|
<p class="mb-2">No products created for this store yet.</p>
|
|
<a class="btn btn-dark btn-sm" href="/products.php">Add the first SKU</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="table-responsive">
|
|
<table class="table align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th>SKU</th>
|
|
<th>Product</th>
|
|
<th>Status</th>
|
|
<th class="text-end">Stock</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($products as $product): ?>
|
|
<tr>
|
|
<td class="text-muted"><?= h($product['sku']) ?></td>
|
|
<td><a class="link-dark" href="/product.php?id=<?= h((string)$product['id']) ?>"><?= h($product['name']) ?></a></td>
|
|
<td><span class="badge bg-light text-dark border"><?= h(ucfirst($product['status'])) ?></span></td>
|
|
<td class="text-end"><?= h((string)$product['stock']) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
|
|
<?php render_footer(); ?>
|