From 37d70487d11c53b8b1d867729fca57e9f666b8a7 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Mon, 3 Feb 2025 21:54:53 +0300 Subject: [PATCH] add configuration data into recap, wip add configuration data into the recap product --- gestion/lib/Controller/PageController.php | 2 +- gestion/lib/Db/Bdd.php | 2 +- .../InvoiceRecap/InvoiceRecapService.php | 106 ++++++++++++++---- 3 files changed, 84 insertions(+), 26 deletions(-) diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index a3d0608..d13e394 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -839,7 +839,7 @@ class PageController extends Controller { $pdf->SetMargins(0,0,0); // logo : 80 de largeur et 55 de hauteur - $pdf->Image($this->src_path."logo.png", 10, 10, 55, 30); + $pdf->Image($this->src_path."logo.png", 10, 10, 55, 30); // adresse du facture $pdf->SetFont('ComicSans','B',11); $_x = 122 ; $_y = 40; $pdf->SetXY( $_x, $_y ); $pdf->Cell( 100, 8, utf8_decode($current_client), 0, 0, ''); $_y += 8; diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index 4e51138..8fa2fd9 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -447,7 +447,7 @@ class Bdd { LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id LEFT JOIN ".$this->tableprefix."defunt on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id WHERE YEAR(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[2]." AND MONTH(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[1]." - AND ".$this->tableprefix."client.id = ? ORDER BY year DESC, month DESC;"; + AND ".$this->tableprefix."client.id = ? ORDER BY date_soin ASC"; $result = $this->execSQL($sql, array($clientId)); return $result; } diff --git a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php index d2d7e51..db1b298 100644 --- a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php +++ b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php @@ -94,6 +94,9 @@ class InvoiceRecapService { $tvaIntraCommuValue = $firstClient["legal_one"]; } $defaultConfig = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); + $configurationAddresses = FileExportHelpers::GetAddressAndCityFromAddress($defaultConfig[0]->adresse); + $configurationAddress = $configurationAddresses["address"]; + $configurationAddressCity = $configurationAddresses["city"]; $factures = json_decode($this->gestionBdd->getClientFacturesByClientGroupFacturationIdAndDate($clientGroupId,$date)); $factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; }); $groupName = ""; @@ -166,27 +169,53 @@ class InvoiceRecapService { if($doesLogoExist){ $pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25); } + + //adresse de mon entreprise + $companyInfoXAxis = 10; + $companyInfoYAxis = 40; + $pdf->SetFont('ComicSans', '', 11); + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport($defaultConfig[0]->entreprise)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport($configurationAddress)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport($configurationAddressCity)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($defaultConfig[0]->telephone)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, 'Mail : ' . $defaultConfig[0]->mail); + + // adresse du facture - $pdf->SetFont('ComicSans','B',11); $_x = 122 ; $_y = 40; - $pdf->SetXY( $_x, $_y ); $pdf->Cell( 100, 8, utf8_decode('Groupe '.$groupName), 0, 0, ''); $_y += 8; + $clientInfoXAxis = 125; + $clientInfoYAxis = 40; + $pdf->SetFont('ComicSans','B',size: 11); + $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); + $pdf->Cell( 0, 7, utf8_decode('Groupe '.$groupName)); + $clientInfoYAxis += 7; + $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); // date facture - $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 122, 60 ); - $pdf->Cell( 60, 8, "Saint Senoux, le ".utf8_decode($date_formated), 0, 0, ''); + $pdf->SetFont('ComicSans','',11); + $pdf->Cell( 0, 7, "Saint Senoux, le ".utf8_decode($date_formated)); // observations - $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, 85 ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); + $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, 95 ) ; $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, 85 ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); + $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, 95 ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 105 ); $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, 105 ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 110 ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 120 ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); + $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"); // signature $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 145 ); @@ -336,7 +365,6 @@ class InvoiceRecapService { $num_page++; } - // var_dump("tonga aty ve");die; $ff_pdf = html_entity_decode( $defaultConfig[0]->path). '/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '. @@ -365,6 +393,9 @@ class InvoiceRecapService { $tvaIntraCommuValue = $firstClient["legal_one"]; } $defaultConfig = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); + $configurationAddresses = FileExportHelpers::GetAddressAndCityFromAddress($defaultConfig[0]->adresse); + $configurationAddress = $configurationAddresses["address"]; + $configurationAddressCity = $configurationAddresses["city"]; $factures = json_decode($this->gestionBdd->getClientFacturesByClientIdAndDate( clientId: $clientId, date: $date @@ -451,32 +482,59 @@ class InvoiceRecapService { if($doesLogoExist){ $pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25); } + + //adresse de mon entreprise + $companyInfoXAxis = 10; + $companyInfoYAxis = 40; + $pdf->SetFont('ComicSans', '', 11); + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport($defaultConfig[0]->entreprise)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport($configurationAddress)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport($configurationAddressCity)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($defaultConfig[0]->telephone)); + $companyInfoYAxis += 7; + $pdf->SetXY($companyInfoXAxis,$companyInfoYAxis); + $pdf->Cell(0, 7, 'Mail : ' . $defaultConfig[0]->mail); + + // adresse du facture + $clientInfoXAxis = 125; + $clientInfoYAxis = 40; $pdf->SetFont('ComicSans','B',size: 11); - $pdf->SetY(40); - $pdf->Cell( 0, 8, utf8_decode($current_client), 0, 1, 'R'); - $pdf->Cell( 0, 8, trim(utf8_decode(html_entity_decode($clientAddress))), 0,1,'R'); - if($clientCity != ''){ - $pdf->Cell( 0, 8, trim(utf8_decode(html_entity_decode($clientCity))), 0, 1, 'R'); - } + $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); + $pdf->Cell( 0, 7, utf8_decode($current_client)); + $clientInfoYAxis += 7; + $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); + $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientAddress)))); + $clientInfoYAxis += 7; + $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); + $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientCity)))); + $clientInfoYAxis += 7; + $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); // date facture $pdf->SetFont('ComicSans','',11); - $pdf->Cell( 0, 8, "Saint Senoux, le ".utf8_decode($date_formated), 0, 1, 'R'); + $pdf->Cell( 0, 7, "Saint Senoux, le ".utf8_decode($date_formated)); // observations - $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, 85 ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); + $pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, 95 ) ; $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, 85 ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); + $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, 95 ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); + $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 105 ); $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, 105 ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 110 ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); - $pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, 120 ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); + $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"); // signature $pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 145 );