2016-06-28 11:54:23 +02:00

149 lines
7.7 KiB
PHP

<?php
/**
* Description of privatesaleshome
*
* @company Antadis
*/
class privatesaleshomeModuleFrontController extends ModuleFrontController {
/**
*
*/
public function init(){
if(Configuration::get('PRIVATESALES_COLUMN') == 0){
$this->display_column_left = false;
$this->display_column_right = false;
}else if(Configuration::get('PRIVATESALES_COLUMN') == 1){
$this->display_column_left = true;
$this->display_column_right = false;
}else if(Configuration::get('PRIVATESALES_COLUMN') == 2){
$this->display_column_left = false;
$this->display_column_right = true;
}else if(Configuration::get('PRIVATESALES_COLUMN') == 3){
$this->display_column_left = true;
$this->display_column_right = true;
}
parent::init();
}
/**
*
*/
public function initContent(){
if(!$this->context->cookie->logged && !Configuration::get('PRIVATESALES_LISTING_PUBLIC')){
Tools::redirect($this->context->link->getPageLink('authentication',null,$this->context->cookie->id_lang,'ps=0&back='.$this->context->link->getModuleLink('privatesales', 'home')));
}
parent::initContent();
$categories = SaleCategory::getCategory();
$news = null;
if(Tools::getValue('type') == "nouveautes"){
$news = 1;
}else if(Tools::getValue('type') == "ventes"){
$news = 2;
}
if(Configuration::get('PRIVATESALES_FLASH'))
$flashsales = SaleCore::getSales("current",0,TRUE,FALSE,TRUE,'position','ASC',FALSE,TRUE);
else
$flashsales = array();
if(Configuration::get('PRIVATESALES_HOTSPOT'))
$hotspotsales = SaleCore::getSales("hotspot");
else
$hotspotsales = array();
if(Configuration::get('PRIVATESALES_PASTSALES'))
$pastsales = SaleCore::getSales("past",Configuration::get('PRIVATESALES_PASTLIMIT'));
else
$pastsales = array();
if(Configuration::get('PRIVATESALES_FUTURESALES'))
$futuresales = SaleCore::getSales("future",Configuration::get('PRIVATESALES_FUTURELIMIT'), TRUE, FALSE, TRUE, 'date_start', 'ASC');
else
$futuresales = array();
//$currentsales = SaleCore::getSales("current",0,TRUE,FALSE,TRUE,'position','ASC',FALSE,FALSE,$news);
$currentsales = SaleCore::getSales("current",0,TRUE,FALSE,TRUE,'date_start','DESC',FALSE,FALSE,$news);
$this->addCSS(array(
_THEME_CSS_DIR_.'product_list.css' => 'all',
));
$mobileDetect = new Mobile_Detect();
if($mobileDetect->isMobile())
$mobile = true;
else
$mobile = false;
$customer = Context::getContext()->customer;
$slider = array();
for ($i=1; $i < 6; $i++) {
if (Configuration::get('PRIVATESALES_SLIDER_ACTIVE_'.$i)) {
$slider[] = array(
'title' => Configuration::get('PRIVATESALES_SLIDER_TITLE_'.$i),
'link' => Configuration::get('PRIVATESALES_SLIDER_LINK_'.$i),
'img' => 'slider/slider_'.$i.'_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMG_'.$i).'.png',
'img_mobile' => 'slider/slider_'.$i.'_mobile_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMGMOBILE_'.$i).'.png',
);
}
}
$this->context->smarty->assign(array(
'news' => $news,
'flashsales' => $flashsales,
'currentsales' => $currentsales,
'hotspotsales' => $hotspotsales,
'futuresales' => $futuresales,
'pastsales' => $pastsales,
'categories' => $categories,
'id_category' => false,
'alertedcat' => false,
'meta_description' => Configuration::get('PRIVATESALES_META_DESCRIPTION'),
'meta_title' => Configuration::get('PRIVATESALES_META_TITLE')." - " .Configuration::get('PS_SHOP_NAME') ,
'link_allsale' => $this->context->link->getModuleLink('privatesales', 'home'),
'popup_connection' => Configuration::get('PRIVATESALES_POPUP_CONNECTION'),
'link_img' => __PS_BASE_URI__.'modules/privatesales/img/',
'link_mod_img' => _PS_MODULE_DIR_.'modules/privatesales/img/',
'sales_mobile' => $mobile,
'sale_customer_uniqid' => md5($customer->email),
'slider_active' => Configuration::get('PRIVATESALES_SLIDER_ACTIVE'),
'slider' => $slider,
'banner_link' => Configuration::get('PRIVATESALES_BANNER_LINK'),
'banner_title' => Configuration::get('PRIVATESALES_BANNER_TITLE'),
'banner_link_block' => Configuration::get('PRIVATESALES_BANNER_LINK_BLOCK'),
'banner_title_block' => Configuration::get('PRIVATESALES_BANNER_TITLE_BLOCK'),
'banner_link_active' => Configuration::get('PRIVATESALES_BANNER_LINK_ACTIVE'),
'banner_link_top' => Configuration::get('PRIVATESALES_BANNER_LINK_TOP'),
'banner_title_top' => Configuration::get('PRIVATESALES_BANNER_TITLE_TOP'),
'banner_img_top' => 'banner/bandeau_superieur_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_TOP').'.png',
'banner_imgmobile_top' => 'banner/bandeau_superieur_mobile_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMGMOBILE_TOP').'.png',
'banner_link_top_active' => Configuration::get('PRIVATESALES_BANNER_LINK_TOP_ACTIVE'),
'banner_link_second' => Configuration::get('PRIVATESALES_BANNER_LINK_SECOND'),
'banner_title_second' => Configuration::get('PRIVATESALES_BANNER_TITLE_SECOND'),
'banner_img_second' => 'banner/bandeau_second_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_SECOND').'.png',
'banner_imgmobile_second' => 'banner/bandeau_second_mobile_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMGMOBILE_SECOND').'.png',
'banner_link_second_active' => Configuration::get('PRIVATESALES_BANNER_LINK_SECOND_ACTIVE'),
'banner_link_third' => Configuration::get('PRIVATESALES_BANNER_LINK_THIRD'),
'banner_title_third' => Configuration::get('PRIVATESALES_BANNER_TITLE_THIRD'),
'banner_img_third' => 'banner/bandeau_third_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_THIRD').'.png',
'banner_imgmobile_third' => 'banner/bandeau_third_mobile_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMGMOBILE_THIRD').'.png',
'banner_link_third_active' => Configuration::get('PRIVATESALES_BANNER_LINK_THIRD_ACTIVE'),
'banner_concour_link' => Configuration::get('PRIVATESALES_BANNER_LINK_CONCOURS'),
'banner_concour_title' => Configuration::get('PRIVATESALES_BANNER_TITLE_CONCOURS'),
'banner_concour_link_2' => Configuration::get('PRIVATESALES_BANNER_LINK_CONCOURS_2'),
'banner_concour_title_2' => Configuration::get('PRIVATESALES_BANNER_TITLE_CONCOURS_2'),
'banner_concour_link_active' => Configuration::get('PRIVATESALES_BANNER_LINK_CONCOURS_ACTIVE'),
));
$this->setTemplate('privatesales-home.tpl');
}
}