Browse Source

[backend] Vente au kilo : adaptation export CSV

dev
Guillaume Bourgeois 5 years ago
parent
commit
7f5cc6b798
1 changed files with 17 additions and 13 deletions
  1. +17
    -13
      backend/controllers/DistributionController.php

+ 17
- 13
backend/controllers/DistributionController.php View File

foreach($pointSale->orders as $order) { foreach($pointSale->orders as $order) {
$orderLine = [$order->getStrUser()] ; $orderLine = [$order->getStrUser()] ;
foreach($order->productOrder as $productOrder) { foreach($order->productOrder as $productOrder) {
$orderLine[$productsIndexArray[$productOrder->id_product]] = $productOrder->quantity ;
$orderLine[$productsIndexArray[$productOrder->id_product]] = $productOrder->quantity . ' '.Product::strUnit($productOrder->unit, true, true);
} }
$datas[] = $this->_lineOrderReportCSV($orderLine, $cpt) ; $datas[] = $this->_lineOrderReportCSV($orderLine, $cpt) ;
} }
// total point de vente // total point de vente
$totalsPointSaleArray = ['Total'] ; $totalsPointSaleArray = ['Total'] ;
foreach ($productsArray as $product) { foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders);
if($quantity) {
$index = $productsIndexArray[$product->id] ;
if(!isset($totalsPointSaleArray[$index])) {
$totalsPointSaleArray[$index] = 0 ;
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$index = $productsIndexArray[$product->id] ;
if(!isset($totalsPointSaleArray[$index])) {
$totalsPointSaleArray[$index] = '' ;
}
$totalsPointSaleArray[$index] .= $quantity . ' '.Product::strUnit($unit, true, true).' ';
} }
$totalsPointSaleArray[$index] += $quantity ;
} }
} }
// global // global
$totalsGlobalArray = ['> Totaux'] ; $totalsGlobalArray = ['> Totaux'] ;
foreach ($productsArray as $product) { foreach ($productsArray as $product) {
$quantity = Order::getProductQuantity($product->id, $ordersArray);
if($quantity) {
$index = $productsIndexArray[$product->id] ;
if(!isset($totalsGlobalArray[$index])) {
$totalsGlobalArray[$index] = 0 ;
foreach(Product::$unitsArray as $unit => $dataUnit) {
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit);
if ($quantity) {
$index = $productsIndexArray[$product->id] ;
if(!isset($totalsGlobalArray[$index])) {
$totalsGlobalArray[$index] = '' ;
}
$totalsGlobalArray[$index] .= $quantity . ' '.Product::strUnit($unit, true, true).' ';
} }
$totalsGlobalArray[$index] += $quantity ;
} }
} }



Loading…
Cancel
Save