377 lines
17 KiB
PHP
Executable File
377 lines
17 KiB
PHP
Executable File
<?php
|
|
require_once 'Framework/Controleurrequete.php';
|
|
require_once 'Modele/Statistique.php';
|
|
require_once $_SESSION['dossierSociete'].'/Tarifs/Modele/Police_sodciete.php';
|
|
|
|
// Créer une classe PDF personnalisée qui étend FPDF
|
|
class MonPDF extends FPDF_Protection {
|
|
private $titreEnTete = 'FICHE TECHNIQUE No 1';
|
|
|
|
// Fonction d'en-tête pour chaque page
|
|
function Header() {
|
|
$this->SetMargins(10, 10, 10);
|
|
|
|
$imagePath = $_SESSION['lienLogo'];
|
|
$imageWidth = 15;
|
|
$this->Image($imagePath, 94, 3, $imageWidth);
|
|
|
|
$this->SetFont('Arial', 'B', 7);
|
|
$this->Cell(0, 5, convertirc(_($this->titreEnTete)), 0, 1, 'L', false);
|
|
|
|
$this->SetY(10);
|
|
$this->SetFont('Arial', '', 7);
|
|
$this->Cell(0, 5, convertirc(_('Edition du').': '.heureCouranteLang($_SESSION['lang'])), 0, 1, 'R', false);
|
|
|
|
$this->Ln(12);
|
|
}
|
|
|
|
// Fonction de pied de page avec numéro centré
|
|
function Footer() {
|
|
// Positionnement à 1.5 cm du bas
|
|
$this->SetY(-15);
|
|
// Police Arial italique 8
|
|
$this->SetFont('Arial', 'I', 9);
|
|
$this->SetTextColor(100, 100, 100);
|
|
// Numéro de page centré - utilisation de {nb} qui est géré automatiquement par FPDF
|
|
$this->Cell(0, 10, convertirc(_('Page')) . ' ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
|
|
$this->SetTextColor(0);
|
|
}
|
|
|
|
// Méthode pour changer le titre de l'en-tête
|
|
public function setTitreEnTete($titre) {
|
|
$this->titreEnTete = $titre;
|
|
}
|
|
}
|
|
|
|
class ControleurAjaxstatsmaladiefichetechniqueunpdf extends Controleur
|
|
{
|
|
private $detailsp;
|
|
private $police_societe;
|
|
|
|
public function __construct() {
|
|
$this->detailsp = new Statistique();
|
|
$this->police_societe = new Police_sodciete();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// Récupération des paramètres
|
|
$idPolice = $this->requete->getParametreFormulaire("idPolice");
|
|
$idCollege = $this->requete->getParametreFormulaire("idCollege");
|
|
$codeGcAssureur = $this->requete->getParametreFormulaire("codeGcAssureur");
|
|
$Chargement = $this->requete->getParametreFormulaire("Chargement");
|
|
$debutStat = $this->requete->getParametreDate("debutStat");
|
|
$finStat = $this->requete->getParametreDate("finStat");
|
|
$chargeravantapres = $this->requete->getParametreFormulaire("chargeravantapres");
|
|
|
|
// Normalisation des paramètres
|
|
$idCollege = ($idCollege == "") ? null : $idCollege;
|
|
$idPolice = ($idPolice == "") ? null : $idPolice;
|
|
|
|
$_SESSION['debutStat'] = $debutStat;
|
|
$_SESSION['finStat'] = $finStat;
|
|
|
|
// Vérification 1: Données d'entête
|
|
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
|
|
|
|
if (empty($entete)) {
|
|
echo '<div class="alert alert-warning">' . _("Aucune donnée disponible pour les critères de filtrage") . '</div>';
|
|
return;
|
|
}
|
|
|
|
// Préparation des paramètres pour les requêtes suivantes
|
|
$p_datedebut = $_SESSION['debutStat'];
|
|
$p_datefin = $_SESSION['finStat'];
|
|
$p_garant = $codeGcAssureur;
|
|
$p_id = $entete['idPolice'];
|
|
$p_id_college = null;
|
|
$p_id_clients = null;
|
|
|
|
// Vérification 2: Dates valides
|
|
if ($debutStat > $finStat) {
|
|
echo '<div class="alert alert-warning">' . _("La date de début doit être antérieure à la date de fin") . '</div>';
|
|
return;
|
|
}
|
|
|
|
$infosDuGarant = $this->police_societe->getInfosGarant($codeGcAssureur);
|
|
|
|
// Vérification 3: Données des statuts
|
|
$statutsfts = $this->detailsp->donneelementaire_rp($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin);
|
|
|
|
if (empty($statutsfts)) {
|
|
echo '<div class="alert alert-warning">' . _("Aucune donnée de statut disponible") . '</div>';
|
|
return;
|
|
}
|
|
|
|
// Vérification 4: Données primes/sinistres
|
|
if ($infosDuGarant['typeGarant'] == '1') {
|
|
$primeSinistrefts = $this->detailsp->donneelementaire_rp2_1($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin, $Chargement, $chargeravantapres);
|
|
} else {
|
|
$primeSinistrefts = $this->detailsp->donneelementaire_rp2_2($p_garant, $p_id, $p_datedebut, $p_datefin, $Chargement);
|
|
}
|
|
|
|
|
|
if (empty($primeSinistrefts)) {
|
|
echo '<div class="alert alert-warning">' . _("Aucune donnée de prime/sinistre disponible") . '</div>';
|
|
return;
|
|
}
|
|
|
|
|
|
// Vérification 5: Nombre total de pages avant création PDF
|
|
$statuts = $this->detailsp->listestatutbeneficiaire($idPolice, $debutStat, $finStat);
|
|
|
|
// Estimation du nombre de pages nécessaires
|
|
$nombreLignesStatuts = count($statutsfts);
|
|
$nombreLignesPrimeSinistre = count($primeSinistrefts);
|
|
$pagesNecessaires = ceil(($nombreLignesStatuts + $nombreLignesPrimeSinistre) / 20) + 2; // +2 pour les pages d'entête
|
|
|
|
if ($pagesNecessaires > 50) { // Limite arbitraire de 50 pages
|
|
echo '<div class="alert alert-warning">' . _("Trop de données à afficher") ." (". $pagesNecessaires .") ". _("pages nécessaires)") . '</div>';
|
|
return;
|
|
}
|
|
|
|
// Création du PDF
|
|
$pdf = new MonPDF();
|
|
// $pdf = new FPDF_Protection();
|
|
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
|
|
$userPassword = '';
|
|
$ownerPassword = null;
|
|
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
|
|
|
|
$pdf->AliasNbPages(); // Active la numérotation des pages
|
|
|
|
// Ajouter la première page
|
|
$pdf->AddPage();
|
|
$pdf->SetMargins(10, 10, 10);
|
|
|
|
// Page de couverture avec images
|
|
$imagePath = $_SESSION['lienLogo'];
|
|
$imageWidth = 45;
|
|
$pageWidth = $pdf->getPageWidth();
|
|
$xPosition = ($pageWidth - $imageWidth) / 2;
|
|
|
|
$pdf->Image($imagePath, $xPosition, 15, $imageWidth);
|
|
$pdf->Image($_SESSION['dossierSociete'].'/Tarifs/Img/libellestatistique.jpg', 55, 90, 110);
|
|
$pdf->Image($_SESSION['dossierSociete'].'/Tarifs/Img/cadredetailsstats.jpg', 5, 130, 200);
|
|
|
|
if ($p_id != null) {
|
|
$pdf->SetY(145);
|
|
$pdf->SetFont('Times', 'BUI', 18);
|
|
$pdf->Cell(70, 5, convertirc(_('Garant').' '), 0, 0, 'R', false);
|
|
$pdf->SetFont('Times', 'BI', 14);
|
|
$pdf->MultiCell(115, 5, convertirc(_($entete['garant'])), 0, 'L');
|
|
$pdf->Ln(4);
|
|
|
|
// Vérification avant de continuer l'ajout de contenu
|
|
if ($pdf->GetY() > 250) {
|
|
$pdf->AddPage();
|
|
$pdf->setTitreEnTete('FICHE TECHNIQUE No 1 - SUITE');
|
|
}
|
|
|
|
$pdf->SetFont('Times', 'BUI', 18);
|
|
$pdf->Cell(70, 5, convertirc(_('Souscripteur').' '), 0, 0, 'R', false);
|
|
$pdf->SetFont('Times', 'BI', 14);
|
|
$pdf->MultiCell(115, 5, convertirc(_($entete['souscripteur'])), 0, 'L');
|
|
$pdf->Ln(5);
|
|
|
|
$pdf->SetFont('Times', 'BUI', 18);
|
|
$pdf->Cell(70, 5, convertirc(_('Police').' '), 0, 0, 'R', false);
|
|
$pdf->SetFont('Times', 'BI', 14);
|
|
$pdf->MultiCell(115, 5, convertirc(_($entete['libellePolice'])), 0, 'L');
|
|
$pdf->Cell(0, 5, '', 0, 1, 'L', false);
|
|
$pdf->Ln(30);
|
|
} else {
|
|
$pdf->SetY(158);
|
|
$pdf->SetFont('Times', 'BUI', 18);
|
|
$pdf->Cell(50, 5, convertirc(_('Garant').' '), 0, 0, 'R', false);
|
|
$pdf->SetFont('Times', 'BI', 14);
|
|
$pdf->MultiCell(115, 5, convertirc(_($infosDuGarant['libelle'])), 0, 'L');
|
|
$pdf->Ln(40);
|
|
}
|
|
|
|
$pdf->SetFont('Times', 'BI', 12);
|
|
$pdf->Cell(0, 6, convertirc(_('PERIODE CONSIDEREE').' : '.dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang'])), 0, 1, 'C', false);
|
|
$pdf->SetFont('Arial', '', 7);
|
|
$pdf->Cell(0, 5, (''), 0, 1, 'R', false);
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
// Nouvelle page pour le contenu principal
|
|
$pdf->AddPage();
|
|
$pdf->setTitreEnTete('FICHE TECHNIQUE No 1');
|
|
|
|
$pdf->SetMargins(10, 10, 10);
|
|
$pdf->SetFont('Arial', 'B', 13);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(0, 8, convertirc(_("DONNEES ELEMENTAIRES")), 1, 0, 'C', true);
|
|
|
|
$pdf->Ln(10);
|
|
$pdf->SetFont('Arial', 'B', 11);
|
|
$pdf->SetTextColor(0);
|
|
$pdf->Ln(8);
|
|
$pdf->Cell(0, 6, convertirc(_('PERIODE COMPTABLE CONSIDEREE').': '.dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang'])), 0, 1, 'C', false);
|
|
|
|
if ($p_id != null) {
|
|
$pdf->Ln(10);
|
|
$pdf->SetFont('Arial', 'BUI', 11);
|
|
$pdf->Cell(35, 8, convertirc(_('GARANT').': '), 0, 0, 'L', false);
|
|
$pdf->SetFont('Arial', 'BI', 11);
|
|
$pdf->Cell(0, 8, convertirc($entete['garant']), 0, 1, 'L', false);
|
|
|
|
// Vérification position Y avant de continuer
|
|
if ($pdf->GetY() > 250) {
|
|
$pdf->AddPage();
|
|
$pdf->setTitreEnTete('FICHE TECHNIQUE No 1 - SUITE');
|
|
}
|
|
|
|
$pdf->SetFont('Arial', 'BUI', 11);
|
|
$pdf->Cell(35, 8, convertirc(_('SOUSCRIPTEUR').': '), 0, 0, 'L', false);
|
|
$pdf->SetFont('Arial', 'BI', 11);
|
|
$pdf->Cell(0, 8, convertirc($entete['souscripteur']), 0, 1, 'L', false);
|
|
|
|
$pdf->SetFont('Arial', 'BUI', 11);
|
|
$pdf->Cell(35, 8, convertirc(_('POLICE No').': '), 0, 0, 'L', false);
|
|
$pdf->SetFont('Arial', 'BI', 11);
|
|
$pdf->Cell(0, 8, convertirc($entete['numeroPolice'].' / '.$entete['libellePolice']), 0, 1, 'L', false);
|
|
|
|
$pdf->SetFont('Arial', 'BUI', 11);
|
|
$pdf->Cell(35, 8, convertirc(_('COURTIER').': '), 0, 0, 'L', false);
|
|
$pdf->SetFont('Arial', 'BI', 11);
|
|
$pdf->Cell(0, 8, convertirc($entete['courtier']), 0, 1, 'L', false);
|
|
} else {
|
|
$pdf->Ln(10);
|
|
$pdf->SetFont('Arial', 'BUI', 11);
|
|
$pdf->Cell(35, 8, convertirc(_('GARANT').': '), 0, 0, 'L', false);
|
|
$pdf->SetFont('Arial', 'BI', 11);
|
|
$pdf->Cell(0, 8, convertirc($p_garant), 0, 1, 'L', false);
|
|
}
|
|
|
|
$pdf->SetFont('Arial', 'BUI', 11);
|
|
$pdf->Cell(35, 8, convertirc(_('POPULATION').': '), 0, 0, 'L', false);
|
|
$pdf->SetFont('Arial', 'BI', 11);
|
|
$pdf->Cell(0, 8, convertirc(_('cf Tableau ci-dessous').': '), 0, 1, 'L', false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$hl = 6;
|
|
$pdf->SetFont('Arial', 'B', 8);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(37, $hl, convertirc(_('Statut bénéficiaire')), 1, 0, 'C', true);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(51, $hl, convertirc(_("Nombre d'assurés sur la période")), 1, 0, 'C', true);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(51, $hl, convertirc(_("Bénéficiaires traités sur la période")), 1, 0, 'C', true);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(51, $hl, convertirc(_("% Bénéficiaires traités sur la période")), 1, 1, 'C', true);
|
|
|
|
$pdf->SetFont('Arial', '', 9);
|
|
|
|
$total_assure = 0;
|
|
$total_traite = 0;
|
|
$total_taux = 0;
|
|
|
|
foreach ($statutsfts as $statutsf) {
|
|
// Vérification avant d'ajouter une ligne (éviter le débordement de page)
|
|
if ($pdf->GetY() > 250) {
|
|
$pdf->AddPage();
|
|
$pdf->setTitreEnTete('FICHE TECHNIQUE No 1 - SUITE');
|
|
// Réaffichage de l'entête du tableau si nouvelle page
|
|
$pdf->SetFont('Arial', 'B', 8);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(37, $hl, convertirc(_('Statut bénéficiaire')), 1, 0, 'C', true);
|
|
$pdf->Cell(51, $hl, convertirc(_("Nombre d'assurés sur la période")), 1, 0, 'C', true);
|
|
$pdf->Cell(51, $hl, convertirc(_("Bénéficiaires traités sur la période")), 1, 0, 'C', true);
|
|
$pdf->Cell(51, $hl, convertirc(_("% Bénéficiaires traités sur la période")), 1, 1, 'C', true);
|
|
$pdf->SetFont('Arial', '', 9);
|
|
}
|
|
|
|
$pdf->Cell(37, $hl, convertirc($statutsf['libelle']), 1, 0, 'L', false);
|
|
$pdf->Cell(51, $hl, convertirc(format_N($statutsf['Nombre'])), 1, 0, 'C', false);
|
|
$pdf->Cell(51, $hl, convertirc(format_N($statutsf['Nombretraite'])), 1, 0, 'C', false);
|
|
$pdf->Cell(51, $hl, convertirc($statutsf['Taux_EffTraite']." %"), 1, 1, 'C', false);
|
|
|
|
$total_assure += $statutsf['Nombre'];
|
|
$total_traite += $statutsf['Nombretraite'];
|
|
$total_taux += $statutsf['Taux_EffTraite'];
|
|
}
|
|
|
|
$hl = 8;
|
|
$pdf->SetFont('Arial', 'B', 9);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(37, $hl, convertirc(_('TOTAL')), 1, 0, 'C', true);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(51, $hl, convertirc(_(format_N($total_assure))), 1, 0, 'C', true);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(51, $hl, convertirc(_(format_N($total_traite))), 1, 0, 'C', true);
|
|
$pdf->SetFillColor(182,216,242);
|
|
$pdf->Cell(51, $hl, convertirc(_(format_N($total_taux)." %")), 1, 1, 'C', true);
|
|
|
|
$pdf->Ln(15);
|
|
|
|
$tp = 13;
|
|
$ht = 7;
|
|
|
|
foreach ($primeSinistrefts as $primeSinistreft) {
|
|
// Vérification avant d'ajouter du contenu supplémentaire
|
|
if ($pdf->GetY() > 200) {
|
|
$pdf->AddPage();
|
|
$pdf->setTitreEnTete('FICHE TECHNIQUE No 1 - SUITE');
|
|
}
|
|
|
|
$pdf->SetFont('Arial', 'BU', $tp);
|
|
$pdf->Cell(0, $ht, convertirc(_("PRIMES ET SINISTRALITE")." "), 0, 1, 'C', false);
|
|
|
|
$pdf->SetFont('Arial', 'B', 10);
|
|
$pdf->Ln(5);
|
|
$pdf->Cell(100, $ht, convertirc(_("RAPPEL PRIME NETTE TOTALE").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, format_N($primeSinistreft['PRIMETOTALE']), 0, 1, 'L', false);
|
|
|
|
$pdf->SetFont('Arial', '', 10);
|
|
$pdf->Cell(100, $ht, convertirc(_("PRIME NETTE DE LA PERIODE").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, format_N($primeSinistreft['PRIMENETTE']), 0, 1, 'L', false);
|
|
|
|
$pdf->SetFont('Arial', '', 10);
|
|
$pdf->Cell(100, $ht, convertirc(_("CHARGEMENT DE LA PERIODE").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, format_N($primeSinistreft['CHARGEMENT']), 0, 1, 'L', false);
|
|
|
|
$pdf->Ln(5);
|
|
|
|
$pdf->Cell(100, $ht, convertirc(_("PROVISION POUR SINISTRE DE LA PERIODE").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, format_N($primeSinistreft['PROVISION']), 0, 1, 'L', false);
|
|
|
|
$pdf->Cell(100, $ht, convertirc(_("SINISTRE DE LA PERIODE").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, format_N($primeSinistreft['SINISTRES']), 0, 1, 'L', false);
|
|
|
|
$pdf->Ln(10);
|
|
|
|
$pdf->SetFont('Arial', 'B', 10);
|
|
$pdf->Cell(110, $ht, convertirc(_("RESULTATS TECHNIQUES DE LA PERIODE (Rapport Sinistres/Primes)").': '), 0, 1, 'L', false);
|
|
|
|
if ($chargeravantapres == "AVANT") {
|
|
$pdf->SetFont('Arial', '', 10);
|
|
$pdf->Cell(110, $ht, convertirc(_("RAPPORT (SINISTRES/PRIME NETTE DE LA PERIODE) NET").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, number_format($primeSinistreft['RAPPRSP'], 2, '.', ','), 0, 1, 'L', false);
|
|
} else {
|
|
$pdf->SetFont('Arial', '', 10);
|
|
$pdf->Cell(110, $ht, convertirc(_("RAPPORT (SINISTRES/PROVISION) NET").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, number_format($primeSinistreft['RAPPRSP'], 2, '.', ','), 0, 1, 'L', false);
|
|
}
|
|
|
|
$pdf->Cell(110, $ht, convertirc(_("EXCEDENT (ou DEFICIT (-))").': '), 0, 0, 'L', false);
|
|
$pdf->Cell(40, $ht, format_N($primeSinistreft['ECART']), 0, 1, 'L', false);
|
|
}
|
|
|
|
// Vérification finale du nombre de pages créées
|
|
if ($pdf->PageNo() > 50) {
|
|
echo '<div class="alert alert-warning">' . _("Le document généré est trop volumineux") . '</div>';
|
|
return;
|
|
}
|
|
|
|
$fichier = "Temp/TMP_CUMUL_SP_FICHE1"."_".uniqid().".pdf";
|
|
$pdf->Output($fichier, "F");
|
|
|
|
$t_html = '<div id="div_export_b" class="alert alert-info">';
|
|
$t_html .= '<a style="font-size:15pt;" href="'.$fichier.'" target="_blank">'._("TELECHARGER FICHE 01").'</a>';
|
|
$t_html .= '</div>';
|
|
echo $t_html;
|
|
}
|
|
} |