newdesigngestionnaire/Controleur/Editions/etats_avenants/incorporation.php

258 lines
7.9 KiB
PHP
Executable File

<?php
class PDF extends FPDF_Protection {
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();
// 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->SetX($x);
$this->SetFont('Arial', '', 10);
// Set the border color
// Header row with blue background
$this->SetFillColor(226, 238, 253);
// $this->SetTextColor(0); // White text
$this->SetFont('Arial', 'B', 10);
$this->Cell(190, 7,'CONDITIONS PARTICULIERES ', 1, 1, 'C', true);
$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', '', 10);
foreach ($data as $row) {
// Set horizontal border color
// $this->SetDrawColor($horizontalColor[0], $horizontalColor[1], $horizontalColor[2]);
for ($i = 0; $i < count($row); $i++) {
$this->Cell(95, 7, $row[$i], 1);
}
$this->Ln(); // Move to the next line for the next row
}
// Reset the border color to default (black)
$this->SetDrawColor(0, 0, 0);
}
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);
// Create header cells
$headers = array($this->convert_utf8("Période d'assurance"), 'Prime nette', 'Prime additionnelle', 'Accessoires', 'Taxe', 'Prime totale');
foreach ($headers as $header) {
$this->Cell(32, 10, $header, 1, 0, 'C', true); // Border around each cell with blue background
}
$this->Ln(); // Move to the next line for the data
}
function CreatePrimeTable() {
// Set font and fill color
$this->SetFont('Arial', '', 8);
$this->SetFillColor(255); // Reset fill color to white
// Sample data for the table
$data = array($this->convert_utf8('01/01/2022 - 31/12/2022'), '168 544 682', '0', '600 000', '5 074 340', '174 219 022');
// Create data cells
foreach ($data as $cell) {
$this->Cell(32, 8, $cell, 1);
// $this->MultiCell(0, 10, $cell);
}
$this->Ln(); // Move to the next line for the next row
}
function CreateTablePrimeTerme($header, $data) {
// Set font
$this->SetFont('Arial', 'B', 12);
// Add table header
foreach ($header as $col) {
$this->Cell(40, 10, $col, 1);
}
$this->Ln(); // Move to the next line for data
// Set font back to regular
$this->SetFont('Arial', '', 12);
// Add table data
foreach ($data as $row) {
foreach ($row as $col) {
$this->Cell(40, 10, $col, 1);
}
$this->Ln(); // Move to the next line for the next row
}
}
}
// Example data
$header = array('Assuré(e)', 'Matricule', 'Matricule souscripteur', 'Nom','Prénoms','Satut','Genre','Date de
naissance',"Date d'effet");
// Create PDF
$pdf = new PDF();
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = '';
$ownerPassword = null;
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
$pdf->setHeaderData($title);
// Add page title
$pdf->SetMargins(10, 10, 10);
$pdf->AddPage();
// Create the four columns table
// $pdf->CreateTable($data, 10);
// Header row (add empty line after header)
// $pdf->PageTitle('Your Page Title');
// $pdf->CreateTable($header, $data);
// Add table header
// $pdf->AddTableHeader();
// Add table rows
// $pdf->AddTableRow('Data 1', 'Data A');
// Sample data for the two columns table
$data = array(
array('Compagnie: SANLAM ASSURANCE', 'Nature de risque: SANTE GROUPE '),
array('Code Compagnie : 114', 'Data 4'),
array($pdf->convert_utf8('Intermédiaire: ASSUREUR CONSEILS'), 'Data 6'),
array($pdf->convert_utf8('Code Intermédiaire: 29'), 'Data 6'),
array("Souscripteur: FONDS D'ENTRETIEN ROUTIER", 'Data 6'),
array($pdf->convert_utf8('Numéro de compte:4315'), 'Data 6'),
array('Adresse postale: 04 BP 3089 Abidjan 04', 'Data 6'),
array($pdf->convert_utf8('Numéro police: 3023 8180000007 '), '')
// Add more rows as needed
);
// Set the border color (e.g., red)
$borderColor = array(255, 255, 255);
// Set the colors for vertical and horizontal borders
$verticalColor = array(255, 0, 0); // Red
$horizontalColor = array(0, 0, 0); // Blue
$pdf->CreateTableConditionParticulieres($data, 10, $pdf->GetY(),$borderColor,$verticalColor, $horizontalColor);
$pdf->Cell(190, 7,$pdf->convert_utf8('PRIME AU COMPTANT (à régler à la signature des présentes) '), 0, 1, 'C', true);
// Create the blue header
$pdf->CreatePrimeTableHeader();
// Create a row with sample data
$pdf->CreatePrimeTable();
require("piedfacturetest.php");