<?php
/**
 * Email Configuration File
 * Last updated: 2026-07-11 17:56:24
 */

// ============================================
// SMTP SETTINGS
// ============================================

define('SMTP_HOST', 'mail.esc.al');
define('SMTP_AUTH', true);
define('SMTP_USERNAME', 'rent@esc.al');
define('SMTP_PASSWORD', 'Bkasxh12.');
define('SMTP_SECURE', 'ssl');
define('SMTP_PORT', 465);

// ============================================
// SENDER INFORMATION
// ============================================

define('SENDER_EMAIL', 'rent@esc.al');
define('SENDER_NAME', 'ESC Rental');

// ============================================
// ADMIN NOTIFICATIONS
// ============================================

define('ADMIN_EMAIL', 'dollanga.12@gmail.com');
define('ADMIN_NAME', 'ESC Rental Admin');

// ============================================
// EMAIL SETTINGS
// ============================================

define('EMAIL_ENABLED', true);
define('EMAIL_ADMIN_ON_BOOKING', true);
define('EMAIL_CUSTOMER_ON_BOOKING', true);

// ============================================
// EMAIL TEMPLATES
// ============================================

function getCustomerBookingTemplate($booking_data, $car_data, $price_data) {
    $site_name = SENDER_NAME;
    $reservation_code = $booking_data['reservation_code'];
    $customer_name = htmlspecialchars($booking_data['customer_name']);
    $car_name = htmlspecialchars($car_data['brand'] . ' ' . $car_data['model']);
    $license_plate = htmlspecialchars($car_data['license_plate']);
    $pickup_date = date('d/m/Y', strtotime($booking_data['pickup_date']));
    $pickup_time = substr($booking_data['pickup_time'], 0, 5);
    $dropoff_date = date('d/m/Y', strtotime($booking_data['dropoff_date']));
    $dropoff_time = substr($booking_data['dropoff_time'], 0, 5);
    $total_price = number_format($price_data['grand_total'], 2);
    
    return <<<HTML
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>Booking Confirmation</title></head>
<body style="font-family: Arial, sans-serif;">
    <div style="max-width: 600px; margin: 0 auto; padding: 20px;">
        <div style="background: #0066cc; color: white; padding: 20px; text-align: center;">
            <h2>Booking Confirmation</h2>
            <p>Thank you for choosing {$site_name}!</p>
        </div>
        <div style="background: #f8fafc; padding: 30px; border: 1px solid #e5e7eb;">
            <p>Dear <strong>{$customer_name}</strong>,</p>
            <p>Your reservation has been successfully confirmed.</p>
            <div style="background: #e5e7eb; padding: 10px; text-align: center; font-size: 18px; font-weight: bold; margin: 20px 0;">
                Reservation Code: {$reservation_code}
            </div>
            <p><strong>Vehicle:</strong> {$car_name} ({$license_plate})<br>
            <strong>Pickup:</strong> {$pickup_date} at {$pickup_time}<br>
            <strong>Return:</strong> {$dropoff_date} at {$dropoff_time}<br>
            <strong>Total:</strong> €{$total_price}</p>
            <p>Please bring your driver's license and ID at pickup.</p>
            <p>Best regards,<br><strong>{$site_name} Team</strong></p>
        </div>
        <div style="text-align: center; font-size: 12px; color: #6b7280; margin-top: 30px;">
            <p>This is an automated confirmation. Please do not reply.</p>
        </div>
    </div>
</body>
</html>
HTML;
}

function getAdminNotificationTemplate($booking_data, $car_data, $price_data) {
    $reservation_code = $booking_data['reservation_code'];
    $customer_name = htmlspecialchars($booking_data['customer_name']);
    $customer_email = htmlspecialchars($booking_data['customer_email']);
    $customer_phone = htmlspecialchars($booking_data['customer_phone']);
    $car_name = htmlspecialchars($car_data['brand'] . ' ' . $car_data['model']);
    $total_price = number_format($price_data['grand_total'], 2);
    
    return <<<HTML
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>New Reservation</title></head>
<body>
    <h2>🔔 New Reservation Created!</h2>
    <p><strong>Code:</strong> {$reservation_code}</p>
    <p><strong>Customer:</strong> {$customer_name}<br>
    <strong>Email:</strong> {$customer_email}<br>
    <strong>Phone:</strong> {$customer_phone}</p>
    <p><strong>Vehicle:</strong> {$car_name}<br>
    <strong>Total:</strong> €{$total_price}</p>
    <p><a href="http://rent.esc.al/admin/reservations.php?search={$reservation_code}">View in Admin Panel →</a></p>
</body>
</html>
HTML;
}

function getCustomerBookingText($booking_data, $car_data, $price_data) {
    return "Booking Confirmation\n\n" .
           "Reservation Code: {$booking_data['reservation_code']}\n" .
           "Vehicle: {$car_data['brand']} {$car_data['model']}\n" .
           "Pickup: {$booking_data['pickup_date']} at {$booking_data['pickup_time']}\n" .
           "Return: {$booking_data['dropoff_date']} at {$booking_data['dropoff_time']}\n" .
           "Total: €" . number_format($price_data['grand_total'], 2);
}

function getAdminNotificationText($booking_data, $car_data, $price_data) {
    return "New Reservation: {$booking_data['reservation_code']}\n" .
           "Customer: {$booking_data['customer_name']} - {$booking_data['customer_phone']}\n" .
           "Vehicle: {$car_data['brand']} {$car_data['model']}\n" .
           "Total: €" . number_format($price_data['grand_total'], 2);
}
?>