diff --git a/modules/privatesales/Sale.php b/modules/privatesales/Sale.php index cf22c140..c1b50b4e 100755 --- a/modules/privatesales/Sale.php +++ b/modules/privatesales/Sale.php @@ -1838,20 +1838,10 @@ class Sale { * of its products. * * @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" - $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" // return the maximal reduction applied from all products of each sale @@ -1868,8 +1858,7 @@ class Sale { ON sf.id_sale = s.id_sale WHERE sp.reduction_type='percentage' - AND DATE(s.date_start) = '".$date_day."' - AND TIME(s.date_start) > '".$from_hour.":00' + AND CAST(s.date_start AS DATE) = CAST(NOW() AS DATE) AND sf.id_field = ".$id_field." AND sf.`value` IS NOT NULL AND sf.`value` <> '' @@ -1878,6 +1867,7 @@ class Sale { $results = Db::getInstance()->ExecuteS($sql); + // update the sentence with the max reduction, if any, for // each sale foreach ($results as $result) { diff --git a/modules/privatesales/cron.php b/modules/privatesales/cron.php index c9ccce4c..3ef1a2ec 100755 --- a/modules/privatesales/cron.php +++ b/modules/privatesales/cron.php @@ -7,8 +7,6 @@ include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/Sale.php'); $sales = Sale::getSales(TRUE, NULL, NULL, FALSE); -Sale::updateSalesReductionAtDate('', '00:00'); - $file = fopen('lastupdate.txt', 'w'); fwrite($file, date('Ymd His')); fclose($file); diff --git a/modules/privatesales/cron_salesreduction.php b/modules/privatesales/cron_salesreduction.php new file mode 100644 index 00000000..3d1487c0 --- /dev/null +++ b/modules/privatesales/cron_salesreduction.php @@ -0,0 +1,12 @@ +