|
|
|
|
|
|
|
|
|
|
|
|
|
|
// total point de vente |
|
|
// total point de vente |
|
|
$totalsPointSaleArray = $this->_totalReportCSV( |
|
|
$totalsPointSaleArray = $this->_totalReportCSV( |
|
|
'Total', |
|
|
|
|
|
|
|
|
' Total (unité)', |
|
|
$pointSale->orders, |
|
|
$pointSale->orders, |
|
|
$productsArray, |
|
|
$productsArray, |
|
|
$productsIndexArray |
|
|
$productsIndexArray |
|
|
); |
|
|
); |
|
|
$datas[] = $this->_lineOrderReportCSV($totalsPointSaleArray, $cpt); |
|
|
$datas[] = $this->_lineOrderReportCSV($totalsPointSaleArray, $cpt); |
|
|
|
|
|
|
|
|
|
|
|
$totalsGlobalPiecesArray = $this->_totalReportPiecesCSV( |
|
|
|
|
|
' Total (pièces)', |
|
|
|
|
|
$ordersArray, |
|
|
|
|
|
$productsArray, |
|
|
|
|
|
$productsIndexArray |
|
|
|
|
|
); |
|
|
|
|
|
$datas[] = $this->_lineOrderReportCSV($totalsGlobalPiecesArray, $cpt); |
|
|
|
|
|
|
|
|
$datas[] = []; |
|
|
$datas[] = []; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// global |
|
|
// global |
|
|
$totalsGlobalArray = $this->_totalReportCSV( |
|
|
$totalsGlobalArray = $this->_totalReportCSV( |
|
|
'> Totaux', |
|
|
|
|
|
|
|
|
'> Totaux (unité)', |
|
|
$ordersArray, |
|
|
$ordersArray, |
|
|
$productsArray, |
|
|
$productsArray, |
|
|
$productsIndexArray |
|
|
$productsIndexArray |
|
|
); |
|
|
); |
|
|
$datas[] = $this->_lineOrderReportCSV($totalsGlobalArray, $cpt); |
|
|
$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'); |
|
|
CSV::downloadSendHeaders('Commandes_' . $date . '.csv'); |
|
|
echo CSV::array2csv($datas); |
|
|
echo CSV::array2csv($datas); |
|
|
die(); |
|
|
die(); |
|
|
|
|
|
|
|
|
return $totalsPointSaleArray; |
|
|
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) |
|
|
public function _lineOrderReportCSV($orderLine, $cptMax, $showTotal = false) |
|
|
{ |
|
|
{ |
|
|
$line = []; |
|
|
$line = []; |