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();
    }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $this->fields_form = array('legend' => array('title' => $this->trans('Catalog price rules', array(), 'Admin.Catalog.Feature'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->trans('Name', array(), 'Admin.Global'), 'name' => 'name', 'maxlength' => 255, 'required' => true), array('type' => 'select', 'label' => $this->trans('Shop', array(), 'Admin.Global'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->trans('Currency', array(), 'Admin.Global'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->trans('All currencies', array(), 'Admin.Global'))), Currency::getCurrencies(false, true, true)), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Country', array(), 'Admin.Global'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->trans('All countries', array(), 'Admin.Global'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Group', array(), 'Admin.Global'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->trans('All groups', array(), 'Admin.Global'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->trans('From quantity', array(), 'Admin.Catalog.Feature'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->trans('Price (tax excl.)', array(), 'Admin.Catalog.Feature'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->trans('Leave initial price', array(), 'Admin.Catalog.Feature'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->trans('From', array(), 'Admin.Global'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->trans('To', array(), 'Admin.Global'), 'name' => 'to'), array('type' => 'select', 'label' => $this->trans('Reduction type', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->trans('Amount', array(), 'Admin.Global')), array('reduction_type' => 'percentage', 'name' => $this->trans('Percentage', array(), 'Admin.Global'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Reduction with or without taxes', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->trans('Tax included', array(), 'Admin.Global'), 'val' => 1), array('lab' => $this->trans('Tax excluded', array(), 'Admin.Global'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->trans('Reduction', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions')));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 6);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1, 'shop_id' => ($value = $this->getFieldValue($this->object, 'id_shop')) ? $value : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $shops = Shop::getShops();
     if (count($this->context->employee->getAssociatedShops()) > 1) {
         $shops = array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), $shops);
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Specific price rules')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'options' => array('query' => $shops, 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency:'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group:'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity:'), 'name' => 'from_quantity', 'size' => 6, 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.):'), 'name' => 'price', 'size' => 6, 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'date', 'label' => $this->l('From:'), 'name' => 'from', 'size' => 12), array('type' => 'date', 'label' => $this->l('To:'), 'name' => 'to', 'size' => 12), array('type' => 'select', 'label' => $this->l('Reduction type:'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Reduction:'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 2);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 2), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
Example #4
0
 /**
  * Render shop list
  *
  * @return string
  */
 public function getRenderedShopList()
 {
     if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) {
         return '';
     }
     $shop_context = Shop::getContext();
     $context = Context::getContext();
     $tree = Shop::getTree();
     if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) {
         $current_shop_value = '';
         $current_shop_name = Translate::getAdminTranslation('All shops');
     } elseif ($shop_context == Shop::CONTEXT_GROUP) {
         $current_shop_value = 'g-' . Shop::getContextShopGroupID();
         $current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']);
     } else {
         $current_shop_value = 's-' . Shop::getContextShopID();
         foreach ($tree as $group_id => $group_data) {
             foreach ($group_data['shops'] as $shop_id => $shop_data) {
                 if ($shop_id == Shop::getContextShopID()) {
                     $current_shop_name = $shop_data['name'];
                     break;
                 }
             }
         }
     }
     $tpl = $this->createTemplate('helpers/shops_list/list.tpl');
     $tpl->assign(array('tree' => $tree, 'current_shop_name' => $current_shop_name, 'current_shop_value' => $current_shop_value, 'multishop_context' => $context->controller->multishop_context, 'multishop_context_group' => $context->controller->multishop_context_group, 'is_shop_context' => $context->controller->multishop_context & Shop::CONTEXT_SHOP, 'is_group_context' => $context->controller->multishop_context & Shop::CONTEXT_GROUP, 'shop_context' => $shop_context, 'url' => $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext='));
     return $tpl->fetch();
 }
Example #5
0
 public function init()
 {
     if ($cms_rewrite = Tools::getValue('cms_rewrite')) {
         $sql = 'SELECT l.`id_cms`
             FROM `' . _DB_PREFIX_ . 'cms_lang` l
             LEFT JOIN `' . _DB_PREFIX_ . 'cms_shop` s ON (l.`id_cms` = s.`id_cms`)
             WHERE l.`link_rewrite` = \'' . pSQL(str_replace('.html', '', $cms_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms > 0) {
             $_GET['id_cms'] = $id_cms;
         }
     } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) {
         $sql = 'SELECT `id_cms_category`
             FROM `' . _DB_PREFIX_ . 'cms_category_lang`
             WHERE `link_rewrite` = \'' . pSQL($cms_category_rewrite) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms_category > 0) {
             $_GET['id_cms_category'] = $id_cms_category;
         }
     }
     parent::init();
 }
    public static function updateNewMessages($id_shop = null)
    {
        $context = Context::getContext();
        if ($id_shop == null && Shop::getContext() == Shop::CONTEXT_SHOP) {
            $id_shop = Shop::getContextShopID();
        }
        if ($id_shop > 0) {
            if (($mf_employee = Db::getInstance()->getRow('SELECT id_employee, id_last_new_message, id_first_new_message FROM `' . _DB_PREFIX_ . 'mf_employee` WHERE `id_shop`=' . (int) $id_shop . ' AND `id_employee` = ' . (int) $context->employee->id)) != false) {
                $id_last_new_message = Db::getInstance()->getValue('SELECT IFNULL(MAX(`' . self::$definition['primary'] . '`), 0)
						FROM `' . _DB_PREFIX_ . self::$definition['table'] . '` WHERE `id_shop`=' . (int) $id_shop);
                if ($id_last_new_message > $mf_employee['id_last_new_message']) {
                    $id_first_new_message = $mf_employee['id_last_new_message'];
                } else {
                    $id_first_new_message = $mf_employee['id_first_new_message'];
                }
                return Db::getInstance()->execute('
					UPDATE `' . _DB_PREFIX_ . 'mf_employee`
					SET `id_last_new_message` = ' . (int) $id_last_new_message . ',
					`id_first_new_message`=' . (int) $id_first_new_message . '
					WHERE `id_shop`=' . (int) $id_shop . ' AND `id_employee` = ' . (int) $context->employee->id);
            } else {
                return Db::getInstance()->execute('
					INSERT INTO `' . _DB_PREFIX_ . 'mf_employee`
					(`id_last_new_message`, `id_first_new_message`, `id_employee`, `id_shop`) VALUES ((
						SELECT IFNULL(MAX(`' . self::$definition['primary'] . '`), 0)
						FROM `' . _DB_PREFIX_ . self::$definition['table'] . '`
					), 0, ' . (int) $context->employee->id . ', ' . (int) $id_shop . ')');
            }
        }
    }
Example #7
0
 public function getContent()
 {
     $output = '<p class="info">' . $this->l('On some versions you could have to disable Cache, save, open your shop home page, than go back and enable it:') . '<br><br>' . sprintf('%s -> %s -> %s', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')) . '<br>' . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')) . '<br>' . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')) . '<br>' . '</p>';
     $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'product_lang`
         WHERE `link_rewrite`
         IN (SELECT `link_rewrite` FROM `' . _DB_PREFIX_ . 'product_lang`
         GROUP BY `link_rewrite`, `id_lang`
         HAVING count(`link_rewrite`) > 1)';
     if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
         $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
     }
     if ($res = Db::getInstance()->ExecuteS($sql)) {
         $err = $this->l('You need to fix duplicate URL entries:') . '<br>';
         foreach ($res as $row) {
             $lang = $this->context->language->getLanguage($row['id_lang']);
             $err .= $row['name'] . ' (' . $row['id_product'] . ') - ' . $row['link_rewrite'] . '<br>';
             $shop = $this->context->shop->getShop($lang['id_shop']);
             $err .= $this->l('Language: ') . $lang['name'] . '<br>' . $this->l('Shop: ') . $shop['name'] . '<br><br>';
         }
         $output .= $this->displayWarning($err);
     } else {
         $output .= $this->displayConfirmation($this->l('Nice. You have no duplicate URL entry.'));
     }
     return '<div class="panel">' . $output . '</div>';
 }
 public function init()
 {
     if ($product_rewrite = Tools::getValue('product_rewrite')) {
         $url_id_pattern = '/.*?([0-9]+)\\-([a-zA-Z0-9-]*)(\\.html)?/';
         $lang_id = (int) Context::getContext()->language->id;
         $sql = 'SELECT `id_product`
             FROM `' . _DB_PREFIX_ . 'product_lang`
             WHERE `link_rewrite` = \'' . pSQL(str_replace('.html', '', $product_rewrite)) . '\' AND `id_lang` = ' . $lang_id;
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_product > 0) {
             $_GET['id_product'] = $id_product;
         } elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) {
             $sql = 'SELECT `id_product`
                 FROM `' . _DB_PREFIX_ . 'product_lang`
                 WHERE `id_product` = \'' . pSQL($url_parts[1]) . '\' AND `id_lang` = ' . $lang_id;
             if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                 $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
             }
             $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
             if ($id_product > 0) {
                 $_GET['id_product'] = $id_product;
             }
         }
     }
     parent::init();
 }
    public function getContent()
    {
        $output = '';
        $output .= '<div style="display:block;" class="hint">
				On some versions you have to disable Cache save than open your shop home page than go back and enable it.<br/>
				Advanced Parameters > Performance > Clear Smarty cache<br /><br/>
				Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save<br />
				Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save<br />
			</div><br />';
        $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'product_lang`
				WHERE `link_rewrite`
					IN (SELECT `link_rewrite` FROM `' . _DB_PREFIX_ . 'product_lang`
					GROUP BY `link_rewrite`, `id_lang`
					HAVING count(`link_rewrite`) > 1)';
        if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
            $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
        }
        if ($results = Db::getInstance()->ExecuteS($sql)) {
            $output .= 'You need to fix duplicate URL entries<br/>';
            foreach ($results as $row) {
                $language_info = $this->context->language->getLanguage($row['id_lang']);
                $output .= $row['name'] . ' (' . $row['id_product'] . ') - ' . $row['link_rewrite'] . '<br/>';
                $shop_info = $this->context->shop->getShop($language_info['id_shop']);
                $output .= 'Language:' . $language_info['name'] . '<br /> Shop:' . $shop_info['name'] . '<br/><br/>';
            }
        } else {
            $output .= 'Nice you don\'t have any duplicate URL entries.';
        }
        return $output;
    }
 /**
  * Returns the invoice logo
  *
  * @return String Logo path
  */
 protected function getLogo()
 {
     $logo = '';
     if (Configuration::get('PS_LOGO_INVOICE', null, null, (int) Shop::getContextShopID()) != false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_INVOICE', null, null, (int) Shop::getContextShopID()))) {
         $logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO_INVOICE', null, null, (int) Shop::getContextShopID());
     } elseif (Configuration::get('PS_LOGO', null, null, (int) Shop::getContextShopID()) != false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, (int) Shop::getContextShopID()))) {
         $logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, (int) Shop::getContextShopID());
     }
     return $logo;
 }
Example #11
0
 public function __construct()
 {
     // Get current id_shop context
     $this->context_id_shop_prev = Shop::getContextShopID();
     // Set id_shop context to 'CONTEXT_ALL'
     //		$this->setContext();
     $this->name = 'mobassistantconnector';
     $this->tab = 'mobile';
     $this->version = '1.2.13';
     $this->author = 'eMagicOne';
     $this->module_key = 'c0b8b5438c3e54ae5f47df2d8da43907';
     $this->need_instance = 0;
     $this->is_configurable = 1;
     $this->bootstrap = true;
     $this->cart_version = Configuration::get('PS_INSTALL_VERSION');
     $this->def_shop = Configuration::get('PS_SHOP_DEFAULT');
     // Initialize logger
     $this->file_logger = new FileLoggerMob();
     $this->file_logger->setFilename(_PS_MODULE_DIR_ . $this->name . '/log/' . self::LOG_FILENAME);
     if (version_compare($this->cart_version, '1.6.0.4', '=')) {
         $this->ps_versions_compliancy = array('min' => '1.5.1', 'max' => '1.7');
     } else {
         $this->ps_versions_compliancy = array('min' => '1.5.1', 'max' => '1.6');
     }
     parent::__construct();
     $this->displayName = $this->l('Mobile Assistant Connector');
     $this->description = $this->l("Feel stressed leaving your Prestashop store off-hand during your vacation, meetings or conferences?\n\t\t\tAre you carrying laptop everywhere you go, repeatedly searching the answer for bothering question in your mind - 'What’s going on at my store?'\n\t\t\tWith Prestashop Mobile Assistant on you can be on the move and have access to the real-time store data reports at your fingertips.\n\t\t\tUsing it you can monitor key details on your products, customers and orders from your Android device wherever you are.");
     $this->database_version_cur = $this->getDatabaseVersion();
     if ($this->database_version_cur) {
         // Update module version in database
         if (version_compare($this->database_version_cur, $this->version, '<')) {
             self::upgradeModuleVersion($this->name, $this->version);
             $this->_generateConfigXml();
         }
         if (version_compare($this->database_version_cur, '1.2.0', '=')) {
             $this->dropOldTables();
         }
         // Create additional tables
         if (version_compare($this->database_version_cur, '1.2.1', '<')) {
             $this->createTables();
             $this->movePushDevices();
         }
         if (version_compare($this->database_version_cur, '1.2.0', '>') && version_compare($this->database_version_cur, '1.2.5', '<')) {
             $this->changeTableDevices();
         }
     }
     $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
     if (!Configuration::get('MOBASSISTANTCONNECTOR')) {
         $this->warning = $this->l('No name provided');
     }
 }
 public function init()
 {
     if ($category_rewrite = Tools::getValue('category_rewrite')) {
         $sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang`
             WHERE `link_rewrite` = \'' . pSQL(str_replace('.html', '', $category_rewrite)) . '\' AND `id_lang` = ' . Context::getContext()->language->id;
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_category > 0) {
             $_GET['id_category'] = $id_category;
         }
     }
     parent::init();
 }
    public function init()
    {
        if (Tools::getValue('category_rewrite')) {
            // SQL safe?
            $category_rewrite = Tools::getValue('category_rewrite');
            $sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang`
					WHERE `link_rewrite` = \'' . $category_rewrite . '\' AND `id_lang` = ' . Context::getContext()->language->id;
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
            }
            $categorys_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
            $categorys_count = count($categorys_list);
            if ($categorys_count == 1) {
                // Found ONLY one so dont need to look for parent
                $id_category = (int) $categorys_list[0]['id_category'];
                $_GET['noredirect'] = TRUE;
            } else {
                if ($categorys_count > 1) {
                    // Found more than one so look for parent
                    // SQL safe?
                    $parent_rewrite = Tools::getValue('categories_rewrite');
                    $shop_id = (int) Shop::getContextShopID();
                    $sql = 'SELECT c.`id_category`
						FROM `ps_category` c
						LEFT JOIN `ps_category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.id_shop = ' . $shop_id . ' )
							INNER JOIN ps_category_shop category_shop ON (category_shop.id_category = c.id_category AND category_shop.id_shop = ' . $shop_id . ')
						LEFT JOIN `ps_category_lang` clp ON (c.`id_parent` = clp.`id_category`)
						WHERE cl.`link_rewrite` = \'' . $category_rewrite . '\'
							AND clp.`link_rewrite` = \'' . $parent_rewrite . '\'
							AND cl.`id_lang` = ' . Context::getContext()->language->id;
                    $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                    $_GET['noredirect'] = TRUE;
                } else {
                    // none found
                    $id_category = 0;
                }
            }
            if ($id_category > 0) {
                $_GET['id_category'] = $id_category;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        }
        parent::init();
    }
 public function init()
 {
     if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) {
         $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 \'' . pSQL(str_replace('-', '%', $supplier_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_supplier > 0) {
             $_GET['id_supplier'] = $id_supplier;
         }
     }
     parent::init();
 }
    public function init()
    {
        if ($manufacturer_rewrite = Tools::getValue('manufacturer_rewrite')) {
            $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite);
            $sql = 'SELECT m.`id_manufacturer`
				FROM `' . _DB_PREFIX_ . 'manufacturer` m
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`)
				WHERE m.`name` LIKE \'' . pSQL($manufacturer_rewrite) . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_manufacturer = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_manufacturer > 0) {
                $_GET['id_manufacturer'] = $id_manufacturer;
                $_GET['noredirect'] = 1;
            }
        }
        parent::init();
    }
Example #16
0
 public function getCurrentShopName()
 {
     $shop_context = Shop::getContext();
     $tree = Shop::getTree();
     if ($this->noShopSelection()) {
         $current_shop_name = Translate::getAdminTranslation('All shops');
     } elseif ($shop_context == Shop::CONTEXT_GROUP) {
         $current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']);
     } else {
         foreach ($tree as $group_id => $group_data) {
             foreach ($group_data['shops'] as $shop_id => $shop_data) {
                 if ($shop_id == Shop::getContextShopID()) {
                     $current_shop_name = $shop_data['name'];
                     break;
                 }
             }
         }
     }
     return $current_shop_name;
 }
    public function init()
    {
        if (Tools::getValue('product_rewrite')) {
            //$url_id_pattern = '/[a-zA-Z0-9-]*\/([0-9]+)\-([a-zA-Z0-9-]*)\.html/';
            $url_id_pattern = '/.*?([0-9]+)\\-([a-zA-Z0-9-]*)\\.html/';
            $rewrite_url = Tools::getValue('product_rewrite');
            $sql = 'SELECT `id_product`
				FROM `' . _DB_PREFIX_ . 'product_lang`
				WHERE `link_rewrite` = \'' . $rewrite_url . '\' AND `id_lang` = ' . Context::getContext()->language->id;
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_product > 0) {
                $_GET['id_product'] = $id_product;
            } else {
                if (preg_match($url_id_pattern, $_SERVER['REQUEST_URI'], $url_split)) {
                    $url_id_product = $url_split[1];
                    $sql = 'SELECT `id_product`
					FROM `' . _DB_PREFIX_ . 'product_lang`
					WHERE `id_product` = \'' . $url_id_product . '\' AND `id_lang` = ' . Context::getContext()->language->id;
                    if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                        $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
                    }
                    $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                    if ($id_product > 0) {
                        $_GET['id_product'] = $id_product;
                    } else {
                        //TODO: Do we need to send 404?
                        header('HTTP/1.1 404 Not Found');
                        header('Status: 404 Not Found');
                    }
                } else {
                    //TODO: Do we need to send 404?
                    header('HTTP/1.1 404 Not Found');
                    header('Status: 404 Not Found');
                }
            }
        }
        parent::init();
    }
    public function init()
    {
        if (Tools::getValue('cms_rewrite')) {
            $rewrite_url = Tools::getValue('cms_rewrite');
            $sql = 'SELECT l.`id_cms`
				FROM `' . _DB_PREFIX_ . 'cms_lang` l
				LEFT JOIN `' . _DB_PREFIX_ . 'cms_shop` s ON (l.`id_cms` = s.`id_cms`)
				WHERE l.`link_rewrite` = \'' . $rewrite_url . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_cms > 0) {
                $_GET['id_cms'] = $id_cms;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        } else {
            if (Tools::getValue('cms_category_rewrite')) {
                $rewrite_url = Tools::getValue('cms_category_rewrite');
                $sql = 'SELECT `id_cms_category`
				FROM `' . _DB_PREFIX_ . 'cms_category_lang`
				WHERE `link_rewrite` = \'' . $rewrite_url . '\'';
                if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                    $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
                }
                $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                if ($id_cms_category > 0) {
                    $_GET['id_cms_category'] = $id_cms_category;
                } else {
                    //TODO: Do we need to send 404?
                    header('HTTP/1.1 404 Not Found');
                    header('Status: 404 Not Found');
                }
            }
        }
        parent::init();
    }
Example #19
0
 public static function _getIdShop($default_if_null = true)
 {
     $id_shop = version_compare(_PS_VERSION_, '1.5', '>') ? Shop::getContextShopID() : Shop::getCurrentShop();
     if (!$id_shop && $default_if_null) {
         if (Configuration::get('PS_SHOP_DEFAULT')) {
             $id_shop = Configuration::get('PS_SHOP_DEFAULT');
         } else {
             $id_shop = 1;
         }
     }
     return $id_shop;
 }
Example #20
0
 public function getAddLinkFieldsValues()
 {
     $links_label_edit = '';
     $labels_edit = '';
     $new_window_edit = '';
     if (Tools::isSubmit('updatelinksmenutop')) {
         $link = MenuTopLinks::getLinkLang(Tools::getValue('id_linksmenutop'), (int) Shop::getContextShopID());
         foreach ($link['link'] as $key => $label) {
             $link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label);
         }
         $links_label_edit = $link['link'];
         $labels_edit = $link['label'];
         $new_window_edit = $link['new_window'];
     }
     $fields_values = array('new_window' => Tools::getValue('new_window', $new_window_edit), 'id_linksmenutop' => Tools::getValue('id_linksmenutop'));
     if (Tools::getValue('submitAddmodule')) {
         foreach (Language::getLanguages(false) as $lang) {
             $fields_values['label'][$lang['id_lang']] = '';
             $fields_values['link'][$lang['id_lang']] = '';
         }
     } else {
         foreach (Language::getLanguages(false) as $lang) {
             $fields_values['label'][$lang['id_lang']] = Tools::getValue('label_' . (int) $lang['id_lang'], isset($labels_edit[$lang['id_lang']]) ? $labels_edit[$lang['id_lang']] : '');
             $fields_values['link'][$lang['id_lang']] = Tools::getValue('link_' . (int) $lang['id_lang'], isset($links_label_edit[$lang['id_lang']]) ? $links_label_edit[$lang['id_lang']] : '');
         }
     }
     return $fields_values;
 }
Example #21
0
<?php

include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/gshoppingflux.php';
$module = new GShoppingFlux();
$shop_id = Shop::getContextShopID();
$module->generateShopFileList($shop_id);
die('OK, export completed successfully.');
Example #22
0
    /**
     * This tricky method generates a SQL clause to check if ranged data are overloaded by multishop
     *
     * @since 1.5.0
     *
     * @param string $range_table Range table
     *
     * @return string SQL quoer to get the delivery range table in this Shop(Group)
     */
    public static function sqlDeliveryRangeShop($range_table, $alias = 'd')
    {
        if (Shop::getContext() == Shop::CONTEXT_ALL) {
            $where = 'AND d2.id_shop IS NULL AND d2.id_shop_group IS NULL';
        } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) {
            $where = 'AND ((d2.id_shop_group IS NULL OR d2.id_shop_group = ' . Shop::getContextShopGroupID() . ') AND d2.id_shop IS NULL)';
        } else {
            $where = 'AND (d2.id_shop = ' . Shop::getContextShopID() . ' OR (d2.id_shop_group = ' . Shop::getContextShopGroupID() . '
					AND d2.id_shop IS NULL) OR (d2.id_shop_group IS NULL AND d2.id_shop IS NULL))';
        }
        $sql = 'AND ' . $alias . '.id_delivery = (
					SELECT d2.id_delivery
					FROM ' . _DB_PREFIX_ . 'delivery d2
					WHERE d2.id_carrier = `' . bqSQL($alias) . '`.id_carrier
						AND d2.id_zone = `' . bqSQL($alias) . '`.id_zone
						AND d2.`id_' . bqSQL($range_table) . '` = `' . bqSQL($alias) . '`.`id_' . bqSQL($range_table) . '`
						' . $where . '
					ORDER BY d2.id_shop DESC, d2.id_shop_group DESC
					LIMIT 1
				)';
        return $sql;
    }
Example #23
0
 /**
  * Add an sql restriction for shops fields
  *
  * @param int $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value
  * @param string $alias
  */
 public static function addSqlRestriction($share = false, $alias = null)
 {
     if ($alias) {
         $alias .= '.';
     }
     $group = Shop::getGroupFromShop(Shop::getContextShopID(), false);
     if ($share == Shop::SHARE_CUSTOMER && Shop::getContext() == Shop::CONTEXT_SHOP && $group['share_customer']) {
         $restriction = ' AND ' . $alias . 'id_shop_group = ' . (int) Shop::getContextShopGroupID();
     } else {
         $restriction = ' AND ' . $alias . 'id_shop IN (' . implode(', ', Shop::getContextListShopID($share)) . ') ';
     }
     return $restriction;
 }
 private function makeMenu()
 {
     $menu = '';
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     $head = $this->_itemHead;
     $tail = $this->_itemTail;
     foreach ($menu_items as $item) {
         if (!$item) {
             continue;
         }
         preg_match($this->pattern, $item, $value);
         $id = (int) substr($item, strlen($value[1]), strlen($item));
         switch (substr($item, 0, strlen($value[1]))) {
             case 'CAT':
                 $this->getCategory($menu, (int) $id);
                 break;
             case 'PRD':
                 $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' active' : '';
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if (!is_null($product->id)) {
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $product->getLink() . '"><span>' . $product->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' active' : '';
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $cms[0]['link'] . '"><span>' . $cms[0]['meta_title'] . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'CMS_CAT':
                 $category = new CMSCategory((int) $id, (int) $id_lang);
                 if (count($category)) {
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $category->getLink() . '"><span>' . $category->name . '</span></a>';
                     $this->getCMSMenuItems($menu, $category->id);
                     $menu .= '</li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'MAN':
                 $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' active' : '';
                 $manufacturer = new Manufacturer((int) $id, (int) $id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link->getManufacturerLink((int) $id, $manufacturer->link_rewrite) . '"><span>' . $manufacturer->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'SUP':
                 $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' active' : '';
                 $supplier = new Supplier((int) $id, (int) $id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link->getSupplierLink((int) $id, $supplier->link_rewrite) . '"><span>' . $supplier->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'SHOP':
                 $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' active' : '';
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $link = new Link();
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $shop->getBaseURL() . '"><span>' . $shop->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = MenuTopLinks_mod::get((int) $id, (int) $id_lang, (int) $id_shop);
                 if (count($link)) {
                     if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                         $default_language = Configuration::get('PS_LANG_DEFAULT');
                         $link = MenuTopLinks_mod::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
         }
     }
     return $menu;
 }
Example #25
0
 protected function displayForm()
 {
     $this->context->controller->addJqueryPlugin('tablednd');
     $this->context->controller->addJS(_PS_JS_DIR_ . 'admin-dnd.js');
     $this->_display = 'index';
     $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('CMS block configuration'), 'image' => _PS_ADMIN_IMG_ . 'information.png'), 'input' => array(array('type' => 'cms_blocks', 'label' => $this->l('CMS Blocks:'), 'name' => 'cms_blocks', 'values' => array(0 => BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::LEFT_COLUMN, Shop::getContextShopID()), 1 => BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::RIGHT_COLUMN, Shop::getContextShopID())))));
     $this->fields_form[1]['form'] = array('tinymce' => true, 'legend' => array('title' => $this->l('Footer\'s various links Configuration'), 'image' => _PS_ADMIN_IMG_ . 'information.png'), 'input' => array(array('type' => 'checkbox', 'name' => 'cms_footer', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display various links and information in the Footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'cms_pages', 'label' => $this->l('Footer links:'), 'name' => 'footerBox[]', 'values' => BlockCMSModel::getAllCMSStructure(), 'desc' => $this->l('Mark all pages you want to display in the footer CMS block')), array('type' => 'textarea', 'label' => $this->l('Footer informations:'), 'name' => 'footer_text', 'rows' => 5, 'cols' => 60, 'lang' => true), array('type' => 'checkbox', 'name' => 'cms_footer_powered_by', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "Powered by Prestashop"'), 'val' => '1')), 'id' => 'id', 'name' => 'name'))), 'submit' => array('name' => 'submitFooterCMS', 'title' => $this->l('   Save   '), 'class' => 'button'));
     $this->context->controller->getLanguages();
     $tmp = Configuration::get('FOOTER_CMS');
     $footer_boxes = explode('|', $tmp);
     if ($footer_boxes && is_array($footer_boxes)) {
         foreach ($footer_boxes as $key => $value) {
             $this->fields_value[$value] = true;
         }
     }
     $this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION');
     $this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY');
     foreach ($this->context->controller->_languages as $language) {
         $footer_text = Configuration::get('FOOTER_CMS_TEXT_' . $language['id_lang']);
         $this->fields_value['footer_text'][$language['id_lang']] = $footer_text;
     }
     $helper = $this->initForm();
     $helper->submit_action = '';
     $helper->title = $this->l('CMS Block configuration');
     $helper->fields_value = $this->fields_value;
     $this->_html .= $helper->generateForm($this->fields_form);
     return;
 }
Example #26
0
 public function processSaveCmsInfo()
 {
     if ($id_info = Tools::getValue('id_info')) {
         $info = new InfoBlock((int) $id_info);
     } else {
         $info = new InfoBlock();
         if (Shop::isFeatureActive()) {
             $shop_ids = Tools::getValue('checkBoxShopAsso_configuration');
             if (!$shop_ids) {
                 $this->html .= '<div class="alert alert-danger conf error">' . $this->l('You have to select at least one shop.') . '</div>';
                 return false;
             }
         } else {
             $info->id_shop = Shop::getContextShopID();
         }
     }
     $languages = Language::getLanguages(false);
     $text = array();
     foreach ($languages as $lang) {
         $text[$lang['id_lang']] = Tools::getValue('text_' . $lang['id_lang']);
     }
     $info->text = $text;
     if (Shop::isFeatureActive() && !$info->id_shop) {
         $saved = true;
         foreach ($shop_ids as $id_shop) {
             $info->id_shop = $id_shop;
             $saved &= $info->add();
         }
     } else {
         $saved = $info->save();
     }
     if ($saved) {
         $this->_clearCache('blockcmsinfo.tpl');
     } else {
         $this->html .= '<div class="alert alert-danger conf error">' . $this->l('An error occurred while attempting to save.') . '</div>';
     }
     return $saved;
 }
Example #27
0
 private function getSingleMapData($params)
 {
     $cart = Cart::getCartByOrderId((int) $params['id_order']);
     if (Validate::isLoadedObject($cart)) {
         $products = $cart->getProducts();
         if (count($products) == 0 && method_exists('Shop', 'getContextShopID') && Shop::getContextShopID() != (int) $cart->id_shop) {
             Shop::initialize();
             $products = $cart->getProducts(true);
         }
         $currency = Currency::getCurrencyInstance((int) $cart->id_currency);
         if (!is_null($products) && is_array($products) && Validate::isLoadedObject($currency)) {
             $data = array();
             $data['order_date'] = $params['date_add'];
             $data['email'] = $params['email'];
             $data['customer_name'] = $params['firstname'] . ' ' . $params['lastname'];
             $data['order_id'] = (int) $params['id_order'];
             $data['currency_iso'] = $currency->iso_code;
             $products_arr = array();
             foreach ($products as $product) {
                 $product_data = array();
                 $product_data['url'] = $this->getProductLink($product['id_product'], $product['link_rewrite']);
                 $product_data['name'] = $product['name'];
                 $product_data['image'] = $this->getProductImageUrl((int) $product['id_product']);
                 $product_data['description'] = $this->getDescritpion($product, (int) $params['id_lang']);
                 $product_data['price'] = $product['price'];
                 $products_arr[(int) $product['id_product']] = $product_data;
             }
             $data['products'] = $products_arr;
             return $data;
         }
     }
     return null;
 }
Example #28
0
    /**
     * Render an area to determinate shop association
     *
     * @return string
     */
    public function renderAssoShop($disable_shared = false)
    {
        if (!Shop::isFeatureActive()) {
            return;
        }
        $assos = array();
        if ((int) $this->id) {
            $sql = 'SELECT `id_shop`, `' . bqSQL($this->identifier) . '`
					FROM `' . _DB_PREFIX_ . bqSQL($this->table) . '_shop`
					WHERE `' . bqSQL($this->identifier) . '` = ' . (int) $this->id;
            foreach (Db::getInstance()->executeS($sql) as $row) {
                $assos[$row['id_shop']] = $row['id_shop'];
            }
        } else {
            switch (Shop::getContext()) {
                case Shop::CONTEXT_SHOP:
                    $assos[Shop::getContextShopID()] = Shop::getContextShopID();
                    break;
                case Shop::CONTEXT_GROUP:
                    foreach (Shop::getShops(false, Shop::getContextShopGroupID(), true) as $id_shop) {
                        $assos[$id_shop] = $id_shop;
                    }
                    break;
                default:
                    foreach (Shop::getShops(false, null, true) as $id_shop) {
                        $assos[$id_shop] = $id_shop;
                    }
                    break;
            }
        }
        $tpl = $this->createTemplate('assoshop.tpl');
        $tree = Shop::getTree();
        $nb_shop = 0;
        foreach ($tree as &$value) {
            $value['disable_shops'] = isset($value[$disable_shared]) && $value[$disable_shared];
            $nb_shop += count($value['shops']);
        }
        $tpl->assign(array('input' => array('type' => 'shop', 'values' => $tree), 'fields_value' => array('shop' => $assos), 'form_id' => $this->id, 'table' => $this->table, 'nb_shop' => $nb_shop));
        return $tpl->fetch();
    }
Example #29
0
 protected function displayForm()
 {
     $this->context->controller->addJqueryPlugin('tablednd');
     if (version_compare(_PS_VERSION_, '1.6.0.11', '>=') === true) {
         $this->context->controller->addJS(_PS_JS_DIR_ . 'admin/dnd.js');
     } else {
         $this->context->controller->addJS(_PS_JS_DIR_ . 'admin-dnd.js');
     }
     $current_index = AdminController::$currentIndex;
     $token = Tools::getAdminTokenLite('AdminModules');
     $this->_display = 'index';
     $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('CMS block configuration'), 'icon' => 'icon-list-alt'), 'input' => array(array('type' => 'cms_blocks', 'label' => $this->l('CMS Blocks'), 'name' => 'cms_blocks', 'values' => array(0 => BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::LEFT_COLUMN, Shop::getContextShopID()), 1 => BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::RIGHT_COLUMN, Shop::getContextShopID())))), 'buttons' => array('newBlock' => array('title' => $this->l('New block'), 'href' => $current_index . '&amp;configure=' . $this->name . '&amp;token=' . $token . '&amp;addBlockCMS', 'class' => 'pull-right', 'icon' => 'process-icon-new')));
     $this->fields_form[1]['form'] = array('tinymce' => true, 'legend' => array('title' => $this->l('Configuration of the various links in the footer'), 'icon' => 'icon-link'), 'input' => array(array('type' => 'checkbox', 'name' => 'cms_footer', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display various links and information in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'cms_pages', 'label' => $this->l('Footer links'), 'name' => 'footerBox[]', 'values' => BlockCMSModel::getAllCMSStructure(), 'desc' => $this->l('Please mark every page that you want to display in the footer CMS block.')), array('type' => 'textarea', 'label' => $this->l('Footer information'), 'name' => 'footer_text', 'rows' => 5, 'cols' => 60, 'lang' => true), array('type' => 'checkbox', 'name' => 'PS_STORES_DISPLAY_FOOTER', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "Our stores" link in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'name' => 'cms_footer_display_price-drop', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "Price drop" link in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'name' => 'cms_footer_display_new-products', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "New products" link in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'name' => 'cms_footer_display_best-sales', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "Best sales" link in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'name' => 'cms_footer_display_contact', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "Contact us" link in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'name' => 'cms_footer_display_sitemap', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display sitemap link in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'name' => 'cms_footer_powered_by', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Display "Powered by PrestaShop" in the footer'), 'val' => '1')), 'id' => 'id', 'name' => 'name'))), 'submit' => array('name' => 'submitFooterCMS', 'title' => $this->l('Save')));
     $this->context->controller->getLanguages();
     $tmp = Configuration::get('FOOTER_CMS');
     $footer_boxes = explode('|', $tmp);
     if ($footer_boxes && is_array($footer_boxes)) {
         foreach ($footer_boxes as $key => $value) {
             $this->fields_value[$value] = true;
         }
     }
     $this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION');
     $this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY');
     $this->fields_value['PS_STORES_DISPLAY_FOOTER_on'] = Configuration::get('PS_STORES_DISPLAY_FOOTER');
     $this->fields_value['cms_footer_display_price-drop_on'] = Configuration::get('FOOTER_PRICE-DROP');
     $this->fields_value['cms_footer_display_new-products_on'] = Configuration::get('FOOTER_NEW-PRODUCTS');
     $this->fields_value['cms_footer_display_best-sales_on'] = Configuration::get('FOOTER_BEST-SALES');
     $this->fields_value['cms_footer_display_contact_on'] = Configuration::get('FOOTER_CONTACT');
     $this->fields_value['cms_footer_display_sitemap_on'] = Configuration::get('FOOTER_SITEMAP');
     foreach ($this->context->controller->_languages as $language) {
         $footer_text = Configuration::get('FOOTER_CMS_TEXT_' . $language['id_lang']);
         $this->fields_value['footer_text'][$language['id_lang']] = $footer_text;
     }
     $helper = $this->initForm();
     $helper->submit_action = '';
     $helper->title = $this->l('CMS Block configuration');
     $helper->fields_value = $this->fields_value;
     $this->_html .= $helper->generateForm($this->fields_form);
     return;
 }
Example #30
0
 /**
  * Returns an array with selected shops and type (group or boutique shop)
  *
  * @param string $table
  * @return array
  */
 protected function getSelectedAssoShop($table)
 {
     if (!Shop::isFeatureActive() || !Shop::isTableAssociated($table)) {
         return array();
     }
     $shops = Shop::getShops(true, null, true);
     if (count($shops) == 1 && isset($shops[0])) {
         return array($shops[0], 'shop');
     }
     $assos = array();
     if (Tools::isSubmit('checkBoxShopAsso_' . $table)) {
         foreach (Tools::getValue('checkBoxShopAsso_' . $table) as $id_shop => $value) {
             $assos[] = (int) $id_shop;
         }
     } elseif (Shop::getTotalShops(false) == 1) {
         // if we do not have the checkBox multishop, we can have an admin with only one shop and being in multishop
         $assos[] = (int) Shop::getContextShopID();
     }
     return $assos;
 }