<?php

/**
 * User: Yilmaz Kilic
 * Date: 30.06.2016
 * Time: 09:43
 */
class AORGMailer
{
    function createMail($order, $orders_products, $rating_link, $language_code = "de", $tpl_path = ""){
        $module_smarty = new Smarty;
        $module_smarty->assign('tpl_path', $tpl_path.'GXModules/AusgezeichnetORG/Bewertung/Shop/Templates/' . CURRENT_TEMPLATE . '/');
        $module_smarty->assign('language', $_SESSION['language']);
        $module_smarty->assign('order', $order);
        $module_smarty->assign('orders_products', $orders_products);
        $module_smarty->assign('rating_link',$rating_link);
        $date_purchased = substr($order['date_purchased'],0,10);
        $date_purchased = substr($date_purchased,8,2).".".substr($date_purchased,5,2).".".substr($date_purchased,0,4);
        $module_smarty->assign('date_purchased',$date_purchased);
        $module_smarty->assign('page_url', HTTPS_SERVER);

        $module_smarty->caching = 0;
        $fetched = $module_smarty->fetch($tpl_path.'GXModules/AusgezeichnetORG/Bewertung/Shop/Templates/' . CURRENT_TEMPLATE . '/module/aorg_mail_temp_'.$language_code.'.html');

        return $fetched;
    }
    function sendMessage($absender,$empfaenger,$cc = "",$betreff,$mailtext){
        $header  = "MIME-Version: 1.0\r\n";
        $header .= "Content-type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable\r\n"; //ISO-8859-1 Content-Transfer-Encoding: quoted-printable\r\n";
        $header .= "From: $absender\r\n";
        $header .= "Reply-To: $empfaenger\r\n";
        if($cc != "") $header .= "Cc: $cc\r\n";  // falls an CC gesendet werden soll
        $header .= "X-Mailer: PHP ". phpversion();

        // Admin
        mail($empfaenger,utf8_decode($betreff),utf8_decode($mailtext), $header);
    }

}