detailsp = new Statistique(); } public function index() { $codeGcAssureur = $this->requete->getParametreFormulaire("codeGcAssureur"); $idPolice = $this->requete->getParametreFormulaire("idPolice"); $debutStat = $this->requete->getParametreDate("debutStat"); $finStat = $this->requete->getParametreDate("finStat"); $Chargement = $this->requete->getParametreFormulaire("Chargement"); $_SESSION['debutStat'] = $debutStat; $_SESSION['finStat'] = $finStat; $p_datedebut = $_SESSION['debutStat']; $p_datefin = $_SESSION['finStat']; $p_garant = $codeGcAssureur; if ($p_garant == "AUC") { $p_garant = null; } $p_id = $idPolice; if ($p_id == "") { $p_id = null; } $idCollege = ""; $p_id_clients = null; $p_id_college = null; $p_code = 'QTM'; $p_taux = '18'; $recapresultattechniquesgarants = $this->detailsp->getrecapresultattechniquesgarants($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin, $p_code); $TOTALmontantnbre_policeG = $TOTALmontantApayerTotalG = $TOTALprimeAnalyseTotalG = $TOTALprimeAnnuelleTotalG = 0; $TOTALrapportSpTotalG = 0.00; $TOTALajustementSpG = 0.00; // Création du PDF et ajout de la première page IMMÉDIATEMENT $pdf = new FPDF_Protection(); $pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES'); $userPassword = ''; $ownerPassword = null; $pdf->SetProtection(['print'], $userPassword, $ownerPassword); $pdf->AliasNbPages(); $pdf->AddPage(); // ← AJOUT CRITIQUE ICI $pdf->SetMargins(10, 10, 10); // Vérifier si des données existent if (empty($recapresultattechniquesgarants)) { $pdf->SetFont('Arial', 'B', 12); $pdf->Cell(0, 10, convertirc(_('Aucune donnée disponible pour la période sélectionnée')), 0, 1, 'C'); $this->outputPDF($pdf); return; } foreach ($recapresultattechniquesgarants as $recapresultattechniquesgarant) { $p_garant = $recapresultattechniquesgarant['codeGcAssureur']; // Vérifier si on dépasse la hauteur de page if ($pdf->GetY() > 250) { $pdf->AddPage(); } $resultattechniques = $this->detailsp->getrecapresultattechniques($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin, $p_code, $Chargement); if ($pdf->PageNo() == 1 || $pdf->GetY() < 30) { $pdf->Image($_SESSION['lienLogo'], 94, 3, 15); $pdf->SetFont('Arial', 'B', 7); $pdf->Cell(0, 5, '', 0, 1, 'L', false); $pdf->SetY(10); $pdf->SetFont('Arial', '', 7); $pdf->Cell(0, 5, convertirc(_('Edition du').': '.heureCouranteLang($_SESSION['lang'])), 0, 1, 'R', false); $pdf->Ln(2); $pdf->SetFont('Arial', 'B', 13); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(0, 8, convertirc(_("RECAPITULATIF DES EMISSIONS PAR COMPAGNIE ET PAR COURTIER")), 1, 0, 'C', true); $pdf->Ln(10); $pdf->SetFont('Arial', 'B', 11); $pdf->SetTextColor(0); $pdf->Ln(8); $pdf->Cell(0, 5, convertirc(_('PERIODE CONSIDEREE').': '.dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang'])), 0, 1, 'C', false); } $pdf->Ln(8); $pdf->SetFont('Arial', 'BUI', 11); $pdf->Cell(35, 8, convertirc(_('COMPAGNIE')), 0, 0, 'L', false); $pdf->SetFont('Arial', 'BI', 11); $pdf->Cell(0, 8, convertirc(': '.$recapresultattechniquesgarant['GARANT']), 0, 1, 'L', false); $pdf->Ln(5); $hl = 7; $pdf->SetFont('Arial', 'B', 8); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(73, $hl, convertirc(_('Courtier')), 1, 0, 'C', true); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(15, $hl, convertirc(_("Nbr Police")), 1, 0, 'C', true); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(53, $hl, convertirc(_("Sinistres")), 1, 0, 'C', true); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(40, $hl, convertirc(_("Primes totales annuelles")), 1, 0, 'C', true); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(12, $hl, convertirc(_("R/SP (%)")), 1, 1, 'C', true); $hl = 5; $pdf->SetFont('Arial', 'B', 8); $pdf->Cell(88, $hl, convertirc('-'), 1, 0, 'C', false); $pdf->Cell(17, $hl, convertirc(_("Tardifs")), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(_("Courant")), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(_("Total")), 1, 0, 'C', false); $pdf->Cell(20, $hl, convertirc(_("Période")), 1, 0, 'C', false); $pdf->Cell(20, $hl, convertirc(_("Totales")), 1, 0, 'C', false); $pdf->Cell(12, $hl, convertirc("-"), 1, 1, 'C', false); $pdf->SetFont('Arial', '', 8); $TOTALmontantnbre_police = $TOTALmontantApayerTotal = $TOTALprimeAnalyseTotal = $TOTALprimeAnnuelleTotal = 0; $TOTALrapportSpTotal = 0.00; $TOTALajustementSp = 0.00; foreach ($resultattechniques as $resultattechnique) { // Vérifier l'espace avant d'ajouter une nouvelle ligne if ($pdf->GetY() > 270) { $pdf->AddPage(); // Réafficher les en-têtes de colonnes sur la nouvelle page $this->drawTableHeaders($pdf); } $hl = 7; $pdf->SetFont('Arial', '', 7); $pdf->Cell(73, $hl, convertirc(_($resultattechnique['courtier'])), 1, 0, 'L', false); $pdf->Cell(15, $hl, convertirc(_($resultattechnique['nbre_police'])), 1, 0, 'R', false); $pdf->Cell(17, $hl, convertirc(''), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(format_N($resultattechnique['sinistresAnalyse'])), 1, 0, 'R', false); $pdf->Cell(18, $hl, convertirc(format_N($resultattechnique['sinistresAnalyse'])), 1, 0, 'R', false); $pdf->Cell(20, $hl, convertirc(format_N($resultattechnique['primeAnalyseGarant'])), 1, 0, 'R', false); $pdf->Cell(20, $hl, convertirc(format_N($resultattechnique['primeAnnuelle'])), 1, 0, 'R', false); $pdf->Cell(12, $hl, convertirc(_($resultattechnique['rapportApp'])), 1, 1, 'C', false); $TOTALmontantnbre_police = $TOTALmontantnbre_police + $resultattechnique['nbre_police']; $TOTALmontantApayerTotal = $TOTALmontantApayerTotal + $resultattechnique['sinistresAnalyse']; $TOTALprimeAnalyseTotal = $TOTALprimeAnalyseTotal + $resultattechnique['primeAnalyseGarant']; $TOTALprimeAnnuelleTotal = $TOTALprimeAnnuelleTotal + $resultattechnique['primeAnnuelle']; $TOTALajustementSp = $TOTALajustementSp + $resultattechnique['ajustementSp']; } $TOTALrapportSpTotal = $resultattechnique['rspAnalyse']; $pdf->SetFont('Arial', 'B', 8); $pdf->SetTextColor(75, 0, 130); $pdf->Cell(73, $hl, convertirc(_('TOTAL').' '.$resultattechnique['codeGcAssureur']), 1, 0, 'L', false); $pdf->Cell(15, $hl, convertirc(_($TOTALmontantnbre_police)), 1, 0, 'R', false); $pdf->Cell(17, $hl, convertirc(''), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(format_N($resultattechnique['sinistresAnnuelle'])), 1, 0, 'R', false); $pdf->Cell(18, $hl, convertirc(format_N($resultattechnique['sinistresAnnuelle'])), 1, 0, 'R', false); $pdf->Cell(20, $hl, convertirc(format_N($TOTALprimeAnalyseTotal)), 1, 0, 'R', false); $pdf->Cell(20, $hl, convertirc(format_N($TOTALprimeAnnuelleTotal)), 1, 0, 'R', false); $pdf->Cell(12, $hl, convertirc($TOTALrapportSpTotal), 1, 1, 'C', false); $TOTALmontantnbre_policeG = $TOTALmontantnbre_policeG + $TOTALmontantnbre_police; $TOTALmontantApayerTotalG = $TOTALmontantApayerTotalG + $resultattechnique['sinistresAnnuelle']; $TOTALprimeAnalyseTotalG = $TOTALprimeAnalyseTotalG + $TOTALprimeAnalyseTotal; $TOTALprimeAnnuelleTotalG = $TOTALprimeAnnuelleTotalG + $TOTALprimeAnnuelleTotal; $TOTALajustementSpG = $TOTALajustementSpG + $TOTALajustementSp; $pdf->SetTextColor(0, 0, 0); $pdf->Ln(5); $TOTALrapportSpTotalG = $resultattechnique['rspAnalyse']; } // Total général if ($pdf->GetY() > 270) { $pdf->AddPage(); } $hl = 4; $pdf->SetFont('Arial', 'B', 8); $pdf->SetTextColor(255, 0, 0); $pdf->Cell(73, $hl, convertirc(_('TOTAL GENERAL')), 1, 0, 'L', false); $pdf->Cell(15, $hl, convertirc(_($TOTALmontantnbre_policeG)), 1, 0, 'C', false); $pdf->Cell(17, $hl, convertirc(''), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(format_N($TOTALmontantApayerTotalG)), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(format_N($TOTALmontantApayerTotalG)), 1, 0, 'C', false); $pdf->Cell(20, $hl, convertirc(format_N($TOTALprimeAnalyseTotalG)), 1, 0, 'C', false); $pdf->Cell(20, $hl, convertirc(format_N($TOTALprimeAnnuelleTotalG)), 1, 0, 'C', false); $pdf->Cell(12, $hl, convertirc($TOTALrapportSpTotalG), 1, 1, 'C', false); $pdf->SetFont('Arial', '', 8); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(8); $pdf->Cell(45, $hl, convertirc(_("# R/SP (%). = Rapport Sinitre Total / Prime Totale période")), 0, 0, 'L', false); $this->outputPDF($pdf); } /** * Fonction pour dessiner les en-têtes du tableau (réutilisable sur les nouvelles pages) */ private function drawTableHeaders($pdf) { $hl = 7; $pdf->SetFont('Arial', 'B', 8); $pdf->SetFillColor(144, 238, 144); $pdf->Cell(73, $hl, convertirc(_('Courtier')), 1, 0, 'C', true); $pdf->Cell(15, $hl, convertirc(_("Nbr Police")), 1, 0, 'C', true); $pdf->Cell(53, $hl, convertirc(_("Sinistres")), 1, 0, 'C', true); $pdf->Cell(40, $hl, convertirc(_("Primes totales annuelles")), 1, 0, 'C', true); $pdf->Cell(12, $hl, convertirc(_("R/SP (%)")), 1, 1, 'C', true); $hl = 5; $pdf->SetFont('Arial', 'B', 8); $pdf->Cell(88, $hl, convertirc('-'), 1, 0, 'C', false); $pdf->Cell(17, $hl, convertirc(_("Tardifs")), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(_("Courant")), 1, 0, 'C', false); $pdf->Cell(18, $hl, convertirc(_("Total")), 1, 0, 'C', false); $pdf->Cell(20, $hl, convertirc(_("Période")), 1, 0, 'C', false); $pdf->Cell(20, $hl, convertirc(_("Totales")), 1, 0, 'C', false); $pdf->Cell(12, $hl, convertirc("-"), 1, 1, 'C', false); $pdf->SetFont('Arial', '', 8); } /** * Fonction pour générer et afficher le PDF */ private function outputPDF($pdf) { $fichier = "Temp/TMP_CUMUL_FT22_RECAPITULATIF_DES_EMISSIONS_PAR_COMPAGNIE"."_".uniqid().".pdf"; $pdf->Output($fichier, "F"); $t_html = '
'; $t_html .= ''._("TELECHARGER FT22_RECAPITULATIF_DES_EMISSIONS_PAR_COMPAGNIE").''; $t_html .= '
'; echo $t_html; } }