diff --git a/gestion/lib/Service/Devis/DevisPdfTableRenderer.php b/gestion/lib/Service/Devis/DevisPdfTableRenderer.php index 6d054e4..8d3f5a4 100644 --- a/gestion/lib/Service/Devis/DevisPdfTableRenderer.php +++ b/gestion/lib/Service/Devis/DevisPdfTableRenderer.php @@ -37,11 +37,12 @@ class DevisPdfTableRenderer $endY = ($numPage == $nbPage && !$sansMontant) ? 225 : 235; if (!$sansMontant) { - // AVEC montants : toutes les colonnes - $verticalLines = [25, 45, 65, 80, 100, 125, 145, 165, 185]; + // Ajustement final des positions des lignes verticales + // Article et Défunt de même taille, TTC réduit + $verticalLines = [22, 39, 56, 75, 105, 135, 155, 170, 185]; } else { - // SANS montants : SUPPRIMER la colonne vide à droite - $verticalLines = [35, 70, 105, 120, 135, 160]; // Seulement 6 lignes au lieu de 7 + // Pour sans montant: Article et Défunt de même taille + $verticalLines = [27, 47, 67, 85, 115, 145]; } foreach ($verticalLines as $x) { @@ -55,27 +56,26 @@ class DevisPdfTableRenderer if (!$sansMontant) { $headers = [ - [5, 20, "N° Devis"], - [25, 20, "N° Dossier"], - [45, 20, "N° Commande"], - [65, 15, "Date"], - [80, 20, "Article"], - [100, 25, "Lieu du soin"], - [125, 20, "Défunt"], - [145, 20, "H.T."], - [165, 20, "TVA"], - [185, 20, "T.T.C"] + [5, 17, "N° Devis"], + [22, 17, "N° Dossier"], + [39, 17, "N° Commande"], + [56, 19, "Date"], + [75, 30, "Article"], // Taille augmentée + [105, 30, "Lieu du soin"], + [135, 20, "Défunt"], // Taille réduite pour équilibrer + [155, 15, "H.T."], + [170, 15, "TVA"], + [185, 15, "T.T.C"] // Taille réduite ]; } else { - // SANS montants : SUPPRIMER la colonne vide, agrandir la dernière colonne $headers = [ - [5, 30, "N° Devis"], - [35, 35, "N° Dossier"], - [70, 35, "N° Commande"], - [105, 15, "Date"], - [120, 15, "Article"], - [135, 25, "Lieu du soin"], - [160, 45, "Défunt"] // Dernière colonne plus large + [5, 22, "N° Devis"], + [27, 20, "N° Dossier"], + [47, 20, "N° Commande"], + [67, 18, "Date"], + [85, 30, "Article"], // Même taille que Défunt + [115, 30, "Lieu du soin"], + [145, 30, "Défunt"] // Même taille que Article ]; } @@ -113,7 +113,6 @@ class DevisPdfTableRenderer { $pdf->SetFont('Arial', '', 7); - // Fonction généraliste pour gérer automatiquement le débordement $addSmartCell = function ($pdf, $x, $y, $width, $text, $align = 'L') use ($yDevis) { $textWidth = $pdf->GetStringWidth($text); $maxWidth = $width - 2; @@ -128,47 +127,41 @@ class DevisPdfTableRenderer }; if (!$sansMontant) { - $addSmartCell($pdf, 6, $yDevis, 18, $devis['devis_full_number']); + // LARGEURS ÉQUILIBRÉES avec Article et Défunt de même taille + $addSmartCell($pdf, 6, $yDevis, 16, $devis['devis_full_number']); + $addSmartCell($pdf, 23, $yDevis, 16, $devis['case_number'] ?? ''); + $addSmartCell($pdf, 40, $yDevis, 16, $devis['order_number'] ?? ''); - // N° Dossier - UTILISER case_number - $addSmartCell($pdf, 26, $yDevis, 18, $devis['case_number'] ?? ''); - - // N° Commande - UTILISER order_number - $addSmartCell($pdf, 46, $yDevis, 18, $devis['order_number'] ?? ''); - - $addSmartCell($pdf, 66, $yDevis, 13, mb_convert_encoding($formatterDate->format($dateSoin), 'ISO-8859-1', 'UTF-8')); + $addSmartCell($pdf, 57, $yDevis, 18, mb_convert_encoding($formatterDate->format($dateSoin), 'ISO-8859-1', 'UTF-8')); $articleText = \OCA\Gestion\Helpers\FileExportHelpers::FormatTextForExport($devis['article'] ?? 'SOINS'); - $addSmartCell($pdf, 81, $yDevis, 18, $articleText); + $addSmartCell($pdf, 76, $yDevis, 29, $articleText); // Article agrandi $lieuText = \OCA\Gestion\Helpers\FileExportHelpers::FormatTextForExport($devis['lieu_nom'] ?? ''); - $addSmartCell($pdf, 101, $yDevis, 23, $lieuText); + $addSmartCell($pdf, 106, $yDevis, 29, $lieuText); $defuntText = \OCA\Gestion\Helpers\FileExportHelpers::FormatTextForExport($devis['defunt_nom'] ?? ''); - $addSmartCell($pdf, 126, $yDevis, 18, $defuntText); + $addSmartCell($pdf, 136, $yDevis, 19, $defuntText); // Défunt réduit - $addSmartCell($pdf, 146, $yDevis, 18, number_format($devis['montant_htc'], 2, '.', '') . chr(128), 'C'); - $addSmartCell($pdf, 166, $yDevis, 18, number_format($devis['montant_tva'], 2, '.', '') . chr(128), 'C'); - $addSmartCell($pdf, 186, $yDevis, 18, number_format($devis['montant_ttc'], 2, '.', '') . chr(128), 'C'); + $addSmartCell($pdf, 156, $yDevis, 14, number_format($devis['montant_htc'], 2, '.', '') . chr(128), 'R'); + $addSmartCell($pdf, 171, $yDevis, 14, number_format($devis['montant_tva'], 2, '.', '') . chr(128), 'R'); + $addSmartCell($pdf, 186, $yDevis, 14, number_format($devis['montant_ttc'], 2, '.', '') . chr(128), 'R'); // TTC réduit } else { - $addSmartCell($pdf, 6, $yDevis, 28, $devis['devis_full_number']); + // Pour sans montant: Article et Défunt de même taille + $addSmartCell($pdf, 6, $yDevis, 21, $devis['devis_full_number']); + $addSmartCell($pdf, 28, $yDevis, 19, $devis['case_number'] ?? ''); + $addSmartCell($pdf, 48, $yDevis, 19, $devis['order_number'] ?? ''); - // N° Dossier - UTILISER case_number - $addSmartCell($pdf, 36, $yDevis, 33, $devis['case_number'] ?? ''); - - // N° Commande - UTILISER order_number - $addSmartCell($pdf, 71, $yDevis, 33, $devis['order_number'] ?? ''); - - $addSmartCell($pdf, 106, $yDevis, 13, mb_convert_encoding($formatterDate->format($dateSoin), 'ISO-8859-1', 'UTF-8')); + $addSmartCell($pdf, 68, $yDevis, 17, mb_convert_encoding($formatterDate->format($dateSoin), 'ISO-8859-1', 'UTF-8')); $articleText = \OCA\Gestion\Helpers\FileExportHelpers::FormatTextForExport($devis['article'] ?? 'SOINS'); - $addSmartCell($pdf, 121, $yDevis, 13, $articleText); + $addSmartCell($pdf, 86, $yDevis, 29, $articleText); // Article agrandi $lieuText = \OCA\Gestion\Helpers\FileExportHelpers::FormatTextForExport($devis['lieu_nom'] ?? ''); - $addSmartCell($pdf, 136, $yDevis, 23, $lieuText); + $addSmartCell($pdf, 116, $yDevis, 29, $lieuText); $defuntText = \OCA\Gestion\Helpers\FileExportHelpers::FormatTextForExport($devis['defunt_nom'] ?? ''); - $addSmartCell($pdf, 161, $yDevis, 44, $defuntText); + $addSmartCell($pdf, 146, $yDevis, 29, $defuntText); // Défunt réduit } } @@ -177,29 +170,33 @@ class DevisPdfTableRenderer $pdf->Line(5, 225, 205, 225); $pdf->SetFont('Arial', 'B', 8); + // Alignement des totaux avec les colonnes HT, TVA, TTC $pdf->SetXY(5, 225); $pdf->Cell(130, 8, 'TOTAL', 0, 0, 'C'); - // POSITIONS CORRIGÉES - $pdf->SetXY(136, 225); - $pdf->Cell(18, 8, number_format($totals['ht'], 2, '.', '') . chr(128), 0, 0, 'C'); - $pdf->SetXY(156, 225); - $pdf->Cell(18, 8, number_format($totals['tva'], 2, '.', '') . chr(128), 0, 0, 'C'); - $pdf->SetXY(176, 225); - $pdf->Cell(14, 8, number_format($totals['ttc'], 2, '.', '') . chr(128), 0, 0, 'C'); + // POSITIONS alignées avec les colonnes du tableau + $pdf->SetXY(155, 225); + $pdf->Cell(15, 8, number_format($totals['ht'], 2, '.', '') . chr(128), 0, 0, 'R'); + $pdf->SetXY(170, 225); + $pdf->Cell(15, 8, number_format($totals['tva'], 2, '.', '') . chr(128), 0, 0, 'R'); + $pdf->SetXY(185, 225); + $pdf->Cell(15, 8, number_format($totals['ttc'], 2, '.', '') . chr(128), 0, 0, 'R'); - // TOTAL TTC + // CADRE TOTAL TTC - Texte à l'intérieur du cadre aligné à droite $pdf->SetXY(155, 240); - $pdf->Cell(20, 8, 'TOTAL TTC', 0, 0, 'C'); - $pdf->SetXY(176, 240); - $pdf->Cell(14, 8, number_format($totals['ttc'], 2, '.', '') . chr(128), 0, 0, 'C'); + $pdf->Cell(30, 8, 'TOTAL TTC', 0, 0, 'C'); + // Valeur alignée avec la fin du tableau tout à droite + $pdf->SetXY(185, 240); + $pdf->Cell(15, 8, number_format($totals['ttc'], 2, '.', '') . chr(128), 0, 0, 'R'); + + // Cadre TOTAL TTC aligné avec la fin du tableau (205) $lines = [ - [155, 240, 155, 248], - [176, 240, 176, 248], - [190, 240, 190, 248], - [155, 240, 190, 240], - [155, 248, 190, 248] + [155, 240, 155, 248], // Ligne verticale gauche + [185, 240, 185, 248], // Ligne de séparation + [205, 240, 205, 248], // Ligne verticale droite (alignée avec fin du tableau) + [155, 240, 205, 240], // Ligne horizontale haute + [155, 248, 205, 248] // Ligne horizontale basse ]; foreach ($lines as $line) { diff --git a/gestion/templates/content/apercustousdevis.php b/gestion/templates/content/apercustousdevis.php index d3eeb04..d9fcb04 100644 --- a/gestion/templates/content/apercustousdevis.php +++ b/gestion/templates/content/apercustousdevis.php @@ -315,15 +315,16 @@ } ?> +