<?php
/**
 * ORDER NOTIFICATION EMAIL - ADMIN
 * File: templates/email/order-notification-admin.php
 *
 * Available variables (from Mailer::sendAdminOrderNotification):
 * $order_number, $order_id, $item_title,
 * $customer_name, $customer_email, $customer_phone,
 * $vendor_name, $vendor_email, $vendor_phone,
 * $start_date, $end_date, $total_days, $quantity, $status, $payment_status,
 * $subtotal, $security_deposit, $platform_fee, $vendor_earnings, $total_amount,
 * $app_name, $app_url
 */

ob_start();
?>

<p>A new booking has been placed and payment confirmed on <strong><?= $app_name ?></strong>. Here is the full order summary.</p>

<div class="order-summary">
    <h4>Order Summary</h4>
    <p><strong>Order Number:</strong> <?= htmlspecialchars($order_number ?? '') ?></p>
    <p><strong>Item:</strong> <?= htmlspecialchars($item_title ?? '') ?></p>
    <p><strong>Rental Period:</strong> <?= date('M j, Y', strtotime($start_date)) ?> &ndash; <?= date('M j, Y', strtotime($end_date)) ?></p>
    <p><strong>Duration:</strong> <?= $total_days ?> day<?= $total_days > 1 ? 's' : '' ?></p>
    <p><strong>Quantity:</strong> <?= $quantity ?></p>
    <p><strong>Order Status:</strong> <span style="color:#27ae60; font-weight:bold;"><?= ucfirst($status ?? '') ?></span></p>
    <p><strong>Payment Status:</strong> <span style="color:#27ae60; font-weight:bold;"><?= ucfirst($payment_status ?? '') ?></span></p>
</div>

<div class="order-summary">
    <h4>Customer</h4>
    <p><strong>Name:</strong> <?= htmlspecialchars($customer_name ?? '') ?></p>
    <p><strong>Email:</strong> <?= htmlspecialchars($customer_email ?? '') ?></p>
    <p><strong>Phone:</strong> <?= htmlspecialchars($customer_phone ?? '') ?></p>
</div>

<div class="order-summary">
    <h4>Vendor</h4>
    <p><strong>Business:</strong> <?= htmlspecialchars($vendor_name ?? '') ?></p>
    <p><strong>Email:</strong> <?= htmlspecialchars($vendor_email ?? '') ?></p>
    <p><strong>Phone:</strong> <?= htmlspecialchars($vendor_phone ?? '') ?></p>
</div>

<div class="order-summary">
    <h4>Financial Breakdown</h4>
    <p><strong>Subtotal:</strong> &#8358;<?= number_format($subtotal, 2) ?></p>
    <p><strong>Security Deposit:</strong> &#8358;<?= number_format($security_deposit, 2) ?></p>
    <p><strong>Platform Fee (Revenue):</strong> <span style="color:#27ae60;">&#8358;<?= number_format($platform_fee, 2) ?></span></p>
    <p><strong>Vendor Earnings:</strong> &#8358;<?= number_format($vendor_earnings, 2) ?></p>
    <p style="font-size:16px; border-top:1px solid #ddd; padding-top:10px; margin-top:10px;">
        <strong>Total Collected:</strong>
        <span style="color:#27ae60; font-size:18px; font-weight:bold;"> &#8358;<?= number_format($total_amount, 2) ?></span>
    </p>
</div>

<p>
    <a href="<?= $app_url ?>/admin/orders.php" class="btn" style="background:#27ae60; color:white; padding:10px 20px; text-decoration:none; border-radius:5px;">View in Admin Panel</a>
</p>

<?php
$content = ob_get_clean();

$email_data = [
    'title'       => 'New Order Notification',
    'greeting'    => "New Order Notification &#128203;",
    'content'     => $content,
    'action_url'  => $app_url . '/admin/orders.php',
    'action_text' => 'View in Admin Panel',
    'footer_note' => "This is an automated admin notification from " . $app_name . ".",
    'signature'   => $app_name . " System"
];

include 'layout.php';
?>