public function renderBonusPayment(order $order, $template)
 {
     list($tpl_block) = def_module::loadTemplates("emarket/payment/" . $template, 'bonus_block');
     $customer = customer::get($order->getCustomerId());
     $block_arr = array('bonus' => $this->formatCurrencyPrice(array('reserved_bonus' => $order->getBonusDiscount(), 'available_bonus' => $customer->bonus, 'spent_bonus' => $customer->spent_bonus, 'actual_total_price' => $order->getActualPrice())));
     $block_arr['void:reserved_bonus'] = $this->parsePriceTpl($template, $this->formatCurrencyPrice(array('actual' => $order->getBonusDiscount())));
     $block_arr['void:available_bonus'] = $this->parsePriceTpl($template, $this->formatCurrencyPrice(array('actual' => $customer->bonus)));
     $block_arr['void:spent_bonus'] = $this->parsePriceTpl($template, $this->formatCurrencyPrice(array('actual' => $customer->spent_bonus)));
     $block_arr['void:actual_total_price'] = $this->parsePriceTpl($template, $this->formatCurrencyPrice(array('actual' => $order->getActualPrice())));
     return def_module::parseTemplate($tpl_block, $block_arr);
 }
 public function sendCustomerNotification(order $order, $changedStatus, $codeName)
 {
     $customer = umiObjectsCollection::getInstance()->getObject($order->getCustomerId());
     $email = $customer->email ? $customer->email : $customer->getValue("e-mail");
     if ($email) {
         $name = $customer->lname . " " . $customer->fname . " " . $customer->father_name;
         $langs = cmsController::getInstance()->langs;
         $statusString = "";
         $subjectString = $langs['notification-status-subject'];
         $regedit = regedit::getInstance();
         switch ($changedStatus) {
             case 'status_id':
                 if ($regedit->getVal('//modules/emarket/no-order-status-notification')) {
                     return;
                 }
                 if ($codeName == 'waiting') {
                     $paymentStatusCodeName = order::getCodeByStatus($order->getPaymentStatus());
                     $pkey = 'notification-status-payment-' . $paymentStatusCodeName;
                     $okey = 'notification-status-' . $codeName;
                     $statusString = $paymentStatusCodeName == 'initialized' ? (isset($langs[$okey]) ? $langs[$okey] . " " . $langs['notification-and'] : "") . (isset($langs[$pkey]) ? " " . $langs[$pkey] : "") : (isset($langs[$pkey]) ? $langs[$pkey] . " " . $langs['notification-and'] : "") . (isset($langs[$okey]) ? " " . $langs[$okey] : "");
                     $subjectString = $langs['notification-client-neworder-subject'];
                 } else {
                     $key = 'notification-status-' . $codeName;
                     $statusString = isset($langs[$key]) ? $langs[$key] : "_";
                 }
                 break;
             case 'payment_status_id':
                 if ($regedit->getVal('//modules/emarket/no-payment-status-notification')) {
                     return;
                 }
                 $key = 'notification-status-payment-' . $codeName;
                 $statusString = isset($langs[$key]) ? $langs[$key] : "_";
                 break;
             case 'delivery_status_id':
                 if ($regedit->getVal('//modules/emarket/no-delivery-status-notification')) {
                     return;
                 }
                 $key = 'notification-status-delivery-' . $codeName;
                 $statusString = isset($langs[$key]) ? $langs[$key] : "_";
                 break;
         }
         $collection = umiObjectsCollection::getInstance();
         $paymentObject = $collection->getObject($order->payment_id);
         if ($paymentObject) {
             $paymentType = $collection->getObject($paymentObject->payment_type_id);
             $paymentClassName = $paymentType->class_name;
         } else {
             $paymentClassName = null;
         }
         $templateName = $paymentClassName == "receipt" ? "status_notification_receipt" : "status_notification";
         list($template) = def_module::loadTemplatesForMail("emarket/mail/default", $templateName);
         $param = array();
         $param["order_id"] = $order->id;
         $param["order_name"] = $order->name;
         $param["order_number"] = $order->number;
         $param["status"] = $statusString;
         $domain = cmsController::getInstance()->getCurrentDomain();
         $currentHost = getServer('HTTP_HOST');
         $param["domain"] = $domain->getHost();
         if ($param["domain"] != $currentHost) {
             $mirrowsList = $domain->getMirrowsList();
             foreach ($mirrowsList as $mirrow) {
                 if ($mirrow->getHost() == $currentHost) {
                     $param["domain"] = $mirrow->getHost();
                 }
             }
         }
         if ($paymentClassName == "receipt") {
             $param["receipt_signature"] = sha1("{$customer->id}:{$customer->email}:{$order->order_date}");
         }
         $content = def_module::parseTemplateForMail($template, $param);
         $regedit = regedit::getInstance();
         $letter = new umiMail();
         $letter->addRecipient($email, $name);
         $cmsController = cmsController::getInstance();
         $domains = domainsCollection::getInstance();
         $domainId = $cmsController->getCurrentDomain()->getId();
         $defaultDomainId = $domains->getDefaultDomain()->getId();
         if ($regedit->getVal("//modules/emarket/from-email/{$domainId}")) {
             $fromMail = $regedit->getVal("//modules/emarket/from-email/{$domainId}");
             $fromName = $regedit->getVal("//modules/emarket/from-name/{$domainId}");
         } elseif ($regedit->getVal("//modules/emarket/from-email/{$defaultDomainId}")) {
             $fromMail = $regedit->getVal("//modules/emarket/from-email/{$defaultDomainId}");
             $fromName = $regedit->getVal("//modules/emarket/from-name/{$defaultDomainId}");
         } else {
             $fromMail = $regedit->getVal("//modules/emarket/from-email");
             $fromName = $regedit->getVal("//modules/emarket/from-name");
         }
         $letter->setFrom($fromMail, $fromName);
         $letter->setSubject($subjectString);
         $letter->setContent($content);
         $letter->commit();
         $letter->send();
     }
 }