Merge branch 'ticket-12948-PrivatesaleNewsletter' into develop

This commit is contained in:
Marion Muszynski 2017-04-25 15:56:53 +02:00
commit 7abf49d816
2 changed files with 33 additions and 25 deletions

View File

@ -20,7 +20,7 @@ class AdminPrivateSalesNewsletter extends AdminTab {
<div class="margin-form">
<div id="title" style="float: left;">
<div style="margin-bottom:10px;">
FR : <input type="text" style="width: 500px;" name="title" value="'. Configuration::get('TITLE_NEWS_DIMANCHE') .'" />
FR : <input type="text" style="width: 500px;" name="title" value="'. Configuration::get('TITLE_NEWS_DIMANCHE') .'" />
</div>
<div style="margin:10px 0;">
ES : <input type="text" style="width: 500px;" name="title_es" value="'. Configuration::get('TITLE_NEWS_DIMANCHE_ES') .'" />
@ -31,7 +31,7 @@ class AdminPrivateSalesNewsletter extends AdminTab {
echo '
<div class="margin-form">
<input type="submit" class="button" name="submitTitleDimanche" value="'.$this->l('Update this title').'" />
<input type="submit" class="button" name="submitTitleDimanche" value="'.$this->l('Update this title').'" />
</div>';
echo '</fieldset>
@ -78,11 +78,11 @@ class AdminPrivateSalesNewsletter extends AdminTab {
<select id="version" name="version">
<option '.($this->curnewsletter !== NULL ? ($this->curnewsletter['version'] == 'fr' ? 'selected' : '' ) : 'selected').' value="fr">FR</option>
<option '.($this->curnewsletter !== NULL ? ($this->curnewsletter['version'] == 'es' ? 'selected' : '' ) : '').' value="es">ES</option>
</select>
</select>
</div>
<div class="clear"></div>
</div>';
echo '<br class="clear" />
<div class="margin-form">
<input type="hidden" name="id_newsletter" value="'.($this->curnewsletter !== NULL? $this->curnewsletter['id_newsletter']: '').'" />
@ -112,7 +112,7 @@ class AdminPrivateSalesNewsletter extends AdminTab {
<legend><img src="'.__PS_BASE_URI__.'modules/privatesales_newsletter/prefs.gif" alt="" title="" /> '.$this->l('Vente en avant').'</legend>
<form action="'.$currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesNewsletter').'" method="post">
<table class="table" style="width: 100%;">';
$sales = Sale::getSales(NULL, NULL, NULL, 'not_ended', FALSE, FALSE, '`position` DESC');
$ids = array();
foreach ($sales as $key => $sale) {
@ -157,7 +157,7 @@ class AdminPrivateSalesNewsletter extends AdminTab {
ORDER BY `id_newsletter` DESC
LIMIT 30
') as $news) {
echo '<tr>
<td>'.$news['id_newsletter'].'</td>
<td>'.$news['title'].'</td>
@ -179,18 +179,26 @@ class AdminPrivateSalesNewsletter extends AdminTab {
global $cookie, $currentIndex;
if(Tools::isSubmit('submitNewsletterAdd')) {
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'privatesale_newsletter` VALUES (
DEFAULT,
"'.pSQL(Tools::getValue('title')).'",
"'.pSQL(Tools::getValue('image_url')).'",
"'.pSQL(Tools::getValue('date_pub')).'",
"'.pSQL(Tools::getValue('version')).'",
"'.pSQL(Tools::getValue('preheader')).'"
)
');
$id_newsletter = Db::getInstance()->Insert_ID();
$date = Tools::getValue('date_pub');
$now = date('Y-m-d');
$now_seven_more = date('Y-m-d',strtotime($now.' + 7 days'));
if($date<$now || $date>$now_seven_more) {
$this->_errors[] = Tools::displayError('Vous ne pouvez pas créer une newsletter dans le passé ou dans plus de 7 jours');
} else {
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'privatesale_newsletter` VALUES (
DEFAULT,
"'.pSQL(Tools::getValue('title')).'",
"'.pSQL(Tools::getValue('image_url')).'",
"'.pSQL(Tools::getValue('date_pub')).'",
"'.pSQL(Tools::getValue('version')).'",
"'.pSQL(Tools::getValue('preheader')).'"
)
');
$id_newsletter = Db::getInstance()->Insert_ID();
}
// if(isset($_FILES['image']) && $_FILES['image']['name'] != '') {
// if(!copy($_FILES['image']['tmp_name'], _PS_ROOT_DIR_.'/modules/privatesales/img/newsletter/'.$id_newsletter.'.jpg')) {
// echo $this->displayError($this->l('An error occured during the image upload.'));
@ -212,7 +220,7 @@ class AdminPrivateSalesNewsletter extends AdminTab {
WHERE `id_newsletter` = '.$id_newsletter.'
');
}
// if(isset($_FILES['image']) && $_FILES['image']['name'] != '') {
// if(!copy($_FILES['image']['tmp_name'], _PS_ROOT_DIR_.'/modules/privatesales/img/newsletter/'.$id_newsletter.'.jpg')) {
// echo $this->displayError($this->l('An error occured during the image upload.'));
@ -227,9 +235,9 @@ class AdminPrivateSalesNewsletter extends AdminTab {
} else if(Tools::isSubmit('submitTitleDimanche')) {
Configuration::updateValue('TITLE_NEWS_DIMANCHE', Tools::getValue('title'));
Configuration::updateValue('TITLE_NEWS_DIMANCHE_ES', Tools::getValue('title_es'));
Configuration::updateValue('TITLE_NEWS_LAST_DAY', Tools::getValue('title_last_day'));
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesNewsletter'));
} else if(Tools::isSubmit('submitForwardSale')) {
$forward = Tools::getValue('sale_forward', 0);

View File

@ -957,8 +957,8 @@ $(document).ready(function () {
var phone_mobile = /^((\+|00)33\s?|0)[67](\s?\d{2}){4}$/i;
var phone_mobile_without_zero = /^[67](\s?\d{2}){4}$/i;
var phone_mobile_be = /^((\+|00)32\s?|0)4(60|[789]\d)(\s?\d{2}){3}$/i;
var phone_mobile_without_zero_be = /^4(60|[789]\d)(\s?\d{2}){3}$/i;
var phone_mobile_be = /^((\+|00)32\s?|0)4(60|[6789]\d)(\s?\d{2}){3}$/i;
var phone_mobile_without_zero_be = /^4(60|[6789]\d)(\s?\d{2}){3}$/i;
var phone_mobile_es = /^((\+|00)34\s?\d{1}|6)(\s?\d{2}){4}$/i;
@ -994,11 +994,11 @@ $(document).ready(function () {
if($('#sl-0-country').val() == 'BE'){
if($('#custPhone').val().length == 9 && !(phone_mobile_without_zero_be.test($('#custPhone').val()))){
ev.preventDefault();
alert($('#error-mobile-invalid').val() + '\n\nFormat : 0461010203 ou 0032461010203');
alert($('#error-mobile-invalid').val() + '\n\nFormat : 0460110203 ou 0032460110203');
return (false);
}else if($('#custPhone').val().length > 9 && !(phone_mobile_be.test($('#custPhone').val()))) {
ev.preventDefault();
alert($('#error-mobile-invalid').val() + '\n\nFormat : 0461010203 ou 0032461010203');
alert($('#error-mobile-invalid').val() + '\n\nFormat : 0460110203 ou 0032460110203');
return (false);
}
}