production/Societes/envoyx/Tarifs/Controleur/Fpdf.php
2026-03-04 01:48:40 +00:00

569 lines
19 KiB
PHP
Executable File

<?php
require_once $_SESSION['dossierSociete'].'/Tarifs/Modele/Police_sodciete.php';
$this->police_societe = new Police_sodciete();
$idPolice = $_SESSION['idPolice_C'];
// $codeGarant = $this->police_societe->getcodeGarant($idPolice);
// $codeGcAssureur = $codeGarant['codeGcAssureur'];
// $infosDuGarant = $this->police_societe->getInfosGarant($codeGcAssureur);
$enteteEmission = $this->editionpieceavenant_societe->get_edition_emission_entete();
$detailEmission = $this->editionpieceavenant_societe->get_edition_emission_detail();
$detailEmissionRetraits = $this->editionpieceavenant_societe->get_edition_emission_detail_retrait();
// var_dump($detailEmissionRetraits);
// var_dump($detailEmission);
class PDF extends FPDF {
private $headerData;
function Header() {
$this->SetFont('helvetica', '', 8);
$dateEtHeure = date("d/m/Y H:i:s");
$this->Cell(80, 10, $this->headerData, 0,0,'L',false,'');
$this->SetX(110);
$this->Cell(80, 10, 'Edition du : '.$dateEtHeure, 0,0,'R',false,'');
$this->Ln(10);
}
public function setHeaderData($title) {
$this->headerData = $title;
}
function Footer() {
$this->SetY(-15);
$this->SetFont('Arial', 'I', 8);
$this->Cell(0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C');
}
// function CreateTable($header, $data) {
// // Table header
// $this->SetFont('Arial', 'B', 10);
// foreach ($header as $col) {
// $this->Cell(30, 10, $col, 1);
// }
// $this->Ln();
// // Table data
// $this->SetFont('Arial', '', 10);
// foreach ($data as $row) {
// foreach ($row as $col) {
// $this->Cell(30, 10, $col, 1);
// }
// $this->Ln();
// }
// }
function PageTitle($title) {
// Set background color
// Set font and font size
$this->SetFont('Arial', 'B', 16);
// Calculate the width of the title
$titleWidth = $this->GetStringWidth($title);
// Calculate the X coordinate to center the title
$x = (210 - $titleWidth) / 2; // Assuming standard page width (210 units)
// Move to the calculated X coordinate
$this->SetX($x);
// Add the centered title
$this->Cell($this->w/2, 15, $title, 1, 0, 'C', false);
}
function AddTableHeader() {
// Set background color for the table header
$this->SetFillColor(226, 238, 253); // RGB values for blue
$this->SetTextColor(0, 0, 0); // RGB values for white text
$this->SetFont('Arial', 'B', 12);
// Create table header cells
$this->Cell(190, 10, 'Conditions particulieres', 1, 0, 'C', true);
$this->Ln();
$this->Ln();
// Reset background color and text color for the content
$this->SetFillColor(255, 255, 255); // Reset to default white background
$this->SetTextColor(0, 0, 0); // Reset to default black text
}
function AddTableRow($col1, $col2) {
// Add data to the table
$this->Cell(40, 10, $col1, 1);
$this->Cell(45, 10, $col2, 1);
$this->Cell(40, 10, $col1, 1);
$this->Cell(45, 10, $col2, 1);
}
function CreateTableConditionParticulieres($data, $x, $y,$borderColor, $verticalColor, $horizontalColor) {
// $this->Ln(10);
$this->SetX($x);
$this->SetFont('Arial', '', 9);
// Set the border color
// Header row with blue background
$this->SetFillColor(226, 238, 253);
// $this->SetTextColor(0); // White text
$this->SetFont('Arial', 'B', 12);
$this->Cell(190, 9,'CONDITIONS PARTICULIERES ', 1, 1, 'C', true);
$this->Ln(5);
$this->SetDrawColor($borderColor[0], $borderColor[1], $borderColor[2]);
// Set vertical border color
// $this->SetDrawColor($verticalColor[0], $verticalColor[1], $verticalColor[2]);
// $this->Ln(); // Move to the next line for the data
// Reset colors and font for data rows
$this->SetFillColor(255); // Reset background color
$this->SetTextColor(0); // Reset text color
$this->SetFont('Arial', '', 9);
foreach ($data as $row) {
// Set horizontal border color
// $this->SetDrawColor($horizontalColor[0], $horizontalColor[1], $horizontalColor[2]);
for ($i = 0; $i < count($row); $i++) {
if($i==0){
$parties = explode(":", $row[$i]);
$key= $parties[0];
$val= $parties[1];
$this->SetFont('Arial', '', 10);
$this->Cell(35, 10, $key, 1);
$this->SetFont('Arial', 'B', 10);
$this->Cell(60, 10, ': '.$val, 1);
}
else{
$parties = explode(":", $row[$i]);
$key= $parties[0];
$val= $parties[1];
$this->SetFont('Arial', '', 10);
$this->Cell(45, 10, $key, 1);
$this->SetFont('Arial', 'B', 10);
$this->Cell(50, 10, ': '.$val, 1);
}
$this->SetFont('Arial', '', 10);
}
$this->Ln(); // Move to the next line for the next row
}
// Reset the border color to default (black)
$this->SetDrawColor(0, 0, 0);
}
function RecapEffectif($data, $x, $y,$titre) {
// $this->Ln(10);
$this->SetX($x);
$this->SetFont('Arial', '', 10);
// Set the border color
// Header row with blue background
// $this->SetFillColor(255, 255, 255);
$this->SetTextColor(128,0,0); // White text
$this->SetFont('Arial', 'B', 10);
// Set the current position
// $this->SetX(20);
// $this->SetY(30);
// Create a rectangle at the current position
$this->Rect($x, $y-1, 190, 39, 'D');
$this->Cell(180, 9,$this->convert_utf8($titre), 0, 1, 'L', true);
$this->SetTextColor(0); // White text
// $this->Ln(5);
$this->SetDrawColor(0);
// Set vertical border color
// $this->SetDrawColor($verticalColor[0], $verticalColor[1], $verticalColor[2]);
// $this->Ln(); // Move to the next line for the data
// Reset colors and font for data rows
$this->SetFillColor(255); // Reset background color
$this->SetTextColor(0); // Reset text color
$this->SetFont('Arial', '', 10);
foreach ($data as $row) {
// Set horizontal border color
// $this->SetDrawColor($horizontalColor[0], $horizontalColor[1], $horizontalColor[2]);
for ($i = 0; $i < count($row); $i++) {
if($i==0){
$parties = explode(":", $row[$i]);
$key= $parties[0];
$val= $parties[1];
$this->SetFont('Arial', '', 10);
$this->Cell(30, 10, $key, 0);
$this->SetFont('Arial', 'B', 10);
$this->Cell(30, 10, ': '.$val, 0);
}
else if($i==1){
$parties = explode(":", $row[$i]);
$key= $parties[0];
$val= $parties[1];
$this->SetFont('Arial', '', 10);
$this->Cell(50, 10, $key, 0);
$this->SetFont('Arial', 'B', 10);
$this->Cell(30, 10, ': '.$val, 0);
}
else{
$parties = explode(":", $row[$i]);
$key= $parties[0];
$val= $parties[1];
$this->SetFont('Arial', '', 10);
$this->Cell(30, 10, $key, 0);
$this->SetFont('Arial', 'B', 10);
$this->Cell(25, 10, ': '.$val, 0);
}
$this->SetFont('Arial', '', 10);
}
$this->Ln(); // Move to the next line for the next row
}
// Reset the border color to default (black)
$this->SetDrawColor(0, 0, 0);
}
function findColleLibelleById($list, $id, $field) {
foreach ($list as $item) {
if ($item['idCollege'] == $id) {
return $item[$field];
}
}
// Return null if ID is not found
return null;
}
function convert_utf8($text){
return iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $text);
}
function CreatePrimeTableHeader() {
$this->SetFillColor(226, 238, 253); // Blue color for the header background
$this->SetFont('Arial', 'B', 8);
$this->SetDrawColor(0, 0, 0);
// Create header cells
$headers = array($this->convert_utf8("Période d'assurance"), 'Prime nette', 'Prime additionnelle', 'Accessoires', 'Taxe', 'Prime totale');
$count = 0;
foreach ($headers as $header) {
if($count ==0){
$this->Cell(45, 9, $header, 1, 0, 'C', true); // Border around each cell with blue background
}
else{
$this->Cell(29, 9, $header, 1, 0, 'C', true);
}
$count++;
}
$this->Ln(); // Move to the next line for the data
}
function CreatePrimeTable($debut,$fin,$enteteEmission) {
// Set font and fill color
$this->SetFont('Arial', '',8);
$this->SetFillColor(255); // Reset fill color to white
// Sample data for the table
// $periode = 'Du '.$debut.' Au '.$fin;
$periode = $debut.' Au '.$fin;
$data = array($periode, format_N($enteteEmission['primeNette']), '........', format_N($enteteEmission['accessoire']), format_N($enteteEmission['taxe']), format_N($enteteEmission['primeTtc']));
$this->SetFont('Arial', 'B', 8);
// Create data cells
$count = 0;
$isLn=0;
foreach ($data as $cell) {
if($count == sizeof($data)-1)
$isLn=1;
// $this->Cell(32, 8, $cell, 1);
// $this->MultiCell(0, 10, $cell);
if($count ==0){
// $this->Cell(40, 12, $cell, 1, $isLn, 'C', true); // Border around each cell with blue background
$this->Cell(45, 9, $cell, 1, $isLn, 'C', true); //
// $this->MultiCell(40, 5,$this->convert_utf8($cell), 0, 'L',false);
}
else{
$this->Cell(29, 9, $cell, 1, $isLn, 'C', true);
}
$count++;
// $this->Ln();
}
$this->SetFont('Arial', '', 8);
$this->Ln(3); // Move to the next line for the next row
}
function CreateDetailFamilleTable($data){
$this->SetFillColor(226, 238, 253); // Blue color for the header background
$this->SetFont('Arial', 'B', 9);
$this->SetDrawColor(0, 0, 0);
// Create header cells
$headers = array($this->convert_utf8("Assuré(s)"), 'Matricule', 'Souscripteur', 'Nom', $this->convert_utf8('Prénoms'), 'Statut', 'Genre', $this->convert_utf8('Né(e) le'), $this->convert_utf8("Date d'éffet"));
$count = 0;
foreach ($headers as $header) {
if($count ==4){
$this->Cell(30, 12, $header, 1, 0, 'C', true); // Border around each cell with blue background
}
else{
$this->Cell(20, 12, $header, 1, 0, 'C', true);
}
$count++;
}
$this->Ln(); // Move to the next line for the data
// Set font and fill color
$this->SetFont('Arial', '',8);
$this->SetFillColor(255); // Reset fill color to white
// Sample data for the table
// $periode = 'Du '.$debut.' Au '.$fin;
// $periode = $debut.' Au '.$fin;
$this->SetFont('Arial', 'B', 7);
$count = 0;
$isLn=0;
foreach ($data as $row) {
$count = 0;
foreach ($row as $col) {
// $this->Cell(20, 10, $col, 1);
if($count ==4){
$this->Cell(30, 8, $col, 1, $isLn, 'C', true); //
}
else{
$this->Cell(20, 8, $col, 1, $isLn, 'C', true);
}
$count ++;
}
$this->Ln(); // Move to the next line after each row
}
// $this->Cell(150, 8, '', 0, 1, 'C', true); //
$this->Ln(1);
$this->Cell(40, 8, 'Effectif famille: '.sizeof($data), 0, 1, 'L', true); //
$this->SetFont('Arial', '', 8);
$this->Ln(3); // Move to the next line for the next row
}
function CreateDetailFamilleEntete(){
$this->Ln(20); // Move to the next line for the next row
$this->SetFillColor(226, 238, 253); // Blue color for the header background
$this->SetFont('Arial', 'B', 9);
$this->SetDrawColor(0, 0, 0);
// Create header cells
$headers = array($this->convert_utf8("Assuré(s)"), 'Matricule', 'Souscripteur', 'Nom', $this->convert_utf8('Prénoms'), 'Statut', 'Genre', $this->convert_utf8('Né(e) le'), $this->convert_utf8("Date d'éffet"));
$count = 0;
foreach ($headers as $header) {
if($count ==4){
$this->Cell(30, 12, $header, 1, 0, 'C', true); // Border around each cell with blue background
}
else{
$this->Cell(20, 12, $header, 1, 0, 'C', true);
}
$count++;
}
$this->Ln(3); // Move to the next line for the next row
}
function CreateDetailFamilleRow($data){
$this->SetFont('Arial', 'B', 9);
$this->SetDrawColor(0, 0, 0);
// Set font and fill color
$this->SetFont('Arial', '',8);
$this->SetFillColor(255); // Reset fill color to white
// Sample data for the table
// $periode = 'Du '.$debut.' Au '.$fin;
// $periode = $debut.' Au '.$fin;
$this->SetFont('Arial', 'B', 7);
$count = 0;
$isLn=0;
foreach ($data as $row) {
$count = 0;
foreach ($row as $col) {
// $this->Cell(20, 10, $col, 1);
if($count ==4){
$this->Cell(30, 8, $col, 1, $isLn, 'C', true); //
}
else{
$this->Cell(20, 8, $col, 1, $isLn, 'C', true);
}
$count ++;
}
$this->Ln(); // Move to the next line after each row
}
// $this->Cell(150, 8, '', 0, 1, 'C', true); //
$this->Ln(1);
$this->Cell(40, 8, 'Effectif famille: '.sizeof($data), 0, 1, 'L', true); //
$this->SetFont('Arial', '', 8);
$this->Ln(3); // Move to the next line for the next row
}
function CreateTablePrimeTerme($debut,$fin) {
// Set font
// $this->Ln();
// $this->Ln();
$this->SetFont('Arial', '', 9);
// Add table header
// $this->Cell(190, 4,'', 0, 1, 'C', true);
$this->Cell(190, 8,'PRIME TERME (prochaine prime)', 1, 1, 'C', true);
$this->SetFont('Arial', 'B', 9);
$periode = $debut.' Au '.$fin;
$this->Cell(45, 16,$periode, 1, 0, 'C', true);
$this->Cell(29, 16,'..............', 1, 0, 'C', true);
$this->Cell(29, 16,'..............', 1, 0, 'C', true);
// $this->Cell(30, 12,"(Prime de base peut être modifiée par rapport à la réelle
// vraiment assuré, l'application de la clause
// d'ajustement et le niveau de taux en vigueur)
// ", 1, 0, 'C', true);
// $this->SetFillColor(255, 255, 255); // Red color
// $this->Cell(90, 24,"", 1, 0, 'C', true);
// Set the coordinates for the last cell
// $this->SetXY(20, $this->GetY() + 10); // Move to the next line
$this->SetFont('Arial', '',9);
// Last cell as a MultiCell
$this->MultiCell(87, 4,$this->convert_utf8("(Prime de base peut être modifié par rapport à la réelle vraiment assuré, l'application de la clause d'ajustement et le niveau de taux en vigueur)
"), 1, 'L');
// $this->Rect($this->GetX()-80, $this->GetY(), 90, 5, 'D');
// $this->Cell(40,24,"(Prime de base peut être modifié par rapport à la réelle",);
// Set initial position
// $x = 151;
// $y = 180;
$this->SetFont('Arial', '', 8);
// $this->SetXY(151, 180);
// $this->Cell(40, 16, $this->convert_utf8('(Prime de base peut être modifié par'));
// $this->SetXY(151, 182);
// $this->Cell(40, 16, $this->convert_utf8('(rapport à la réelle à la réelle vraiment'));
// $this->SetXY(151, 184);
// $this->Cell(40, 16, $this->convert_utf8("( assuré , l'application de la clause"));
// $this->SetXY(151, 186);
// $this->Cell(40, 16, $this->convert_utf8("d'ajustement et le niveau de taux en"));
// $this->SetXY(151, 188);
// $this->Cell(40, 16, $this->convert_utf8("vigueur)"));
// $this->SetXY(175, 180);
// $this->SetFont('Arial', '', 12);
// $this->Cell(40, 10, 'Cell 1');
// $this->Ln(3); // Move to the next line for the next row
}
function CreateTablePrimeAnnuelle() {
// Set font
// $this->Ln();
$this->SetFont('Arial', 'B', 16);
$this->SetFillColor(255, 255, 255); // White background
$this->SetDrawColor(255, 255, 255); // White color
$this->SetFont('Arial', '', 10);
$this->Cell(45, 24,'Prime annuelle', 1, 0, 'C', true);
$this->SetFont('Arial', '', 9);
$this->SetDrawColor(0, 0, 0); // White color
$this->SetFont('Arial', 'B', 9);
$this->Cell(29, 24,'.............', 1, 0, 'R', true);
$this->Cell(29, 24,'..............', 1, 0, 'C', true);
// $this->Cell(90, 24,"", 1, 0, 'C', true);
$this->SetFont('Arial', '',9);
$this->MultiCell(88, 6,$this->convert_utf8("(Prime de base peut être modifié par rapport à la réelle vraiment assuré, l'application de la clause d'ajustement et le niveau de taux en vigueur)
"), 1, 'L');
$this->SetFont('Arial', '', 8);
$this->Ln(3);
}
function commenceParVoyelle($chaine) {
$voyelles = array('a', 'e', 'i', 'o', 'u', 'y'); // Ajoutez 'y' si vous souhaitez le considérer comme une voyelle
$premierCaractere = mb_strtolower(mb_substr($chaine, 0, 1));
return in_array($premierCaractere, $voyelles);
}
}
?>