<?php
namespace Claromentis\Core\Message\Digest;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] = (@$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] ?: array()) + array("_7f628626dd1d55c71b1fc0932f" . "fd1d2c" => base64_decode("aXNfYXJyYX" . "k="), "_6a02aaef" . "c5f2925e4" . "69e5aca39" . "90865a" => base64_decode("YXBwX3R5c" . "GU="), "_aab499eef7e4" . "15d7a0fb08eb7" . "3e45ecc" => base64_decode("aW1f" . "bXNn" . "X2lk"), "_4aae454f02b643f430f92d61eefbd76" . "4" => base64_decode("U0VMRUNUIGVtYWlsYWQsIGxhbmd1YWdlIEZST00gdXNlcnMgV0hF" . "UkUgaWQ9aW50OnVpZA=="), "_afbde5640e" . "69e7faa246c" . "9a10c31459e" => base64_decode("U0VMRUNUIHN1YmplY3QsI" . "G1lc3NhZ2VfdGV4dCBGUk" . "9NIGltZXNzYWdlcyBXSEV" . "SRSBpZD1pbnQ6bXNnX2lk"), "_71294b2a63b" . "9368ebc9aa58" . "50a8178b6" => base64_decode("aW50Z" . "XJ2YW" . "xfdHl" . "wZQ=="));
use ClaMailMessage;
use ErrorHandler;






class DigestMessage extends ErrorHandler
{
    
    
    
    
    
    
    protected $interval_type;
    protected $messages_info;
    protected $language;
    
    
    
    
    
    
    private $decorator;
    protected $user_id;
    
    
    
    
    
    
    
    public function __construct($_71294b2a63b9368ebc9aa5850a8178b6, $user_id)
    {
        $this->interval_type = $_71294b2a63b9368ebc9aa5850a8178b6;
        $this->user_id = $user_id;
        $this->messages_info = [];
    }
    
    
    
    
    public function SetMessages($_21dea7718737962854e0632405a6abb2)
    {
        $this->messages_info = $_21dea7718737962854e0632405a6abb2;
    }
    
    
    
    
    public function Send()
    {
        global $db;
        $_efc81103ecdaf9157ad709e7d1eb087c = [];
        foreach ($this->messages_info as $_e05e0022a2e5ad344b9c4a0d3f64e1a5) {
            $_189840d11056515e52402d1412a0b6e4 = $db->query($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_afbde5640e69e7f" . "aa246c9a10c31459" . "e"], $_e05e0022a2e5ad344b9c4a0d3f64e1a5[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_aab499eef7e4" . "15d7a0fb08eb7" . "3e45ecc"]]);
            if (!$_189840d11056515e52402d1412a0b6e4->hasData()) {
                continue;
            }
            if (!isset($_efc81103ecdaf9157ad709e7d1eb087c[$_e05e0022a2e5ad344b9c4a0d3f64e1a5[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_6a02aaefc5f2925e469e5aca39908" . "65a"]]]) || !$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_7f628626dd1d55c71b1fc0932ffd1d2" . "c"]($_efc81103ecdaf9157ad709e7d1eb087c[$_e05e0022a2e5ad344b9c4a0d3f64e1a5[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_6a02aaefc5f2925e469e5aca39908" . "65a"]]])) {
                $_efc81103ecdaf9157ad709e7d1eb087c[$_e05e0022a2e5ad344b9c4a0d3f64e1a5[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_6a02aaefc5f2925e469e5aca399086" . "5a"]]] = [];
            }
            $_efc81103ecdaf9157ad709e7d1eb087c[$_e05e0022a2e5ad344b9c4a0d3f64e1a5[$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_6a02aaefc5f2" . "925e469e5aca3" . "990865a"]]][] = $_189840d11056515e52402d1412a0b6e4->fetchArray();
        }
        if (empty($_efc81103ecdaf9157ad709e7d1eb087c)) {
            return true;
        }
        list($_c2f6f7dc50f77b2d217bd2e23a6ff2a0, $language) = $db->query_row($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4aae454f02b643f430f92d61eef" . "bd764"], $this->GetUserId());
        $this->SetDecorator(new DigestDecorator($_efc81103ecdaf9157ad709e7d1eb087c, $this->interval_type, $language));
        $_4c4d12d3e4f6cac68e3eecffe9887915 = array($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_71294b2a63b93" . "68ebc9aa5850a8" . "178b6"] => DigestSchedule::GetIntervalTypeString($this->interval_type));
        $_f69812ed2c66c3cd2e502c9eac3591ee = new ClaMailMessage();
        $_f69812ed2c66c3cd2e502c9eac3591ee->SetTo($_c2f6f7dc50f77b2d217bd2e23a6ff2a0);
        $_f69812ed2c66c3cd2e502c9eac3591ee->SetSubject($this->decorator->GetSubject());
        $_f69812ed2c66c3cd2e502c9eac3591ee->SetHtmlBody($this->decorator->Compile($_4c4d12d3e4f6cac68e3eecffe9887915));
        $_f69812ed2c66c3cd2e502c9eac3591ee->Send();
        if ($_f69812ed2c66c3cd2e502c9eac3591ee->IsError()) {
            return $this->SetErrMsg($_f69812ed2c66c3cd2e502c9eac3591ee->GetErrMsg());
        }
        return true;
    }
    
    
    
    
    
    
    
    
    public function SetDecorator(DigestDecorator $_2e2ee510f512062f96daee84c4e3a0ca)
    {
        $this->decorator = $_2e2ee510f512062f96daee84c4e3a0ca;
        return $this;
    }
    
    
    
    
    
    
    
    
    public function SetUserId($_161fa4c6089ed7645dda77e187f5b1dd)
    {
        $this->user_id = (int) $_161fa4c6089ed7645dda77e187f5b1dd;
        return $this;
    }
    
    
    
    
    
    
    public function GetUserId()
    {
        return $this->user_id;
    }
}