From 9f667f62ba80fa1cc79ddc21143150bb4c28c20b Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 9 Jan 2026 11:12:32 +0000 Subject: [PATCH] =?UTF-8?q?Korekra=20maili=20-=20mail=20potwierdzaj=C4=85c?= =?UTF-8?q?y=20wysy=C5=82k=C4=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/order_details.php | 32 +++++++++++++- debug_price.log | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/admin/order_details.php b/admin/order_details.php index 5ce816f..5b404e0 100644 --- a/admin/order_details.php +++ b/admin/order_details.php @@ -89,6 +89,35 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['status']) && get_user } } + if ($new_status === 'shipped' && $old_status !== 'shipped') { + require_once __DIR__ . '/../mail/MailService.php'; + + // Fetch order and client details for email + $stmt = $pdo->prepare(" + SELECT o.*, c.name as client_company_name, u.email as client_email + FROM orders o + JOIN clients c ON o.client_id = c.id + JOIN users u ON c.id = u.client_id + WHERE o.id = ? AND u.id = (SELECT MIN(id) FROM users WHERE client_id = o.client_id) + "); + $stmt->execute([$order_id]); + $order_details_for_email = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($order_details_for_email && !empty($order_details_for_email['client_email'])) { + $client_email = $order_details_for_email['client_email']; + $order_details_link = get_site_url() . '/order_details.php?id=' . $order_id; + + $subject_client = "Your Order #{$order_id} has been shipped!"; + $body_html_client = "

Great news! Your order #{$order_id} has been shipped.

" + . "

You can track your order and view details here: {$order_details_link}

"; + $body_text_client = "Great news! Your order #{$order_id} has been shipped.\n" + . "You can track your order and view details here: {$order_details_link}"; + + MailService::sendMail($client_email, $subject_client, $body_html_client, $body_text_client); + } + } + + header("Location: order_details.php?id=$order_id"); exit; } @@ -125,7 +154,7 @@ $page_title = 'Szczegóły zamówienia #' . htmlspecialchars($order['id']);
-

+

Szczegóły zamówienia #

Powrót do listy @@ -172,6 +201,7 @@ $page_title = 'Szczegóły zamówienia #' . htmlspecialchars($order['id']);
Podsumowanie
+

Numer zamówienia:

Klient:

Data:

Metoda płatności:

diff --git a/debug_price.log b/debug_price.log index e3005c0..3ba4866 100644 --- a/debug_price.log +++ b/debug_price.log @@ -14619,3 +14619,101 @@ Product price query executed. Found: {"price_net":"233.20","price_gross":"286.84 Found product price. Net: 233.2, Gross: 286.84 FINAL: Returning Net: 233.2, Gross: 286.84 --- +--- +START getEffectivePrice for product 1, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"1111.00","price_gross":"1366.53"} +Found product price. Net: 1111, Gross: 1366.53 +FINAL: Returning Net: 1111, Gross: 1366.53 +--- +--- +START getEffectivePrice for product 2, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"1318.05","price_gross":"1621.20"} +Found product price. Net: 1318.05, Gross: 1621.2 +FINAL: Returning Net: 1318.05, Gross: 1621.2 +--- +--- +START getEffectivePrice for product 3, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"9.95","price_gross":"12.24"} +Found product price. Net: 9.95, Gross: 12.24 +FINAL: Returning Net: 9.95, Gross: 12.24 +--- +--- +START getEffectivePrice for product 4, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"9.95","price_gross":"12.24"} +Found product price. Net: 9.95, Gross: 12.24 +FINAL: Returning Net: 9.95, Gross: 12.24 +--- +--- +START getEffectivePrice for product 5, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"68.00","price_gross":"83.64"} +Found product price. Net: 68, Gross: 83.64 +FINAL: Returning Net: 68, Gross: 83.64 +--- +--- +START getEffectivePrice for product 6, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"171.60","price_gross":"211.07"} +Found product price. Net: 171.6, Gross: 211.07 +FINAL: Returning Net: 171.6, Gross: 211.07 +--- +--- +START getEffectivePrice for product 7, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"233.20","price_gross":"286.84"} +Found product price. Net: 233.2, Gross: 286.84 +FINAL: Returning Net: 233.2, Gross: 286.84 +--- +--- +START getEffectivePrice for product 1, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"1111.00","price_gross":"1366.53"} +Found product price. Net: 1111, Gross: 1366.53 +FINAL: Returning Net: 1111, Gross: 1366.53 +--- +--- +START getEffectivePrice for product 2, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"1318.05","price_gross":"1621.20"} +Found product price. Net: 1318.05, Gross: 1621.2 +FINAL: Returning Net: 1318.05, Gross: 1621.2 +--- +--- +START getEffectivePrice for product 3, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"9.95","price_gross":"12.24"} +Found product price. Net: 9.95, Gross: 12.24 +FINAL: Returning Net: 9.95, Gross: 12.24 +--- +--- +START getEffectivePrice for product 4, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"9.95","price_gross":"12.24"} +Found product price. Net: 9.95, Gross: 12.24 +FINAL: Returning Net: 9.95, Gross: 12.24 +--- +--- +START getEffectivePrice for product 5, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"68.00","price_gross":"83.64"} +Found product price. Net: 68, Gross: 83.64 +FINAL: Returning Net: 68, Gross: 83.64 +--- +--- +START getEffectivePrice for product 6, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"171.60","price_gross":"211.07"} +Found product price. Net: 171.6, Gross: 211.07 +FINAL: Returning Net: 171.6, Gross: 211.07 +--- +--- +START getEffectivePrice for product 7, client +Client price not found or not set, falling back to product price. +Product price query executed. Found: {"price_net":"233.20","price_gross":"286.84"} +Found product price. Net: 233.2, Gross: 286.84 +FINAL: Returning Net: 233.2, Gross: 286.84 +---