public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->form = new AForm('ContactUsFrm'); $this->form->loadFromDb('ContactUsFrm'); $form = $this->form->getForm(); if ($this->request->is_POST() && $this->_validate()) { // move all uploaded files to their directories $file_pathes = $this->form->processFileUploads($this->request->files); $mail = new AMail($this->config); $mail->setTo($this->config->get('store_main_email')); $mail->setFrom($this->request->post['email']); $mail->setSender($this->request->post['first_name']); $mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['name'])); $msg = $this->request->post['enquiry'] . "\r\n"; $form_fields = $this->form->getFields(); foreach ($form_fields as $field_name => $field_info) { if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) { $field_details = $this->form->getField($field_name); $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name]; } } if ($file_pathes) { $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n"; foreach ($file_pathes as $file_info) { $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME); $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n"; $mail->addAttachment($file_info['path'], $basename); } } $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'))); $mail->send(); //get success_page if ($form['success_page']) { $success_url = $this->html->getSecureURL($form['success_page']); } else { $success_url = $this->html->getSecureURL('content/contact/success'); } $this->redirect($success_url); } if ($this->request->is_POST()) { foreach ($this->request->post as $name => $value) { $this->form->assign($name, $value); } } $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('form_output', $this->form->getFormHtml()); $this->view->assign('action', $this->html->getURL('content/contact')); $this->view->assign('store', $this->config->get('store_name')); $this->view->assign('address', nl2br($this->config->get('config_address'))); $this->view->assign('telephone', $this->config->get('config_telephone')); $this->view->assign('fax', $this->config->get('config_fax')); $this->processTemplate('pages/content/contact.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * @param int $order_id * @param int $order_status_id * @param string $comment */ public function _confirm($order_id, $order_status_id, $comment = '') { $order_query = $this->db->query("SELECT *,\n\t\t\t\t\t\t\t\t\t\t\t\tl.filename AS filename,\n\t\t\t\t\t\t\t\t\t\t\t\tl.directory AS directory\n\t\t\t\t\t\t\t\t\t\t FROM `" . $this->db->table("orders") . "` o\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n\t\t\t\t\t\t\t\t\t\t WHERE o.order_id = '" . (int) $order_id . "'\n\t\t\t\t\t\t\t\t\t\t AND o.order_status_id = '0'"); if ($order_query->num_rows) { $order_row = $this->dcrypt->decrypt_data($order_query->row, 'orders'); //if promotions applied - updates total and add row to order_total for promo type $update = array(); $update[] = "order_status_id = '" . (int) $order_status_id . "'"; $sql = "UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t SET " . implode(", ", $update) . "\n\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'"; $this->db->query($sql); $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n\t\t\t\t\t\t\t SET order_id = '" . (int) $order_id . "',\n\t\t\t\t\t\t\t order_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t notify = '1',\n\t\t\t\t\t\t\t comment = '" . $this->db->escape($comment) . "',\n\t\t\t\t\t\t\t date_added = NOW()"); $order_row['comment'] = $order_row['comment'] . ' ' . $comment; $order_product_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t FROM " . $this->db->table("order_products") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE order_id = '" . (int) $order_id . "'"); foreach ($order_product_query->rows as $product) { $this->db->query("UPDATE " . $this->db->table("products") . "\n\t\t\t\t\t\t\t\t\t SET quantity = (quantity - " . (int) $product['quantity'] . ")\n\t\t\t\t\t\t\t\t\t WHERE product_id = '" . (int) $product['product_id'] . "' AND subtract = 1"); $order_option_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_options") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { $this->db->query("UPDATE " . $this->db->table("product_option_values") . "\n\t\t\t\t\t\t\t\t\t SET quantity = (quantity - " . (int) $product['quantity'] . ")\n\t\t\t\t\t\t\t\t\t WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "'\n\t\t\t\t\t\t\t\t\t AND subtract = 1"); } $this->cache->delete('product'); } $language = new ALanguage($this->registry, $order_row['code']); $language->load($order_row['filename']); $language->load('mail/order_confirm'); $this->load->model('localisation/currency'); $order_status_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_statuses") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_status_id = '" . (int) $order_status_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $order_row['language_id'] . "'"); $order_product_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_products") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'"); $order_total_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_totals") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY sort_order ASC"); $order_download_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_downloads") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'"); $subject = sprintf($language->get('text_subject'), $order_row['store_name'], $order_id); // HTML Mail $template = new ATemplate(); $template->data['title'] = sprintf($language->get('text_subject'), html_entity_decode($order_row['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); $template->data['text_greeting'] = sprintf($language->get('text_greeting'), html_entity_decode($order_row['store_name'], ENT_QUOTES, 'UTF-8')); $template->data['text_order_detail'] = $language->get('text_order_detail'); $template->data['text_order_id'] = $language->get('text_order_id'); $template->data['text_invoice'] = $language->get('text_invoice'); $template->data['text_date_added'] = $language->get('text_date_added'); $template->data['text_telephone'] = $language->get('text_telephone'); $template->data['text_email'] = $language->get('text_email'); $template->data['text_ip'] = $language->get('text_ip'); $template->data['text_fax'] = $language->get('text_fax'); $template->data['text_shipping_address'] = $language->get('text_shipping_address'); $template->data['text_payment_address'] = $language->get('text_payment_address'); $template->data['text_shipping_method'] = $language->get('text_shipping_method'); $template->data['text_payment_method'] = $language->get('text_payment_method'); $template->data['text_comment'] = $language->get('text_comment'); $template->data['text_powered_by'] = $language->get('text_powered_by'); $template->data['text_project_label'] = $language->get('text_powered_by') . ' ' . project_base(); $template->data['column_product'] = $language->get('column_product'); $template->data['column_model'] = $language->get('column_model'); $template->data['column_quantity'] = $language->get('column_quantity'); $template->data['column_price'] = $language->get('column_price'); $template->data['column_total'] = $language->get('column_total'); $template->data['order_id'] = $order_id; $template->data['customer_id'] = $order_row['customer_id']; $template->data['date_added'] = dateISO2Display($order_row['date_added'], $language->get('date_format_short')); $template->data['logo'] = 'cid:' . md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION); $template->data['store_name'] = $order_row['store_name']; $template->data['address'] = nl2br($this->config->get('config_address')); $template->data['telephone'] = $this->config->get('config_telephone'); $template->data['fax'] = $this->config->get('config_fax'); $template->data['email'] = $this->config->get('store_main_email'); $template->data['store_url'] = $order_row['store_url']; $template->data['invoice'] = $order_row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id; $template->data['firstname'] = $order_row['firstname']; $template->data['lastname'] = $order_row['lastname']; $template->data['shipping_method'] = $order_row['shipping_method']; $template->data['payment_method'] = $order_row['payment_method']; $template->data['customer_email'] = $order_row['email']; $template->data['customer_telephone'] = $order_row['telephone']; $template->data['customer_ip'] = $order_row['ip']; $template->data['comment'] = trim(nl2br($order_row['comment'])); //override with the data from the before hooks if ($this->data) { $template->data = array_merge($template->data, $this->data); } $this->load->model('localisation/zone'); $zone_row = $this->model_localisation_zone->getZone($order_row['shipping_zone_id']); if ($zone_row) { $zone_code = $zone_row['code']; } else { $zone_code = ''; } $shipping_data = array('firstname' => $order_row['shipping_firstname'], 'lastname' => $order_row['shipping_lastname'], 'company' => $order_row['shipping_company'], 'address_1' => $order_row['shipping_address_1'], 'address_2' => $order_row['shipping_address_2'], 'city' => $order_row['shipping_city'], 'postcode' => $order_row['shipping_postcode'], 'zone' => $order_row['shipping_zone'], 'zone_code' => $zone_code, 'country' => $order_row['shipping_country']); $template->data['shipping_address'] = $this->customer->getFormatedAdress($shipping_data, $order_row['shipping_address_format']); $zone_row = $this->model_localisation_zone->getZone($order_row['payment_zone_id']); if ($zone_row) { $zone_code = $zone_row['code']; } else { $zone_code = ''; } $payment_data = array('firstname' => $order_row['payment_firstname'], 'lastname' => $order_row['payment_lastname'], 'company' => $order_row['payment_company'], 'address_1' => $order_row['payment_address_1'], 'address_2' => $order_row['payment_address_2'], 'city' => $order_row['payment_city'], 'postcode' => $order_row['payment_postcode'], 'zone' => $order_row['payment_zone'], 'zone_code' => $zone_code, 'country' => $order_row['payment_country']); $template->data['payment_address'] = $this->customer->getFormatedAdress($payment_data, $order_row['payment_address_format']); if (!has_value($this->data['products'])) { $this->data['products'] = array(); } foreach ($order_product_query->rows as $product) { $option_data = array(); $order_option_query = $this->db->query("SELECT oo.*, po.element_type\n\t\t\t\t\t\tFROM " . $this->db->table("order_options") . " oo\n\t\t\t\t\t\tLEFT JOIN " . $this->db->table("product_option_values") . " pov\n\t\t\t\t\t\t\tON pov.product_option_value_id = oo.product_option_value_id\n\t\t\t\t\t\tLEFT JOIN " . $this->db->table("product_options") . " po\n\t\t\t\t\t\t\tON po.product_option_id = pov.product_option_id\n\t\t\t\t\t\tWHERE oo.order_id = '" . (int) $order_id . "' AND oo.order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { if ($option['element_type'] == 'H') { continue; } elseif ($option['element_type'] == 'C' && in_array($option['value'], array(0, 1, ''))) { $option['value'] = ''; } $option_data[] = array('name' => $option['name'], 'value' => $option['value']); } $this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'], $order_row['currency'], $order_row['value']), 'total' => $this->currency->format($product['total'], $order_row['currency'], $order_row['value'])); } $template->data['products'] = $this->data['products']; $template->data['totals'] = $order_total_query->rows; $html = $template->fetch('mail/order_confirm.tpl'); // Text Mail $text = sprintf($language->get('text_greeting'), html_entity_decode($order_row['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n"; $text .= $language->get('text_order_id') . ' ' . $order_id . "\n"; $text .= $language->get('text_date_added') . ' ' . dateISO2Display($order_row['date_added'], $language->get('date_format_short')) . "\n"; $text .= $language->get('text_order_status') . ' ' . $order_status_query->row['name'] . "\n\n"; $text .= $language->get('text_product') . "\n"; foreach ($order_product_query->rows as $result) { $text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_row['currency'], $order_row['value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . $this->db->table("order_options") . " WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { $text .= chr(9) . '-' . $option['name'] . ' ' . $option['value'] . "\n"; } } $text .= "\n"; $text .= $language->get('text_total') . "\n"; foreach ($order_total_query->rows as $result) { $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n"; } $order_total = $result['text']; $text .= "\n"; if ($order_row['customer_id']) { $text .= $language->get('text_invoice') . "\n"; $text .= $order_row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id . "\n\n"; } if ($order_download_query->num_rows) { $text .= $language->get('text_download') . "\n"; $text .= $order_row['store_url'] . 'index.php?rt=account/download' . "\n\n"; } if ($order_row['comment'] != '') { $comment = $order_row['comment'] . "\n\n" . $comment; } if ($comment) { $text .= $language->get('text_comment') . "\n\n"; $text .= $comment . "\n\n"; } $text .= $language->get('text_footer'); $mail = new AMail($this->config); $mail->setTo($order_row['email']); $mail->setFrom($this->config->get('store_main_email')); $mail->setSender($order_row['store_name']); $mail->setSubject($subject); $mail->setHtml($html); $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8')); $mail->addAttachment(DIR_RESOURCE . $this->config->get('config_logo'), md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION)); $mail->send(); if ($this->config->get('config_alert_mail')) { // HTML $template->data['text_greeting'] = $language->get('text_received') . "\n\n"; $template->data['invoice'] = ''; $template->data['text_invoice'] = ''; $html = $template->fetch('mail/order_confirm.tpl'); $subject = sprintf($language->get('text_subject'), html_entity_decode($this->config->get('store_name'), ENT_QUOTES, 'UTF-8'), $order_id . ' (' . $order_total . ')'); $mail->setSubject($subject); $mail->setTo($this->config->get('store_main_email')); $mail->setHtml($html); $mail->send(); // Send to additional alert emails $emails = explode(',', $this->config->get('config_alert_emails')); foreach ($emails as $email) { if (trim($email)) { $mail->setTo($email); $mail->send(); } } } $msg_text = sprintf($language->get('text_new_order_text'), $order_row['firstname'] . ' ' . $order_row['lastname']); $msg_text .= "<br/><br/>"; foreach ($template->data['totals'] as $total) { $msg_text .= $total['title'] . ' - ' . $total['text'] . "<br/>"; } $msg = new AMessage(); $msg->saveNotice($language->get('text_new_order') . $order_id, $msg_text); } }
public function main() { $this->loadModel('tool/forms_manager'); $this->loadLanguage('forms_manager/forms_manager'); $this->loadLanguage('forms_manager/default_email'); if ($this->request->is_POST()) { $path = $_SERVER['HTTP_REFERER']; if (!isset($this->request->get['form_id'])) { $this->redirect($path); exit; } $form_id = $this->request->get['form_id']; $form_data = $this->model_tool_forms_manager->getForm($form_id); $form = new AForm($form_data['form_name']); $form->loadFromDb($form_data['form_name']); $errors = $form->validateFormData($this->request->post); if ($errors) { //save error and data to session $this->session->data['custom_form_' . $form_id] = $this->request->post; $this->session->data['custom_form_' . $form_id]['errors'] = $errors; $this->redirect($path); exit; } else { $mail = new AMail($this->config); $mail->setTo($this->config->get('store_main_email')); if (isset($this->request->post['email'])) { $mail->setFrom($this->request->post['email']); unset($this->request->post['email']); } else { $sender_email = $this->config->get('forms_manager_default_sender_email'); $sender_email = !$sender_email ? $this->config->get('store_main_email') : $sender_email; $mail->setFrom($sender_email); } if (isset($this->request->post['first_name'])) { $mail->setSender($this->request->post['first_name']); unset($this->request->post['first_name']); } else { $sender_name = $this->config->get('forms_manager_default_sender_name'); $sender_name = !$sender_name ? $this->config->get('store_name') : $sender_name; $mail->setSender($sender_name); } if (isset($this->request->post['email_subject'])) { $mail->setSubject($this->request->post['email_subject']); unset($this->request->post['email_subject']); } else { $mail->setSubject($form_data['form_name']); } $msg = $this->config->get('store_name') . "\r\n" . $this->config->get('config_url') . "\r\n"; $fields = $this->model_tool_forms_manager->getFields($form_id); foreach ($fields as $field) { // skip files and captchas if (in_array($field['element_type'], array('K', 'J', 'U'))) { continue; } if (isset($this->request->post[$field['field_name']])) { $val = $this->request->post[$field['field_name']]; $val = $this->_prepareValue($val); //for zones if ($field['element_type'] == 'Z') { $msg .= $field['name'] . ': ' . $val . ""; $val = $this->request->post[$field['field_name'] . '_zones']; $val = $this->_prepareValue($val); $msg .= "\t" . $val . "\r\n"; } else { $msg .= $field['name'] . ': ' . $val . "\r\n"; } } } // add attachments $file_pathes = $form->processFileUploads($this->request->files); if ($file_pathes) { $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n"; foreach ($file_pathes as $file_info) { $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME); $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n"; $mail->addAttachment($file_info['path'], $basename); } } $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'))); $mail->send(); if (empty($mail->error)) { if ($form_data['success_page']) { $success_url = $this->html->getSecureURL($form_data['success_page']); } else { $success_url = $this->html->getSecureURL('forms_manager/default_email/success'); } //clear form session unset($this->session->data['custom_form_' . $form_id]); $this->redirect($success_url); exit; } else { $this->session->data['warning'] = $mail->error; $this->redirect($this->html->getSecureURL('forms_manager/default_email', '&form_id=' . $form_id)); exit; } } } $this->data['warning'] = $this->session->data['warning']; if (isset($this->session->data['warning'])) { unset($this->session->data['warning']); } $this->document->setTitle($this->language->get('text_default_email_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('forms_manager/default_email'), 'text' => $this->language->get('text_default_email_title'), 'separator' => $this->language->get('text_separator'))); $this->data['continue'] = $_SERVER['HTTP_REFERER']; $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button', 'icon' => 'icon-arrow-right')); $this->data['continue_button'] = $continue; $this->view->batchAssign($this->data); $this->processTemplate('pages/default_email.tpl'); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if ($this->customer->isLogged()) { $this->redirect($this->html->getSecureURL('account/account')); } $this->document->setTitle($this->language->get('heading_title')); $this->loadModel('account/customer'); $request_data = $this->request->post; if ($this->request->is_POST()) { $this->errors = array_merge($this->errors, $this->model_account_customer->validateRegistrationData($request_data)); if (!$this->errors) { //if allow login as email, need to set loginname = email if (!$this->config->get('prevent_email_as_login')) { $request_data['loginname'] = $request_data['email']; } $this->data['customer_id'] = $this->model_account_customer->addCustomer($request_data); $this->model_account_customer->editCustomerNotifications($request_data, $this->data['customer_id']); unset($this->session->data['guest']); //login customer after create account is approvement and email activation are disabled in settings if (!$this->config->get('config_customer_approval') && !$this->config->get('config_customer_email_activation')) { $this->customer->login($request_data['loginname'], $request_data['password']); } $template = new ATemplate(); $this->loadLanguage('mail/account_create'); $subject = sprintf($this->language->get('text_subject'), $this->config->get('store_name')); $message = sprintf($this->language->get('text_welcome'), $this->config->get('store_name')) . "\n\n"; $template->data['text_welcome'] = $message; $activation = false; if (!$this->config->get('config_customer_approval')) { //add account activation link if required if ($this->config->get('config_customer_email_activation')) { $activation = true; // sign of activation email $code = md5(mt_rand(1, 3000)); $email = $this->request->post['email']; $this->session->data['activation'] = array('customer_id' => $this->data['customer_id'], 'code' => $code, 'email' => $email); $activate_url = $this->html->getSecureURL('account/login', '&activation=' . $code . '&email=' . $email); $message .= sprintf($this->language->get('text_activate'), $activate_url . "\n") . "\n"; $template->data['text_activate'] = sprintf($this->language->get('text_activate'), '<a href="' . $activate_url . '">' . $activate_url . '</a>'); } else { $message .= $this->language->get('text_login') . "\n"; $template->data['text_login'] = $this->language->get('text_login'); } } else { $message .= $this->language->get('text_approval') . "\n"; $template->data['text_approval'] = $this->language->get('text_approval'); } if (!$activation) { $login_url = $this->html->getSecureURL('account/login'); $message .= $login_url . "\n\n"; $message .= $this->language->get('text_services') . "\n\n"; $template->data['text_login_later'] = '<a href="' . $login_url . '">' . $login_url . '</a><br>' . $this->language->get('text_services'); } $message .= $this->language->get('text_thanks') . "\n"; $message .= $this->config->get('store_name'); $template->data['text_thanks'] = $this->language->get('text_thanks'); $mail = new AMail($this->config); $mail->setTo($this->request->post['email']); $mail->setFrom($this->config->get('store_main_email')); $mail->setSender($this->config->get('store_name')); $mail->setSubject($subject); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $store_logo = md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION); $template->data['logo'] = 'cid:' . $store_logo; $template->data['store_name'] = $this->config->get('store_name'); $template->data['store_url'] = $this->config->get('config_url'); $template->data['text_project_label'] = project_base(); $mail_html = $template->fetch('mail/account_create.tpl'); $mail->addAttachment(DIR_RESOURCE . $this->config->get('config_logo'), $store_logo); $mail->setHtml($mail_html); $mail->send(); $this->extensions->hk_UpdateData($this, __FUNCTION__); //set success text for non-approved customers on login page after redirect if ($this->config->get('config_customer_approval')) { $this->loadLanguage('account/success'); $this->session->data['success'] = sprintf($this->language->get('text_approval', 'account/success'), $this->config->get('store_name'), $this->html->getSecureURL('content/contact')); } if ($this->config->get('config_customer_email_activation') || !$this->session->data['redirect']) { $redirect_url = $this->html->getSecureURL('account/success'); } else { $redirect_url = $this->session->data['redirect']; } $this->redirect($redirect_url); } else { if (!$this->errors['warning']) { $this->errors['warning'] = implode('<br>', $this->errors); } } } $this->document->initBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/create'), 'text' => $this->language->get('text_create'), 'separator' => $this->language->get('text_separator'))); if ($this->config->get('prevent_email_as_login')) { $this->data['noemaillogin'] = true; } $form = new AForm(); $form->setForm(array('form_name' => 'AccountFrm')); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'AccountFrm', 'action' => $this->html->getSecureURL('account/create'))); if ($this->config->get('prevent_email_as_login')) { // require login name $this->data['form']['fields']['general']['loginname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'loginname', 'value' => $this->request->post['loginname'], 'required' => true)); } $this->data['form']['fields']['general']['firstname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'firstname', 'value' => $this->request->post['firstname'], 'required' => true)); $this->data['form']['fields']['general']['lastname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'lastname', 'value' => $this->request->post['lastname'], 'required' => true)); $this->data['form']['fields']['general']['email'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'email', 'value' => $this->request->get_or_post('email'), 'required' => true)); $this->data['form']['fields']['general']['telephone'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'telephone', 'value' => $this->request->post['telephone'])); $this->data['form']['fields']['general']['fax'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'fax', 'value' => $this->request->post['fax'], 'required' => false)); //get only active IM drivers $im_drivers = $this->im->getIMDriverObjects(); if ($im_drivers) { foreach ($im_drivers as $protocol => $driver_obj) { if (!is_object($driver_obj) || $protocol == 'email') { continue; } $fld = $driver_obj->getURIField($form, $this->request->post[$protocol]); $this->data['form']['fields']['general'][$protocol] = $fld; $this->data['entry_' . $protocol] = $fld->label_text; } } $this->data['form']['fields']['address']['company'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'company', 'value' => $this->request->post['company'], 'required' => false)); $this->data['form']['fields']['address']['address_1'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'address_1', 'value' => $this->request->post['address_1'], 'required' => true)); $this->data['form']['fields']['address']['address_2'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'address_2', 'value' => $this->request->post['address_2'], 'required' => false)); $this->data['form']['fields']['address']['city'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'city', 'value' => $this->request->post['city'], 'required' => true)); $this->view->assign('zone_id', $this->request->post['zone_id'], 'FALSE'); $this->data['form']['fields']['address']['zone'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'zone_id', 'required' => true)); $this->data['form']['fields']['address']['postcode'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'postcode', 'value' => $this->request->post['postcode'], 'required' => true)); $this->loadModel('localisation/country'); $countries = $this->model_localisation_country->getCountries(); $options = array("FALSE" => $this->language->get('text_select')); foreach ($countries as $item) { $options[$item['country_id']] = $item['name']; } $this->data['form']['fields']['address']['country'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'country_id', 'options' => $options, 'value' => isset($this->request->post['country_id']) ? $this->request->post['country_id'] : $this->config->get('config_country_id'), 'required' => true)); $this->data['form']['fields']['password']['password'] = $form->getFieldHtml(array('type' => 'password', 'name' => 'password', 'value' => $this->request->post['password'], 'required' => true)); $this->data['form']['fields']['password']['confirm'] = $form->getFieldHtml(array('type' => 'password', 'name' => 'confirm', 'value' => $this->request->post['confirm'], 'required' => true)); $this->data['form']['fields']['newsletter']['newsletter'] = $form->getFieldHtml(array('type' => 'radio', 'name' => 'newsletter', 'value' => !is_null($this->request->get_or_post('newsletter')) ? $this->request->get_or_post('newsletter') : -1, 'options' => array('1' => $this->language->get('text_yes'), '0' => $this->language->get('text_no')))); //If captcha enabled, validate if ($this->config->get('config_account_create_captcha')) { if ($this->config->get('config_recaptcha_site_key')) { $this->data['form']['fields']['newsletter']['captcha'] = $form->getFieldHtml(array('type' => 'recaptcha', 'name' => 'recaptcha', 'recaptcha_site_key' => $this->config->get('config_recaptcha_site_key'), 'language_code' => $this->language->getLanguageCode())); } else { $this->data['form']['fields']['newsletter']['captcha'] = $form->getFieldHtml(array('type' => 'captcha', 'name' => 'captcha', 'attr' => '')); } } //TODO: REMOVE THIS IN 1.3!!! // backward compatibility code $deprecated = $this->data['form']['fields']; foreach ($deprecated as $section => $fields) { foreach ($fields as $name => $fld) { if (in_array($name, array('country', 'zone'))) { $name .= '_id'; } $this->data['form'][$name] = $fld; } } //end of trick $agree = isset($this->request->post['agree']) ? $this->request->post['agree'] : false; $this->data['form']['agree'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'agree', 'value' => 1, 'checked' => $agree)); $this->data['form']['continue'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_continue'))); $this->data['error_warning'] = $this->errors['warning']; $this->data['error_loginname'] = $this->errors['loginname']; $this->data['error_firstname'] = $this->errors['firstname']; $this->data['error_lastname'] = $this->errors['lastname']; $this->data['error_email'] = $this->errors['email']; $this->data['error_telephone'] = $this->errors['telephone']; $this->data['error_password'] = $this->errors['password']; $this->data['error_confirm'] = $this->errors['confirm']; $this->data['error_address_1'] = $this->errors['address_1']; $this->data['error_city'] = $this->errors['city']; $this->data['error_postcode'] = $this->errors['postcode']; $this->data['error_country'] = $this->errors['country']; $this->data['error_zone'] = $this->errors['zone']; $this->data['error_captcha'] = $this->errors['captcha']; $this->data['action'] = $this->html->getSecureURL('account/create'); $this->data['newsletter'] = $this->request->post['newsletter']; if ($this->config->get('config_account_id')) { $this->loadModel('catalog/content'); $content_info = $this->model_catalog_content->getContent($this->config->get('config_account_id')); if ($content_info) { $text_agree = $this->language->get('text_agree'); $this->data['text_agree_href'] = $this->html->getURL('r/content/content/loadInfo', '&content_id=' . $this->config->get('config_account_id')); $this->data['text_agree_href_text'] = $content_info['title']; } else { $text_agree = ''; } } else { $text_agree = ''; } $this->data['text_agree'] = $text_agree; $text_account_already = sprintf($this->language->get('text_account_already'), $this->html->getSecureURL('account/login')); $this->data['text_account_already'] = $text_account_already; $this->view->batchAssign($this->data); $this->processTemplate('pages/account/create.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->form = new AForm('ContactUsFrm'); $this->form->loadFromDb('ContactUsFrm'); $form = $this->form->getForm(); if ($this->request->is_POST() && $this->_validate()) { // move all uploaded files to their directories $file_pathes = $this->form->processFileUploads($this->request->files); $template = new ATemplate(); $subject = sprintf($this->language->get('email_subject'), $this->request->post['name']); $template->data['subject'] = $subject; $mail = new AMail($this->config); $mail->setTo($this->config->get('store_main_email')); $mail->setFrom($this->config->get('store_main_email')); $mail->setReplyTo($this->request->post['email']); $mail->setSender($this->request->post['first_name']); $mail->setSubject($subject); $store_logo = md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION); $template->data['logo'] = 'cid:' . $store_logo; $template->data['store_name'] = $this->config->get('store_name'); $template->data['store_url'] = $this->config->get('config_url'); $template->data['text_project_label'] = project_base(); $template->data['entry_enquiry'] = $msg = $this->language->get('entry_enquiry'); $msg .= "\r\n" . $this->request->post['enquiry'] . "\r\n"; $template->data['enquiry'] = nl2br($this->request->post['enquiry'] . "\r\n"); $form_fields = $this->form->getFields(); $template->data['form_fields'] = array(); foreach ($form_fields as $field_name => $field_info) { if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) { $field_details = $this->form->getField($field_name); $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name]; $template->data['form_fields'][rtrim($field_details['name'], ':')] = $this->request->post[$field_name]; } } if ($file_pathes) { $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n"; foreach ($file_pathes as $file_info) { $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME); $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n"; $mail->addAttachment($file_info['path'], $basename); $template->data['form_fields'][$file_info['display_name']] = $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)"; } } $mail_html = $template->fetch('mail/contact.tpl'); $mail->setHtml($mail_html); $mail->addAttachment(DIR_RESOURCE . $this->config->get('config_logo'), $store_logo); $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'))); $mail->send(); //get success_page if ($form['success_page']) { $success_url = $this->html->getSecureURL($form['success_page']); } else { $success_url = $this->html->getSecureURL('content/contact/success'); } //notify admin $this->loadLanguage('common/im'); $message_arr = array(1 => array('message' => sprintf($this->language->get('im_customer_contact_admin_text'), $this->request->post['email'], $this->request->post['first_name']))); $this->im->send('customer_contact', $message_arr); $this->extensions->hk_ProcessData($this); $this->redirect($success_url); } if ($this->request->is_POST()) { foreach ($this->request->post as $name => $value) { $this->form->assign($name, $value); } } $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('form_output', $this->form->getFormHtml()); $this->view->assign('action', $this->html->getURL('content/contact')); $this->view->assign('store', $this->config->get('store_name')); $this->view->assign('address', nl2br($this->config->get('config_address'))); $this->view->assign('telephone', $this->config->get('config_telephone')); $this->view->assign('fax', $this->config->get('config_fax')); $this->processTemplate('pages/content/contact.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }