106 lines
6.7 KiB
PHP
106 lines
6.7 KiB
PHP
<?php
|
|
$pageTitle = $selectedCategory ? $selectedCategory['name'] : 'کاتالوگ و فروشگاه محصولات';
|
|
require __DIR__ . '/../layout/header.php';
|
|
require __DIR__ . '/../layout/navbar.php';
|
|
?>
|
|
|
|
<div class="bg-stone-100/60 py-8 border-b border-stone-200">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
|
<div>
|
|
<h1 class="text-2xl sm:text-3xl font-extrabold text-stone-900">
|
|
<?= $selectedCategory ? htmlspecialchars($selectedCategory['name']) : 'کلیه محصولات و ملزومات پرورش بلدرچین' ?>
|
|
</h1>
|
|
<p class="text-xs sm:text-sm text-stone-500 mt-1">
|
|
<?= $selectedCategory ? htmlspecialchars($selectedCategory['description']) : 'تولید و توزیع مستقیم گوشت، تخم، دان و تجهیزات استاندارد' ?>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Category Pills -->
|
|
<div class="flex flex-wrap gap-2">
|
|
<a href="/products" class="px-3.5 py-2 rounded-xl text-xs font-bold transition <?= !$categoryId ? 'bg-amber-600 text-white shadow-sm' : 'bg-white text-stone-700 hover:bg-stone-200 border border-stone-200' ?>">
|
|
همه دستهها
|
|
</a>
|
|
<?php foreach ($categories as $cat): ?>
|
|
<a href="/products?cat=<?= $cat['id'] ?>" class="px-3.5 py-2 rounded-xl text-xs font-bold transition <?= ($categoryId == $cat['id']) ? 'bg-amber-600 text-white shadow-sm' : 'bg-white text-stone-700 hover:bg-stone-200 border border-stone-200' ?>">
|
|
<?= htmlspecialchars($cat['name']) ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
|
|
<?php if (empty($products)): ?>
|
|
<div class="text-center py-20 bg-white rounded-3xl border border-stone-200 p-8">
|
|
<i class="fas fa-box-open text-5xl text-stone-300 mb-4 block"></i>
|
|
<h3 class="text-lg font-bold text-stone-700">هیچ محصولی در این بخش یافت نشد.</h3>
|
|
<p class="text-xs text-stone-400 mt-1">میتوانید سایر دستهبندیها را مشاهده نمایید.</p>
|
|
<a href="/products" class="inline-block mt-5 px-6 py-2.5 rounded-xl bg-amber-500 text-stone-900 text-xs font-bold hover:bg-amber-600 transition">
|
|
مشاهده همه محصولات
|
|
</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
|
|
<?php foreach ($products as $prod): ?>
|
|
<div class="bg-white rounded-2xl border border-stone-200 overflow-hidden shadow-sm hover:shadow-lg transition flex flex-col justify-between group">
|
|
<div class="relative">
|
|
<a href="/product/<?= $prod['slug'] ?>" class="block h-52 bg-stone-50 overflow-hidden p-4 flex items-center justify-center">
|
|
<img src="<?= $prod['image'] ?>" alt="<?= htmlspecialchars($prod['name']) ?>" class="max-h-full max-w-full object-contain group-hover:scale-105 transition duration-300">
|
|
</a>
|
|
|
|
<?php if ((int)$prod['is_wholesale_available'] === 1): ?>
|
|
<span class="absolute top-3 right-3 bg-amber-500 text-stone-950 text-[11px] font-extrabold px-2.5 py-1 rounded-lg shadow-sm">
|
|
<i class="fas fa-boxes-stacked ml-1"></i> تخفیف عمده
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="p-5 flex-1 flex flex-col justify-between">
|
|
<div>
|
|
<span class="text-[11px] font-semibold text-amber-700 block mb-1"><?= htmlspecialchars($prod['category_name']) ?></span>
|
|
<a href="/product/<?= $prod['slug'] ?>" class="font-bold text-stone-900 group-hover:text-amber-600 transition text-base block mb-2 leading-snug">
|
|
<?= htmlspecialchars($prod['name']) ?>
|
|
</a>
|
|
<p class="text-xs text-stone-500 line-clamp-2 mb-4 leading-relaxed">
|
|
<?= htmlspecialchars($prod['short_desc']) ?>
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<!-- Price box -->
|
|
<div class="bg-stone-50 p-3 rounded-xl mb-4 border border-stone-100">
|
|
<div class="flex items-center justify-between">
|
|
<span class="text-xs text-stone-500">قیمت مصرفکننده:</span>
|
|
<span class="text-base font-black text-stone-900"><?= \Bildirchin\Helpers::formatPrice($prod['price']) ?></span>
|
|
</div>
|
|
<?php if ((int)$prod['is_wholesale_available'] === 1 && $prod['wholesale_price'] > 0): ?>
|
|
<div class="flex items-center justify-between mt-1 pt-1 border-t border-stone-200/60 text-xs">
|
|
<span class="text-amber-700 font-medium">عمده (از <?= \Bildirchin\Helpers::toPersianDigits($prod['wholesale_min_qty']) ?> <?= $prod['unit'] ?>):</span>
|
|
<span class="font-bold text-emerald-700"><?= \Bildirchin\Helpers::formatPrice($prod['wholesale_price']) ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- Action buttons -->
|
|
<div class="flex items-center gap-2">
|
|
<a href="/product/<?= $prod['slug'] ?>" class="flex-1 text-center py-2.5 px-3 rounded-xl bg-stone-100 hover:bg-stone-200 text-stone-800 text-xs font-bold transition">
|
|
جزییات و خرید
|
|
</a>
|
|
<button onclick="addToCart(<?= $prod['id'] ?>, 1)" class="w-10 h-10 rounded-xl bg-amber-500 hover:bg-amber-600 text-stone-950 flex items-center justify-center transition shadow-sm" title="افزودن به سبد خرید">
|
|
<i class="fas fa-cart-plus"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php
|
|
require __DIR__ . '/../layout/footer.php';
|
|
?>
|