<?php

namespace MovieEngine\Emails\Types;

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

use MovieEngine\Emails\EmailBase;

class PayoutRejectedEmail extends EmailBase {

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

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

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

        $subject = esc_html__('Action Required: Payout Request Rejected', 'cine-movie-engine');

        $data = [
            'user_name'      => $user->display_name,
            'amount'         => $display_amount,
            'reason'         => sanitize_text_field($note),
            'dashboard_link' => home_url('/dashboard'),
            'site_name'      => get_bloginfo('name'),
        ];

        $to = ! empty($custom_to) ? $custom_to : $user->user_email;

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