|
|
@@ -580,25 +580,43 @@ class DistributionController extends BackendController |
|
|
|
|
|
|
|
// total point de vente |
|
|
|
$totalsPointSaleArray = $this->_totalReportCSV( |
|
|
|
'Total', |
|
|
|
' Total (unité)', |
|
|
|
$pointSale->orders, |
|
|
|
$productsArray, |
|
|
|
$productsIndexArray |
|
|
|
); |
|
|
|
$datas[] = $this->_lineOrderReportCSV($totalsPointSaleArray, $cpt); |
|
|
|
|
|
|
|
$totalsGlobalPiecesArray = $this->_totalReportPiecesCSV( |
|
|
|
' Total (pièces)', |
|
|
|
$ordersArray, |
|
|
|
$productsArray, |
|
|
|
$productsIndexArray |
|
|
|
); |
|
|
|
$datas[] = $this->_lineOrderReportCSV($totalsGlobalPiecesArray, $cpt); |
|
|
|
|
|
|
|
$datas[] = []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// global |
|
|
|
$totalsGlobalArray = $this->_totalReportCSV( |
|
|
|
'> Totaux', |
|
|
|
'> Totaux (unité)', |
|
|
|
$ordersArray, |
|
|
|
$productsArray, |
|
|
|
$productsIndexArray |
|
|
|
); |
|
|
|
$datas[] = $this->_lineOrderReportCSV($totalsGlobalArray, $cpt); |
|
|
|
|
|
|
|
// global (pièces) |
|
|
|
$totalsGlobalPiecesArray = $this->_totalReportPiecesCSV( |
|
|
|
'> Totaux (pièces)', |
|
|
|
$ordersArray, |
|
|
|
$productsArray, |
|
|
|
$productsIndexArray |
|
|
|
); |
|
|
|
$datas[] = $this->_lineOrderReportCSV($totalsGlobalPiecesArray, $cpt); |
|
|
|
|
|
|
|
CSV::downloadSendHeaders('Commandes_' . $date . '.csv'); |
|
|
|
echo CSV::array2csv($datas); |
|
|
|
die(); |
|
|
@@ -765,6 +783,34 @@ class DistributionController extends BackendController |
|
|
|
return $totalsPointSaleArray; |
|
|
|
} |
|
|
|
|
|
|
|
public function _totalReportPiecesCSV($label, $ordersArray, $productsArray, $productsIndexArray) |
|
|
|
{ |
|
|
|
$totalsPointSaleArray = [$label]; |
|
|
|
|
|
|
|
foreach ($productsArray as $product) { |
|
|
|
$quantity = 0 ; |
|
|
|
foreach (Product::$unitsArray as $unit => $dataUnit) { |
|
|
|
$quantityProduct = Order::getProductQuantity($product->id, $ordersArray, false, $unit); |
|
|
|
|
|
|
|
if($unit == 'piece') { |
|
|
|
$quantity += $quantityProduct ; |
|
|
|
} |
|
|
|
else { |
|
|
|
if($product->weight > 0) { |
|
|
|
$quantity += ($quantityProduct * $dataUnit['coefficient']) / $product->weight ; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if($quantity) { |
|
|
|
$index = $productsIndexArray[$product->id]; |
|
|
|
$totalsPointSaleArray[$index] = $quantity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $totalsPointSaleArray; |
|
|
|
} |
|
|
|
|
|
|
|
public function _lineOrderReportCSV($orderLine, $cptMax, $showTotal = false) |
|
|
|
{ |
|
|
|
$line = []; |