diff --git a/gestion/lib/Service/Order/OrderPdfService.php b/gestion/lib/Service/Order/OrderPdfService.php index deff243..99005a8 100644 --- a/gestion/lib/Service/Order/OrderPdfService.php +++ b/gestion/lib/Service/Order/OrderPdfService.php @@ -150,7 +150,7 @@ class OrderPdfService { $filename .= mb_strtoupper($defuntNom,'UTF-8'); } else{ - $filename .= mb_strtoupper($orderPdfData['provider_name'],'UTF-8'); + $filename .= mb_strtoupper($orderPdfData['company_name'],'UTF-8'); } return $filename; } diff --git a/gestion/lib/Service/Order/OrderService.php b/gestion/lib/Service/Order/OrderService.php index 471f225..d727dc3 100644 --- a/gestion/lib/Service/Order/OrderService.php +++ b/gestion/lib/Service/Order/OrderService.php @@ -145,7 +145,7 @@ class OrderService { "quantite" => $orderItem["order_item_quantity"], "produit_price" => $orderItem["order_product_ht_amount"], "produit_reference" => $orderItem["order_product_reference"], - "description" => $orderItem["order_product_label"], + "produit_description" => $orderItem["order_product_label"], ]; } $orderDetails["client_real_adress"] = $orderDetails["provider_address"]; diff --git a/gestion/lib/Service/Order/PdfHandler/OrderPdfHandler.php b/gestion/lib/Service/Order/PdfHandler/OrderPdfHandler.php index ab6d982..d7bd07e 100644 --- a/gestion/lib/Service/Order/PdfHandler/OrderPdfHandler.php +++ b/gestion/lib/Service/Order/PdfHandler/OrderPdfHandler.php @@ -46,7 +46,7 @@ class OrderPdfHandler extends FPDF { private $initialIndexPosition = 0; private $articlesCountToGet = 0; - private const MAX_ARTICLES_PER_PAGE = 18; + private const MAX_ARTICLES_PER_PAGE = 16; private const DEFAULT_SUBCONTRACTOR_NAME = "SOUS TRAITANT"; function Header() @@ -159,6 +159,7 @@ class OrderPdfHandler extends FPDF { $products = $this->orderData["products"]; // var_dump($products); $yValue = 116; + $maxDescriptionWidth = 98; $currentIndexPosition = $this->currentIndexPosition; for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->articlesCountToGet);$currentIndexPosition++){ $product = $products[$currentIndexPosition]; @@ -166,7 +167,7 @@ class OrderPdfHandler extends FPDF { $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue); $totalHt+=$valueHt; $totalTtc+=$valueTtc; - $productDescription = $product["produit_reference"]; + $productDescription = $product["produit_reference"] . ' ' . $product['produit_description']; $dateValue = ""; if($product === end($products) ){ $dateValue = $this->orderData["devis_date"]; @@ -177,9 +178,23 @@ class OrderPdfHandler extends FPDF { $tvaAmount = $valueTtc - $valueHt; $this->SetXY( 10,$yValue ); $this->Cell(25, 6, $dateValue, 0,0,'C'); - + + $productDescription = FileExportHelpers::FormatTextForExport($productDescription); + $productDescriptionWidth = $this->GetStringWidth($productDescription); + $productDescriptionWidthIsGreaterThanMaxWidth = $productDescriptionWidth > $maxDescriptionWidth; + $productDescriptionIsMultiline = false; $this->SetXY( 35,$yValue ); - $this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($productDescription),0); + if ($productDescriptionWidthIsGreaterThanMaxWidth) { + $yBefore = $this->GetY(); + $this->MultiCell($maxDescriptionWidth, 6, $productDescription,0,'L'); + $yAfter = $this->GetY(); + $productDescriptionIsMultiline = ($yAfter - $yBefore) > 6; + if($productDescriptionIsMultiline){ + $this->SetXY($this->GetX(),$yBefore); + } + } else { + $this->Cell($maxDescriptionWidth, 6, $productDescription); + } $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); @@ -191,6 +206,9 @@ class OrderPdfHandler extends FPDF { $this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C'); $yValue += 6; $totalTva += $tvaAmount; + if($productDescriptionIsMultiline){ + $yValue += 6; + } } $this->currentIndexPosition = $currentIndexPosition; $this->initialIndexPosition = $this->currentIndexPosition;