Fix
This commit is contained in:
@@ -282,6 +282,34 @@ try {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'order_details':
|
||||
if (isset($_GET['id'])) {
|
||||
$orderId = (int)$_GET['id'];
|
||||
|
||||
// Получаем информацию о заказе
|
||||
$stmt = $db->prepare("
|
||||
SELECT o.*, u.email as user_email, u.full_name as user_full_name
|
||||
FROM orders o
|
||||
LEFT JOIN users u ON o.user_id = u.user_id
|
||||
WHERE o.order_id = ?
|
||||
");
|
||||
$stmt->execute([$orderId]);
|
||||
$order = $stmt->fetch();
|
||||
|
||||
// Получаем товары в заказе
|
||||
if ($order) {
|
||||
$stmt = $db->prepare("
|
||||
SELECT oi.*, p.image_url
|
||||
FROM order_items oi
|
||||
LEFT JOIN products p ON oi.product_id = p.product_id
|
||||
WHERE oi.order_id = ?
|
||||
");
|
||||
$stmt->execute([$orderId]);
|
||||
$order_items = $stmt->fetchAll();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
@@ -296,6 +324,7 @@ try {
|
||||
<base href="/cite_practica/admin/">
|
||||
<title>AETERNA - Админ-панель</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background: #f5f5f5; }
|
||||
.admin-header { background: #453227; color: white; padding: 20px; display: flex; justify-content: space-between; align-items: center; }
|
||||
@@ -501,7 +530,7 @@ try {
|
||||
</a>
|
||||
<button type="button" class="btn btn-danger btn-sm delete-category-btn"
|
||||
data-id="<?= $category['category_id'] ?>"
|
||||
<?= $category['product_count'] > 0 ? 'disabled' : '' ?>>
|
||||
data-has-products="<?= $category['product_count'] > 0 ? '1' : '0' ?>">
|
||||
<i class="fas fa-trash"></i> Удалить
|
||||
</button>
|
||||
</td>
|
||||
@@ -739,47 +768,219 @@ try {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php elseif ($action == 'order_details'): ?>
|
||||
|
||||
<?php if (isset($order) && $order): ?>
|
||||
<div style="margin-bottom: 20px;">
|
||||
<a href="index.php?action=orders" class="btn btn-primary">
|
||||
<i class="fas fa-arrow-left"></i> Назад к заказам
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h2>Детали заказа #<?= htmlspecialchars($order['order_number']) ?></h2>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
|
||||
<!-- Информация о заказе -->
|
||||
<div style="background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
|
||||
<h3 style="margin-top: 0;">Информация о заказе</h3>
|
||||
<table style="width: 100%; border: none;">
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Номер заказа:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['order_number']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Дата создания:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= date('d.m.Y H:i', strtotime($order['created_at'])) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Статус:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;">
|
||||
<span style="padding: 5px 10px; border-radius: 4px; background:
|
||||
<?php
|
||||
echo match($order['status']) {
|
||||
'pending' => '#ffc107',
|
||||
'processing' => '#17a2b8',
|
||||
'completed' => '#28a745',
|
||||
'cancelled' => '#dc3545',
|
||||
default => '#6c757d'
|
||||
};
|
||||
?>; color: white;">
|
||||
<?= htmlspecialchars($order['status']) ?>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Способ оплаты:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= $order['payment_method'] == 'card' ? 'Банковская карта' : 'Наличные' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Способ доставки:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= $order['delivery_method'] == 'courier' ? 'Курьерская доставка' : 'Самовывоз' ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Информация о клиенте -->
|
||||
<div style="background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
|
||||
<h3 style="margin-top: 0;">Информация о клиенте</h3>
|
||||
<table style="width: 100%; border: none;">
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>ФИО:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['customer_name']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Email:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['customer_email']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Телефон:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['customer_phone']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Регион:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['delivery_region'] ?? '—') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Адрес доставки:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['delivery_address']) ?></td>
|
||||
</tr>
|
||||
<?php if (!empty($order['postal_code'])): ?>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;"><strong>Индекс:</strong></td>
|
||||
<td style="border: none; padding: 8px 0;"><?= htmlspecialchars($order['postal_code']) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Товары в заказе -->
|
||||
<div style="background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); margin-bottom: 20px;">
|
||||
<h3 style="margin-top: 0;">Товары в заказе</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>
|
||||
<?php if (!empty($item['image_url'])): ?>
|
||||
<img src="/cite_practica/<?= htmlspecialchars($item['image_url']) ?>"
|
||||
alt="<?= htmlspecialchars($item['product_name']) ?>"
|
||||
style="width: 60px; height: 60px; object-fit: cover; border-radius: 4px;">
|
||||
<?php else: ?>
|
||||
<div style="width: 60px; height: 60px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; border-radius: 4px;">
|
||||
<i class="fas fa-image" style="color: #ccc;"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= htmlspecialchars($item['product_name']) ?></td>
|
||||
<td><?= number_format($item['product_price'], 0, '', ' ') ?> ₽</td>
|
||||
<td><?= $item['quantity'] ?> шт.</td>
|
||||
<td><?= number_format($item['total_price'], 0, '', ' ') ?> ₽</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Итоговая сумма -->
|
||||
<div style="background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); max-width: 400px; margin-left: auto;">
|
||||
<h3 style="margin-top: 0;">Итого</h3>
|
||||
<table style="width: 100%; border: none;">
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;">Товары:</td>
|
||||
<td style="border: none; padding: 8px 0; text-align: right;"><?= number_format($order['subtotal'], 0, '', ' ') ?> ₽</td>
|
||||
</tr>
|
||||
<?php if ($order['discount_amount'] > 0): ?>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;">Скидка:</td>
|
||||
<td style="border: none; padding: 8px 0; text-align: right; color: #28a745;">-<?= number_format($order['discount_amount'], 0, '', ' ') ?> ₽</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td style="border: none; padding: 8px 0;">Доставка:</td>
|
||||
<td style="border: none; padding: 8px 0; text-align: right;"><?= number_format($order['delivery_price'], 0, '', ' ') ?> ₽</td>
|
||||
</tr>
|
||||
<tr style="font-size: 18px; font-weight: bold;">
|
||||
<td style="border: none; padding: 12px 0; border-top: 2px solid #ddd;">Итого к оплате:</td>
|
||||
<td style="border: none; padding: 12px 0; text-align: right; border-top: 2px solid #ddd;"><?= number_format($order['final_amount'], 0, '', ' ') ?> ₽</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($order['notes'])): ?>
|
||||
<div style="background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); margin-top: 20px;">
|
||||
<h3 style="margin-top: 0;">Примечания</h3>
|
||||
<p><?= htmlspecialchars($order['notes']) ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="alert alert-danger">
|
||||
<i class="fas fa-exclamation-circle"></i> Заказ не найден
|
||||
</div>
|
||||
<a href="index.php?action=orders" class="btn btn-primary">Вернуться к списку заказов</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<script>
|
||||
$('.delete-category-btn').click(function() {
|
||||
const categoryId = $(this).data('id');
|
||||
const btn = $(this);
|
||||
$(document).ready(function() {
|
||||
$('.delete-category-btn').click(function() {
|
||||
const categoryId = $(this).data('id');
|
||||
const btn = $(this);
|
||||
|
||||
if (confirm('Удалить эту категорию?')) {
|
||||
$.ajax({
|
||||
url: 'fix_delete_category.php',
|
||||
method: 'POST',
|
||||
data: { category_id: categoryId },
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.success) {
|
||||
alert(result.message);
|
||||
location.reload();
|
||||
} else {
|
||||
alert('Ошибка: ' + result.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX error:', status, error);
|
||||
alert('Ошибка при удалении категории: ' + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#categoryForm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (confirm('Удалить эту категорию?')) {
|
||||
$.ajax({
|
||||
url: 'fix_delete_category.php',
|
||||
url: $(this).attr('action'),
|
||||
method: 'POST',
|
||||
data: { category_id: categoryId },
|
||||
success: function(response) {
|
||||
const result = JSON.parse(response);
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.success) {
|
||||
alert(result.message);
|
||||
location.reload();
|
||||
window.location.href = 'index.php?action=categories';
|
||||
} else {
|
||||
alert('Ошибка: ' + result.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX error:', status, error);
|
||||
alert('Ошибка при сохранении категории');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#categoryForm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr('action'),
|
||||
method: 'POST',
|
||||
data: $(this).serialize(),
|
||||
success: function(response) {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
alert(result.message);
|
||||
window.location.href = 'index.php?action=categories';
|
||||
} else {
|
||||
alert('Ошибка: ' + result.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user