<?php
require_once(__DIR__ . '/vendor/autoload.php');

use Fpdf\Fpdf;

class ENTETE extends FPDF
{
  var $colonnes;
  var $format;
  var $angle = 0;

  function addEntete($NoAtelier, $Allocution, $Nom, $Prenom, $Adresse, $NoPostal, $Localite, $Natel, $TelephonePrive, $TelephonePro, $Email, $DateNaissance, $Marque, $Famille, $Model, $NoPlaque, $NoChassis, $NoMoteur, $DateMiseEnCirculation, $DateExpertise, $Couleur, $DateGarantie, $TypeGarantie, $Puissance, $Description)
  {
    $initx = 10;
    $endx = 200;
    $inity = 45;
    $y = $inity;
    $dy = 5;
    $font = 10;
    $fonth = 5;
    $this->SetXY(10, 15);
    $this->SetFont("Helvetica", "B", 20);
    $this->Cell(190, 10, iconv('UTF-8', 'windows-1252', "N°" . $NoAtelier), 0, 0, "R");
    $this->SetLineWidth(0.05);
    $this->Line($initx, $y, $endx, $y);
    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(22, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Allocution :"), 0, 0, "L");
    $this->SetXY(32, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(18, $fonth, iconv('UTF-8', 'windows-1252', $Allocution), 0, 0, "L");
    $this->Line(50, $y, 50, $y + $dy);
    $this->SetXY(50, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(12, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Nom :"), 0, 0, "L");
    $this->SetXY(62, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(58, $fonth, iconv('UTF-8', 'windows-1252', $Nom), 0, 0, "L");
    $this->Line(120, $y, 120, $y + $dy);
    $this->SetXY(120, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(18, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Prénom :"), 0, 0, "L");
    $this->SetXY(138, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(62, $fonth, iconv('UTF-8', 'windows-1252', $Prenom), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(20, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Adresse :"), 0, 0, "L");
    $this->SetXY(30, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(80, $fonth, iconv('UTF-8', 'windows-1252', $Adresse), 0, 0, "L");
    $this->Line(110, $y, 110, $y + $dy);
    $this->SetXY(110, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(20, $fonth, $tel = iconv('UTF-8', 'windows-1252', "N° Postal :"), 0, 0, "L");
    $this->SetXY(130, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(15, $fonth, iconv('UTF-8', 'windows-1252', $NoPostal), 0, 0, "L");
    $this->Line(145, $y, 145, $y + $dy);
    $this->SetXY(145, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(20, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Localité :"), 0, 0, "L");
    $this->SetXY(165, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(35, $fonth, iconv('UTF-8', 'windows-1252', $Localite), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(15, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Natel :"), 0, 0, "L");
    $this->SetXY(25, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(30, $fonth, iconv('UTF-8', 'windows-1252', $Natel), 0, 0, "L");
    $this->Line(55, $y, 55, $y + $dy);
    $this->SetXY(55, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(35, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Téléphone privé :"), 0, 0, "L");
    $this->SetXY(90, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(30, $fonth, iconv('UTF-8', 'windows-1252', $TelephonePrive), 0, 0, "L");
    $this->Line(120, $y, 120, $y + $dy);
    $this->SetXY(120, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(50, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Téléphone professionnel :"), 0, 0, "L");
    $this->SetXY(170, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(30, $fonth, iconv('UTF-8', 'windows-1252', $TelephonePro), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(15, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Email :"), 0, 0, "L");
    $this->SetXY(25, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(90, $fonth, iconv('UTF-8', 'windows-1252', $Email), 0, 0, "L");
    $this->Line(115, $y, 115, $y + $dy);
    $this->SetXY(115, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(35, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Date de naissance :"), 0, 0, "L");
    $this->SetXY(150, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(50, $fonth, iconv('UTF-8', 'windows-1252', $DateNaissance), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(18, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Marque :"), 0, 0, "L");
    $this->SetXY(28, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(27, $fonth, iconv('UTF-8', 'windows-1252', $Marque), 0, 0, "L");
    $this->Line(55, $y, 55, $y + $dy);
    $this->SetXY(55, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(18, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Famille :"), 0, 0, "L");
    $this->SetXY(73, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(32, $fonth, iconv('UTF-8', 'windows-1252', $Famille), 0, 0, "L");
    $this->Line(105, $y, 105, $y + $dy);
    $this->SetXY(105, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(18, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Model :"), 0, 0, "L");
    $this->SetXY(123, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(77, $fonth, iconv('UTF-8', 'windows-1252', $Model), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(22, $fonth, $tel = iconv('UTF-8', 'windows-1252', "N° plaque :"), 0, 0, "L");
    $this->SetXY(32, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(23, $fonth, iconv('UTF-8', 'windows-1252', $NoPlaque), 0, 0, "L");
    $this->Line(55, $y, 55, $y + $dy);
    $this->SetXY(55, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(25, $fonth, $tel = iconv('UTF-8', 'windows-1252', "N° châssis :"), 0, 0, "L");
    $this->SetXY(80, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(47, $fonth, iconv('UTF-8', 'windows-1252', $NoChassis), 0, 0, "L");
    $this->Line(127, $y, 127, $y + $dy);
    $this->SetXY(127, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(25, $fonth, $tel = iconv('UTF-8', 'windows-1252', "N° moteur :"), 0, 0, "L");
    $this->SetXY(152, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(48, $fonth, iconv('UTF-8', 'windows-1252', $NoMoteur), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(55, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Date de mise en circulation :"), 0, 0, "L");
    $this->SetXY(65, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(25, $fonth, iconv('UTF-8', 'windows-1252', $DateMiseEnCirculation), 0, 0, "L");
    $this->Line(90, $y, 90, $y + $dy);
    $this->SetXY(90, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(32, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Date d'expertise :"), 0, 0, "L");
    $this->SetXY(122, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(23, $fonth, iconv('UTF-8', 'windows-1252', $DateExpertise), 0, 0, "L");
    $this->Line(145, $y, 145, $y + $dy);
    $this->SetXY(145, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(20, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Couleur :"), 0, 0, "L");
    $this->SetXY(165, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(35, $fonth, iconv('UTF-8', 'windows-1252', $Couleur), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(27, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Date garantie :"), 0, 0, "L");
    $this->SetXY(37, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(23, $fonth, iconv('UTF-8', 'windows-1252', $DateGarantie), 0, 0, "L");
    $this->Line(60, $y, 60, $y + $dy);
    $this->SetXY(60, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(30, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Type garantie :"), 0, 0, "L");
    $this->SetXY(90, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(60, $fonth, iconv('UTF-8', 'windows-1252', $TypeGarantie), 0, 0, "L");
    $this->Line(150, $y, 150, $y + $dy);
    $this->SetXY(150, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(35, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Puissance (CV) :"), 0, 0, "L");
    $this->SetXY(185, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(15, $fonth, iconv('UTF-8', 'windows-1252', $Puissance), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(25, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Description :"), 0, 0, "L");
    $this->SetXY(35, $y + 1);
    $this->SetFont("Helvetica", "", $font);
    $this->MultiCell(165, 3.5, iconv('UTF-8', 'windows-1252', $Description), 0, "L");

    $y = $y + 4 * $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->Line($initx, $inity, $initx, $y);
    $this->Line($endx, $inity, $endx, $y);
    return;
    $this->SetLineWidth(0.8);
    $this->SetXY(10, 10);
    $this->SetFont("Helvetica", "B", 16);
    $this->Cell(190, 8, "Fiche atelier", 0, 0, "C");
    $this->SetXY(10, 18);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(20, 8, "Client", 0, 0, "L");
    $this->Line(30, 18, 30, 26);
    $this->SetXY(30, 18);
    $this->SetFont("Helvetica", "", 12);
    $this->Cell(50, 5, $Nom . " " . $Prenom, 0, 0, "L");
    $this->Line(80, 18, 80, 26);
    $this->SetXY(80, 18);
    $this->Cell(40, 8, $TelephonePrive, 0, 0, "L");
    $this->Line(120, 18, 120, 26);
    $this->SetXY(120, 18);
    $this->Cell(80, 8, $Adresse, 0, 0, "L");
    $this->SetXY(10, 26);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(20, 8, "Véhicule", 0, 0, "L");
    $this->Line(30, 26, 30, 34);
    $this->SetXY(30, 26);
    $this->SetFont("Helvetica", "", 12);
    $this->Cell(60, 8, $Marque . " " . $Model, 0, 0, "L");
    $this->Line(90, 26, 90, 34);
    $this->SetXY(90, 26);
    $this->Cell(50, 8, $NoChassis, 0, 0, "L");
    $this->Line(140, 26, 140, 34);
    $this->SetXY(140, 26);
    $this->Cell(30, 8, $NoPlaque, 0, 0, "L");
    $this->Line(170, 26, 170, 34);
    $this->SetXY(170, 26);
    $this->Cell(30, 8, "Km", 0, 0, "L");
    $this->SetXY(10, 34);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(25, 8, "Réception", 0, 0, "L");
    $this->Line(35, 34, 35, 42);
    $this->SetXY(35, 34);
    $this->SetFont("Helvetica", "", 12);
    //$this->Cell(25,8, $Date1, 0, 0, "L"); ?
    $this->Line(60, 34, 60, 42);
    $this->SetXY(60, 34);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(35, 8, "Réceptionnaire", 0, 0, "L");
    $this->Line(95, 34, 95, 42);
    $this->SetXY(95, 34);
    $this->SetFont("Helvetica", "", 12);
    //$this->Cell(35,8, $Personne, 0, 0, "L"); ?
    $this->Line(130, 34, 130, 42);
    $this->SetXY(130, 34);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(30, 8, "Restitution", 0, 0, "L");
    $this->Line(160, 34, 160, 42);
    $this->SetXY(160, 34);
    $this->SetFont("Helvetica", "", 12);
    // $this->Cell(40,8, $Date2, 0, 0, "L"); ?
    $this->SetXY(10, 42);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(30, 8, "Description", 0, 0, "L");
    $this->Line(40, 42, 40, 50);
    $this->SetXY(40, 42);
    $this->SetFont("Helvetica", "", 12);
    // $this->MultiCell(170,8, $Travail, 0, "L", 0); ?
    $this->SetXY(10, 74);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(40, 8, "Travail effectué", 0, 0, "L");
    $this->Line(50, 74, 50, 82);
    $this->SetXY(150, 74);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(40, 8, "Parking", 0, 0, "L");
    $this->Line(150, 74, 150, 82);
    $this->Line(170, 74, 170, 82);
    $this->SetXY(170, 74);
    $this->SetFont("Helvetica", "", 8);
    $this->Cell(15, 8, "A", 0, 0, "L");
    $this->Line(185, 74, 185, 82);
    $this->SetXY(185, 74);
    $this->Cell(15, 8, "D", 0, 0, "L");
    $this->SetXY(10, 154);
    $this->SetFont("Helvetica", "B", 12);
    $this->Cell(60, 8, "No Article", 0, 0, "L");
    $this->Line(70, 154, 70, 258);
    $this->SetXY(70, 154);
    $this->Cell(110, 8, "Qts", 0, 0, "L");
    $this->Line(90, 154, 90, 258);
    $this->SetXY(90, 154);
    $this->Cell(110, 8, "Description", 0, 0, "L");
    $this->SetXY(10, 258);
    $this->Cell(30, 8, "Heure début", 0, 0, "L");
    $this->Line(40, 258, 40, 290);
    $this->SetXY(40, 258);
    $this->Cell(30, 8, "Heure fin", 0, 0, "L");
    $this->Line(70, 258, 70, 290);
    $this->SetXY(70, 258);
    $this->Cell(30, 8, "Date", 0, 0, "L");
    $this->Line(100, 258, 100, 290);
    $this->SetXY(100, 258);
    $this->Cell(30, 8, "Durée", 0, 0, "L");
    $this->Line(130, 258, 130, 290);
    $this->SetXY(130, 258);
    $this->Cell(30, 8, "Mécano", 0, 0, "L");
    $this->Line(160, 258, 160, 266);
    $this->SetXY(160, 258);
    // $this->Cell(30,8, "Prévu ".$Temps, 0, 0, "L"); ?

  }
  function addEntete2($NoAtelier, $Allocution, $Nom, $Prenom, $Adresse, $NoPostal, $Localite, $Natel, $TelephonePrive, $TelephonePro, $Email, $DateNaissance, $Marque, $Famille, $Model, $NoPlaque, $NoChassis, $NoMoteur, $DateMiseEnCirculation, $DateExpertise, $Couleur, $DateGarantie, $TypeGarantie, $Puissance, $Description)
  {
    $initx = 10;
    $endx = 200;
    $inity = 40;
    $y = $inity;
    $dy = 5;
    $font = 10;
    $fonth = 5;
    $this->SetXY(10, 10);
    $this->SetFont("Helvetica", "B", 20);
    $this->Cell(190, 10, iconv('UTF-8', 'windows-1252', "N°" . $NoAtelier), 0, 0, "R");
    $this->SetLineWidth(0.05);
    $this->Line($initx, $y, $endx, $y);
    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(22, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Allocution :"), 0, 0, "L");
    $this->SetXY(32, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(18, $fonth, iconv('UTF-8', 'windows-1252', $Allocution), 0, 0, "L");
    $this->Line(50, $y, 50, $y + $dy);
    $this->SetXY(50, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(12, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Nom :"), 0, 0, "L");
    $this->SetXY(62, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(58, $fonth, iconv('UTF-8', 'windows-1252', $Nom), 0, 0, "L");
    $this->Line(120, $y, 120, $y + $dy);
    $this->SetXY(120, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(18, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Prénom :"), 0, 0, "L");
    $this->SetXY(138, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(62, $fonth, iconv('UTF-8', 'windows-1252', $Prenom), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->SetXY(10, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(20, $fonth, $tel = iconv('UTF-8', 'windows-1252', "Model :"), 0, 0, "L");
    $this->SetXY(30, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(45, $fonth, iconv('UTF-8', 'windows-1252', $Model), 0, 0, "L");
    $this->Line(75, $y, 75, $y + $dy);
    $this->SetXY(75, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(25, $fonth, $tel = iconv('UTF-8', 'windows-1252', "N° châssis :"), 0, 0, "L");
    $this->SetXY(100, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(50, $fonth, iconv('UTF-8', 'windows-1252', $NoChassis), 0, 0, "L");
    $this->Line(150, $y, 150, $y + $dy);
    $this->SetXY(150, $y);
    $this->SetFont("Helvetica", "B", $font);
    $this->Cell(20, $fonth, $tel = iconv('UTF-8', 'windows-1252', "N° plaque :"), 0, 0, "L");
    $this->SetXY(170, $y);
    $this->SetFont("Helvetica", "", $font);
    $this->Cell(30, $fonth, iconv('UTF-8', 'windows-1252', $NoPlaque), 0, 0, "L");

    $y = $y + $dy;
    $this->Line($initx, $y, $endx, $y);

    $this->Line($initx, $inity, $initx, $y);
    $this->Line($endx, $inity, $endx, $y);
    return;
  }
  function mois($no)
  {
    switch ($no) {
      case 1:
        return "janvier";
      case 2:
        return "février";
      case 3:
        return "mars";
      case 4:
        return "avril";
      case 5:
        return "mai";
      case 6:
        return "juin";
      case 7:
        return "juillet";
      case 8:
        return "août";
      case 9:
        return "septembre";
      case 10:
        return "octobre";
      case 11:
        return "novembre";
      case 12:
        return "décembre";
    }
  }
}
