public function init()
    {
        if (Tools::getValue('supplier_rewrite')) {
            $name_supplier = str_replace('-', '%', Tools::getValue('supplier_rewrite'));
            //
            // TODO:: need to core update Prestashop code and
            // DB for link_rewrite for suppliers
            // Should we use the Mysql FullText Index Search ??
            //
            $sql = 'SELECT sp.`id_supplier`
				FROM `' . _DB_PREFIX_ . 'supplier` sp
				LEFT JOIN `' . _DB_PREFIX_ . 'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`)
				WHERE sp.`name` LIKE \'' . $name_supplier . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_supplier = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_supplier > 0) {
                $_GET['id_supplier'] = $id_supplier;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        }
        parent::init();
    }
Example #2
0
 public function postProcess()
 {
     global $currentIndex;
     if (isset($_POST['submitDatabase' . $this->table])) {
         if ($this->tabAccess['edit'] === '1') {
             foreach ($this->_fieldsDatabase as $field => $values) {
                 if (isset($values['required']) and $values['required']) {
                     if (($value = Tools::getValue($field)) == false and (string) $value != '0') {
                         $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required');
                     }
                 }
             }
             if (!sizeof($this->_errors)) {
                 /* Datas are not saved in database but in config/settings.inc.php */
                 $settings = array();
                 foreach ($_POST as $k => $value) {
                     if ($value) {
                         $settings['_' . Tools::strtoupper($k) . '_'] = $value;
                     }
                 }
                 rewriteSettingsFile(NULL, NULL, $settings);
                 Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
         }
     }
 }
 public function postProcess()
 {
     global $cookie, $currentIndex;
     $this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     $this->adminAttributes->postProcess($this->token);
     Module::hookExec('postProcessAttributeGroup', array('errors' => &$this->_errors));
     // send _errors as reference to allow postProcessAttributeGroup to stop saving process
     if (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 $object = new $this->className();
                 if ($object->deleteSelection($_POST[$this->table . 'Box'])) {
                     Tools::redirectAdmin($currentIndex . '&conf=2' . '&token=' . $this->token);
                 }
                 $this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
             } else {
                 $this->_errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } else {
         parent::postProcess();
     }
 }
Example #4
0
 protected function _prepareHook($params)
 {
     $languages = Language::getLanguages(true, $this->context->shop->id);
     if (!count($languages)) {
         return false;
     }
     $link = new Link();
     if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
         $default_rewrite = array();
         if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
             $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
             $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
             $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
             foreach ($rewrite_infos as $infos) {
                 $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
                 $default_rewrite[$infos['id_lang']] = $arr_link;
             }
         }
         $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
     }
     return true;
 }
Example #5
0
 public function renderForm($args, $data)
 {
     global $currentIndex;
     $options = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')));
     $orderby = array(array('order' => 'date_add', 'name' => $this->l('Date Add')), array('order' => 'date_upd', 'name' => $this->l('Date Update')), array('order' => 'name', 'name' => $this->l('Name')), array('order' => 'id_product', 'name' => $this->l('Product Id')), array('order' => 'price', 'name' => $this->l('Price')));
     $orderway = array(array('orderway' => 'ASC', 'name' => $this->l('Ascending')), array('orderway' => 'DESC', 'name' => $this->l('Descending')));
     $root = Category::getRootCategory();
     $categories = array();
     $helper = $this->getFormHelper();
     $items = '';
     $tab_edit = '';
     if ($data['params'] && isset($data['params']['leotab']) && $data['params']['leotab']) {
         $tabs = $data['params']['leotab'];
         $items = $this->getTabs($tabs);
         if (Tools::getValue('id_tab')) {
             $id_tab = Tools::getValue('id_tab');
             $tab_edit = $items[$id_tab] ? $items[$id_tab] : '';
             $categories = $items[$id_tab]['categories'] ? $items[$id_tab]['categories'] : array();
         }
     }
     $tree = new HelperTreeCategories('categories-tree', 'Categories');
     $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories);
     $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp')));
     $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => (int) Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'text_title' => 'title_' . Context::getContext()->language->iso_code, 'path' => __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/img/icontab/', 'images' => LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . _THEME_NAME_ . '/img/icontab/'), 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'items' => $items, 'tab_edit' => $tab_edit);
     return $helper->generateForm($this->fields_form);
 }
 protected function canonicalRedirection()
 {
     global $link, $cookie;
     if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
         // Automatically redirect to the canonical URL if needed
         if (isset($this->php_self) && !empty($this->php_self)) {
             // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
             $canonicalURL = $link->getPageLink($this->php_self, $this->ssl, $cookie->id_lang);
             if (!Tools::getValue('ajax') && !preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', ($this->ssl && _PS_SSL_ENABLED_ ? 'https://' : 'http://') . urldecode($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']))) {
                 if ($_SERVER['REQUEST_URI'] == __PS_BASE_URI__) {
                     header('HTTP/1.0 303 See Other');
                     header('Cache-Control: no-cache');
                 } else {
                     header('HTTP/1.0 301 Moved Permanently');
                     header('Cache-Control: no-cache');
                 }
                 $params = '';
                 $excludedKey = array('isolang', 'id_lang');
                 foreach ($_GET as $key => $value) {
                     if (!in_array($key, $excludedKey)) {
                         $params .= ($params == '' ? '?' : '&') . $key . '=' . $value;
                     }
                 }
                 Module::hookExec('frontCanonicalRedirect');
                 if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) {
                     die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . $params . '">' . $canonicalURL . $params . '</a>');
                 }
                 Tools::redirectLink($canonicalURL . $params);
             }
         }
     }
 }
Example #7
0
    public function hookAdminStatsModules($params)
    {
        $engineParams = array('id' => 'id_customer', 'title' => $this->displayName, 'columns' => $this->_columns, 'defaultSortColumn' => $this->_defaultSortColumn, 'defaultSortDirection' => $this->_defaultSortDirection, 'emptyMessage' => $this->_emptyMessage, 'pagingMessage' => $this->_pagingMessage);
        if (Tools::getValue('export')) {
            $this->csvExport($engineParams);
        }
        $this->_html = '
		<div class="blocStats"><h2 class="icon-' . $this->name . '"><span></span>' . $this->displayName . '</h2>
			' . $this->engine($engineParams) . '
		<p><a class="button export-csv" href="' . htmlentities($_SERVER['REQUEST_URI']) . '&export=1"><span>' . $this->l('CSV Export') . '</span></a></p>
		</div><br />
		<div class="blocStats"><h2 class="icon-guide"><span></span>' . $this->l('Guide') . '</h2>
			<h2 >' . $this->l('Develop clients\' loyalty') . '</h2>
			<p class="space">
				' . $this->l('Keeping a client is more profitable than gaining a new one. Thus, it is necessary to develop their loyalty, in other words to make them want to come back to your webshop.') . ' <br />
				' . $this->l('Word of mouth is also a means to of getting new, satisfied clients; a dissatisfied one won\'t attract new clients.') . '<br />
				' . $this->l('In order to achieve this goal you can organize: ') . '
				<ul>
					<li>' . $this->l('Punctual operations: commercial rewards (personalized special offers, product or service offered),
						non commercial rewards (priority handling of an order or a product), pecuniary rewards (bonds, discount coupons, payback).') . '</li>
					<li>' . $this->l('Sustainable operations: loyalty points or cards, which not only justify communication between merchant and client,
						 but also offer advantages to clients (private offers, discounts).') . '</li>
				</ul>
				' . $this->l('These operations encourage clients to buy products and visit your webshop regularly.') . ' <br />
			</p><br />
		</div>';
        return $this->_html;
    }
 private function rev_uploader()
 {
     $key = Tools::getValue('security_key');
     if (empty($key) || Tools::encrypt(GlobalsRevSlider::MODULE_NAME) != $key) {
         echo json_encode(array('error_on' => 1, 'error_details' => 'Security Error'));
         die;
     }
     $targetFolder = ABSPATH . '/uploads/';
     $randnum = rand(00, 9999999);
     $sds_time = time();
     $NewFileName = $randnum . '-' . $sds_time;
     //$verifyToken = md5('unique_salt' . $_POST['timestamp']);
     if (!empty($_FILES)) {
         $tempFile = $_FILES['Filedata']['tmp_name'];
         //$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
         $targetPath = $targetFolder;
         //$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
         // Validate the file type
         $fileTypes = array('jpg', 'jpeg', 'gif', 'png');
         // File extensions
         $fileParts = pathinfo($_FILES['Filedata']['name']);
         if (in_array($fileParts['extension'], $fileTypes)) {
             // $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $randnum.$_FILES['Filedata']['name']);
             $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $NewFileName . '.' . $fileParts['extension']);
             if (!empty($worked)) {
                 echo '1';
             }
         } else {
             echo '0';
         }
     }
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id = intval(Tools::getValue('id_attachment')) and $a = new Attachment($id)) {
             $_POST['file'] = $a->file;
             $_POST['mime'] = $a->mime;
         }
         if (!sizeof($this->_errors)) {
             if (isset($_FILES['file']) and is_uploaded_file($_FILES['file']['tmp_name'])) {
                 if ($_FILES['file']['size'] > $this->maxFileSize) {
                     $this->_errors[] = $this->l('File too large, maximum size allowed:') . ' ' . $this->maxFileSize / 1000 . ' ' . $this->l('kb');
                 } else {
                     $uploadDir = dirname(__FILE__) . '/../../download/';
                     do {
                         $uniqid = sha1(microtime());
                     } while (file_exists($uploadDir . $uniqid));
                     if (!copy($_FILES['file']['tmp_name'], $uploadDir . $uniqid)) {
                         $this->_errors[] = $this->l('File copy failed');
                     }
                     @unlink($_FILES['file']['tmp_name']);
                     $_POST['name_2'] .= '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
                     $_POST['file'] = $uniqid;
                     $_POST['mime'] = $_FILES['file']['type'];
                 }
             }
         }
         $this->validateRules();
     }
     return parent::postProcess();
 }
Example #10
0
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = new Order($id_order);
     $paypal_order = PayPalOrder::getOrderById($id_order);
     if (defined("PAYPAL_FORCE_CURRENCY")) {
         $currency = new Currency((int) $this->context->currency->id);
         $paycurrency = new Currency(PAYPAL_FORCE_CURRENCY);
         $currency_decimals = $paycurrency->decimals;
         $paypal_order['total_paid'] = $paypal_order['total_paid'] / $currency->conversion_rate * $paycurrency->conversion_rate;
     }
     $price = Tools::displayPrice($paypal_order['total_paid'], $this->context->currency);
     $order_state = new OrderState($id_order);
     if ($order_state) {
         $order_state_message = $order_state->template[$this->context->language->id];
     }
     if (!$order || !$order_state || isset($order_state_message) && $order_state_message == 'payment_error') {
         $this->context->smarty->assign(array('logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => $price));
         if (isset($order_state_message) && $order_state_message) {
             $this->context->smarty->assign('message', $order_state_message);
         }
         $template = 'error.tpl';
     } else {
         $this->context->smarty->assign(array('order' => $paypal_order, 'price' => $price));
         if (version_compare(_PS_VERSION_, '1.5', '>')) {
             $this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($paypal_order['id_order'])));
         }
         $template = 'order-confirmation.tpl';
     }
     $this->context->smarty->assign('use_mobile', (bool) $this->paypal->useMobile());
     echo $this->paypal->fetchTemplate($template);
 }
Example #11
0
 public function init()
 {
     parent::init();
     if (Module::isEnabled('aimultidimensions')) {
         if (Tools::getIsset('add') && $this->context->cart->id) {
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php';
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'config.php';
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions' . $GLOBALS['aimd_config_suffix'] . '.php';
             $add = 1;
             $idProduct = (int) Tools::getValue('id_product', NULL);
             if (checkLink($idProduct)) {
                 $idProductAttribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
                 $customizationId = (int) Tools::getValue('id_customization', 0);
                 $qty = (int) abs(Tools::getValue('qty', 1));
                 if ($add && $qty >= 0 && getProducts($idProduct)) {
                     $quantity = (int) Db::getInstance()->getValue('SELECT quantity FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart = ' . $this->context->cart->id . ' AND id_product = ' . $idProduct . ' AND ' . 'id_product_attribute = ' . $idProductAttribute);
                     if (Tools::getValue('op', 'up') == 'up') {
                         $quantity += (int) $qty;
                     } else {
                         $quantity -= (int) $qty;
                     }
                     $cookie = $this->context->cookie;
                     $cart = $this->context->cart;
                     include_once 'modules/aimultidimensions/includes/cart.php';
                     Product::flushPriceCache();
                 }
             }
         }
     }
 }
 public function postProcess()
 {
     global $currentIndex;
     if (isset($_POST['submitLocalization' . $this->table])) {
         if ($this->tabAccess['edit'] === '1') {
             $this->_postConfig($this->_fieldsLocalization);
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitLocalizationPack')) {
         if (!($pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/' . Tools::getValue('iso_localization_pack') . '.xml')) and !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
             $this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
         } elseif (!($selection = Tools::getValue('selection'))) {
             $this->_errors[] = Tools::displayError('Please select at least one content item to import.');
         } else {
             foreach ($selection as $selected) {
                 if (!Validate::isLocalizationPackSelection($selected)) {
                     $this->_errors[] = Tools::displayError('Invalid selection');
                     return;
                 }
             }
             $localizationPack = new LocalizationPack();
             if (!$localizationPack->loadLocalisationPack($pack, $selection)) {
                 $this->_errors = array_merge($this->_errors, $localizationPack->getErrors());
             } else {
                 Tools::redirectAdmin($currentIndex . '&conf=23&token=' . $this->token);
             }
         }
     }
     parent::postProcess();
 }
 public function preProcess()
 {
     parent::preProcess();
     $this->id_cart = (int) Tools::getValue('id_cart', 0);
     /* check if the cart has been made by a Guest customer, for redirect link */
     if (Cart::isGuestCartByCartId($this->id_cart)) {
         $redirectLink = 'guest-tracking.php';
     } else {
         $redirectLink = 'history.php';
     }
     $this->id_module = (int) Tools::getValue('id_module', 0);
     $this->id_order = Order::getOrderByCartId((int) $this->id_cart);
     $this->secure_key = Tools::getValue('key', false);
     if (!$this->id_order or !$this->id_module or !$this->secure_key or empty($this->secure_key)) {
         Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '?slowvalidation' : ''));
     }
     $order = new Order((int) $this->id_order);
     if (!Validate::isLoadedObject($order) or $order->id_customer != self::$cookie->id_customer or $this->secure_key != $order->secure_key) {
         Tools::redirect($redirectLink);
     }
     $module = Module::getInstanceById((int) $this->id_module);
     if ($order->payment != $module->displayName) {
         Tools::redirect($redirectLink);
     }
 }
Example #14
0
 public function postProcess()
 {
     global $currentIndex, $cookie, $smarty;
     if (Tools::getValue('getReferrerData')) {
         $id_referrer = Tools::getValue('referrer');
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\n\t\t            select o.id_order, concat(c.firstname, ' ', c.lastname) as 'name', concat(a.`address1`, a.`address2`) as 'address', a.`phone_mobile`, o.`total_paid`, date(c.date_add) as 'date_register'\n                    from ps_orders o \n                    inner join ps_customer c on o.id_customer = c.id_customer\n                    inner join ps_address a on a.`id_address` = o.`id_address_delivery`\n                    where o.id_customer in (select id_customer from ps_customer where id_referrer = " . $id_referrer . ")\n\t\t            ");
         $smarty->assign('referredOrders', $res);
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\n\t\t            select id_customer, concat(firstname, ' ', lastname) as 'name', date(date_add) as 'date_add' from ps_customer where id_referrer = " . $id_referrer);
         $smarty->assign('referredCustomers', $res);
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\r\n\t\t            select concat(c.firstname, ' ', c.lastname) as 'name', count(*) as 'total_orders', sum(o.total_paid) as 'total_paid' from ps_orders o \n                    inner join `ps_order_history` oh on oh.id_order = o.id_order\n                    inner join ps_customer c on c.id_customer = o.id_customer\n                    where o.id_customer = " . $id_referrer . "\n                    and oh.id_order_history = (select max(id_order_history) from ps_order_history where id_order = o.id_order)\n                    and oh.id_order_state not in (6, 14, 20)\n\t\t            ");
         $smarty->assign('referrer_details', $res[0]);
         $smarty->assign('orderToken', Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
     }
     $date_from = Tools::getValue('date_from', date('Y-n-j'));
     $date_to = Tools::getValue('date_to', date('Y-n-j'));
     $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\n\t\t        select c.id_customer `customerID`, concat(c.firstname, ' ', c.lastname) as `name`, \n                count(distinct(c2.id_customer)) as 'total_registered',\n                count(o.id_order) as 'total_orders',\n                count(distinct(o.id_customer)) as 'total_friends_orders',\n                round(coalesce(avg(o.total_paid), 0)) as 'avg_order'\n                from ps_customer c\n                inner join ps_customer c2 on c.id_customer = c2.id_referrer\n                left join ps_orders o on o.id_customer = c2.id_customer\n\t\t        inner join `ps_order_history` oh on oh.id_order = o.id_order\n                where date(c2.`date_add`) between '" . $date_from . "' and '" . $date_to . "'\n\t\t        and  oh.id_order_history = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = o.`id_order` GROUP BY moh.`id_order`)\n\t\t\t\tand oh.id_order_state not in (6,8,20)\n                group by c.id_customer  \n\t\t        ");
     $friends_shopped = array();
     $avg_order = array();
     foreach ($res as $key => $row) {
         $friends_shopped[$key] = $row['total_friends_orders'];
         $avg_order[$key] = $row['avg_order'];
     }
     array_multisort($friends_shopped, SORT_DESC, $avg_order, SORT_ASC, $res);
     $smarty->assign('date_from', $date_from);
     $smarty->assign('date_to', $date_to);
     $smarty->assign('referrals', $res);
     $smarty->assign('token', $this->token);
     $smarty->assign('customerToken', Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee));
 }
 /**
  * Initialize order confirmation controller
  * @see FrontController::init()
  */
 public function init()
 {
     parent::init();
     $this->id_cart = (int) Tools::getValue('id_cart', 0);
     $is_guest = false;
     /* check if the cart has been made by a Guest customer, for redirect link */
     if (Cart::isGuestCartByCartId($this->id_cart)) {
         $is_guest = true;
         $redirectLink = 'index.php?controller=guest-tracking';
     } else {
         $redirectLink = 'index.php?controller=history';
     }
     $this->id_module = (int) Tools::getValue('id_module', 0);
     $this->id_order = Order::getOrderByCartId((int) $this->id_cart);
     $this->secure_key = Tools::getValue('key', false);
     $order = new Order((int) $this->id_order);
     if ($is_guest) {
         $customer = new Customer((int) $order->id_customer);
         $redirectLink .= '&id_order=' . $order->reference . '&email=' . urlencode($customer->email);
     }
     if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) {
         Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
     }
     $this->reference = $order->reference;
     if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) {
         Tools::redirect($redirectLink);
     }
     $module = Module::getInstanceById((int) $this->id_module);
     if ($order->payment != $module->displayName) {
         Tools::redirect($redirectLink);
     }
 }
Example #16
0
 public function renderForm($args, $data)
 {
     # validate module
     unset($args);
     $this->checkFolderImage();
     $helper = $this->getFormHelper();
     $items = '';
     $slide_edit = '';
     if ($data['params'] && isset($data['params']['leoslide']) && $data['params']['leoslide']) {
         $slides = $data['params']['leoslide'];
         $items = $this->getSlide($slides);
         if (Tools::getValue('id_slide')) {
             $id_slide = Tools::getValue('id_slide');
             $slide_edit = $items[$id_slide] ? $items[$id_slide] : '';
         }
     }
     $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Image Size Width'), 'name' => 'img_width', 'default' => 1170), array('type' => 'text', 'label' => $this->l('Image size Height'), 'name' => 'img_height', 'default' => 400), array('type' => 'text', 'label' => $this->l('Thumb Size Width'), 'name' => 'thumb_width', 'default' => 100), array('type' => 'text', 'label' => $this->l('Thumb size Height'), 'name' => 'thumb_height', 'default' => 100), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000)), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp')));
     if (Tools::getIsset('addleowidgets')) {
         $this->fields_form[1]['form']['input'][] = array('type' => 'html', 'name' => 'html', 'default' => '', 'html_content' => '<div class="alert alert-info">' . $this->l('Please Click save to input image') . '</div>');
     } else {
         $this->fields_form[1]['form']['input'][] = array('type' => 'slide', 'name' => 'slide', 'lang' => true, 'selectImg' => Context::getContext()->link->getAdminLink('AdminLeomanagewidgetsImages'), 'tree' => '', 'default' => '');
     }
     $theme_dir = Context::getContext()->shop->theme_directory;
     $images = array();
     $thums = array();
     $images = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/image');
     $thums = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum');
     $iso = Context::getContext()->language->iso_code;
     $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'iso' => file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en', 'path_css' => _THEME_CSS_DIR_, 'ad' => __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_), 'images' => $images, 'thums' => $thums, 'items' => $items, 'slide_edit' => $slide_edit, 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'pathimg' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/image/', 'paththum' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum/');
     return $helper->generateForm($this->fields_form);
 }
 public function renderForm($args, $data)
 {
     $options = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')));
     $orderby = array(array('order' => 'date_add', 'name' => $this->l('Date Add')), array('order' => 'date_upd', 'name' => $this->l('Date Update')), array('order' => 'name', 'name' => $this->l('Name')), array('order' => 'id_product', 'name' => $this->l('Product Id')), array('order' => 'price', 'name' => $this->l('Price')));
     $orderway = array(array('orderway' => 'ASC', 'name' => $this->l('Ascending')), array('orderway' => 'DESC', 'name' => $this->l('Descending')));
     $root = Category::getRootCategory();
     $categories = array();
     $helper = $this->getFormHelper();
     $items = '';
     $tab_edit = '';
     if ($data['params'] && isset($data['params']['leotab']) && $data['params']['leotab']) {
         $tabs = $data['params']['leotab'];
         $items = $this->getTabs($tabs);
         if (Tools::getValue('id_tab')) {
             $id_tab = Tools::getValue('id_tab');
             $tab_edit = $items[$id_tab] ? $items[$id_tab] : '';
             $categories = $items[$id_tab]['categories'] ? $items[$id_tab]['categories'] : array();
         }
     }
     $tree = new HelperTreeCategories('categories-tree', 'Categories');
     $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories);
     $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Number of Items In Page'), 'name' => 'itemspage', 'default' => 3, 'desc' => $this->l('The maximum number of products in each page tab (default: 3).')), array('type' => 'text', 'label' => $this->l('Number of Columns In Page'), 'name' => 'columns', 'default' => 3, 'desc' => $this->l('The maximum number of products in each page tab (default: 3).')), array('type' => 'text', 'label' => $this->l('Number of products displayed In Tab'), 'name' => 'itemstab', 'default' => 6, 'desc' => $this->l('The maximum number of products in each tab (default: 6).')), array('type' => 'select', 'label' => $this->l('Order By:'), 'desc' => $this->l('The maximum number of products in each page  (default: 3).'), 'name' => 'orderby', 'default' => 'date_add', 'options' => array('query' => $orderby, 'id' => 'order', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Order Way:'), 'desc' => $this->l('The maximum number of products in each page  (default: 3).'), 'name' => 'orderway', 'default' => 'date_add', 'options' => array('query' => $orderway, 'id' => 'orderway', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000, 'desc' => $this->l('Enter Time(miniseconds) to play carousel. Value 0 to stop.')), array('type' => 'setting_tab', 'name' => 'setting_tab', 'lang' => true, 'tree' => $tree->render(), 'default' => '')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp')));
     $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => (int) Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'text_title' => 'title_' . Context::getContext()->language->iso_code, 'path' => __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/img/icontab/', 'images' => LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . _THEME_NAME_ . '/img/icontab/'), 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'items' => $items, 'tab_edit' => $tab_edit);
     return $helper->generateForm($this->fields_form);
 }
Example #18
0
 /**
  * Change language
  */
 public function process()
 {
     if (Tools::getValue('language')) {
         $this->session->lang = Tools::getValue('language');
         $this->redirect('welcome');
     }
 }
Example #19
0
    public function display()
    {
        global $cookie, $currentIndex;
        echo '<div style="float:left;width:600px">';
        $this->getList((int) $cookie->id_lang, !Tools::getValue($this->table . 'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table . 'Orderway') ? 'DESC' : NULL);
        $this->displayList();
        echo '</div>';
        echo '
		<fieldset style="float:left;width:280px"><legend><img src="../img/admin/pdf.gif" alt="" /> ' . $this->l('Print PDF') . '</legend>
			<form action="' . $currentIndex . '&token=' . $this->token . '" method="post">
				<label style="width:90px">' . $this->l('From:') . ' </label>
				<div class="margin-form" style="padding-left:100px">
					<input type="text" size="4" maxlength="10" name="date_from" value="' . date('Y-m-01') . '" style="width: 120px;" />
					<p class="clear">' . $this->l('Format: 2007-12-31 (inclusive)') . '</p>
				</div>
				<label style="width:90px">' . $this->l('To:') . ' </label>
				<div class="margin-form" style="padding-left:100px">
					<input type="text" size="4" maxlength="10" name="date_to" value="' . date('Y-m-t') . '" style="width: 120px;" />
					<p class="clear">' . $this->l('Format: 2008-12-31 (inclusive)') . '</p>
				</div>
				<div class="margin-form" style="padding-left:100px">
					<input type="submit" value="' . $this->l('Generate PDF file') . '" name="submitPrint" class="button" />
				</div>
			</form>
		</fieldset><div class="clear">&nbsp;</div>';
    }
Example #20
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $shop_name = htmlentities(Configuration::get('PS_SHOP_NAME'), NULL, 'utf-8');
     $shop_url = Tools::getHttpHost(true, true);
     $customer = Context::getContext()->customer;
     if (!preg_match("#.*\\.html\$#Ui", Tools::getValue('mail')) or !preg_match("#.*\\.html\$#Ui", Tools::getValue('mail'))) {
         die(Tools::redirect());
     }
     $file = file_get_contents(dirname(__FILE__) . '/../../mails/' . strval(preg_replace('#\\.{2,}#', '.', Tools::getValue('mail'))));
     $file = str_replace('{shop_name}', $shop_name, $file);
     $file = str_replace('{shop_url}', $shop_url . __PS_BASE_URI__, $file);
     $file = str_replace('{shop_logo}', $shop_url . _PS_IMG_ . 'logo.jpg', $file);
     $file = str_replace('{firstname}', $customer->firstname, $file);
     $file = str_replace('{lastname}', $customer->lastname, $file);
     $file = str_replace('{email}', $customer->email, $file);
     $file = str_replace('{firstname_friend}', 'XXXXX', $file);
     $file = str_replace('{lastname_friend}', 'xxxxxx', $file);
     $file = str_replace('{link}', 'authentication.php?create_account=1', $file);
     $discount_type = (int) Configuration::get('REFERRAL_DISCOUNT_TYPE');
     if ($discount_type == 1) {
         $file = str_replace('{discount}', Discount::display((double) Configuration::get('REFERRAL_PERCENTAGE'), $discount_type, new Currency($this->context->currency->id)), $file);
     } else {
         $file = str_replace('{discount}', Discount::display((double) Configuration::get('REFERRAL_DISCOUNT_VALUE_' . $this->context->currency->id), $discount_type, new Currency($this->context->currency->id)), $file);
     }
     $this->context->smarty->assign(array('content' => $file));
     $this->setTemplate('email.tpl');
 }
Example #21
0
    public function hookAdminStatsModules($params)
    {
        $totalVisits = $this->getTotalVisits();
        $totalGuests = $this->getTotalGuests();
        if (Tools::getValue('export')) {
            $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => 3));
        }
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<p><center>
				<img src="../img/admin/down.gif" />' . $this->l('A visit corresponds to an internet user coming to your shop. Until the end of their session, only one visit is counted.') . '
				' . $this->l('A visitor is an unknown person, who has not registered or logged on, surfing on your shop. A visitor can come and visit your shop many times.') . '
			</center></p>
			<div style="margin-top:20px"></div>
			<p>' . $this->l('Total visits:') . ' ' . $totalVisits . '</p>
			<p>' . $this->l('Total visitors:') . ' ' . $totalGuests . '</p>
			' . ($totalVisits ? ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => 3)) . '<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>' : '') . '
			
		</fieldset>
		<br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
				<h2>' . $this->l('Determine the interest of a visit') . '</h2>
				' . $this->l('The visitors\' evolution graph strongly resembles the visits\' graph, but provides additional information:') . '<br />
				<ul>
					<li>' . $this->l('If this is the case, congratulations, your website is well planned and pleasing.') . '</li>
					<li>' . $this->l('Otherwise, the conclusion is not so simple. The problem can be aesthetic or ergonomic, or else the offer is not sufficient. It is also possible that these visitors mistakenly came here without particular interest for your shop; this phenomenon often happens with the search engines.') . '</li>
				</ul>
				' . $this->l('This information is mostly qualitative: you have to determine the interest of a disjointed visit.') . '<br />
		</fieldset>';
        return $this->_html;
    }
Example #22
0
    public function hookAdminStatsModules($params)
    {
        if (Tools::getValue('export')) {
            if (Tools::getValue('exportType') == 'browser') {
                $this->csvExport(array('type' => 'pie', 'option' => 'wb'));
            } else {
                if (Tools::getValue('exportType') == 'os') {
                    $this->csvExport(array('type' => 'pie', 'option' => 'os'));
                }
            }
        }
        $equipment = $this->getEquipment();
        $this->html = '
		<div class="panel-heading">' . $this->displayName . '
		</div>
		<h4>' . $this->l('Guide') . '</h4>
		<div class="alert alert-warning">
			<h4>' . $this->l('Making sure that your website is accessible to as many people as possible') . '</h4>
			<p>
			' . $this->l('When managing a website, it is important to keep track of the software used by visitors so as to be sure that the site displays the same way for everyone. PrestaShop was built to be compatible with the most recent Web browsers and computer operating systems (OS). However, because you may end up adding advanced features to your website or even modifying the core PrestaShop code, these additions may not be accessible to everyone. That is why it is a good idea to keep track of the percentage of users for each type of software before adding or changing something that only a limited number of users will be able to access.') . '
			</p>
		</div>
		<div class="row row-margin-bottom">
			<div class="col-lg-12">
				<div class="col-lg-8">
					' . $this->engine(array('type' => 'pie', 'option' => 'wb')) . '
				</div>
				<div class="col-lg-4">
					<p>' . $this->l('Indicates the percentage of each web browser used by customers.') . '</p>
					<hr/>
					<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI'] . '&export=1&exportType=browser') . '">
						<i class="icon-cloud-upload"></i>' . $this->l('CSV Export') . '
					</a>
				</div>
			</div>
		</div>
		<div class="row row-margin-bottom">
			<div class="col-lg-12">
				<div class="col-lg-8">
					' . $this->engine(array('type' => 'pie', 'option' => 'os')) . '
				</div>
				<div class="col-lg-4">
					<p>' . $this->l('Indicates the percentage of each operating system used by customers.') . '</p>
					<hr/>
					<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI'] . '&export=1&exportType=os') . '">
						<i class="icon-cloud-upload"></i>' . $this->l('CSV Export') . '
					</a>
				</div>
			</div>
		</div>';
        if ($equipment) {
            $this->html .= '<table class="table">
				<tr><th><span class="title_box  active">' . $this->l('Plugins') . '</th></span><th></th></tr>';
            foreach ($equipment as $name => $value) {
                $this->html .= '<tr><td>' . $name . '</td><td>' . number_format(100 * $value, 2) . '%</td></tr>';
            }
            $this->html .= '</table>';
        }
        return $this->html;
    }
Example #23
0
 public function renderForm($args, $data)
 {
     # validate module
     unset($args);
     $this->checkFolderImage();
     $helper = $this->getFormHelper();
     $items = '';
     $slide_edit = '';
     if ($data['params'] && isset($data['params']['leoslide']) && $data['params']['leoslide']) {
         $slides = $data['params']['leoslide'];
         $items = $this->getSlide($slides);
         if (Tools::getValue('id_slide')) {
             $id_slide = Tools::getValue('id_slide');
             $slide_edit = $items[$id_slide] ? $items[$id_slide] : '';
         }
     }
     $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Image Size Width'), 'name' => 'img_width', 'class' => 'fixed-width-xl', 'default' => 1170), array('type' => 'text', 'label' => $this->l('Image size Height'), 'name' => 'img_height', 'class' => 'fixed-width-xl', 'default' => 400), array('type' => 'text', 'label' => $this->l('Thumb Size Width'), 'name' => 'thumb_width', 'class' => 'fixed-width-xl', 'default' => 100), array('type' => 'text', 'label' => $this->l('Thumb size Height'), 'name' => 'thumb_height', 'class' => 'fixed-width-xl', 'default' => 100), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'class' => 'fixed-width-xl', 'default' => 400, 'desc' => $this->l('Enter Time(miniseconds) to play slide. Value 0 to stop.')), array('type' => 'text', 'label' => $this->l('Transition Speed'), 'name' => 'transitionSpeed', 'class' => 'fixed-width-xl', 'default' => 900, 'desc' => $this->l('Enter Time(miniseconds) to next each slide.')), array('type' => 'select', 'label' => $this->l('Display Progress Bar'), 'name' => 'displayProgressBar', 'default' => '1', 'options' => array('query' => array(array('id' => 1, 'name' => $this->l('Enable')), array('id' => 0, 'name' => $this->l('Disable'))), 'id' => 'id', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Display Thumbnail Numbers'), 'name' => 'displayThumbnailNumbers', 'default' => '1', 'options' => array('query' => array(array('id' => 1, 'name' => $this->l('Enable')), array('id' => 0, 'name' => $this->l('Disable'))), 'id' => 'id', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Display Thumbnail Background'), 'name' => 'displayThumbnailBackground', 'default' => '1', 'options' => array('query' => array(array('id' => 1, 'name' => $this->l('Enable')), array('id' => 0, 'name' => $this->l('Disable'))), 'id' => 'id', 'name' => 'name')), array('type' => 'slide', 'name' => 'slide', 'lang' => true, 'selectImg' => Context::getContext()->link->getAdminLink('AdminLeotempcpImages'), 'tree' => '', 'default' => '')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp')));
     $theme_dir = Context::getContext()->shop->theme_directory;
     $images = array();
     $thums = array();
     $images = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/image');
     $thums = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum');
     $iso = Context::getContext()->language->iso_code;
     $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'iso' => file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en', 'path_css' => _THEME_CSS_DIR_, 'ad' => __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_), 'images' => $images, 'thums' => $thums, 'items' => $items, 'slide_edit' => $slide_edit, 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'pathimg' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/image/', 'paththum' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum/');
     return $helper->generateForm($this->fields_form);
 }
Example #24
0
 public function renderForm($args, $data)
 {
     # validate module
     unset($args);
     $this->checkFolderImage();
     $helper = $this->getFormHelper();
     $items = '';
     $slide_edit = '';
     if ($data['params'] && isset($data['params']['leoslide']) && $data['params']['leoslide']) {
         $slides = $data['params']['leoslide'];
         $items = $this->getSlide($slides);
         if (Tools::getValue('id_slide')) {
             $id_slide = Tools::getValue('id_slide');
             $slide_edit = $items[$id_slide] ? $items[$id_slide] : '';
         }
     }
     $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form')), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp')));
     $theme_dir = Context::getContext()->shop->theme_directory;
     $images = array();
     $thums = array();
     $images = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/image');
     $thums = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum');
     $iso = Context::getContext()->language->iso_code;
     $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'iso' => file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en', 'path_css' => _THEME_CSS_DIR_, 'ad' => __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_), 'images' => $images, 'thums' => $thums, 'items' => $items, 'slide_edit' => $slide_edit, 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'pathimg' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/image/', 'paththum' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum/');
     return $helper->generateForm($this->fields_form);
 }
Example #25
0
 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nb_products = (int) ProductSale::getNbSales();
         $this->pagination($nb_products);
         if (!Tools::getValue('orderby')) {
             $this->orderBy = 'sales';
         }
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
         $this->addColorsToProductList($products);
         /************************* /Images Array ******************************/
         if (method_exists('Product', 'getProductsImgs')) {
             $image_array = array();
             for ($i = 0; $i < $nb_products; $i++) {
                 if (isset($products[$i]['id_product'])) {
                     $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
                 }
             }
             $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
         }
         /************************* /Images Array ******************************/
         $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
    public function hookAdminStatsModules($params)
    {
        if (Module::isInstalled('blocknewsletter')) {
            $totals = $this->getTotals();
            if (Tools::getValue('export')) {
                $this->csvExport(array('type' => 'line', 'layers' => 3));
            }
            $this->_html = '
			<div class="panel-heading">
				' . $this->displayName . '
			</div>
			<div class="row row-margin-bottom">
				<div class="col-lg-12">
					<div class="col-lg-8">
						' . $this->engine(array('type' => 'line', 'layers' => 3)) . '
					</div>
					<div class="col-lg-4">
						<ul class="list-unstyled">
							<li>' . $this->l('Customer registrations:') . ' ' . (int) $totals['customers'] . '</li>
							<li>' . $this->l('Visitor registrations: ') . ' ' . (int) $totals['visitors'] . '</li>
							<li>' . $this->l('Both:') . ' ' . (int) $totals['both'] . '</li>
						</ul>
						<hr/>
						<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI'] . '&export=1') . '">
							<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
						</a>
					</div>
				</div>
			</div>';
        } else {
            $this->_html = '<p>' . $this->l('The "Newsletter block" module must be installed.') . '</p>';
        }
        return $this->_html;
    }
 public function __construct()
 {
     $this->bootstrap = true;
     $this->className = 'Configuration';
     $this->table = 'configuration';
     parent::__construct();
     // Prevent classes which extend AdminPreferences to load useless data
     if (get_class($this) == 'AdminPreferencesController') {
         $round_mode = array(array('value' => PS_ROUND_HALF_UP, 'name' => $this->trans('Round up away from zero, when it is half way there (recommended)', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_HALF_DOWN, 'name' => $this->trans('Round down towards zero, when it is half way there', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_HALF_EVEN, 'name' => $this->trans('Round towards the next even value', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_HALF_ODD, 'name' => $this->trans('Round towards the next odd value', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_UP, 'name' => $this->trans('Round up to the nearest value', array(), 'Admin.ShopParameters.Feature')), array('value' => PS_ROUND_DOWN, 'name' => $this->trans('Round down to the nearest value', array(), 'Admin.ShopParameters.Feature')));
         $activities1 = array(0 => $this->trans('-- Please choose your main activity --', array(), 'Install'), 2 => $this->trans('Animals and Pets', array(), 'Install'), 3 => $this->trans('Art and Culture', array(), 'Install'), 4 => $this->trans('Babies', array(), 'Install'), 5 => $this->trans('Beauty and Personal Care', array(), 'Install'), 6 => $this->trans('Cars', array(), 'Install'), 7 => $this->trans('Computer Hardware and Software', array(), 'Install'), 8 => $this->trans('Download', array(), 'Install'), 9 => $this->trans('Fashion and accessories', array(), 'Install'), 10 => $this->trans('Flowers, Gifts and Crafts', array(), 'Install'), 11 => $this->trans('Food and beverage', array(), 'Install'), 12 => $this->trans('HiFi, Photo and Video', array(), 'Install'), 13 => $this->trans('Home and Garden', array(), 'Install'), 14 => $this->trans('Home Appliances', array(), 'Install'), 15 => $this->trans('Jewelry', array(), 'Install'), 1 => $this->trans('Lingerie and Adult', array(), 'Install'), 16 => $this->trans('Mobile and Telecom', array(), 'Install'), 17 => $this->trans('Services', array(), 'Install'), 18 => $this->trans('Shoes and accessories', array(), 'Install'), 19 => $this->trans('Sport and Entertainment', array(), 'Install'), 20 => $this->trans('Travel', array(), 'Install'));
         $activities2 = array();
         foreach ($activities1 as $value => $name) {
             $activities2[] = array('value' => $value, 'name' => $name);
         }
         $fields = array('PS_SSL_ENABLED' => array('title' => $this->trans('Enable SSL', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('If you own an SSL certificate for your shop\'s domain name, you can activate SSL encryption (https://) for customer account identification and order processing.', array(), 'Admin.ShopParameters.Help'), 'hint' => $this->trans('If you want to enable SSL on all the pages of your shop, activate the "Enable on all the pages" option below.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'));
         $fields['PS_SSL_ENABLED_EVERYWHERE'] = array('title' => $this->trans('Enable SSL on all pages', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('When enabled, all the pages of your shop will be SSL-secured.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0', 'disabled' => Tools::getValue('PS_SSL_ENABLED', Configuration::get('PS_SSL_ENABLED')) ? false : true);
         $fields = array_merge($fields, array('PS_TOKEN_ENABLE' => array('title' => $this->trans('Increase front office security', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Enable or disable token in the Front Office to improve PrestaShop\'s security.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0', 'visibility' => Shop::CONTEXT_ALL), 'PS_ALLOW_HTML_IFRAME' => array('title' => $this->trans('Allow iframes on HTML fields', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Allow iframes on text fields like product description. We recommend that you leave this option disabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_USE_HTMLPURIFIER' => array('title' => $this->trans('Use HTMLPurifier Library', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Clean the HTML content on text fields. We recommend that you leave this option enabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_PRICE_ROUND_MODE' => array('title' => $this->trans('Round mode', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('You can choose among 6 different ways of rounding prices. "Round up away from zero ..." is the recommended behavior.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $round_mode, 'identifier' => 'value'), 'PS_ROUND_TYPE' => array('title' => $this->trans('Round type', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('You can choose when to round prices: either on each item, each line or the total (of an invoice, for example).', array(), 'Admin.ShopParameters.Help'), 'cast' => 'intval', 'type' => 'select', 'list' => array(array('name' => $this->trans('Round on each item', array(), 'Admin.ShopParameters.Feature'), 'id' => Order::ROUND_ITEM), array('name' => $this->trans('Round on each line', array(), 'Admin.ShopParameters.Feature'), 'id' => Order::ROUND_LINE), array('name' => $this->trans('Round on the total', array(), 'Admin.ShopParameters.Feature'), 'id' => Order::ROUND_TOTAL)), 'identifier' => 'id'), 'PS_PRICE_DISPLAY_PRECISION' => array('title' => $this->trans('Number of decimals', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Choose how many decimals you want to display', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'class' => 'fixed-width-xxl'), 'PS_DISPLAY_SUPPLIERS' => array('title' => $this->trans('Display brands and suppliers', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Enable brands and suppliers pages on your front office even when their respective modules are disabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_DISPLAY_BEST_SELLERS' => array('title' => $this->trans('Display best sellers', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('Enable best sellers page on your front office even when its respective module is disabled.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_MULTISHOP_FEATURE_ACTIVE' => array('title' => $this->trans('Enable Multistore', array(), 'Admin.ShopParameters.Feature'), 'desc' => $this->trans('The multistore feature allows you to manage several e-shops with one Back Office. If this feature is enabled, a "Multistore" page will be available in the "Advanced Parameters" menu.', array(), 'Admin.ShopParameters.Help'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL), 'PS_SHOP_ACTIVITY' => array('title' => $this->trans('Main Shop Activity', array(), 'Admin.ShopParameters.Feature'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $activities2, 'identifier' => 'value')));
         // No HTTPS activation if you haven't already.
         if (!Tools::usingSecureMode() && !Configuration::get('PS_SSL_ENABLED')) {
             $fields['PS_SSL_ENABLED']['type'] = 'disabled';
             $fields['PS_SSL_ENABLED']['disabled'] = '<a class="btn btn-link" href="https://' . Tools::getShopDomainSsl() . Tools::safeOutput($_SERVER['REQUEST_URI']) . '">' . $this->trans('Please click here to check if your shop supports HTTPS.', array(), 'Admin.ShopParameters.Feature') . '</a>';
         }
         $this->fields_options = array('general' => array('title' => $this->trans('General', array(), 'Admin.Global'), 'icon' => 'icon-cogs', 'fields' => $fields, 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))));
     }
 }
Example #28
0
    public function getContent()
    {
        $this->_html = '';
        if (Tools::isSubmit('submitCross') and Tools::getValue('displayPrice') != 0 and Tools::getValue('displayPrice') != 1) {
            $this->_html .= $this->displayError('Invalid displayPrice');
        } elseif (Tools::isSubmit('submitCross')) {
            Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int) Tools::getValue('displayPrice'));
            $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully'));
        }
        $this->_html .= '
		<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post">
		<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend>
			<label>' . $this->l('Display price on products') . '</label>
			<div class="margin-form">
				<input type="radio" name="displayPrice" id="display_on" value="1" ' . (Configuration::get('CROSSSELLING_DISPLAY_PRICE') ? 'checked="checked" ' : '') . '/>
				<label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
				<input type="radio" name="displayPrice" id="display_off" value="0" ' . (!Configuration::get('CROSSSELLING_DISPLAY_PRICE') ? 'checked="checked" ' : '') . '/>
				<label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
				<p class="clear">' . $this->l('Show the price on the products in the block.') . '</p>
			</div>
			<center><input type="submit" name="submitCross" value="' . $this->l('Save') . '" class="button" /></center>
		</fieldset>
		</form>';
        return $this->_html;
    }
Example #29
0
 public function postProcess()
 {
     if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'cashondelivery') {
             $authorized = true;
             break;
         }
     }
     //		if (!$authorized)
     //			die(Tools::displayError('This payment method is not available.'));
     $customer = new Customer($this->context->cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     if (Tools::getValue('confirm')) {
         $customer = new Customer((int) $this->context->cart->id_customer);
         $total = $this->context->cart->getOrderTotal(true, Cart::BOTH);
         $this->module->validateOrder((int) $this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
         Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $this->context->cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder);
     }
 }
Example #30
0
 function hookHeader($params)
 {
     global $smarty, $cookie;
     $id_category = intval(Tools::getValue('id_category'));
     if (!$id_category) {
         if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
             if (isset($regs[2]) and is_numeric($regs[2])) {
                 $id_category = intval($regs[2]);
             } elseif (isset($regs[5]) and is_numeric($regs[5])) {
                 $id_category = intval($regs[5]);
             }
         } elseif ($id_product = intval(Tools::getValue('id_product'))) {
             $product = new Product($id_product);
             $id_category = $product->id_category_default;
         }
     }
     $category = new Category($id_category);
     $orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');
     $orderWayValues = array(0 => 'ASC', 1 => 'DESC');
     $orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[intval(Configuration::get('PS_PRODUCTS_ORDER_BY'))]));
     $orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[intval(Configuration::get('PS_PRODUCTS_ORDER_WAY'))]));
     if (!in_array($orderBy, $orderByValues)) {
         $orderBy = $orderByValues[0];
     }
     if (!in_array($orderWay, $orderWayValues)) {
         $orderWay = $orderWayValues[0];
     }
     $smarty->assign(array('feedUrl' => 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/rss.php?id_category=' . $id_category . '&amp;orderby=' . $orderBy . '&amp;orderway=' . $orderWay));
     return $this->display(__FILE__, 'feederHeader.tpl');
 }