public function renderDetails($tpl = null) { if ($this->getLayout() != 'modal') { $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); } $unidentified = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('unidentified_group')); $guest = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('guest_group')); $default = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('customer_group')); /* $unidentified_group_information = sprintf( /*$this->l('%s - All persons without a customer account or customers that are not logged in.'), '<b>'.$unidentified->name[$this->context->language->id].'</b>' * / ); $guest_group_information = sprintf( /*$this->l('%s - All persons who placed an order through Guest Checkout.'), '<b>'.$guest->name[$this->context->language->id].'</b>' * / ); $default_group_information = sprintf( /*$this->l('%s - All persons who created an account on this site.'), '<b>'.$default->name[$this->context->language->id].'</b>' */ //); $groupModel = new JeproshopGroupModelGroup(); $groups = $groupModel->getGroupList(); $this->assignRef('groups', $groups); /*$this->displayInformation($this->l('PrestaShop has three default customer groups:')); $this->displayInformation($unidentified_group_information); $this->displayInformation($guest_group_information); $this->displayInformation($default_group_information); */ parent::display($tpl); }
public function display($tpl = null) { if (!isset($this->context) || $this->context == null) { $this->context = JeproshopContext::getContext(); } if (!$this->context->controller->isInitialized()) { $this->context->controller->initialize(); } $app = JFactory::getApplication(); $useSSL = isset($this->context->controller->ssl_enabled) && $this->context->conteoller->ssl_enabled && $app->input->get('enable_ssl') || JeproshopTools::usingSecureMode() ? true : false; $protocol_content = $useSSL ? 'https://' : 'http://'; /*$contextParams = $this->context->controller->getContextParams(); foreach ($contextParams as $assign_key => $assign_value){ if (!is_array($assign_value) && mb_substr($assign_value, 0, 1, 'utf-8') == '/' || $protocol_content == 'https://'){ $this->assignRef($assign_key, $protocol_content.JeproshopTools::getMediaServer($assign_value).$assign_value); }else{ $this->assignRef($assign_key, $assign_value); } }*/ if (!isset(self::$cache_products)) { $category = new JeproshopCategoryModelCategory(JeproshopContext::getContext()->shop->getCategoryId(), (int) JeproshopContext::getContext()->language->lang_id); $nb = (int) JeproshopSettingModelSetting::getValue('number_of_products_on_page'); self::$cache_products = JeproshopDefaultModelDefault::getProducts((int) JeproshopContext::getContext()->language->lang_id, 0, $nb ? $nb : 8, 'position'); } if (self::$cache_products === false || empty(self::$cache_products)) { self::$cache_products = false; } $this->assignRef('products', self::$cache_products); $display_add_product = JeproshopSettingModelSetting::getValue('display_category_attribute'); $this->assignRef('display_add_product', $display_add_product); $homeSize = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('home')); $this->assignRef('homeSize', $homeSize); $this->assignRef('pagination', JeproshopDefaultModelDefault::$_pagination); parent::display($tpl); }
public function __construct($country_id = null, $lang_id = null, $shop_id = NULL) { $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->get_shop_from_context = FALSE; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($country_id) { $cache_id = 'jeproshop_country_model_' . (int) $country_id . '_' . (int) $lang_id . '_' . (int) $shop_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_country') . " AS country "; //Get language data if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_country_lang') . " AS country_lang ON (country_lang." . $db->quoteName('country_id') . " = country." . $db->quoteName('country_id') . " AND country_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; } if (JeproshopShopModelShop::isTableAssociated('country')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_country_shop') . " AS country_shop ON (country_shop." . $db->quoteName('country_id') . " = country." . $db->quoteName('country_id') . " AND country_shop." . $db->quoteName('shop_id') . " = " . (int) $shop_id . ") "; } $db->setQuery($query); $country_data = $db->loadObject(); if ($country_data) { if (!$lang_id) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_country_lang') . " WHERE " . $db->quoteName('country_id') . " = " . (int) $country_id; $db->setQuery($query); $country_lang_data = $db->loadObjectList(); if ($country_lang_data) { foreach ($country_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'country_id') { if (!isset($country_data->{$key}) || !is_array($country_data->{$key})) { $country_data->{$key} = array(); } $country_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $country_data); } } else { $country_data = JeproshopCache::retrieve($cache_id); } if ($country_data) { $country_data->country_id = (int) $country_id; foreach ($country_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } }
/** * This method is allow to know if a feature is active * @return bool */ public static function isFeaturePublished() { static $feature_active = NULL; if ($feature_active === NULL) { $feature_active = JeproshopSettingModelSetting::getValue('combination_feature_active'); } return $feature_active; }
public function __construct($image_id = null, $lang_id = null) { //parent::__construct($id, $id_lang); if ($lang_id !== null) { $this->lang_id = JeproshopSettingModelSetting::getLanguage($lang_id) !== false ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($image_id) { $cache_id = 'jeproshop_image_model_' . (int) $image_id . '_' . (int) $lang_id; if (!JeproshopCache::isStored($cache_id)) { $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_image') . " AS image "; if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_image_lang') . " AS image_lang ON (image." . $db->quoteName('image_id'); $query .= " = image_lang." . $db->quoteName('image_id') . " AND image." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") "; } $query .= "WHERE image." . $db->quoteName('image_id') . " = " . (int) $image_id; $db->setQuery($query); $image_data = $db->loadObject(); if ($image_data) { if (!$lang_id && isset($this->multilang) && $this->multilang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_image_lang'); $query .= " WHERE image_id = " . (int) $image_id; $db->setQuery($query); $image_lang_data = $db->loadObjectList(); if ($image_lang_data) { foreach ($image_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'image_id') { if (!isset($image_data->{$key}) || !is_array($image_data->{$key})) { $image_data->{$key} = array(); } $image_data->{$key}[$row->lang_id] = $value; } } } } JeproshopCache::store($cache_id, $image_data); } } } else { $image_data = JeproshopCache::retrieve($cache_id); } if ($image_data) { $image_data->image_id = $image_id; foreach ($image_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } $this->image_dir = COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY; $this->source_index = COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . 'index.php'; }
public function renderDetails($tpl = null) { $app = JFactory::getApplication(); $category_id = $app->input->get('category_id'); $viewCategory = $app->input->get('view_category'); if ($category_id && $viewCategory) { $app->redirect('index.php?option=com_jeproshop&view=product&category_id=' . (int) $category_id . '&view_category=1'); } if (!JeproshopSettingModelSetting::getValue('stock_management')) { JError::raiseWarning(JText::_('List of products without available quantities for sale are not displayed because stock management is disabled.')); } $helper = new JeproshopHelper(); $this->assignRef('helper', $helper); $this->addToolBar(); $this->sideBar = JHtmlSideBar::render(); parent::display($tpl); }
public function initialize() { $app = JFactory::getApplication(); $context = JeproshopContext::getContext(); parent::initialize(); $category_id = $app->input->get('category_id'); $task = $app->input->get('task'); if ($category_id && $task != 'delete') { $this->category = new JeproshopCategoryModelCategory($category_id); } else { if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { $this->category = new JeproshopCategoryModelCategory($context->shop->category_id); } elseif (count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()) > 1 && JeproshopSettingModelSetting::getValue('multishop_feature_active') && count(JeproshopShopModelShop::getShops(true, null, true)) != 1) { $this->category = JeproshopCategoryModelCategory::getTopCategory(); } else { $this->category = new JeproshopCategoryModelCategory(JeproshopSettingModelSetting::getValue('root_category')); } } if (JeproshopTools::isLoadedObject($this->category, 'category_id') && !$this->category->isAssociatedToShop() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { $app->redirect('index.php?option=com_jeproshop&view=category&task=edit&category_id=' . (int) $context->shop->getCategoryId() . '&' . JeproshopTools::getCategoryToken() . '=1'); } }
/** * This metohd is allow to know if a feature is used or active * @since 1.5.0.1 * @return bool */ public static function isFeaturePublished() { return JeproshopSettingModelSetting::getValue('feature_feature_active'); }
if (isset($context->cookie->customer_id) && (int) $context->customer_id) { $customer = new JeproshopCustomerModelCustomer($context->cookie->customer_id); if (!JeproshopTools::isLoadedObject($customer)) { $context->cookie->logout(); } else { $customer->logged = TRUE; if ($customer->lang_id != $context->language->lang_id) { $customer->lang_id = $context->language->lang_id; $customer->update(); } } } if (!isset($customer) || !JeproshopTools::isLoadedObject($customer)) { $customer = new JeproshopCustomerModelCustomer(); if (JeproshopGroupModelGroup::isFeaturePublished()) { $customer->default_group_id = (int) JeproshopSettingModelSetting::getValue('unidentified_group'); } } $customer->guest_id = $context->cookie->guest_id; $context->customer = $customer; /** controller and redirection */ $controller = JFactory::getApplication()->input->get('view'); if ($controller) { if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controller.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php'; } else { $controller = ''; } $context->controller = JControllerLegacy::getInstance('Jeproshop' . $controller); $context->controller->initialize();
public static function getProducts($lang_id, $limit_start, $limit, $order_by = null, $order_way = null, $get_total = false, $published = true, $random = false, $random_number_products = 1, $check_access = true, JeproshopContext $context = null) { if (!$context) { $context = JeproshopContext::getContext(); } $db = JFactory::getDBO(); $app = JFactory::getApplication(); jimport('joomla.html.pagination'); //if ($check_access && !$context->controller->checkAccess($context->customer->customer_id, $category_id)){ return false; } if ($limit_start < 1) { $limit_start = 0; } if (empty($order_by)) { $order_by = 'position'; } else { /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */ $order_by = strtolower($order_by); } if (empty($order_way)) { $order_way = "DESC"; } $order_by_prefix = false; if ($order_by == 'product_id' || $order_by == 'date_add' || $order_by == 'date_upd') { $order_by_prefix = "product"; } elseif ($order_by == 'name') { $order_by_prefix = "product_lang"; } elseif ($order_by == 'manufacturer') { $order_by_prefix = "manufacturer"; $order_by = "name"; } elseif ($order_by == 'position') { $order_by_prefix = "product"; } if ($order_by == 'price') { $order_by = 'order_price'; } if (!JeproshopTools::isOrderBy($order_by) || !JeproshopTools::isOrderWay($order_way)) { die(JError::raiseError()); } $supplier_id = (int) $app->input->get('supplier_id'); /* Return only the number of products */ $query = "SELECT COUNT(product." . $db->quoteName('product_id') . ") AS total FROM " . $db->quoteName('#__jeproshop_product') . " AS product "; $query .= JeproshopShopModelShop::addSqlAssociation('product') . " WHERE product_shop." . $db->quoteName('visibility') . " IN ('both', 'catalog')"; $query .= " AND product_shop." . $db->quoteName('published') . " = 1 " . ($supplier_id ? " AND product.supplier_id = " . (int) $supplier_id : ""); $db->setQuery($query); $total = (int) $db->loadResult(); $number_days_new_product = JeproshopSettingModelSetting::getValue('number_days_new_product'); $query = "SELECT product.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.product_attribute_id) AS "; $query .= "product_attribute_id, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, product_lang." . $db->quoteName('description'); $query .= ", product_lang." . $db->quoteName('short_description') . ", product_lang." . $db->quoteName('available_now') . ", product_lang." . $db->quoteName('available_later'); $query .= ", product_lang." . $db->quoteName('link_rewrite') . ", product_lang." . $db->quoteName('meta_description') . ", product_lang." . $db->quoteName('meta_keywords'); $query .= ", product_lang." . $db->quoteName('meta_title') . ", product_lang." . $db->quoteName('name') . ", MAX(image_shop." . $db->quoteName('image_id') . " ) AS "; $query .= "image_id, image_lang." . $db->quoteName('legend') . ", manufacturer." . $db->quoteName('name') . " AS manufacturer_name, DATEDIFF(product_shop." . $db->quoteName('date_add'); $query .= ", DATE_SUB(NOW(), INTERVAL " . (JeproshopTools::isUnsignedInt($number_days_new_product) ? $number_days_new_product : 20) . "\tDAY)) > 0 AS new, product_shop.price AS"; $query .= " order_price FROM " . $db->quoteName('#__jeproshop_product') . " AS product " . JeproshopShopModelShop::addSqlAssociation('product') . " LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_product_attribute') . " AS product_attribute ON (product." . $db->quoteName('product_id') . " = product_attribute." . $db->quoteName('product_id'); $query .= ") " . JeproshopShopModelShop::addSqlAssociation('product_attribute', false, 'product_attribute_shop.`default_on` = 1'); $query .= JeproshopProductModelProduct::sqlStock('product', 'product_attribute_shop', false, $context->shop) . " LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang'); $query .= " AS product_lang ON (product." . $db->quoteName('product_id') . " = product_lang." . $db->quoteName('product_id') . " AND product_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . JeproshopShopModelShop::addSqlRestrictionOnLang('product_lang'); $query .= ") LEFT JOIN " . $db->quoteName('#__jeproshop_image') . " AS image ON (image." . $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . ") " . JeproshopShopModelShop::addSqlAssociation('image', false, 'image_shop.cover=1') . " LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_image_lang') . " AS image_lang ON (image_shop." . $db->quoteName('image_id') . " = image_lang." . $db->quoteName('image_id') . " AND image_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_manufacturer') . " AS manufacturer ON manufacturer." . $db->quoteName('manufacturer_id') . " = product." . $db->quoteName('manufacturer_id') . "\tWHERE product_shop." . $db->quoteName('shop_id') . " = " . (int) $context->shop->shop_id; $query .= " AND product_shop." . $db->quoteName('published') . " = 1 AND product_shop." . $db->quoteName('visibility') . " IN ('both', 'catalog') "; $query .= ($supplier_id ? " AND product.supplier_id = " . (int) $supplier_id : "") . " GROUP BY product_shop.product_id"; if ($random === true) { $query .= " ORDER BY RAND() LIMIT " . (int) $random_number_products; } else { //$query .= " ORDER BY " . (!empty($order_by_prefix) ? $order_by_prefix. "." : "") . $db->quoteName($order_by); $query .= " " . $order_way . " LIMIT " . (int) $limit_start . ", " . (int) $limit; } $db->setQuery($query); $result = $db->loadObjectList(); if ($order_by == 'order_price') { JeproshopTools::orderbyPrice($result, $order_way); } if (!$result) { return array(); } self::$_pagination = new JPagination($total, $limit_start, $limit); /* Modify SQL result */ return JeproshopProductModelProduct::getProductsProperties($lang_id, $result); }
public function __construct($attribute_group_id = null, $lang_id = null, $shop_id = null) { if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== FALSE ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->get_shop_from_context = false; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($attribute_group_id) { $cache_id = 'jeproshop_attribute_group_model_' . (int) $attribute_group_id; if (!JeproshopCache::isStored($cache_id)) { $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_attribute_group') . " AS attribute_group "; $where = " WHERE attribute_group." . $db->quoteName('attribute_group_id') . " = " . (int) $attribute_group_id; //Get Language information if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_group_lang') . " AS attribute_group_lang ON (attribute_group."; $query .= $db->quoteName('attribute_group_id') . " = attribute_group_lang." . $db->quoteName('attribute_group_id') . " AND "; $query .= "attribute_group_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; if ($this->shop_id && !empty($this->multiLangShop)) { $where .= " AND attribute_group_lang." . $db->quoteName('shop_id') . " = " . (int) $shop_id; } } // Get Shop Information if (JeproshopShopModelShop::isTableAssociated('attribute_group')) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_group_shop') . " AS attribute_group_shop ON (attribute_group."; $query .= $db->quoteName('attribute_group_id') . " = attribute_group_shop." . $db->quoteName('attribute_group_id') . " AND attribute_group_shop."; $query .= $db->quoteName('shop_id') . " = " . (int) $this->shop_id . ")"; } $db->setQuery($query . $where); $attributeGroupData = $db->loadObject(); if ($attributeGroupData) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_attribute_group_lang') . " WHERE " . $db->quoteName('attribute_group_id') . " = "; $query .= (int) $attribute_group_id; // . (($this->shop_id && $this->isMultiLangShop()) ? " AND " . $db->quoteName('shop_id') . " = " . (int)$this->shop_id : ""); $db->setQuery($query); $attributeGroupDataLang = $db->loadObjectList(); if ($attributeGroupDataLang) { foreach ($attributeGroupDataLang as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'attribute_group_id') { if (!isset($attributeGroupData->{$key}) || !is_array($attributeGroupData->{$key})) { $attributeGroupData->{$key} = array(); } $attributeGroupData->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $attributeGroupData); } } else { $attributeGroupData = JeproshopCache::retrieve($cache_id); } if ($attributeGroupData) { $this->attribute_group_id = (int) $attribute_group_id; foreach ($attributeGroupData as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } }
$life_time = time() + max(JeproshopSettingModelSetting::getValue('bo_life_time'), 1) * 3600; $context->cookie = new JeproshopCookie('jeproshop_admin', '', $life_time); /** @var employee */ $context->employee = new JeproshopEmployeeModelEmployee(JFactory::getUser()->id); $context->cookie->employee_id = $context->employee->employee_id; /** Loading default country */ $context->country = new JeproshopCountryModelCountry(JeproshopSettingModelSetting::getValue('default_country'), JeproshopSettingModelSetting::getValue('default_lang')); /** if the cookie stored language is not an available language, use default language */ if (isset($context->cookie->lang_id) && $context->cookie->lang_id) { $language = new JeproshopLanguageModelLanguage($context->cookie->lang_id); } if (!isset($language) || !JeproshopTools::isLoadedObject($language, 'lang_id')) { $language = new JeproshopLanguageModelLanguage(JeproshopSettingModelSetting::getValue('default_lang')); } $context->language = $language; $currency_id = $context->cookie->currency_id ? $context->cookie->currency_id : JeproshopSettingModelSetting::getValue('default_currency'); $context->currency = new JeproshopCurrencyModelCurrency($currency_id); /** controller and redirection */ $controller = JFactory::getApplication()->input->get('view'); //if($controller == 'orders'){ $controller = 'order'; } if ($controller) { if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controller.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php'; } else { $controller = ''; } $context->controller = JControllerLegacy::getInstance('Jeproshop' . $controller); $context->controller->initialize(); $context->controller->initContent(); } else {
/** * Update context after customer creation * @param JeproshopCustomerModelCustomer $customer Created customer * @param JeproshopContext $context */ protected function updateContext(JeproshopCustomerModelCustomer $customer, JeproshopContext $context = null) { if (!isset($context)) { $context = JeproshopContext::getContext(); } $data = JRequest::get('post'); $context->customer = $customer; $confirmation = 1; $context->cookie->customer_id = (int) $customer->customer_id; $context->cookie->customer_lastname = $customer->lastname; $context->cookie->customer_firstname = $customer->firstname; $context->cookie->passwd = $customer->passwd; $context->cookie->logged = 1; // if register process is in two steps, we display a message to confirm account creation if (!JeproshopSettingModelSetting::getValue('registration_process_type')) { $context->cookie->account_created = 1; } $customer->logged = 1; $context->cookie->email = $customer->email; $context->cookie->is_guest = isset($data['is_new_customer']) ? !$data['is_new_customer'] : 0; // Update cart address $context->cart->secure_key = $customer->secure_key; }
public function __construct($manufacturer_id = null, $lang_id = null) { parent::__construct(); $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($manufacturer_id) { $cache_id = 'jeproshop_manufacturer_model_' . $manufacturer_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer') . " AS j_manufacturer "; $where = ""; /** get language information **/ if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang "; $query .= "ON (j_manufacturer.manufacturer_id = manufacturer_lang.manufacturer_id AND manufacturer_lang.lang_id = " . (int) $lang_id . ") "; /* if($this->shop_id && !(empty($this->multiLangShop))){ $where = " AND manufacturer_lang.shop_id = " . $this->shop_id; }*/ } /** Get shop informations ** / if(JeproshopShopModelShop::isTableAssociated('manufacturer')){ $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_shop') . " AS manufacturer_shop ON ("; $query .= "j_manufacturer.manufacturer_id = manufacturer_shop.manufacturer_id AND manufacturer_shop.shop_id = " . (int) $this->shop_id . ")"; }*/ $query .= " WHERE j_manufacturer.manufacturer_id = " . (int) $manufacturer_id . $where; $db->setQuery($query); $manufacturer_data = $db->loadObject(); if ($manufacturer_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer_lang'); $query .= " WHERE manufacturer_id = " . (int) $manufacturer_id; $db->setQuery($query); $manufacturer_lang_data = $db->loadObjectList(); if ($manufacturer_lang_data) { foreach ($manufacturer_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'manufacturer_id') { if (!isset($manufacturer_data->{$key}) || !is_array($manufacturer_data->{$key})) { $manufacturer_data->{$key} = array(); } $manufacturer_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $manufacturer_data); } } else { $manufacturer_data = JeproshopCache::retrieve($cache_id); } if ($manufacturer_data) { $manufacturer_data->manufacturer_id = $manufacturer_id; foreach ($manufacturer_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } $this->link_rewrite = $this->getLink(); $this->image_dir = COM_JEPROSHOP_MANUFACTURER_IMAGE_DIRECTORY; }
/** * @static * @return bool */ public static function isFeaturePublished() { static $is_feature_active = null; if ($is_feature_active === null) { $is_feature_active = (bool) JeproshopSettingModelSetting::getValue('cart_rule_feature_active'); } return $is_feature_active; }
/** * Assign address var to smarty */ protected function assignAddressFormat() { $addressItems = array(); $addressFormat = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields(JeproshopSettingModelSetting::getValue('default_country'), false, true); $requireFormFieldsList = JeproshopAddressFormatModelAddressFormat::$requireFormFieldsList; foreach ($addressFormat as $addressLine) { foreach (explode(' ', $addressLine) as $addressItem) { $addressItems[] = trim($addressItem); } } // Add missing require fields for a new user subscription form foreach ($requireFormFieldsList as $fieldName) { if (!in_array($fieldName, $addressItems)) { $addressItems[] = trim($fieldName); } } foreach (array('invoice', 'delivery') as $addressType) { $this->assignRef($addressType . '_address_fields', $addressFormat); $this->assignRef($addressType . '_all_fields', $addressItems); } }
echo $customer_view_link; ?> " ><?php echo ucfirst($customer->firstname); ?> </a></td> <td class="nowrap hidden-phone" width="25%" ><?php echo $customer->email; ?> </td> <td class="nowrap " width="6%" ><?php echo JeproshopTools::displayPrice($customer->total_spent); ?> </td> <?php if (JeproshopSettingModelSetting::getValue('enable_b2b_mode')) { ?> <td class="nowrap" width="5" ><?php if (isset($customer->website)) { ?> <a href="<?php echo $customer->website; ?> " ><?php } echo ucfirst($customer->company); if (isset($customer->website)) { ?> </a><?php } ?>
protected function checkMobileContext() { // Check mobile context $app = JFactory::getApplication(); if ($app->input->get('no_mobile_theme')) { JeproshopContext::getContext()->cookie->no_mobile = true; if (JeproshopContext::getContext()->cookie->guest_id) { $guest = new JeproshopGuestModelGuest(JeproshopContext::getContext()->cookie->guest_id); $guest->mobile_theme = false; $guest->update(); } } elseif ($app->input->get('mobile_theme_ok')) { JeproshopContext::getContext()->cookie->no_mobile = false; if (JeproshopContext::getContext()->cookie->guest_id) { $guest = new JeproshopGuestModelGest(JeproshopContext::getContext()->cookie->guest_id); $guest->mobile_theme = true; $guest->update(); } } return isset($_SERVER['HTTP_USER_AGENT']) && isset(JeproshopContext::getContext()->cookie) && (bool) JeproshopSettingModelSetting::getValue('allow_mobile_device') && @filemtime(_PS_THEME_MOBILE_DIR_) && !JeproshopContext::getContext()->cookie->no_mobile; }
</td> <td><?php echo $line->carrier_name; ?> </td> <td data-value="<?php if ($line->weight > 0) { echo $line->weight; } else { ?> 0<?php } ?> " ><?php if ($line->weight > 0) { echo $line->weight . ' ' . JeproshopSettingModelSetting::getValue('weight_unit'); } else { ?> -<?php } ?> </td> <td data-value="<?php if ($this->order->getTaxCalculationMethod() == COM_JEPROSHOP_TAX_INCLUDED) { echo $line->shipping_cost_tax_incl; } else { echo $line->shipping_cost_tax_excl; } ?> " > <?php
/** * Check if order is free * @return boolean * / public function checkFreeOrder(){ $context = JeproshopContext::getContext(); if ($context->cart->getOrderTotal() <= 0) { $order = new JeproshopFreeOrderModelFreeOrder(); $order->free_order_class = true; $order->validateOrder($context->cart->cart_id, Configuration::get('PS_OS_PAYMENT'), 0, Tools::displayError('Free order', false), null, array(), null, false, $context->cart->secure_key); return (int)JeproshopOrderModelOrder::getOrderByCartId($context->cart->cart_id); } return false; } public function assignCarrier(){ $view = JFactory::getDBO(); $context = JeproshopContext::getContext(); $address = new JeproshopAddressModelAddress($context->cart->address_delivery_id); $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId($address->address_id); $carriers = $context->cart->simulateCarriersOutput(null, true); $checked = $context->cart->simulateCarrierSelectedOutput(false); $delivery_option_list = $context->cart->getDeliveryOptionList(); $delivery_option = $context->cart->getDeliveryOption(null, false); $this->setDefaultCarrierSelection($delivery_option_list); $view->assignRef('address_collection', $context->cart->getAddressCollection()); $view->assignRef('delivery_option_list', $delivery_option_list); $view->assignRef('carriers', $carriers); $view->assignRef('checked', $checked); $view->assignRef('delivery_option', $delivery_option); $vars = array( /*'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array( 'carriers' => $carriers, 'checked' => $checked, 'delivery_option_list' => $delivery_option_list, 'delivery_option' => $delivery_option ))* / ); JeproshopCartModelCart::addExtraCarriers($vars); $view->assignRef('extra_carriers', $vars); } /** * Decides what the default carrier is and update the cart with it * * @todo this function must be modified - id_carrier is now delivery_option * * @param array $carriers * * @deprecated since 1.5.0 * * @return number the id of the default carrier * / protected function setDefaultCarrierSelection($carriers) { $context = JeproshopContext::getContext(); if (!$context->cart->getDeliveryOption(null, true)) $context->cart->setDeliveryOption($context->cart->getDeliveryOption()); }*/ public function globalInitialization() { $app = JFactory::getApplication(); $view = $app->input->get('view'); $viewClass = $this->getView($view, JFactory::getDocument()->getType()); $context = JeproshopContext::getContext(); $this->isLogged = (bool) ($context->customer->customer_id && JeproshopCustomerModelCustomer::customerIdExistsStatic((int) $context->cookie->customer_id)); parent::initialize(); /* Disable some cache related bugs on the cart/order */ header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); if (!$context->customer->isLogged(true) && $this->useMobileTheme() && $app->input->get('step')) { $app->redirect(JRoute::_('index.php?option=com_jeproshop&view=authentication&lang_id=' . $context->language->lang_id, true, 1)); } // Redirect to the good order process $task = $app->input->get('task', ''); $order_process_type = JeproshopSettingModelSetting::getValue('order_process_type'); if ($order_process_type == 'standard' && ($task != '' || $task != 'display')) { //$app->redirect('index.php?option=com_jeproshop&view=order'); } if ($order_process_type == 'page_checkout' && $task != 'opc') { $step = $app->input->get('step'); if (isset($step) && $step == 3) { $app->redirect('index.php?option=com_jeproshop&view=order&task=opc&isPaymentStep=true'); } $app->redirect('index.php?option=com_jeproshop&view=order&task=opc'); } $catalog_mode = JeproshopSettingModelSetting::getValue('catalog_mode'); if ($catalog_mode) { $this->has_errors = true; JError::raiseError(500, JText::_('COM_JEPROSHOP_THIS_STORE_DOES_NOT_ACCEPT_NEW_ORDER_MESSAGE')); } $order_id = (int) $app->input->get('order_id'); $currentTask = $app->input->get('task'); if ($currentTask == 'submitReorder' && $order_id) { $oldCart = new JeproshopCartModelCart(JeproshopOrderModelOrder::getStaticCartId($order_id, $context->customer->customer_id)); $duplication = $oldCart->duplicate(); if (!$duplication || !JeproshopTools::isLoadedObject($duplication->cart, 'cart_id')) { $this->has_errors = true; Tools::displayError('Sorry. We cannot renew your order.'); } else { if (!$duplication->success) { $this->has_errors = true; Tools::displayError('Some items are no longer available, and we are unable to renew your order.'); } else { $context->cookie->cart_id = $duplication->cart->cart_id; $context->cookie->write(); if ($order_process_type == 'page_checkout') { $app->redirect('index.php?option=com_jeproshop&view=order&task=opc'); } $app->redirect('index.php?option=com_jeproshop&view=order'); } } } $viewClass->assignRef('order_process_type', $order_process_type); $nbProducts = $context->cart->numberOfProducts(); if ($nbProducts) { if (JeproshopCartRuleModelCartRule::isFeaturePublished()) { if (Tools::isSubmit('submitAddDiscount')) { if (!($code = trim(Tools::getValue('discount_name')))) { $this->has_errors = true; JError::raiseError('You must enter a voucher code.'); } elseif (!Validate::isCleanHtml($code)) { $this->has_errors = true; JEroor::raiseError('The voucher code is invalid.'); } else { $cartRule = new JeproshopCartRuleModelCartRule(JeproshopCartRuleModelCartRule::getIdByCode($code)); if ($cartRule && JeproshopTools::isLoadedObject($cartRule, 'cart_rule_id')) { if ($error = $cartRule->checkValidity($context, false, true)) { $this->has_errors = true; JError::raiseError(500, $error); } else { $context->cart->addCartRule($cartRule->cart_rule_id); if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { Tools::redirect('index.php?controller=order-opc&addingCartRule=1'); } Tools::redirect('index.php?controller=order&task=adding_cart_rule'); } } else { $this->has_errors = true; Tools::displayError('This voucher does not exists.'); } } $discountName = JeproshopTools::safeOutput($code); $viewClass->assignRef('discount_name', $discountName); } elseif (($cart_rule_id = (int) Tools::getValue('delete_discount')) && JeproshopTools::isUnsignedId($cart_rule_id)) { $context->cart->removeCartRule($cart_rule_id); $app->redirect('index.php?option=com_jeproshop&view=order&task=opc'); } } /* Is there only virtual product in cart */ if ($isVirtualCart = $context->cart->isVirtualCart()) { $this->setNoCarrier(); } } //$viewClass->assignRef('back', JTools::safeOutput(Tools::getValue('back')));*/ }
public static function isFeaturePublished() { static $feature_published = null; if ($feature_published === null) { $db = JFactory::getDBO(); $query = "SELECT COUNT(*) FROM " . $db->quoteName('#__jeproshop_shop'); $db->setQuery($query); $feature_published = JeproshopSettingModelSetting::getValue('multishop_feature_active') && $db->loadResult() > 1; } return $feature_published; }
protected function sortProducts() { $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); $stock_management = (int) JeproshopSettingModelSetting::getValue('stock_management'); $order_by_values = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7 => 'reference'); $order_way_values = array(0 => 'asc', 1 => 'desc'); $this->orderBy = $app->getUserStateFromRequest($option, $view, 'order_by', 'order_by', JeproshopSettingModelSetting::getValue('default_order_by'), 'string'); $this->orderWay = $app->getUserStateFromRequest($option, $view, 'order_way', 'order_way', JeproshopSettingModelSetting::getValue('default_order_way'), 'string'); if (!in_array($this->orderBy, $order_by_values)) { $this->orderBy = $order_by_values[0]; } if (!in_array($this->orderWay, $order_way_values)) { $this->orderWay = $order_way_values[0]; } $this->assignRef('order_by_default', $order_by_values[(int) JeproshopSettingModelSetting::getValue('default_order_way')]); $this->assignRef('order_way_position', $order_way_values[(int) JeproshopSettingModelSetting::getValue('default_order_way')]); // Deprecated: orderwayposition $this->assignRef('default_order_way', $order_way_values[(int) JeproshopSettingModelSetting::getValue('default_order_way')]); $this->assignRef('stock_management', $stock_management); }
/** * Return manufacturers * * @param boolean $get_nb_products [optional] return products numbers for each * @param int $lang_id * @param bool $published * @param int $p * @param int $n * @param bool $all_group * @return array Manufacturers */ public static function getManufacturers($get_nb_products = false, $lang_id = 0, $published = true, $p = false, $n = false, $all_group = false, $group_by = false) { if (!$lang_id) { $lang_id = (int) JeproshopSettingModelSetting::getValue('default_lang'); } if (!JeproshopGroupModelGroup::isFeaturePublished()) { $all_group = true; } $db = JFactory::getDBO(); $query = "SELECT manufacturer.*, manufacturer_lang." . $db->quoteName('description') . ", manufacturer_lang."; $query .= $db->quoteName('short_description') . " FROM " . $db->quoteName('#__jeproshop_manufacturer') . " AS "; $query .= "manufacturer " . JeproshopShopModelShop::addSqlAssociation('manufacturer') . " INNER JOIN "; $query .= $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang ON (manufacturer."; $query .= $db->quoteName('manufacturer_id') . " = manufacturer_lang." . $db->quoteName('manufacturer_id'); $query .= " AND manufacturer_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; $query .= $published ? " WHERE manufacturer." . $db->quoteName('published') . " = 1" : ""; $query .= ($group_by ? " GROUP BY manufacturer." . $db->quoteName('manufacturer_id') : "") . " ORDER BY "; $query .= "manufacturer." . $db->quoteName('name') . " ASC " . ($p ? " LIMIT " . ((int) $p - 1) * (int) $n . ", " . (int) $n : ""); $db->setQuery($query); $manufacturers = $db->loadObjectList(); if ($manufacturers === false) { return false; } /* if ($get_nb_products) { $sql_groups = ''; if (!$all_group) { $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); } foreach ($manufacturers as $key => $manufacturer) { $manufacturers[$key]['nb_products'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' WHERE p.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].' AND product_shop.`visibility` NOT IN ("none") '.($active ? ' AND product_shop.`active` = 1 ' : '').' '.($all_group ? '' : ' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sql_groups.' )')); } } */ $total_manufacturers = count($manufacturers); $rewrite_settings = (int) JeproshopSettingModelSetting::getValue('rewrite_settings'); for ($i = 0; $i < $total_manufacturers; $i++) { $manufacturers[$i]->link_rewrite = $rewrite_settings ? JeproshopValidator::link_rewrite($manufacturers[$i]->name) : 0; } return $manufacturers; }
/** * getHttpHost return the <b>current</b> host used, with the protocol (http or https) if $http is true * This function should not be used to choose http or https domain name. * Use JeproshopTools::getShopDomain() or JeproshopTools::getShopSslDomain instead * * @param bool $http * @param bool $entities * @param bool $ignore_port * @return string */ public static function getHttpHost($http = false, $entities = false, $ignore_port = false) { $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; if ($ignore_port && ($pos = strpos($host, ':'))) { $host = substr($host, 0, $pos); } if ($entities) { $host = htmlspecialchars($host, ENT_COMPAT, 'UTF-8'); } if ($http) { $host = (JeproshopSettingModelSetting::getValue('enable_ssl') ? 'https://' : 'http://') . $host; } return $host; }
public function update_status() { $app = JFactory::getApplication(); $order_status_id = $app->input->get('order_status_id'); $order_id = $app->input->get('order_id'); $order = new JeproshopOrderModelOrder($order_id); $context = JeproshopContext::getContext(); if (!JeproshopTools::isLoadedObject($order, 'order_id')) { echo '<p>' . JText::_('COM_JEPROSHOP_THE_ORDER_CANNOT_BE_FOUND_WITH_IN_YOUR_DATABASE_MESSAGE') . '</p>'; } if ($this->viewAccess()) { $orderStatus = new JeproshopOrderStatusModelOrderStatus($order_status_id); if (!JeproshopTools::isLoadedObject($orderStatus, 'order_status_id')) { echo JText::_('COM_JEPROSHOP_THE_ORDER_STATUS_CANNOT_BE_FOUND_WITH_IN_YOUR_DATABASE_MESSAGE'); } else { $order = new JeproshopOrderModelOrder(); $currentOrderStatus = $order->getCurrentOrderStatus(); if ($currentOrderStatus->order_status_id != $orderStatus) { // Create a order history $orderHistory = new JeproshopOrderHistoryModelOrderHistory(); $orderHistory->order_id = $order->order_id; $orderHistory->employee_id = (int) $context->employee->employee_id; $useExistingPayment = false; if (!$order->hasInvoice()) { $useExistingPayment = true; } $orderHistory->changeOrderStatusId((int) $orderStatus->order_status_id, $order, $useExistingPayment); $carrier = new JeproshopCarrierModelCarrier($order->carrier_id, $order->lang_id); $templateVars = array(); if ($orderHistory->order_status_id == JeproshopSettingModelSetting::getValue('order_status_shipping') && $order->shipping_number) { } if ($orderHistory->addWithEmail(true, $templateVars)) { // synchronizes quantities if needed... if (JeproshopSettingModelSetting::getValue('advanced_stock_management')) { foreach ($order->getProducts() as $product) { if (JeproshopStockAvailableModelStockAvailable::dependsOnStock($product->product_id)) { JeproshopStockAvailableModelStockAvailable::synchronize($product->product_id, (int) $product->sho_id); } } } $app->redirect('index.php?option=com_jeproshop&view=order&task=view&order_id=' . (int) $order->order_id . '&' . JeproshopTools::getOrderToken() . '=1'); } echo JText::_('COM_JEPROSHOP_AN_ERROR_OCCURRED_WHILE_CHANGING_ORDER_STATUS_OR_WE_WERE_UNABLE_TO_SEND_AN_EMAIL_TO_THE_CUSTOMER_MESSAGE'); } else { echo JText::_('COM_JEPROSHOP_THE_ORDER_HAS_ALREADY_BEEN_ASSIGNED_THIS_STATUS_MESSAGE'); } } } else { echo JText::_('COM_JEPROSHOP_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THIS_ORDER_MESSAGE'); } }
public function renderEditForm($tpl = null) { $this->loadObject(true); $app = JFactory::getApplication(); if (!isset($this->context)) { $this->context = JeproshopContext::getContext(); } $shop_id = JeproshopContext::getContext()->shop->shop_id; $selected_categories = array(isset($this->context->controller->category->parent_id) && $this->context->controller->category->isParentCategoryAvailable($shop_id) ? (int) $this->context->controller->category->parent_id : $app->input->get('parent_id', JeproshopCategoryModelCategory::getRootCategory()->category_id)); $unidentified = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('unidentified_group')); $guest = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('guest_group')); $default = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('customer_group')); $unidentified_group_information = '<b>' . $unidentified->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WITHOUT_A_VALID_CUSTOMER_ACCOUNT_MESSAGE'); $guest_group_information = '<b>' . $guest->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_CUSTOMER_WHO_PLACED_AN_ORDER_WITH_THE_GUEST_CHECKOUT_MESSAGE'); $default_group_information = '<b>' . $default->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WHO_HAVE_CREATED_AN_CREATED_AN_ACCOUNT_ON_THIS_SITE_MESSAGE'); $this->assignRef('unidentified_group_information', $unidentified_group_information); $this->assignRef('guest_group_information', $guest_group_information); $this->assignRef('default_group_information', $default_group_information); $image = COM_JEPROSHOP_CATEGORY_IMAGE_DIR . $this->context->controller->category->category_id . '.jpg'; $image_url = JeproshopImageManager::thumbnail($image, 'category_' . $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true, true); $imageSize = file_exists($image) ? filesize($image) / 1000 : false; $shared_category = JeproshopTools::isLoadedObject($this->context->controller->category, 'category_id') && $this->context->controller->category->hasMultishopEntries(); $this->assignRef('shared_category', $shared_category); $allow_accented_chars_url = (int) JeproshopSettingModelSetting::getValue('allow_accented_chars_url'); $this->assignRef('allow_accented_chars_url', $allow_accented_chars_url); //$this->assignRef('selected_categories', $selected_categories); $categories_tree = new JeproshopCategoriesTree('jform_categories_tree', JText::_('COM_JEPROSHOP_CATEGORIES_LABEL'), null, $this->context->language->lang_id); $categories_tree->setTreeTemplate('associated_categories')->setSelectedCategories($selected_categories)->setUseCheckBox(true)->setInputName('parent_id'); $categories_data = $categories_tree->render(); $this->assignRef('categories_tree', $categories_data); $image = JeproshopImageManager::thumbnail(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . '.jpg', 'category_' . (int) $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true); $this->assignRef('image', $image ? $image : false); $size = $image ? filesize(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . 'jpg') / 1000 : false; $this->assignRef('size', $size); $category_group_ids = $this->context->controller->category->getGroups(); $groups = JeproshopGroupModelGroup::getGroups($this->context->language->lang_id); //if empty $carrier_groups_ids : object creation : we set the default groups if (empty($category_group_ids)) { $preSelected = array(JeproshopSettingModelSetting::getValue('unidentified_group'), JeproshopSettingModelSetting::getValue('guest_group'), JeproshopSettingModelSetting::getValue('customer_group')); $category_group_ids = array_merge($category_group_ids, $preSelected); } foreach ($groups as $group) { $groupBox = $app->input->get('group_box_' . $group->group_id, in_array($group->group_id, $category_group_ids)); $this->assignRef('group_box_' . $group->group_id, $groupBox); } $is_root_category = (bool) $app->input->get('is_root_category'); $this->assignRef('is_root_category', $is_root_category); $helper = new JeproshopHelper(); $this->assignRef('helper', $helper); $this->assignRef('groups', $groups); $this->addToolBar(); $this->sideBar = JHtmlSideBar::render(); parent::display($tpl); }
public function getOrderList(JeproshopContext $context = NULL) { jimport('joomla.html.pagination'); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); if (!$context) { $context = JeproshopContext::getContext(); } $select = " ord.currency_id, ord.order_id AS pdf_id, CONCAT(LEFT(customer." . $db->quoteName('firstname') . ", 1), '. ',"; $select .= " customer." . $db->quoteName('lastname') . ") AS " . $db->quoteName('customer_name') . ", order_status_lang."; $select .= $db->quoteName('name') . " AS " . $db->quoteName('order_status_name') . ", order_status." . $db->quoteName('color'); $select .= ", IF((SELECT COUNT(orders.order_id) FROM " . $db->quoteName('#__jeproshop_orders') . " AS orders WHERE orders.customer_id "; $select .= "= ord.customer_id) > 1, 0, 1) AS new, country_lang.name as country_name, IF(ord.valid, 1, 0) badge_success "; $join = " LEFT JOIN " . $db->quoteName('#__jeproshop_customer') . " AS customer ON (customer." . $db->quoteName('customer_id'); $join .= " = ord." . $db->quoteName('customer_id') . ") INNER JOIN " . $db->quoteName('#__jeproshop_address') . " AS address "; $join .= " ON address.address_id = ord.address_delivery_id INNER JOIN " . $db->quoteName('#__jeproshop_country') . " AS country "; $join .= " ON address.country_id = country.country_id INNER JOIN " . $db->quoteName('#__jeproshop_country_lang') . " AS country_lang"; $join .= " ON (country." . $db->quoteName('country_id') . " = country_lang." . $db->quoteName('country_id') . " AND country_lang."; $join .= $db->quoteName('lang_id') . " = " . (int) $context->language->lang_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_order_status'); $join .= " AS order_status ON (order_status." . $db->quoteName('order_status_id') . " = ord." . $db->quoteName('current_status') . ") LEFT JOIN "; $join .= $db->quoteName('#__jeproshop_order_status_lang') . " order_status_lang ON (order_status." . $db->quoteName('order_status_id') . " = "; $join .= " order_status_lang." . $db->quoteName('order_status_id') . " AND order_status_lang." . $db->quoteName('lang_id') . " = "; $join .= (int) $context->language->lang_id . ") "; $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $limit_start = $app->getUserStateFromRequest($option . $view . '.limit_start', 'limit_start', 0, 'int'); $order_by = $app->getUserStateFromRequest($option . $view . '.order_by', 'order_by', 'order_id', 'string'); $order_way = $app->getUserStateFromRequest($option . $view . '.order_way', 'order_way', 'DESC', 'string'); $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int'); $deleted = false; /* Manage default params values */ $use_limit = true; if ($limit === false) { $use_limit = false; } $select_shop = ", shop.shop_name AS shop_name "; $join_shop = " LEFT JOIN " . $db->quoteName('#__jeproshop_shop') . " AS shop ON ord.shop_id = shop.shop_id "; $where_shop = JeproshopShopModelShop::addSqlRestriction(JeproshopShopModelShop::SHARE_ORDER, 'ord', 'shop'); if (JeproshopCountryModelCountry::isCurrentlyUsed()) { $query = "SELECT DISTINCT country.country_id, country_lang." . $db->quoteName('name') . " FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord "; $query .= " INNER JOIN " . $db->quoteName('#__jeproshop_address') . " AS address ON address.address_id = ord.address_delivery_id INNER JOIN " . $db->quoteName('#__jeproshop_country'); $query .= " AS country ON address.country_id = country.country_id INNER JOIN " . $db->quoteName('#__jeproshop_country_lang') . " AS country_lang ON (country." . $db->quoteName('country_id'); $query .= " = country_lang." . $db->quoteName('country_id') . " AND country_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") ORDER BY country_lang.name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); $shopLinkType = 'shop'; } $where = ""; if ($this->multishop_context && JeproshopShopModelShop::isTableAssociated('order')) { if (JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_ALL || !$context->employee->isSuperAdmin()) { if (JeproshopShopModelShop::isFeaturePublished() && $test_join && JeproshopShopModelShop::isTableAssociated('order')) { $where .= " AND ord.order_id IN (SELECT order_shop.shop_id FROM " . $db->quoteName('#__jeproshop_order_shop') . " AS order_shop WHERE order_shop.shop_id IN (" . implode(', ', JeproshopShopModelShop::getContextListShopIds()) . "))"; } } } $lang_join = ""; /*if($lang_id){ $lang_join = " LEFT JOIN " . $db->quoteName('#__jeproshop_order'); } */ do { $query = "SELECT SQL_CALC_FOUND_ROWS ord." . $db->quoteName('order_id') . " AS pdf_id, ord." . $db->quoteName('reference') . ", ord." . $db->quoteName('customer_id'); if (JeproshopSettingModelSetting::getValue('enable_b2b_mode')) { $query .= ", customer." . $db->quoteName('company'); } $query .= ", " . $db->quoteName('total_paid_tax_incl') . ", " . $db->quoteName('payment') . ", ord." . $db->quoteName('date_add') . " AS date_add, ord."; $query .= $db->quoteName('currency_id') . ", order_status." . $db->quoteName('order_status_id') . ", " . $select . $select_shop; $query .= " FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord " . $lang_join . $join . $join_shop . " WHERE 1 " . $where; $query .= ($deleted ? " AND ord." . $db->quoteName('deleted') . " = 0 " : "") . (isset($filter) ? $filter : "") . $where_shop; $query .= (isset($group) ? $group : "") . " ORDER BY " . (str_replace('`', '', $order_by) == 'order_id' ? "ord." : ""); $query .= $order_by . " " . $order_way; $db->setQuery($query); $total = count($db->loadObjectList()); $query .= $use_limit === true ? " LIMIT " . (int) $limit_start . ", " . (int) $limit : ""; $db->setQuery($query); $orders = $db->loadObjectList(); if ($use_limit == true) { $limit_start = (int) $limit_start - (int) $limit; if ($limit_start < 0) { break; } } else { break; } } while (empty($orders)); $this->pagination = new JPagination($total, $limit_start, $limit); return $orders; }
/** * Returns address format by country * * @param $country_id * @return String field address format */ public function getFormat($country_id) { $out = $this->getFormatFromDataBase($country_id); if (empty($out)) { $out = $this->getFormatFromDataBase(JeproshopSettingModelSetting::getValue('default_country')); } return $out; }
</label> </p> <p class="checkbox" id="spanShippingBack" style="display:none;"> <label for="shippingBack"> <input type="checkbox" id="shippingBack" name="shippingBack" /> <?php echo JText::_('COM_JEPROSHOP_REPAY_SHIPPING_COSTS_LABEL'); ?> </label> </p> <?php } ?> </div> <?php if (!$this->order->hasBeenDelivered() || $this->order->hasBeenDelivered() && JeproshopSettingModelSetting::getValue('return_order')) { ?> <div class="row"> <input type="submit" name="cancelProduct" value="<?php if ($this->order->hasBeenDelivered()) { echo JText::_('COM_JEPROSHOP_RETURN_PRODUCTS_LABEL'); } elseif ($this->order->hasBeenPaid()) { echo JText::_('COM_JEPROSHOP_REFUND_PRODUCTS_LABEL'); } else { echo JText::_('COM_JEPROSHOP_CANCEL_PRODUCTS_LABEL'); } ?> " class="btn btn-default" /> </div> <?php }
<div class="control-group" > <div class="control-label" ><label title="<?php echo JText::_('COM_JEPROSHOP_MAX_WEIGHT_TITLE_DESC'); ?> " ><?php echo JText::_('COM_JEPROSHOP_MAX_WEIGHT_LABEL'); ?> </label></div> <div class="controls" > <div class="input-append" > <input type="text" id="jform_max_weight" name="jform[max_weight]" class="input-small" value="<?php echo $this->carrier->max_weight; ?> " /> <a class="btn btn-primary" href="" ><label ><?php echo JeproshopSettingModelSetting::getValue('weight_unit'); ?> </label></a> </div> </div> </div> <div class="control-group" > <div class="control-label" ><label title="<?php echo JText::_('COM_JEPROSHOP_MARK_THE_GROUPS_THAT_ALLOWED_ACCESS_TO_THIS_CARRIER_TITLE_DESC'); ?> " ><?php echo JText::_('COM_JEPROSHOP_ASSOCIATED_GROUPS_LABEL'); ?> </label></div> <div class="controls" > <table class="table table-bordered" style="width:500px;">