<?php
require_once __DIR__ . '/../../includes/email.php';

$details = [];
if (isset($amounts)) $details['Amount'] = formatCurrency((float)$amounts, $currency ?? '$');
if (isset($acct_num)) $details['Account'] = $acct_num;
if (isset($d_o_t)) $details['Date'] = $d_o_t;
if (isset($transId)) $details['Reference'] = $transId;

try {
    sendBankEmail(
        $email,
        'Withdrawal Confirmation',
        $depositname ?? 'Valued Customer',
        'Withdrawal Successfully Processed',
        '<p>A withdrawal has been <strong style="color:#0a1f44;">processed</strong> from your account.</p>',
        'View Dashboard', 'https://dbhacu.com/dashboard/dashboard',
        $details
    );
} catch (Exception $e) {
    error_log('Email send failed: ' . $e->getMessage());
}
