public function showShop()
 {
     $shop = Shop::where('user_id', Auth::user()->id)->first();
     if (!$shop) {
         $shop = new Shop();
         $shop->user_id = Auth::user()->id;
         $shop->save();
     }
     $items = $shop->shopItems;
     $total = 0;
     foreach ($items as $item) {
         $total += $item->item->price;
     }
     return view('shop', ['items' => $items, 'total' => $total]);
 }
    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 postProcess()
 {
     // Check if cart is valid
     $cart = new Cart((int) Tools::getValue('id_cart'));
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         $this->returnError('Invalid cart');
     }
     // Check if customer exists
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         $this->returnError('Invalid customer');
     }
     $currency = new Currency((int) $cart->id_currency);
     $total_paid = Tools::getValue('total_paid');
     $extra_vars = array('transaction_id' => Tools::getValue('transaction_id'));
     // Build the validation token
     $validation_token = md5(Configuration::get('MYMOD_API_CRED_SALT') . Tools::getValue('id_cart') . $total_paid . Tools::getValue('transaction_id'));
     // Check validation token
     if (Tools::getValue('validation_token') != $validation_token) {
         $this->returnError('Invalid token');
     }
     // Validate order
     $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total_paid, $this->module->displayName . ' API', NULL, $extra_vars, (int) $currency->id, false, $customer->secure_key);
     // Redirect on order confirmation page
     $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
     $return_url = Tools::getShopProtocol() . $shop->domain . $shop->getBaseURI();
     $this->returnSuccess($return_url . 'index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
示例#4
0
 /**
  * Create a link to a photo
  *
  * @param mixed $photo Photos object (can be an ID supplier, but deprecated)
  * @param string $alias
  * @param int $id_lang
  * @return string
  */
 public static function getPhotosLink($photo, $alias = null, $id_lang = null, $id_shop = null)
 {
     if (!$id_lang) {
         $id_lang = Context::getContext()->language->id;
     }
     if ($id_shop === null) {
         $shop = Context::getContext()->shop;
     } else {
         $shop = new Shop($id_shop);
     }
     $url = 'http://' . $shop->domain . $shop->getBaseURI() . $this->getLangLink($id_lang, null, $id_shop);
     $dispatcher = Dispatcher::getInstance();
     if (!is_object($photo)) {
         if ($alias !== null && !$dispatcher->hasKeyword('photo_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('photo_rule', $id_lang, 'meta_title', $id_shop)) {
             return $url . $dispatcher->createUrl('photo_rule', $id_lang, array('id' => (int) $photo, 'rewrite' => (string) $alias), $this->allow, '', $id_shop);
         }
         $photo = new Photos($photo, $id_lang);
     }
     // Set available keywords
     $params = array();
     $params['id'] = $photo->id;
     $params['rewrite'] = !$alias ? $photo->link_rewrite : $alias;
     $params['meta_keywords'] = Tools::str2url($photo->meta_keywords);
     $params['meta_title'] = Tools::str2url($photo->meta_title);
     return $url . $dispatcher->createUrl('photo_rule', $id_lang, $params, $this->allow, '', $id_shop);
 }
示例#5
0
 private function _getDefaultShopUrl()
 {
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
         return $shop->getBaseURL();
     } else {
         return __PS_BASE_URI__;
     }
 }
示例#6
0
 /**
  * Общение с коллегами
  *
  * @param string $msg - сообщение
  */
 public function send($msg)
 {
     if ($msg == "Farmer: Tomato complete...") {
         $this->cannery->money -= 10000;
         $this->farmer->money += 10000;
         $this->cannery->makeKetchup($this->farmer->getTomato());
     } else {
         if ($msg == "Cannery: Ketchup complete...") {
             $this->shop->money -= 15000;
             $this->cannery->money += 15000;
             $this->shop->sellKetchup($this->cannery->getKetchup());
         }
     }
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->required_database = true;
        $this->required_fields = array('company', 'address2', 'postcode', 'other', 'phone', 'phone_mobile', 'vat_number', 'dni');
        $this->table = 'address';
        $this->className = 'Address';
        $this->lang = false;
        $this->addressType = 'customer';
        $this->explicitSelect = true;
        $this->context = Context::getContext();
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->allow_export = true;
        if (!Tools::getValue('realedit')) {
            $this->deleted = true;
        }
        $countries = Country::getCountries($this->context->language->id);
        foreach ($countries as $country) {
            $this->countries_array[$country['id_country']] = $country['name'];
        }
        $this->fields_list = array('id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name'), 'filter_key' => 'a!firstname'), 'lastname' => array('title' => $this->l('Last Name'), 'filter_key' => 'a!lastname'), 'address1' => array('title' => $this->l('Address')), 'postcode' => array('title' => $this->l('Zip/Postal Code'), 'align' => 'right'), 'city' => array('title' => $this->l('City')), 'country' => array('title' => $this->l('Country'), 'type' => 'select', 'list' => $this->countries_array, 'filter_key' => 'cl!id_country'));
        parent::__construct();
        $this->_select = 'cl.`name` as country';
        $this->_join = '
			LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = ' . (int) $this->context->language->id . ')
			LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON a.id_customer = c.id_customer
		';
        $this->_where = 'AND a.id_customer != 0 ' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c');
    }
示例#8
0
    public function install()
    {
        if (!parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('displayHeader')) {
            return false;
        }
        $res = Db::getInstance()->execute('
			CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'editorial` (
			`id_editorial` int(10) unsigned NOT NULL auto_increment,
			`id_shop` int(10) unsigned NOT NULL ,
			`body_home_logo_link` varchar(255) NOT NULL,
			PRIMARY KEY (`id_editorial`))
			ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
        if ($res) {
            $res &= Db::getInstance()->execute('
				CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'editorial_lang` (
				`id_editorial` int(10) unsigned NOT NULL,
				`id_lang` int(10) unsigned NOT NULL,
				`body_title` varchar(255) NOT NULL,
				`body_subheading` varchar(255) NOT NULL,
				`body_paragraph` text NOT NULL,
				`body_logo_subheading` varchar(255) NOT NULL,
				PRIMARY KEY (`id_editorial`, `id_lang`))
				ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
        }
        if ($res) {
            foreach (Shop::getShops(false) as $shop) {
                $res &= $this->createExampleEditorial($shop['id_shop']);
            }
        }
        if (!$res) {
            $res &= $this->uninstall();
        }
        return $res;
    }
示例#9
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();
 }
示例#10
0
    private function getOrigins($dateBetween)
    {
        $directLink = $this->l('Direct link');
        $sql = 'SELECT http_referer
				FROM ' . _DB_PREFIX_ . 'connections
				WHERE 1
					' . Shop::addSqlRestriction() . '
					AND date_add BETWEEN ' . $dateBetween;
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
        $websites = array($directLink => 0);
        while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result)) {
            if (!isset($row['http_referer']) || empty($row['http_referer'])) {
                ++$websites[$directLink];
            } else {
                $website = preg_replace('/^www./', '', parse_url($row['http_referer'], PHP_URL_HOST));
                if (!isset($websites[$website])) {
                    $websites[$website] = 1;
                } else {
                    ++$websites[$website];
                }
            }
        }
        arsort($websites);
        return $websites;
    }
示例#11
0
 public function install()
 {
     if (Shop::isFeatureActive()) {
         Shop::setContext(Shop::CONTEXT_ALL);
     }
     //Ajout d'un onglet à la racine du site
     $parentTab = Tab::getIdFromClassName('AdminImporter');
     if (empty($parentTab)) {
         $parentTab = self::createTab(0, $this->name, 'EDC feeds importer', 'AdminImporter');
     }
     self::createTab($parentTab, $this->name, 'Import des produits', 'AdminImporterRunning');
     self::createTab($parentTab, $this->name, 'Configuration', 'AdminImporterConfiguration');
     self::createTab($parentTab, $this->name, 'Counter', 'AdminImporterCounter');
     self::createTab($parentTab, $this->name, 'Labo', 'AdminImporterLab');
     // self::createTab($parentTab, $this->name, 'CRON', 'AdminImporterCron');
     Configuration::updateValue('IMPORTER_URL_FULL_FEED', 'http://graphics.edc-internet.nl/b2b_feed.php?key=[KEY]&sort=xml&type=xml&lang=[LANG]&version=2015');
     Configuration::updateValue('IMPORTER_URL_NEW_PRODUCTS', 'http://graphics.edc-internet.nl/b2b_feed.php?key=[KEY]&sort=xml&type=xml&lang=[LANG]&version=2015&new=1');
     Configuration::updateValue('IMPORTER_URL_STOCK', 'http://graphics.edc-internet.nl/xml/eg_xml_feed_stock.xml');
     Configuration::updateValue('IMPORTER_DISCONTINUED', 'http://graphics.edc-internet.nl/xml/deleted_products.xml');
     Configuration::updateValue('IMPORTER_IMPORT_CURRENT_STEP', 0);
     Configuration::updateValue('IMPORTER_IMPORT_CURRENT_KEY_IN_XML', 0);
     Configuration::updateValue('IMPORTER_XML_FILE', '');
     Configuration::updateValue('IMPORTER_XML_COUNT');
     //Créer le dossier import
     if (!parent::install() || !$this->installDb()) {
         return false;
     }
     return true;
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'alias';
        $this->className = 'Alias';
        $this->lang = false;
        parent::__construct();
        // Alias fields
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        if (!Tools::getValue('realedit')) {
            $this->deleted = false;
        }
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->fields_list = array('alias' => array('title' => $this->l('Aliases')), 'search' => array('title' => $this->l('Search')), 'active' => array('title' => $this->l('Status'), 'class' => 'fixed-width-sm', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
        // Search options
        $current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
        $cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
        list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE product_shop.`visibility` IN ("both", "search") AND product_shop.`active` = 1');
        $this->fields_options = array('indexation' => array('title' => $this->l('Indexing'), 'icon' => 'icon-cogs', 'info' => '<p>' . $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of a Front Office search.') . '<br />
						' . $this->l('Indexed products') . ' <strong>' . (int) $indexed . ' / ' . (int) $total . '</strong>.
						</p>
						<p>' . $this->l('Building the product index may take a few minutes.') . $this->l('If your server stops before the process ends, you can resume the indexing by clicking "Add missing products."') . '</p>
						<a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&amp;redirect=1" class="btn-link"><i class="icon-external-link-sign"></i> ' . $this->l('Add missing products to the index.') . '</a><br />
						<a href="searchcron.php?full=1&amp;token=' . substr(_COOKIE_KEY_, 34, 8) . '&amp;redirect=1" class="btn-link"><i class="icon-external-link-sign"></i> ' . $this->l('Re-build the entire index.') . '</a><br /><br />
						' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . ' <a href="' . Tools::safeOutput($cron_url) . '"><i class="icon-external-link-sign"></i> ' . Tools::safeOutput($cron_url) . '</a>', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexing'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable the automatic indexing of products. If you enable this feature, the products will be indexed in the search automatically when they are saved. If the feature is disabled, you will have to index products manually by using the links provided in the field set.'))), 'submit' => array('title' => $this->l('Save'))), 'search' => array('title' => $this->l('Search'), 'icon' => 'icon-search', 'fields' => array('PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'hint' => array($this->l('Enable ajax search for your visitors.'), $this->l('With ajax search, the first 10 products matching the user query will appear in real time below the input field.'))), 'PS_INSTANT_SEARCH' => array('title' => $this->l('Instant search'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'hint' => array($this->l('Enable instant search for your visitors?'), $this->l('With instant search, the results will appear immediately as the user writes a query.'))), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'hint' => $this->l('Only words this size or larger will be indexed.'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'validation' => 'isGenericName', 'hint' => $this->l('Please enter the index words separated by a "|".'), 'type' => 'textLang')), 'submit' => array('title' => $this->l('Save'))), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'icon-cogs', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when completing a new search.') . '<br />
						' . $this->l('A word with a weight of eight will have four times more value than a word with a weight of two.') . '<br /><br />
						' . $this->l('We advise you to set a greater weight for words which appear in the name or reference of a product. This will allow the search results to be as precise and relevant as possible.') . '<br /><br />
						' . $this->l('Setting a weight to 0 will exclude that field from search index. Re-build of the entire index is required when changing to or from 0'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval')), 'submit' => array('title' => $this->l('Save'))));
    }
 public function install()
 {
     $e = get_headers(ERP_WS);
     if ($e[0] == 'HTTP/1.1 200 OK') {
         if ($this->isCurlInstalled() == false) {
             $this->_errors[] = $this->l('Error while installing the module. CURL Extension is not active on your server. Please contact your server administrator.');
             return false;
         }
         if (Shop::isFeatureActive()) {
             Shop::setContext(Shop::CONTEXT_ALL);
         }
         if (!Configuration::hasKey('ERP_ADMIN_PARENT_ORDERS_TAB_ID')) {
             Configuration::updateValue('ERP_ADMIN_PARENT_ORDERS_TAB_ID', Tab::getIdFromClassName('AdminParentOrders'));
         }
         if (parent::install() != false && $this->parseSQL('install.sql') != false && $this->installStockMvtReason() != false && $this->installErpTab() != false && $this->addTrashCategory() != false && $this->addOrderState($this->l('Order to the supplier')) != false && $this->registerHook('actionOrderStatusUpdate') != false && $this->registerHook('displayBackOfficeHeader') != false) {
             foreach ($this->field_name_configuration as $field_name => $param) {
                 Configuration::updateValue(Tools::strtoupper($field_name), $param['default']);
             }
             // load a licence if exits
             $this->loadLicenceIfExists();
             // save the first install date
             if (!Configuration::hasKey('ERP_FIRST_INSTALL_DATE') || Configuration::get('ERP_FIRST_INSTALL_DATE') == '' || Configuration::get('ERP_FIRST_INSTALL_DATE') == false) {
                 Configuration::updateValue('ERP_FIRST_INSTALL_DATE', date("Y-m-d H:i:s"));
             }
             return true;
         }
         return false;
     } else {
         $this->_errors[] = $this->l('Error while getting headers of WS ! Please contact the customer service.');
         return false;
     }
 }
示例#14
0
    public function getData()
    {
        $this->_totalCount = $this->getTotalCount();
        $this->query = 'SELECT m.name, SUM(od.product_quantity) as quantity, ROUND(SUM(od.product_quantity * od.product_price) / c.conversion_rate, 2) as sales
				FROM ' . _DB_PREFIX_ . 'order_detail od
				LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
				LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON (o.id_order = od.id_order)
				LEFT JOIN ' . _DB_PREFIX_ . 'currency c ON (c.id_currency = o.id_currency)
				LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
				WHERE o.invoice_date BETWEEN ' . $this->getDate() . '
					' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
					AND o.valid = 1
					AND m.id_manufacturer IS NOT NULL
				GROUP BY p.id_manufacturer';
        if (Validate::IsName($this->_sort)) {
            $this->query .= ' ORDER BY `' . bqSQL($this->_sort) . '`';
            if (isset($this->_direction) && Validate::isSortDirection($this->_direction)) {
                $this->query .= ' ' . $this->_direction;
            }
        }
        if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) {
            $this->query .= ' LIMIT ' . (int) $this->_start . ', ' . (int) $this->_limit;
        }
        $this->_values = Db::getInstance()->executeS($this->query);
    }
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Stores'), 'image' => '../img/admin/home.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'size' => 33, 'required' => false, 'hint' => sprintf($this->l('Allowed characters: letters, spaces and %s'), '().-'), 'desc' => $this->l('Store name (e.g. Citycentre Mall Store)')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'size' => 33, 'required' => true), array('type' => 'text', 'label' => $this->l('Address (2)'), 'name' => 'address2', 'size' => 33), array('type' => 'text', 'label' => $this->l('Postal Code/Zip Code'), 'name' => 'postcode', 'size' => 6, 'required' => true), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'size' => 33, 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('id' => 'id_state', 'name' => 'name', 'query' => null)), array('type' => 'latitude', 'label' => $this->l('Latitude / Longitude'), 'name' => 'latitude', 'required' => true, 'size' => 11, 'maxlength' => 12, 'desc' => $this->l('Store coordinates (e.g. 45.265469/-47.226478)')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'size' => 33), array('type' => 'text', 'label' => $this->l('Fax'), 'name' => 'fax', 'size' => 33), array('type' => 'text', 'label' => $this->l('E-mail address'), 'name' => 'email', 'size' => 33), array('type' => 'textarea', 'label' => $this->l('Note'), 'name' => 'note', 'cols' => 42, 'rows' => 4), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Whether or not to display this store'))), 'rightCols' => array('input' => array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'desc' => $this->l('Storefront picture'))), 'submit' => array('title' => $this->l('   Save   '), 'class' => 'button'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true);
     $days = array();
     $days[1] = $this->l('Monday');
     $days[2] = $this->l('Tuesday');
     $days[3] = $this->l('Wednesday');
     $days[4] = $this->l('Thursday');
     $days[5] = $this->l('Friday');
     $days[6] = $this->l('Saturday');
     $days[7] = $this->l('Sunday');
     $hours = $this->getFieldValue($obj, 'hours');
     if (!empty($hours)) {
         $hours_unserialized = Tools::unSerialize($hours);
     }
     $this->fields_value = array('latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'), 'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'), 'image' => $image ? $image : false, 'size' => $image ? filesize(_PS_STORE_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false, 'days' => $days, 'hours' => isset($hours_unserialized) ? $hours_unserialized : false);
     return parent::renderForm();
 }
    public function initFormByStatus()
    {
        $this->fields_form = array('legend' => array('title' => $this->l('By order status'), 'image' => '../img/admin/pdf.gif'), 'input' => array(array('type' => 'checkboxStatuses', 'label' => $this->l('Statuses:'), 'name' => 'id_order_state', 'values' => array('query' => OrderState::getOrderStates($this->context->language->id), 'id' => 'id_order_state', 'name' => 'name'), 'desc' => $this->l('You can also export orders which have not been charged yet.') . ' (<img src="../img/admin/charged_ko.gif" alt="" />).')), 'submit' => array('title' => $this->l('Generate PDF file by status.'), 'class' => 'button', 'id' => 'submitPrint2'));
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT COUNT(o.id_order) as nbOrders, (
				SELECT oh.id_order_state
				FROM ' . _DB_PREFIX_ . 'order_history oh
				WHERE oh.id_order = oi.id_order
				ORDER BY oh.date_add DESC, oh.id_order_history DESC
				LIMIT 1
			) id_order_state
			FROM ' . _DB_PREFIX_ . 'order_invoice oi
			LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON (oi.id_order = o.id_order)
			WHERE o.id_shop IN(' . implode(', ', Shop::getContextListShopID()) . ')
			GROUP BY id_order_state
		');
        $status_stats = array();
        foreach ($result as $row) {
            $status_stats[$row['id_order_state']] = $row['nbOrders'];
        }
        $this->tpl_form_vars = array('statusStats' => $status_stats, 'style' => '');
        $this->table = 'invoice_status';
        $this->show_toolbar = false;
        return parent::renderForm();
    }
    public static function getTaxRulesGroups($only_active = true)
    {
        return Db::getInstance()->executeS('
			SELECT DISTINCT g.id_tax_rules_group, g.name, g.active
			FROM `' . _DB_PREFIX_ . 'tax_rules_group` g' . Shop::addSqlAssociation('tax_rules_group', 'g') . ($only_active ? ' WHERE g.`active` = 1' : '') . '
			ORDER BY name ASC');
    }
示例#18
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();
 }
示例#19
0
    /**
     * AdminController::renderList() override
     * @see AdminController::renderList()
     */
    public function renderList()
    {
        // removes toolbar btn
        $this->toolbar_btn = array();
        // overrides select
        $this->_select = '
			CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name,
			CONCAT(a.employee_lastname, \' \', a.employee_firstname) as employee,
			mrl.name as reason,
			stock.reference as product_reference,
			stock.ean13 as product_ean13,
			stock.upc as product_upc,
			w.id_currency as id_currency,
			w.name as warehouse_name';
        // overrides join
        $this->_join = 'INNER JOIN ' . _DB_PREFIX_ . 'stock stock ON a.id_stock = stock.id_stock
							LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
								stock.id_product = pl.id_product
								AND pl.id_lang = ' . (int) $this->context->language->id . Shop::addSqlRestrictionOnLang('pl') . '
							)
							LEFT JOIN `' . _DB_PREFIX_ . 'stock_mvt_reason_lang` mrl ON (
								a.id_stock_mvt_reason = mrl.id_stock_mvt_reason
								AND mrl.id_lang = ' . (int) $this->context->language->id . '
							)
							LEFT JOIN `' . _DB_PREFIX_ . 'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
							LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
							LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (
								al.id_attribute = pac.id_attribute
								AND pac.id_product_attribute <> 0
								AND al.id_lang = ' . (int) $this->context->language->id . '
							)';
        // overrides group
        $this->_group = 'GROUP BY a.id_stock_mvt';
        // overrides where depending on the warehouse
        $id_warehouse = (int) $this->getCurrentWarehouseId();
        if ($id_warehouse > 0) {
            $this->_where = ' AND w.id_warehouse = ' . $id_warehouse;
            self::$currentIndex .= '&id_warehouse=' . $id_warehouse;
        }
        // sets the current warehouse
        $this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
        // sets the list of warehouses
        $warehouses = Warehouse::getWarehouses(true);
        array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
        $this->tpl_list_vars['list_warehouses'] = $warehouses;
        // sets toolbar
        $this->initToolbar();
        // renders list
        $list = parent::renderList();
        // if export requested
        if (Tools::isSubmit('csv')) {
            if (count($this->_list) > 0) {
                $this->renderCSV();
                die;
            } else {
                $this->displayWarning($this->l('There is nothing to export as a CSV.'));
            }
        }
        return $list;
    }
    public function __construct()
    {
        $this->table = 'alias';
        $this->className = 'Alias';
        $this->lang = false;
        parent::__construct();
        // Alias fields
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        if (!Tools::getValue('realedit')) {
            $this->deleted = false;
        }
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
        $this->fields_list = array('alias' => array('title' => $this->l('Aliases'), 'width' => 'auto'), 'search' => array('title' => $this->l('Search'), 'width' => 100), 'active' => array('title' => $this->l('Status'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
        // Search options
        $current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
        $cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($current_file_name['0'])) . 'searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
        list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p'));
        $this->fields_options = array('indexation' => array('title' => $this->l('Indexation'), 'icon' => 'search', 'info' => $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of the Front Office search.') . '<br />
						' . $this->l('Indexed products:') . ' <b>' . (int) $indexed . ' / ' . (int) $total . '</b>.
						</p>
						<p>' . $this->l('Building the product index can take a few minutes or more.') . $this->l('If your server stops the process before it ends, you can resume the indexation by clicking "Add missing products."') . '</p>
						-&gt; <a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Add missing products to index.') . '</a><br />
						-&gt; <a href="searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Re-build entire index.') . '</a><br /><br />
						' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . ' <a href="' . $cron_url . '">' . $cron_url . '</a>', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexation'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable automatic indexation of the products. If you enable this feature, the products will be indexed in the search automatically when they are saved, but if the feature is disabled, you will have to index the products manually by using the links provided in this fieldset.')))), 'search' => array('title' => $this->l('Search'), 'icon' => 'search', 'fields' => array('PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable ajax search for your visitors.') . '<br />' . $this->l('With ajax search, the first 10 products matching the user query will appear in real time below the input field.')), 'PS_INSTANT_SEARCH' => array('title' => $this->l('Instant search'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => $this->l('Enable instant search for your visitors.') . '<br />' . $this->l('With instant search, the results will appear immediately as the user writes a query.')), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'desc' => $this->l('Only words this size or larger will be indexed.'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'size' => 35, 'validation' => 'isGenericName', 'desc' => $this->l('Please enter the words separated by a "|".'), 'type' => 'textLang')), 'submit' => array()), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'weight', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when try a new search.') . '<br />
						' . $this->l('A word with a weight of 8 will have 4 times more value than a word with a weight of 2.') . '<br /><br />
						' . $this->l('That\'s why we advise to set a greater weight for words which appear in the name or reference of a product than the ones in the description. Thus, the search results will be as precise and relevant as possible.'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'))));
    }
    public function renderList()
    {
        $this->addRowAction('details');
        $this->toolbar_btn = array();
        // disables link
        $this->list_no_link = true;
        // query
        $this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations, SUM(s.usable_quantity+s.usable_quantity_remainder) as stock';
        $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product = a.id_product)
						' . Shop::addSqlAssociation('product_attribute', 'pa', false) . '
						INNER JOIN `' . _DB_PREFIX_ . 'stock` s ON (s.id_product = a.id_product)';
        $this->_group = 'GROUP BY a.id_product';
        self::$currentIndex .= '&coverage_period=' . (int) $this->getCurrentCoveragePeriod() . '&warn_days=' . (int) $this->getCurrentWarning();
        if ($this->getCurrentCoverageWarehouse() != -1) {
            $this->_where .= ' AND s.id_warehouse = ' . (int) $this->getCurrentCoverageWarehouse();
            self::$currentIndex .= '&id_warehouse=' . (int) $this->getCurrentCoverageWarehouse();
        }
        // Hack for multi shop ..
        $this->_where .= ' AND b.id_shop = 1';
        $this->tpl_list_vars['stock_cover_periods'] = $this->stock_cover_periods;
        $this->tpl_list_vars['stock_cover_cur_period'] = $this->getCurrentCoveragePeriod();
        $this->tpl_list_vars['stock_cover_warehouses'] = $this->stock_cover_warehouses;
        $this->tpl_list_vars['stock_cover_cur_warehouse'] = $this->getCurrentCoverageWarehouse();
        $this->tpl_list_vars['stock_cover_warn_days'] = $this->getCurrentWarning();
        $this->ajax_params = array('period' => $this->getCurrentCoveragePeriod(), 'id_warehouse' => $this->getCurrentCoverageWarehouse(), 'warn_days' => $this->getCurrentWarning());
        $this->displayInformation($this->l('Considering the coverage period chosen and the quantity of products/combinations that you sold.'));
        $this->displayInformation($this->l('this interface gives you an idea of when a product will run out of stock.'));
        return $this->adminControllerRenderList();
    }
 public static function getBlockContent($params, &$smarty)
 {
     //use in template as {getBelvgBlockContent id="block_identifier"}
     if (!Module::isEnabled('belvg_staticblocks')) {
         return FALSE;
     }
     if (isset($params['id'])) {
         $block_identifier = $params['id'];
         $sql = '
         SELECT `id_belvg_staticblocks`
         FROM `' . _DB_PREFIX_ . 'belvg_staticblocks`
         WHERE `block_identifier` = "' . pSQL($block_identifier) . '" AND `status` = "1"';
         if (Shop::isFeatureActive()) {
             $sql .= ' AND `id_belvg_staticblocks` IN (
                 SELECT sa.`id_belvg_staticblocks`
                 FROM `' . _DB_PREFIX_ . 'belvg_staticblocks_shop` sa
                 WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
             )';
         }
         $block_id = (int) Db::getInstance()->getValue($sql);
         if ($block_id) {
             $id_lang = Context::getContext()->cookie->id_lang;
             $block = new self($block_id);
             if (isset($block->content[$id_lang])) {
                 return $block->content[$id_lang];
             }
         }
     }
 }
示例#23
0
    public function install()
    {
        if (!parent::install() || !$this->registerHook('displayHeader') || !$this->registerHook('displayAdditionalFooter')) {
            return false;
        }
        $res = Db::getInstance()->execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'footercontent` (
			`id_content` int(10) unsigned NOT NULL auto_increment,
			`id_shop` int(10) unsigned NOT NULL,
			`width` int(10) unsigned NOT NULL,
			PRIMARY KEY (`id_content`))
			ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
        if ($res) {
            $res &= Db::getInstance()->execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'footercontent_lang` (
				`id_content` int(10) unsigned NOT NULL,
				`id_lang` int(10) unsigned NOT NULL,
				`body_title` varchar(255) NOT NULL,
				`body_paragraph` text NOT NULL,
				PRIMARY KEY (`id_content`, `id_lang`))
				ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8');
        }
        if ($res) {
            foreach (Shop::getShops(false) as $shop) {
                $res &= $this->createExampleContent($shop['id_shop']);
            }
        }
        if (!$res) {
            $res &= $this->uninstall();
        }
        return (bool) $res;
    }
示例#24
0
    public function getData()
    {
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $this->query = 'SELECT SQL_CALC_FOUND_ROWS cr.code, ocr.name, COUNT(ocr.id_cart_rule) as total, ROUND(SUM(o.total_paid_real) / o.conversion_rate,2) as ca
				FROM ' . _DB_PREFIX_ . 'order_cart_rule ocr
				LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON o.id_order = ocr.id_order
				LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule cr ON cr.id_cart_rule = ocr.id_cart_rule
				WHERE o.valid = 1
					' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
					AND o.invoice_date BETWEEN ' . $this->getDate() . '
				GROUP BY ocr.id_cart_rule';
        if (Validate::IsName($this->_sort)) {
            $this->query .= ' ORDER BY `' . bqSQL($this->_sort) . '`';
            if (isset($this->_direction) && (Tools::strtoupper($this->_direction) == 'ASC' || Tools::strtoupper($this->_direction) == 'DESC')) {
                $this->query .= ' ' . pSQL($this->_direction);
            }
        }
        if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) {
            $this->query .= ' LIMIT ' . (int) $this->_start . ', ' . (int) $this->_limit;
        }
        $values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query);
        foreach ($values as &$value) {
            $value['ca'] = Tools::displayPrice($value['ca'], $currency);
        }
        $this->_values = $values;
        $this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
    }
示例#25
0
 public function getData()
 {
     if (!isset($this->_data)) {
         $this->setData(Shop::getTree());
     }
     return $this->_data;
 }
 public function renderForm()
 {
     $this->initFormToolBar();
     if (!$this->loadObject(true)) {
         return;
     }
     $cover = false;
     $obj = $this->loadObject(true);
     if (isset($obj->id)) {
         $this->display = 'edit';
         $cover = ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/' . $obj->id . '.' . $obj->cover, 'ph_simpleblog_cat_' . $obj->id . '.' . $obj->cover, 350, $obj->cover, false);
     } else {
         $this->display = 'add';
     }
     $this->fields_value = array('cover' => $cover ? $cover : false, 'cover_size' => $cover ? filesize(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/' . $obj->id . '.' . $obj->cover) / 1000 : false);
     $categories = SimpleBlogCategory::getCategories($this->context->language->id, true, true);
     array_unshift($categories, array('id' => 0, 'name' => $this->l('No parent')));
     foreach ($categories as $key => $category) {
         if (isset($obj->id) && $obj->id) {
             if ($category['id'] == $obj->id_simpleblog_category) {
                 unset($category[$key]);
             }
         }
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Category'), 'image' => '../img/admin/tab-categories.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Parent Category:'), 'name' => 'id_parent', 'required' => true, 'options' => array('id' => 'id', 'query' => $categories, 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'required' => true, 'lang' => true, 'class' => 'copy2friendlyUrl'), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'lang' => true, 'rows' => 5, 'cols' => 40, 'autoload_rte' => true), array('type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true), array('type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true), array('type' => 'text', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true), array('type' => 'text', 'label' => $this->l('Friendly URL:'), 'name' => 'link_rewrite', 'required' => true, 'lang' => true), array('type' => 'switch', 'label' => $this->l('Displayed'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'file', 'label' => $this->l('Category image:'), 'display_image' => true, 'name' => 'cover', 'desc' => $this->l('Upload a image from your computer.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     $this->tpl_form_vars['PS_FORCE_FRIENDLY_PRODUCT'] = (int) Configuration::get('PS_FORCE_FRIENDLY_PRODUCT');
     return parent::renderForm();
 }
 /**
  * AdminController::renderList() override
  * @see AdminController::renderList()
  */
 public function renderList()
 {
     // sets actions
     $this->addRowAction('details');
     $this->addRowAction('addstock');
     $this->addRowAction('removestock');
     if (count(Warehouse::getWarehouses()) > 1) {
         $this->addRowAction('transferstock');
     }
     // no link on list rows
     $this->list_no_link = true;
     // inits toolbar
     $this->toolbar_btn = array();
     // overrides query
     $this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations';
     $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product = a.id_product)' . Shop::addSqlAssociation('product_attribute', 'pa', false);
     $this->_where = 'AND a.is_virtual = 0';
     $this->_group = 'GROUP BY a.id_product';
     // displays informations
     $this->displayInformation($this->l('This interface allows you to manage product stock and their variations.') . '<br />');
     $this->displayInformation($this->l('Through this interface, you can increase and decrease product stock for an given warehouse.'));
     $this->displayInformation($this->l('Furthermore, you can move product quantities between warehouses, or within one warehouse.') . '<br />');
     $this->displayInformation($this->l('If you want to increase quantities of multiple products at once, you can use the "Supply orders" page under the "Stock" menu.') . '<br />');
     $this->displayInformation($this->l('Finally, you need to provide the quantity that you\'ll be adding: "Usable for sale" means that this quantity will be available in your shop(s), otherwise it will be considered reserved (i.e. for other purposes).'));
     return parent::renderList();
 }
示例#28
0
 /**
  * Returns a link to a product image for display
  * Note: the new image filesystem stores product images in subdirectories of img/p/
  *
  * @param string $name rewrite link of the image
  * @param string $ids id part of the image filename - can be "id_product-id_image" (legacy support, recommended) or "id_image" (new)
  * @param string $type
  */
 public function getImageLink($name, $ids, $type = null)
 {
     $not_default = false;
     // Check if module is installed, enabled, customer is logged in and watermark logged option is on
     /* if (Configuration::get('WATERMARK_LOGGED') && (Module::isInstalled('watermark') && Module::isEnabled('watermark')) && isset(Context::getContext()->customer->id)) {
         $type .= '-'.Configuration::get('WATERMARK_HASH');
         }
        */
     // legacy mode or default image
     $theme = Shop::isFeatureActive() && file_exists(_MODULE_SMARTBLOG_DIR_ . $ids . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . '.jpg') ? '-' . Context::getContext()->shop->id_theme : '';
     if (Configuration::get('PS_LEGACY_IMAGES') && file_exists(_MODULE_SMARTBLOG_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . '.jpg') || ($not_default = strpos($ids, 'default') !== false)) {
         if ($this->allow == 1 && !$not_default) {
             $uri_path = __PS_BASE_URI__ . 'blog/' . $ids . ($type ? '-' . $type : '') . $theme . '/' . $name . '.jpg';
         } else {
             $uri_path = _THEME_PROD_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . '.jpg';
         }
     } else {
         // if ids if of the form id_product-id_image, we want to extract the id_image part
         $split_ids = explode('-', $ids);
         $id_image = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0];
         $theme = Shop::isFeatureActive() && file_exists(_MODULE_SMARTBLOG_DIR_ . Image::getImgFolderStatic($id_image) . $id_image . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . '.jpg') ? '-' . Context::getContext()->shop->id_theme : '';
         if ($this->allow == 1) {
             $uri_path = __PS_BASE_URI__ . 'blog/' . $id_image . ($type ? '-' . $type : '') . $theme . '/' . $name . '.jpg';
         } else {
             $uri_path = __PS_BASE_URI__ . 'modules/smartblog/images/' . $id_image . ($type ? '-' . $type : '') . $theme . '.jpg';
         }
     }
     return $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path;
 }
示例#29
0
 public function initializeContext()
 {
     global $smarty;
     // Clean all cache values
     Cache::clean('*');
     Context::getContext()->shop = new Shop(1);
     Shop::setContext(Shop::CONTEXT_SHOP, 1);
     Configuration::loadConfiguration();
     if (!isset(Context::getContext()->language) || !Validate::isLoadedObject(Context::getContext()->language)) {
         if ($id_lang = (int) Configuration::get('PS_LANG_DEFAULT')) {
             Context::getContext()->language = new Language($id_lang);
         }
     }
     if (!isset(Context::getContext()->country) || !Validate::isLoadedObject(Context::getContext()->country)) {
         if ($id_country = (int) Configuration::get('PS_COUNTRY_DEFAULT')) {
             Context::getContext()->country = new Country((int) $id_country);
         }
     }
     if (!isset(Context::getContext()->currency) || !Validate::isLoadedObject(Context::getContext()->currency)) {
         if ($id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT')) {
             Context::getContext()->currency = new Currency((int) $id_currency);
         }
     }
     Context::getContext()->cart = new Cart();
     Context::getContext()->employee = new Employee(1);
     if (!defined('_PS_SMARTY_FAST_LOAD_')) {
         define('_PS_SMARTY_FAST_LOAD_', true);
     }
     require_once _PS_ROOT_DIR_ . '/config/smarty.config.inc.php';
     Context::getContext()->smarty = $smarty;
 }
示例#30
0
 public function __construct()
 {
     global $cookie;
     parent::__construct();
     $this->is_seller = $cookie->profile == (int) Configuration::get('AGILE_MS_PROFILE_ID');
     Shop::$id_shop_owner = $this->is_seller ? $cookie->id_employee : 0;
     if (Module::isInstalled('agilemultipleseller') and !isset($_GET['logout']) and $this->is_seller and (Tools::getValue("controller") == "" or Tools::getValue("controller") == "adminhome")) {
         $tid = Tab::getIdFromClassName('AdminProducts');
         $token = Tools::getAdminToken('AdminProducts' . intval($tid) . intval($cookie->id_employee));
         Tools::redirectAdmin("./index.php?controller=AdminProducts&token=" . $token);
     }
     if (Module::isInstalled('agilesellerlistoptions')) {
         require_once _PS_ROOT_DIR_ . '/modules/agilesellerlistoptions/agilesellerlistoptions.php';
         $aslo_module = new AgileSellerListOptions();
         $msg = $aslo_module->hookAgileAdminTop(null);
         if (!empty($msg)) {
             $this->displayWarning($msg);
         }
     }
     $tab = Tab::getInstanceFromClassName('AdminShopGroup');
     if (Module::isInstalled('agilemultipleshop')) {
         $tab->active = 1;
     } else {
         $tab->active = 0;
     }
     $tab->update();
 }