<?php

namespace MovieEngine\Emails\Types;

if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

use MovieEngine\Emails\EmailBase;

class AdminPayoutRequestEmail extends EmailBase {

    public function trigger($user, $args = [], $custom_to = '') {

        $amount = isset($args['amount']) ? (float) $args['amount'] : 0;

        $formatted_amount = number_format_i18n($amount, 2);
        $display_amount   = '$' . $formatted_amount;

        $subject = sprintf(
            /* translators: 1: formatted payout amount including currency */
            esc_html__('New Payout Request: %1$s', 'cine-movie-engine'),
            $display_amount
        );

        $data = [
            'user_name'             => $user->display_name,
            'amount'                => $display_amount,
            'admin_dashboard_link'  => esc_url(admin_url('admin.php?page=movie-engine-referrals&tab=payouts')),
            'site_name'             => get_bloginfo('name'),
        ];

        $to = ! empty($custom_to) ? $custom_to : get_option('admin_email');

        return $this->send($to, $subject, 'admin-payout-request', $data);
    }
}
