88 lines
2.8 KiB
PHP
88 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* Description of privatesalestrailer
|
|
*
|
|
* @company Antadis
|
|
*/
|
|
|
|
class privatesalestrailerModuleFrontController extends ModuleFrontController {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function init(){
|
|
|
|
if(Configuration::get('PRIVATESALES_TRAILER_COLUMN') == 0){
|
|
$this->display_column_left = false;
|
|
$this->display_column_right = false;
|
|
}else if(Configuration::get('PRIVATESALES_TRAILER_COLUMN') == 1){
|
|
$this->display_column_left = true;
|
|
$this->display_column_right = false;
|
|
}else if(Configuration::get('PRIVATESALES_TRAILER_COLUMN') == 2){
|
|
$this->display_column_left = false;
|
|
$this->display_column_right = true;
|
|
}else if(Configuration::get('PRIVATESALES_TRAILER_COLUMN') == 3){
|
|
$this->display_column_left = true;
|
|
$this->display_column_right = true;
|
|
}
|
|
|
|
parent::init();
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function initContent(){
|
|
|
|
$ajax = Tools::getValue('ajax');
|
|
if($ajax){
|
|
echo $this->ajaxProcessSubmitAlert();
|
|
}
|
|
|
|
parent::initContent();
|
|
|
|
$this->addCSS(array(
|
|
_THEME_CSS_DIR_.'scenes.css' => 'all',
|
|
_THEME_CSS_DIR_.'category.css' => 'all',
|
|
_THEME_CSS_DIR_.'product_list.css' => 'all',
|
|
));
|
|
|
|
if(!Tools::getValue('id_sale')){
|
|
Tools::redirect($this->context->link->getModuleLink('privatesales', 'home'));
|
|
}
|
|
$sale = new SaleCore(Tools::getValue('id_sale'), Context::getContext()->language->id);
|
|
|
|
$customer = Context::getContext()->customer;
|
|
$alerted = SaleAlertMail::isAlerted($customer->id,$sale->id);
|
|
|
|
$this->context->smarty->assign(array(
|
|
'sale' => $sale,
|
|
'alerted' => $alerted,
|
|
'link_img' => __PS_BASE_URI__.'modules/privatesales/img/',
|
|
'link_mod_img' => _PS_MODULE_DIR_.'modules/privatesales/img/'
|
|
));
|
|
$this->setTemplate('privatesales-trailer.tpl');
|
|
}
|
|
|
|
public function ajaxProcessSubmitAlert(){
|
|
$id_privatesales = Tools::getValue('id_privatesales');
|
|
if(!$id_privatesales)
|
|
return Tools::jsonEncode(array('hasError' => true));
|
|
|
|
$customer = Context::getContext()->customer;
|
|
if(!$customer)
|
|
return Tools::jsonEncode(array('hasError' => true));
|
|
|
|
$alert = new SaleAlertMail();
|
|
$alert->id_privatesales = $id_privatesales;
|
|
$alert->id_user = $customer->id;
|
|
$alert->email = $customer->email;
|
|
if($alert->add()){
|
|
return Tools::jsonEncode(array('hasError' => false));
|
|
}else{
|
|
return Tools::jsonEncode(array('hasError' => true));
|
|
}
|
|
}
|
|
|
|
} |