diff --git a/modules/privatesales_newsletter/AdminPrivateSalesNewsletter.php b/modules/privatesales_newsletter/AdminPrivateSalesNewsletter.php index 0896d0b7..674644b5 100755 --- a/modules/privatesales_newsletter/AdminPrivateSalesNewsletter.php +++ b/modules/privatesales_newsletter/AdminPrivateSalesNewsletter.php @@ -20,7 +20,7 @@ class AdminPrivateSalesNewsletter extends AdminTab {
- FR : + FR :
ES : @@ -31,7 +31,7 @@ class AdminPrivateSalesNewsletter extends AdminTab { echo '
- +
'; echo ' @@ -78,11 +78,11 @@ class AdminPrivateSalesNewsletter extends AdminTab { +
'; - + echo '
@@ -112,7 +112,7 @@ class AdminPrivateSalesNewsletter extends AdminTab { '.$this->l('Vente en avant').'
'; - + $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 ' @@ -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);
'.$news['id_newsletter'].' '.$news['title'].'