| 1: | <?php
|
| 2: | namespace Opencart\Admin\Controller\Mail;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class Affiliate extends \Opencart\System\Engine\Controller {
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: |
|
| 20: | public function approve(string &$route, array &$args, &$output): void {
|
| 21: | if (isset($args[0])) {
|
| 22: | $customer_id = (int)$args[0];
|
| 23: | } else {
|
| 24: | $customer_id = 0;
|
| 25: | }
|
| 26: |
|
| 27: | $this->load->model('customer/customer');
|
| 28: |
|
| 29: | $customer_info = $this->model_customer_customer->getCustomer($customer_id);
|
| 30: |
|
| 31: | if ($customer_info) {
|
| 32: | $this->load->model('setting/store');
|
| 33: |
|
| 34: | $store_info = $this->model_setting_store->getStore($customer_info['store_id']);
|
| 35: |
|
| 36: | if ($store_info) {
|
| 37: | $store_name = html_entity_decode($store_info['name'], ENT_QUOTES, 'UTF-8');
|
| 38: | $store_url = $store_info['url'];
|
| 39: | } else {
|
| 40: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
|
| 41: | $store_url = HTTP_CATALOG;
|
| 42: | }
|
| 43: |
|
| 44: | $this->load->model('localisation/language');
|
| 45: |
|
| 46: | $language_info = $this->model_localisation_language->getLanguage($customer_info['language_id']);
|
| 47: |
|
| 48: | if ($language_info) {
|
| 49: | $language_code = $language_info['code'];
|
| 50: | } else {
|
| 51: | $language_code = $this->config->get('config_language');
|
| 52: | }
|
| 53: |
|
| 54: |
|
| 55: | $this->load->language('default', 'mail', $language_code);
|
| 56: | $this->load->language('mail/affiliate_approve', 'mail', $language_code);
|
| 57: |
|
| 58: |
|
| 59: | $results = $this->language->all('mail');
|
| 60: |
|
| 61: | foreach ($results as $key => $value) {
|
| 62: | $data[$key] = $value;
|
| 63: | }
|
| 64: |
|
| 65: | $subject = sprintf($this->language->get('mail_text_subject'), $store_name);
|
| 66: |
|
| 67: | $data['text_welcome'] = sprintf($this->language->get('mail_text_welcome'), $store_name);
|
| 68: |
|
| 69: | $data['login'] = $store_url . 'index.php?route=affiliate/login';
|
| 70: |
|
| 71: | $data['store'] = $store_name;
|
| 72: | $data['store_url'] = $store_url;
|
| 73: |
|
| 74: | if ($this->config->get('config_mail_engine')) {
|
| 75: | $mail_option = [
|
| 76: | 'parameter' => $this->config->get('config_mail_parameter'),
|
| 77: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
|
| 78: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
|
| 79: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
|
| 80: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
|
| 81: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
|
| 82: | ];
|
| 83: |
|
| 84: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
|
| 85: | $mail->setTo($customer_info['email']);
|
| 86: | $mail->setFrom($this->config->get('config_email'));
|
| 87: | $mail->setSender($store_name);
|
| 88: | $mail->setSubject($subject);
|
| 89: | $mail->setHtml($this->load->view('mail/affiliate_approve', $data));
|
| 90: | $mail->send();
|
| 91: | }
|
| 92: | }
|
| 93: | }
|
| 94: |
|
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | |
| 103: | |
| 104: | |
| 105: |
|
| 106: | public function deny(string &$route, array &$args, &$output): void {
|
| 107: | if (isset($args[0])) {
|
| 108: | $customer_id = (int)$args[0];
|
| 109: | } else {
|
| 110: | $customer_id = 0;
|
| 111: | }
|
| 112: |
|
| 113: | $this->load->model('customer/customer');
|
| 114: |
|
| 115: | $customer_info = $this->model_customer_customer->getCustomer($customer_id);
|
| 116: |
|
| 117: | if ($customer_info) {
|
| 118: | $this->load->model('setting/store');
|
| 119: |
|
| 120: | $store_info = $this->model_setting_store->getStore($customer_info['store_id']);
|
| 121: |
|
| 122: | if ($store_info) {
|
| 123: | $store_name = html_entity_decode($store_info['name'], ENT_QUOTES, 'UTF-8');
|
| 124: | $store_url = $store_info['url'];
|
| 125: | } else {
|
| 126: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
|
| 127: | $store_url = HTTP_CATALOG;
|
| 128: | }
|
| 129: |
|
| 130: | $this->load->model('localisation/language');
|
| 131: |
|
| 132: | $language_info = $this->model_localisation_language->getLanguage($customer_info['language_id']);
|
| 133: |
|
| 134: | if ($language_info) {
|
| 135: | $language_code = $language_info['code'];
|
| 136: | } else {
|
| 137: | $language_code = $this->config->get('config_language');
|
| 138: | }
|
| 139: |
|
| 140: |
|
| 141: | $this->load->language('default', 'mail', $language_code);
|
| 142: | $this->load->language('mail/affiliate_deny', 'mail', $language_code);
|
| 143: |
|
| 144: |
|
| 145: | $results = $this->language->all('mail');
|
| 146: |
|
| 147: | foreach ($results as $key => $value) {
|
| 148: | $data[$key] = $value;
|
| 149: | }
|
| 150: |
|
| 151: | $subject = sprintf($this->language->get('mail_text_subject'), $store_name);
|
| 152: |
|
| 153: | $data['text_welcome'] = sprintf($this->language->get('mail_text_welcome'), $store_name);
|
| 154: |
|
| 155: | $data['contact'] = $store_url . 'index.php?route=information/contact';
|
| 156: |
|
| 157: | $data['store'] = $store_name;
|
| 158: | $data['store_url'] = $store_url;
|
| 159: |
|
| 160: | if ($this->config->get('config_mail_engine')) {
|
| 161: | $mail_option = [
|
| 162: | 'parameter' => $this->config->get('config_mail_parameter'),
|
| 163: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
|
| 164: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
|
| 165: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
|
| 166: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
|
| 167: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
|
| 168: | ];
|
| 169: |
|
| 170: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
|
| 171: | $mail->setTo($customer_info['email']);
|
| 172: | $mail->setFrom($this->config->get('config_email'));
|
| 173: | $mail->setSender($store_name);
|
| 174: | $mail->setSubject($subject);
|
| 175: | $mail->setHtml($this->load->view('mail/affiliate_deny', $data));
|
| 176: | $mail->send();
|
| 177: | }
|
| 178: | }
|
| 179: | }
|
| 180: | }
|
| 181: | |