From 88a7ca8e96eb4cbadaa89b2f5c02588d584b824d Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Thu, 15 Sep 2016 11:14:09 +0200 Subject: [PATCH] fix export by date --- .../AdminPrivateSalesLogistique.php | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/privatesales_logistique/AdminPrivateSalesLogistique.php b/modules/privatesales_logistique/AdminPrivateSalesLogistique.php index f0c231f1..7860dfda 100755 --- a/modules/privatesales_logistique/AdminPrivateSalesLogistique.php +++ b/modules/privatesales_logistique/AdminPrivateSalesLogistique.php @@ -55,11 +55,18 @@ class AdminPrivateSalesLogistique extends AdminTab { $id_lang = Tools::getValue('export_id_lang', $cookie->id_lang); if ($id_category = (int) Tools::getValue('export_category')) { - $this->getSaleExport($id_category,$id_lang); + + $this->getSaleExport($id_category, $id_lang); + } elseif (Tools::getValue('date_start') && Tools::getValue('date_end')) { + $date_start = Tools::getValue('date_start'); $date_end = Tools::getValue('date_end'); - $this->getSaleExportsByDate($date_start,$date_end,$id_lang); + + $this->getSaleExportsByDate($date_start, $date_end, $id_lang); + + } else { + $this->html .= '

Vous devez choisir une vente ou une période

'; } } } @@ -168,11 +175,11 @@ class AdminPrivateSalesLogistique extends AdminTab { '; } - public function _displayBeforeContent() + public function _displayAfterContent() { global $cookie; $this->html .= ' -


+


'.$this->l('Export').' @@ -277,8 +284,8 @@ class AdminPrivateSalesLogistique extends AdminTab { global $currentIndex; $this->_postProcess(); $this->_displayHeader(); - $this->_displayBeforeContent(); $this->_displayContent(); + $this->_displayAfterContent(); echo $this->html; } @@ -631,7 +638,7 @@ class AdminPrivateSalesLogistique extends AdminTab { SELECT c.id_category FROM `'._DB_PREFIX_.'privatesale` p LEFT JOIN `'._DB_PREFIX_.'privatesale_category` c ON c.id_sale = p.id_sale - WHERE date_start BETWEEN "'. $date_start .' 00:00:00" AND "'. $date_end .' 00:00:00" + WHERE date_start BETWEEN "'. $date_start .' 00:00:00" AND "'. $date_end .' 23:59:59" ORDER BY c.id_sale DESC '); @@ -646,11 +653,10 @@ class AdminPrivateSalesLogistique extends AdminTab { $products = array_unique($products); if(count($products) > 20000){ - $this->html .= '

Choisir une plage moins grande.
Export > 20000 produits

'; - continue; + $this->html .= '

Choisir une plage moins grande.
Export > 20000 produits

'; + exit; }; - $privatesale = Sale::getSaleFromCategory((int) $id_category); $fname = date( "Ymd", strtotime($date_start)).'-'.date( "Ymd", strtotime($date_end)).'.csv'; foreach(glob(dirname(__FILE__).'/*.csv') as $filename) { if ($fname == $filename) { @@ -799,7 +805,7 @@ class AdminPrivateSalesLogistique extends AdminTab { ON o.`id_order` = d.`id_order` LEFT JOIN `'._DB_PREFIX_.'order_history` h ON h.`id_order` = d.`id_order` - WHERE d.`product_id` = '.(int) $p->id.' + WHERE d.`product_id` = '.(int) $p->id.' AND d.`product_attribute_id` = '.(int) $k.' AND h.`id_order_state` = 2 '); @@ -900,6 +906,7 @@ class AdminPrivateSalesLogistique extends AdminTab { fclose($f); $this->html .= '

'.$this->l('Export complete.').' '.$this->l('Click here to download the file').'

'; } + public function getSaleExport($id_category=0,$id_lang=0) { global $link, $cookie;