1: | <?php
2: | namespace Opencart\Admin\Controller\Mail;
3: | /**
4: | * Class Returns
5: | *
6: | * @package Opencart\Admin\Controller\Mail
7: | */
8: | class Returns extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * @param string $route
13: | * @param array<int, mixed> $args
14: | * @param mixed $output
15: | *
16: | * @throws \Exception
17: | *
18: | * @return void
19: | */
20: | public function index(string &$route, array &$args, &$output): void {
21: | if (isset($args[0])) {
22: | $return_id = $args[0];
23: | } else {
24: | $return_id = '';
25: | }
26: |
27: | if (isset($args[1])) {
28: | $return_status_id = $args[1];
29: | } else {
30: | $return_status_id = '';
31: | }
32: |
33: | if (isset($args[2])) {
34: | $comment = $args[2];
35: | } else {
36: | $comment = '';
37: | }
38: |
39: | if (isset($args[3])) {
40: | $notify = $args[3];
41: | } else {
42: | $notify = '';
43: | }
44: |
45: | if ($notify) {
46: | $this->load->model('sale/returns');
47: |
48: | $return_info = $this->model_sale_returns->getReturn($return_id);
49: |
50: | if ($return_info) {
51: | $this->load->model('sale/order');
52: |
53: | $order_info = $this->model_sale_order->getOrder($return_info['order_id']);
54: |
55: | if ($order_info) {
56: | $store_name = html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8');
57: | $store_url = $order_info['store_url'];
58: | } else {
59: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
60: | $store_url = HTTP_CATALOG;
61: | }
62: |
63: | $this->load->model('localisation/language');
64: |
65: | $language_info = $this->model_localisation_language->getLanguage($return_info['language_id']);
66: |
67: | if ($language_info) {
68: | $language_code = $language_info['code'];
69: | } else {
70: | $language_code = $this->config->get('config_language');
71: | }
72: |
73: | $this->load->language('default', 'mail', $language_code);
74: | $this->load->language('mail/returns', 'mail', $language_code);
75: |
76: | $subject = sprintf($this->language->get('mail_text_subject'), $store_name, $return_id);
77: |
78: | $data['return_id'] = $return_id;
79: | $data['date_added'] = date($this->language->get('date_format_short'), strtotime($return_info['date_modified']));
80: | $data['return_status'] = $return_info['return_status'];
81: | $data['comment'] = nl2br($comment);
82: |
83: | $data['store'] = $store_name;
84: | $data['store_url'] = $store_url;
85: |
86: | if ($this->config->get('config_mail_engine')) {
87: | $mail_option = [
88: | 'parameter' => $this->config->get('config_mail_parameter'),
89: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
90: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
91: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
92: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
93: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
94: | ];
95: |
96: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
97: | $mail->setTo($return_info['email']);
98: | $mail->setFrom($this->config->get('config_email'));
99: | $mail->setSender($store_name);
100: | $mail->setSubject($subject);
101: | $mail->setHtml($this->load->view('mail/returns', $data));
102: | $mail->send();
103: | }
104: | }
105: | }
106: | }
107: | }
108: |

OpenCart API API documentation generated by ApiGen dev-master