<?php

namespace MGModule\DNSManager2\mgLibs\custom\mailer\mergefields;

use \MGModule\DNSManager2\models\whmcs\configuration;

class Other {
    private $data;
    private $output;
    
    public function __construct() {
        $this->data['company_name'] = configuration\configuration::bySetting('CompanyName')->value;
        $this->data['company_domain'] = configuration\configuration::bySetting('Domain')->value;
        $this->data['company_logo_url'] = configuration\configuration::bySetting('LogoURL')->value;
        $this->data['whmcs_url'] = configuration\configuration::bySetting('SystemURL')->value;
        $this->data['whmcs_link'] = "<a href=\"" . $this->data['whmcs_url'] . "\">" . $this->data['whmcs_url'] . "</a>";
        $this->data['signature'] = nl2br(strip_tags(html_entity_decode(configuration\configuration::bySetting('Signature')->value, ENT_QUOTES)));
        $this->data['date'] = date("l, jS F Y");
        $this->data['time'] = date("g:ia");
    }
    
    public function getFormatedData() {
        $this->output = $this->data;
        
        return $this->output;
    }
    
    public function getMergeFields() {
        $map = self::getMergeFieldsMap();
        $formated = $this->getFormatedData();
        $fields = array();
        
        foreach($map as $k => $v) $fields[$k] = $formated[$v];

        return $fields;
    }
    
    public static function getMergeFieldsNames() {
        return array_keys(self::getMergeFieldsMap());
    }
    
    private static function getMergeFieldsMap() {
        return array('company_name' => 'company_name', 'company_domain' => 'company_domain', 
            'company_logo_url' => 'company_logo_url', 'whmcs_url' => 'whmcs_url', 
            'whmcs_link' => 'whmcs_link', 'signature' => 'signature', 'date' => 'date', 
            'time' => 'time', 
            //'pw_reset_url' => '', 'order_id' => '', 'order_number' => '', 'order_details' => '', 
        );
    }
}