[MVC] Полная миграция на MVC архитектуру
- Создано ядро MVC: App, Router, Controller, Model, View, Database - Созданы модели: User, Product, Category, Cart, Order - Созданы контроллеры: Home, Auth, Product, Cart, Order, Page, Admin - Созданы layouts и partials для представлений - Добавлены все views для страниц - Настроена маршрутизация с чистыми URL - Обновлена конфигурация Docker и Apache для mod_rewrite - Добавлена единая точка входа public/index.php
This commit is contained in:
74
app/Views/admin/orders/details.php
Normal file
74
app/Views/admin/orders/details.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php use App\Core\View; ?>
|
||||
|
||||
<a href="/cite_practica/admin/orders" class="btn btn-primary" style="margin-bottom: 20px;">
|
||||
<i class="fas fa-arrow-left"></i> Назад к заказам
|
||||
</a>
|
||||
|
||||
<h2>Заказ <?= htmlspecialchars($order['order_number']) ?></h2>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px;">
|
||||
<div class="form-container">
|
||||
<h3>Информация о заказе</h3>
|
||||
<table style="border: none;">
|
||||
<tr><td><strong>Дата:</strong></td><td><?= View::formatDateTime($order['created_at']) ?></td></tr>
|
||||
<tr><td><strong>Покупатель:</strong></td><td><?= htmlspecialchars($order['customer_name']) ?></td></tr>
|
||||
<tr><td><strong>Email:</strong></td><td><?= htmlspecialchars($order['customer_email']) ?></td></tr>
|
||||
<tr><td><strong>Телефон:</strong></td><td><?= htmlspecialchars($order['customer_phone']) ?></td></tr>
|
||||
<tr><td><strong>Адрес:</strong></td><td><?= htmlspecialchars($order['delivery_address']) ?></td></tr>
|
||||
<tr><td><strong>Способ доставки:</strong></td><td><?= htmlspecialchars($order['delivery_method']) ?></td></tr>
|
||||
<tr><td><strong>Способ оплаты:</strong></td><td><?= htmlspecialchars($order['payment_method']) ?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<h3>Статус заказа</h3>
|
||||
<form action="/cite_practica/admin/orders/<?= $order['order_id'] ?>/status" method="POST">
|
||||
<div class="form-group">
|
||||
<select name="status" class="form-control">
|
||||
<option value="pending" <?= $order['status'] === 'pending' ? 'selected' : '' ?>>Ожидает</option>
|
||||
<option value="processing" <?= $order['status'] === 'processing' ? 'selected' : '' ?>>В обработке</option>
|
||||
<option value="shipped" <?= $order['status'] === 'shipped' ? 'selected' : '' ?>>Отправлен</option>
|
||||
<option value="completed" <?= $order['status'] === 'completed' ? 'selected' : '' ?>>Завершен</option>
|
||||
<option value="cancelled" <?= $order['status'] === 'cancelled' ? 'selected' : '' ?>>Отменен</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Обновить статус</button>
|
||||
</form>
|
||||
|
||||
<h3 style="margin-top: 20px;">Итого</h3>
|
||||
<table style="border: none;">
|
||||
<tr><td>Товары:</td><td><?= View::formatPrice($order['subtotal']) ?></td></tr>
|
||||
<tr><td>Скидка:</td><td>-<?= View::formatPrice($order['discount_amount']) ?></td></tr>
|
||||
<tr><td>Доставка:</td><td><?= View::formatPrice($order['delivery_price']) ?></td></tr>
|
||||
<tr style="font-weight: bold;"><td>ИТОГО:</td><td><?= View::formatPrice($order['final_amount']) ?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top: 30px;">Товары в заказе</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Изображение</th>
|
||||
<th>Товар</th>
|
||||
<th>Цена</th>
|
||||
<th>Кол-во</th>
|
||||
<th>Сумма</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($order['items'] as $item): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="/cite_practica/<?= htmlspecialchars($item['image_url'] ?? 'img/1.jpg') ?>"
|
||||
style="width: 50px; height: 50px; object-fit: cover; border-radius: 4px;">
|
||||
</td>
|
||||
<td><?= htmlspecialchars($item['product_name']) ?></td>
|
||||
<td><?= View::formatPrice($item['product_price']) ?></td>
|
||||
<td><?= $item['quantity'] ?></td>
|
||||
<td><?= View::formatPrice($item['total_price']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
62
app/Views/admin/orders/index.php
Normal file
62
app/Views/admin/orders/index.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php use App\Core\View; ?>
|
||||
|
||||
<h2>Заказы</h2>
|
||||
|
||||
<?php if (empty($orders)): ?>
|
||||
<div class="alert">Заказы отсутствуют</div>
|
||||
<?php else: ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>№ заказа</th>
|
||||
<th>Дата</th>
|
||||
<th>Покупатель</th>
|
||||
<th>Сумма</th>
|
||||
<th>Статус</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($orders as $order): ?>
|
||||
<tr>
|
||||
<td><strong><?= htmlspecialchars($order['order_number']) ?></strong></td>
|
||||
<td><?= View::formatDateTime($order['created_at']) ?></td>
|
||||
<td>
|
||||
<?= htmlspecialchars($order['customer_name']) ?><br>
|
||||
<small><?= htmlspecialchars($order['user_email']) ?></small>
|
||||
</td>
|
||||
<td><?= View::formatPrice($order['final_amount']) ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$statusColors = [
|
||||
'pending' => '#ffc107',
|
||||
'processing' => '#17a2b8',
|
||||
'shipped' => '#007bff',
|
||||
'completed' => '#28a745',
|
||||
'cancelled' => '#dc3545'
|
||||
];
|
||||
$statusNames = [
|
||||
'pending' => 'Ожидает',
|
||||
'processing' => 'Обработка',
|
||||
'shipped' => 'Отправлен',
|
||||
'completed' => 'Завершен',
|
||||
'cancelled' => 'Отменен'
|
||||
];
|
||||
$color = $statusColors[$order['status']] ?? '#666';
|
||||
$name = $statusNames[$order['status']] ?? $order['status'];
|
||||
?>
|
||||
<span style="background: <?= $color ?>; color: white; padding: 3px 10px; border-radius: 4px; font-size: 12px;">
|
||||
<?= $name ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/cite_practica/admin/orders/<?= $order['order_id'] ?>" class="btn btn-sm btn-primary">
|
||||
<i class="fas fa-eye"></i> Подробнее
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user