Poprawione maile

This commit is contained in:
Flatlogic Bot 2025-12-28 17:47:10 +00:00
parent 76dbc45562
commit ae3b136175
18 changed files with 1827 additions and 105 deletions

View File

@ -9,6 +9,12 @@ body {
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
border-radius: 0.5rem;
border: 1px solid #dee2e6;
padding-bottom: 1rem;
}
.product-card .card-footer {
padding-left: 1rem;
padding-right: 1rem;
}
.product-card:hover {

File diff suppressed because it is too large Load Diff

View File

@ -178,6 +178,9 @@ $translations = [
'login_password' => 'Hasło',
'credit_limit' => 'Limit kredytowy',
'credit_balance' => 'Saldo kredytowe',
'order_summary' => 'Podsumowanie zamówienia',
'grand_total' => 'Suma całkowita',
'price' => 'Cena',
],
'en' => [
'login_header' => 'Login',
@ -353,6 +356,9 @@ $translations = [
'rolka' => 'roll',
'login_email' => 'Email',
'login_password' => 'Password',
'order_summary' => 'Order Summary',
'grand_total' => 'Grand Total',
'price' => 'Price',
],
];

View File

@ -131,7 +131,7 @@ try {
<p class="card-text fw-bold"><?= format_money($prices['gross'], $_SESSION['lang'] ?? 'pl', $pdo) ?> <?= t('gross') ?></p>
</div>
</div>
<div class.card-footer bg-white border-top-0 pb-3">
<div class="card-footer bg-white border-top-0 pb-3">
<form action="cart_actions.php" method="POST" class="d-grid">
<input type="hidden" name="action" value="add">
<input type="hidden" name="product_id" value="<?= $product['id'] ?>">

View File

@ -9,6 +9,51 @@
class MailService
{
public static function sendTemplatedMail($to, string $language, string $template_name, array $data = [], array $opts = [])
{
$base_path = __DIR__ . '/../templates/mail/';
$template_path = $base_path . "$language/$template_name.php";
if (!file_exists($template_path)) {
// Fallback to English if the language template doesn't exist
$template_path = $base_path . "en/$template_name.php";
}
if (!file_exists($template_path)) {
return ['success' => false, 'error' => "Email template not found: $template_name"];
}
// Make data available to the template
$db = db();
$data['db'] = $db;
$data['lang'] = $language;
extract($data);
$lang = $language;
// Include helpers that might be used in templates
require_once __DIR__ . '/../includes/currency.php';
// Render the email body template
ob_start();
include $template_path;
$body = ob_get_clean();
// The template should define the subject
if (!isset($subject)) {
$subject = 'Notification from ' . ($data['site_name'] ?? 'our site');
}
// Render the main layout, passing in the generated body
ob_start();
include $base_path . 'layout.php';
$htmlBody = ob_get_clean();
// Create a text-only version
$textBody = strip_tags(html_entity_decode($htmlBody));
return self::sendMail($to, $subject, $htmlBody, $textBody, $opts);
}
// Universal mail sender (no attachments by design)
public static function sendMail($to, string $subject, string $htmlBody, ?string $textBody = null, array $opts = [])
{
@ -158,28 +203,22 @@ class MailService
{
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
try {
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP();
$mail->Host = $cfg['smtp_host'] ?? '';
error_log('SMTP Host: ' . $mail->Host);
$mail->Port = (int)($cfg['smtp_port'] ?? 587);
error_log('SMTP Port: ' . $mail->Port);
$secure = $cfg['smtp_secure'] ?? 'tls';
if ($secure === 'ssl') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS;
elseif ($secure === 'tls') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
else $mail->SMTPSecure = false;
error_log('SMTP Secure: ' . $secure);
$mail->SMTPSecure = false;
$mail->SMTPAuth = true;
$mail->Username = $cfg['smtp_user'] ?? '';
error_log('SMTP User: ' . $mail->Username);
$mail->Password = $cfg['smtp_pass'] ?? '';
// Do not log password for security reasons
$fromEmail = $cfg['from_email'] ?? 'no-reply@localhost';
$fromName = $cfg['from_name'] ?? 'App';
$mail->setFrom($fromEmail, $fromName);
error_log('From Email: ' . $fromEmail);
error_log('From Name: ' . $fromName);
// Use Reply-To for the user's email to avoid spoofing From
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {

View File

@ -2,7 +2,7 @@
require_once __DIR__ . '/includes/init.php';
require_login();
$order_id = isset($_GET['order_id']) ? (int)$_GET['order_id'] : 0;
$order_id = $_SESSION['latest_order_id'] ?? 0;
if ($order_id === 0) {
header('Location: orders.php');
@ -10,8 +10,8 @@ if ($order_id === 0) {
}
$db = db();
$stmt = $db->prepare("SELECT * FROM orders WHERE id = ? AND user_id = ?");
$stmt->execute([$order_id, $_SESSION['user_id']]);
$stmt = $db->prepare("SELECT * FROM orders WHERE id = ? AND client_id = ?");
$stmt->execute([$order_id, $_SESSION['client_id']]);
$order = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$order) {
@ -19,18 +19,67 @@ if (!$order) {
exit;
}
// Fetch order items
$stmt = $db->prepare("
SELECT oi.*, p.name as product_name
FROM order_items oi
JOIN products p ON oi.product_id = p.id
WHERE oi.order_id = ?
");
$stmt->execute([$order_id]);
$order_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$page_title = t('order_confirmation');
require_once __DIR__ . '/includes/html_head.php';
require_once __DIR__ . '/includes/header.php';
?>
<div class="container mt-5">
<div class="alert alert-success" role="alert">
<h4 class="alert-heading"><?= t('thank_you_for_your_order') ?></h4>
<p><?= t('your_order_number') ?> <strong>#<?php echo $order['id']; ?></strong> <?= t('has_been_placed_successfully') ?></p>
<hr>
<p class="mb-0"><?= t('order_details_will_be_sent') ?> <a href="orders.php"><?= t('orders') ?></a>.</p>
<div class="card">
<div class="card-header bg-success text-white">
<h4 class="mb-0"><?= t('thank_you_for_your_order') ?></h4>
</div>
<div class="card-body">
<p><?= t('your_order_number') ?> <strong>#<?php echo $order['id']; ?></strong> <?= t('has_been_placed_successfully') ?></p>
<hr>
<h5 class="mt-4"><?= t('order_summary') ?></h5>
<table class="table table-bordered">
<thead>
<tr>
<th><?= t('product') ?></th>
<th><?= t('quantity') ?></th>
<th><?= t('price') ?></th>
<th><?= t('total') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($order_items as $item) : ?>
<tr>
<td><?php echo htmlspecialchars($item['product_name']); ?></td>
<td><?php echo $item['quantity']; ?></td>
<td><?php echo format_money($item['unit_price'], get_lang(), $db); ?></td>
<td><?php echo format_money($item['line_total'], get_lang(), $db); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th colspan="3" class="text-right"><?= t('grand_total') ?></th>
<th><?php echo format_money($order['total_amount'], get_lang(), $db); ?></th>
</tr>
</tfoot>
</table>
<p class="mb-0 mt-4"><?= t('order_details_will_be_sent') ?> <a href="orders.php"><?= t('orders') ?></a>.</p>
</div>
<div class="card-footer">
<a href="index.php" class="btn btn-primary"><?= t('continue_shopping') ?></a>
</div>
</div>
<a href="index.php" class="btn btn-primary"><?= t('continue_shopping') ?></a>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>
<?php
// Unset the session variable so it's not shown again on refresh
unset($_SESSION['latest_order_id']);
require_once __DIR__ . '/includes/footer.php';
?>

View File

@ -127,105 +127,78 @@ try {
$client = $stmt->fetch();
$client_company_name = $client['name'] ?? 'N/A';
$product_list_html = '<ul>';
$product_list_text = '';
$product_ids_for_names = array_map(function($item) { return $item['product_id']; }, $order_items_data);
$placeholders = implode(',', array_fill(0, count($product_ids_for_names), '?'));
$stmt = $pdo->prepare("SELECT id, name FROM products WHERE id IN ($placeholders)");
$stmt->execute($product_ids_for_names);
$products_by_id_for_email = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
foreach ($order_items_data as $item) {
$product_name = $products_by_id_for_email[$item['product_id']] ?? 'Unknown Product';
$product_list_html .= "<li>{$product_name} (Quantity: {$item['quantity']})</li>";
$product_list_text .= "- {$product_name} (Quantity: {$item['quantity']})\n";
}
$product_list_html .= '</ul>';
$order_details_link = get_site_url() . '/order_details.php?id=' . $order_id;
$admin_order_details_link = get_site_url() . '/admin/order_details.php?id=' . $order_id;
$admin_email = getenv('MAIL_TO') ?: 'admin@example.com';
// --- Email Sending Logic ---
$site_name = get_site_url(); // Or your site name
if ($client_email) {
// 1. Client - Order Confirmation
$subject_client = "Your Order Confirmation (#{$order_id})";
$body_html_client = "<p>Thank you for your order.</p>"
. "<p><strong>Order Number:</strong> {$order_id}</p>"
. "<p><strong>Order Date:</strong> " . date('Y-m-d') . "</p>"
. "<strong>Products:</strong>{$product_list_html}"
. "<p><strong>Total Amount:</strong> " . format_money($total_amount_gross, $lang, $pdo) . "</p>"
. "<p><strong>Payment Method:</strong> {" . strtoupper($_POST['payment_method']) . "}</p>"
. "<p>You can view your order details here: <a href='{$order_details_link}'>{$order_details_link}</a></p>";
$body_text_client = "Thank you for your order.\n"
. "Order Number: {$order_id}\n"
. "Order Date: " . date('Y-m-d') . "\n"
. "Products:\n{$product_list_text}"
. "Total Amount: " . format_money($total_amount_gross, $lang, $pdo) . "\n"
. "Payment Method: {" . strtoupper($_POST['payment_method']) . "}\n"
. "View your order details here: {$order_details_link}";
MailService::sendMail($client_email, $subject_client, $body_html_client, $body_text_client);
$data_client = [
'order_id' => $order_id,
'order_items' => $order_items_data,
'products' => $products_by_id_for_email,
'total_amount_gross' => $total_amount_gross,
'payment_method' => $_POST['payment_method'],
'order_details_link' => $order_details_link,
'site_name' => $site_name,
'pdo' => $pdo,
];
MailService::sendTemplatedMail($client_email, $lang, 'order_confirmation', $data_client);
// 3. Client - Payment Instructions (Bank Transfer)
if ($_POST['payment_method'] === 'bank_transfer') {
// TODO: Fetch bank details from a settings table or config
$bank_account_details = "Bank: Example Bank\nAccount Number: 123456789";
$bank_account_details = "Bank: Example Bank\nAccount Number: 123456789";
$transfer_title = "Order #{$order_id}";
$payment_deadline = date('Y-m-d', strtotime('+7 days'));
$subject_bank = "Payment Instructions for Order #{$order_id}";
$body_html_bank = "<p>Please make a payment for your order.</p>"
. "<p><strong>Order Number:</strong> {$order_id}</p>"
. "<p><strong>Amount:</strong> " . format_money($total_amount_gross, $lang, $pdo) . "</p>"
. "<p><strong>Bank Account Details:</strong><br>" . nl2br($bank_account_details) . "</p>"
. "<p><strong>Transfer Title:</strong> {$transfer_title}</p>"
. "<p><strong>Payment Deadline:</strong> {$payment_deadline}</p>";
$body_text_bank = "Please make a payment for your order.\n"
. "Order Number: {$order_id}\n"
. "Amount: " . format_money($total_amount_gross, $lang, $pdo) . "\n"
. "Bank Account Details:\n" . $bank_account_details . "\n"
. "Transfer Title: {$transfer_title}\n"
. "Payment Deadline: {$payment_deadline}";
MailService::sendMail($client_email, $subject_bank, $body_html_bank, $body_text_bank);
$data_bank = [
'order_id' => $order_id,
'total_amount_gross' => $total_amount_gross,
'bank_account_details' => $bank_account_details,
'transfer_title' => $transfer_title,
'payment_deadline' => $payment_deadline,
'site_name' => $site_name,
'pdo' => $pdo,
];
MailService::sendTemplatedMail($client_email, $lang, 'payment_instructions', $data_bank);
}
// 6. Client - Credit Payment Confirmation
if ($_POST['payment_method'] === 'credit') {
$subject_credit = "Your Order Paid with Trade Credit (#{$order_id})";
$body_html_credit = "<p>Your order has been successfully placed using your trade credit.</p>"
. "<p><strong>Order Number:</strong> {$order_id}</p>"
. "<p><strong>Amount:</strong> " . format_money($total_amount_gross, $lang, $pdo) . "</p>"
. "<p><strong>Remaining Credit Limit:</strong> " . format_money($new_balance, $lang, $pdo) . "</p>"
. "<p>You can view your order details here: <a href='{$order_details_link}'>{$order_details_link}</a></p>";
$body_text_credit = "Your order has been successfully placed using your trade credit.\n"
. "Order Number: {$order_id}\n"
. "Amount: " . format_money($total_amount_gross, $lang, $pdo) . "\n"
. "Remaining Credit Limit: " . format_money($new_balance, $lang, $pdo) . "\n"
. "View your order details here: {$order_details_link}";
MailService::sendMail($client_email, $subject_credit, $body_html_credit, $body_text_credit);
$data_credit = [
'order_id' => $order_id,
'total_amount_gross' => $total_amount_gross,
'new_balance' => $new_balance,
'order_details_link' => $order_details_link,
'site_name' => $site_name,
'pdo' => $pdo,
];
MailService::sendTemplatedMail($client_email, $lang, 'credit_payment_confirmation', $data_credit);
}
}
// 2. Admin - New Order Notification
$subject_admin = "New Order Received (#{$order_id})";
$body_html_admin = "<p>A new order has been placed.</p>"
. "<p><strong>Order Number:</strong> {$order_id}</p>"
. "<p><strong>Client:</strong> {$client_company_name}</p>"
. "<p><strong>Total Amount:</strong> " . format_money($total_amount_gross, $lang, $pdo) . "</p>"
. "<p><strong>Payment Method:</strong> {" . strtoupper($_POST['payment_method']) . "}</p>"
. "<p><strong>Delivery Source:</strong> {$delivery_source}</p>"
. "<p>View the order here: <a href='{$admin_order_details_link}'>{$admin_order_details_link}</a></p>";
$body_text_admin = "A new order has been placed.\n"
. "Order Number: {$order_id}\n"
. "Client: {$client_company_name}\n"
. "Total Amount: " . format_money($total_amount_gross, $lang, $pdo) . "\n"
. "Payment Method: {" . strtoupper($_POST['payment_method']) . "}\n"
. "Delivery Source: {$delivery_source}\n"
. "View the order here: {$admin_order_details_link}";
MailService::sendMail($admin_email, $subject_admin, $body_html_admin, $body_text_admin);
$data_admin = [
'order_id' => $order_id,
'client_company_name' => $client_company_name,
'total_amount_gross' => $total_amount_gross,
'payment_method' => $_POST['payment_method'],
'delivery_source' => $delivery_source,
'admin_order_details_link' => $admin_order_details_link,
'site_name' => $site_name,
'pdo' => $pdo,
];
MailService::sendTemplatedMail($admin_email, 'en', 'admin_new_order', $data_admin); // Admin email in English
// 7. Supplier - New Order Items
$stmt = $pdo->prepare("\n SELECT p.supplier_id, s.name as supplier_name, s.email as supplier_email, p.name as product_name, oi.quantity\n FROM order_items oi\n JOIN products p ON oi.product_id = p.id\n JOIN suppliers s ON p.supplier_id = s.id\n WHERE oi.order_id = ? AND p.supplier_id IS NOT NULL\n ");
@ -244,23 +217,15 @@ try {
foreach ($items_by_supplier as $supplier_id => $supplier_data) {
if (!empty($supplier_data['email'])) {
$product_list_supplier_html = '<ul>';
$product_list_supplier_text = '';
foreach ($supplier_data['items'] as $product) {
$product_list_supplier_html .= "<li>{$product['name']}\n (Quantity: {$product['quantity']})</li>";
$product_list_supplier_text .= "- {$product['name']}\n (Quantity: {$product['quantity']})\n";
}
$product_list_supplier_html .= '</ul>';
$subject_supplier = "New Items in Order #{$order_id}";
$body_html_supplier = "<p>You have new items in order #{$order_id}.</p>"
. "<p><strong>Order Number:</strong> {$order_id}</p>"
. "<strong>Products:</strong>{$product_list_supplier_html}";
$body_text_supplier = "You have new items in order #{$order_id}.\n"
. "Order Number: {$order_id}\n"
. "Products:\n{$product_list_supplier_text}";
MailService::sendMail($supplier_data['email'], $subject_supplier, $body_html_supplier, $body_text_supplier);
$data_supplier = [
'order_id' => $order_id,
'supplier_items' => $supplier_data['items'],
'site_name' => $site_name,
'pdo' => $pdo,
];
MailService::sendTemplatedMail($supplier_data['email'], 'en', 'supplier_new_order_items', $data_supplier); // Supplier email in English
}
}

View File

@ -0,0 +1,20 @@
<?php
// templates/mail/en/admin_new_order.php
/**
* @var int $order_id
* @var string $client_company_name
* @var float $total_amount_gross
* @var string $payment_method
* @var string $delivery_source
* @var string $admin_order_details_link
*/
?>
<p>A new order has been placed.</p>
<p><strong>Order ID:</strong> <?php echo $order_id; ?></p>
<p><strong>Client:</strong> <?php echo htmlspecialchars($client_company_name); ?></p>
<p><strong>Total Amount:</strong> <?php echo format_money($total_amount_gross, $lang, $db); ?></p>
<p><strong>Payment Method:</strong> <?php echo htmlspecialchars(ucfirst(str_replace('_', ' ', $payment_method))); ?></p>
<p><strong>Delivery Source:</strong> <?php echo htmlspecialchars(strtoupper($delivery_source)); ?></p>
<p>View order details: <a href="<?php echo $admin_order_details_link; ?>"><?php echo $admin_order_details_link; ?></a></p>

View File

@ -0,0 +1,15 @@
<?php
// templates/mail/en/credit_payment_confirmation.php
/**
* @var int $order_id
* @var float $total_amount_gross
* @var float $new_balance
* @var string $order_details_link
*/
?>
<p>Hello,</p>
<p>We confirm that your payment of <?php echo format_money($total_amount_gross, $lang, $db); ?> for order #<?php echo $order_id; ?> has been successfully processed using your trade credit.</p>
<p>Your new credit balance is <?php echo format_money($new_balance, $lang, $db); ?>.</p>
<p>You can view your order details here: <a href="<?php echo $order_details_link; ?>"><?php echo $order_details_link; ?></a></p>

View File

@ -0,0 +1,24 @@
<?php
// templates/mail/en/order_confirmation.php
/**
* @var int $order_id
* @var string $product_list_html
* @var float $total_amount_gross
* @var string $payment_method
* @var string $order_details_link
*/
?>
<p>Hello,</p>
<p>Thank you for your order #<?php echo $order_id; ?>.</p>
<p><strong>Order Summary:</strong></p>
<ul>
<?php foreach ($order_items as $item): ?>
<li><?php echo htmlspecialchars($products[$item['product_id']] ?? 'Unknown Product'); ?> (Quantity: <?php echo $item['quantity']; ?>)</li>
<?php endforeach; ?>
</ul>
<p><strong>Total:</strong> <?php echo format_money($total_amount_gross, $lang, $db); ?></p>
<p><strong>Payment Method:</strong> <?php echo htmlspecialchars(ucfirst(str_replace('_', ' ', $payment_method))); ?></p>
<p>You can view your order details here: <a href="<?php echo $order_details_link; ?>"><?php echo $order_details_link; ?></a></p>
<p>Thank you for your business!</p>

View File

@ -0,0 +1,19 @@
<?php
// templates/mail/en/payment_instructions.php
/**
* @var int $order_id
* @var float $total_amount_gross
* @var string $bank_account_details
* @var string $transfer_title
* @var string $payment_deadline
*/
?>
<p>Hello,</p>
<p>Please use the following details to make a bank transfer for your order #<?php echo $order_id; ?>.</p>
<p><strong>Amount:</strong> <?php echo format_money($total_amount_gross, $lang, $db); ?></p>
<p><strong>Bank Details:</strong></p>
<pre><?php echo htmlspecialchars($bank_account_details); ?></pre>
<p><strong>Transfer Title:</strong> <?php echo htmlspecialchars($transfer_title); ?></p>
<p>Please make the payment before <strong><?php echo $payment_deadline; ?></strong>.</p>

View File

@ -0,0 +1,18 @@
<?php
// templates/mail/en/supplier_new_order_items.php
/**
* @var int $order_id
* @var string $product_list_supplier_html
*/
?>
<p>Hello,</p>
<p>You have new items to prepare for order #<?php echo $order_id; ?>.</p>
<p><strong>Items to ship:</strong></p>
<ul>
<?php foreach ($supplier_items as $item): ?>
<li><?php echo htmlspecialchars($item['name']); ?> (Quantity: <?php echo $item['quantity']; ?>)</li>
<?php endforeach; ?>
</ul>
<p>Please prepare the items for shipment.</p>

48
templates/mail/layout.php Normal file
View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="<?php echo $lang ?? 'en'; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $subject; ?></title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
}
.header {
background-color: #f7f7f7;
padding: 10px;
text-align: center;
border-bottom: 1px solid #ddd;
}
.content {
padding: 20px 0;
}
.footer {
margin-top: 20px;
padding: 10px;
background-color: #f7f7f7;
text-align: center;
font-size: 0.8em;
color: #777;
}
</style>
</head>
<body>
<div class="header">
<h1><?php echo $site_name ?? 'Our Site'; ?></h1>
</div>
<div class="content">
<?php echo $body; ?>
</div>
<div class="footer">
<p>&copy; <?php echo date('Y'); ?> <?php echo $site_name ?? 'Our Site'; ?>. All rights reserved.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,20 @@
<?php
// templates/mail/pl/admin_new_order.php
/**
* @var int $order_id
* @var string $client_company_name
* @var float $total_amount_gross
* @var string $payment_method
* @var string $delivery_source
* @var string $admin_order_details_link
*/
?>
<p>Złożono nowe zamówienie.</p>
<p><strong>ID Zamówienia:</strong> <?php echo $order_id; ?></p>
<p><strong>Klient:</strong> <?php echo htmlspecialchars($client_company_name); ?></p>
<p><strong>Suma całkowita:</strong> <?php echo format_money($total_amount_gross, $lang, $db); ?></p>
<p><strong>Metoda płatności:</strong> <?php echo htmlspecialchars(ucfirst(str_replace('_', ' ', $payment_method))); ?></p>
<p><strong>Źródło dostawy:</strong> <?php echo htmlspecialchars(strtoupper($delivery_source)); ?></p>
<p>Zobacz szczegóły zamówienia: <a href="<?php echo $admin_order_details_link; ?>"><?php echo $admin_order_details_link; ?></a></p>

View File

@ -0,0 +1,15 @@
<?php
// templates/mail/pl/credit_payment_confirmation.php
/**
* @var int $order_id
* @var float $total_amount_gross
* @var float $new_balance
* @var string $order_details_link
*/
?>
<p>Dzień dobry,</p>
<p>Potwierdzamy, że Twoja płatność w wysokości <?php echo format_money($total_amount_gross, $lang, $db); ?> za zamówienie #<?php echo $order_id; ?> została pomyślnie przetworzona przy użyciu kredytu kupieckiego.</p>
<p>Twoje nowe saldo kredytowe wynosi <?php echo format_money($new_balance, $lang, $db); ?>.</p>
<p>Możesz zobaczyć szczegóły zamówienia tutaj: <a href="<?php echo $order_details_link; ?>"><?php echo $order_details_link; ?></a></p>

View File

@ -0,0 +1,24 @@
<?php
// templates/mail/pl/order_confirmation.php
/**
* @var int $order_id
* @var string $product_list_html
* @var float $total_amount_gross
* @var string $payment_method
* @var string $order_details_link
*/
?>
<p>Dzień dobry,</p>
<p>Dziękujemy za złożenie zamówienia #<?php echo $order_id; ?>.</p>
<p><strong>Podsumowanie zamówienia:</strong></p>
<ul>
<?php foreach ($order_items as $item): ?>
<li><?php echo htmlspecialchars($products[$item['product_id']] ?? 'Nieznany produkt'); ?> (Ilość: <?php echo $item['quantity']; ?>)</li>
<?php endforeach; ?>
</ul>
<p><strong>Suma:</strong> <?php echo format_money($total_amount_gross, $lang, $db); ?></p>
<p><strong>Metoda płatności:</strong> <?php echo htmlspecialchars(ucfirst(str_replace('_', ' ', $payment_method))); ?></p>
<p>Możesz zobaczyć szczegóły zamówienia tutaj: <a href="<?php echo $order_details_link; ?>"><?php echo $order_details_link; ?></a></p>
<p>Dziękujemy za zakupy!</p>

View File

@ -0,0 +1,19 @@
<?php
// templates/mail/pl/payment_instructions.php
/**
* @var int $order_id
* @var float $total_amount_gross
* @var string $bank_account_details
* @var string $transfer_title
* @var string $payment_deadline
*/
?>
<p>Dzień dobry,</p>
<p>Proszę użyć poniższych danych do wykonania przelewu bankowego za zamówienie #<?php echo $order_id; ?>.</p>
<p><strong>Kwota:</strong> <?php echo format_money($total_amount_gross, $lang, $db); ?></p>
<p><strong>Dane bankowe:</strong></p>
<pre><?php echo htmlspecialchars($bank_account_details); ?></pre>
<p><strong>Tytuł przelewu:</strong> <?php echo htmlspecialchars($transfer_title); ?></p>
<p>Proszę dokonać płatności przed <strong><?php echo $payment_deadline; ?></strong>.</p>

View File

@ -0,0 +1,18 @@
<?php
// templates/mail/pl/supplier_new_order_items.php
/**
* @var int $order_id
* @var string $product_list_supplier_html
*/
?>
<p>Dzień dobry,</p>
<p>Masz nowe pozycje do przygotowania dla zamówienia #<?php echo $order_id; ?>.</p>
<p><strong>Pozycje do wysyłki:</strong></p>
<ul>
<?php foreach ($supplier_items as $item): ?>
<li><?php echo htmlspecialchars($item['name']); ?> (Ilość: <?php echo $item['quantity']; ?>)</li>
<?php endforeach; ?>
</ul>
<p>Proszę przygotować pozycje do wysyłki.</p>