diff --git a/cron_export_sales_monthly_test.php b/cron_export_sales_monthly_test.php index 43b93b0..dba123c 100644 --- a/cron_export_sales_monthly_test.php +++ b/cron_export_sales_monthly_test.php @@ -62,6 +62,8 @@ function getCat($id=0, $title='') { // Start echo date('Y-m-d H:i:s')." - START ".$dateSelect->format('Y-m-d')." \n"; $now = $dateSelect->format('Y-m-d').' 00:00:00'; +$dateStartSql = $dateSelect->format('Y-m').'-01 00:00:00'; +$dateEndSql = $dateSelect->format('Y-m').'-31 23:59:59'; $filename = date('Y-m-d', strtotime($now)).'_new.csv'; if ($optDebug === true) { @@ -134,8 +136,8 @@ foreach(Db::getInstance()->ExecuteS(' o.valid = 0 AND ( os.id_order_state = 6 OR os.id_order_state = 7 OR os.id_order_state = 11) )) - AND o.date_add >= DATE_FORMAT("'.$now.'" - INTERVAL 1 MONTH, \'%Y-%m-01 00:00:00\') - AND o.date_add <= DATE_FORMAT(LAST_DAY("'.$now.'" - INTERVAL 1 MONTH), \'%Y-%m-%d 23:59:59\') + AND o.date_add >= "'.$dateStartSql.'" + AND o.date_add <= "'.$dateEndSql.'" GROUP BY o.id_order ') as $row){ $orders[(int)$row['id_order']] = array(); @@ -488,8 +490,8 @@ $orderStateNoCredit = array( $slips = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'order_slip` os - WHERE os.date_add >= DATE_FORMAT("'.$now.'" - INTERVAL 1 MONTH, \'%Y-%m-01 00:00:00\') - AND os.date_add <= DATE_FORMAT(LAST_DAY("'.$now.'" - INTERVAL 1 MONTH), \'%Y-%m-%d 23:59:59\') + WHERE os.date_add >= "'.$dateStartSql.'" + AND os.date_add <= "'.$dateEndSql.'" '); $slipNb = count($slips); @@ -833,5 +835,3 @@ if($slipNb > 0) { } fclose($f); - -exit;