Korekty błędów po spotkaniu 22.12
This commit is contained in:
parent
b56539d828
commit
d4180cc06e
@ -333,6 +333,7 @@ $page_title = $product['id'] ? 'Edytuj produkt' : 'Dodaj produkt';
|
|||||||
<option value="szt" <?= ($product['unit'] ?? 'szt') === 'szt' ? 'selected' : '' ?>><?= t('szt') ?></option>
|
<option value="szt" <?= ($product['unit'] ?? 'szt') === 'szt' ? 'selected' : '' ?>><?= t('szt') ?></option>
|
||||||
<option value="mb" <?= ($product['unit'] ?? 'szt') === 'mb' ? 'selected' : '' ?>><?= t('mb') ?></option>
|
<option value="mb" <?= ($product['unit'] ?? 'szt') === 'mb' ? 'selected' : '' ?>><?= t('mb') ?></option>
|
||||||
<option value="m2" <?= ($product['unit'] ?? 'szt') === 'm2' ? 'selected' : '' ?>><?= t('m2') ?></option>
|
<option value="m2" <?= ($product['unit'] ?? 'szt') === 'm2' ? 'selected' : '' ?>><?= t('m2') ?></option>
|
||||||
|
<option value="rolka" <?= ($product['unit'] ?? 'szt') === 'rolka' ? 'selected' : '' ?>><?= t('rolka') ?></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../includes/auth.php';
|
require_once '../includes/init.php';
|
||||||
|
require_once '../includes/auth.php';
|
||||||
require_role('admin');
|
require_role('admin');
|
||||||
require_once __DIR__ . '/../db/config.php';
|
require_once __DIR__ . '/../db/config.php';
|
||||||
$pdo = db();
|
$pdo = db();
|
||||||
|
|||||||
@ -133,6 +133,11 @@ $pageTitle = 'Szczegóły zamówienia #' . htmlspecialchars($order['id']);
|
|||||||
<p><strong>Data:</strong> <?php echo date('d.m.Y H:i', strtotime($order['created_at'])); ?></p>
|
<p><strong>Data:</strong> <?php echo date('d.m.Y H:i', strtotime($order['created_at'])); ?></p>
|
||||||
<p><strong>Metoda płatności:</strong> <span class="badge bg-secondary"><?php echo htmlspecialchars(get_payment_method_translation_local($order['payment_method'], $i18n)); ?></span></p>
|
<p><strong>Metoda płatności:</strong> <span class="badge bg-secondary"><?php echo htmlspecialchars(get_payment_method_translation_local($order['payment_method'], $i18n)); ?></span></p>
|
||||||
<p><strong>Suma (brutto):</strong> <strong class="fs-5"><?php echo number_format($order['total_amount'], 2, ',', ' '); ?> zł</strong></p>
|
<p><strong>Suma (brutto):</strong> <strong class="fs-5"><?php echo number_format($order['total_amount'], 2, ',', ' '); ?> zł</strong></p>
|
||||||
|
<?php if (!empty($order['notes'])): ?>
|
||||||
|
<hr>
|
||||||
|
<p><strong>Uwagi do zamówienia:</strong></p>
|
||||||
|
<p><?php echo nl2br(htmlspecialchars($order['notes'])); ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|||||||
102
admin/orders.php
102
admin/orders.php
@ -4,6 +4,13 @@ session_start();
|
|||||||
require_once __DIR__ . '/../includes/auth.php';
|
require_once __DIR__ . '/../includes/auth.php';
|
||||||
require_role('admin');
|
require_role('admin');
|
||||||
require_once __DIR__ . '/../includes/helpers.php';
|
require_once __DIR__ . '/../includes/helpers.php';
|
||||||
|
require_once __DIR__ . '/../includes/i18n.php';
|
||||||
|
|
||||||
|
function t_filter_status($status) {
|
||||||
|
if ($status === 'new_today') return 'Nowe (dziś)';
|
||||||
|
if ($status === 'new_week') return 'Nowe (tydzień)';
|
||||||
|
return t_status($status);
|
||||||
|
}
|
||||||
|
|
||||||
$pdotry = null;
|
$pdotry = null;
|
||||||
$error = null;
|
$error = null;
|
||||||
@ -15,11 +22,13 @@ $stats = [
|
|||||||
'in_progress' => 0,
|
'in_progress' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$filter_status = $_GET['status'] ?? null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pdo = db();
|
$pdo = db();
|
||||||
|
|
||||||
// Fetch all orders with customer information
|
// Fetch orders with customer information based on filter
|
||||||
$stmt = $pdo->query("
|
$sql = "
|
||||||
SELECT
|
SELECT
|
||||||
o.id,
|
o.id,
|
||||||
c.name as client_company_name,
|
c.name as client_company_name,
|
||||||
@ -29,10 +38,34 @@ try {
|
|||||||
o.delivery_source
|
o.delivery_source
|
||||||
FROM orders o
|
FROM orders o
|
||||||
LEFT JOIN clients c ON o.client_id = c.id
|
LEFT JOIN clients c ON o.client_id = c.id
|
||||||
ORDER BY o.created_at DESC
|
";
|
||||||
");
|
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
if ($filter_status) {
|
||||||
|
switch ($filter_status) {
|
||||||
|
case 'new_today':
|
||||||
|
$sql .= " WHERE o.created_at >= :today_start";
|
||||||
|
$params[':today_start'] = date('Y-m-d 00:00:00');
|
||||||
|
break;
|
||||||
|
case 'new_week':
|
||||||
|
$sql .= " WHERE o.created_at >= :week_start";
|
||||||
|
$params[':week_start'] = date('Y-m-d 00:00:00', strtotime('-7 days'));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sql .= " WHERE o.status = :status";
|
||||||
|
$params[':status'] = $filter_status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= " ORDER BY o.created_at DESC";
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
$orders = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$orders = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|
||||||
// Fetch stats
|
// Fetch stats
|
||||||
$today_start = date('Y-m-d 00:00:00');
|
$today_start = date('Y-m-d 00:00:00');
|
||||||
$week_start = date('Y-m-d 00:00:00', strtotime('-7 days'));
|
$week_start = date('Y-m-d 00:00:00', strtotime('-7 days'));
|
||||||
@ -78,43 +111,60 @@ $pageTitle = "Zarządzanie zamówieniami";
|
|||||||
|
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="card text-center">
|
<a href="?status=new_today" class="text-decoration-none">
|
||||||
<div class="card-body">
|
<div class="card text-center">
|
||||||
<h5 class="card-title">Nowe (dziś)</h5>
|
<div class="card-body">
|
||||||
<p class="card-text fs-4"><?= $stats['new_today'] ?></p>
|
<h5 class="card-title">Nowe (dziś)</h5>
|
||||||
|
<p class="card-text fs-4"><?= $stats['new_today'] ?></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="card text-center">
|
<a href="?status=new_week" class="text-decoration-none">
|
||||||
<div class="card-body">
|
<div class="card text-center">
|
||||||
<h5 class="card-title">Nowe (tydzień)</h5>
|
<div class="card-body">
|
||||||
<p class="card-text fs-4"><?= $stats['new_week'] ?></p>
|
<h5 class="card-title">Nowe (tydzień)</h5>
|
||||||
|
<p class="card-text fs-4"><?= $stats['new_week'] ?></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="card text-center text-bg-warning">
|
<a href="?status=pending_payment" class="text-decoration-none">
|
||||||
<div class="card-body">
|
<div class="card text-center text-bg-warning">
|
||||||
<h5 class="card-title">Do zapłaty</h5>
|
<div class="card-body">
|
||||||
<p class="card-text fs-4"><?= $stats['awaiting_payment'] ?></p>
|
<h5 class="card-title">Do zapłaty</h5>
|
||||||
|
<p class="card-text fs-4"><?= $stats['awaiting_payment'] ?></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="card text-center text-bg-info">
|
<a href="?status=in_progress" class="text-decoration-none">
|
||||||
<div class="card-body">
|
<div class="card text-center text-bg-info">
|
||||||
<h5 class="card-title">W realizacji</h5>
|
<div class="card-body">
|
||||||
<p class="card-text fs-4"><?= $stats['in_progress'] ?></p>
|
<h5 class="card-title">W realizacji</h5>
|
||||||
|
<p class="card-text fs-4"><?= $stats['in_progress'] ?></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
Wszystkie zamówienia
|
<?php
|
||||||
|
$list_title = 'Wszystkie zamówienia';
|
||||||
|
if ($filter_status) {
|
||||||
|
$list_title = 'Filtrowane: ' . t_filter_status($filter_status);
|
||||||
|
}
|
||||||
|
echo htmlspecialchars($list_title);
|
||||||
|
if ($filter_status) {
|
||||||
|
echo '<a href="orders.php" class="btn btn-sm btn-secondary float-end">Wyczyść filtr</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
@ -140,7 +190,7 @@ $pageTitle = "Zarządzanie zamówieniami";
|
|||||||
<td>#<?= htmlspecialchars($order['id']) ?></td>
|
<td>#<?= htmlspecialchars($order['id']) ?></td>
|
||||||
<td><?= htmlspecialchars($order['client_company_name'] ?? 'Klient indywidualny') ?></td>
|
<td><?= htmlspecialchars($order['client_company_name'] ?? 'Klient indywidualny') ?></td>
|
||||||
<td><?= date('d.m.Y H:i', strtotime($order['created_at'])) ?></td>
|
<td><?= date('d.m.Y H:i', strtotime($order['created_at'])) ?></td>
|
||||||
<td><span class="badge bg-info"><?= htmlspecialchars($order['status']) ?></span></td>
|
<td><span class="badge bg-info"><?= t_status($order['status']) ?></span></td>
|
||||||
<td><?= htmlspecialchars($order['delivery_source'] ?? 'N/A') ?></td>
|
<td><?= htmlspecialchars($order['delivery_source'] ?? 'N/A') ?></td>
|
||||||
<td><?= htmlspecialchars(number_format($order['total_amount'], 2, ',', ' ')) ?> zł</td>
|
<td><?= htmlspecialchars(number_format($order['total_amount'], 2, ',', ' ')) ?> zł</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@ -68,8 +68,7 @@ $page_title = 'Użytkownicy';
|
|||||||
<td>
|
<td>
|
||||||
<a href="edit_user.php?id=<?php echo $user['id']; ?>" class="btn btn-sm btn-secondary">
|
<a href="edit_user.php?id=<?php echo $user['id']; ?>" class="btn btn-sm btn-secondary">
|
||||||
<i class="bi bi-pencil-fill"></i> Edytuj
|
<i class="bi bi-pencil-fill"></i> Edytuj
|
||||||
</a>
|
</a> </td>
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
3759
debug_price.log
3759
debug_price.log
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,28 @@ $current_lang = get_lang();
|
|||||||
<a class="navbar-brand" href="<?php echo BASE_URL; ?>index.php">
|
<a class="navbar-brand" href="<?php echo BASE_URL; ?>index.php">
|
||||||
<img src="<?php echo BASE_URL; ?>assets/pasted-20251209-065617-6bf1b4e6.png" alt="Logo" style="height: 40px;">
|
<img src="<?php echo BASE_URL; ?>assets/pasted-20251209-065617-6bf1b4e6.png" alt="Logo" style="height: 40px;">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<div class="position-absolute start-50 translate-middle-x">
|
||||||
|
<div class="d-flex flex-column align-items-center">
|
||||||
|
<span style="font-family: 'Montserrat', sans-serif; font-size: 20px; color: #333; white-space: nowrap;">ExTrading e-commerce</span>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['user_id']) && $_SESSION['user_role'] !== 'admin' && isset($_SESSION['client_id'])) {
|
||||||
|
$client_id = $_SESSION['client_id'];
|
||||||
|
$stmt = db()->prepare("SELECT credit_limit, credit_balance FROM clients WHERE id = ?");
|
||||||
|
$stmt->execute([$client_id]);
|
||||||
|
$client_credit = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($client_credit) {
|
||||||
|
echo "<span class='text-muted' style='font-size: 12px;'>";
|
||||||
|
echo t('credit_limit') . ": " . format_money($client_credit['credit_limit'], $current_lang, db());
|
||||||
|
echo " | " . t('credit_balance') . ": " . format_money($client_credit['credit_balance'], $current_lang, db());
|
||||||
|
echo "</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -15,6 +15,11 @@
|
|||||||
<meta property="og:image" content="<?= htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '') ?>">
|
<meta property="og:image" content="<?= htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '') ?>">
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
|
||||||
|
<!-- Google Fonts -->
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
<!-- Bootstrap 5.3 CSS -->
|
<!-- Bootstrap 5.3 CSS -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
|||||||
@ -173,13 +173,18 @@ $translations = [
|
|||||||
'szt' => 'sztuka',
|
'szt' => 'sztuka',
|
||||||
'mb' => 'metr bieżący',
|
'mb' => 'metr bieżący',
|
||||||
'm2' => 'metr kwadratowy',
|
'm2' => 'metr kwadratowy',
|
||||||
|
'rolka' => 'rolka',
|
||||||
'login_email' => 'Adres e-mail',
|
'login_email' => 'Adres e-mail',
|
||||||
'login_password' => 'Hasło',
|
'login_password' => 'Hasło',
|
||||||
|
'credit_limit' => 'Limit kredytowy',
|
||||||
|
'credit_balance' => 'Saldo kredytowe',
|
||||||
],
|
],
|
||||||
'en' => [
|
'en' => [
|
||||||
'login_header' => 'Login',
|
'login_header' => 'Login',
|
||||||
'username' => 'Username',
|
'username' => 'Username',
|
||||||
'password' => 'Password',
|
'password' => 'Password',
|
||||||
|
'credit_limit' => 'Credit limit',
|
||||||
|
'credit_balance' => 'Credit balance',
|
||||||
'login_button' => 'Login',
|
'login_button' => 'Login',
|
||||||
'login_failed' => 'Login failed',
|
'login_failed' => 'Login failed',
|
||||||
'logout_link' => 'Logout',
|
'logout_link' => 'Logout',
|
||||||
@ -345,6 +350,7 @@ $translations = [
|
|||||||
'szt' => 'piece',
|
'szt' => 'piece',
|
||||||
'mb' => 'linear meter',
|
'mb' => 'linear meter',
|
||||||
'm2' => 'square meter',
|
'm2' => 'square meter',
|
||||||
|
'rolka' => 'roll',
|
||||||
'login_email' => 'Email',
|
'login_email' => 'Email',
|
||||||
'login_password' => 'Password',
|
'login_password' => 'Password',
|
||||||
],
|
],
|
||||||
|
|||||||
@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
case 'admin':
|
case 'admin':
|
||||||
case 'finance':
|
case 'finance':
|
||||||
case 'support':
|
case 'support':
|
||||||
header('Location: /admin/products.php');
|
header('Location: /admin/orders.php');
|
||||||
break;
|
break;
|
||||||
case 'client':
|
case 'client':
|
||||||
header('Location: /index.php');
|
header('Location: /index.php');
|
||||||
@ -44,7 +44,7 @@ if (is_logged_in()) {
|
|||||||
case 'admin':
|
case 'admin':
|
||||||
case 'finance':
|
case 'finance':
|
||||||
case 'support':
|
case 'support':
|
||||||
header('Location: /admin/products.php');
|
header('Location: /admin/orders.php');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
header('Location: /index.php');
|
header('Location: /index.php');
|
||||||
|
|||||||
@ -21,7 +21,19 @@ $user_id = $_SESSION['user_id'];
|
|||||||
|
|
||||||
// Fetch details for the added product, including the primary image
|
// Fetch details for the added product, including the primary image
|
||||||
$stmt = $db->prepare(
|
$stmt = $db->prepare(
|
||||||
"SELECT\n p.id,\n p.name,\n p.unit,\n p.price_net,\n p.price_gross,\n pi.file_path AS primary_image\n FROM products p\n LEFT JOIN product_images pi ON pi.product_id = p.id AND pi.is_primary = 1\n WHERE p.id = :product_id\n");
|
"SELECT
|
||||||
|
p.id,
|
||||||
|
p.name,
|
||||||
|
p.unit,
|
||||||
|
p.price_net,
|
||||||
|
p.price_gross,
|
||||||
|
COALESCE(
|
||||||
|
(SELECT CONCAT('uploads/products/', pi.file_path) FROM product_images pi WHERE pi.product_id = p.id AND pi.is_primary = 1),
|
||||||
|
(SELECT CONCAT('uploads/products/', pi.file_path) FROM product_images pi WHERE pi.product_id = p.id ORDER BY pi.id ASC LIMIT 1)
|
||||||
|
) AS primary_image
|
||||||
|
FROM products p
|
||||||
|
WHERE p.id = :product_id"
|
||||||
|
);
|
||||||
$stmt->execute(['product_id' => $product_id]);
|
$stmt->execute(['product_id' => $product_id]);
|
||||||
$added_product = $stmt->fetch(PDO::FETCH_ASSOC);
|
$added_product = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
@ -41,7 +53,21 @@ if (empty($added_product['primary_image'])) {
|
|||||||
|
|
||||||
// Fetch related products (accessories)
|
// Fetch related products (accessories)
|
||||||
$related_products_stmt = $db->prepare(
|
$related_products_stmt = $db->prepare(
|
||||||
"SELECT\n p.id,\n p.name,\n p.unit,\n p.price_net,\n p.price_gross,\n pi.file_path as primary_image\n FROM products p\n JOIN product_relations pr ON p.id = pr.related_product_id\n LEFT JOIN product_images pi ON p.id = pi.product_id AND pi.is_primary = 1\n WHERE pr.product_id = :product_id AND p.product_role = 'akcesoria'\n");
|
"SELECT
|
||||||
|
p.id,
|
||||||
|
p.name,
|
||||||
|
p.unit,
|
||||||
|
p.price_net,
|
||||||
|
p.price_gross,
|
||||||
|
COALESCE(
|
||||||
|
(SELECT CONCAT('uploads/products/', pi.file_path) FROM product_images pi WHERE pi.product_id = p.id AND pi.is_primary = 1),
|
||||||
|
(SELECT CONCAT('uploads/products/', pi.file_path) FROM product_images pi WHERE pi.product_id = p.id ORDER BY pi.id ASC LIMIT 1)
|
||||||
|
) AS primary_image
|
||||||
|
FROM products p
|
||||||
|
JOIN product_relations pr ON p.id = pr.related_product_id
|
||||||
|
WHERE pr.product_id = :product_id AND p.product_role = 'akcesoria'
|
||||||
|
GROUP BY p.id
|
||||||
|
");
|
||||||
$related_products_stmt->execute(['product_id' => $product_id]);
|
$related_products_stmt->execute(['product_id' => $product_id]);
|
||||||
$related_products = $related_products_stmt->fetchAll(PDO::FETCH_ASSOC);
|
$related_products = $related_products_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user