<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function


namespace Bookingor\Integrations\Email;

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;


//Load Composer's autoloader

class EmailNotification
{
    public static function sendEmail($to, $subject, $body)
    {

        $mail_type = get_option('bookingor_settings_email_type');
        $senderName = get_option('bookingor_settings_wp_sender_name');
        $senderEmail = get_option('bookingor_settings_wp_email_sender');


       if ($mail_type === 'wp_mail') {
            $headers = array('Content-Type: text/html');
            try {
                $mailed = wp_mail($to, $subject, $body, $headers);
            } catch (\Exception $e) {
                $mailed = false;
            }
            return $mailed;
        }
    }

    public static function replace($all_string_variables, $finalArray, $text)
    {
        return str_replace($all_string_variables, $finalArray, $text);
    }



    public static function string_Placeholder_variable($categoryString = [], $serviceString = [], $staffString = [], $customerString = [], $bookedString = [], $locationString = [],  $businessString = [], $text = null)
    {

        $all_string_variables = [


            '[#category_name]',

            '[#service_name]',
            '[#service_description]',
            '[#service_cost]',
            '[#service_deposit]',
            '[#service_deposit_type]',
            '[#service_tax]',
            '[#service_duration]',
            '[#service_duration_type]',
            '[#timeslot_length]',
            '[#service_slot_increment]',
            '[#padding_before]',
            '[#padding_after]',
            '[#service_capacity_min]',
            '[#service_capacity_max]',
            '[#recurring_status]',
            '[#recurring_type]',
            '[#recurring_payment]',
            '[#status]',
            '[#currency_symbol]',


            "[#staff_first_name]",
            "[#staff_last_name]",
            "[#staff_email]",
            "[#staff_phone]",
            "[#status]",


            '[#customer_first_name]',
            '[#customer_last_name]',
            '[#customer_phone]',
            '[#customer_email]',


            '[#book_start_time]',
            '[#book_end_time]',
            '[#book_date]',
            '[#book_discount_price]',
            '[#book_status]',
            '[#book_tax_amount]',
            '[#book_payment_method]',
            '[#book_paid_amount]',


            '[#location_name]',
            '[#location_country]',
            '[#location_city]',
            '[#location_address]',
            '[#location_phone]',



            '[#business_name]',
            '[#business_email]',
            '[#business_phone]',
            '[#business_website]',
        ];
        $finalArray = array_merge($categoryString, $serviceString, $staffString, $customerString, $bookedString, $locationString, $businessString);
        return self::replace($all_string_variables, $finalArray, $text);
    }
}
