fix position of sale with lock position
This commit is contained in:
parent
8a1b3793da
commit
bd9ff4fe9e
@ -272,12 +272,6 @@ if (isset($_GET['updatePositionDrag'])){
|
||||
foreach ($_positions as $id => $value) {
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = '. (int)$value['new'].' WHERE id_sale = '. $id);
|
||||
}
|
||||
// die(json_encode(array(
|
||||
// "position" => $position,
|
||||
// "position_initial" => $position_initial,
|
||||
// "new_position" => $new_position,
|
||||
// "sale_positions" => $_positions,
|
||||
// )));
|
||||
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = '. (int)$new_position.' WHERE id_sale = '. $id_sale);
|
||||
|
||||
|
@ -955,6 +955,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
<button type="submit" name="not_ended" class="tri btn btn-default active">Ventes actuelles</button>
|
||||
<button type="submit" name="finished" class="tri btn btn-default">Ventes terminées</button>
|
||||
<button type="submit" name="all" class="tri btn btn-default">Toutes les ventes</button>
|
||||
<!--a style="cursor: pointer;" onclick="resortPosition();" class="btn btn-default">Resort</a-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@ -1286,5 +1287,17 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
Sale::unlockPosition($id_sale);
|
||||
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales'));
|
||||
}
|
||||
// elseif(isset($_GET['resort_position'])){
|
||||
// $nb_sales = Db::getInstance()->getValue('
|
||||
// SELECT COUNT(p.`id_sale`)
|
||||
// FROM `ps_privatesale` p
|
||||
// WHERE CAST(p.`date_start` AS DATE) = CAST(NOW() AS DATE)
|
||||
// AND `date_end` > NOW()
|
||||
// ');
|
||||
|
||||
// if($nb_sales>0) {
|
||||
// Sale::sortActiveSaleAfterAdd($nb_sales);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +268,12 @@ class Sale {
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
self::sortActiveSaleAfterAdd();
|
||||
// $today = strtotime(date("Y-m-d H:i:s"));
|
||||
// $start = strtotime($sale->date_start);
|
||||
// $end = strtotime($sale->date_end);
|
||||
// if($start <= $today && $end > $today){
|
||||
// self::sortActiveSaleAfterAdd(1);
|
||||
// }
|
||||
|
||||
Module::hookExec('privatesales_create', array('sale' => $this));
|
||||
}
|
||||
@ -299,18 +303,21 @@ class Sale {
|
||||
}
|
||||
}
|
||||
|
||||
public static function sortActiveSaleAfterAdd(){
|
||||
foreach(Db::getInstance()->executeS('
|
||||
SELECT id_sale, position
|
||||
FROM '._DB_PREFIX_.'privatesale
|
||||
WHERE lock_position = 1
|
||||
AND `date_end` > NOW()
|
||||
ORDER BY position DESC
|
||||
') as $sale){
|
||||
$pos = $sale['position']+1;
|
||||
public static function sortActiveSaleAfterAdd($nb = 1){
|
||||
for ($i=0; $i < $nb; $i++) {
|
||||
foreach(Db::getInstance()->executeS('
|
||||
SELECT id_sale, position
|
||||
FROM '._DB_PREFIX_.'privatesale
|
||||
WHERE lock_position = 1
|
||||
AND `date_end` > NOW()
|
||||
AND `date_start` < NOW()
|
||||
ORDER BY position DESC
|
||||
') as $sale){
|
||||
$pos = $sale['position']+1;
|
||||
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = position-1 WHERE position = '. $pos);
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = position+1 WHERE id_sale = '. $sale['id_sale']);
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = position-1 WHERE position = '. $pos);
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = position+1 WHERE id_sale = '. $sale['id_sale']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -851,6 +858,7 @@ class Sale {
|
||||
|
||||
if($carrier === "lp") {
|
||||
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_SOCOL')));
|
||||
$carriers[] = 22; // dropshipping
|
||||
} else {
|
||||
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR')));
|
||||
}
|
||||
@ -999,6 +1007,7 @@ class Sale {
|
||||
|
||||
if($carrier === "lp") {
|
||||
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_SOCOL')));
|
||||
$carriers[] = 22; // dropshipping
|
||||
} else {
|
||||
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR')));
|
||||
}
|
||||
|
19
modules/privatesales/cron_position.php
Normal file
19
modules/privatesales/cron_position.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) exit;
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
|
||||
include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
include(dirname(__FILE__).'/Sale.php');
|
||||
|
||||
|
||||
$nb_sales = Db::getInstance()->getValue('
|
||||
SELECT COUNT(p.`id_sale`)
|
||||
FROM `ps_privatesale` p
|
||||
WHERE CAST(p.`date_start` AS DATE) = CAST(NOW() AS DATE)
|
||||
AND `date_end` > NOW()
|
||||
');
|
||||
|
||||
if($nb_sales>0) {
|
||||
Sale::sortActiveSaleAfterAdd($nb_sales);
|
||||
}
|
@ -14,3 +14,6 @@ function itemLockPosition(linkId) {
|
||||
function itemUnLockPosition(linkId) {
|
||||
document.location.href = current_location + "&id=" + linkId + "&unlock_position=1";
|
||||
}
|
||||
function resortPosition() {
|
||||
document.location.href = current_location + "&resort_position=1";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user