move the cron task to another dedicated file
This commit is contained in:
parent
4ca5bc73a9
commit
6ec43fe75d
@ -1838,20 +1838,10 @@ class Sale {
|
|||||||
* of its products.
|
* of its products.
|
||||||
*
|
*
|
||||||
* @param string $date_day the sales starting day (to express in "Y-m-d")
|
* @param string $date_day the sales starting day (to express in "Y-m-d")
|
||||||
* @param string $from_hour hour before the sales starting hour.
|
|
||||||
* (to express in "H:i")
|
|
||||||
*/
|
*/
|
||||||
public static function updateSalesReductionAtDate($date_day='', $from_hour='00:00')
|
public static function updateSalesReductionAtDate()
|
||||||
{
|
{
|
||||||
$id_field = 2; // id=2 for the extra field sale "pourcentage"
|
$id_field = 2; // id=2 for the extra field sale "pourcentage"
|
||||||
$from_hour = mysql_escape_string($from_hour);
|
|
||||||
if (empty($date_day)) {
|
|
||||||
$date_day = date('Y-m-d');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$date_day = mysql_escape_string($date_day);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// for all sales at "date_day" and hour > "from_hour"
|
// for all sales at "date_day" and hour > "from_hour"
|
||||||
// return the maximal reduction applied from all products of each sale
|
// return the maximal reduction applied from all products of each sale
|
||||||
@ -1868,8 +1858,7 @@ class Sale {
|
|||||||
ON sf.id_sale = s.id_sale
|
ON sf.id_sale = s.id_sale
|
||||||
WHERE
|
WHERE
|
||||||
sp.reduction_type='percentage'
|
sp.reduction_type='percentage'
|
||||||
AND DATE(s.date_start) = '".$date_day."'
|
AND CAST(s.date_start AS DATE) = CAST(NOW() AS DATE)
|
||||||
AND TIME(s.date_start) > '".$from_hour.":00'
|
|
||||||
AND sf.id_field = ".$id_field."
|
AND sf.id_field = ".$id_field."
|
||||||
AND sf.`value` IS NOT NULL
|
AND sf.`value` IS NOT NULL
|
||||||
AND sf.`value` <> ''
|
AND sf.`value` <> ''
|
||||||
@ -1878,6 +1867,7 @@ class Sale {
|
|||||||
|
|
||||||
$results = Db::getInstance()->ExecuteS($sql);
|
$results = Db::getInstance()->ExecuteS($sql);
|
||||||
|
|
||||||
|
|
||||||
// update the sentence with the max reduction, if any, for
|
// update the sentence with the max reduction, if any, for
|
||||||
// each sale
|
// each sale
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
|
@ -7,8 +7,6 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
|
|||||||
include(dirname(__FILE__).'/Sale.php');
|
include(dirname(__FILE__).'/Sale.php');
|
||||||
$sales = Sale::getSales(TRUE, NULL, NULL, FALSE);
|
$sales = Sale::getSales(TRUE, NULL, NULL, FALSE);
|
||||||
|
|
||||||
Sale::updateSalesReductionAtDate('', '00:00');
|
|
||||||
|
|
||||||
$file = fopen('lastupdate.txt', 'w');
|
$file = fopen('lastupdate.txt', 'w');
|
||||||
fwrite($file, date('Ymd His'));
|
fwrite($file, date('Ymd His'));
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
12
modules/privatesales/cron_salesreduction.php
Normal file
12
modules/privatesales/cron_salesreduction.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?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');
|
||||||
|
|
||||||
|
Sale::updateSalesReductionAtDate();
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user