//blocknewsletter now use boostrap design
This commit is contained in:
@@ -90,55 +90,28 @@ class Blocknewsletter extends Module
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$this->_html = '<h2>'.$this->displayName.'</h2>';
|
||||
$this->_html = '';
|
||||
|
||||
if (Tools::isSubmit('submitUpdate'))
|
||||
{
|
||||
if (isset($_POST['conf_email']) && Validate::isBool((int)$_POST['conf_email']))
|
||||
Configuration::updateValue('NW_CONFIRMATION_EMAIL', pSQL($_POST['conf_email']));
|
||||
$conf_email = Tools::getValue('NW_CONFIRMATION_EMAIL');
|
||||
if ($conf_email && Validate::isBool((int)$conf_email))
|
||||
Configuration::updateValue('NW_CONFIRMATION_EMAIL', (int)$conf_email);
|
||||
|
||||
if (isset($_POST['verif_email']) && Validate::isBool((int)$_POST['verif_email']))
|
||||
Configuration::updateValue('NW_VERIFICATION_EMAIL', (int)$_POST['verif_email']);
|
||||
|
||||
if (!empty($_POST['voucher']) && !Validate::isDiscountName($_POST['voucher']))
|
||||
$this->_html .= '<div class="alert">'.$this->l('The coucher code is invalid.').'</div>';
|
||||
$verif_email = Tools::getValue('NW_VERIFICATION_EMAIL');
|
||||
if ($verif_email && Validate::isBool((int)$verif_email))
|
||||
Configuration::updateValue('NW_VERIFICATION_EMAIL', (int)$verif_email);
|
||||
|
||||
$voucher = Tools::getValue('NW_VOUCHER_CODE');
|
||||
if ($voucher && !Validate::isDiscountName($voucher))
|
||||
$this->_html .= $this->displayError($this->l('The coucher code is invalid.'));
|
||||
else
|
||||
{
|
||||
Configuration::updateValue('NW_VOUCHER_CODE', pSQL($_POST['voucher']));
|
||||
$this->_html .= '<div class="conf ok">'.$this->l('Updated').'</div>';
|
||||
Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
|
||||
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
|
||||
}
|
||||
}
|
||||
return $this->_displayForm();
|
||||
}
|
||||
|
||||
private function _displayForm()
|
||||
{
|
||||
$this->_html .= '
|
||||
<form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'">
|
||||
<fieldset>
|
||||
<legend><img src="'.$this->_path.'logo.gif" />'.$this->l('Settings').'</legend>
|
||||
<label>'.$this->l('Would you like to send a verification email after subscription?').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="verif_email" value="1" '.(Configuration::get('NW_VERIFICATION_EMAIL') ? 'checked="checked" ' : '').'/>'.$this->l('Yes').'
|
||||
<input type="radio" name="verif_email" value="0" '.(!Configuration::get('NW_VERIFICATION_EMAIL') ? 'checked="checked" ' : '').'/>'.$this->l('No').'
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<label>'.$this->l('Would you like to send a confirmation email after subscription?').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="conf_email" value="1" '.(Configuration::get('NW_CONFIRMATION_EMAIL') ? 'checked="checked" ' : '').'/>'.$this->l('Yes').'
|
||||
<input type="radio" name="conf_email" value="0" '.(!Configuration::get('NW_CONFIRMATION_EMAIL') ? 'checked="checked" ' : '').'/>'.$this->l('No').'
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<label>'.$this->l('Welcome voucher code').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="voucher" value="'.Configuration::get('NW_VOUCHER_CODE').'" />
|
||||
<p>'.$this->l('Leave blank to disable by default.').'</p>
|
||||
</div>
|
||||
<div class="margin-form clear pspace"><input type="submit" name="submitUpdate" value="'.$this->l('Update').'" class="button" /></div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
return $this->_html;
|
||||
return $this->_html.$this->renderForm();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,4 +503,89 @@ class Blocknewsletter extends Module
|
||||
return (bool)Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE id_shop='.(int)$id_shop.' AND email=\''.pSQL($email)."'");
|
||||
return true;
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Settings'),
|
||||
'icon' => 'icon-cogs'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Would you like to send a verification email after subscription?'),
|
||||
'name' => 'NW_VERIFICATION_EMAIL',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Would you like to send a confirmation email after subscription?'),
|
||||
'name' => 'NW_CONFIRMATION_EMAIL',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Welcome voucher code'),
|
||||
'name' => 'NW_VOUCHER_CODE',
|
||||
'class' => '.fixed-width-md',
|
||||
'desc' => $this->l('Leave blank to disable by default.')
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'btn btn-primary')
|
||||
),
|
||||
);
|
||||
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
$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 = 'submitUpdate';
|
||||
$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->generateForm(array($fields_form));
|
||||
}
|
||||
|
||||
public function getConfigFieldsValues()
|
||||
{
|
||||
return array(
|
||||
'NW_VERIFICATION_EMAIL' => Tools::getValue('NW_VERIFICATION_EMAIL', Configuration::get('NW_VERIFICATION_EMAIL')),
|
||||
'NW_CONFIRMATION_EMAIL' => Tools::getValue('NW_CONFIRMATION_EMAIL', Configuration::get('NW_CONFIRMATION_EMAIL')),
|
||||
'NW_VOUCHER_CODE' => Tools::getValue('NW_VOUCHER_CODE', Configuration::get('NW_VOUCHER_CODE')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user