<?php
class EmailPedidoDonoLoja extends Pedido {

  public function __construct($registry)
  {
    parent::__construct($registry);
    parent::getConfigMail();
  }

  public function sendTask($typeemail, $order_id, $attribute_value)
  {

    try {
      if (!$this->config->get('config_alert_mail')) {
        throw new exception('O configuração de alerta de pedido esta desabilitada. E-mail referente ao pedido: ' . $order_id . ' não enviado!');
      }

      parent::getInfosTemplateOrder($order_id);
      $this->getInfosOwner($order_id);

      $this->mail->setTo($this->to);//$order_info['email']
      $this->mail->setSender($this->sender);//$order_info['store_name']
      $this->mail->setSubject(html_entity_decode($this->subject, ENT_QUOTES, 'UTF-8'));
      $this->mail->setHtml(parent::getTemplate($typeemail));
      $this->mail->setText(html_entity_decode($this->text, ENT_QUOTES, 'UTF-8'));
      $this->mail->send(true);

      parent::sendAdditionalEmail($attribute_value);

    } catch(Exception $e){
      throw $e;
    }

  }

  public function getInfosOwner($order_id){

    $this->to = $this->config->get('config_email');

    $this->template->data['header_background_color'] = $this->config->get('wg24_header_bg_color');
    $this->template->data['customer_name'] = $this->order_info['firstname'] . ' ' . $this->order_info['lastname'];

    $this->subject = sprintf($this->language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);

    // Text
    $this->template->data['text_new_received_to'] = $this->language->get('text_new_received') . $this->order_info['firstname'] . ' ' . $this->order_info['lastname'];
    $this->template->data['text_status'] = $this->language->get('text_new_order_status');
    $this->template->data['status'] = $this->order_status;

  }


}