шаг 4 завершен
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var array<int, array<string, mixed>> $categories */
|
||||
/** @var array<int, array<string, mixed>> $flatCategories */
|
||||
/** @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="parent_id">
|
||||
<option value="">Без родителя</option>
|
||||
<?php foreach ($flatCategories 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>
|
||||
H1
|
||||
<input name="h1">
|
||||
</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>
|
||||
Сортировка
|
||||
<input name="sort_order" type="number" value="100">
|
||||
</label>
|
||||
<label class="checkbox-label">
|
||||
<input name="is_active" type="checkbox" checked>
|
||||
Активна
|
||||
</label>
|
||||
<button class="primary-button" type="submit">Добавить категорию</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h2>Текущее дерево</h2>
|
||||
<?php
|
||||
$items = $categories;
|
||||
$depth = 0;
|
||||
$currentSlug = '';
|
||||
require base_path('views/partials/category-tree.php');
|
||||
?>
|
||||
</div>
|
||||
</section>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user