* * @author Anna Larch * @author Richard Steinmetz * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see . * */ namespace OCA\Gestion\Service\InvoiceRecap; use DateTime; use OCA\Gestion\Constants\MultipleFactureTypeConstant; use OCA\Gestion\Db\Bdd; use OCA\Gestion\Helpers\DateHelpers; use OCP\Files\IRootFolder; use \FPDF; use IntlDateFormatter; use OCA\Gestion\Helpers\FileExportHelpers; class InvoiceRecapService { /** @var Bdd */ private $gestionBdd; /** @var IRootFolder */ private $rootFolder; private $defaultImagePath = "/var/www/html/data/admin/files/.gestion/"; private const DEFAULT_NEXTCLOUD_ADMIN = "admin"; public function __construct( Bdd $gestionBdd, IRootFolder $rootFolder) { $this->gestionBdd = $gestionBdd; $this->rootFolder = $rootFolder; } private function doesSignatureImageExists(){ $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); try{ if(isset($storage)){ $storage->get("/.gestion/sign.png"); $signatureExist = true; }else{ $signatureExist = false; } } catch(\OCP\Files\NotFoundException $e) { $signatureExist = false; } return $signatureExist; } private function doesLogoExist(){ $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); try{ if(isset($storage)){ $file = $storage->get('/.gestion/logo.png'); return true; }else{ return false; } } catch(\OCP\Files\NotFoundException $e) { return false; } } private function generateInvoiceRecapPerClientGroupFacturation($clientGroupId,$date,$idNextcloud){ $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"]; $configurationAddressCity = $configurationAddresses["city"]; $factures = json_decode($this->gestionBdd->getClientFacturesByClientGroupFacturationIdAndDate($clientGroupId,$date)); $factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; }); $clientGroupFacturation = $this->gestionBdd->getClientGroupFacturationById($clientGroupId); if($clientGroupFacturation == null){ return null; } foreach ($factures as $key => $facture) { $facture_temp = array( 'num' => $facture->num, 'id_client' => $facture->id_client, 'client' => $facture->entreprise, 'adresse_client' => $facture->adresse_client, 'mail_client' => $facture->mail_client, 'adresse_devis' => $facture->lieu, 'nom_client' => html_entity_decode($facture->nom), 'prenoms_client' => html_entity_decode($facture->prenom), 'numero_commande' => $facture->numero_commande, 'date_soin' => $facture->date_soin, 'date' => $facture->date, 'date_facture' => $facture->date_paiement, 'defunt' => $facture->nom_defunt, 'montant_htc' => 0, 'tva' => $defaultConfig[0]->tva_default, 'montant_tva' => 0, 'montant_ttc' => 0 ); $produits = json_decode($this->gestionBdd->getListProduit($facture->id_devis,$idNextcloud)); $produitsReferenceArray = []; foreach ($produits as $key => $produit) { $htPrice = $produit->prix_unitaire; if($facture->fk_client_group_id != null){ $price = $this->gestionBdd->getProductPriceByClientGroupId($facture->fk_client_group_id,$produit->id); if($price != null){ $htPrice = $price; } } $facture_temp['montant_htc'] += $htPrice * $produit->quantite; $produitsReferenceArray[] = $produit->reference; }; $produitsReferenceArray = array_unique($produitsReferenceArray); $produitsReferenceAsString = implode("-", $produitsReferenceArray); $facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva'])/100; $facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc']; $facture_temp['produit_references'] = $produitsReferenceAsString; array_push($data_factures, $facture_temp); }; $data_temp = array(); foreach ($data_factures as $key => $facture) { $datesplit = explode('-', $facture['date_facture']); if($data_temp[strval($datesplit[0])][strval($datesplit[1])]==NULL) { $data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0=>$facture); } else { array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])], $facture); } } foreach ($data_temp as $key_annee => $annee) { foreach ($annee as $key_mois => $mois) { $pdf = new FPDF(); $pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $date_facture = $mois[0]['date_facture']; $date_temp = date("t-m-Y", strtotime($date_facture)); $formatter = new IntlDateFormatter('fr_FR', IntlDateFormatter::LONG, IntlDateFormatter::NONE); $date_formated = $formatter->format(DateTime::createFromFormat('d-m-Y', $date_temp)); try { $storage->newFolder(html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/'); } catch(\OCP\Files\NotPermittedException $e) { } $pdf->AddPage(); $pdf->SetLineWidth(0.2); // on sup les 2 cm en bas $pdf->SetAutoPagebreak(False); $pdf->SetMargins(0,0,0); // logo : 80 de largeur et 55 de hauteur if($doesLogoExist){ $pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); } //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','',size: 11); $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, utf8_decode($clientGroupFacturation["group_facturation_name"])); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $clientAdress = $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(FileExportHelpers::FormatTextForExport($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"])))); // date facture $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, "le ".utf8_decode($date_formated)); // observations $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, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 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."); $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, 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", 140, 175, 45,30); } $y0 = 260; $pageWidth = $pdf->GetPageWidth(); //Positionnement en bas et tout centrer $pdf->SetFont('ComicSans','',6); $pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 8 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 12 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); /*$pdf->SetXY( 1, $y0 + 16 ); $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $num_page = 1; $nb_page = ceil(sizeof($mois) / 26); $index_facture_position = 0; $max_nb_toget = (sizeof($mois)<=26)?sizeof($mois):26; $montant_ht_total = 0; $montant_tva_total = 0; $montant_ttc_total = 0; while ($num_page <= $nb_page) { $pdf->AddPage(); // on sup les 2 cm en bas $pdf->SetAutoPagebreak(False); $pdf->SetMargins(0,0,10); if($doesLogoExist){ $pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); } //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); // n° page en haute à droite if($nb_page>1){ $pdf->SetXY( 120, 5 ); $pdf->SetFont( "ComicSans", "B", 9 ); $pdf->Cell( 160, 8, $num_page . '/' . $nb_page, 0, 0, 'C'); } // adresse du facture $clientInfoXAxis = 125; $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->SetMargins(0,0,10); $pdf->MultiCell( 0, 7, trim(FileExportHelpers::FormatTextForExport($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"])))); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, 'Siret: ' . FileExportHelpers::FormatTextForExport($clientGroupFacturation["siret_number"])); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, 'Email: ' . utf8_decode(html_entity_decode($clientGroupFacturation["email"])),0,1); // *********************** // le cadre des articles // *********************** // cadre avec 18 lignes max ! et 118 de hauteur --> 80 + 118 = 198 pour les traits verticaux $pdf->SetLineWidth(0.2); $pdf->Rect(5, 80, 200, 153, "D"); // cadre titre des colonnes $pdf->SetFillColor(255); $pdf->Line(5, 90, 205, 90); // les traits verticaux colonnes $pdf->Line(145, 80, 145, 233); $pdf->Line(163, 80, 163, 233); if($num_page == $nb_page){ $pdf->Line(183, 80, 183, 240); $pdf->Line(25, 80, 25, 225); $pdf->Line(46, 80, 46, 225); $pdf->Line(99, 80, 99, 225); } else{ $pdf->Line(183, 80, 183, 233); $pdf->Line(25, 80, 25, 233); $pdf->Line(46, 80, 46, 233); $pdf->Line(99, 80, 99, 233); } // titre colonne $pdf->SetXY( 1, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 30, 8, FileExportHelpers::FormatTextForExport("N°"), 0, 0, 'C'); $pdf->SetXY( 26, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 18, 8, "Date", 0, 0, 'C'); $pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C'); $pdf->SetXY( 100, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 45, 8, FileExportHelpers::FormatTextForExport("Articles"), 0, 0, 'C'); $pdf->SetXY( 147, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 13, 8, "H.T.", 0, 0, 'C'); $pdf->SetXY( 168, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 10, 8, "TVA 20%", 0, 0, 'C'); $pdf->SetXY( 183, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 22, 8, "T.T.C", 0, 0, 'C'); // (new DateTime($facture['date_soin']))->format('d-M') $formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE); // Set the pattern for the formatter to "d-MMMM" to display the day and month name in French $formatter_ds->setPattern('dd-MMM'); //recuperation des factures $y_facture = 90; $init_index = $index_facture_position; for ($index_facture_position; $index_facture_position < ($init_index + $max_nb_toget) ; $index_facture_position++) { $date_soin_temp = new DateTime($mois[$index_facture_position]['date_soin']); $defuntNameText = $mois[$index_facture_position]['defunt']; $defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText); $defuntNameTextIsMultiline = $defuntNameTextWidth >= 50; $pdf->SetXY( 6, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, $mois[$index_facture_position]['num'], 0, 0, ''); $pdf->SetXY( 29, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, ''); $pdf->SetXY( 47, $y_facture ); $pdf->SetFont('ComicSans','',8); if($defuntNameTextIsMultiline){ $pdf->MultiCell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0,'L'); } else{ $pdf->Cell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0); } $pdf->SetXY( 100, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 38, 5, FileExportHelpers::FormatTextForExport($mois[$index_facture_position]['produit_references']), 0, 0, ''); $pdf->SetXY( 147, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 13, 5, number_format($mois[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY( 168, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 10, 5, number_format($mois[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY( 183, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 22, 5, number_format($mois[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C'); $montant_ht_total = $montant_ht_total+$mois[$index_facture_position]['montant_htc']; $montant_tva_total = $montant_tva_total+$mois[$index_facture_position]['montant_tva']; $montant_ttc_total = $montant_ttc_total+$mois[$index_facture_position]['montant_ttc']; if($defuntNameTextIsMultiline){ $y_facture=$y_facture+5; } $y_facture=$y_facture+5; } $nb_facture_chargee = $index_facture_position+1; $reste_a_chargee = sizeof($mois) - $nb_facture_chargee; $max_nb_toget = ($reste_a_chargee <= 26) ? $reste_a_chargee+1 : 26; // si derniere page alors afficher cadre des TVA if ($num_page == $nb_page) { $pdf->Line(5, 225, 205, 225); $pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 5, 225 ); $pdf->Cell( 140, 8, 'TOTAL', 0, 0, 'C'); $pdf->SetFont('ComicSans','',8); $pdf->SetXY( 147, 225 ); $pdf->Cell( 13, 8, number_format($montant_ht_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans','',8); $pdf->SetXY( 168, 225 ); $pdf->Cell( 10, 8, number_format($montant_tva_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans','',8); $pdf->SetXY( 183, 225 ); $pdf->Cell( 22, 8, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 147, 233 ); $pdf->Cell( 30, 6.5, 'TOTAL TTC', 0, 0, 'C'); $pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 183, 233 ); $pdf->Cell( 22, 6.5, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C', true); $pdf->Line(145, 233, 145, 240); $pdf->Line(183, 233, 183, 240); $pdf->Line(183, 233, 205, 233); $pdf->Line(205, 233, 205, 240); $pdf->Line(145, 240, 205, 240); } $y1 = 245; $pdf->SetFillColor(255); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('ComicSans','',9); $pdf->SetXY( 10, $y1 ); $pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Loi N° 92-442 du 31 décembre 1992: La présente facture est payable en comptant a réception."), 0, 0, 'L'); $pdf->SetXY( 10, $y1 + 4 ); $pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Indemnité forfaitaire pour frais de recouvrement due en cas de retard de paiement: 40").chr(128), 0, 0, 'L'); $pdf->SetXY( 10, $y1 + 8 ); $pdf->Multicell( $pdf->GetPageWidth()-20, 4, utf8_decode("Toute somme non payée dans les trente jours est susceptible de porter intérets à un taux égal à une fois et demi le taux de l'intéret légal."), 0, 0, 'L'); // ************************** // pied de page // ************************** $pdf->SetFont('ComicSans','',6); $pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 8 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 12 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); /*$pdf->SetXY( 1, $y0 + 16 ); $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $num_page++; } $ff_pdf = html_entity_decode( $defaultConfig[0]->path). '/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '. strtoupper( FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]) ). '/GROUPE_'.$clientGroupFacturation["group_facturation_name"].'_RECAP_FACTURE_'.strtoupper( FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]) ).'_'.$key_annee.'.pdf'; $storage->newFile($ff_pdf); $pdfContent = $pdf->Output('','S'); $file_pdf = $storage->get($ff_pdf); $file_pdf->putContent($pdfContent); } } } private function generateInvoiceRecapPerClient($clientId,$date,$idNextcloud){ $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"]; $configurationAddressCity = $configurationAddresses["city"]; $factures = json_decode($this->gestionBdd->getClientFacturesByClientIdAndDate( clientId: $clientId, date: $date )); $factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; }); foreach ($factures as $key => $facture) { $facture_temp = array( 'num' => $facture->num, 'id_client' => $facture->id_client, 'client' => $facture->entreprise, 'adresse_client' => $facture->adresse_client, 'mail_client' => $facture->mail_client, 'adresse_devis' => $facture->lieu, 'nom_client' => html_entity_decode($facture->nom), 'prenoms_client' => html_entity_decode($facture->prenom), 'numero_commande' => $facture->numero_commande, 'date_soin' => $facture->date_soin, 'date' => $facture->date, 'date_facture' => $facture->date_paiement, 'defunt' => $facture->nom_defunt, 'montant_htc' => 0, 'tva' => $defaultConfig[0]->tva_default, 'montant_tva' => 0, 'montant_ttc' => 0, "group_id" => $facture->group_id, "group_name" => $facture->group_name, "group_address" => $facture->group_address, "group_email" => $facture->group_email, "group_city" => $facture->group_city, "group_postal_code" => $facture->group_postal_code, "group_siret_number" => $facture->group_siret_number, "code_comptable" => $facture->code_comptable ?? '-', "client_siret" => $facture->client_siret ); $produits = json_decode($this->gestionBdd->getListProduit($facture->id_devis,$idNextcloud)); $produitsReferenceArray = []; foreach ($produits as $key => $produit) { $htPrice = $produit->prix_unitaire; if($facture->fk_client_group_id != null){ $price = $this->gestionBdd->getProductPriceByClientGroupId($facture->fk_client_group_id,$produit->id); if($price != null){ $htPrice = $price; } } $facture_temp['montant_htc'] += $htPrice * $produit->quantite; $produitsReferenceArray[] = $produit->reference; }; $produitsReferenceArray = array_unique($produitsReferenceArray); $produitsReferenceAsString = implode("-", $produitsReferenceArray); $facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva'])/100; $facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc']; $facture_temp['produit_references'] = $produitsReferenceAsString; array_push($data_factures, $facture_temp); }; $data_temp = array(); foreach ($data_factures as $key => $facture) { $datesplit = explode('-', $facture['date_facture']); if($data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']]==NULL) { $data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']] = array(0=>$facture); } else { array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']], $facture); } } foreach ($data_temp as $key_annee => $annee) { foreach ($annee as $key_mois => $mois) { foreach ($mois as $key_client => $client) { $pdf = new FPDF(); $pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $current_client = ''; $clientHeaderLabel = ''; $clientAddress = ''; $clientCity = ''; $tvaIntraCommuValue = ''; $clientMail = ''; $date_facture = ''; foreach ($client as $key => $facture) { $current_client = $facture['nom_client']; $clientHeaderLabel = $current_client; $date_facture = $facture['date_facture']; $isClientInsideGroup = $facture["group_id"] != null; if($isClientInsideGroup){ $clientHeaderLabel = $facture["group_name"]; $clientAddress = $facture["group_address"]; $clientCity = $facture["group_postal_code"]. " ".$facture["group_city"]; $tvaIntraCommuValue = $facture["group_siret_number"]; $clientMail = $facture["group_email"]; } else{ $clientAddresses = FileExportHelpers::GetAddressAndCityFromAddress($facture['adresse_client']); $clientAddress = $clientAddresses['address']; $clientCity = $clientAddresses['city']; $tvaIntraCommuValue = $facture["client_siret"]; $clientMail = $facture['mail_client']; } break; } $date_temp = date("t-m-Y", strtotime($date_facture)); $formatter = new IntlDateFormatter('fr_FR', IntlDateFormatter::LONG, IntlDateFormatter::NONE); $date_formated = $formatter->format(DateTime::createFromFormat('d-m-Y', $date_temp)); try { $storage->newFolder(html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/'); } catch(\OCP\Files\NotPermittedException $e) { } $pdf->AddPage(); $pdf->SetLineWidth(0.2); // on sup les 2 cm en bas $pdf->SetAutoPagebreak(False); $pdf->SetMargins(0,0,10); // logo : 80 de largeur et 55 de hauteur if($doesLogoExist){ $pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); } //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','',size: 11); $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, utf8_decode($clientHeaderLabel)); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $clientAdressWidth = $pdf->GetStringWidth($clientAddress); $maxWidth = $pdf->GetPageWidth(); $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; $pdf->SetMargins(0,0,10); $pdf->MultiCell( 0, 7, trim(FileExportHelpers::FormatTextForExport($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)))); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); // date facture $pdf->Cell( 0, 7, "le ".utf8_decode($date_formated)); // observations $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, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 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."); $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, 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", 140, 175, 45,30); } $y0 = 260; $pageWidth = $pdf->GetPageWidth(); //Positionnement en bas et tout centrer $pdf->SetFont('ComicSans','',7); $pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->mentions_default)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 8 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 12 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 16 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); /*$pdf->SetXY( 1, $y0 + 16 ); $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $num_page = 1; $nb_page = ceil(sizeof($client) / 26); $index_facture_position = 0; $max_nb_toget = (sizeof($client)<=26)?sizeof($client):26; $montant_ht_total = 0; $montant_tva_total = 0; $montant_ttc_total = 0; while ($num_page <= $nb_page) { $pdf->AddPage(); // on sup les 2 cm en bas $pdf->SetAutoPagebreak(False); $pdf->SetMargins(0,0,10); if($doesLogoExist){ $pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); } //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); // n° page en haute à droite if($nb_page>1){ $pdf->SetXY( 120, 5 ); $pdf->SetFont( "ComicSans", "B", 9 ); $pdf->Cell( 160, 8, $num_page . '/' . $nb_page, 0, 0, 'C'); } // adresse du facture $clientInfoXAxis = 125; $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->SetMargins(0,0,10); $pdf->MultiCell( 0, 7, trim(FileExportHelpers::FormatTextForExport($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)))); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, 'Siret: ' . FileExportHelpers::FormatTextForExport($tvaIntraCommuValue)); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, 'Email: ' . utf8_decode(html_entity_decode($clientMail)),0,1); // *********************** // le cadre des articles // *********************** // cadre avec 18 lignes max ! et 118 de hauteur --> 80 + 118 = 198 pour les traits verticaux $pdf->SetFillColor(255); $pdf->Rect(5, 80, 200, 153, "DF"); // cadre titre des colonnes $pdf->Line(5, 90, 205, 90); // les traits verticaux colonnes $pdf->Line(145, 80, 145, 233); $pdf->Line(163, 80, 163, 233); if($num_page == $nb_page){ $pdf->Line(183, 80, 183, 240); $pdf->Line(25, 80, 25, 225); $pdf->Line(46, 80, 46, 225); $pdf->Line(99, 80, 99, 225); } else{ $pdf->Line(183, 80, 183, 233); $pdf->Line(25, 80, 25, 233); $pdf->Line(46, 80, 46, 233); $pdf->Line(99, 80, 99, 233); } // titre colonne $pdf->SetXY( 1, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 30, 8, FileExportHelpers::FormatTextForExport("N°"), 0, 0, 'C'); $pdf->SetXY( 26, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 18, 8, "Date", 0, 0, 'C'); $pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C'); $pdf->SetXY( 100, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 45, 8, "Articles", 0, 0, 'C'); $pdf->SetXY( 147, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 13, 8, "H.T.", 0, 0, 'C'); $pdf->SetXY( 168, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 10, 8, "TVA 20%", 0, 0, 'C'); $pdf->SetXY( 183, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 22, 8, "T.T.C", 0, 0, 'C'); // (new DateTime($facture['date_soin']))->format('d-M') $formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE); // Set the pattern for the formatter to "d-MMMM" to display the day and month name in French $formatter_ds->setPattern('dd-MMM'); //recuperation des factures $y_facture = 90; $init_index = $index_facture_position; for ($index_facture_position; $index_facture_position < ($init_index + $max_nb_toget) ; $index_facture_position++) { $date_soin_temp = new DateTime($client[$index_facture_position]['date_soin']); $defuntNameText = $client[$index_facture_position]['defunt']; $defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText); $defuntNameTextIsMultiline = $defuntNameTextWidth >= 50; $pdf->SetXY( 6, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, $client[$index_facture_position]['num'], 0, 0, ''); $pdf->SetXY( 29, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 18, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, ''); $pdf->SetXY( 47, $y_facture ); $pdf->SetFont('ComicSans','',8); if($defuntNameTextIsMultiline){ $pdf->MultiCell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText)); } else{ $pdf->Cell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0); } $pdf->SetXY( 100, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, ''); $pdf->SetXY( 147, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 13, 5, number_format($client[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY( 168, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 10, 5, number_format($client[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY( 183, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 22, 5, number_format($client[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C'); $montant_ht_total = $montant_ht_total+$client[$index_facture_position]['montant_htc']; $montant_tva_total = $montant_tva_total+$client[$index_facture_position]['montant_tva']; $montant_ttc_total = $montant_ttc_total+$client[$index_facture_position]['montant_ttc']; if($defuntNameTextIsMultiline){ $y_facture=$y_facture+5; } $y_facture=$y_facture+5; } $nb_facture_chargee = $index_facture_position+1; $reste_a_chargee = sizeof($client) - $nb_facture_chargee; $max_nb_toget = ($reste_a_chargee <= 26) ? $reste_a_chargee+1 : 26; // si derniere page alors afficher cadre des TVA if ($num_page == $nb_page) { $pdf->Line(5, 225, 205, 225); $pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 5, 225 ); $pdf->Cell( 140, 8, 'TOTAL', 0, 0, 'C'); $pdf->SetFont('ComicSans','',8); $pdf->SetXY( 147, 225 ); $pdf->Cell( 13, 8, number_format($montant_ht_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans','',8); $pdf->SetXY( 168, 225 ); $pdf->Cell( 10, 8, number_format($montant_tva_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans','',8); $pdf->SetXY( 183, 225 ); $pdf->Cell( 22, 8, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 147, 233 ); $pdf->Cell( 30, 6.5, 'TOTAL TTC', 0, 0, 'C'); $pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 183, 233 ); $pdf->Cell( 22, 6.5, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C', true); $pdf->Line(145, 233, 145, 240); $pdf->Line(183, 233, 183, 240); $pdf->Line(183, 233, 205, 233); $pdf->Line(205, 233, 205, 240); $pdf->Line(145, 240, 205, 240); } $y1 = 245; $pdf->SetFillColor(255); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('ComicSans','',9); $pdf->SetXY( 10, $y1 );$pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Loi N° 92-442 du 31 décembre 1992: La présente facture est payable en comptant a réception."), 0, 0, 'L'); $pdf->SetXY( 10, $y1 + 4 );$pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Indemnité forfaitaire pour frais de recouvrement due en cas de retard de paiement: 40").chr(128), 0, 0, 'L'); $pdf->SetXY( 10, $y1 + 8 );$pdf->Multicell( $pdf->GetPageWidth()-20, 4, utf8_decode("Toute somme non payée dans les trente jours est susceptible de porter intérets à un taux égal à une fois et demi le taux de l'intéret légal."), 0, 0, 'L'); // ************************** // pied de page // ************************** $pdf->SetFont('ComicSans','',7); $pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->mentions_default)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 8 );$pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 12 );$pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->SetXY( 1, $y0 + 16 );$pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); /*$pdf->SetXY( 1, $y0 + 16 ); $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $num_page++; } $fullPdfPath = html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/'.strtoupper(FileExportHelpers::ConvertSpecialChar($current_client)).'_RECAP_FACTURE_'.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'_'.$key_annee.'.pdf'; $storage->newFile($fullPdfPath); $pdfContent = $pdf->Output('','S'); $file_pdf = $storage->get($fullPdfPath); $file_pdf->putContent($pdfContent); } } } } public function generateInvoiceRecap($filter,$filterType,$date,$idNextcloud){ try { if($filterType == MultipleFactureTypeConstant::GROUP_FILTER_TYPE){ $this->generateInvoiceRecapPerClientGroupFacturation($filter,$date,$idNextcloud); } else{ $this->generateInvoiceRecapPerClient($filter,$date,$idNextcloud); } } catch(\OCP\Files\NotFoundException $e) { } } }