name = 'privatesales_salemenu'; $this->tab = 'pricing_promotion'; $this->author = 'Antadis'; $this->version = '1.0'; parent::__construct(); $this->displayName = $this->l('Private Sales Sale menu'); $this->description = $this->l('Adds a list of the current private sales'); } public function install() { if(!Module::isInstalled('privatesales')) { return FALSE; } return parent::install() && $this->registerHook('top'); } public function hookSubTop($params) { return $this->hookTop($params); } public function hookTop($params) { global $cookie, $smarty; include_once dirname(__FILE__).'/../privatesales/Sale.php'; if(_PS_MOBILE_) return false; /* if($cookie->isLogged()) { */ $sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` ASC'); $sales_1 = array(); $sales_2 = array(); $sales_3 = array(); $sale_ids = array(); foreach($sales as $sale) { if($sale->sale_type !== NULL) { if($sale->sale_type == 1) { $sales_1[] = $sale; } elseif($sale->sale_type == 2) { $sales_2[] = $sale; } elseif($sale->sale_type == 3) { $sales_3[] = $sale; } } $sale_ids[] = (int) $sale->id; } $extra_sale_fields = array(); foreach(Db::getInstance()->ExecuteS(' SELECT `id_sale`, `value` FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` WHERE `id_sale` IN ('.implode(', ', $sale_ids).') AND `id_lang` = '.(int) $cookie->id_lang.' AND `id_field` = 1 ') as $row) { $extra_sale_fields[(int) $row['id_sale']] = $row['value']; } $smarty->assign(array( 'menu_sales' => $sales, 'menu_sales_1' => $sales_1, 'menu_sales_2' => $sales_2, 'menu_sales_3' => $sales_3, 'extra_sale_fields' => $extra_sale_fields, )); $smarty->assign('customer_groups', $cookie->isLogged()? Customer::getGroupsStatic((int) $cookie->id_customer): array(1)); return $this->display(__FILE__, 'menu.tpl'); /*} */ } }