Browse Source

[Administration] Distributions > récapitulatif commandes PDF : amélioration lisibilité quantités #1282

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
5a5a36ecfc
1 changed files with 11 additions and 9 deletions
  1. +11
    -9
      common/logic/Distribution/Distribution/Service/DistributionReportPdfGenerator.php

+ 11
- 9
common/logic/Distribution/Distribution/Service/DistributionReportPdfGenerator.php View File



class DistributionReportPdfGenerator extends AbstractGenerator class DistributionReportPdfGenerator extends AbstractGenerator
{ {
const LIMIT_PRODUCTS = 100;
const LIMIT_PRODUCTS = 120;


protected OrderRepository $orderRepository; protected OrderRepository $orderRepository;
protected OrderBuilder $orderBuilder; protected OrderBuilder $orderBuilder;
foreach( Product::$unitsArray as $unit => $dataUnit) { foreach( Product::$unitsArray as $unit => $dataUnit) {
$quantity = $this->orderSolver->getProductQuantity($product, $pointSale->orders, false, $unit); $quantity = $this->orderSolver->getProductQuantity($product, $pointSale->orders, false, $unit);
if ($quantity) { if ($quantity) {
$theUnit = ( $this->productSolver->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $this->productSolver->strUnit($unit, 'wording_short', true) ;
$strProducts .= '(' .$quantity .$theUnit.') '.$this->productSolver->getNameExport($product) . '<br />';
$strProducts .= $this->displayOrderProduct($quantity, $unit, $product);
} }
} }


foreach ($productsArray as $product) { foreach ($productsArray as $product) {
foreach ($order->productOrder as $productOrder) { foreach ($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) { if($product->id == $productOrder->id_product) {
$unit = ( $this->productSolver->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'. $this->productSolver->strUnit($productOrder->unit, 'wording_short', true) ;
$strProducts .= '('.$productOrder->quantity .$unit.') '.$this->productSolver->getNameExport($product) . '<br />';
$strProducts .= $this->displayOrderProduct($productOrder->quantity, $productOrder->unit, $product);
} }
} }
} }
foreach( Product::$unitsArray as $unit => $dataUnit) { foreach( Product::$unitsArray as $unit => $dataUnit) {
$quantity = $this->orderSolver->getProductQuantity($product, $pointSale->orders, false, $unit); $quantity = $this->orderSolver->getProductQuantity($product, $pointSale->orders, false, $unit);
if ($quantity) { if ($quantity) {
$theUnit = ( $this->productSolver->strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'. $this->productSolver->strUnit($unit, 'wording_short', true) ;
$html .= '(' .$quantity .$theUnit.') '.$this->productSolver->getNameExport($product) . '<br />';
$html .= $this->displayOrderProduct($quantity, $unit, $product);
} }
} }


foreach( Product::$unitsArray as $unit => $dataUnit) { foreach( Product::$unitsArray as $unit => $dataUnit) {
$quantity = $this->orderSolver->getProductQuantity($product, $ordersArray, false, $unit); $quantity = $this->orderSolver->getProductQuantity($product, $ordersArray, false, $unit);
if ($quantity) { if ($quantity) {
$theUnit = ( $this->productSolver->strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'. $this->productSolver->strUnit($unit, 'wording_short', true) ;
$html .= '(' .$quantity .$theUnit.') '.$product->name . '<br />';
$html .= $this->displayOrderProduct($quantity, $unit, $product);
} }
} }
if($isBig && $cpt == self::LIMIT_PRODUCTS) { if($isBig && $cpt == self::LIMIT_PRODUCTS) {


return $html; return $html;
} }

public function displayOrderProduct(string $quantity, string $unit, Product $product)
{
$theUnit = ( $this->productSolver->strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'. $this->productSolver->strUnit($unit, 'wording_short', true) ;
return '<strong>'.$quantity. $theUnit.'</strong> '.$this->productSolver->getNameExport($product). '<br />';
}
} }

Loading…
Cancel
Save