protected function index()
 {
     $this->load->helper('widgets');
     $widgets = new NecoWidget($this->registry, $this->Route);
     foreach ($widgets->getWidgets('column_left') as $widget) {
         $settings = (array) unserialize($widget['settings']);
         if ($settings['asyn']) {
             $url = Url::createUrl("{$settings['route']}", $settings['params']);
             $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\n                        .attr({\n                            id:'" . $widget['name'] . "'\n                        })\n                        .html(makeWaiting())\n                        .load('" . $url . "')\n                        .appendTo('" . $settings['target'] . "');");
         } else {
             if (isset($settings['route'])) {
                 if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) {
                     if ($settings['autoload']) {
                         $this->data['widgets'][] = $widget['name'];
                     }
                     $this->children[$widget['name']] = $settings['route'];
                     $this->widget[$widget['name']] = $widget;
                 }
             }
         }
     }
     $this->id = 'column_left';
     if ($this->data['widgets']) {
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/column_left.tpl')) {
             $this->template = $this->config->get('config_template') . '/common/column_left.tpl';
         } else {
             $this->template = 'choroni/common/column_left.tpl';
         }
         $this->render();
     }
 }
 protected function index($widget = null)
 {
     if (isset($widget)) {
         $this->data['settings'] = $settings = (array) unserialize($widget['settings']);
         $this->data['widget_hook'] = $this->data['widgetName'] = $widget['name'];
     }
     $this->language->load('module/manufacturer');
     if (isset($settings['title'])) {
         $this->data['heading_title'] = $settings['title'];
     } else {
         $this->data['heading_title'] = $this->language->get('heading_title');
     }
     if (isset($this->request->get['manufacturer_id'])) {
         $this->data['manufacturer_id'] = $this->request->get['manufacturer_id'];
     } else {
         $this->data['manufacturer_id'] = 0;
     }
     $this->load->model('store/manufacturer');
     $this->data['manufacturers'] = array();
     $results = $this->modelManufacturer->getManufacturers();
     foreach ($results as $result) {
         $this->data['manufacturers'][] = array('manufacturer_id' => $result['manufacturer_id'], 'name' => $result['name'], 'href' => Url::createUrl("store/manufacturer", array("manufacturer_id" => $result['manufacturer_id'])));
     }
     $this->loadAssets();
     if ($scripts) {
         $this->scripts = array_merge($this->scripts, $scripts);
     }
     $this->id = 'manufacturer';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/module/manufacturer.tpl')) {
         $this->template = $this->config->get('config_template') . '/module/manufacturer.tpl';
     } else {
         $this->template = 'choroni/module/manufacturer.tpl';
     }
     $this->render();
 }
 protected function getCategories($parent_id, $current_path = '')
 {
     $output = '';
     $results = $this->modelCategory->getCategories($parent_id);
     foreach ($results as $result) {
         if (!$current_path) {
             $new_path = $result['category_id'];
         } else {
             $new_path = $current_path . '_' . $result['category_id'];
         }
         $output .= '<url>';
         $output .= '<loc>' . str_replace('&', '&amp;', Url::createUrl("store/category", array("path" => $new_path))) . '</loc>';
         $output .= '<changefreq>weekly</changefreq>';
         $output .= '<priority>0.7</priority>';
         $output .= '</url>';
         $products = $this->modelProduct->getProductsByCategoryId($result['category_id']);
         foreach ($products as $product) {
             $output .= '<url>';
             $output .= '<loc>' . str_replace('&', '&amp;', Url::createUrl("store/product", array("path" => $new_path, "product_id" => $product['product_id']))) . '</loc>';
             $output .= '<changefreq>weekly</changefreq>';
             $output .= '<priority>1.0</priority>';
             $output .= '</url>';
         }
         $output .= $this->getCategories($result['category_id'], $new_path);
     }
     return $output;
 }
 protected function getCategories($parent_id = 0)
 {
     $output = '';
     $results = $this->modelCategory->getCategories($parent_id);
     if ($results) {
         $output .= '<ul class="nt-dd2">';
         foreach ($results as $result) {
             $childrens = $this->modelCategory->getCategories($result['category_id']);
             if ($childrens) {
                 $output .= '<li class="hasCategories">';
             } else {
                 $output .= '<li>';
             }
             if ($this->category_id == $result['category_id']) {
                 $output .= '<a href="' . Url::createUrl("store/category", array("path" => $result['category_id'])) . '"><b>' . $result['name'] . '</b></a>';
             } else {
                 $output .= '<a href="' . Url::createUrl("store/category", array("path" => $result['category_id'])) . '">' . $result['name'] . '</a>';
             }
             if ($childrens) {
                 $output .= '<ul>';
                 foreach ($childrens as $child) {
                     $output .= '<li><a href="' . Url::createUrl("store/category", array("path" => $result['category_id'] . '_' . $child['category_id'])) . '" title="' . $child['name'] . '">' . $child['name'] . '</a></li>';
                 }
                 $output .= '</ul>';
             }
             $output .= '</li>';
         }
         $output .= '</ul>';
     }
     return $output;
 }
Пример #5
0
 protected function index($widget = null)
 {
     if (isset($widget)) {
         $this->data['settings'] = $settings = (array) unserialize($widget['settings']);
         $this->data['widget_hook'] = $this->data['widgetName'] = $widget['name'];
     }
     $this->language->load('module/page');
     if (isset($settings['title'])) {
         $this->data['heading_title'] = $settings['title'];
     } else {
         $this->data['heading_title'] = $this->language->get('heading_title');
     }
     $this->load->model('content/page');
     $this->data['pages'] = array();
     foreach ($this->modelPage->getAll() as $result) {
         $this->data['pages'][] = array('title' => $result['title'], 'href' => Url::createUrl("content/page", array("page_id" => $result['post_id'])));
     }
     $this->data['contact'] = Url::createUrl("page/contact");
     $this->data['sitemap'] = Url::createUrl("page/sitemap");
     $this->loadAssets();
     if ($scripts) {
         $this->scripts = array_merge($this->scripts, $scripts);
     }
     $this->id = 'page';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/module/page.tpl')) {
         $this->template = $this->config->get('config_template') . '/module/page.tpl';
     } else {
         $this->template = 'choroni/module/page.tpl';
     }
     $this->render();
 }
Пример #6
0
 /**
  * 重定向.
  *
  * @access protected
  * @param string $route 路由.
  * @param array $params 参数, 默认 [].
  */
 protected function redirect($route, array $params = [])
 {
     $url = Url::createUrl($route, $params);
     if (!headers_sent()) {
         header('Location: ' . $url);
         exit;
     }
     exit('<meta http-equiv="refresh" content="0" url="' . $url . '" />');
 }
Пример #7
0
 protected function loadWidgets()
 {
     $this->load->helper('widgets');
     $widgets = new NecoWidget($this->registry, $this->Route);
     foreach ($widgets->getWidgets('main') as $widget) {
         $settings = (array) unserialize($widget['settings']);
         if ($settings['asyn']) {
             $url = Url::createUrl("{$settings['route']}", $settings['params']);
             $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n                        .attr({\r\n                            id:'" . $widget['name'] . "'\r\n                        })\r\n                        .html(makeWaiting())\r\n                        .load('" . $url . "')\r\n                        .appendTo('" . $settings['target'] . "');");
         } else {
             if (isset($settings['route'])) {
                 if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) {
                     if ($settings['autoload']) {
                         $this->data['widgets'][] = $widget['name'];
                     }
                     $this->children[$widget['name']] = $settings['route'];
                     $this->widget[$widget['name']] = $widget;
                 }
             }
         }
     }
     foreach ($widgets->getWidgets('featuredContent') as $widget) {
         $settings = (array) unserialize($widget['settings']);
         if ($settings['asyn']) {
             $url = Url::createUrl("{$settings['route']}", $settings['params']);
             $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n                        .attr({\r\n                            id:'" . $widget['name'] . "'\r\n                        })\r\n                        .html(makeWaiting())\r\n                        .load('" . $url . "')\r\n                        .appendTo('" . $settings['target'] . "');");
         } else {
             if (isset($settings['route'])) {
                 if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) {
                     if ($settings['autoload']) {
                         $this->data['featuredWidgets'][] = $widget['name'];
                     }
                     $this->children[$widget['name']] = $settings['route'];
                     $this->widget[$widget['name']] = $widget;
                 }
             }
         }
     }
     foreach ($widgets->getWidgets('featuredFooter') as $widget) {
         $settings = (array) unserialize($widget['settings']);
         if ($settings['asyn']) {
             $url = Url::createUrl("{$settings['route']}", $settings['params']);
             $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n                        .attr({\r\n                            id:'" . $widget['name'] . "'\r\n                        })\r\n                        .html(makeWaiting())\r\n                        .load('" . $url . "')\r\n                        .appendTo('" . $settings['target'] . "');");
         } else {
             if (isset($settings['route'])) {
                 if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) {
                     if ($settings['autoload']) {
                         $this->data['featuredFooterWidgets'][] = $widget['name'];
                     }
                     $this->children[$widget['name']] = $settings['route'];
                     $this->widget[$widget['name']] = $widget;
                 }
             }
         }
     }
 }
 public function index()
 {
     $this->language->load('page/deprecated');
     $this->document->title = $this->data['heading_title'] = $this->language->get('heading_title');
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("common/home"), 'text' => $this->language->get('text_home'), 'separator' => false);
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("page/deprecated"), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'));
     $this->data['breadcrumbs'] = $this->document->breadcrumbs;
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/page/deprecated.tpl')) {
         $this->template = $this->config->get('config_template') . '/page/deprecated.tpl';
     } else {
         $this->template = 'choroni/page/deprecated.tpl';
     }
     $this->children[] = 'common/header2';
     $this->children[] = 'common/footer2';
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
 public function index()
 {
     if ($this->customer->isLogged()) {
         $this->redirect(Url::createUrl("account/account"));
     }
     if (!$this->customer->isLogged() && (!$this->config->get('social_twitter_consumer_key') || !$this->config->get('social_twitter_consumer_secret'))) {
         $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Twitter, por favor intente con otro servicio")));
     }
     $this->load->library('twitter_sdk/twitteroauth');
     if ($this->session->has("oauth_token") && $this->session->has("oauth_token_secret") && $this->request->hasQuery("oauth_verifier")) {
         $twitter = new TwitterOAuth($this->config->get('social_twitter_consumer_key'), $this->config->get('social_twitter_consumer_secret'), $this->session->get("oauth_token"), $this->session->get("oauth_token_secret"));
         $access_token = $twitter->getAccessToken($this->request->getQuery("oauth_verifier"));
         $user_info = $twitter->get('account/verify_credentials');
         $data = array("oauth_id" => $user_info->id, "company" => $user_info->name, "oauth_provider" => 'twitter', "oauth_token" => $this->session->get("oauth_token"), "oauth_token_secret" => $this->session->get("oauth_token_secret"));
         $result = $this->modelCustomer->getCustomerByTwitter($data);
         if ($result) {
             if ($this->customer->loginWithTwitter($data)) {
                 if (!$result['email']) {
                     $this->redirect(Url::createUrl("account/complete_profile"));
                 } elseif ($this->session->has('redirect')) {
                     $this->redirect(str_replace('&amp;', '&', $this->session->get('redirect')));
                 } else {
                     $this->redirect(Url::createUrl("common/home"));
                 }
             } else {
                 $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Twitter, por favor intente con otro servicio")));
             }
         } elseif ($this->modelCustomer->addCustomerFromTwitter($data)) {
             if ($this->customer->loginWithTwitter($data)) {
                 $this->redirect(Url::createUrl("account/complete_profile"));
             } else {
                 $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Twitter, por favor intente con otro servicio")));
             }
         }
     } else {
         $twitter = new TwitterOAuth($this->config->get('social_twitter_consumer_key'), $this->config->get('social_twitter_consumer_secret'));
         $request_token = $twitter->getRequestToken(Url::createUrl("api/twitter"));
         $this->session->set("oauth_token", $request_token['oauth_token']);
         $this->session->set("oauth_token_secret", $request_token['oauth_token_secret']);
         if ($twitter->http_code == '200') {
             $this->redirect($twitter->getAuthorizeURL($request_token['oauth_token']));
         } else {
             $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Twitter, por favor intente con otro servicio")));
         }
     }
 }
Пример #10
0
 /**
  * ControllerCommonHeader::index()
  * 
  * @return
  */
 protected function index()
 {
     if ($this->request->hasQuery('hl')) {
         $this->session->set('language', $this->request->getQuery('hl'));
         if ($this->session->has('redirect')) {
             $this->redirect($this->session->get('redirect'));
         } else {
             $this->redirect(Url::createAdminUrl('common/home'));
         }
     }
     $this->load->language('common/header');
     $this->data['title'] = $this->document->title . " | NecoTienda";
     $this->data['breadcrumbs'] = $this->document->breadcrumbs;
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->load->library('browser');
     $browser = new Browser();
     if ($browser->getBrowser() == 'Internet Explorer' && $browser->getVersion() <= 8) {
         $this->redirect(Url::createUrl("page/deprecated", null, 'NONSSL', HTTP_CATALOG));
     }
     if (!$this->user->validSession()) {
         $this->data['logged'] = '';
         $this->data['home'] = Url::createAdminUrl('common/login');
     } else {
         $this->data['logged'] = sprintf($this->language->get('text_logged'), $this->user->getUserName());
         if ($this->session->has('success')) {
             $this->data['success'] = $this->session->get('success');
             $this->session->clear('success');
         }
         if ($this->session->has('error')) {
             $this->data['error'] = $this->session->get('error');
             $this->session->clear('error');
         }
         $this->load->auto("setting/store");
         $this->data['stores'] = $this->modelStore->getAll();
     }
     $this->loadCss();
     $this->id = 'header';
     $this->template = 'common/header.tpl';
     $this->render();
 }
 public function run()
 {
     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "stat s \r\n        LEFT JOIN " . DB_PREFIX . "customer c ON (s.customer_id=c.customer_id) \r\n        LEFT JOIN " . DB_PREFIX . "product p ON (s.object_id=p.product_id) \r\n        LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id=pd.product_id) \r\n        WHERE DAY(s.date_added) = '" . $this->db->escape(date('d')) . "' \r\n            AND MONTH(s.date_added) = '" . $this->db->escape(date('m')) . "'\r\n            AND YEAR(s.date_added) = '" . $this->db->escape(date('Y')) . "'\r\n            AND s.object_type = 'product'\r\n            AND s.status = 1\r\n            AND s.customer_id <> 0\r\n            AND pd.language_id = 1\r\n        GROUP BY s.customer_id\r\n        LIMIT 40");
     if ($query->num_rows && (int) $this->config->get('marketing_email_recommended_products')) {
         $this->load->library('tax');
         $this->load->library('currency');
         $this->load->library('image');
         $this->load->library('url');
         $this->tax = new Tax($this->registry);
         $this->currency = new Currency($this->registry);
         $products = array();
         foreach ($query->rows as $product) {
             $image = !empty($product['image']) ? $product['image'] : 'no_image.jpg';
             $price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')), '', '', false);
             $products[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'image' => NTImage::resizeAndSave($image, 150, 150), 'model' => $product['model'], 'href' => Url::createUrl('store/product', array('product_id' => $product['product_id'])));
         }
         $params = array('job' => 'send_recommended_products', 'newsletter_id' => (int) $this->config->get('marketing_email_recommended_products'));
         $this->load->library('task');
         $task = new Task($this->registry);
         $task->object_id = (int) $this->config->get('marketing_email_recommended_products');
         $task->object_type = 'newsletter';
         $task->task = 'recommended_products';
         $task->type = 'send';
         $task->time_exec = date('Y-m-d') . ' 08:00:00';
         $task->params = $params;
         $task->time_interval = "";
         $task->time_last_exec = "";
         $task->run_once = true;
         $task->status = 1;
         $task->date_start_exec = date('Y-m-d') . ' 08:00:00';
         $task->date_end_exec = date('Y-m-d') . ' 23:00:00';
         foreach ($query->rows as $customer) {
             $params = array('customer_id' => $customer['customer_id'], 'fullname' => $customer['firstname'] . " " . $customer['lastname'], 'company' => $customer['company'], 'rif' => $customer['rif'], 'telephone' => $customer['telephone'], 'email' => $customer['email'], 'products' => $products);
             $queue = array("params" => $params, "status" => 1, "time_exec" => date('Y-m-d') . ' 08:00:00');
             $task->addQueue($queue);
             $this->db->query("UPDATE " . DB_PREFIX . "stat SET status = 0 \r\n                WHERE customer_id = '" . (int) $product['customer_id'] . "'\r\n                    AND DAY(date_added) = '" . $this->db->escape(date('d')) . "' \r\n                    AND MONTH(date_added) = '" . $this->db->escape(date('m')) . "'\r\n                    AND YEAR(date_added) = '" . $this->db->escape(date('Y')) . "'");
         }
         $task->createSendTask();
     }
 }
Пример #12
0
 private function prepareTemplate($newsletter)
 {
     if (!$newsletter) {
         return false;
     }
     $this->load->library('url');
     $this->load->library('BarcodeQR');
     $this->load->library('Barcode39');
     $qr = new BarcodeQR();
     $barcode = new Barcode39(C_CODE);
     $qrStore = "cache/" . $this->escape($this->config->get('config_owner')) . '.png';
     $eanStore = "cache/" . $this->escape($this->config->get('config_owner')) . "_barcode_39.gif";
     if (!file_exists(DIR_IMAGE . $qrStore)) {
         $qr->url(HTTP_HOME);
         $qr->draw(150, DIR_IMAGE . $qrStore);
     }
     if (!file_exists(DIR_IMAGE . $eanStore)) {
         $barcode->draw(DIR_IMAGE . $eanStore);
     }
     $newsletter = str_replace("%7B", "{", $newsletter);
     $newsletter = str_replace("%7D", "}", $newsletter);
     $newsletter = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $newsletter);
     $newsletter = str_replace("{%store_url%}", HTTP_HOME, $newsletter);
     $newsletter = str_replace("{%url_login%}", Url::createUrl("account/login"), $newsletter);
     $newsletter = str_replace("{%store_owner%}", $this->config->get('config_owner'), $newsletter);
     $newsletter = str_replace("{%store_name%}", $this->config->get('config_name'), $newsletter);
     $newsletter = str_replace("{%store_rif%}", $this->config->get('config_rif'), $newsletter);
     $newsletter = str_replace("{%store_email%}", $this->config->get('config_email'), $newsletter);
     $newsletter = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $newsletter);
     $newsletter = str_replace("{%store_address%}", $this->config->get('config_address'), $newsletter);
     /*
      $newsletter = str_replace("{%products%}",$product_html,$newsletter);
     */
     $newsletter = str_replace("{%date_added%}", date('d-m-Y h:i A'), $newsletter);
     $newsletter = str_replace("{%ip%}", $_SERVER['REMOTE_ADDR'], $newsletter);
     $newsletter = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $newsletter);
     $newsletter = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="NT Code" />', $newsletter);
     $newsletter .= "<p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
     return html_entity_decode(htmlspecialchars_decode($newsletter));
 }
Пример #13
0
 protected function index()
 {
     $this->language->load('common/footer');
     $this->load->library('user');
     $this->data['config_js_security'] = $this->config->get('config_js_security');
     $this->data['text_powered_by'] = sprintf($this->language->get('text_powered_by'), $this->config->get('config_name'));
     $this->id = 'footer';
     $this->load->helper('widgets');
     $widgets = new NecoWidget($this->registry, $this->Route);
     foreach ($widgets->getWidgets('footer') as $widget) {
         $settings = (array) unserialize($widget['settings']);
         if ($settings['asyn']) {
             $url = Url::createUrl("{$settings['route']}", $settings['params']);
             $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n                        .attr({\r\n                            id:'" . $widget['name'] . "'\r\n                        })\r\n                        .html(makeWaiting())\r\n                        .load('" . $url . "')\r\n                        .appendTo('" . $settings['target'] . "');");
         } else {
             if (isset($settings['route'])) {
                 if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) {
                     if ($settings['autoload']) {
                         $this->data['widgets'][] = $widget['name'];
                     }
                     $this->children[$widget['name']] = $settings['route'];
                     $this->widget[$widget['name']] = $widget;
                 }
             }
         }
     }
     // SCRIPTS
     if ($this->config->get('config_seo_url')) {
         $urlBase = HTTP_HOME . 'buscar/';
     } else {
         $urlBase = HTTP_HOME . 'index.php?r=store/search&q=';
     }
     $scripts[] = array('id' => 'search', 'method' => 'function', 'script' => "function moduleSearch(keyword) {\r\n            var url = '" . $urlBase . "';\r\n            var form = \$(keyword).closest('form');\r\n            var category = \$('#'+ \$(keyword).attr('id').replace('Keyword','Category')).val();\r\n            var store = \$('#'+ \$(keyword).attr('id').replace('Keyword','Store')).val();\r\n            var zone = \$('#'+ \$(keyword).attr('id').replace('Keyword','Zone')).val();\r\n            \r\n            url += \$(keyword).val()\r\n                .replace(/_/g,'-')\r\n                .replace('+','-')\r\n                .replace(/\\s+/g,'-');\r\n            \r\n            if (typeof category != 'undefined') {\r\n                url += '_Cat_'+ category\r\n                    .replace(/_/g,'-')\r\n                    .replace('+','-')\r\n                    .replace(/\\s+/g,'-');\r\n            }\r\n            \r\n            if (typeof zone != 'undefined') {\r\n                url += '_Estado_'+ zone\r\n                    .replace(/_/g,'-')\r\n                    .replace('+','-')\r\n                    .replace(/\\s+/g,'-');\r\n            }\r\n            \r\n            if (typeof store != 'undefined') {\r\n                url += '_Tienda_'+ store\r\n                    .replace(/_/g,'-')\r\n                    .replace('+','-')\r\n                    .replace(/\\s+/g,'-');\r\n            }\r\n            \r\n            window.location = url;\r\n        }");
     $this->scripts = array_merge($this->scripts, $scripts);
     $r_output = $w_output = $s_output = $f_output = "";
     $script_keys = array();
     foreach ($this->scripts as $k => $script) {
         if (in_array($script['id'], $script_keys)) {
             continue;
         }
         $script_keys[$k] = $script['id'];
         switch ($script['method']) {
             case 'ready':
             default:
                 $r_output .= $script['script'];
                 break;
             case 'window':
                 $w_output .= $script['script'];
                 break;
             case 'function':
                 $f_output .= $script['script'];
                 break;
         }
     }
     $jspath = defined("CDN") ? CDN_JS : HTTP_THEME_JS;
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/header.tpl')) {
         $jspath = str_replace("%theme%", $this->config->get('config_template'), $jspath);
         $jsFolder = str_replace("%theme%", $this->config->get('config_template'), DIR_THEME_JS);
     } else {
         $jspath = str_replace("%theme%", "choroni", $jspath);
         $jsFolder = str_replace("%theme%", "choroni", DIR_THEME_JS);
     }
     if (file_exists($jsFolder . str_replace('/', '', strtolower($this->Route) . '.js'))) {
         $javascripts[] = $jspath . str_replace('/', '', strtolower($this->Route) . '.js');
     }
     if (count($javascripts)) {
         $this->javascripts = array_merge($this->javascripts, $javascripts);
     }
     foreach ($this->javascripts as $key => $js) {
         $f_output .= file_get_contents($js);
         unset($this->javascripts[$key]);
     }
     if (file_exists(str_replace('%theme%', $this->config->get('config_template'), DIR_THEME_JS) . 'theme.js')) {
         $f_output .= file_get_contents(str_replace('%theme%', $this->config->get('config_template'), DIR_THEME_JS) . 'theme.js');
     }
     $this->data['scripts'] = $s_output;
     $this->data['scripts'] .= $r_output ? "<script> \n \$(function(){" . $r_output . "}); </script>" : "";
     $this->data['scripts'] .= $w_output ? "<script> \n (function(\$){ \$(window).load(function(){ " . $w_output . " }); })(jQuery);</script>" : "";
     $this->data['scripts'] .= $f_output ? "<script> \n " . $f_output . " </script>" : "";
     $jspath = defined("CDN_JS") ? CDN_JS : HTTP_JS;
     // javascript files
     if ($this->user->getId()) {
         $javascripts[] = HTTP_ADMIN . "js/front/admin.js";
         if ($this->request->hasQuery('theme_editor') && $this->request->hasQuery('theme_id') && (int) $this->request->getQuery('theme_id') > 0) {
             $javascripts[] = $jspath . "vendor/jquery-ui.min.js";
             $javascripts[] = $jspath . "necojs/neco.css.js";
             $javascripts[] = $jspath . "necojs/neco.colorpicker.js";
             $javascripts[] = HTTP_ADMIN . "js/front/theme_editor.js";
         }
     }
     if ($javascripts) {
         $this->data['javascripts'] = $this->javascripts = array_merge($this->javascripts, $javascripts);
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/footer.tpl')) {
         $this->template = $this->config->get('config_template') . '/common/footer.tpl';
     } else {
         $this->template = 'choroni/common/footer.tpl';
     }
     $this->data['google_analytics_code'] = $this->config->get('google_analytics_code');
     $this->data['live_client_id'] = $this->config->get('social_live_client_id');
     $this->data['facebook_app_id'] = $this->config->get('social_facebook_app_id');
     $this->data['google_client_id'] = $this->config->get('social_google_client_id');
     $this->data['twitter_oauth_token_secret'] = $this->config->get('social_twitter_oauth_token_secret');
     $this->render();
 }
 protected function index()
 {
     $this->language->load('payment/pp_standard');
     if (!$this->config->get('pp_standard_test')) {
         $this->data['action'] = 'https://www.paypal.com/cgi-bin/webscr';
     } else {
         $this->data['action'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     }
     $this->load->library('image');
     $this->data['Image'] = new NTImage();
     $this->load->model('checkout/order');
     if ($this->request->hasQuery('order_id')) {
         $order_id = $this->request->getQuery('order_id');
     } elseif ($this->session->has('order_id')) {
         $order_id = $this->session->get('order_id');
     } else {
         $order_id = 0;
     }
     $order_info = $this->modelOrder->getOrder($order_id);
     $this->data['business'] = $this->config->get('pp_standard_email');
     $this->data['item_name'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
     $this->data['currency_code'] = $order_info['currency'];
     $this->data['amount'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE);
     $this->data['first_name'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8');
     $this->data['last_name'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
     $this->data['address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
     $this->data['address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8');
     $this->data['city'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
     $this->data['zip'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
     $this->data['country'] = $order_info['payment_iso_code_2'];
     $this->data['notify_url'] = Url::createUrl("payment/pp_standard/callback");
     $this->data['email'] = $order_info['email'];
     $this->data['invoice'] = $order_id . ' - ' . html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8') . ' ' . html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
     $this->data['lc'] = $this->session->get('language');
     $this->data['return'] = Url::createUrl("account/order");
     $this->data['cancel_return'] = Url::createUrl("account/payment/register", array('order_id' => $order_id));
     if (!$this->config->get('pp_standard_transaction')) {
         $this->data['paymentaction'] = 'authorization';
     } else {
         $this->data['paymentaction'] = 'sale';
     }
     $this->load->library('encryption');
     $encryption = new Encryption($this->config->get('config_encryption'));
     $this->data['custom'] = $encryption->encrypt($order_id);
     $this->data['button_pay'] = 'PayPal Standard';
     $this->load->model("marketing/newsletter");
     $result = $this->modelNewsletter->getById($this->config->get('pp_standard_newsletter_id'));
     $this->data['instructions'] = html_entity_decode($result['htmlbody']);
     // style files
     $csspath = defined("CDN") ? CDN . CSS : HTTP_CSS;
     $styles[] = array('media' => 'all', 'href' => $csspath . 'jquery-ui/jquery-ui.min.css');
     $styles[] = array('media' => 'all', 'href' => $csspath . 'neco.form.css');
     if (count($styles)) {
         $this->data['styles'] = $this->styles = array_merge($this->styles, $styles);
     }
     $this->id = 'payment';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/payment/pp_standard.tpl')) {
         $this->template = $this->config->get('config_template') . '/payment/pp_standard.tpl';
     } else {
         $this->template = 'choroni/payment/pp_standard.tpl';
     }
     $this->render();
 }
 public function login($fb)
 {
     if ($this->customer->isLogged()) {
         $this->redirect(Url::createUrl("account/account"));
     }
     if (!$this->customer->isLogged() && (!$this->config->get('social_facebook_app_id') || !$this->config->get('social_facebook_app_secret'))) {
         $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Facebook, por favor intente con otro servicio")));
     }
     echo __LINE__ . '<br />';
     if ($fb) {
         /**
                       $graphObject = object(Facebook\GraphObject) {
                       ["backingData":protected] => array(12) {
                       ["id"]=> string(10) "1518317082"
                       ["birthday"]=> string(10) "12/20/1985"
                       ["email"]=> string(23) "*****@*****.**"
                       ["first_name"]=> string(6) "Yosiet"
                       ["gender"]=> string(4) "male"
                       ["last_name"]=> string(5) "Serga"
                       ["link"]=> string(34) "http://www.facebook.com/1518317082"
                       ["locale"]=> string(5) "es_ES"
                       ["name"]=> string(12) "Yosiet Serga"
                       ["timezone"]=> float(-4.5)
                       ["updated_time"]=> string(24) "2013-11-08T00:36:26+0000"
                       ["verified"]=> bool(true)
                       }
                       }
                      * */
         echo __LINE__ . '<br />';
         $data = array('email' => $fb->getEmail(), 'company' => $fb->getName(), 'firstname' => $fb->getFirstName(), 'lastname' => $fb->getLastName(), 'oauth_provider' => 'facebook', 'oauth_id' => $fb->getId());
         $this->load->auto('account/customer');
         echo __LINE__ . '<br />';
         $result = $this->modelCustomer->getCustomerByEmail($fb->getEmail());
         echo __LINE__ . '<br />';
         if ($result) {
             echo __LINE__ . '<br />';
             if ($this->customer->loginWithFacebook($data)) {
                 echo __LINE__ . '<br />';
                 if ($this->session->has('redirect')) {
                     $this->redirect(str_replace('&amp;', '&', $this->session->get('redirect')));
                 } else {
                     $this->redirect(Url::createUrl("common/home"));
                 }
             } else {
                 $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Facebook, por favor intente con otro servicio")));
             }
         } elseif ($this->modelCustomer->addCustomer($data)) {
             if ($this->customer->loginWithFacebook($data)) {
                 if ($this->session->has('redirect')) {
                     $this->redirect(str_replace('&amp;', '&', $this->session->get('redirect')));
                 } else {
                     $this->redirect(Url::createUrl("common/home"));
                 }
             } else {
                 $this->redirect(Url::createUrl("account/login", array("error" => "No se pudo iniciar sesion utilizando Facebook, por favor intente con otro servicio")));
             }
         }
     } else {
     }
 }
        $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
    } else {
        $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
        $special = $this->modelProduct->getProductSpecial($result['product_id']);
        if ($special) {
            $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
        }
    }
    $options = $this->modelProduct->getProductOptions($result['product_id']);
    if ($options) {
        $add = Url::createUrl('store/product', array('product_id' => $result['product_id']));
    } else {
        $add = Url::createUrl('checkout/cart', array('product_id' => $result['product_id']));
    }
    list($pdia, $pmes, $pano) = explode('-', date('d-m-Y', strtotime($result['created'])));
    if ($special) {
        $sticker = '<b class="oferta"></b>';
    } elseif ($discount) {
        $sticker = '<b class="descuento"></b>';
    } elseif (strtotime($dia . "-" . $mes . "-" . $ano) <= strtotime($pdia . "-" . $pmes . "-" . $pano)) {
        $sticker = '<b class="nuevo"></b>';
    } else {
        $sticker = "";
    }
    $this->load->auto('image');
    $this->data['products'][$k] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'overview' => $result['meta_description'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'sticker' => $sticker, 'options' => $options, 'image' => NTImage::resizeAndSave($image, 38, 38), 'lazyImage' => NTImage::resizeAndSave('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')), 'thumb' => NTImage::resizeAndSave($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')), 'href' => Url::createUrl('store/product', array('product_id' => $result['product_id'])), 'add' => $add, 'created' => $result['created']);
    if ($this->config->get('config_store_mode') === 'store') {
        $this->data['products'][$k]['price'] = $price;
        $this->data['products'][$k]['special'] = $special;
    }
}
Пример #17
0
 public function index()
 {
     $Url = new Url($this->registry);
     if (!$this->customer->isLogged()) {
         if (isset($this->request->get['order_id'])) {
             $order_id = $this->request->get['order_id'];
         } else {
             $order_id = 0;
         }
         $this->session->set('redirect', Url::createUrl("account/invoice", array("order_id" => $order_id)));
         $this->redirect(Url::createUrl("account/login"));
     }
     $this->language->load('account/invoice');
     $this->load->model('account/customer');
     $customer_address = $this->modelCustomer->getCustomer($this->customer->getId());
     $this->document->title = $this->language->get('heading_title');
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("common/home"), 'text' => $this->language->get('text_home'), 'separator' => false);
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("account/account"), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'));
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("account/history"), 'text' => $this->language->get('text_history'), 'separator' => $this->language->get('text_separator'));
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("account/invoice", array("order_id" => $this->request->get['order_id'])), 'text' => $this->language->get('text_invoice'), 'separator' => $this->language->get('text_separator'));
     $this->load->model('account/order');
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     $order_info = $this->modelOrder->getOrder($order_id);
     if ($order_info) {
         $this->data['heading_title'] = $this->language->get('heading_title');
         $this->data['text_invoice_id'] = $this->language->get('text_invoice_id');
         $this->data['text_order_id'] = $this->language->get('text_order_id');
         $this->data['text_email'] = $this->language->get('text_email');
         $this->data['text_telephone'] = $this->language->get('text_telephone');
         $this->data['text_fax'] = $this->language->get('text_fax');
         $this->data['text_shipping_address'] = $this->language->get('text_shipping_address');
         $this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
         $this->data['text_payment_address'] = $this->language->get('text_payment_address');
         $this->data['text_payment_method'] = $this->language->get('text_payment_method');
         $this->data['text_order_history'] = $this->language->get('text_order_history');
         $this->data['text_product'] = $this->language->get('text_product');
         $this->data['text_model'] = $this->language->get('text_model');
         $this->data['text_quantity'] = $this->language->get('text_quantity');
         $this->data['text_price'] = $this->language->get('text_price');
         $this->data['text_total'] = $this->language->get('text_total');
         $this->data['text_comment'] = $this->language->get('text_comment');
         $this->data['column_date_added'] = $this->language->get('column_date_added');
         $this->data['column_status'] = $this->language->get('column_status');
         $this->data['column_comment'] = $this->language->get('column_comment');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['order_id'] = $this->request->get['order_id'];
         if ($order_info['invoice_id']) {
             $this->data['invoice_id'] = $order_info['invoice_prefix'] . $order_info['invoice_id'];
         } else {
             $this->data['invoice_id'] = '';
         }
         $this->data['email'] = $order_info['email'];
         $this->data['telephone'] = $order_info['telephone'];
         $this->data['fax'] = $order_info['fax'];
         if ($order_info['shipping_address_format']) {
             $format = $order_info['shipping_address_format'];
         } else {
             $format = "<div style='font-weight:bold;width:130px;float:left'>Raz&oacute;n Social:</div><div style='float:left'>{company}</div>\r\n                        <div style='font-weight:bold;width:130px;float:left'>RIF:</div><div style='float:left'>{rif}</div>\r\n                        <div style='font-weight:bold;width:130px;float:left'>Direcci&oacute;n:</div><div style='float:left'>{address_1}, {city}, {zone} - {country}</div>";
         }
         $find = array('{company}', '{rif}', '{address_1}', '{city}', '{zone}', '{zone_code}', '{country}');
         $replace = array('company' => $customer_address['company'], 'rif' => $customer_address['rif'], 'address_1' => $order_info['shipping_address_1'], 'city' => $order_info['shipping_city'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone'], 'country' => $order_info['shipping_country']);
         $this->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         $this->data['shipping_method'] = $order_info['shipping_method'];
         if ($order_info['payment_address_format']) {
             $format = $order_info['payment_address_format'];
         } else {
             $format = "<div style='font-weight:bold;width:130px;float:left'>Raz&oacute;n Social:</div><div style='float:left'>{company}</div>\r\n                        <div style='font-weight:bold;width:130px;float:left'>RIF:</div><div style='float:left'>{rif}</div>\r\n                        <div style='font-weight:bold;width:130px;float:left'>Direcci&oacute;n:</div><div style='float:left'>{address_1}, {city}, {zone} - {country}</div>\r\n                        <div style='font-weight:bold;width:130px;float:left'>Tel&eacute;fono:</div><div style='float:left'>{telephone}</div>\r\n                        <div style='font-weight:bold;width:130px;float:left'>Email:</div><div style='float:left'>{email}</div>";
         }
         $find = array('{company}', '{rif}', '{address_1}', '{city}', '{zone}', '{zone_code}', '{country}', '{telephone}', '{email}');
         $replace = array('company' => $customer_address['company'], 'rif' => $customer_address['rif'], 'address_1' => $order_info['payment_address_1'], 'city' => $order_info['payment_city'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country'], 'telephone' => $customer_address['telephone'], 'email' => $customer_address['email']);
         $this->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         $this->data['payment_method'] = $order_info['payment_method'];
         $this->data['products'] = array();
         $products = $this->modelOrder->getOrderProducts($this->request->get['order_id']);
         foreach ($products as $product) {
             $options = $this->modelOrder->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);
             $option_data = array();
             foreach ($options as $option) {
                 $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_info['currency'], $order_info['value']), 'total' => $this->currency->format($product['total'], $order_info['currency'], $order_info['value']));
         }
         $this->data['totals'] = $this->modelOrder->getOrderTotals($this->request->get['order_id']);
         $this->data['comment'] = $order_info['comment'];
         $this->data['historys'] = array();
         $results = $this->modelOrder->getOrderHistories($this->request->get['order_id']);
         foreach ($results as $result) {
             $this->data['historys'][] = array('date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), 'status' => $result['status'], 'comment' => nl2br($result['comment']));
         }
         $this->data['continue'] = Url::createUrl("account/history");
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/account/invoice.tpl')) {
             $this->template = $this->config->get('config_template') . '/account/invoice.tpl';
         } else {
             $this->template = 'choroni/account/invoice.tpl';
         }
         // style files
         $csspath = defined("CDN_CSS") ? CDN_CSS : HTTP_CSS;
         str_replace('%theme%', $this->config->get('config_template'), HTTP_THEME_CSS);
         if (file_exists(str_replace('%theme%', $this->config->get('config_template'), HTTP_THEME_CSS) . 'neco.form.css')) {
             $styles[] = array('media' => 'all', 'href' => str_replace('%theme%', $this->config->get('config_template'), HTTP_THEME_CSS) . 'neco.form.css');
         } else {
             $styles[] = array('media' => 'all', 'href' => $csspath . 'neco.form.css');
         }
         $this->styles = array_merge($styles, $this->styles);
         // javascript files
         $jspath = defined("CDN_JS") ? CDN_JS : HTTP_JS;
         $javascripts[] = $jspath . "necojs/neco.form.js";
         $this->javascripts = array_merge($this->javascripts, $javascripts);
         // SCRIPTS
         $scripts[] = array('id' => 'messageScripts', 'method' => 'ready', 'script' => "\$('#form').ntForm({\r\n            ajax:true,\r\n            url:'{$this->data['action']}',\r\n            success:function(data) {\r\n                if (data.success) {\r\n                    window.location.href = '" . Url::createUrl('account/message') . "';\r\n                }\r\n                if (data.error) {\r\n                    \$('#messageForm').append(data.msg);\r\n                }\r\n            }\r\n        });\r\n        \r\n        \$('#form textarea').ntInput();\r\n        ");
         $this->scripts = array_merge($this->scripts, $scripts);
         $this->children = array('common/nav', 'account/column_left', 'common/footer', 'common/header');
         $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
     } else {
         $this->data['heading_title'] = $this->language->get('heading_title');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = Url::createUrl("account/history");
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/error/not_found.tpl')) {
             $this->template = $this->config->get('config_template') . '/error/not_found.tpl';
         } else {
             $this->template = 'choroni/error/not_found.tpl';
         }
         $this->children = array('common/nav', 'common/column_left', 'common/footer', 'common/header');
         $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
     }
 }
 public function index()
 {
     if ($this->config->get('google_base_status')) {
         $output = '<?xml version="1.0" encoding="UTF-8" ';
         $output .= '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">';
         $output .= '<channel>';
         $output .= '<title>' . $this->config->get('config_name') . '</title>';
         $output .= '<description>' . $this->config->get('config_meta_description') . '</description>';
         $output .= '<link>' . HTTP_HOME . '</link>';
         $this->load->model('store/category');
         $this->load->model('store/product');
         $products = $this->modelProduct->getProducts();
         foreach ($products as $product) {
             if ($product['description']) {
                 $output .= '<item>';
                 $output .= '<title>' . html_entity_decode($product['name'], ENT_QUOTES, 'UTF-8') . '</title>';
                 $output .= '<link>' . Url::createUrl("store/product") . '&amp;product_id=' . $product['product_id'] . '</link>';
                 $output .= '<description>' . $product['description'] . '</description>';
                 $output .= '<g:brand>' . html_entity_decode($product['manufacturer'], ENT_QUOTES, 'UTF-8') . '</g:brand>';
                 $output .= '<g:condition>new</g:condition>';
                 $output .= '<g:id>' . $product['product_id'] . '</g:id>';
                 if ($product['image']) {
                     $output .= '<g:image_link>' . NTImage::resizeAndSave($product['image'], 500, 500) . '</g:image_link>';
                 } else {
                     $output .= '<g:image_link>' . NTImage::resizeAndSave('no_image.jpg', 500, 500) . '</g:image_link>';
                 }
                 $output .= '<g:mpn>' . $product['model'] . '</g:mpn>';
                 $special = $this->modelProduct->getProductSpecial($product['product_id']);
                 if ($special) {
                     $output .= '<g:price>' . $this->tax->calculate($special, $product['tax_class_id']) . '</g:price>';
                 } else {
                     $output .= '<g:price>' . $this->tax->calculate($product['price'], $product['tax_class_id']) . '</g:price>';
                 }
                 $categories = $this->modelProduct->getCategories($product['product_id']);
                 foreach ($categories as $category) {
                     $path = $this->getPath($category['category_id']);
                     if ($path) {
                         $string = '';
                         foreach (explode('_', $path) as $path_id) {
                             $category_info = $this->modelCategory->getCategory($path_id);
                             if ($category_info) {
                                 if (!$string) {
                                     $string = $category_info['name'];
                                 } else {
                                     $string .= ' &gt; ' . $category_info['name'];
                                 }
                             }
                         }
                         $output .= '<g:product_type>' . $string . '</g:product_type>';
                     }
                 }
                 $output .= '<g:quantity>' . $product['quantity'] . '</g:quantity>';
                 $output .= '<g:upc>' . $product['model'] . '</g:upc>';
                 $output .= '<g:weight>' . $this->weight->format($product['weight'], $product['weight_class']) . '</g:weight>';
                 $output .= '</item>';
             }
         }
         $output .= '</channel>';
         $output .= '</rss>';
         $this->response->addHeader('Content-Type: application/rss+xml');
         $this->response->setOutput($output, 0);
     }
 }
Пример #19
0
 public function callback()
 {
     $this->language->load('module/cart');
     $this->session->clear('shipping_methods');
     $this->session->clear('shipping_method');
     $this->session->clear('payment_methods');
     $this->session->clear('payment_method');
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if (isset($this->request->post['remove'])) {
             $result = explode('_', $this->request->post['remove']);
             $this->cart->remove(trim($result[1]));
         } else {
             if (isset($this->request->post['option'])) {
                 $option = $this->request->post['option'];
             } else {
                 $option = array();
             }
             $this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option);
         }
     }
     $output = '<table cellpadding="2" cellspacing="0" style="width: 100%;">';
     if ($this->cart->getProducts()) {
         foreach ($this->cart->getProducts() as $product) {
             $output .= '<tr>';
             $output .= '<td width="1" valign="top" align="left"><span class="cart_remove" id="remove_ ' . $product['key'] . '" />&nbsp;</span></td><td width="1" valign="top" align="right">' . $product['quantity'] . '&nbsp;x&nbsp;</td>';
             $output .= '<td align="left" valign="top"><a href="' . Url::createUrl("store/product", array("product_id" => $product['product_id'])) . '">' . $product['name'] . '</a>';
             $output .= '<div>';
             foreach ($product['option'] as $option) {
                 $output .= ' - <small style="color: #999;">' . $option['name'] . ' ' . $option['value'] . '</small><br />';
             }
             $output .= '</div></td>';
             $output .= '</tr>';
         }
         $output .= '</table>';
         $output .= '<br />';
         $total = 0;
         $taxes = $this->cart->getTaxes();
         $this->load->model('checkout/extension');
         $sort_order = array();
         $view = Url::createUrl("checkout/cart");
         $checkout = Url::createUrl("checkout/shipping");
         $results = $this->modelExtension->getExtensions('total');
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             $this->load->model('total/' . $result['key']);
             $this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
         }
         $sort_order = array();
         foreach ($total_data as $key => $value) {
             $sort_order[$key] = $value['sort_order'];
         }
         array_multisort($sort_order, SORT_ASC, $total_data);
         $output .= '<table cellpadding="0" cellspacing="0" align="right" style="display:inline-block;">';
         foreach ($total_data as $total) {
             $output .= '<tr>';
             $output .= '<td align="right"><span class="cart_module_total"><b>' . $total['title'] . '</b></span></td>';
             $output .= '<td align="right"><span class="cart_module_total">' . $total['text'] . '</span></td>';
             $output .= '</tr>';
         }
         $output .= '</table>';
         $output .= '<div style="padding-top:5px;text-align:center;clear:both;"><a href="' . $view . '">' . $this->language->get('text_view') . '</a> | <a href="' . $checkout . '">' . $this->language->get('text_checkout') . '</a></div>';
     } else {
         $output .= '<div style="text-align: center;">' . $this->language->get('text_empty') . '</div>';
     }
     $this->response->setOutput($output, $this->config->get('config_compression'));
 }
 public function getById()
 {
     $product_id = $this->request->get['product_id'];
     $this->load->auto('store/product');
     $this->load->auto('image');
     $this->load->auto('tax');
     $this->load->auto('currency');
     $tax = new Tax($this->registry);
     $currency = new Currency($this->registry);
     $strProducts = '';
     $product = $this->modelProduct->getById($product_id);
     $tags = $this->modelProduct->getTags($product_id);
     if (isset($this->request->get['format']) && !empty($this->request->get['format'])) {
         $strProducts .= "Producto: " . $product['name'] . "\n";
         $strProducts .= "Precio: " . $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))) . "\n";
         //TODO: cureency format
         $strProducts .= "URL: " . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/");
         if ($tags) {
             foreach ($tags as $key => $tag) {
                 $ntag = $key + 1;
                 $strProducts .= "\nTag " . $ntag . ": " . Url::createUrl("product/search", array("keyword" => $tag['tag']), "NONSSL", HTTP_CATALOG . "/") . "\n";
             }
         }
         $strProducts .= "\n";
         echo $strProducts;
     } else {
         $strProducts .= "<div style='margin:5px;padding:3px;background:#FFF;float:left;border:dotted 1px #ccc;width:100px;display:block;text-align:center'>";
         $strProducts .= "<br><p><a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/") . "'>" . $product['name'] . "</a></p>";
         if (empty($product['image'])) {
             $strProducts .= "<a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/") . "'>";
             $strProducts .= "<img src='" . NTImage::resizeAndSave('no_image.jpg', 50, 50) . "' alt='" . $product['name'] . "'>";
             $strProducts .= "</a>";
         } else {
             $strProducts .= "<a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id'])) . "'>";
             $strProducts .= "<img src='" . NTImage::resizeAndSave($product['image'], 50, 50) . "' alt='" . $product['name'] . "'>";
             $strProducts .= "</a>";
         }
         $strProducts .= "<input type='hidden' name='" . $product['product_id'] . "' value='" . $product['product_id'] . "'>";
         $strProducts .= "<br><b>" . $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))) . "</b><br>";
         if ($tags) {
             foreach ($tags as $key => $tag) {
                 $strProducts .= "&nbsp;&nbsp;<a href='" . Url::createUrl("product/search", array("keyword" => $tag['tag']), "NONSSL", HTTP_CATALOG . "/") . "' style='font:normal 9px verdana'>" . $tag['tag'] . "</a>&nbsp;&nbsp;";
             }
         }
         $strProducts .= "<br></div>";
         echo $strProducts;
     }
 }
$_['entry_telephone'] = 'Tel&eacute;fono:';
$_['entry_fax'] = 'Fax:';
$_['entry_company'] = 'Raz&oacute;n Social:';
$_['entry_address_1'] = 'Direcci&oacute;n Principal:';
$_['entry_address_2'] = 'Direcci&oacute;n Alterna:';
$_['entry_postcode'] = 'C&oacute;digo Postal:';
$_['entry_city'] = 'Ciudad:';
$_['entry_country'] = 'Pa&iacute;s:';
$_['entry_zone'] = 'Estado/Provincia/Departamento:';
$_['entry_newsletter'] = 'Subscribirme:';
$_['entry_password'] = '******';
$_['entry_confirm'] = 'Confirmar Contrase&ntilde;a:';
$_['entry_rif'] = 'RIF:';
$_['entry_captcha'] = 'Ingrese el resultado de la ecuaci&oacute;n:';
// Error
$_['error_exists'] = 'El email ya existe! Si ya posees una cuenta con nosotros, por favor <a href="' . Url::createUrl("account/login") . '" title="Iniciar sesi&oacute;n" style="color:#000 !important">Ingresa Aqu&iacute;</a>';
$_['error_firstname'] = 'El nombre debe poseer entre 3 y 32 caracteres!';
$_['error_lastname'] = 'El apellido debe poseer entre 3 y 32 caracteres!';
$_['error_sexo'] = 'Debe seleccionar su sexo!';
$_['error_nacimiento'] = 'Debe ingresar una fecha v&aacute;lida y ser mayor de edad!';
$_['error_email'] = 'E-Mail inv&aacute;lido!';
$_['error_password'] = '******';
$_['error_confirm'] = 'La conatrse&ntilde;a no concuerda con la confirmaci&oacute;n!';
$_['error_address_1'] = 'La direcci&oacute;n debe poseer entre 3 y 128 caracteres!';
$_['error_city'] = 'La ciudad debe poseer entre 3 y 128 caracteres!';
$_['error_country'] = 'Por favor seleccione un pa&iacute;s';
$_['error_zone'] = 'Por favor seleccione un Estado/Provincia/Departamento';
$_['error_telephone'] = 'El tel&eacute;fono debe poseer entre 3 y 32 caracteres!';
$_['error_agree'] = 'Error: Debe leer y aceptar las %s para continuar!';
$_['error_rif'] = 'Debe ingresar un RIF v&aacute;lido';
$_['error_company'] = 'Debe poseer al menos 3 caracteres';
 public function insert()
 {
     $this->document->title = $this->language->get('heading_title');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validateForm()) {
         $newsletter = $this->modelNewsletter->getById($this->request->post['newsletter_id']);
         $dom = new DOMDocument();
         $dom->preserveWhiteSpace = false;
         $dom->loadHTML(html_entity_decode($newsletter['htmlbody']));
         if ($this->request->post['embed_image']) {
             $images = $dom->getElementsByTagName('img');
             $total_images = $total_embed_images = 0;
             foreach ($images as $image) {
                 $src = $image->getAttribute('src');
                 $src = str_replace(HTTP_IMAGE, DIR_IMAGE, $src);
                 if (file_exists($src)) {
                     $img = file_get_contents($src);
                     $ext = substr($src, strrpos($src, '.') + 1);
                     $embed = base64_encode($img);
                     $image->setAttribute('src', "data:image/{$ext};base64,{$embed}");
                     $total_embed_images++;
                 }
                 $total_images++;
             }
         }
         $params = array('contact_id' => '{%contact_id%}', 'campaign_id' => '{%campaign_id%}');
         if ($this->request->post['trace_email']) {
             $trace_url = Url::createUrl("marketing/campaign/trace", $params, 'NONSSL', HTTP_CATALOG);
             $trackEmail = $dom->createElement('img');
             $trackEmail->setAttribute('src', $trace_url);
             $dom->appendChild($trackEmail);
         }
         if ($this->request->post['trace_click']) {
             $links = $dom->getElementsByTagName('a');
             $total_links = $total_trace_links = 0;
             foreach ($links as $link) {
                 $href = $link->getAttribute('href');
                 $total_links++;
                 if (empty($href) || $href == "#" || strpos($href, "mailto")) {
                     continue;
                 }
                 //TODO: validar enlaces
                 //TODO: sanitizar enlaces
                 $params['link_index'] = md5(time() . mt_rand(1000000, 9999999) . $href);
                 $_link = Url::createUrl("marketing/campaign/link", $params, 'NONSSL', HTTP_CATALOG);
                 $link->setAttribute('href', $_link);
                 $_links[] = array("url" => $_link, "redirect" => $href, "link_index" => $params['link_index']);
                 $total_trace_links++;
                 //TODO: agregar valor a la etiqueta title si esta vacia
             }
         }
         $this->request->post['contacts'] = $contacts = $this->modelList->getContacts($this->request->post['contact_list']);
         foreach ($contacts as $key => $contact) {
             if (in_array($contact['email'], $to)) {
                 continue;
             }
             $to[$key] = array('contact_id' => $contact['contact_id'], 'name' => $contact['name'], 'email' => $contact['email']);
         }
         if ($this->request->post['repeat'] && $this->request->post['repeat'] == "weekly") {
             $this->request->post['repeat'] = "weekly@" . $this->request->post['repeat_wday'];
         }
         //TODO: verificar si la fecha es mayor al ahora
         $date_start_exec = "";
         $date_start_exec .= $this->request->post['start_year'] . "-";
         $date_start_exec .= $this->request->post['start_month'] . "-";
         $date_start_exec .= $this->request->post['start_day'] . " ";
         $date_start_exec .= $this->request->post['start_hour'] . ":";
         $date_start_exec .= $this->request->post['start_minute'] . ":00 ";
         $date_start_exec .= $this->request->post['start_meridium'];
         //TODO: verificar si la fecha es mayor a la fecha de inicio
         $date_end_exec = "";
         $date_end_exec .= $this->request->post['end_year'] . "-";
         $date_end_exec .= $this->request->post['end_month'] . "-";
         $date_end_exec .= $this->request->post['end_day'] . " ";
         $date_end_exec .= $this->request->post['end_hour'] . ":";
         $date_end_exec .= $this->request->post['end_minute'] . ":00 ";
         $date_end_exec .= $this->request->post['end_meridium'];
         //TODO: agregar info para rastrear con google analytics
         $htmlbody = htmlentities($dom->saveHTML());
         if (file_exists(DIR_SYSTEM . 'library/email/spam_rules.php')) {
             require_once DIR_SYSTEM . 'library/email/spam_rules.php';
             foreach ($spam_rules as $rule) {
                 if (preg_match($rule[0], $htmlbody)) {
                     $score += $rule[2];
                     $broken_rules[] = array($rule[1], $rule[2]);
                 }
             }
         }
         $email_size = mb_strlen($htmlbody, '8bit') / 1000;
         if ($email_size >= 1000) {
             $size = round($email_size / 1000, 2) . " MB";
         } else {
             $size = round($email_size, 2) . " KB";
         }
         $this->data['total_embed_images'] = $total_embed_images;
         $this->data['total_trace_links'] = $total_trace_links;
         $this->data['total_images'] = $total_images;
         $this->data['total_links'] = $total_links;
         $this->data['date_start_exec'] = $date_start_exec;
         $this->data['spam_score'] = $score;
         $this->data['broken_rules'] = $broken_rules;
         $this->data['email_size'] = $email_size;
         $this->data['size'] = $size;
         $this->data['contacts'] = count($contacts);
         $this->request->post['date_start'] = date('Y-m-d H:i:s', strtotime($date_start_exec));
         $this->request->post['date_end'] = date('Y-m-d H:i:s', strtotime($date_end_exec));
         $data = array('to' => $to, 'post' => $this->request->post, 'links' => $_links);
         $this->cache->set("campaign.html.temp", $htmlbody);
         $this->cache->set("campaign.data.temp", serialize($data));
         $this->beforeSend();
     } else {
         $this->getForm();
     }
 }
Пример #23
0
 /**
  * 仓储认证处理
  * @return bool
  */
 public function doStoreCertAction()
 {
     if (IS_AJAX) {
         $user_id = $this->user_id;
         $cert = new \nainai\certificate();
         $store_id = intval($_POST['store']);
         if (!empty($res = $cert->checkUserInfo($user_id, $this->user_type))) {
             //用户信息不完整
             $res['return'] = Url::createUrl('/ucenter/info');
             echo JSON::encode($res);
             exit;
         } else {
             if ($res = $cert->certStoreApply($user_id, $store_id)) {
                 //提交成功
                 echo JSON::encode(Tool::getSuccInfo());
                 exit;
             } else {
                 echo JSON::decode(Tool::getSuccInfo(0, '系统繁忙,稍后再试', Url::createUrl('/ucenter/dealCert')));
                 exit;
             }
         }
     }
     return false;
 }
Пример #24
0
 public function recover()
 {
     $this->load->language('common/login');
     $this->data['error_warning'] = '';
     $this->document->title = $this->language->get('heading_recover_title');
     if ($this->user->isLogged() && isset($this->request->get['token']) && $this->request->get['token'] == $this->session->get('ukey')) {
         $this->redirect(Url::createAdminUrl('common/home'));
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validateRecover()) {
         $result = $this->db->query("SELECT * FROM " . DB_PREFIX . "user WHERE username = '******'username') . "' AND email = '" . $this->request->getPost('email') . "'");
         if ($result->num_rows) {
             $password = substr(md5(rand()), 0, 7);
             $this->db->query("UPDATE " . DB_PREFIX . "user SET \r\n                `password` = '" . md5($password) . "' \r\n                WHERE username = '******'username') . "' \r\n                AND email = '" . $this->request->getPost('email') . "'");
             $this->user->registerActivity($result->row['user_id'], 'user', 'Solicitud de generación de contraseña nueva', 'update');
             $this->load->auto('email/mailer');
             $mailer = new Mailer();
             $message = "<h1>Hola " . $this->request->getPost('username') . ",</h1>\n\n";
             $message .= "<p>Tu nueva contrase&ntilde;a es:</p>\n";
             $message .= "<h1>" . $password . "</h1>\n";
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($this->request->getPost('email'), $this->request->getPost('username'));
             $mailer->SetFrom('*****@*****.**', 'NecoTienda');
             $mailer->Subject = 'Recuperacion de Contrasena';
             $mailer->Body = $message;
             $mailer->Send();
             $this->redirect(Url::createUrl('common/login'));
         } else {
             $this->user->registerActivity($result->row['user_id'], 'user', 'Intento fallido de solicitud de generación de contraseña nueva', 'update');
             $this->data['error_warning'] = $this->language->get('error_user_unknown');
         }
     }
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     }
     $this->data['action'] = Url::createAdminUrl('common/login/recover');
     $this->setvar('username');
     $this->setvar('email');
     $scripts[] = array('id' => 'login', 'method' => 'ready', 'script' => "\$('#form input').keydown(function(e) {\r\n        \t\tif (e.keyCode == 13) {\r\n                    \$('#form').submit();\r\n        \t\t}\r\n        \t});");
     $this->scripts = array_merge($scripts, $this->scripts);
     $this->template = 'common/recover.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
Пример #25
0
 public function index()
 {
     $Url = new Url($this->registry);
     if ($this->config->get('config_store_mode') != 'store') {
         $this->redirect(HTTP_HOME);
     }
     $this->load->model('checkout/extension');
     if (!$this->cart->hasProducts() || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         $this->session->set('message', 'No existe la cantidad solicitada disponible para el art&iacute;lo se&ntilde;alado con tres (3) asteriscos');
         $this->redirect(Url::createUrl("checkout/cart"));
     }
     if (!$this->customer->isLogged()) {
         $this->session->set('redirect', Url::createUrl("checkout/cart"));
         $this->redirect(Url::createUrl("account/login"));
     }
     if ($this->cart->hasShipping() && $this->session->get('shipping_methods') && !$this->request->hasPost('shipping_method')) {
         $this->session->set('message', $this->language->get('error_must_select_shipping_method'));
         $this->redirect(Url::createUrl("checkout/cart"));
     } else {
         $this->session->clear('shipping_address_id');
         $this->session->clear('shipping_methods');
         $this->session->clear('shipping_method');
         $this->tax->setZone($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
     }
     /*
      if (!$this->session->has('payment_address_id')) {
      $this->redirect(Url::createUrl("checkout/payment"));
      }
      if (!$this->session->has('payment_method')) {
      $this->redirect(Url::createUrl("checkout/payment"));
      }
     */
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     $sort_order = array();
     $results = $this->modelExtension->getExtensions('total');
     foreach ($results as $key => $value) {
         $sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
     }
     array_multisort($sort_order, SORT_ASC, $results);
     foreach ($results as $result) {
         $this->load->model('total/' . $result['key']);
         $this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
     }
     $sort_order = array();
     foreach ($total_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $total_data);
     $data = array();
     $data['store_name'] = $this->config->get('config_name');
     $data['store_url'] = $this->config->get('config_url');
     $data['customer_id'] = $this->customer->getId();
     $data['customer_group_id'] = $this->customer->getCustomerGroupId();
     $data['firstname'] = $this->customer->getFirstName();
     $data['lastname'] = $this->customer->getLastName();
     $data['email'] = $this->customer->getEmail();
     $data['telephone'] = $this->customer->getTelephone();
     $this->load->model('account/address');
     $this->load->model('account/customer');
     $shipping_address_id = $this->session->has('shipping_address_id') ? $this->session->get('shipping_address_id') : $this->request->getPost('shipping_address_id');
     if ($shipping_address_id) {
         $shipping_address = $this->modelAddress->getAddress($shipping_address_id);
         $data['shipping_company'] = $data['company'];
         $data['shipping_rif'] = $data['rif'];
         $data['shipping_firstname'] = $data['firstname'];
         $data['shipping_lastname'] = $data['lastname'];
         $data['shipping_address_1'] = $shipping_address['address_1'];
         $data['shipping_address_2'] = $shipping_address['address_2'];
         $data['shipping_city'] = $shipping_address['city'];
         $data['shipping_postcode'] = $shipping_address['postcode'];
         $data['shipping_zone'] = $shipping_address['zone'];
         $data['shipping_zone_id'] = $shipping_address['zone_id'];
         $data['shipping_country'] = $shipping_address['country'];
         $data['shipping_country_id'] = $shipping_address['country_id'];
         $data['shipping_address_format'] = $shipping_address['address_format'];
     } else {
         $data['shipping_company'] = $this->customer->getCompany();
         $data['shipping_rif'] = $this->customer->getRif();
         $data['shipping_firstname'] = $this->customer->getFirstName();
         $data['shipping_lastname'] = $this->customer->getLastName();
         $data['shipping_address_1'] = $this->request->getPost('shipping_address_1');
         $data['shipping_city'] = $this->request->getPost('shipping_city');
         $data['shipping_postcode'] = $this->request->getPost('shipping_postcode');
         $data['shipping_zone_id'] = $this->request->getPost('shipping_zone_id');
         $data['shipping_country_id'] = $this->request->getPost('shipping_country_id');
     }
     $data['shipping_method'] = $this->request->getPost('shipping_method');
     $payment_address_id = $this->session->has('payment_address_id') ? $this->session->get('payment_address_id') : $this->request->getPost('payment_address_id');
     if ($payment_address_id) {
         $payment_address = $this->modelAddress->getAddress($payment_address_id);
         $data['payment_company'] = $payment_address['company'];
         $data['payment_rif'] = $payment_address['rif'];
         $data['payment_firstname'] = $payment_address['firstname'];
         $data['payment_lastname'] = $payment_address['lastname'];
         $data['payment_address_1'] = $payment_address['address_1'];
         $data['payment_address_2'] = $payment_address['address_2'];
         $data['payment_city'] = $payment_address['city'];
         $data['payment_postcode'] = $payment_address['postcode'];
         $data['payment_zone'] = $payment_address['zone'];
         $data['payment_zone_id'] = $payment_address['zone_id'];
         $data['payment_country'] = $payment_address['country'];
         $data['payment_country_id'] = $payment_address['country_id'];
         $data['payment_telephone'] = $customer_address['telephone'];
         $data['payment_email'] = $customer_address['email'];
         $data['payment_address_format'] = $payment_address['address_format'];
     } else {
         $data['payment_company'] = $this->customer->getCompany();
         $data['payment_rif'] = $this->customer->getRif();
         $data['payment_firstname'] = $this->customer->getFirstName();
         $data['payment_lastname'] = $this->customer->getLastName();
         $data['payment_address_1'] = $this->request->getPost('payment_address_1');
         $data['payment_city'] = $this->request->getPost('payment_city');
         $data['payment_postcode'] = $this->request->getPost('payment_postcode');
         $data['payment_zone_id'] = $this->request->getPost('payment_zone_id');
         $data['payment_country_id'] = $this->request->getPost('payment_country_id');
     }
     $product_data = array();
     foreach ($this->cart->getProducts() as $product) {
         $option_data = array();
         foreach ($product['option'] as $option) {
             $option_data[] = array('product_option_value_id' => $option['product_option_value_id'], 'name' => $option['name'], 'value' => $option['value'], 'prefix' => $option['prefix']);
         }
         $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->getRate($product['tax_class_id']));
     }
     $data['products'] = $product_data;
     $data['totals'] = $total_data;
     $data['comment'] = $this->session->get('comment');
     $data['total'] = $total;
     $data['language_id'] = $this->config->get('config_language_id');
     $data['currency_id'] = $this->currency->getId();
     $data['currency'] = $this->currency->getCode();
     $data['value'] = $this->currency->getValue($this->currency->getCode());
     if ($this->session->has('coupon')) {
         $this->load->model('checkout/coupon');
         $coupon = $this->modelCoupon->getCoupon($this->session->get('coupon'));
         if ($coupon) {
             $data['coupon_id'] = $coupon['coupon_id'];
         } else {
             $data['coupon_id'] = 0;
         }
     } else {
         $data['coupon_id'] = 0;
     }
     $data['ip'] = $this->request->server['REMOTE_ADDR'];
     $this->load->model('checkout/order');
     $order_id = $this->modelOrder->create($data);
     if ($order_id) {
         $this->session->set('order_id', $order_id);
         $this->modelOrder->confirm($order_id, $this->config->get('cheque_order_status_id'));
         if ($this->request->hasQuery('resp') && $this->request->getQuery('resp') === 'json') {
             $this->load->auto('json');
             $this->response->setOutput(Json::encode(['order_id' => $order_id]), $this->config->get('config_compression'));
         } else {
             $this->redirect(Url::createUrl('checkout/success', array('order_id' => $order_id)));
         }
     }
 }
Пример #26
0
 protected function notifyReview($product_id)
 {
     if (!$product_id) {
         return false;
     }
     $this->load->auto('email/mailer');
     $this->load->auto('store/product');
     $this->load->auto('store/review');
     $this->load->auto('content/page');
     $product_info = $this->modelProduct->getById($product_id);
     if ($product_info) {
         $page = $this->modelPage->getPage($this->config->get('config_email_new_comment'));
         if ($page->num_rows) {
             $subject = $page['title'];
             $message = str_replace("{%product_url%}", Url::createUrl('store/product', array('product_id' => $product_id)), $page['description']);
             $message = str_replace("{%product_name%}", $product_info['name'], $message);
             $mailer = new Mailer();
             $reps = $this->modelReview->getAllByProductId($product_id);
             foreach ($reps as $k => $v) {
                 $mailer->AddBCC($v['email'], $v['author']);
             }
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->Subject = $subject;
             $mailer->Body = $message;
             $mailer->Send();
         }
     }
 }
Пример #27
0
 public function confirm()
 {
     $this->language->load('payment/cod');
     $this->load->model('account/order');
     $this->load->model('account/payment');
     $this->load->library('email/mailer');
     if ($this->session->has('order_id')) {
         $this->data['order_id'] = $this->session->get('order_id');
     } elseif ($this->request->hasQuery('order_id')) {
         $this->data['order_id'] = $this->request->getQuery('order_id');
     } elseif ($this->request->hasPost('cod_order_id')) {
         $this->data['order_id'] = $this->request->getPost('cod_order_id');
     } else {
         $this->data['order_id'] = 0;
     }
     $order_info = $this->modelOrder->getOrder($this->data['order_id']);
     if ($order_info && $this->customer->isLogged()) {
         $total_payment = $this->modelPayment->getSumPayments(array('order_id' => $order_info['order_id'], 'limit' => 1000));
         $total = $order_info['total'] - $total_payment;
         $amount = explode(",", $this->request->getPost('cod_amount'));
         $payment = round(str_replace(".", "", $amount[0]) . "." . $amount[1], 2);
         $data['order_id'] = $order_info['order_id'];
         $data['payment_method'] = $this->language->get('text_title');
         $data['amount'] = $payment;
         $data['comment'] = $this->language->get('text_date_of_payment') . ": " . $this->request->getPost('cod_date_of_payment') . "\n";
         $data['comment'] .= $this->language->get('text_payment_method_on_delivery') . ": " . $this->request->getPost('cod_payment_method_on_delivery') . "\n";
         $data['comment'] .= "\n" . $this->request->getPost('cod_comment');
         $data['order_status_id'] = $this->config->get('cod_order_status_id');
         $data['order_payment_status_id'] = $this->config->get('config_payment_status_id');
         $json['payment_id'] = $payment_id = $this->modelPayment->add($data);
         $this->modelOrder->addOrderHistory($order_info['order_id'], $data);
         $this->modelOrder->updateStatus($order_info['order_id'], $this->config->get('cod_order_status_id'));
         $this->modelOrder->updatePaymentMethod($order_info['order_id'], $this->language->get('text_title'));
         $diff = $payment - $total;
         if ($diff < 0) {
             //falta dinero
             $diff = $diff * -1;
             $json['warning'] = 1;
             $json['msg'] = str_replace('{%payment_receipt%}', Url::createUrl("account/payment"), $this->language->get('error_moneyless'));
             $json['msg'] = str_replace('{%invoice%}', Url::createUrl("account/invoice", array('order_id' => $order_info['order_id'])), $json['msg']);
             $json['msg'] = str_replace('{%diff%}', $this->currency->format($diff), $json['msg']);
         } elseif ($diff > 0) {
             //sobra dinero
             $json['warning'] = 1;
             $json['msg'] = str_replace('{%payment_receipt%}', Url::createUrl("account/payment"), $this->language->get('error_moneymore'));
             $json['msg'] = str_replace('{%invoice%}', Url::createUrl("account/invoice", array('order_id' => $order_info['order_id'])), $json['msg']);
             $json['msg'] = str_replace('{%diff%}', $this->currency->format($diff), $json['msg']);
         } else {
             $json['success'] = 1;
             $json['msg'] = $this->language->get('text_success');
         }
         $mailer = new Mailer();
         if ($this->config->get('cod_newsletter_id')) {
             $this->load->model("marketing/newsletter");
             $this->load->library('BarcodeQR');
             $this->load->library('Barcode39');
             $qr = new BarcodeQR();
             $barcode = new Barcode39(C_CODE);
             $totals = $this->modelOrder->getOrderTotals($order_id);
             $text = $this->config->get('config_owner') . "\n";
             $text .= "Pago ID: " . $payment_id . "\n";
             $text .= "Pedido ID: " . $order_id . "\n";
             $text .= "Fecha Emision del Pedido: " . date('d-m-Y h:i A', strtotime($order_info['date_added'])) . "\n";
             $text .= "Cliente: " . $this->customer->getCompany() . "\n";
             $text .= "RIF: " . $this->customer->getRif() . "\n";
             $text .= "Direccion IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
             $qrStore = "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.jpg';
             $qrPayment = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_qr_code_payment_" . $payment_id) . '.jpg';
             $eanStore = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_barcode_39_order_id_" . $order_id) . '.gif';
             $qr->text($text);
             $qr->draw(150, DIR_IMAGE . $qrPayment);
             $qr->url(HTTP_HOME);
             $qr->draw(150, DIR_IMAGE . $qrStore);
             $barcode->draw(DIR_IMAGE . $eanStore);
             $payment_text = '<h1>' . $this->config->get('config_owner') . "</h1>";
             $payment_text .= "Pago ID: " . $payment_id . "<br />";
             $payment_text .= "Pedido ID: " . $order_id . "<br />";
             $payment_text .= "Fecha Emision del Pedido: " . date('d-m-Y h:i A', strtotime($order_info['date_added'])) . "<br />";
             $payment_text .= "Cliente: " . $this->customer->getCompany() . "<br />";
             $payment_text .= "RIF: " . $this->customer->getRif() . "<br />";
             $payment_text .= "Direccion IP: " . $_SERVER['REMOTE_ADDR'] . "<br />";
             $total_html = "<div class=\"clear:both;float:none;\"></div><br /><table>";
             foreach ($totals as $total) {
                 $total_html .= "<tr>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['title'] . "</td>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['text'] . "</td>";
                 $total_html .= "</tr>";
             }
             $total_html .= "</table>";
             $payment_text .= $total_html;
             $result = $this->modelNewsletter->getById($this->config->get('cod_newsletter_id'));
             $message = $result['htmlbody'];
             $message = str_replace("{%title%}", 'Pago N&deg; ' . $payment_id . " - " . $this->config->get('config_name'), $message);
             $message = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $message);
             $message = str_replace("{%store_url%}", HTTP_HOME, $message);
             $message = str_replace("{%store_owner%}", $this->config->get('config_owner'), $message);
             $message = str_replace("{%store_name%}", $this->config->get('config_name'), $message);
             $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
             $message = str_replace("{%store_email%}", $this->config->get('config_email'), $message);
             $message = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $message);
             $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
             $message = str_replace("{%totals%}", $total_html, $message);
             $message = str_replace("{%order_id%}", $this->config->get('config_invoice_prefix') . $order_id, $message);
             $message = str_replace("{%invoice_id%}", $this->config->get('config_invoice_prefix') . $invoice_id, $message);
             $message = str_replace("{%rif%}", $this->customer->getRif(), $message);
             $message = str_replace("{%fullname%}", $this->customer->getFirstName() . " " . $this->customer->getFirstName(), $message);
             $message = str_replace("{%company%}", $this->customer->getCompany(), $message);
             $message = str_replace("{%email%}", $this->customer->getEmail(), $message);
             $message = str_replace("{%telephone%}", $this->customer->getTelephone(), $message);
             $message = str_replace("{%payment%}", $payment_text, $message);
             $message = str_replace("{%payment_method%}", $order_info['payment_method'], $message);
             $message = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order_info['date_added'])), $message);
             $message = str_replace("{%ip%}", $_SERVER['REMOTE_ADDR'], $message);
             $message = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $message);
             $message = str_replace("{%comment%}", $order_info['comment'], $message);
             $message = str_replace("{%qr_code_payment%}", '<img src="' . HTTP_IMAGE . $qrPayment . '" alt="QR Code" />', $message);
             $message = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $message);
             $message .= "<p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
         } else {
             $message = $this->config->get('config_owner') . "\n";
             $message .= "Pago ID: " . $payment_id . "\n";
             $message .= "Pedido ID: " . $order_id . "\n";
             $message .= "Fecha Emision: " . date('d-m-Y h:i A', strtotime($order_info['date_added'])) . "\n";
             $message .= "Cliente: " . $this->customer->getCompany() . "\n";
             $message .= "RIF: " . $this->customer->getRif() . "\n";
             $message .= "Direccion IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
             $message .= "\n" . "Powered By Necotienda&reg; " . date('Y') . "\n";
         }
         if ($message) {
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($this->customer->getEmail(), $this->customer->getCompany());
             $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->Subject = $this->config->get('config_owner') . " " . $this->language->get('text_new_payment') . " #" . $payment_id;
             $mailer->Body = html_entity_decode(htmlspecialchars_decode($message));
             $mailer->Send();
         }
     } elseif (!$this->customer->isLogged()) {
         $json['error'] = 1;
         $json['msg'] = $this->language->get('error_not_logged');
     } else {
         $json['error'] = 1;
         $json['msg'] = $this->language->get('error_payment');
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json), $this->config->get('config_compression'));
 }
Пример #28
0
 public function index()
 {
     $Url = new Url($this->registry);
     if ($this->config->get('config_store_mode') != 'store') {
         $this->redirect(HTTP_HOME);
     }
     $this->language->load('checkout/success');
     $this->load->auto('account/address');
     $address = $this->modelAddress->getAddress($this->customer->getAddressId());
     $method_data = array();
     $results = $this->modelExtension->getExtensions('payment');
     foreach ($results as $result) {
         $this->load->model('payment/' . $result['key']);
         $this->language->load('payment/' . $result['key']);
         $method = $this->{'model_payment_' . $result['key']}->getMethod($address);
         if ($method) {
             $method_data[$result['key']] = $method;
         }
     }
     $sort_order = array();
     foreach ($method_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $method_data);
     $this->data['payment_methods'] = $method_data;
     foreach ($method_data as $key => $value) {
         $this->children[$key] = 'payment/' . $key;
     }
     $order_id = 0;
     if ($this->session->has('order_id')) {
         $order_id = $this->session->get('order_id');
     } elseif ($this->request->hasPost('order_id')) {
         $order_id = $this->request->getPost('order_id');
     } elseif ($this->request->hasQuery('order_id')) {
         $order_id = $this->request->getQuery('order_id');
     }
     $this->data['order_id'] = $order_id;
     if ($order_id) {
         if ($this->config->get('marketing_email_new_order')) {
             $this->load->model('account/order');
             $this->load->model('account/payment');
             $this->load->model("marketing/newsletter");
             $this->load->library('email/mailer');
             $this->load->library('BarcodeQR');
             $this->load->library('Barcode39');
             $this->load->library('tcpdf/config/lang/spa');
             $this->load->library('tcpdf/tcpdf');
             $mailer = new Mailer();
             $qr = new BarcodeQR();
             $barcode = new Barcode39(C_CODE);
             $this->data['Currency'] = $this->currency;
             $this->data['order'] = $order = $this->modelOrder->getOrder($order_id);
             $this->data['products'] = $products = $this->modelOrder->getOrderProducts($order_id);
             $this->data['totals'] = $totals = $this->modelOrder->getOrderTotals($order_id);
             $this->data['payments'] = $payments = $this->modelPayment->getPayments(array('order_id' => $order_id, 'order_payment_status_id' => $this->config->get('order_payment_status_approved')));
             $shipping_address = $order['shipping_address_1'] . ", " . $order['shipping_city'] . ". " . $order['shipping_zone'] . " - " . $order['shipping_country'] . ". CP " . $order['shipping_zone_code'];
             $payment_address = $order['payment_address_1'] . ", " . $order['payment_city'] . ". " . $order['payment_zone'] . " - " . $order['payment_country'] . ". CP " . $order['payment_zone_code'];
             $text = $this->config->get('config_owner') . "\n";
             $text .= "Pedido ID: " . $order_id . "\n";
             $text .= "Fecha Emision: " . date('d-m-Y h:i A', strtotime($order['date_added'])) . "\n";
             $text .= "Cliente: " . $this->customer->getCompany() . "\n";
             $text .= "RIF: " . $this->customer->getRif() . "\n";
             $text .= "Direccion IP: " . $order['ip'] . "\n";
             $text .= "Productos (" . count($products) . ")\n";
             $text .= "Modelo\tCant.\tTotal\n";
             foreach ($products as $key => $product) {
                 $text .= $product['model'] . "\t" . $product['quantity'] . "\t" . $this->currency->format($product['total'], $order['currency'], $order['value']) . "\n";
             }
             $qrStore = "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.jpg';
             $qrOrder = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_qr_code_order_" . $order_id) . '.jpg';
             $eanStore = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_barcode_39_order_id_" . $order_id) . '.gif';
             $qr->text($text);
             $qr->draw(150, DIR_IMAGE . $qrOrder);
             $qr->url(HTTP_HOME);
             $qr->draw(150, DIR_IMAGE . $qrStore);
             $barcode->draw(DIR_IMAGE . $eanStore);
             $product_html = "<table><thead><tr style=\"background:#ccc;color:#666;\"><th>Item</th><th>" . $this->language->get('column_description') . "</th><th>" . $this->language->get('column_model') . "</th><th>" . $this->language->get('column_quantity') . "</th><th>" . $this->language->get('column_price') . "</th><th>" . $this->language->get('column_total') . "</th></tr></thead><tbody>";
             foreach ($products as $key => $product) {
                 $options = $this->modelOrder->getOrderOptions($order_id, $product['order_product_id']);
                 $option_data = "";
                 foreach ($options as $option) {
                     $option_data .= "&nbsp;&nbsp;&nbsp;&nbsp;- " . $option['name'] . "<br />";
                 }
                 $product_html .= "<tr>";
                 $product_html .= "<td style=\"width:5%\">" . (int) ($key + 1) . "</td>";
                 $product_html .= "<td style=\"width:45%\">" . $product['name'] . "<br />" . $option_data . "</td>";
                 $product_html .= "<td style=\"width:20%\">" . $product['model'] . "</td>";
                 $product_html .= "<td style=\"width:10%\">" . $product['quantity'] . "</td>";
                 $product_html .= "<td style=\"width:10%\">" . $this->currency->format($product['price'], $order['currency'], $order['value']) . "</td>";
                 $product_html .= "<td style=\"width:10%\">" . $this->currency->format($product['total'], $order['currency'], $order['value']) . "</td>";
                 $product_html .= "</tr>";
             }
             $product_html .= "</tbody></table>";
             $total_html = "<div class=\"clear:both;float:none;\"></div><br /><table style=\"float:right;\">";
             foreach ($totals as $total) {
                 $total_html .= "<tr>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['title'] . "</td>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['text'] . "</td>";
                 $total_html .= "</tr>";
             }
             $total_html .= "</table>";
             $result = $this->modelNewsletter->getById($this->config->get('marketing_email_new_order'));
             $message = $result['htmlbody'];
             $message = str_replace("{%title%}", 'Pedido N&deg; ' . $order_id . " - " . $this->config->get('config_name'), $message);
             $message = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $message);
             $message = str_replace("{%store_url%}", HTTP_HOME, $message);
             $message = str_replace("{%store_owner%}", $this->config->get('config_owner'), $message);
             $message = str_replace("{%store_name%}", $this->config->get('config_name'), $message);
             $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
             $message = str_replace("{%store_email%}", $this->config->get('config_email'), $message);
             $message = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $message);
             $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
             $message = str_replace("{%products%}", $product_html, $message);
             $message = str_replace("{%totals%}", $total_html, $message);
             $message = str_replace("{%order_id%}", $this->config->get('config_invoice_prefix') . $order_id, $message);
             $message = str_replace("{%invoice_id%}", $this->config->get('config_invoice_prefix') . $invoice_id, $message);
             $message = str_replace("{%rif%}", $this->customer->getRif(), $message);
             $message = str_replace("{%fullname%}", $this->customer->getFirstName() . " " . $this->customer->getFirstName(), $message);
             $message = str_replace("{%company%}", $this->customer->getCompany(), $message);
             $message = str_replace("{%email%}", $this->customer->getEmail(), $message);
             $message = str_replace("{%telephone%}", $this->customer->getTelephone(), $message);
             $message = str_replace("{%payment_address%}", $payment_address, $message);
             $message = str_replace("{%payment_method%}", $order['payment_method'], $message);
             $message = str_replace("{%shipping_address%}", $shipping_address, $message);
             $message = str_replace("{%shipping_method%}", $order['shipping_method'], $message);
             $message = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order['date_added'])), $message);
             $message = str_replace("{%ip%}", $order['ip'], $message);
             $message = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $message);
             $message = str_replace("{%comment%}", $order['comment'], $message);
             $message = str_replace("{%qr_code_order%}", '<img src="' . HTTP_IMAGE . $qrOrder . '" alt="QR Code" />', $message);
             $message = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $message);
             $message .= "<p style=\"text-align:center\">Powered By <a href=\"http://www.necotienda.org\">Necotienda</a>&reg; " . date('Y') . "</p>";
             if ($this->config->get('marketing_email_order_pdf')) {
                 $pdfFile = DIR_CACHE . str_replace(" ", "_", $this->config->get('config_owner') . "_pedido_" . $order_id) . '.pdf';
                 $result = $this->modelNewsletter->getById($this->config->get('marketing_email_order_pdf'));
                 $pdfBody = html_entity_decode($result['htmlbody']);
                 $pdfBody = str_replace("{%store_url%}", HTTP_HOME, $pdfBody);
                 $pdfBody = str_replace("{%title%}", 'Pedido N&deg; ' . $order_id . " - " . $this->config->get('config_name'), $pdfBody);
                 $pdfBody = str_replace("{%store_owner%}", $this->config->get('config_owner'), $pdfBody);
                 $pdfBody = str_replace("{%store_name%}", $this->config->get('config_name'), $pdfBody);
                 $pdfBody = str_replace("{%store_rif%}", $this->config->get('config_rif'), $pdfBody);
                 $pdfBody = str_replace("{%store_email%}", $this->config->get('config_email'), $pdfBody);
                 $pdfBody = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $pdfBody);
                 $pdfBody = str_replace("{%store_address%}", $this->config->get('config_address'), $pdfBody);
                 $pdfBody = str_replace("{%products%}", $product_html, $pdfBody);
                 $pdfBody = str_replace("{%totals%}", $total_html, $pdfBody);
                 $pdfBody = str_replace("{%order_id%}", $this->config->get('config_invoice_prefix') . $order_id, $pdfBody);
                 $pdfBody = str_replace("{%invoice_id%}", $this->config->get('config_invoice_prefix') . $invoice_id, $pdfBody);
                 $pdfBody = str_replace("{%rif%}", $this->customer->getRif(), $pdfBody);
                 $pdfBody = str_replace("{%fullname%}", $this->customer->getFirstName() . " " . $this->customer->getFirstName(), $pdfBody);
                 $pdfBody = str_replace("{%company%}", $this->customer->getCompany(), $pdfBody);
                 $pdfBody = str_replace("{%email%}", $this->customer->getEmail(), $pdfBody);
                 $pdfBody = str_replace("{%telephone%}", $this->customer->getTelephone(), $pdfBody);
                 $pdfBody = str_replace("{%payment_address%}", $payment_address, $pdfBody);
                 $pdfBody = str_replace("{%payment_method%}", $order['payment_method'], $pdfBody);
                 $pdfBody = str_replace("{%shipping_address%}", $shipping_address, $pdfBody);
                 $pdfBody = str_replace("{%shipping_method%}", $order['shipping_method'], $pdfBody);
                 $pdfBody = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order['date_added'])), $pdfBody);
                 $pdfBody = str_replace("{%ip%}", $order['ip'], $pdfBody);
                 $pdfBody = str_replace("{%comment%}", $order['comment'], $pdfBody);
                 if (file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
                     $pdfBody = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $pdfBody);
                 } else {
                     $pdfBody = str_replace("{%store_logo%}", '', $pdfBody);
                 }
                 if (file_exists(DIR_IMAGE . $qrStore)) {
                     $pdfBody = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $pdfBody);
                 } else {
                     $pdfBody = str_replace("{%qr_code_store%}", '', $pdfBody);
                 }
                 if (file_exists(DIR_IMAGE . $qrOrder)) {
                     $pdfBody = str_replace("{%qr_code_order%}", '<img src="' . HTTP_IMAGE . $qrOrder . '" alt="QR Code" />', $pdfBody);
                 } else {
                     $pdfBody = str_replace("{%qr_code_order%}", '', $pdfBody);
                 }
                 $pdfBody = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $pdfBody);
                 $pdfBody .= "<p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
                 // create new PDF document
                 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                 // set document information
                 $pdf->SetCreator("Powered By NecoTienda&reg;");
                 $pdf->SetTitle($this->config->get('config_name'));
                 $pdf->SetAuthor($this->config->get('config_name'));
                 $pdf->SetSubject($this->config->get('config_owner') . " " . $this->language->get('text_order') . " #" . $order_id);
                 $pdf->SetKeywords($this->config->get('config_name') . ', ' . $product_tags . ',pdf');
                 // set default header data
                 $pdf->SetHeaderData($this->config->get('config_logo'), PDF_HEADER_LOGO_WIDTH, $this->config->get('config_owner'), $this->config->get('config_name'));
                 // set header and footer fonts
                 $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
                 $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
                 // set default monospaced font
                 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                 //set margins
                 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
                 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
                 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
                 //set auto page breaks
                 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                 //set image scale factor
                 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                 //set some language-dependent strings
                 $pdf->setLanguageArray($l);
                 // set font
                 $pdf->SetFont('dejavusans', '', 10);
                 // add a page
                 $pdf->AddPage();
                 // output the HTML content
                 $pdf->writeHTML($pdfBody, true, false, true, false, '');
                 //Close and output PDF document
                 $pdf->Output($pdfFile, 'F');
             }
             $subject = $this->config->get('config_owner') . " " . $this->language->get('text_new_order') . " #" . $order_id;
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($this->customer->getEmail(), $this->customer->getCompany());
             $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->Subject = $subject;
             $mailer->Body = html_entity_decode(htmlspecialchars_decode($message));
             if ($pdfFile && file_exists($pdfFile)) {
                 $mailer->AddAttachment($pdfFile);
             }
             $mailer->Send();
         }
         $order_id = $this->session->get('order_id');
         $this->cart->clear();
         $this->session->clear('shipping_method');
         $this->session->clear('shipping_methods');
         $this->session->clear('payment_method');
         $this->session->clear('payment_methods');
         $this->session->clear('guest');
         $this->session->clear('comment');
         $this->session->clear('order_id');
         $this->session->clear('coupon');
     }
     $this->document->title = $this->language->get('heading_title');
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("common/home"), 'text' => $this->language->get('text_home'), 'separator' => false);
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("checkout/cart"), 'text' => $this->language->get('text_basket'), 'separator' => $this->language->get('text_separator'));
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("checkout/success"), 'text' => $this->language->get('text_checkout_success'), 'separator' => $this->language->get('text_separator'));
     $this->data['breadcrumbs'] = $this->document->breadcrumbs;
     $this->data['heading_title'] = $this->language->get('heading_title');
     if ($this->config->get('page_order_success')) {
         $this->load->model('content/page');
         $page = $this->modelPage->getById($this->config->get('page_order_success'));
         $this->data['text_message'] = html_entity_decode($page['description']);
     } else {
         $this->data['text_message'] = sprintf($this->language->get('text_message'), Url::createUrl("account/account"), Url::createUrl("account/order"), Url::createUrl("page/contact"));
     }
     // style files
     $csspath = defined("CDN") ? CDN . CSS : HTTP_CSS;
     $styles[] = array('media' => 'all', 'href' => $csspath . 'jquery-ui/jquery-ui.min.css');
     $styles[] = array('media' => 'all', 'href' => $csspath . 'neco.form.css');
     $this->data['styles'] = $this->styles = array_merge($this->styles, $styles);
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/checkout/success.tpl')) {
         $this->template = $this->config->get('config_template') . '/checkout/success.tpl';
     } else {
         $this->template = 'choroni/checkout/success.tpl';
     }
     $this->children[] = 'common/nav';
     $this->children[] = 'common/footer';
     $this->children[] = 'common/header';
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
Пример #29
0
 protected function prefetch($limit)
 {
     $this->language->load('module/random');
     $this->load->model('store/product');
     $results = $this->modelProduct->getRandomProducts($this->config->get('catalog_limit'));
     $this->load->auto('store/review');
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['button_see_product'] = $this->language->get('button_see_product');
     $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
     $this->data['products'] = array();
     list($dia, $mes, $ano) = explode('-', date('d-m-Y'));
     $l = (int) $this->config->get('config_new_days') > 30 ? 30 : $this->config->get('config_new_days');
     if (($dia = $dia - $l) <= 0) {
         $dia = $dia + 30;
         if ($dia <= 0) {
             $dia = 1;
         }
         $mes = $mes - 1;
         if ($mes <= 0) {
             $mes = $mes + 12;
             $ano = $ano - 1;
         }
     }
     foreach ($results as $key => $result) {
         $image = !empty($result['image']) ? $result['image'] : 'no_image.jpg';
         if ($this->config->get('config_review')) {
             $rating = $this->modelReview->getAverageRating($result['product_id']);
         } else {
             $rating = false;
         }
         $special = false;
         $discount = $this->modelProduct->getProductDiscount($result['product_id']);
         if ($discount) {
             $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             $special = $this->modelProduct->getProductSpecial($result['product_id']);
             if ($special) {
                 $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
             }
         }
         $options = $this->modelProduct->getProductOptions($result['product_id']);
         if ($options) {
             $add = Url::createUrl('store/product', array('product_id' => $result['product_id']));
         } else {
             $add = Url::createUrl('checkout/cart', array('product_id' => $result['product_id']));
         }
         list($pdia, $pmes, $pano) = explode('-', date('d-m-Y', strtotime($result['created'])));
         if ($special) {
             $sticker = '<b class="oferta"></b>';
         } elseif ($discount) {
             $sticker = '<b class="descuento"></b>';
         } elseif (strtotime($dia . "-" . $mes . "-" . $ano) <= strtotime($pdia . "-" . $pmes . "-" . $pano)) {
             $sticker = '<b class="nuevo"></b>';
         } else {
             $sticker = "";
         }
         $this->load->auto('image');
         $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'overview' => $result['meta_description'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'sticker' => $sticker, 'options' => $options, 'special' => $special, 'image' => NTImage::resizeAndSave($image, 38, 38), 'lazyImage' => NTImage::resizeAndSave('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')), 'thumb' => NTImage::resizeAndSave($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')), 'href' => Url::createUrl('store/product', array('product_id' => $result['product_id'])), 'add' => $add, 'created' => $result['created']);
     }
     if (!$this->config->get('config_customer_price') || $this->customer->isLogged()) {
         $this->data['display_price'] = true;
     } else {
         $this->data['display_price'] = false;
     }
 }
Пример #30
0
 public function runUpdate($task)
 {
     if ($this->isLocked('update', $task->task_id)) {
         $task->addMinute(15);
     } else {
         $task->start();
         $this->data['update_info'] = $this->update->getInfo();
         if ($this->request->server['REQUEST_METHOD'] == 'POST') {
             $this->modelSetting->editMaintenance(1);
             $backup = new Backup($this->registry);
             $backup->run();
             $this->update->run();
             $this->modelSetting->editMaintenance(0);
         }
         foreach ($task->getTaskQueue() as $key => $queue) {
             if ($count >= 50) {
                 break;
             }
             $params = unserialize($queue['params']);
             $cached = $this->cache->get("campaign.html.{$params['campaign_id']}.{$params['contact_id']}");
             if ($cached) {
                 $htmlbody = html_entity_decode($cached);
             } else {
                 $htmlbody = str_replace("%7B", "{", $htmlbody);
                 $htmlbody = str_replace("%7D", "}", $htmlbody);
                 $htmlbody = str_replace("{%contact_id%}", $params['contact_id'], $htmlbody);
                 $htmlbody = str_replace("{%campaign_id%}", $params['campaign_id'], $htmlbody);
                 $htmlbody = str_replace("{%fullname%}", $params['name'], $htmlbody);
                 $htmlbody = str_replace("{%rif%}", $params['rif'], $htmlbody);
                 $htmlbody = str_replace("{%company%}", $params['company'], $htmlbody);
                 $htmlbody = str_replace("{%email%}", $params['email'], $htmlbody);
                 $htmlbody = str_replace("{%telephone%}", $params['telephone'], $htmlbody);
                 $htmlbody = $this->prepareTemplate($htmlbody, $params);
                 $dom = new DOMDocument();
                 $dom->preserveWhiteSpace = false;
                 $dom->loadHTML($htmlbody);
                 /*
                 if ($params['embed_image']) {
                     $images = $dom->getElementsByTagName('img');
                     foreach ($images as $image) {
                         $src = $image->getAttribute('src');
                         $src = str_replace(HTTP_IMAGE,DIR_IMAGE,$src);
                         if (file_exists($src)) {
                             $img    = file_get_contents($src);
                             $ext    = substr($src,(strrpos($src,'.')+1));
                             $embed  = base64_encode($img); 
                             $image->setAttribute('src',"data:image/$ext;base64,$embed");
                             $total_embed_images++;
                         }
                         $total_images++;
                     }
                 }
                 */
                 $vars = array('contact_id' => $params['contact_id'], 'campaign_id' => $params['campaign_id'], 'referencedBy' => $params['email']);
                 /* trace the email */
                 $trace_url = Url::createUrl("marketing/campaign/trace", $vars, 'NONSSL', HTTP_HOME);
                 $trackEmail = $dom->createElement('img');
                 $trackEmail->setAttribute('src', $trace_url);
                 $dom->appendChild($trackEmail);
                 /* trace the clicks */
                 $links = $dom->getElementsByTagName('a');
                 foreach ($links as $link) {
                     $href = $link->getAttribute('href');
                     if (empty($href) || $href == "#" || strpos($href, "mailto:") || strpos($href, "callto:") || strpos($href, "skype:") || strpos($href, "tel:")) {
                         continue;
                     }
                     //TODO: validar enlaces
                     //TODO: sanitizar enlaces
                     $vars['link_index'] = $link_index = md5(time() . mt_rand(1000000, 9999999) . $href);
                     $_link = Url::createUrl("marketing/campaign/link", $vars, 'NONSSL', HTTP_HOME);
                     $this->db->query("INSERT INTO " . DB_PREFIX . "campaign_link SET \r\n                          `campaign_id` = '" . (int) $params['campaign_id'] . "',\r\n                          `url`         = '" . $this->db->escape($_link) . "',\r\n                          `redirect`    = '" . $this->db->escape($href) . "',\r\n                          `link`        = '" . $this->db->escape($link_index) . "',\r\n                          `date_added`  = NOW()");
                     $link->setAttribute('href', $_link);
                     //TODO: agregar valor a la etiqueta title si esta vacia
                 }
                 $htmlbody = html_entity_decode(htmlentities($dom->saveHTML()));
             }
             $this->mailer->AddAddress($params['email'], $params['name']);
             $this->mailer->IsHTML();
             $this->mailer->SetFrom($campign_info['from_email'], $campign_info['from_name']);
             $this->mailer->AddReplyTo($campign_info['replyto_email'], $campign_info['from_name']);
             $this->mailer->Subject = $campign_info['subject'];
             $this->mailer->Body = $htmlbody;
             $this->mailer->Send();
             $this->mailer->ClearAllRecipients();
             $task->setQueueDone($key);
             $count++;
         }
         if (count($task->getTaskDos($task->task_id))) {
             $task->addMinute(15);
         } else {
             $task->setTaskDone();
         }
     }
     $task->update();
 }