Files
new.rybstock.ru/views/admin/products.php
T
2026-06-04 01:30:45 +03:00

121 lines
4.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
/** @var array<int, array<string, mixed>> $categories */
/** @var array<int, array<string, mixed>> $products */
/** @var string|null $message */
/** @var string|null $error */
?>
<section class="admin-layout">
<div class="panel">
<p class="eyebrow">Админка</p>
<h1>Товары</h1>
<p class="muted">Первичная форма для добавления товара с одной стартовой фасовкой.</p>
<?php if ($message !== null): ?>
<div class="status-box success"><?= e($message) ?></div>
<?php endif; ?>
<?php if ($error !== null): ?>
<div class="status-box danger"><?= e($error) ?></div>
<?php endif; ?>
<form class="admin-form" method="post">
<label>
Категория
<select name="category_id">
<option value="">Без категории</option>
<?php foreach ($categories as $category): ?>
<option value="<?= e((string) $category['id']) ?>"><?= e($category['name']) ?></option>
<?php endforeach; ?>
</select>
</label>
<label>
Название
<input name="name" required>
</label>
<label>
Slug
<input name="slug" required>
</label>
<label>
Краткое описание
<textarea name="short_description" rows="3"></textarea>
</label>
<label>
Title
<input name="seo_title">
</label>
<label>
Description
<textarea name="seo_description" rows="3"></textarea>
</label>
<label>
Keywords
<textarea name="seo_keywords" rows="2"></textarea>
</label>
<label>
Базовая единица
<select name="base_unit">
<option value="kg">кг</option>
<option value="g">г</option>
<option value="l">л</option>
<option value="ml">мл</option>
<option value="pcs">шт</option>
<option value="pack">упаковка</option>
</select>
</label>
<label>
Название фасовки
<input name="variant_name" placeholder="Например: короб 10 кг">
</label>
<label>
Количество в фасовке
<input name="package_quantity" type="number" step="0.001" value="1">
</label>
<label>
Шаг количества
<input name="step_quantity" type="number" step="0.001" value="1">
</label>
<label>
Цена за единицу
<input name="price_per_unit" type="number" step="0.01">
</label>
<label>
Цена за фасовку
<input name="package_price" type="number" step="0.01" value="0">
</label>
<label>
Старая цена для перечеркивания
<input name="old_package_price" type="number" step="0.01" placeholder="Например: 4550">
</label>
<label>
Скидка в процентах
<input name="discount_percent" type="number" min="0" max="99" step="0.01" placeholder="Например: 10">
</label>
<label class="checkbox-label">
<input name="is_published" type="checkbox">
Опубликовать
</label>
<button class="primary-button" type="submit">Добавить товар</button>
</form>
</div>
<div class="panel">
<h2>Последние товары</h2>
<?php if ($products === []): ?>
<p class="muted">Товаров пока нет.</p>
<?php else: ?>
<div class="admin-list">
<?php foreach ($products as $product): ?>
<div>
<strong><?= e($product['name']) ?></strong>
<span><?= e($product['category_name'] ?? 'Без категории') ?></span>
<span><?= !empty($product['is_published']) ? 'Опубликован' : 'Черновик' ?></span>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</section>