diff --git a/modules/stats_logistic/ajax.php b/modules/stats_logistic/ajax.php index 594c4405..078da683 100644 --- a/modules/stats_logistic/ajax.php +++ b/modules/stats_logistic/ajax.php @@ -23,14 +23,21 @@ switch ($action) { $start = Tools::getValue('date_export_begin'); $end = Tools::getValue('date_export_end'); + $path = dirname(__FILE__) . '/export'; + $filename = 'export-remb-'.$start.'-'.$end.'.csv'; + $file = $path . '/' . $filename; + if (file_exists($file)) { + unlink($file); + } + if (empty($start) || empty($end)) { $url = ''; } else { $url = Tools::getShopDomain(true) . '/modules/stats_logistic/ajax.php?action=check&token='.Tools::getValue('token'); } - $cmd = dirname(__FILE__).'/bin/export.php --start '.$start.' --end '.$end.''; - exec('php '.$cmd.' &'); + $cmd = dirname(__FILE__).'/bin/export.php --start '.$start.' --end '.$end; + exec("php ".$cmd." > /dev/null &"); // Always return checkin url echo json_encode(array( diff --git a/modules/stats_logistic/bin/export.php b/modules/stats_logistic/bin/export.php index 0b009b9f..80a384d6 100644 --- a/modules/stats_logistic/bin/export.php +++ b/modules/stats_logistic/bin/export.php @@ -9,7 +9,6 @@ $_SERVER['SERVER_PORT'] = 443; require_once __DIR__ . '/../../../config/config.inc.php'; require_once __DIR__ . '/../stats_logistic.php'; - if (!Tools::isCli()){ exit(); } diff --git a/modules/stats_logistic/models/StatsLogistic.php b/modules/stats_logistic/models/StatsLogistic.php index a9be642e..d18b7a95 100644 --- a/modules/stats_logistic/models/StatsLogistic.php +++ b/modules/stats_logistic/models/StatsLogistic.php @@ -15,7 +15,7 @@ class StatsLogistic { $this->date_export_begin = $start; $this->date_export_end = $end; - + $fname = 'export-remb-'.$this->date_export_begin.'-'.$this->date_export_end.'.csv'; $result = null; $sale_ids = $this->getSales(); @@ -180,7 +180,7 @@ class StatsLogistic } } } - $fname = 'export-remb-'.$this->date_export_begin.'-'.$this->date_export_end.'.csv'; + if ($result !== null) { $this->exportCSV($result, $fname); } else { diff --git a/modules/stats_logistic/views/js/export.js b/modules/stats_logistic/views/js/export.js index c212eb62..cdaf9b24 100644 --- a/modules/stats_logistic/views/js/export.js +++ b/modules/stats_logistic/views/js/export.js @@ -27,11 +27,8 @@ $(function(){ } $('form').submit(function(e) { - e.preventDefault(); $(this).find('input#submitExport').attr('disabled', 'disabled'); url = $(this).attr('action'); - console.log(url); - console.log($(this).serialize()); $.post(url, $(this).serialize(), function (data, textStatus) { if (data.url != '') { url = data.url;