diff --git a/adm/ajax_vp.php b/adm/ajax_vp.php
index 351b245e..5c55c2ee 100644
--- a/adm/ajax_vp.php
+++ b/adm/ajax_vp.php
@@ -9,14 +9,20 @@ require_once('../modules/privatesales/Sale.php');
require_once('../modules/privatesales_delay/saledelay.php');
require_once('../modules/privatesales_extrafields/privatesales_extrafields.php');
+if (isset($_GET['flush_sale'])){
+ $replies = CacheRedis::getInstance()->clear('sale*');
+ echo '
';
- $sales = Sale::getSales(NULL, NULL, NULL, 'not_ended', FALSE, FALSE, '`position` DESC');
+ $sales = Sale::getSalesBack(NULL, NULL, NULL, 'not_ended', FALSE, FALSE, '`position` DESC');
$ids = array();
foreach ($sales as $key => $sale) {
$ids[] = $sale->id;
@@ -1109,7 +1127,8 @@ class AdminPrivateSalesSales extends AdminTab {
echo ' ';
}
}
- $category_link = Link::getCategoryLink($sale->id_category);
+ $link = new Link();
+ $category_link = $link->getCategoryLink($sale->id_category);
$category_link_bo = '?tab=AdminCatalog&viewcategory&id_category='.$sale->id_category.'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
echo '
diff --git a/modules/privatesales/Sale.php b/modules/privatesales/Sale.php
index f98f046a..a3661ad9 100755
--- a/modules/privatesales/Sale.php
+++ b/modules/privatesales/Sale.php
@@ -1646,7 +1646,93 @@ class Sale {
$query .= ' LIMIT '.$limit;
}
- if ($future == 'current' && false === ($sales = CacheRedis::getInstance()->getQuery($query, self::CONTROLLER_NAME))) {
+ if (false === ($sales = CacheRedis::getInstance()->getQuery($query, self::CONTROLLER_NAME))) {
+ $sales = Db::getInstance()->ExecuteS($query);
+ CacheRedis::getInstance()->setQuery($query, self::CONTROLLER_NAME, $sales);
+ }
+
+ if($sales) {
+ if($lite) {
+ foreach($sales AS $sale) {
+ $result[] = $sale['id_sale'];
+ }
+ } else {
+ foreach($sales AS $sale) {
+ $result[] = new Sale($sale['id_sale']);
+ }
+ }
+ }
+ return $result;
+ }
+
+ public static function getSalesBack($enabled=NULL, $logout=NULL, $featured=NULL, $future=NULL, $lite=FALSE, $pub=FALSE, $order_by='`date_end` ASC', $limit=NULL, $sale_type=NULL, $site_version=FALSE, $without_consumable=FALSE) {
+ global $cookie;
+ $result = array();
+ $where = array();
+
+ $query = '
+ SELECT p.`id_sale`
+ FROM `'._DB_PREFIX_.'privatesale` p
+ ';
+
+ // if($sale_type !== NULL){
+ // $query.= ' LEFT JOIN `'._DB_PREFIX_.'privatesale_type` pt ON(pt.id_sale = p.id_sale AND pt.id_sale_type = '. $sale_type.')';
+ // }
+
+ if($site_version !== FALSE) {
+ $query .= '
+ LEFT JOIN `'._DB_PREFIX_.'privatesale_site_version` sv
+ ON p.`id_sale` = sv.`id_sale`
+ ';
+ $where[] = 'sv.`version` = "'.pSQL($site_version).'"';
+ }
+
+ if($enabled !== NULL OR $logout !== NULL OR $featured !== NULL OR $future !== NULL) {
+ $enabled !== null? $where[] = '`enabled` = '.(int) $enabled: TRUE;
+ $logout !== null? $where[] = '`logout` = '.(int) $logout: TRUE;
+ $pub != FALSE? '': $where[] = '`public` = 0';
+ $featured !== null? $where[] = '`featured` = '.(int) $featured: TRUE;
+ // $sale_type !== NULL? $where[] = '`sale_type` = '.(int) $sale_type: TRUE;
+
+ if($future === 'current') {
+ $where[] = '`date_start` < NOW() AND `date_end` > NOW()';
+ } elseif($future === 'not_ended') {
+ $where[] = '`date_end` > NOW()';}
+ elseif($future === 'all') {
+ $where[] = ' 1 = 1';
+ } elseif ($future === 'today') {
+ $where[] = 'CAST(`date_start` AS DATE) = CAST(NOW() AS DATE)';
+ } elseif ($future === 'tomorrow') {
+ $where[] = 'CAST(`date_start` AS DATE) = CAST(DATE_ADD(NOW(), INTERVAL 1 DAY) AS DATE)';
+ } elseif ($future === 'last') {
+ $where[] = 'CAST(`date_end` AS DATE) = CAST(NOW() AS DATE)';
+ } elseif ($future === 'ended_tomorrow') {
+ $where[] = 'CAST(`date_end` AS DATE) = CAST(DATE_ADD(NOW(), INTERVAL 1 DAY) AS DATE)';
+ } elseif(is_int($future)) {
+ $where[] = '(`date_start` > NOW() AND `date_start` < DATE_ADD(NOW(), INTERVAL '.$future.' DAY))';
+ } elseif($future === TRUE) {
+ $where[] = '`date_start` > NOW()';
+ } elseif($future === FALSE) {
+ $where[] = '`date_start` < NOW() AND `date_end` < NOW()';
+ }
+ $query .= 'WHERE '.implode(' AND ', $where);
+ }
+
+ // if($sale_type !== NULL){
+ // $query.= ' AND pt.id_sale_type = '. $sale_type;
+ // }
+
+ if ($without_consumable && _SHOP_CATEGORYENABLED!== FALSE) {
+ $query .= ' AND p.`id_sale` != '.(int) _SHOP_PRIVATESALES_CONSUMABLE;
+ }
+
+ $query .= ' ORDER BY '.$order_by;
+
+ if($limit !== NULL) {
+ $query .= ' LIMIT '.$limit;
+ }
+
+ if ($future == FALSE && false === ($sales = CacheRedis::getInstance()->getQuery($query, self::CONTROLLER_NAME))) {
$sales = Db::getInstance()->ExecuteS($query);
CacheRedis::getInstance()->setQuery($query, self::CONTROLLER_NAME, $sales);
} else {
diff --git a/modules/privatesales_extrafields/privatesales_extrafields.php b/modules/privatesales_extrafields/privatesales_extrafields.php
index f0ee3a17..e2bf1ce1 100755
--- a/modules/privatesales_extrafields/privatesales_extrafields.php
+++ b/modules/privatesales_extrafields/privatesales_extrafields.php
@@ -230,9 +230,9 @@ class PrivateSales_ExtraFields extends Module {
foreach($this->_languages as $language) {
echo '';
|