<?php
require_once(__DIR__ . '/../vendor/autoload.php');
use Fpdf\Fpdf;
//define('EURO', chr(128) );
//define('EURO_VAL', 6.55957 );

class FICHEATT extends FPDF
{
// variables privées
var $colonnes;
var $format;
var $angle=0;

function addEntete( $Nom, $Prenom, $Telephone, $Adresse, $MarqueModel,$NoChasis,$NoPlaque,$Km,$Date1, $Date2, $Personne, $Travail, $Temps )
{
	for($cpt=10;$cpt<=290;$cpt+=8)
	{
	  switch($cpt)
	  {
	  	case 10:
	  	case 18:
	  	case 42:
	  	case 74:
	  	case 154:
	  	case 258:
	  	case 290:
	      $this->SetLineWidth(0.8);
	  	break;
	  	default:
	      $this->SetLineWidth(0.4);
	  	break;
	  }	
	  $this->Line( 10, $cpt, 200, $cpt);
	}
	$this->SetLineWidth(0.8);
	$this->Line( 10, 10, 10, $cpt-8);
	$this->Line( 200, 10, 200, $cpt-8);
	$this->SetLineWidth(0.4);
	$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,8, iconv('UTF-8', 'windows-1252',$Nom." ".$Prenom), 0, 0, "L");
	$this->Line( 80, 18, 80, 26);
	$this->SetXY( 80 , 18 );
	$this->Cell(40,8, $Telephone, 0, 0, "L");
	$this->Line( 120, 18, 120, 26);
	$this->SetXY( 120 , 18 );
	$this->Cell(80,8, iconv('UTF-8', 'windows-1252',$Adresse), 0, 0, "L");
	$this->SetXY( 10 , 26 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(20,8, iconv('UTF-8', 'windows-1252',"Véhicule"), 0, 0, "L");
	$this->Line( 30, 26, 30, 34);
	$this->SetXY( 30 , 26 );
	$this->SetFont( "Helvetica", "", 12);
	$this->Cell(60,8, iconv('UTF-8', 'windows-1252',$MarqueModel), 0, 0, "L");
	$this->Line( 90, 26,90, 34);
	$this->SetXY( 90 , 26 );
	$this->Cell(50,8, $NoChasis, 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, iconv('UTF-8', 'windows-1252',"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, iconv('UTF-8', 'windows-1252',"Réceptionnaire"), 0, 0, "L");
	$this->Line( 95, 34, 95, 42);
	$this->SetXY( 95 , 34 );
	$this->SetFont( "Helvetica", "", 12);
	$this->Cell(35,8, iconv('UTF-8', 'windows-1252',$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, iconv('UTF-8', 'windows-1252',$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, iconv('UTF-8', 'windows-1252',$Travail), 0, "L", 0);
	$this->SetXY( 10 , 74 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(40,8, iconv('UTF-8', 'windows-1252',"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, iconv('UTF-8', 'windows-1252',"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, iconv('UTF-8', 'windows-1252',"Durée"), 0, 0, "L");
	$this->Line( 130, 258, 130, 290);
	$this->SetXY( 130 , 258 );
	$this->Cell(30,8, iconv('UTF-8', 'windows-1252',"Mécano"), 0, 0, "L");
	$this->Line( 160, 258, 160, 266);
	$this->SetXY( 160 , 258 );
	$this->Cell(30,8, iconv('UTF-8', 'windows-1252',"Prévu ".$Temps), 0, 0, "L");

}
function addService( $Nom, $Prenom, $Telephone, $Adresse, $MarqueModel,$NoChasis,$NoPlaque,$Km,$Date1, $Date2, $Personne, $Travail, $Temps, $IdService, $NoAtelier )
{
	$requette = "SELECT * FROM service_vhc WHERE Id = :id";
	$statement = Connection::getStatement($requette);
	$statement->bindParam(":id", $IdService);
	$statement->execute();
	$ligne = $statement->fetch();
	for($cpt=10;$cpt<=42;$cpt+=8)
	{
	  switch($cpt)
	  {
	  	case 10:
	  	case 18:
	  	case 42:
	      $this->SetLineWidth(0.8);
	  	break;
	  	default:
	      $this->SetLineWidth(0.4);
	  	break;
	  }	
	  $this->Line( 10, $cpt, 200, $cpt);
	}
	for($cpt=48;$cpt<=258;$cpt+=6)
	{
	  switch($cpt)
	  {
	  	case 66:
	  	case 154:
	  	case 258:
	      $this->SetLineWidth(0.8);
	  	break;
	  	default:
	      $this->SetLineWidth(0.4);
	  	break;
	  }	
	  $this->Line( 10, $cpt, 200, $cpt);
	}
	for($cpt=266;$cpt<=290;$cpt+=8)
	{
	  switch($cpt)
	  {
	  	case 290:
	      $this->SetLineWidth(0.8);
	  	break;
	  	default:
	      $this->SetLineWidth(0.4);
	  	break;
	  }	
	  $this->Line( 10, $cpt, 200, $cpt);
	}
	$this->SetLineWidth(0.8);
	$this->Line( 10, 10, 10, $cpt-8);
	$this->Line( 200, 10, 200, $cpt-8);
	$this->SetLineWidth(0.4);
	$this->SetXY( 10 , 10 );
	$this->SetFont( "Helvetica", "B", 16);
	if ($ligne["Nom"]!="")
	{
	  $this->Cell(190,8, iconv('UTF-8', 'windows-1252',$ligne["Nom"]."(".$ligne["Duree"].")"), 0, 0, "C");
	}
	else
	{
	  $this->Cell(190,8, iconv('UTF-8', 'windows-1252',"Service ".$ligne["Km"]."(".$ligne["Duree"].")"), 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,8, iconv('UTF-8', 'windows-1252',$Nom." ".$Prenom), 0, 0, "L");
	$this->Line( 80, 18, 80, 26);
	$this->SetXY( 80 , 18 );
	$this->Cell(40,8, $Telephone, 0, 0, "L");
	$this->Line( 120, 18, 120, 26);
	$this->SetXY( 120 , 18 );
	$this->Cell(80,8, iconv('UTF-8', 'windows-1252',$Adresse), 0, 0, "L");
	$this->SetXY( 10 , 26 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(20,8, iconv('UTF-8', 'windows-1252',"Véhicule"), 0, 0, "L");
	$this->Line( 30, 26, 30, 34);
	$this->SetXY( 30 , 26 );
	$this->SetFont( "Helvetica", "", 12);
	$this->Cell(60,8, iconv('UTF-8', 'windows-1252',$MarqueModel), 0, 0, "L");
	$this->Line( 90, 26,90, 34);
	$this->SetXY( 90 , 26 );
	$this->Cell(50,8, $NoChasis, 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, iconv('UTF-8', 'windows-1252',"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, iconv('UTF-8', 'windows-1252',"Réceptionnaire"), 0, 0, "L");
	$this->Line( 95, 34, 95, 42);
	$this->SetXY( 95 , 34 );
	$this->SetFont( "Helvetica", "", 12);
	$this->Cell(35,8, iconv('UTF-8', 'windows-1252',$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, iconv('UTF-8', 'windows-1252',$Date2), 0, 0, "L");
	$this->SetXY( 10 , 42 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(30,6, "Description", 0, 0, "L");
	$this->Line( 40, 42, 40, 48);
	$this->SetXY( 40 , 42 );
	$this->SetFont( "Helvetica", "", 12);
	$this->MultiCell(170,6, iconv('UTF-8', 'windows-1252',$Travail), 0, "L", 0);
	$this->Line( 18, 66, 18, 258);
	$this->Line( 70, 66, 70, 258);
	$this->Line( 98, 66, 98, 258);
	$this->Line( 104, 66, 104, 258);
    $requetteOptions = "SELECT voa.* FROM atelier_option".ID_GARAGE." AS ao, vhc_option AS vo, vhc_option_action AS voa WHERE ao.Id_atelier = :noatelier AND ao.Id_option = vo.Id AND vo.Id_option = voa.Id_option";
	$statement = Connection::getStatement($requetteOptions);
	$statement->bindParam(":noatelier", $NoAtelier);
	$statement->execute();
	$req_options = "";
	while ($ligneOption=$statement->fetch())
	{
	  if ($req_options != "") $req_options .= ", ";
	  $req_options .= $ligneOption["Id_action"];
	}
	
	//echo $requetteOptions."<br/>\n";
	//echo $req_options."<br/>\n";
	if ($req_options != "")
	{
	  $req_options = " OR (action.Id IN (".$req_options.") AND action.Id_Type = action_type.Id)";
	}
    $requetteRemplacement = "SELECT voa.* FROM atelier_option".ID_GARAGE." AS ao, vhc_option AS vo, vhc_option_action_remplacement AS voa WHERE ao.Id_atelier = :noatelier AND ao.Id_option = vo.Id AND vo.Id_option = voa.Id_option";
	$statement = Connection::getStatement($requetteRemplacement);
	$statement->bindParam(":noatelier", $NoAtelier);
	$statement->execute();
	$req_Remplacement = "";
	while ($ligneRemplacement=$statement->fetch())
	{
	  if ($req_Remplacement != "") $req_Remplacement .= ", ";
	  $req_Remplacement .= $ligneRemplacement["Id_action"];
	}
	//echo $requetteRemplacement."<br/>\n";
	//echo $req_Remplacement."<br/>\n";
	if ($req_Remplacement != "")
	{
	  $req_Remplacement = " AND action.Id NOT IN (".$req_Remplacement.")";
	}
  	$requette2 = "SELECT DISTINCT action_type.Abreviation, action_type.Avec_Article, action.Texte, action.Id AS Id_Action, action_type.Description FROM service_action, action, action_type WHERE (service_action.Id_Service = :idservice AND (service_action.Id_Action = action.Id$req_Remplacement) AND service_action.Id_Action_Type = action_type.Id)$req_options ORDER BY action.Id_Rubrique, action.Position";
	//echo $requette2."<br/>\n";
  	//$requette2 = "SELECT action_type.Description, action_type.Avec_Article, action.Texte, service_action.Id_Action, action_type.Valeurs FROM service_action, action, action_type WHERE service_action.Id_Service = ".$ligne['Id_Service']." AND service_action.Id_Action = action.Id AND service_action.Id_Action_Type = action_type.Id ORDER BY action.Id_Rubrique, action.Position";
	//echo $requette2."<br/>\n";
	//$requette2 = "SELECT action_type.Abreviation, action_type.Avec_Article, action.Texte AS Texte, service_action.Id_Action, action_type.Description FROM service_action, action, action_type WHERE service_action.Id_Service = $IdService AND service_action.Id_Action = action.Id AND service_action.Id_Action_Type = action_type.Id ORDER BY action.Id_Rubrique, action.Position";
	$statement = Connection::getStatement($requette2);
	$statement->bindParam(":idservice", $IdService);
	$statement->execute();
	$pos=66;
	while ($ligne2=$statement->fetch())
	{
		$this->SetXY( 10 , $pos );
		if (strlen($ligne2["Abreviation"]) == 3)
		{
		  $this->SetFont( "Helvetica", "", 8);
		}
		else
		{
		  $this->SetFont( "Helvetica", "", 12);
		}
		$this->Cell(8,6, $ligne2["Abreviation"], 0, 0, "C");
		$this->SetXY( 18 , $pos );
		$this->SetFont( "Helvetica", "", 10);
    if ($ligne2["Texte"]!="")
    {
  		$this->Cell(52,6, iconv('UTF-8', 'windows-1252',$ligne2["Texte"]), 0, 0, "L");
    }
    else
    {
  		$this->Cell(52,6, iconv('UTF-8', 'windows-1252',$ligne2["Description"]), 0, 0, "L");
    }
		if ($ligne2["Avec_Article"]==1)
		{
			$requette3 = "SELECT service_article.* FROM service_vhc, service_article WHERE service_vhc.Id = :idservice AND service_vhc.Id_vhc = service_article.Id_Vhc AND service_article.Id_Action = :idaction";
			$statement = Connection::getStatement($requette2);
			$statement->bindParam(":idservice", $IdService);
			$statement->bindParam(":idaction", $ligne2["Id_Action"]);
			$statement->execute();
			if ($ligne3 = $statement->fetch())
			{
				$no_article = $ligne3["NoArticle"];
				$pos_p = strpos($no_article, "(");
				if ($pos_p !== false)
				{
				  $no_article = substr($no_article,$pos_p);
				  $rpl = array("(", ")");
				  $no_article = str_replace($rpl, "", $no_article);
				}
				$this->SetXY( 70 , $pos );
				$this->SetFont( "Helvetica", "", 10);
				$this->Cell(28,6, $no_article, 0, 0, "L");
			}
			$requette3 = "SELECT service_option_article.* FROM service_vhc, service_option_article WHERE service_vhc.Id = :idservice AND service_option_article.Id_Vhc = service_vhc.Id_vhc AND service_option_article.Id_Action = :idaction";
			$statement = Connection::getStatement($requette3);
			$statement->bindParam(":idservice", $IdService);
			$statement->bindParam(":idaction", $ligne2["Id_Action"]);
			$statement->execute();
			if ($ligne3 = $statement->fetch())
			{
			  $no_article = $ligne3["NoArticle"];
			  $pos_p = strpos($no_article, "(");
			  if ($pos_p !== false)
			  {
				$no_article = substr($no_article,$pos_p);
				$rpl = array("(", ")");
				$no_article = str_replace($rpl, "", $no_article);
			  }
			  $this->SetXY( 70, $pos );
			  $this->SetFont( "Helvetica", "", 10);
			  $this->Cell(28,6, iconv('UTF-8', 'windows-1252',$no_article), 0, 0, "L");
			}
		}
		else
		{
			$this->SetFillColor(128);
			$this->Rect(104,$pos,6,6,"FD");
		}
		$pos+=6;
	}
	$this->SetLineWidth(0.8);
	$this->Line( 110, 66, 110, 258);
    $this->SetLineWidth(0.4);
	$this->SetXY( 110 , 66 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(40,8, iconv('UTF-8', 'windows-1252',"Travail effectué"), 0, 0, "L");
	$this->Line( 150, 66, 150, 72);
	$this->SetXY( 150 , 66 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(40,8, "Parking", 0, 0, "L");
	$this->Line( 170, 66, 170, 72);
	$this->SetXY( 170 , 66 );
	$this->SetFont( "Helvetica", "", 8);
	$this->Cell(15,8, "A", 0, 0, "L");
	$this->Line( 185, 66, 185, 72);
	$this->SetXY( 185 , 66 );
	$this->Cell(15,8, "D", 0, 0, "L");
	$this->SetLineWidth(0.8);
	$this->Line( 110, 156, 200, 156);
    $this->SetLineWidth(0.4);
	$this->SetXY( 110 , 156 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(40,6, "No Article", 0, 0, "L");
	$this->Line( 150, 156, 150, 258);
	$this->SetXY( 150 , 156 );
	$this->Cell(15,6, "Qts", 0, 0, "L");
	$this->Line( 165, 156, 165, 258);
	$this->SetXY( 165 , 156 );
	$this->Cell(35,6, "Description", 0, 0, "L");
	$this->SetXY( 10 , 258 );
	$this->Cell(30,8, iconv('UTF-8', 'windows-1252',"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, iconv('UTF-8', 'windows-1252',"Durée"), 0, 0, "L");
	$this->Line( 130, 258, 130, 290);
	$this->SetXY( 130 , 258 );
	$this->Cell(30,8, iconv('UTF-8', 'windows-1252',"Mécano"), 0, 0, "L");
	$this->Line( 160, 258, 160, 266);
	$this->SetXY( 160 , 258 );
	$this->Cell(30,8, iconv('UTF-8', 'windows-1252',"Prévu ".$Temps), 0, 0, "L");

}
function addContractLoc( $Nom, $Prenom, $Telephone, $Adresse, $MarqueModel, $NoChasis, $NoPlaque ,$Adresse2, $Dated, $Heured, $Datef, $Heuref, $Km, $Etat, $NoTarif, $Tarif, $Nb, $Rabais, $Total, $KmUnit, $PrixKmSup, $Caution, $TypeCaution, $NoCC, $ExpCC, $TypeVhc)
{
	$this->SetLineWidth(0.8);
	$this->Line( 10, 10, 10, 290);
	$this->Line( 200, 10, 200, 290);
	$this->Line( 10, 10, 200, 10);
	$this->Line( 10, 290, 200, 290);
	$this->SetFont( "Helvetica", "", 12);
	$this->SetXY( 10 , 10 );
	$this->Cell(50,6, "Charmilles 3 SA", 0, 0, "L");
	$this->SetFont( "Helvetica", "B", 12);
	$this->SetXY( 10 , 16 );
	$this->Cell(50,6, iconv('UTF-8', 'windows-1252',"Centre Honda Genève"), 0, 0, "L");
	$this->SetFont( "Helvetica", "", 12);
	$this->SetXY( 10 , 22 );
	$this->Cell(50,6, "Rue des Charmilles 3", 0, 0, "L");
	$this->SetXY( 10 , 28 );
	$this->Cell(50,6, iconv('UTF-8', 'windows-1252',"1203 Genève"), 0, 0, "L");
	$this->SetXY( 145 , 10 );
	$this->Cell(55,6, iconv('UTF-8', 'windows-1252',"Téléphone: 022 339.70.00"), 0, 0, "L");
	$this->SetFont( "Helvetica", "B", 16);
	$this->SetXY( 10 , 16 );
	$this->Cell(190,10, "Contrat de location", 0, 0, "C");
	$this->Line( 10, 34, 200, 34);
	$this->SetXY( 10 , 34 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(20,8, "Client", 0, 0, "L");
	$this->SetLineWidth(0.4);
	$this->Line( 30, 34, 30, 42);
	$this->SetXY( 30 , 34 );
	$this->SetFont( "Helvetica", "", 12);
	$this->Cell(50,8, iconv('UTF-8', 'windows-1252',$Nom." ".$Prenom), 0, 0, "L");
	$this->Line( 80, 34, 80, 42);
	$this->SetXY( 80 , 34 );
	$this->Cell(40,8, $Telephone, 0, 0, "L");
	$this->Line( 120, 34, 120, 42);
	$this->SetXY( 120 , 34 );
	$this->Cell(80,8, iconv('UTF-8', 'windows-1252',$Adresse), 0, 0, "L");
	$this->Line( 10, 42, 200, 42);
	$this->SetXY( 10 , 42 );
	$this->SetFont( "Helvetica", "B", 12);
	$this->Cell(20,8, iconv('UTF-8', 'windows-1252',"Véhicule"), 0, 0, "L");
	$this->Line( 30, 42, 30, 50);
	$this->SetXY( 30 , 42 );
	$this->SetFont( "Helvetica", "", 12);
	$this->Cell(80,8, iconv('UTF-8', 'windows-1252',$MarqueModel), 0, 0, "L");
	$this->Line( 110, 42,110, 50);
	$this->SetXY( 110 , 42 );
	$this->Cell(50,8, $NoChasis, 0, 0, "L");
	$this->Line( 160, 42, 160, 50);
	$this->SetXY( 160 , 42 );
	$this->Cell(40,8, $NoPlaque, 0, 0, "L");
	$this->Line( 10, 50, 200, 50);
	if(!empty($Adresse2))
	{
	  $this->SetXY( 10 , 50 );
	  $this->SetFont( "Helvetica", "B", 12);
	  $this->Cell(40,10, "Adresse locale", 0, 0, "L");
	  $this->SetXY( 50 , 50 );
	  $this->SetFont( "Helvetica", "", 12);
	  $this->Cell(40,10, iconv('UTF-8', 'windows-1252',$Adresse2), 0, 0, "L");
	}
	$this->SetLineWidth(0.8);
	$this->Line( 10, 60, 200, 60);
	$this->SetFont( "Helvetica", "B", 12);
	$this->SetLineWidth(0.4);
	$this->Line( 50, 60, 50, 90);
	$this->SetXY( 50 , 60 );
	$this->Cell(30,10, "Date", 0, 0, "C");
	$this->Line( 80, 60, 80, 90);
	$this->SetXY( 80 , 60 );
	$this->Cell(20,10, "Heure", 0, 0, "C");
	$this->Line( 100, 60, 100, 90);
	$this->SetXY( 100 , 60 );
	$this->Cell(30,10, "Km", 0, 0, "C");
	$this->SetXY( 130 , 60 );
	$this->Cell(70,10, iconv('UTF-8', 'windows-1252',"Etat initial véhicule"), 0, 0, "C");
	$this->Line( 10, 70, 200, 70);
	$this->SetXY( 10 , 70 );
	$this->Cell(40,10, iconv('UTF-8', 'windows-1252',"Départ effectif"), 0, 0, "L");
	$this->Line( 10, 80, 130, 80);
	$this->SetXY( 10 , 80 );
	$this->Cell(40,10, iconv('UTF-8', 'windows-1252',"Retour prévu"), 0, 0, "L");
	$this->SetFont( "Helvetica", "", 12);
	$this->SetXY( 50 , 70 );
	$this->Cell(30,10, $Dated, 0, 0, "C");
	$this->SetXY( 50 , 80 );
	$this->Cell(30,10, $Datef, 0, 0, "C");
	$this->SetXY( 80 , 70 );
	$this->Cell(20,10, $Heured, 0, 0, "C");
	$this->SetXY( 80 , 80 );
	$this->Cell(20,10, $Heuref, 0, 0, "C");
	$this->SetXY( 100 , 70 );
	$this->Cell(30,10, $Km, 0, 0, "C");
	$this->SetXY( 130 , 70 );
	$this->Cell(80,5, iconv('UTF-8', 'windows-1252',$Etat), 0, 0, "L");
	$this->SetLineWidth(0.8);
	$this->Line( 10, 90, 130, 90);
	$this->Line( 130, 60, 130, 100);
	$this->SetFont( "Helvetica", "B", 12);
	$this->SetXY( 10 , 90 );
	$this->Cell(20,10, "Casque", 0, 0, "L");
	$this->SetLineWidth(0.4);
	$this->Line( 30, 90, 30, 100);
	$this->SetLineWidth(0.8);
	$this->Line( 10, 100, 200, 100);
	$this->SetXY( 10 , 100 );
	switch($NoTarif)
	{
	  case 1:
	    $NomTarif="1 à 2 jour(s)";
      break;
	  case 2:
	    $NomTarif="3 à 5 jours";
      break;
	  case 3:
	    $NomTarif="6 à 9 jours";
      break;
	  case 4:
	    $NomTarif="10 à 12 jours";
      break;
	  case 5:
	    $NomTarif="13 à 15 jours";
      break;
      default:
		$NomTarif="Inconnu";
      break;
	}
	$this->Cell(70,10, iconv('UTF-8', 'windows-1252',"Tarif ".$NomTarif." ".$Tarif." CHF/unité"), 0, 0, "L");
	$this->SetXY( 80 , 100 );
	$this->Cell(30,10, iconv('UTF-8', 'windows-1252',$Nb." unité(s)"), 0, 0, "L");
	if($Rabais!=0)
	{
	  $this->SetXY( 120 , 100 );
	  $this->Cell(20,10, $Rabais."%", 0, 0, "L");
	}
	$this->SetXY( 140 , 100 );
	$this->Cell(40,10, $Total." CHF TTC", 0, 0, "L");
	if($KmUnit!=0)
	{
	  $this->SetXY( 10 , 110 );
	  $this->Cell(70,10, iconv('UTF-8', 'windows-1252',"km inclus $KmUnit km/unité "), 0, 0, "L");
	  $this->SetXY( 80 , 110 );
	  $this->Cell(30,10, iconv('UTF-8', 'windows-1252',$Nb." unité(s)"), 0, 0, "L");
	  $this->SetXY( 140 , 110 );
	  $this->Cell(40,10, ($Nb*$KmUnit)." Km compris", 0, 0, "L");
	  $this->SetXY( 10 , 110 );
	  $this->Cell(70,10, iconv('UTF-8', 'windows-1252',$PrixKmSup." CHF/Km supplémentaire"), 0, 0, "L");
    }
	$this->SetXY( 10 , 120 );
	$this->Cell(50,10, "Caution $Caution CHF", 0, 0, "L");
	$this->SetXY( 60 , 120 );
	switch($TypeCaution)
	{
	  case 0:
	    $this->Cell(40,10, "Cash", 0, 0, "L");
	  break;
	  case 1:
	    $this->Cell(40,10, "Visa", 0, 0, "L");
	  break;
	  case 2:
	    $this->Cell(40,10, "Master card", 0, 0, "L");
	  break;
	  case 3:
	    $this->Cell(40,10, "American express", 0, 0, "L");
	  break;
	  case 4:
	    $this->Cell(40,10, "Diners card", 0, 0, "L");
	  break;
	}
	if($TypeCaution!=0)
	{
	  $NoCCC=str_replace(" ","",$NoCC);
	  $Taille=strlen($NoCCC);
	  $No=substr($NoCCC,0,4);
	  for ($cpt=4;$cpt<($Taille-4);$cpt++)
	  {
	  	$No.="*";
	  }
	  $No.=substr($NoCCC,$Taille-4);
	  $this->SetXY( 100 , 120 );
	  $this->Cell(40,10, $No, 0, 0, "L");
	  $this->SetXY( 140 , 120 );
	  $this->Cell(40,10, "Exp ".substr($ExpCC,5,2)."/".substr($ExpCC,2,2), 0, 0, "L");
    }
	$this->Line( 10, 130, 200, 130);
	$this->SetXY( 10 , 130 );
	$this->Cell(200,10, iconv('UTF-8', 'windows-1252',"Schéma état initial véhicule"), 0, 0, "C");
	$this->SetLineWidth(0.4);
	$this->Line( 10, 140, 200, 140);
//	$this->SetXY( 10 , 150 );
//	$this->MultiCell(190,10, "Les frais occasionnés en cas de vol ou d'accident seront déduits de la caution", 0, "L", 0);
	$this->SetFont( "Helvetica", "", 12);
	switch ($TypeVhc)
	{ 
	  case 0:
		$this->Image("../config/scooter.png",15,145,180,55);
	    break;
	  case 1:
		$this->Image("../config/motonc.png",15,145,180,55);
	    break;
	  case 2:
		$this->Image("../config/motoc.png",15,145,180,55);
	    break;
	}
	$this->SetLineWidth(0.8);
	$this->Line( 10, 210, 200, 210);
	$this->SetXY( 15 , 215 );
	$this->MultiCell(180,5, iconv('UTF-8', 'windows-1252',"Le locataire atteste avoir pris connaissance du tarif ainsi que des conditions de locations et d'assurance imprimées au verso et s'engage à porter le plus grand soin à l'utilisation du véhicule qu'il a loué. Les frais occasionnés en cas de vol ou d'accident seront déduits de la caution"), 0, "J", 0);
	$this->SetXY( 20 , 240 );
	if(date("j")==1)
	  $Date="1er ".$this->mois(date("n")).date(" Y");
	else
	  $Date=date("j ").$this->mois(date("n")).date(" Y");
	$this->Cell(70,10, iconv('UTF-8', 'windows-1252',"Genève le, $Date"), 0, 0, "L");
	$this->SetXY( 10 , 250 );
	$this->Cell(95,10, iconv('UTF-8', 'windows-1252',$Nom." ".$Prenom), 0, 0, "C");
	$this->SetXY( 115 , 240 );
	$this->Cell(70,10, iconv('UTF-8', 'windows-1252',"Genève le, $Date"), 0, 0, "L");
	$this->SetXY( 105 , 250 );
	$this->Cell(95,10, "Charmilles 3 S.A.", 0, 0, "C");
	$this->SetXY( 120 , 255 );
	$this->Cell(65,10, iconv('UTF-8', 'windows-1252',"1203 Genève"), 0, 0, "C");
}
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";
  }
}	
}
?>
