* @copyright 2007-2017 ST-themes * @license Use, by you or one client for one Prestashop instance. */ if (!defined('_PS_VERSION_')) exit; use PrestaShop\PrestaShop\Core\Module\WidgetInterface; require_once _PS_MODULE_DIR_.'stnewsletter/classes/StNewsLetterClass.php'; class StNewsLetter extends Module implements WidgetInterface { private $templateFile; public $imgtype = array('jpg', 'gif', 'jpeg', 'png'); protected static $access_rights = 0775; private $_pages = array(); private $_html = ''; public $fields_list; public $fields_form; public $fields_value; private $validation_errors = array(); private $_prefix_st = 'ST_NW_'; public static $location = array( 4 => array('id' =>4 , 'name' => 'Popup'), 36 => array('id' =>36 , 'name' => 'Full width top', 'hook' => 'FullWidthTop', 'full_width' => 1), 31 => array('id' =>31 , 'name' => 'Full width top 2', 'hook' => 'FullWidthTop2', 'full_width' => 1), 16 => array('id' =>16 , 'name' => 'Homepage top', 'hook' => 'HomeTop'), 1 => array('id' =>1 , 'name' => 'Homepage', 'hook' => 'Home'), 17 => array('id' =>17 , 'name' => 'Homepage bottom', 'hook' => 'HomeBottom'), 29 => array('id' =>29 , 'name' => 'Homepage left', 'hook' => 'HomeLeft'), 30 => array('id' =>30 , 'name' => 'Homepage Right', 'hook' => 'HomeRight'), 53 => array('id' =>53 , 'name' => 'Homepage first quarter', 'hook' => 'HomeFirstQuarter'), 54 => array('id' =>54 , 'name' => 'Homepage second quarter', 'hook' => 'HomeSecondQuarter'), 58 => array('id' =>58 , 'name' => 'Homepage third quarter', 'hook' => 'HomeThirdQuarter'), 59 => array('id' =>59 , 'name' => 'Homepage fourth quarter', 'hook' => 'HomeFourthQuarter'), 37 => array('id' =>37 , 'name' => 'Full width Bottom', 'hook' => 'FullWidthBottom', 'full_width' => 1), 2 => array('id' =>2 , 'name' => 'Left column except the produt page', 'hook' => 'LeftColumn', 'column'=>1), 10 => array('id' =>10 , 'name' => 'Right column except the produt page', 'hook' => 'RightColumn', 'column'=>1), 100 => array('id' =>100 , 'name' => 'Left column on the product page only', 'hook' => 'LeftColumnProduct', 'column'=>1), 101 => array('id' =>101 , 'name' => 'Right column on the product page only', 'hook' => 'RightColumnProduct', 'column'=>1), 102 => array('id' =>102 , 'name' => 'Product right column', 'hook' => 'ProductRightColumn', 'column'=>1), 13 => array('id' =>13 , 'name' => 'Stacked footer (Column 1)' , 'hook' => 'StackedFooter1', 'is_stacked_footer'=>1), 38 => array('id' =>38 , 'name' => 'Stacked footer (Column 2)' , 'hook' => 'StackedFooter2', 'is_stacked_footer'=>1), 55 => array('id' =>55 , 'name' => 'Stacked footer (Column 3)' , 'hook' => 'StackedFooter3', 'is_stacked_footer'=>1), 39 => array('id' =>39 , 'name' => 'Stacked footer (Column 4)' , 'hook' => 'StackedFooter4', 'is_stacked_footer'=>1), 40 => array('id' =>40 , 'name' => 'Stacked footer (Column 5)' , 'hook' => 'StackedFooter5', 'is_stacked_footer'=>1), 41 => array('id' =>41 , 'name' => 'Stacked footer (Column 6)' , 'hook' => 'StackedFooter6', 'is_stacked_footer'=>1), 3 => array('id' =>3 , 'name' => 'Footer (3/12 wide)', 'span' => '3', 'hook' => 'Footer'), 43 => array('id' =>43 , 'name' => 'Footer (2/12 wide)', 'span' => '2', 'hook' => 'Footer'), 56 => array('id' =>56 , 'name' => 'Footer (2.4/12 wide)', 'span' => '2-4', 'hook' => 'Footer'), 44 => array('id' =>44 , 'name' => 'Footer (4/12 wide)', 'span' => '4', 'hook' => 'Footer'), 45 => array('id' =>45 , 'name' => 'Footer (5/12 wide)', 'span' => '5', 'hook' => 'Footer'), 46 => array('id' =>46 , 'name' => 'Footer (6/12 wide)', 'span' => '6', 'hook' => 'Footer'), 81 => array('id' =>81 , 'name' => 'Footer (7/12 wide)', 'span' => '7', 'hook' => 'Footer'), 82 => array('id' =>82 , 'name' => 'Footer (8/12 wide)', 'span' => '8', 'hook' => 'Footer'), 83 => array('id' =>83 , 'name' => 'Footer (9/12 wide)', 'span' => '9', 'hook' => 'Footer'), 84 => array('id' =>84 , 'name' => 'Footer (10/12 wide)', 'span' => '10', 'hook' => 'Footer'), 47 => array('id' =>47 , 'name' => 'Footer (12/12 wide)', 'span' => '12', 'hook' => 'Footer'), 12 => array('id' =>12 , 'name' => 'Footer tertiary (3/12 wide)', 'span' => '3', 'hook' => 'FooterAfter'), 48 => array('id' =>48 , 'name' => 'Footer tertiary (2/12 wide)', 'span' => '2', 'hook' => 'FooterAfter'), 57 => array('id' =>57 , 'name' => 'Footer tertiary (2.4/12 wide)', 'span' => '2-4', 'hook' => 'FooterAfter'), 49 => array('id' =>49 , 'name' => 'Footer tertiary (4/12 wide)', 'span' => '4', 'hook' => 'FooterAfter'), 50 => array('id' =>50 , 'name' => 'Footer tertiary (5/12 wide)', 'span' => '5', 'hook' => 'FooterAfter'), 51 => array('id' =>51 , 'name' => 'Footer tertiary (6/12 wide)', 'span' => '6', 'hook' => 'FooterAfter'), 91 => array('id' =>91 , 'name' => 'Footer tertiary (7/12 wide)', 'span' => '7', 'hook' => 'FooterAfter'), 92 => array('id' =>92 , 'name' => 'Footer tertiary (8/12 wide)', 'span' => '8', 'hook' => 'FooterAfter'), 93 => array('id' =>93 , 'name' => 'Footer tertiary (9/12 wide)', 'span' => '9', 'hook' => 'FooterAfter'), 94 => array('id' =>94 , 'name' => 'Footer tertiary (10/12 wide)', 'span' => '10', 'hook' => 'FooterAfter'), 52 => array('id' =>52 , 'name' => 'Footer tertiary (12/12 wide)', 'span' => '12', 'hook' => 'FooterAfter'), ); public $vc_hooks; protected $templatePath; public function __construct() { $this->name = 'stnewsletter'; $this->tab = 'front_office_features'; $this->version = '1.4.5'; $this->author = 'SUNNYTOO.COM'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->trans('Newsletter popup', array(), 'Modules.Stnewsletter.Admin'); $this->description = $this->trans('Adds a block for newsletter subscription.', array(), 'Modules.Stnewsletter.Admin'); $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->templateFile = 'module:stnewsletter/views/templates/hook/stnewsletter.tpl'; $this->file = 'export_'.date('YmdHis').'.csv'; $this->controllers = array('verification'); $this->vc_hooks = array( 'Full width block' => 'displayFullWidthTop', 'Block' => 'displayHome', 'Column block' => 'displayLeftColumn', 'Footer block' => 'displayStackedFooter1', ); $this->templatePath = 'module:'.$this->name.'/views/templates/hook/'; } private function initPages() { $this->_pages = array( array( 'id' => 'index', 'val' => '1', 'name' => $this->getTranslator()->trans('Index', array(), 'Admin.Theme.Panda') ), array( 'id' => 'category', 'val' => '2', 'name' => $this->getTranslator()->trans('Category', array(), 'Admin.Theme.Panda') ), array( 'id' => 'product', 'val' => '4', 'name' => $this->getTranslator()->trans('Product', array(), 'Admin.Theme.Panda') ), array( 'id' => 'pricesdrop', 'val' => '8', 'name' => $this->getTranslator()->trans('Prices Drop', array(), 'Admin.Theme.Panda') ), array( 'id' => 'newproducts', 'val' => '16', 'name' => $this->getTranslator()->trans('New Products', array(), 'Admin.Theme.Panda') ), array( 'id' => 'manufacturer', 'val' => '32', 'name' => $this->getTranslator()->trans('Manufacturer', array(), 'Admin.Theme.Panda') ), array( 'id' => 'supplier', 'val' => '64', 'name' => $this->getTranslator()->trans('Supplier', array(), 'Admin.Theme.Panda') ), array( 'id' => 'bestsales', 'val' => '128', 'name' => $this->getTranslator()->trans('Best Sales', array(), 'Admin.Theme.Panda') ), array( 'id' => 'cms', 'val' => '256', 'name' => $this->getTranslator()->trans('Cms', array(), 'Admin.Theme.Panda') ), array( 'id' => 'cart', 'val' => '512', 'name' => $this->getTranslator()->trans('Shopping cart', array(), 'Admin.Theme.Panda') ), array( 'id' => 'module-stblog-default', 'val' => '1024', 'name' => $this->getTranslator()->trans('Blog homepage', array(), 'Admin.Theme.Panda') ), array( 'id' => 'module-stblog-category', 'val' => '2048', 'name' => $this->getTranslator()->trans('Blog category', array(), 'Admin.Theme.Panda') ), array( 'id' => 'module-stblog-article', 'val' => '4096', 'name' => $this->getTranslator()->trans('Blog post', array(), 'Admin.Theme.Panda') ), ); } public function install() { $res = parent::install() && $this->installDB() && $this->registerHook('displayHeader') && $this->registerHook('displaySideBar') && $this->registerHook('actionCustomerAccountAdd') && $this->registerHook('additionalCustomerFormFields') && $this->registerHook('displayAdminCustomersForm') && $this->registerHook('vcBeforeInit') && $this->registerHook('registerGDPRConsent') && $this->registerHook('actionDeleteGDPRCustomer') && $this->registerHook('actionExportGDPRData') && Configuration::updateValue($this->_prefix_st.'VERIFICATION_EMAIL', 0) && Configuration::updateValue($this->_prefix_st.'CONFIRMATION_EMAIL', 0) && Configuration::updateValue($this->_prefix_st.'VOUCHER_CODE', '') && Configuration::updateValue($this->_prefix_st.'UNIQUE_VOUCHER', 0) && Configuration::updateValue($this->_prefix_st.'VALIDITY', '7') && Configuration::updateValue($this->_prefix_st.'USER_ONLY', 0) && Configuration::updateValue('NW_SALT', Tools::passwdGen(16)); if ($res) foreach(Shop::getShops(false) as $shop) $res &= $this->sampleData($shop['id_shop']); $conditions = array(); $languages = Language::getLanguages(false); foreach ($languages as $lang) { $conditions[(int) $lang['id_lang']] = $this->getConditionFixtures($lang); } Configuration::updateValue($this->_prefix_st.'NW_CONDITIONS', $conditions, true); $this->prepareHooks(); $this->clearStNewsLetterCache(); return (bool)$res; } public function installDB() { $return = (bool)Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'st_news_letter` ( `id_st_news_letter` INT UNSIGNED NOT NULL AUTO_INCREMENT, `location` int(10) unsigned NOT NULL DEFAULT 0, `hide_on_mobile` tinyint(1) unsigned NOT NULL DEFAULT 0, `active` tinyint(1) unsigned NOT NULL DEFAULT 1, `position` int(10) unsigned NOT NULL DEFAULT 0, `item_k` tinyint(2) unsigned NOT NULL DEFAULT 0, `item_v` varchar(255) DEFAULT NULL, `popup_width` int(10) unsigned NOT NULL DEFAULT 600, `content_text_color` varchar(7) DEFAULT NULL, `content_link_color` varchar(7) DEFAULT NULL, `content_link_hover` varchar(7) DEFAULT NULL, `bg_color` varchar(7) DEFAULT NULL, `bg_pattern` tinyint(2) unsigned NOT NULL DEFAULT 0, `bg_img` varchar(255) DEFAULT NULL, `top_spacing` int(10) unsigned NOT NULL DEFAULT 50, `bottom_spacing` int(10) unsigned NOT NULL DEFAULT 50, `top_padding` varchar(10) DEFAULT NULL, `bottom_padding` varchar(10) DEFAULT NULL, `right_spacing` int(10) unsigned NOT NULL DEFAULT 5, `left_spacing` int(10) unsigned NOT NULL DEFAULT 5, `text_align` tinyint(1) unsigned NOT NULL DEFAULT 0, `input_width` int(10) unsigned NOT NULL DEFAULT 360, `input_height` int(10) unsigned NOT NULL DEFAULT 35, `input_color` varchar(7) DEFAULT NULL, `input_bg` varchar(7) DEFAULT NULL, `input_border` varchar(7) DEFAULT NULL, `btn_color` varchar(7) DEFAULT NULL, `btn_bg` varchar(7) DEFAULT NULL, `btn_hover_color` varchar(7) DEFAULT NULL, `btn_hover_bg` varchar(7) DEFAULT NULL, `show_popup` tinyint(1) unsigned NOT NULL DEFAULT 0, `show_newsletter` tinyint(1) unsigned NOT NULL DEFAULT 1, `cookies_time` int(10) unsigned NOT NULL DEFAULT 0, `delay_popup` int(10) unsigned NOT NULL DEFAULT 2, `subscribed` tinyint(1) unsigned NOT NULL DEFAULT 1, `start_time` datetime DEFAULT NULL, `stop_time` datetime DEFAULT NULL, `display_on` int(10) unsigned NOT NULL DEFAULT 0, `show_gender` tinyint(1) unsigned NOT NULL DEFAULT 0, `title_align` tinyint(1) unsigned NOT NULL DEFAULT 0, `id_gender` int(10) unsigned NOT NULL DEFAULT 0, `template` tinyint(3) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id_st_news_letter`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); $return &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'st_news_letter_lang` ( `id_st_news_letter` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id_lang` int(10) unsigned NOT NULL, `content` text NOT NULL, PRIMARY KEY (`id_st_news_letter`, `id_lang`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); $return &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'st_news_letter_shop` ( `id_st_news_letter` int(10) UNSIGNED NOT NULL, `id_shop` int(11) NOT NULL, PRIMARY KEY (`id_st_news_letter`,`id_shop`), KEY `id_shop` (`id_shop`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'emailsubscription` ( `id` int(6) NOT NULL AUTO_INCREMENT, `id_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\', `id_shop_group` INTEGER UNSIGNED NOT NULL DEFAULT \'1\', `email` varchar(255) NOT NULL, `newsletter_date_add` DATETIME NULL, `ip_registration_newsletter` varchar(15) NOT NULL, `http_referer` VARCHAR(255) NULL, `active` TINYINT(1) NOT NULL DEFAULT \'0\', `id_gender` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY(`id`) ) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8;'); $field = Db::getInstance()->executeS('Describe `'._DB_PREFIX_.'emailsubscription` `id_gender`'); if(!is_array($field) || !count($field)) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'emailsubscription` ADD `id_gender` int(10) unsigned NOT NULL DEFAULT 0'); } $field = Db::getInstance()->executeS('Describe `'._DB_PREFIX_.'emailsubscription` `voucher_sent`'); if(!is_array($field) || !count($field)) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'emailsubscription` ADD `voucher_sent` tinyint(1) unsigned NOT NULL DEFAULT 0'); } return $return; } public function sampleData($id_shop) { $return = true; $samples = array( array( 'location' => 3, 'active' => 1, 'hide_on_mobile'=> 0, 'text_align' => 1, 'input_width' => 258, 'input_height' => 35, 'show_newsletter' => 1, 'input_border' => '#444444', 'subscribed' => 1, 'text' => '
Sign up today for free and be the first to get notified on our new updates, discounts and special Offers.
', ) ); foreach($samples as $k=>$sample) { $module = new StNewsLetterClass(); foreach (Language::getLanguages(false) as $lang) { $module->content[$lang['id_lang']] = $sample['text']; } $module->location = $sample['location']; $module->active = $sample['active']; $module->hide_on_mobile = $sample['hide_on_mobile']; $module->text_align = $sample['text_align']; $module->input_width = $sample['input_width']; $module->input_height = $sample['input_height']; $module->show_newsletter= $sample['show_newsletter']; $module->subscribed = $sample['subscribed']; $module->input_border = $sample['input_border']; $module->position = $k; $module->id_shop_list = array((int)$id_shop); $return &= $module->add(); } return $return; } public function uninstall() { $this->clearStNewsLetterCache(); // Delete configuration return $this->uninstallDB() && parent::uninstall(); } public function uninstallDB() { return Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'st_news_letter`,`'._DB_PREFIX_.'st_news_letter_lang`,`'._DB_PREFIX_.'st_news_letter_shop`'); } protected function stGetCacheId($key,$type='location',$name = null) { $cache_id = parent::getCacheId($name); return $cache_id.'_'.$key.'_'.$type; } private function clearStNewsLetterCache() { $this->_clearCache('*'); } private function _checkImageDir() { $result = ''; if (!file_exists(_PS_UPLOAD_DIR_.$this->name)) { $success = @mkdir(_PS_UPLOAD_DIR_.$this->name, self::$access_rights, true) || @chmod(_PS_UPLOAD_DIR_.$this->name, self::$access_rights); if(!$success) $this->_html .= $this->displayError('"'._PS_UPLOAD_DIR_.$this->name.'" '.$this->getTranslator()->trans('An error occurred during new folder creation', array(), 'Admin.Theme.Panda')); } if (!is_writable(_PS_UPLOAD_DIR_)) $this->_html .= $this->displayError('"'._PS_UPLOAD_DIR_.$this->name.'" '.$this->getTranslator()->trans('directory isn\'t writable.', array(), 'Admin.Theme.Panda')); if (!is_writable(_PS_MODULE_DIR_.$this->name.'/views/css')) $this->_html .= $this->displayError('"'._PS_MODULE_DIR_.$this->name.'/views/css'.'" '.$this->getTranslator()->trans('directory isn\'t writable.', array(), 'Admin.Theme.Panda')); return $result; } public function getContent() { $check_result = $this->_checkImageDir(); $this->context->controller->addCSS(($this ->_path).'views/css/admin.css'); $this->context->controller->addJS($this->_path. 'views/js/admin.js'); $this->initPages(); $id_st_news_letter = (int)Tools::getValue('id_st_news_letter'); if ((Tools::isSubmit('statusstnewsletter'))) { $news_letter = new StNewsLetterClass((int)$id_st_news_letter); if($news_letter->id && $news_letter->toggleStatus()) { $this->clearStNewsLetterCache(); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); //$this->_html .= $this->displayConfirmation($this->getTranslator()->trans('The status has been updated successfully.', array(), 'Admin.Theme.Panda')); } else $this->_html .= $this->displayError($this->getTranslator()->trans('An error occurred while updating the status.', array(), 'Admin.Theme.Panda')); } if(Tools::getValue('act')=='delete_image' && $identi = Tools::getValue('identi')) { $result = array( 'r' => false, 'm' => '', 'd' => '' ); $news_letter = new StNewsLetterClass((int)(int)$identi); if(Validate::isLoadedObject($news_letter)) { $news_letter->bg_img = ''; if($news_letter->save()) { $result['r'] = true; } } die(json_encode($result)); } if ((Tools::isSubmit('groupdeleteimagestnewsletter'))) { $news_letter = new StNewsLetterClass($id_st_news_letter); if($news_letter->id) { @unlink(_PS_ROOT_DIR_._THEME_PROD_PIC_DIR_.$this->name.'/'.$news_letter->bg_img); $news_letter->bg_img = ''; if ($news_letter->save()) { //$this->_html .= $this->displayConfirmation($this->getTranslator()->trans('The image was deleted successfully.', array(), 'Admin.Theme.Panda')); $this->clearStNewsLetterCache(); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&conf=7&updatestnewsletter&id_st_news_letter='.(int)$news_letter->id.'&token='.Tools::getAdminTokenLite('AdminModules')); }else $this->_html .= $this->displayError($this->getTranslator()->trans('An error occurred while delete image.', array(), 'Admin.Theme.Panda')); } else $this->_html .= $this->displayError($this->getTranslator()->trans('An error occurred while delete image.', array(), 'Admin.Theme.Panda')); } if (isset($_POST['savestnewsletter']) || isset($_POST['savestnewsletterAndStay'])) { if ($id_st_news_letter) $news_letter = new StNewsLetterClass((int)$id_st_news_letter); else $news_letter = new StNewsLetterClass(); $error = array(); $news_letter->copyFromPost(); /*if(!$news_letter->location) $error[] = $this->displayError($this->getTranslator()->trans('The field "Show on" is required', array(), 'Modules.Stnewsletter.Admin'));*/ if(!count($error)) { if (isset($_FILES['bg_img']) && isset($_FILES['bg_img']['tmp_name']) && !empty($_FILES['bg_img']['tmp_name'])) { if ($vali = ImageManager::validateUpload($_FILES['bg_img'], Tools::convertBytes(ini_get('upload_max_filesize')))) $error[] = Tools::displayError($vali); else { $bg_image = $this->uploadCheckAndGetName($_FILES['bg_img']['name']); if(!$bg_image) $error[] = Tools::displayError('Image format not recognized'); if (!move_uploaded_file($_FILES['bg_img']['tmp_name'], _PS_UPLOAD_DIR_.$this->name.'/'.$bg_image)) $error[] = Tools::displayError('Error move uploaded file'); else $news_letter->bg_img = $this->name.'/'.$bg_image; } } } $display_on = 0; foreach($this->_pages as $v) $display_on += (int)Tools::getValue('display_on_'.$v['id']); $news_letter->display_on = $display_on; if (!count($error) && $news_letter->validateFields(false) && $news_letter->validateFieldsLang(false)) { $shop_ids = $news_letter->getShopIds(); $news_letter->clearShopIds(); $id_shop_list = array(); if($assos_shop = Tools::getValue('checkBoxShopAsso_st_news_letter')) { foreach ($assos_shop as $id_shop => $row) { $id_shop_list[] = $id_shop; } } if (!$id_shop_list) { $id_shop_list = array(Context::getContext()->shop->id); } $news_letter->id_shop_list = array_unique($id_shop_list); if($news_letter->save()) { $this->prepareHooks(); $this->clearStNewsLetterCache(); if(isset($_POST['savestnewsletterAndStay']) || Tools::getValue('fr') == 'view') { $rd_str = isset($_POST['savestnewsletterAndStay']) && Tools::getValue('fr') == 'view' ? 'fr=view&update' : (isset($_POST['savestnewsletterAndStay']) ? 'update' : 'view'); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&id_st_news_letter='.$news_letter->id.'&conf='.($id_st_news_letter?4:3).'&'.$rd_str.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); } else $this->_html .= $this->displayConfirmation($this->getTranslator()->trans('Newsletter', array(), 'Admin.Theme.Panda').' '.($id_st_news_letter ? $this->getTranslator()->trans('updated', array(), 'Admin.Theme.Panda') : $this->getTranslator()->trans('added', array(), 'Admin.Theme.Panda'))); } else { $news_letter->restoreShopIds($shop_ids); $this->_html .= $this->displayError($this->getTranslator()->trans('An error occurred during newsletter', array(), 'Modules.Stnewsletter.Admin').' '.($id_st_news_letter ? $this->getTranslator()->trans('updating', array(), 'Admin.Theme.Panda') : $this->getTranslator()->trans('creation', array(), 'Admin.Theme.Panda'))); } } else $this->_html .= count($error) ? implode('',$error) : $this->displayError($this->getTranslator()->trans('Invalid value for field(s).', array(), 'Admin.Theme.Panda')); } if (isset($_POST['savesettingstnewsletter']) || isset($_POST['savesettingstnewsletterAndStay'])) { $this->initFieldsForm(); foreach($this->fields_form as $form) foreach($form['form']['input'] as $field) if(isset($field['validation'])) { $errors = array(); $value = Tools::getValue($field['name']); if (isset($field['required']) && $field['required'] && $value==false && (string)$value != '0') $errors[] = sprintf(Tools::displayError('Field "%s" is required.'), $field['label']); elseif($value) { $field_validation = $field['validation']; if (!Validate::$field_validation($value)) $errors[] = sprintf(Tools::displayError('Field "%s" is invalid.'), $field['label']); } // Set default value if ($value === false && isset($field['default_value'])) $value = $field['default_value']; if(count($errors)) { $this->validation_errors = array_merge($this->validation_errors, $errors); } elseif($value==false) { switch($field['validation']) { case 'isUnsignedId': case 'isUnsignedInt': case 'isInt': case 'isBool': $value = 0; break; default: $value = ''; break; } Configuration::updateValue($this->_prefix_st.strtoupper($field['name']), $value); } else Configuration::updateValue($this->_prefix_st.strtoupper($field['name']), $value); } if(count($this->validation_errors)) $this->_html .= $this->displayError(implode('
',
),
array(
'id' => 'template_1',
'value' => 1,
'label' => '
',
),
),
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Top padding:', array(), 'Admin.Theme.Panda'),
'name' => 'top_spacing',
'default_value' => 0,
'class' => 'fixed-width-sm',
'suffix' => 'px'
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Bottom padding:', array(), 'Admin.Theme.Panda'),
'name' => 'bottom_spacing',
'default_value' => 0,
'class' => 'fixed-width-sm',
'suffix' => 'px'
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Top spacing:', array(), 'Admin.Theme.Panda'),
'name' => 'top_padding',
'class' => 'fixed-width-sm',
'suffix' => 'px',
'desc' => $this->getTranslator()->trans('Leave it empty to use the default value.', array(), 'Admin.Theme.Panda'),
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Bottom spacing:', array(), 'Admin.Theme.Panda'),
'name' => 'bottom_padding',
'class' => 'fixed-width-sm',
'suffix' => 'px',
'desc' => $this->getTranslator()->trans('Leave it empty to use the default value.', array(), 'Admin.Theme.Panda'),
),
array(
'type' => 'select',
'label' => $this->getTranslator()->trans('Right spacing:', array(), 'Admin.Theme.Panda'),
'name' => 'right_spacing',
'default_value' => 0,
'options' => array(
'query' => array(
array('id' => 0, 'name'=>'0%'),
array('id' => 5, 'name'=>'5%'),
array('id' => 10, 'name'=>'10%'),
array('id' => 20, 'name'=>'20%'),
array('id' => 30, 'name'=>'30%'),
array('id' => 40, 'name'=>'40%'),
array('id' => 50, 'name'=>'50%'),
array('id' => 60, 'name'=>'60%'),
array('id' => 70, 'name'=>'70%'),
),
'id' => 'id',
'name' => 'name',
),
),
array(
'type' => 'select',
'label' => $this->getTranslator()->trans('Left spacing:', array(), 'Admin.Theme.Panda'),
'name' => 'left_spacing',
'default_value' => 0,
'options' => array(
'query' => array(
array('id' => 0, 'name'=>'0%'),
array('id' => 5, 'name'=>'5%'),
array('id' => 10, 'name'=>'10%'),
array('id' => 20, 'name'=>'20%'),
array('id' => 30, 'name'=>'30%'),
array('id' => 40, 'name'=>'40%'),
array('id' => 50, 'name'=>'50%'),
array('id' => 60, 'name'=>'60%'),
array('id' => 70, 'name'=>'70%'),
),
'id' => 'id',
'name' => 'name',
),
),
array(
'type' => 'radio',
'label' => $this->getTranslator()->trans('Hide on mobile:', array(), 'Admin.Theme.Panda'),
'name' => 'hide_on_mobile',
'default_value' => 0,
'values' => array(
array(
'id' => 'hide_on_mobile_1',
'value' => 1,
'label' => $this->getTranslator()->trans('Hide', array(), 'Admin.Theme.Panda')),
array(
'id' => 'hide_on_mobile_2',
'value' => 2,
'label' => $this->getTranslator()->trans('Open', array(), 'Admin.Theme.Panda')),
array(
'id' => 'hide_on_mobile_off',
'value' => 0,
'label' => $this->getTranslator()->trans('Collapse', array(), 'Admin.Theme.Panda')),
),
'desc' => $this->getTranslator()->trans('Screen width < 768px.', array(), 'Admin.Theme.Panda'),
),
array(
'type' => 'radio',
'label' => $this->getTranslator()->trans('Title:', array(), 'Admin.Theme.Panda'),
'name' => 'title_align',
'default_value' => 0,
'values' => array(
array(
'id' => 'left',
'value' => 0,
'label' => $this->getTranslator()->trans('Left', array(), 'Admin.Theme.Panda')),
array(
'id' => 'center',
'value' => 1,
'label' => $this->getTranslator()->trans('Center', array(), 'Admin.Theme.Panda')),
array(
'id' => 'right',
'value' => 2,
'label' => $this->getTranslator()->trans('Right', array(), 'Admin.Theme.Panda')),
array(
'id' => 'none',
'value' => 3,
'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Panda')),
),
'validation' => 'isUnsignedInt',
),
array(
'type' => 'switch',
'label' => $this->getTranslator()->trans('Show social title:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'show_gender',
'is_bool' => true,
'default_value' => 0,
'values' => array(
array(
'id' => 'show_gender_on',
'value' => 1,
'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Panda')
),
array(
'id' => 'show_gender_off',
'value' => 0,
'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Panda')
)
),
'desc' => $this->getTranslator()->trans('Male or female.', array(), 'Modules.Stnewsletter.Admin'),
),
array(
'type' => 'switch',
'label' => $this->getTranslator()->trans('Status:', array(), 'Admin.Theme.Panda'),
'name' => 'active',
'is_bool' => true,
'default_value' => 1,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->getTranslator()->trans('Enabled', array(), 'Admin.Theme.Panda')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->getTranslator()->trans('Disabled', array(), 'Admin.Theme.Panda')
)
),
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Position:', array(), 'Admin.Theme.Panda'),
'name' => 'position',
'default_value' => 0,
'class' => 'fixed-width-sm'
),
array(
'type' => 'hidden',
'name' => 'fr',
'default_value' => Tools::getValue('fr'),
),
),
'buttons' => array(
array(
'type' => 'submit',
'title'=> $this->getTranslator()->trans('Save all', array(), 'Admin.Theme.Panda'),
'icon' => 'process-icon-save',
'class'=> 'pull-right'
),
),
'submit' => array(
'title' => $this->getTranslator()->trans('Save and stay', array(), 'Admin.Actions'),
'stay' => true
),
);
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->getTranslator()->trans('Content', array(), 'Admin.Theme.Panda'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'textarea',
'label' => $this->getTranslator()->trans('Content:', array(), 'Admin.Theme.Panda'),
'lang' => true,
'name' => 'content',
'cols' => 40,
'rows' => 10,
'autoload_rte' => true,
'desc' => $this->getTranslator()->trans('Format your entry with some basic HTML. Click on FLASH button above to use predefined templates.', array(), 'Modules.Stnewsletter.Admin'),
),
array(
'type' => 'go_to_adv_editor',
'label' => '',
'name' => Context::getContext()->link->getModuleLink(
'stbanner', 'adveditor', array('caller_module'=>$this->name,'adveditor_target'=>'content')),
'name_blank' => Context::getContext()->link->getModuleLink(
'stbanner', 'adveditor', array('caller_module'=>$this->name,'adveditor_window'=>'blank','adveditor_target'=>'content')),
),
array(
'type' => 'radio',
'label' => $this->getTranslator()->trans('Content alignment:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'text_align',
'default_value' => 2,
'values' => array(
array(
'id' => 'text_align_left',
'value' => 1,
'label' => $this->getTranslator()->trans('Left', array(), 'Admin.Theme.Panda')),
array(
'id' => 'text_align_center',
'value' => 2,
'label' => $this->getTranslator()->trans('Center', array(), 'Admin.Theme.Panda')),
array(
'id' => 'text_align_right',
'value' => 3,
'label' => $this->getTranslator()->trans('Right', array(), 'Admin.Theme.Panda')),
),
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Color:', array(), 'Admin.Theme.Panda'),
'name' => 'content_text_color',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Link color:', array(), 'Admin.Theme.Panda'),
'name' => 'content_link_color',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Link hover color:', array(), 'Admin.Theme.Panda'),
'name' => 'content_link_hover',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Border color:', array(), 'Admin.Theme.Panda'),
'name' => 'input_border',
'size' => 33,
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Input width:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'input_width',
'default_value' => 0,
'class' => 'fixed-width-sm',
'suffix' => 'px'
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Input height:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'input_height',
'default_value' => 0,
'class' => 'fixed-width-sm',
'suffix' => 'px'
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Input text color:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'input_color',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Input background color:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'input_bg',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Button color:', array(), 'Admin.Theme.Panda'),
'name' => 'btn_color',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Button background color:', array(), 'Admin.Theme.Panda'),
'name' => 'btn_bg',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Button hover color:', array(), 'Admin.Theme.Panda'),
'name' => 'btn_hover_color',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Button hover background color:', array(), 'Admin.Theme.Panda'),
'name' => 'btn_hover_bg',
'size' => 33,
),
array(
'type' => 'color',
'label' => $this->getTranslator()->trans('Background color:', array(), 'Admin.Theme.Panda'),
'name' => 'bg_color',
'size' => 33,
),
array(
'type' => 'select',
'label' => $this->getTranslator()->trans('Select a pattern number:', array(), 'Admin.Theme.Panda'),
'name' => 'bg_pattern',
'options' => array(
'query' => $this->getPatternsArray(),
'id' => 'id',
'name' => 'name',
'default' => array(
'value' => 0,
'label' => $this->getTranslator()->trans('None', array(), 'Admin.Theme.Panda'),
),
),
'desc' => $this->getPatterns(),
'validation' => 'isUnsignedInt',
),
'bg_img_field' => array(
'type' => 'file',
'label' => $this->getTranslator()->trans('Upload your own pattern or background image:', array(), 'Admin.Theme.Panda'),
'name' => 'bg_img',
'desc' => '',
),
array(
'type' => 'html',
'id' => 'a_cancel',
'label' => '',
'name' => ' '.$this->getTranslator()->trans('Back to list', array(), 'Admin.Theme.Panda').'',
),
),
'buttons' => array(
array(
'type' => 'submit',
'title'=> $this->getTranslator()->trans('Save all', array(), 'Admin.Theme.Panda'),
'icon' => 'process-icon-save',
'class'=> 'pull-right'
),
),
'submit' => array(
'title' => $this->getTranslator()->trans('Save and stay', array(), 'Admin.Actions'),
'stay' => true
),
);
$this->fields_form[2]['form'] = array(
'legend' => array(
'title' => $this->getTranslator()->trans('Popup', array(), 'Modules.Stnewsletter.Admin'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'checkbox',
'label' => $this->getTranslator()->trans('Display on', array(), 'Admin.Theme.Panda'),
'name' => 'display_on',
'lang' => true,
'default_value' => 1,
'values' => array(
'query' => $this->_pages,
'id' => 'id',
'name' => 'name'
),
'desc' => $this->getTranslator()->trans('This option is for Popup windows.', array(), 'Modules.Stnewsletter.Admin'),
),
array(
'type' => 'switch',
'label' => $this->getTranslator()->trans('Display newsletter form:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'show_newsletter',
'is_bool' => true,
'default_value' => 1,
'values' => array(
array(
'id' => 'show_newsletter_on',
'value' => 1,
'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Panda')
),
array(
'id' => 'show_newsletter_off',
'value' => 0,
'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Panda')
)
),
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Width:', array(), 'Admin.Theme.Panda'),
'name' => 'popup_width',
'default_value' => 600,
'class' => 'fixed-width-sm',
'suffix' => 'px',
),
array(
'type' => 'radio',
'label' => $this->getTranslator()->trans('How to show this popup:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'show_popup',
'default_value' => 0,
'is_bool' => true,
'values' => array(
array(
'id' => 'image',
'value' => 0,
'label' => $this->getTranslator()->trans('At all time with a do not show option', array(), 'Modules.Stnewsletter.Admin')),
array(
'id' => 'hosted',
'value' => 1,
'label' => $this->getTranslator()->trans('At all time', array(), 'Modules.Stnewsletter.Admin')),
array(
'id' => 'youtube',
'value' => 2,
'label' => $this->getTranslator()->trans('First time only', array(), 'Modules.Stnewsletter.Admin')),
),
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Do not show again time period:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'cookies_time',
'default_value' => 7,
'class' => 'fixed-width-sm',
'suffix' => 'days',
),
array(
'type' => 'text',
'label' => $this->getTranslator()->trans('Delay:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'delay_popup',
'default_value' => 2,
'class' => 'fixed-width-sm',
'suffix' => 's',
),
array(
'type' => 'switch',
'label' => $this->getTranslator()->trans('Do not show this popup if already subscribed:', array(), 'Modules.Stnewsletter.Admin'),
'name' => 'subscribed',
'is_bool' => true,
'default_value' => 1,
'values' => array(
array(
'id' => 'subscribed_on',
'value' => 1,
'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Panda')
),
array(
'id' => 'subscribed_off',
'value' => 0,
'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Panda')
)
),
),
array(
'type' => 'html',
'id' => 'a_cancel',
'label' => '',
'name' => ' '.$this->getTranslator()->trans('Back to list', array(), 'Admin.Theme.Panda').'',
),
),
'buttons' => array(
array(
'type' => 'submit',
'title'=> $this->getTranslator()->trans('Save all', array(), 'Admin.Theme.Panda'),
'icon' => 'process-icon-save',
'class'=> 'pull-right'
),
),
'submit' => array(
'title' => $this->getTranslator()->trans('Save and stay', array(), 'Admin.Actions'),
'stay' => true
),
);
if (Shop::isFeatureActive())
{
$this->fields_form[0]['form']['input'][] = array(
'type' => 'shop',
'label' => $this->getTranslator()->trans('Shop association:', array(), 'Admin.Theme.Panda'),
'name' => 'checkBoxShopAsso',
);
}
$this->fields_form[0]['form']['input'][] = array(
'type' => 'html',
'id' => 'a_cancel',
'label' => '',
'name' => ' Back to list',
);
$id_st_news_letter = (int)Tools::getValue('id_st_news_letter');
$news_letter = new StNewsLetterClass($id_st_news_letter);
if($news_letter->id)
{
$this->fields_form[0]['form']['input'][] = array('type' => 'hidden', 'name' => 'id_st_news_letter');
if ($news_letter->bg_img)
{
StNewsLetterClass::fetchMediaServer($news_letter->bg_img);
$this->fields_form[1]['form']['input']['bg_img_field']['image'] = ''.$this->getTranslator()->trans('Delete', array(), 'Modules.Stnewsletter.Admin').'
'; } } $helper = new HelperForm(); $helper->show_toolbar = false; $helper->id = (int)$news_letter->id; $helper->module = $this; $helper->table = 'st_news_letter'; $helper->identifier = 'id_st_news_letter'; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->submit_action = 'savestnewsletter'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getFieldsValueSt($news_letter), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); $helper->title = $this->displayName; if (!$news_letter->id) { // Show on Index page in default. $news_letter->display_on = 1; } foreach($this->_pages as $v) $helper->tpl_vars['fields_value']['display_on_'.$v['id']] = (int)$v['val']&(int)$news_letter->display_on; return $helper; } public function initFieldsForm() { $this->fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->getTranslator()->trans('Settings', array(), 'Admin.Theme.Panda'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'switch', 'label' => $this->getTranslator()->trans('Would you like to send a verification email after subscription?', array(), 'Modules.Stnewsletter.Admin'), 'name' => 'verification_email', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Panda') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Panda') ) ), 'validation' => 'isBool', ), array( 'type' => 'switch', 'label' => $this->getTranslator()->trans('Would you like to send a confirmation email after subscription?', array(), 'Modules.Stnewsletter.Admin'), 'name' => 'confirmation_email', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Panda') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Panda') ) ), 'validation' => 'isBool', ), array( 'type' => 'text', 'label' => $this->getTranslator()->trans('Welcome voucher code', array(), 'Modules.Stnewsletter.Admin'), 'name' => 'voucher_code', 'class' => 'fixed-width-md', 'desc' => $this->getTranslator()->trans('Leave blank to disable by default.', array(), 'Admin.Theme.Panda'), 'validation' => 'isString', ), array( 'type' => 'switch', 'label' => $this->getTranslator()->trans('Create a unique voucher code for each subscriber?', array(), 'Modules.Stnewsletter.Admin'), 'name' => 'unique_voucher', 'values' => array( array( 'id' => 'unique_voucher_on', 'value' => 1, 'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Transformer') ), array( 'id' => 'unique_voucher_off', 'value' => 0, 'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Transformer') ) ), 'desc' => $this->getTranslator()->trans('Create a voucher code for each subscriber base on given voucher code.', array(), 'Admin.Theme.Transformer'), 'validation' => 'isBool', ), array( 'type' => 'switch', 'label' => $this->getTranslator()->trans('Send voucher to registered user only', array(), 'Modules.Stnewsletter.Admin'), 'name' => 'user_only', 'values' => array( array( 'id' => 'user_only_on', 'value' => 1, 'label' => $this->getTranslator()->trans('Yes', array(), 'Admin.Theme.Transformer') ), array( 'id' => 'user_only_off', 'value' => 0, 'label' => $this->getTranslator()->trans('No', array(), 'Admin.Theme.Transformer') ) ), 'desc' => $this->getTranslator()->trans('Send a voucher to registered user to restrict the voucher, just the user can use the voucher. if you disable the option, anyone can apply the voucher if he / she gets it.', array(), 'Admin.Theme.Transformer'), 'validation' => 'isBool', ), array( 'type' => 'text', 'label' => $this->getTranslator()->trans('Voucher code validity', array(), 'Modules.Stnewsletter.Admin'), 'name' => 'validity', 'suffix' => 'days', 'class' => 'fixed-width-md', 'desc' => $this->getTranslator()->trans('How many days the voucher code is valid.', array(), 'Admin.Theme.Transformer'), 'validation' => 'isString', ), array( 'type' => 'textarea', 'label' => $this->getTranslator()->trans('Newsletter conditions', array(), 'Modules.Stnewsletter.Admin'), 'lang' => true, 'name' => 'nw_conditions', 'cols' => 40, 'rows' => 100, 'hint' => $this->getTranslator()->trans( 'This text will be displayed beneath the newsletter subscribe button.', array(), 'Modules.Stnewsletter.Admin' ), 'desc' => $this->getTranslator()->trans('Leave blank to disable by default.', array(), 'Modules.Stnewsletter.Admin'), ), ), 'submit' => array( 'title' => $this->getTranslator()->trans('Save', array(), 'Admin.Actions'), 'stay' => true ), ); } protected function initSettingForm() { $helper = new HelperForm(); $helper->show_toolbar = false; $helper->module = $this; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->submit_action = 'savesettingstnewsletter'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper; } private function getConfigFieldsValues() { $fields_values = array( 'verification_email' => Configuration::get($this->_prefix_st.'VERIFICATION_EMAIL'), 'confirmation_email' => Configuration::get($this->_prefix_st.'CONFIRMATION_EMAIL'), 'voucher_code' => Configuration::get($this->_prefix_st.'VOUCHER_CODE'), 'unique_voucher' => Configuration::get($this->_prefix_st.'UNIQUE_VOUCHER'), 'validity' => Configuration::get($this->_prefix_st.'VALIDITY'), 'user_only' => Configuration::get($this->_prefix_st.'USER_ONLY'), 'COUNTRY' => Tools::getValue('COUNTRY'), 'SUSCRIBERS' => Tools::getValue('SUSCRIBERS'), 'OPTIN' => Tools::getValue('OPTIN'), 'action' => 'customers', ); $conditions = array(); $languages = Language::getLanguages(false); foreach ($languages as $lang) { $conditions[$lang['id_lang']] = Configuration::get($this->_prefix_st.'NW_CONDITIONS', $lang['id_lang']); } $fields_values['nw_conditions'] = $conditions; return $fields_values; } public function getPatterns() { $html = ''; foreach(range(1,27) as $v) $html .= '