шаг 3 завершен

This commit is contained in:
Alisa
2026-06-04 00:27:17 +03:00
parent 420e67c9bd
commit 62ce8c4d01
27 changed files with 1565 additions and 42 deletions
+19 -1
View File
@@ -4,16 +4,34 @@ declare(strict_types=1);
/** @var string $templatePath */
/** @var string $title */
/** @var string $metaDescription */
/** @var string $metaKeywords */
/** @var array<int, array{title: string, url?: string}> $breadcrumbs */
/** @var bool $showBackButton */
?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= htmlspecialchars($title ?? 'Рыбсток', ENT_QUOTES, 'UTF-8') ?></title>
<title><?= e($title) ?></title>
<?php if ($metaDescription !== ''): ?>
<meta name="description" content="<?= e($metaDescription) ?>">
<?php endif; ?>
<?php if ($metaKeywords !== ''): ?>
<meta name="keywords" content="<?= e($metaKeywords) ?>">
<?php endif; ?>
<link rel="stylesheet" href="/assets/css/app.css">
</head>
<body>
<header class="site-utility">
<?php if ($showBackButton): ?>
<button class="back-button" type="button" onclick="history.length > 1 ? history.back() : location.href='/'">Вернуться назад</button>
<?php endif; ?>
<?php require base_path('views/partials/breadcrumbs.php'); ?>
</header>
<main class="page">
<?php require $templatePath; ?>
</main>
+121 -4
View File
@@ -3,14 +3,131 @@
declare(strict_types=1);
/** @var string $dbStatus */
/** @var array<int, array<string, mixed>> $categories */
/** @var array<int, array<string, mixed>> $catalogProducts */
/** @var array<int, array<string, mixed>> $popularProducts */
/** @var array<string, mixed> $settings */
/** @var string|null $notice */
/** @var string $buildVersion */
?>
<section class="start-screen">
<p class="eyebrow">Старт проекта</p>
<section class="start-screen wide">
<p class="eyebrow">Шаг 3</p>
<h1>Рыбсток</h1>
<p>Чистый PHP-проект подготовлен. Следующий шаг - схема базы данных и таблицы для каталога, фасовок, заказов и админки.</p>
<p>Каталог открывается уже на главной странице, чтобы покупатель сразу видел ассортимент и не делал лишних переходов.</p>
<p class="muted">Версия сборки: <?= e($buildVersion) ?></p>
<div class="status-box">
<span>MariaDB:</span>
<strong><?= htmlspecialchars($dbStatus, ENT_QUOTES, 'UTF-8') ?></strong>
<strong><?= e($dbStatus) ?></strong>
</div>
<?php if ($notice !== null): ?>
<div class="status-box danger"><?= e($notice) ?></div>
<?php endif; ?>
<div class="content-grid">
<section class="panel">
<h2>Категории</h2>
<?php if ($categories === []): ?>
<p class="muted">Категории пока не найдены. Если схема уже применена, проверьте `database/seed.sql`.</p>
<?php else: ?>
<?php
$items = $categories;
$depth = 0;
require base_path('views/partials/category-tree.php');
?>
<?php endif; ?>
</section>
<section class="panel">
<h2>Настройки доставки</h2>
<dl class="settings-list">
<div>
<dt>Внутри МКАД бесплатно от</dt>
<dd><?= e((string) ($settings['inside_mkad_free_from'] ?? '5000')) ?> руб.</dd>
</div>
<div>
<dt>Внутри МКАД платно</dt>
<dd><?= e((string) ($settings['inside_mkad_paid_price'] ?? '599')) ?> руб.</dd>
</div>
<div>
<dt>За МКАД расчет</dt>
<dd><?= e((string) ($settings['outside_mkad_base_price'] ?? '199')) ?> руб. + <?= e((string) ($settings['outside_mkad_km_price'] ?? '60')) ?> руб./км</dd>
</div>
<div>
<dt>Подъем</dt>
<dd><?= e((string) ($settings['lift_price'] ?? '390')) ?> руб.</dd>
</div>
</dl>
</section>
</div>
<section class="panel products-panel">
<div class="section-heading">
<div>
<p class="eyebrow">Каталог продукции</p>
<h2>Товары на главной</h2>
</div>
<a class="subtle-link" href="/catalog">Весь каталог</a>
</div>
<?php if ($catalogProducts === []): ?>
<p class="muted">После наполнения базы товары будут отображаться здесь сразу на главной странице.</p>
<?php else: ?>
<div class="product-grid">
<?php foreach ($catalogProducts as $product): ?>
<article class="product-card">
<p class="product-category"><?= e($product['category_name'] ?? 'Каталог') ?></p>
<h3><?= e($product['name']) ?></h3>
<p><?= e($product['variant_name'] ?? 'Выберите доступную фасовку') ?></p>
<?php if ($product['price_per_unit'] !== null): ?>
<span class="price-line">за <?= e($product['unit'] ?? 'ед.') ?>: <?= e((string) $product['price_per_unit']) ?> руб.</span>
<?php endif; ?>
<?php if ($product['package_price'] !== null): ?>
<strong><?= e((string) $product['package_price']) ?> руб. за фасовку</strong>
<?php endif; ?>
<?php if (!empty($product['price_tiers'])): ?>
<ul class="price-tiers">
<?php foreach ($product['price_tiers'] as $tier): ?>
<li>
<span><?= e($tier['label']) ?></span>
<strong><?= e((string) $tier['price']) ?> руб.</strong>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<section class="panel products-panel">
<h2>Популярные товары</h2>
<?php if ($popularProducts === []): ?>
<p class="muted">Товары появятся здесь после наполнения каталога и публикации фасовок.</p>
<?php else: ?>
<div class="product-grid">
<?php foreach ($popularProducts as $product): ?>
<article class="product-card">
<h3><?= e($product['name']) ?></h3>
<p><?= e($product['variant_name'] ?? 'Фасовка не выбрана') ?></p>
<?php if ($product['package_price'] !== null): ?>
<strong><?= e((string) $product['package_price']) ?> руб.</strong>
<?php endif; ?>
<?php if (!empty($product['price_tiers'])): ?>
<ul class="price-tiers">
<?php foreach ($product['price_tiers'] as $tier): ?>
<li>
<span><?= e($tier['label']) ?></span>
<strong><?= e((string) $tier['price']) ?> руб.</strong>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
</section>
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/** @var array<int, array{title: string, url?: string}> $breadcrumbs */
?>
<?php if ($breadcrumbs !== []): ?>
<nav class="breadcrumbs" aria-label="Хлебные крошки">
<?php foreach ($breadcrumbs as $index => $item): ?>
<?php if ($index > 0): ?>
<span class="breadcrumbs-separator">/</span>
<?php endif; ?>
<?php if (!empty($item['url']) && $index < count($breadcrumbs) - 1): ?>
<a href="<?= e($item['url']) ?>"><?= e($item['title']) ?></a>
<?php else: ?>
<span><?= e($item['title']) ?></span>
<?php endif; ?>
<?php endforeach; ?>
</nav>
<?php endif; ?>
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
/** @var array<int, array<string, mixed>> $items */
/** @var int $depth */
?>
<ul class="category-list depth-<?= e((string) $depth) ?>">
<?php foreach ($items as $category): ?>
<li>
<a href="/catalog/<?= e($category['slug']) ?>"><?= e($category['name']) ?></a>
<?php if (!empty($category['children'])): ?>
<?php
$previousItems = $items;
$items = $category['children'];
$depth++;
require __DIR__ . '/category-tree.php';
$depth--;
$items = $previousItems;
?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>