public function render() { $output = ''; if (!empty($this->field)) { $data = array(); $data += parent::setGeneralData(); $data['text_select'] = oc::registry()->load->language->get('text_select'); $data['multiple'] = $this->field['type']['multiple']; if ($data['multiple']) { $data['class'] .= ($data['class'] ? ' ' : '') . 'multiple'; } $data['selected'] = array(); if ($data['value']) { if (is_array($data['value'])) { $data['selected'] = $data['value']; } else { $data['selected'][] = $data['value']; } } elseif (!empty($this->field['type']['selected'])) { $data['selected'][] = $this->field['type']['selected']; } if (!empty($this->field['type']['option']) && $this->field['type']['option']) { $data['option'] = $this->field['type']['option']; } else { return $output; } $output = $this->renderField($data); } return $output; }
public function render() { $output = ''; if (!empty($this->field)) { $data = array(); $data += parent::setGeneralData(); if (isset($this->field['type']['maxlength']) && $this->field['type']['maxlength']) { $data['maxlength'] = $this->field['type']['maxlength']; } else { $data['maxlength'] = 32; } if ($this->field['code'] == 'captcha') { $setting = oc::registry()->config->get('quick_order_pro_setting'); $data['maxlength'] = $setting['captcha_count_items']; $data['text_captcha_reload'] = oc::registry()->load->language->get('text_captcha_reload'); } $data['mask'] = $data['placeholder'] = ''; if (!empty($this->field['type']['use_mask']) && $this->field['type']['use_mask'] && !empty($this->field['type']['mask'])) { $data['mask'] = $this->field['type']['mask']; oc::registry()->document->addScript('catalog/view/javascript/quick_order_pro/jquery.maskedinput.min.js'); } if (!empty($this->field['type']['placeholder'])) { $data['placeholder'] = $this->field['type']['placeholder']; } $output = $this->renderField($data); } return $output; }
public static function find($file, $setting = array()) { $template = ''; $available_directories = array(); $available_directories[] = DIRECTORY_SEPARATOR; if (isset($setting['position'])) { $available_directories[] = ($setting['position'] ? 'content' : 'sidebar') . DIRECTORY_SEPARATOR; } if (isset($setting['template_id'])) { $available_directories[] = 'template_' . $setting['template_id'] . DIRECTORY_SEPARATOR; } if (isset($setting['layout_id'])) { $available_directories[] = 'layout_' . $setting['layout_id'] . DIRECTORY_SEPARATOR; } foreach (array(oc::registry()->config->get('config_template'), 'default') as $theme) { $directory = $theme . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . 'module' . DIRECTORY_SEPARATOR . 'quick_order_pro'; $iterations = $available_directories; while (!empty($iterations)) { $available_directory = implode('', $iterations); if (file_exists(DIR_TEMPLATE . $directory . $available_directory . $file . '.tpl')) { $template = $directory . $available_directory . $file . '.tpl'; } if ($template) { break 2; } array_pop($iterations); } } return $template; }
public function validate($value) { $validate = TRUE; $form_id = oc::registry()->message->data['form_id']; if (!$form_id || !isset(oc::registry()->session->data['quick_order_pro_captcha'][$form_id]) || oc::registry()->session->data['quick_order_pro_captcha'][$form_id] != $value) { $validate = FALSE; } return $validate; }
public static function init() { global $registry, $request, $url, $config, $setting, $session; self::$registry = $registry; self::$request = $request; self::$url = $url; self::$config = $config; self::$setting = $setting; self::$session = $session; }
public static function renderFields($fields) { spl_autoload_register(array('field', 'autoloader_field'), FALSE, TRUE); $data = $options = $data['fields'] = $sort_order = array(); foreach ($fields as $key => $value) { $sort_order[$key] = $value['weight']; } array_multisort($sort_order, SORT_ASC, $fields); foreach ($fields as $field_id => $field_info) { if (!$field_info['status']) { continue; } $action = self::getAction($field_info['type']['type']); if (!empty($action['class'])) { $data['fields'][] = $action['class']::getInstance($field_info)->render(); } } $last_form_id = oc::registry()->config->get('quick_order_pro_last_form_id'); if (!empty($last_form_id)) { $options = id::decode($last_form_id); $data += $options; } return tpl::getInstance(tpl::find('fields', $options), $data)->render(); }
public function confirm($order_id, $order_status_id, $data) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info && !$order_info['order_status_id']) { $setting = $this->getSetting(); $sql = "UPDATE `" . DB_PREFIX . "order` SET "; $sql .= "order_status_id = '" . (int) $order_status_id . "', "; $sql .= "date_modified = NOW() "; $sql .= "WHERE order_id = '" . (int) $order_id . "'"; $this->db->query($sql); $sql = "INSERT INTO " . DB_PREFIX . "order_history SET "; $sql .= "order_id = '" . (int) $order_id . "', "; $sql .= "order_status_id = '" . (int) $order_status_id . "', "; $sql .= "notify = '1', "; $sql .= "comment = '', "; $sql .= "date_added = NOW()"; $this->db->query($sql); $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'"); if ($setting['subtract']) { if ($setting['subtract'] == 'default') { $subtract = ' AND subtract = "1"'; } else { $subtract = ''; } foreach ($order_product_query->rows as $order_product) { $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_id = '" . (int) $order_product['product_id'] . "'" . $subtract); $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "'" . $subtract); } } $this->cache->delete('product'); } $order_total_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC"); $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "'"); $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $order_status = $order_status_query->row['name']; } else { $order_status = ''; } // Send out order confirmation mail $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/quick_order_pro'); $subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id); // HTML Mail $template = new Template(); $template->data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); $template->data['text_greeting'] = sprintf($language->get('text_new_greeting'), $order_info['store_url'], html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); $template->data['text_greeting_detail'] = $language->get('text_new_greeting_detail'); $template->data['text_order_detail'] = $language->get('text_new_order_detail'); $template->data['text_instruction'] = $language->get('text_new_instruction'); $template->data['text_date_added'] = $language->get('text_new_date_added'); $template->data['text_ip'] = $language->get('text_new_ip'); $template->data['text_product'] = $language->get('text_new_product'); $template->data['text_model'] = $language->get('text_new_model'); $template->data['text_quantity'] = $language->get('text_new_quantity'); $template->data['text_price'] = $language->get('text_new_price'); $template->data['text_total'] = $language->get('text_new_total'); $template->data['text_footer'] = $language->get('text_new_footer'); $template->data['store_name'] = $order_info['store_name']; $template->data['store_url'] = $order_info['store_url']; $template->data['fields'] = array(); foreach ($data['custom_fields'] as $code => $field_info) { if ($code == 'comment') { continue; } $template->data['fields'][] = array('name' => $field_info['title'], 'value' => $field_info['value']); } if ($setting['customer_email_show_date_added']) { $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added'])); } if ($setting['customer_email_show_ip']) { $template->data['ip'] = $order_info['ip']; } $template->data['comment'] = $order_info['comment']; $template->data['products'] = array(); foreach ($order_product_query->rows as $product) { $option_data = array(); $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { if ($option['type'] != 'file') { $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']); } else { $filename = substr($option['value'], 0, strrpos($option['value'], '.')); $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($filename) > 20 ? utf8_substr($filename, 0, 20) . '..' : $filename); } } $template->data['products'][] = array('name' => $product['name'], 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value'])); } $template->data['totals'] = $order_total_query->rows; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/quick_order_pro.tpl')) { $html = $template->fetch($this->config->get('config_template') . '/template/mail/quick_order_pro.tpl'); } else { $html = $template->fetch('default/template/mail/quick_order_pro.tpl'); } // Text Mail $text = sprintf($language->get('text_new_greeting'), $order_info['store_url'], html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n"; $text .= $language->get('text_new_greeting_detail') . "\n\n"; foreach ($data['custom_fields'] as $code => $field_info) { if ($code == 'comment') { continue; } $text .= $field_info['title'] . ': ' . $field_info['value'] . "\n"; } $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= "\n\n"; $text .= $language->get('text_new_products') . "\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_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option 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'] . ' ' . (utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']) . "\n"; } } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($order_total_query->rows as $result) { $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; if ($order_info['comment']) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $order_info['comment'] . "\n\n"; } $text .= $language->get('text_new_footer') . "\n\n"; $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject($subject); $mail->setHtml($html); $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8')); if ($setting['alert_customer'] && $order_info['email'] != '') { $mail->send(); } // Admin Alert Mail if ($setting['alert_admin']) { $subject = sprintf($language->get('text_new_subject_admin'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id); // Text $text = $language->get('text_new_received') . "\n\n"; $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; $text .= $language->get('text_new_customer_fields') . "\n"; foreach ($data['custom_fields'] as $code => $field_info) { if ($code == 'comment') { continue; } $text .= $field_info['title'] . ': ' . $field_info['value'] . "\n"; } $text .= "\n\n"; if ($setting['admin_email_send_password'] && $setting['create_customer']) { $text .= $language->get('text_customer_password') . ' ' . oc::registry()->message->data['customer_password'] . "\n\n"; } $text .= $language->get('text_new_products') . "\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_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option 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'] . ' ' . (utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']) . "\n"; } } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($order_total_query->rows as $result) { $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; $comment = ''; if ($order_info['comment'] != '') { $comment = $order_info['comment'] . "\n\n"; } if ($comment) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $comment . "\n\n"; } if ($setting['admin_email_type'] == 'config') { $email_to = $this->config->get('config_email'); } else { $email_to = $setting['alert_email']; } $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($email_to); $mail->setFrom($email_to); $mail->setSender($order_info['store_name']); $mail->setSubject($subject); if ($setting['admin_email_same_customer']) { $mail->setHtml($html); } $mail->setText($text); $mail->send(); // Send to additional alert emails $emails = explode(',', $setting['admin_emails']); foreach ($emails as $email) { if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) { $mail->setTo($email); $mail->send(); } } } // Send Admins SMS if configure if ($this->config->get('config_sms_alert')) { $options = array('to' => $this->config->get('config_sms_to'), 'copy' => $this->config->get('config_sms_copy'), 'from' => $this->config->get('config_sms_from'), 'username' => $this->config->get('config_sms_gate_username'), 'password' => $this->config->get('config_sms_gate_password'), 'message' => str_replace(array('{ID}', '{DATE}', '{TIME}', '{SUM}', '{PHONE}'), array($order_id, date('d.m.Y'), date('H:i'), floatval($order_info['total']), $order_info['telephone']), $this->config->get('config_sms_message'))); $this->load->library('sms'); $sms = new Sms($this->config->get('config_sms_gatename'), $options); $sms->send(); } } }
protected function getTokens() { return array('{field_name}' => $this->field_info['title'][oc::registry()->config->get('config_language_id')]); }
private function init() { $this->setting = $this->getSetting(); spl_autoload_register(array($this, 'autoloader')); spl_autoload_extensions('.php'); oc::registry()->message = new message(); }