1063 lines
56 KiB
PHP
1063 lines
56 KiB
PHP
<?php
|
||
/**
|
||
* Description of AdminPreferenceProshop
|
||
*
|
||
* @company Antadis
|
||
*/
|
||
|
||
class AdminPreferencePrivateSalesController extends ModuleAdminController {
|
||
|
||
/**
|
||
*
|
||
*/
|
||
public function __construct(){
|
||
$this->context = Context::getContext();
|
||
$this->className = 'Configuration';
|
||
$this->table = 'configuration';
|
||
$this->bootstrap = true;
|
||
$root_categories = array(
|
||
array(
|
||
'value' => 0,
|
||
'name' => $this->l('--- None ---'),
|
||
),
|
||
array(
|
||
'value' => 1,
|
||
'name' => $this->l('Root'),
|
||
),
|
||
array(
|
||
'value' => 2,
|
||
'name' => ' '.$this->l('Home'),
|
||
),
|
||
);
|
||
|
||
foreach(Category::getHomeCategories((int) $this->context->cookie->id_lang, FALSE) as $cat) {
|
||
$root_categories[] = array(
|
||
'value' => $cat['id_category'],
|
||
'name' => ' '.$cat['name'],
|
||
);
|
||
}
|
||
$column = array(
|
||
array(
|
||
'value' => 0,
|
||
'name' => $this->l('--- None ---'),
|
||
),
|
||
array(
|
||
'value' => 1,
|
||
'name' => $this->l('Left'),
|
||
),
|
||
array(
|
||
'value' => 2,
|
||
'name' => $this->l('Right'),
|
||
),
|
||
array(
|
||
'value' => 3,
|
||
'name' => $this->l('Right and Left'),
|
||
),
|
||
);
|
||
$urlbg = _THEME_IMG_DIR_.'home/background_home.png';
|
||
$urlpicto = _THEME_IMG_DIR_.'picto_sale.png';
|
||
$urlpictocategory = _THEME_IMG_DIR_.'picto_sale_category.png';
|
||
$urlbanner1 = _THEME_IMG_DIR_.'banner/bandeau_superieur_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_TOP').'.png';
|
||
$urlbannermobile1 = _THEME_IMG_DIR_.'banner/bandeau_superieur_mobile_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMGMOBILE_TOP').'.png';
|
||
$urlbanner2 = _THEME_IMG_DIR_.'banner/bandeau_second_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_SECOND').'.png';
|
||
$urlbannermobile2 = _THEME_IMG_DIR_.'banner/bandeau_second_mobile_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMGMOBILE_SECOND').'.png';
|
||
$urlbanner3 = _THEME_IMG_DIR_.'banner/bandeau_third_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_THIRD').'.png';
|
||
$urlbannermobile3 = _THEME_IMG_DIR_.'banner/bandeau_third_mobile_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMGMOBILE_THIRD').'.png';
|
||
$urlbannerblock = _THEME_IMG_DIR_.'banner/bandeau_block_'.Configuration::get('PRIVATESALES_BANNER_TITLEIMG_BLOCK').'.png';
|
||
|
||
// img slider
|
||
$urlslider1 = _THEME_IMG_DIR_.'slider/slider_1_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMG_1').'.png';
|
||
$urlslidermobile1 = _THEME_IMG_DIR_.'slider/slider_1_mobile_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMGMOBILE_1').'.png';
|
||
$urlslider2 = _THEME_IMG_DIR_.'slider/slider_2_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMG_2').'.png';
|
||
$urlslidermobile2 = _THEME_IMG_DIR_.'slider/slider_2_mobile_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMGMOBILE_2').'.png';
|
||
$urlslider3 = _THEME_IMG_DIR_.'slider/slider_3_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMG_3').'.png';
|
||
$urlslidermobile3 = _THEME_IMG_DIR_.'slider/slider_3_mobile_'.Configuration::get('PRIVATESALES_SLIDER_TITLEIMGMOBILE_3').'.png';
|
||
|
||
$fields = array(
|
||
'general' => array(
|
||
'PRIVATESALES_ROOT' => array(
|
||
'title' => $this->l('Private sales root category'),
|
||
'desc' => $this->l('All children from this category will be used for private sales'),
|
||
'validation' => 'isInt',
|
||
'cast' => 'intval',
|
||
'type' => 'select',
|
||
'list' => $root_categories,
|
||
'default' => Configuration::get('PRIVATESALES_ROOT'),
|
||
'identifier' => 'value',
|
||
),
|
||
'PRIVATESALES_LISTING_PUBLIC' => array(
|
||
'title' => $this->l('Show listing privates sales'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_LISTING_PUBLIC'),
|
||
),
|
||
'PRIVATESALES_HOTSPOT' => array(
|
||
'title' => $this->l('Show hotspot privates sales'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_HOTSPOT'),
|
||
),
|
||
'PRIVATESALES_FLASH' => array(
|
||
'title' => $this->l('Show flash privates sales'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_FLASH'),
|
||
),
|
||
'PRIVATESALES_PASTSALES' => array(
|
||
'title' => $this->l('Show past privates sales'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_PASTSALES'),
|
||
),
|
||
'PRIVATESALES_FUTURESALES' => array(
|
||
'title' => $this->l('Show future privates sales'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_FUTURESALES'),
|
||
),
|
||
'PRIVATESALES_SAME_CATEGORY' => array(
|
||
'title' => $this->l('Show privates sales in the same category'),
|
||
'validation' => 'isBool',
|
||
'hint' => $this->l('Show other private sales in the same sale category'),
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_SAME_CATEGORY'),
|
||
),
|
||
'PRIVATESALES_SAME_CATEGORY_NUMBER' => array(
|
||
'title' => $this->l('Number of sales to display'),
|
||
'validation' => 'isInt',
|
||
'hint' => $this->l('Number of sales to display when "Show privates sales in the same category" is active'),
|
||
'cast' => 'intval',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SAME_CATEGORY_NUMBER'),
|
||
),
|
||
'PRIVATESALES_POPUP_CONNECTION' => array(
|
||
'title' => $this->l('Show a connection popup'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_POPUP_CONNECTION'),
|
||
),
|
||
'PRIVATESALES_COLUMN' => array(
|
||
'title' => $this->l('Column'),
|
||
'validation' => 'isInt',
|
||
'cast' => 'intval',
|
||
'type' => 'select',
|
||
'list' => $column,
|
||
'default' => Configuration::get('PRIVATESALES_COLUMN'),
|
||
'identifier' => 'value',
|
||
),
|
||
'PRIVATESALES_TRAILER_COLUMN' => array(
|
||
'title' => $this->l('Column trailer'),
|
||
'validation' => 'isInt',
|
||
'cast' => 'intval',
|
||
'type' => 'select',
|
||
'list' => $column,
|
||
'default' => Configuration::get('PRIVATESALES_TRAILER_COLUMN'),
|
||
'identifier' => 'value',
|
||
),
|
||
'PRIVATESALES_FUTURELIMIT' => array(
|
||
'title' => $this->l('Future sales display limit'),
|
||
'desc' => $this->l('Hide sales starting after this delay, set to 0 to show all upcoming sales'),
|
||
'validation' => 'isInt',
|
||
'cast' => 'intval',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_FUTURELIMIT'),
|
||
),
|
||
'PRIVATESALES_PASTLIMIT' => array(
|
||
'title' => $this->l('Past sales display limit'),
|
||
'desc' => $this->l('Hide sales ending before this delay, set to 0 to show all past sales'),
|
||
'validation' => 'isInt',
|
||
'cast' => 'intval',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_PASTLIMIT'),
|
||
),
|
||
'PRIVATESALES_SEND_ALERT_LIMIT' => array(
|
||
'title' => $this->l('Time before sending the alert'),
|
||
'desc' => $this->l('In minute'),
|
||
'validation' => 'isInt',
|
||
'cast' => 'intval',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SEND_ALERT_LIMIT'),
|
||
),
|
||
'PRIVATESALES_SHOWHOME' => array(
|
||
'title' => $this->l('Show privates sales on home'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_SHOWHOME'),
|
||
),
|
||
'PRIVATESALES_SEO_FR' => array(
|
||
'title' => $this->l('URL Rewriting FR'),
|
||
'validation' => 'isUrl',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SEO_FR'),
|
||
),
|
||
'PRIVATESALES_SEO_EN' => array(
|
||
'title' => $this->l('URL Rewriting EN'),
|
||
'validation' => 'isUrl',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SEO_EN'),
|
||
),
|
||
'PRIVATESALES_SEOTRAILER_FR' => array(
|
||
'title' => $this->l('URL Rewriting teaser FR'),
|
||
'validation' => 'isUrl',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SEOTRAILER_FR'),
|
||
),
|
||
'PRIVATESALES_SEOTRAILER_EN' => array(
|
||
'title' => $this->l('URL Rewriting teaser EN'),
|
||
'validation' => 'isUrl',
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SEOTRAILER_EN'),
|
||
),
|
||
'PRIVATESALES_META_TITLE' => array(
|
||
'title' => $this->l('Meta Title'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_META_TITLE'),
|
||
),
|
||
'PRIVATESALES_META_DESCRIPTION' => array(
|
||
'title' => $this->l('Meta Description'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_META_DESCRIPTION'),
|
||
),
|
||
|
||
),
|
||
'slider' => array(
|
||
'PRIVATESALES_SLIDER_ACTIVE' => array(
|
||
'title' => $this->l('Activer le Slider'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_ACTIVE'),
|
||
),
|
||
'PRIVATESALES_SLIDER_LINK_1' => array(
|
||
'title' => $this->l('Lien de la slide 1'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_LINK_1'),
|
||
),
|
||
'PRIVATESALES_SLIDER_TITLE_1' => array(
|
||
'title' => $this->l('Titre de la slide 1'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_TITLE_1'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Slide 1'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imageslider1',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlslider1,
|
||
'desc' => 'dimension 940px x 300px'
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Mobile Slide 1'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imageslidermobile1',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlslidermobile1,
|
||
'desc' => 'dimension 300px x 200px'
|
||
),
|
||
'PRIVATESALES_SLIDER_LINK_2' => array(
|
||
'title' => $this->l('Lien de la slide 2'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_LINK_2'),
|
||
),
|
||
'PRIVATESALES_SLIDER_TITLE_2' => array(
|
||
'title' => $this->l('Titre de la slide 2'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_TITLE_2'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Slide 2'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imageslider2',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlslider2,
|
||
'desc' => 'dimension 940px x 300px'
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Mobile Slide 2'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imageslidermobile2',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlslidermobile2,
|
||
'desc' => 'dimension 300px x 200px'
|
||
),
|
||
'PRIVATESALES_SLIDER_LINK_3' => array(
|
||
'title' => $this->l('Lien de la slide 3'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_LINK_3'),
|
||
),
|
||
'PRIVATESALES_SLIDER_TITLE_3' => array(
|
||
'title' => $this->l('Titre de la slide 3'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_SLIDER_TITLE_3'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Slide 3'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imageslider3',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlslider3,
|
||
'desc' => 'dimension 940px x 300px'
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Mobile Slide 3'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imageslidermobile3',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlslidermobile3,
|
||
'desc' => 'dimension 300px x 200px'
|
||
),
|
||
),
|
||
'banner' => array(
|
||
'PRIVATESALES_BANNER_LINK_TOP_ACTIVE' => array(
|
||
'title' => $this->l('Activer la bannière 1'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_TOP_ACTIVE'),
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_TOP' => array(
|
||
'title' => $this->l('Lien de la bannière 1'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_TOP'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE_TOP' => array(
|
||
'title' => $this->l('Titre de la bannière 1'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE_TOP'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Bannière 1'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebanner1',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbanner1,
|
||
'desc' => 'dimension 940px x 101px'
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Mobile Bannière 1'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebannermobile1',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbannermobile1,
|
||
'desc' => 'dimension 460px x 260px'
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_SECOND_ACTIVE' => array(
|
||
'title' => $this->l('Activer la bannière 2'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_SECOND_ACTIVE'),
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_SECOND' => array(
|
||
'title' => $this->l('Lien de la bannière 2'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_SECOND'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE_SECOND' => array(
|
||
'title' => $this->l('Titre de la bannière 2'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE_SECOND'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Bannière 2'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebanner2',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbanner2,
|
||
'desc' => 'dimension 940px x 101px'
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Mobile Bannière 2'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebannermobile2',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbannermobile2,
|
||
'desc' => 'dimension 460px x 260px'
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_THIRD_ACTIVE' => array(
|
||
'title' => $this->l('Activer la bannière 3'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_THIRD_ACTIVE'),
|
||
'desc' => 'Attention a désactiver la bannière concours'
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_THIRD' => array(
|
||
'title' => $this->l('Lien de la bannière 3'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_THIRD'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE_THIRD' => array(
|
||
'title' => $this->l('Titre de bannière 3'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE_THIRD'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Bannière 3'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebanner3',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbanner3,
|
||
'desc' => 'dimension 940px x 101px'
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Mobile Bannière 3'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebannermobile3',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbannermobile3,
|
||
'desc' => 'dimension 460px x 260px'
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_ACTIVE' => array(
|
||
'title' => $this->l('Activer la bannière avec petit bloc'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_ACTIVE'),
|
||
),
|
||
'PRIVATESALES_BANNER_LINK' => array(
|
||
'title' => $this->l('Lien de la bannière avec petit bloc'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE' => array(
|
||
'title' => $this->l('Titre du lien'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image Bannière avec petit bloc'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebannerblock',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbannerblock,
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_BLOCK' => array(
|
||
'title' => $this->l('Lien du bloc'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_BLOCK'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE_BLOCK' => array(
|
||
'title' => $this->l('Titre du lien bloc '),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE_BLOCK'),
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_CONCOURS_ACTIVE' => array(
|
||
'title' => $this->l('Activer la bannière concours '),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_CONCOURS_ACTIVE'),
|
||
'desc' => 'Attention a désactiver la bannière 3'
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_CONCOURS' => array(
|
||
'title' => $this->l('Lien de la bannière concours (règles)'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_CONCOURS'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE_CONCOURS' => array(
|
||
'title' => $this->l('Titre de la bannière concours (règles)'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE_CONCOURS'),
|
||
),
|
||
'PRIVATESALES_BANNER_LINK_CONCOURS_2' => array(
|
||
'title' => $this->l('Lien de la bannière concours (gagnants)'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_LINK_CONCOURS'),
|
||
),
|
||
'PRIVATESALES_BANNER_TITLE_CONCOURS_2' => array(
|
||
'title' => $this->l('Titre de la bannière concours (gagnants)'),
|
||
'type' => 'text',
|
||
'default' => Configuration::get('PRIVATESALES_BANNER_TITLE_CONCOURS'),
|
||
),
|
||
),
|
||
'home' => array(
|
||
'PRIVATESALES_HOME_BG' => array(
|
||
'title' => $this->l('Activer le fond du site'),
|
||
'validation' => 'isBool',
|
||
'cast' => 'intval',
|
||
'type' => 'bool',
|
||
'default' => Configuration::get('PRIVATESALES_HOME_BG'),
|
||
),
|
||
array(
|
||
'title' => $this->l('Image de fond'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagebg',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlbg,
|
||
),
|
||
),
|
||
'picto' => array(
|
||
array(
|
||
'title' => $this->l('Picto sur la vente'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagepicto',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlpicto,
|
||
),
|
||
array(
|
||
'title' => $this->l('Picto Catégorie'),
|
||
'type' => 'file',
|
||
'label' => $this->l('Select an image'),
|
||
'name' => 'imagepictocategory',
|
||
'form_group_class' => 'fieldhide input_img',
|
||
'url' => $urlpictocategory,
|
||
)
|
||
),
|
||
'concours' => array(
|
||
),
|
||
'concours_inlive' => array(
|
||
),
|
||
);
|
||
|
||
$this->fields_options = array(
|
||
'general' => array(
|
||
'title' => $this->l('General'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['general'],
|
||
'submit' => array('title' => $this->l(' Save ')),
|
||
),
|
||
'slider' => array(
|
||
'title' => $this->l('Slider home'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['slider'],
|
||
'submit' => array(
|
||
'name' => 'submitPrivateSaleHomeSlider',
|
||
'title' => $this->l(' Save '),
|
||
),
|
||
),
|
||
'banner' => array(
|
||
'title' => $this->l('Bannières'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['banner'],
|
||
'submit' => array(
|
||
'name' => 'submitPrivateSaleHomeBanner',
|
||
'title' => $this->l(' Save '),
|
||
),
|
||
),
|
||
'home' => array(
|
||
'title' => $this->l('Home Background'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['home'],
|
||
'submit' => array(
|
||
'name' => 'submitPrivateSaleHomeBg',
|
||
'title' => $this->l(' Save '),
|
||
),
|
||
),
|
||
'picto' => array(
|
||
'title' => $this->l('Picto Vente'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['picto'],
|
||
'submit' => array(
|
||
'name' => 'submitPrivateSalePicto',
|
||
'title' => $this->l(' Save '),
|
||
),
|
||
),
|
||
'concours' => array(
|
||
'title' => $this->l('Concours'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['concours'],
|
||
'submit' => array(
|
||
'name' => 'submitPrivateSaleConcoursExport',
|
||
'title' => $this->l('Export CONCOURS'),
|
||
),
|
||
),
|
||
'concours_inlive' => array(
|
||
'title' => $this->l('Concours en temps reel'),
|
||
'icon' => 'tab-preferences',
|
||
'fields' => $fields['concours_inlive'],
|
||
'submit' => array(
|
||
'name' => 'submitPrivateSaleConcoursExportInLive',
|
||
'title' => $this->l('Export CONCOURS in Live'),
|
||
),
|
||
),
|
||
);
|
||
|
||
parent::__construct();
|
||
}
|
||
|
||
/*** HACK TRADUCTION ***/
|
||
|
||
public static $l_cache;
|
||
|
||
protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE)
|
||
{
|
||
// need to be called in order to populate $classInModule
|
||
$str = self::findTranslation('privatesales', $string, 'AdminPreferencePrivateSales');
|
||
$str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
|
||
return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str)));
|
||
}
|
||
|
||
/**
|
||
* findTranslation (initially in Module class), to make translations works
|
||
*
|
||
* @param string $name module name
|
||
* @param string $string string to translate
|
||
* @param string $source current class
|
||
* @return string translated string
|
||
*/
|
||
public static function findTranslation($name, $string, $source)
|
||
{
|
||
static $_MODULES;
|
||
if (!is_array($_MODULES))
|
||
{
|
||
// note: $_COOKIE[iso_code] is set in createCustomToken();
|
||
$file = _PS_MODULE_DIR_.'privatesales/translations/'.Configuration::get('PS_LOCALE_LANGUAGE').'.php';
|
||
if (file_exists($file) && include($file))
|
||
$_MODULES = !empty($_MODULES)?array_merge($_MODULES, $_MODULE):$_MODULE;
|
||
}
|
||
$cache_key = $name.'|'.$string.'|'.$source;
|
||
|
||
if (!isset(self::$l_cache[$cache_key]))
|
||
{
|
||
if (!is_array($_MODULES))
|
||
return $string;
|
||
// set array key to lowercase for 1.3 compatibility
|
||
$_MODULES = array_change_key_case($_MODULES);
|
||
if (defined('_THEME_NAME_'))
|
||
$currentKey = '<{'.strtolower($name).'}'.strtolower(_THEME_NAME_).'>'.strtolower($source).'_'.md5($string);
|
||
else
|
||
$currentKey = '<{'.strtolower($name).'}default>'.strtolower($source).'_'.md5($string);
|
||
// note : we should use a variable to define the default theme (instead of "prestashop")
|
||
$defaultKey = '<{'.strtolower($name).'}prestashop>'.strtolower($source).'_'.md5($string);
|
||
$currentKey = $defaultKey;
|
||
|
||
if (isset($_MODULES[$currentKey]))
|
||
$ret = stripslashes($_MODULES[$currentKey]);
|
||
elseif (isset($_MODULES[strtolower($currentKey)]))
|
||
$ret = stripslashes($_MODULES[strtolower($currentKey)]);
|
||
elseif (isset($_MODULES[$defaultKey]))
|
||
$ret = stripslashes($_MODULES[$defaultKey]);
|
||
elseif (isset($_MODULES[strtolower($defaultKey)]))
|
||
$ret = stripslashes($_MODULES[strtolower($defaultKey)]);
|
||
else
|
||
$ret = stripslashes($string);
|
||
|
||
self::$l_cache[$cache_key] = $ret;
|
||
}
|
||
return self::$l_cache[$cache_key];
|
||
}
|
||
|
||
public function postProcess(){
|
||
parent::postProcess();
|
||
if (Tools::isSubmit('submitPrivateSaleHomeSlider')) {
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_ACTIVE', Tools::getValue('PRIVATESALES_SLIDER_ACTIVE'));
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_LINK_1', Tools::getValue('PRIVATESALES_SLIDER_LINK_1'));
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLE_1', Tools::getValue('PRIVATESALES_SLIDER_TITLE_1'));
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_LINK_2', Tools::getValue('PRIVATESALES_SLIDER_LINK_2'));
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLE_2', Tools::getValue('PRIVATESALES_SLIDER_TITLE_2'));
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_LINK_3', Tools::getValue('PRIVATESALES_SLIDER_LINK_3'));
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLE_3', Tools::getValue('PRIVATESALES_SLIDER_TITLE_3'));
|
||
|
||
$languages = Language::getLanguages(false);
|
||
foreach ($languages as $language) {
|
||
$tabimgs = array(
|
||
"slider1" => 'slider_1',
|
||
"slidermobile1" => 'slider_1_mobile',
|
||
"slider2" => 'slider_2',
|
||
"slidermobile2" => 'slider_2_mobile',
|
||
"slider3" => 'slider_3',
|
||
"slidermobile3" => 'slider_3_mobile',
|
||
);
|
||
foreach($tabimgs as $key => $imgName){
|
||
$namePost = 'image'.$key.'_'.$language['id_lang'];
|
||
|
||
if(isset($_FILES[$namePost]) && !empty($_FILES[$namePost]['tmp_name']) ){
|
||
|
||
$fileTemp = $_FILES[$namePost]['tmp_name'];
|
||
$fileParts = pathinfo($_FILES[$namePost]['name']);
|
||
|
||
if($fileParts['extension'] == 'jpg' || $fileParts['extension'] == 'png'){
|
||
$random = Tools::passwdGen(5);
|
||
switch ($key) {
|
||
case 'slider1':
|
||
if (glob(_PS_THEME_DIR_.'img/slider/slider_1_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/slider/slider_1_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLEIMG_1', $random);
|
||
break;
|
||
case 'slidermobile1':
|
||
if (glob(_PS_THEME_DIR_.'img/slider/slider_1_mobile_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/slider/slider_1_mobile_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLEIMGMOBILE_1', $random);
|
||
break;
|
||
case 'slider2':
|
||
if (glob(_PS_THEME_DIR_.'img/slider/slider_2_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/slider/slider_2_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLEIMG_2', $random);
|
||
break;
|
||
case 'slidermobile2':
|
||
if (glob(_PS_THEME_DIR_.'img/slider/slider_2_mobile_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/slider/slider_2_mobile_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLEIMGMOBILE_2', $random);
|
||
break;
|
||
case 'slider3':
|
||
if (glob(_PS_THEME_DIR_.'img/slider/slider_3_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/slider/slider_3_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLEIMG_3', $random);
|
||
break;
|
||
case 'slidermobile3':
|
||
if (glob(_PS_THEME_DIR_.'img/slider/slider_3_mobile_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/slider/slider_3_mobile_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_SLIDER_TITLEIMGMOBILE_3', $random);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/slider/'.$imgName.'_'.$random.'.png');
|
||
if(!$res) {
|
||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), $imgName.'.png');
|
||
} else {
|
||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), $imgName.'.png');
|
||
}
|
||
} else {
|
||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), $imgName.'.png');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (Tools::isSubmit('submitPrivateSaleHomeBanner')) {
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_TOP_ACTIVE', Tools::getValue('PRIVATESALES_BANNER_LINK_TOP_ACTIVE'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_TOP', Tools::getValue('PRIVATESALES_BANNER_LINK_TOP'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE_TOP', Tools::getValue('PRIVATESALES_BANNER_TITLE_TOP'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_SECOND_ACTIVE', Tools::getValue('PRIVATESALES_BANNER_LINK_SECOND_ACTIVE'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_SECOND', Tools::getValue('PRIVATESALES_BANNER_LINK_SECOND'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE_SECOND', Tools::getValue('PRIVATESALES_BANNER_TITLE_SECOND'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_THIRD_ACTIVE', Tools::getValue('PRIVATESALES_BANNER_LINK_THIRD_ACTIVE'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_THIRD', Tools::getValue('PRIVATESALES_BANNER_LINK_THIRD'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE_THIRD', Tools::getValue('PRIVATESALES_BANNER_TITLE_THIRD'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_ACTIVE', Tools::getValue('PRIVATESALES_BANNER_LINK_ACTIVE'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK', Tools::getValue('PRIVATESALES_BANNER_LINK'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE', Tools::getValue('PRIVATESALES_BANNER_TITLE'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_BLOCK', Tools::getValue('PRIVATESALES_BANNER_LINK_BLOCK'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE_BLOCK', Tools::getValue('PRIVATESALES_BANNER_TITLE_BLOCK'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_CONCOURS_ACTIVE', Tools::getValue('PRIVATESALES_BANNER_LINK_CONCOURS_ACTIVE'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_CONCOURS', Tools::getValue('PRIVATESALES_BANNER_LINK_CONCOURS'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE_CONCOURS', Tools::getValue('PRIVATESALES_BANNER_TITLE_CONCOURS'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_LINK_CONCOURS_2', Tools::getValue('PRIVATESALES_BANNER_LINK_CONCOURS_2'));
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLE_CONCOURS_2', Tools::getValue('PRIVATESALES_BANNER_TITLE_CONCOURS_2'));
|
||
|
||
$languages = Language::getLanguages(false);
|
||
foreach ($languages as $language) {
|
||
$tabimgs = array(
|
||
"banner1" => 'bandeau_superieur',
|
||
"bannermobile1" => 'bandeau_superieur_mobile',
|
||
"banner2" => 'bandeau_second',
|
||
"bannermobile2" => 'bandeau_second_mobile',
|
||
"banner3" => 'bandeau_third',
|
||
"bannermobile3" => 'bandeau_third_mobile',
|
||
"bannerblock" => 'bandeau_block',
|
||
"bannerconcours" => 'bandeau_concours',
|
||
);
|
||
foreach($tabimgs as $key => $imgName){
|
||
$namePost = 'image'.$key.'_'.$language['id_lang'];
|
||
if(isset($_FILES[$namePost]) && !empty($_FILES[$namePost]['tmp_name']) ){
|
||
|
||
$fileTemp = $_FILES[$namePost]['tmp_name'];
|
||
$fileParts = pathinfo($_FILES[$namePost]['name']);
|
||
if($fileParts['extension'] == 'jpg' || $fileParts['extension'] == 'png'){
|
||
$random = Tools::passwdGen(5);
|
||
switch ($key) {
|
||
case 'banner1':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_superieur_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_superieur_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMG_TOP', $random);
|
||
break;
|
||
case 'bannermobile1':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_superieur_mobile_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_superieur_mobile_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMGMOBILE_TOP', $random);
|
||
break;
|
||
case 'banner2':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_second_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_second_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMG_SECOND', $random);
|
||
break;
|
||
case 'bannermobile2':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_second_mobile_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_second_mobile_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMGMOBILE_SECOND', $random);
|
||
break;
|
||
case 'banner3':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_third_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_third_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMG_THIRD', $random);
|
||
break;
|
||
case 'bannermobile3':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_third_mobile_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_third_mobile_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMGMOBILE_THIRD', $random);
|
||
break;
|
||
case 'bannerblock':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_block_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_block_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMG', $random);
|
||
break;
|
||
case 'bannerconcours':
|
||
if (glob(_PS_THEME_DIR_.'img/banner/bandeau_concours_*.png')) {
|
||
foreach (glob(_PS_THEME_DIR_.'img/banner/bandeau_concours_*.png') as $filename) {
|
||
unlink($filename);
|
||
}
|
||
}
|
||
Configuration::updateValue('PRIVATESALES_BANNER_TITLEIMG_CONCOURS', $random);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/banner/'.$imgName.'_'.$random.'.png');
|
||
if(!$res) {
|
||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), $imgName.'.png');
|
||
} else {
|
||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), $imgName.'.png');
|
||
}
|
||
} else {
|
||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), $imgName.'.png');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (Tools::isSubmit('submitPrivateSaleHomeBg')) {
|
||
Configuration::updateValue('PRIVATESALES_HOME_BG', Tools::getValue('PRIVATESALES_HOME_BG'));
|
||
$languages = Language::getLanguages(false);
|
||
foreach ($languages as $language) {
|
||
|
||
$namePost = 'imagebg_'.$language['id_lang'];
|
||
if(isset($_FILES[$namePost]) && !empty($_FILES[$namePost]['tmp_name']) ){
|
||
|
||
$fileTemp = $_FILES[$namePost]['tmp_name'];
|
||
$fileParts = pathinfo($_FILES[$namePost]['name']);
|
||
if($fileParts['extension'] == 'jpg' || $fileParts['extension'] == 'png'){
|
||
/*$res = move_uploaded_file($fileTemp, _PS_MODULE_DIR_.'privatesales/img/img_site/background_home.png');*/
|
||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/home/background_home.png');
|
||
if(!$res) {
|
||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), 'background_home.png');
|
||
} else {
|
||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), 'background_home.png');
|
||
}
|
||
} else {
|
||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), 'background_home.png');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (Tools::isSubmit('submitPrivateSalePicto')) {
|
||
|
||
$languages = Language::getLanguages(false);
|
||
foreach ($languages as $language) {
|
||
$tabimgs = array(
|
||
"picto",
|
||
"pictocategory",
|
||
);
|
||
|
||
foreach($tabimgs as $tabimg){
|
||
$namePost = 'image'.$tabimg.'_'.$language['id_lang'];
|
||
if(isset($_FILES[$namePost]) && !empty($_FILES[$namePost]['tmp_name']) ){
|
||
|
||
$fileTemp = $_FILES[$namePost]['tmp_name'];
|
||
$fileParts = pathinfo($_FILES[$namePost]['name']);
|
||
if($fileParts['extension'] == 'jpg' || $fileParts['extension'] == 'png'){
|
||
/*$res = move_uploaded_file($fileTemp, _PS_MODULE_DIR_.'privatesales/img/img_site/picto_sale.png');*/
|
||
if($tabimg == 'picto') {
|
||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/picto_sale.png');
|
||
} elseif($tabimg == 'pictocategory') {
|
||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/picto_sale_category.png');
|
||
}
|
||
|
||
if(!$res) {
|
||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), $namePost.'.png');
|
||
} else {
|
||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), $namePost.'.png');
|
||
}
|
||
} else {
|
||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), $namePost.'.png');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (Tools::isSubmit('submitPrivateSaleConcoursExport')){
|
||
$this->drawLots();
|
||
$items = $this->getPrivateSalesInGame(Configuration::get('PS_LANG_DEFAULT'));
|
||
if($items){
|
||
header("Content-Type: text/csv; charset=UTF-8");
|
||
header("Content-Disposition: attachment;filename='export-concours-".date('Ymd').".csv'");
|
||
$this->exportCsv($items, 'export-jeu-concours.csv');
|
||
die();
|
||
}
|
||
}
|
||
if(Tools::isSubmit('submitPrivateSaleConcoursExportInLive')){
|
||
$items = $this->getPrivateSalesInGame(Configuration::get('PS_LANG_DEFAULT'), true);
|
||
if($items){
|
||
header("Content-Type: text/csv; charset=UTF-8");
|
||
header("Content-Disposition: attachment;filename='export-concours-".date('Ymd').".csv'");
|
||
$this->exportCsv($items, 'export-jeu-concours-in-live.csv');
|
||
die();
|
||
}
|
||
}
|
||
}
|
||
|
||
public function drawLots(){
|
||
$privatesalesInGame = $this->getPrivateSalesInGame(Configuration::get('PS_LANG_DEFAULT'));
|
||
foreach ($privatesalesInGame as $ps) {
|
||
$countWinner = Db::getInstance()->getValue('
|
||
SELECT COUNT(*)
|
||
FROM `'._DB_PREFIX_.'privatesales_concours`
|
||
WHERE `id_privatesales` = ' . (int)$ps['id_privatesales'] .'
|
||
AND `is_winner` = 1'
|
||
);
|
||
|
||
if($countWinner) {
|
||
continue;
|
||
} else {
|
||
$drawLots = Db::getInstance()->execute('
|
||
UPDATE `'._DB_PREFIX_.'privatesales_concours` psc
|
||
SET psc.`is_winner` = 1
|
||
WHERE psc.`id_privatesales` = '. (int)$ps['id_privatesales'] .'
|
||
AND psc.`id_customer` NOT IN (SELECT c.`id_customer` FROM `'._DB_PREFIX_.'customer` c WHERE c.`email` lIKE "%@privilegedemarque.com%" )
|
||
ORDER BY RAND() LIMIT 1'
|
||
);
|
||
}
|
||
}
|
||
}
|
||
|
||
public function getPrivateSalesInGame($id_lang, $in_live = false){
|
||
if($in_live)
|
||
$sql = "
|
||
SELECT ps.`date_start`, DATE_ADD(ps.`date_start`, INTERVAL ps.`concours_delay` HOUR) as gameOver, ps.`id_privatesales`, psl.`title`, psc.`id_product_attribute`, al.`name` as attributeName, c.`id_customer`, CONCAT(c.`firstname`, ' ', c.`lastname`) as customerName, c.`email`, psc.`id_product`, psc.`is_winner`, ppl.`name` as productName
|
||
FROM `"._DB_PREFIX_."privatesales` as ps
|
||
LEFT JOIN `"._DB_PREFIX_."privatesales_lang` as psl ON (psl.`id_privatesales` = ps.`id_privatesales`)
|
||
LEFT JOIN `"._DB_PREFIX_."privatesales_concours` as psc ON (psc.`id_privatesales` = ps.`id_privatesales`)
|
||
LEFT JOIN `"._DB_PREFIX_."product_attribute_combination` as pac ON (pac.`id_product_attribute` = psc.`id_product_attribute`)
|
||
LEFT JOIN `"._DB_PREFIX_."product_lang` as ppl ON (ppl.`id_product` = psc.`id_product`)
|
||
LEFT JOIN `"._DB_PREFIX_."attribute_lang` as al ON (al.`id_attribute` = pac.`id_attribute`)
|
||
LEFT JOIN `"._DB_PREFIX_."customer` as c ON (c.`id_customer` = psc.`id_customer`)
|
||
WHERE ps.`concours` = 1
|
||
AND psl.`id_lang` = ".(int)$id_lang." AND ppl.`id_lang` = ".(int)$id_lang."
|
||
ORDER BY gameOver, ps.`id_privatesales`, psc.`is_winner`
|
||
";
|
||
else
|
||
$sql = "
|
||
SELECT ps.`date_start`, DATE_ADD(ps.`date_start`, INTERVAL ps.`concours_delay` HOUR) as gameOver, ps.`id_privatesales`, psl.`title`, psc.`id_product_attribute`, al.`name` as attributeName, c.`id_customer`, CONCAT(c.`firstname`, ' ', c.`lastname`) as customerName, c.`email`, psc.`id_product`, psc.`is_winner`, ppl.`name` as productName
|
||
FROM `"._DB_PREFIX_."privatesales` as ps
|
||
LEFT JOIN `"._DB_PREFIX_."privatesales_lang` as psl ON (psl.`id_privatesales` = ps.`id_privatesales`)
|
||
LEFT JOIN `"._DB_PREFIX_."privatesales_concours` as psc ON (psc.`id_privatesales` = ps.`id_privatesales`)
|
||
LEFT JOIN `"._DB_PREFIX_."product_attribute_combination` as pac ON (pac.`id_product_attribute` = psc.`id_product_attribute`)
|
||
LEFT JOIN `"._DB_PREFIX_."product_lang` as ppl ON (ppl.`id_product` = psc.`id_product`)
|
||
LEFT JOIN `"._DB_PREFIX_."attribute_lang` as al ON (al.`id_attribute` = pac.`id_attribute`)
|
||
LEFT JOIN `"._DB_PREFIX_."customer` as c ON (c.`id_customer` = psc.`id_customer`)
|
||
WHERE ps.`concours` = 1
|
||
AND DATE_ADD(ps.`date_start`, INTERVAL ps.`concours_delay` HOUR) <= NOW()
|
||
AND psl.`id_lang` = ".(int)$id_lang." AND ppl.`id_lang` = ".(int)$id_lang."
|
||
ORDER BY gameOver, ps.`id_privatesales`, psc.`is_winner`
|
||
";
|
||
//AND ps.`date_end` >= NOW()
|
||
return Db::getInstance()->ExecuteS($sql);
|
||
}
|
||
|
||
public function buildExport(&$item){
|
||
if($item['is_winner'] == 1)
|
||
$item['is_winner'] = 'GAGNANT';
|
||
|
||
}
|
||
|
||
public function exportCsv($items, $filename){
|
||
$row_definition = array(
|
||
'Date_vente_start' => 'date_start',
|
||
'Fin_du_concours' => 'gameOver',
|
||
'ID_vente' => 'id_privatesales',
|
||
'Nom_vente' => 'title',
|
||
'ID_produit' => 'id_product',
|
||
'Nom_produit' => 'productName',
|
||
'ID_attribute' => 'id_product_attribute',
|
||
'Nom_attribute' => 'attributeName',
|
||
'ID_participant' => 'id_customer',
|
||
'Nom_participant' => 'customerName',
|
||
'Email_participant' => 'email',
|
||
'Gagnant' => 'is_winner',
|
||
);
|
||
|
||
//open file pointer to standard output
|
||
/* ob_start();*/
|
||
$fp = fopen("php://output", 'w');
|
||
$delim = ';';
|
||
|
||
$data=array();
|
||
foreach ($row_definition as $col => $index)
|
||
$data[]=$col;
|
||
fputcsv ($fp,$data,$delim);
|
||
|
||
foreach ($items as $item) {
|
||
$this->buildExport($item);
|
||
$data = array();
|
||
foreach ($row_definition as $index)
|
||
$data[] = (isset($item[$index]) ? $item[$index] : '');
|
||
fputcsv ($fp,array_map('utf8_decode',array_values($data)),$delim);
|
||
}
|
||
|
||
fclose($fp);
|
||
/* return ob_get_clean();*/
|
||
}
|
||
} |