From 2b1381bd2a4a95f96b2217afcebc686a9f592d6a Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 5 Feb 2025 21:03:19 +0300 Subject: [PATCH 1/3] =?UTF-8?q?finish=20invoice=20recap=20groupe=20adress?= =?UTF-8?q?=20=C3=A0=20la=20lignen=20wip=20on=20facture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InvoiceRecap/InvoiceRecapService.php | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php index 1b13885..cb972ab 100644 --- a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php +++ b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php @@ -202,7 +202,17 @@ class InvoiceRecapService { $pdf->Cell( 0, 7, utf8_decode($clientGroupFacturation["group_facturation_name"])); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["address"])))); + $clientAdress = FileExportHelpers::FormatTextForExport($clientGroupFacturation["address"]); + $clientAdressWidth = $pdf->GetStringWidth($clientAdress); + $maxWidth = $pdf->GetPageWidth(); + $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; + $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAdress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["postal_code"]. ' ' .$clientGroupFacturation["city"])))); @@ -290,13 +300,18 @@ class InvoiceRecapService { // adresse du facture $clientInfoXAxis = 125; - $clientInfoYAxis = 40; + $clientInfoYAxis = $clientAdressIsMultiline ? 33 : 40; $pdf->SetFont('ComicSans','',size: 11); $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, utf8_decode('Groupe '.$clientGroupFacturation["group_facturation_name"])); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["address"])))); + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAdress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["postal_code"]. ' '.$clientGroupFacturation["city"])))); @@ -584,7 +599,17 @@ class InvoiceRecapService { $pdf->Cell( 0, 7, utf8_decode($clientHeaderLabel)); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientAddress)))); + $clientAddress = FileExportHelpers::FormatTextForExport($clientAddress); + $clientAdressWidth = $pdf->GetStringWidth($clientAddress); + $maxWidth = $pdf->GetPageWidth(); + $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; + $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAddress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientCity)))); @@ -672,13 +697,18 @@ class InvoiceRecapService { // adresse du facture $clientInfoXAxis = 125; - $clientInfoYAxis = 40; + $clientInfoYAxis = $clientAdressIsMultiline ? 33 : 40; $pdf->SetFont('ComicSans','',size: 11); $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, utf8_decode($clientHeaderLabel)); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientAddress)))); + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAddress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientCity)))); From ff594aba51a5ca5c6d272b3e8e6b7215aecce3e0 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 5 Feb 2025 21:12:26 +0300 Subject: [PATCH 2/3] finish multiline adress on facture also --- gestion/lib/Service/InvoicePdfHandler.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index 0eee5d5..6dc1e3f 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -105,7 +105,6 @@ class InvoicePdfHandler extends FPDF { $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->factureData['configuration']->telephone),0,1); $this->Cell(0, 5, 'Mail : ' . $this->factureData['configuration']->mail, 0, 1); } - private function DrawInvoiceClientInfo(){ $this->SetFont('ComicSans', '', 10); $clientName = $this->factureData['client_nom']; @@ -113,12 +112,22 @@ class InvoicePdfHandler extends FPDF { $clientName = $this->factureData['group_name']; } $clientInfoXAxis = 125; - $clientInfoYAxis = 40; + + $clientAddress = FileExportHelpers::FormatTextForExport($this->factureData['client_real_adress']); + $clientAdressWidth = $this->GetStringWidth($clientAddress); + $maxWidth = $this->GetPageWidth(); + $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; + $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; + + $clientInfoYAxis = $clientAdressIsMultiline ? 35 : 40; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($clientName)); $clientInfoYAxis += 5; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_real_adress']))); + $this->MultiCell( 0, 5, trim($clientAddress)); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 5; + } $clientInfoYAxis += 5; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); From 91e397886c19ce65efa5cc11b74f58099eac48ef Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 5 Feb 2025 21:26:31 +0300 Subject: [PATCH 3/3] recap tampon --- .../InvoiceRecap/InvoiceRecapService.php | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php index cb972ab..1f8e3fb 100644 --- a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php +++ b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php @@ -222,25 +222,30 @@ class InvoiceRecapService { $pdf->Cell( 0, 7, "Saint Senoux, le ".utf8_decode($date_formated)); // observations - $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, 95 ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); + $objetYAxis = 110; + $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); $objet = utf8_decode("Récapitulatif Facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 95 ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 105 ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); + $objetYAxis += 10; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); $text1 = utf8_decode("Veuillez trouver ci-dessous le récapitulatif de la facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]))."."; $text2 = utf8_decode("Vous en souhaitant bonne réception."); $text3 = utf8_decode("Veuillez agréer, Madame, Monsieur, mes salutations les meilleures."); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 115 ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 120 ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 125 ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); + $objetYAxis += 10; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); + $objetYAxis += 5; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); + $objetYAxis += 5; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); // signature - $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 145 ); + $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 170); $pdf->Cell( $pdf->GetStringWidth($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom), 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom)), 0, 0, 'L'); if($doesSignatureExist){ - $pdf->Image($this->defaultImagePath."sign.png", 135, 150, 60,40); + $pdf->Image($this->defaultImagePath."sign.png", 140, 175, 45,30); } $y0 = 260; @@ -451,6 +456,7 @@ class InvoiceRecapService { $data_factures = []; $storage = $this->rootFolder->getUserFolder($idNextcloud); $doesLogoExist = $this->doesLogoExist(); + $doesSignatureExist = $this->doesSignatureImageExists(); $defaultConfig = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); $configurationAddresses = FileExportHelpers::GetAddressAndCityFromAddress($defaultConfig[0]->adresse); $configurationAddress = $configurationAddresses["address"]; @@ -619,26 +625,30 @@ class InvoiceRecapService { $pdf->Cell( 0, 7, "Saint Senoux, le ".utf8_decode($date_formated)); // observations - $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, 95 ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); + $objetYAxis = 110; + $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); $objet = utf8_decode("Récapitulatif Facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 95 ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 105 ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); + $objetYAxis += 10; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); $text1 = utf8_decode("Veuillez trouver ci-dessous le récapitulatif de la facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]))."."; $text2 = utf8_decode("Vous en souhaitant bonne réception."); $text3 = utf8_decode("Veuillez agréer, Madame, Monsieur, mes salutations les meilleures."); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 115 ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 120 ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 125 ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); + $objetYAxis += 10; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); + $objetYAxis += 5; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); + $objetYAxis += 5; + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); // signature - $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 145 ); + $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 170); $pdf->Cell( $pdf->GetStringWidth($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom), 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom)), 0, 0, 'L'); - $signatureExists = $this->doesSignatureImageExists(); - if($signatureExists){ - $pdf->Image($this->defaultImagePath."sign.png", 135, 150, 60,40); + if($doesSignatureExist){ + $pdf->Image($this->defaultImagePath."sign.png", 140, 175, 45,30); } $y0 = 260;