/**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->SENDING_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
     }
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $Xoff = 90;
     $Yoff = 0;
     $tab4_top = 60;
     $tab4_hl = 6;
     $tab4_sl = 4;
     $line = 2;
     //*********************LOGO****************************
     $pdf->SetXY(11, 7);
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, 10, 5, 0, $height * 0.7);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     //*********************Entete****************************
     //Nom du Document
     $pdf->SetXY($Xoff, 7);
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L');
     // Bordereau expedition
     //Num Expedition
     $Yoff = $Yoff + 7;
     $Xoff = 142;
     //$pdf->Rect($Xoff, $Yoff, 85, 8);
     $pdf->SetXY($Xoff, $Yoff);
     $pdf->SetFont('', '', $default_font_size - 2);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending") . ': ' . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
     // Add list of linked elements
     // TODO possibility to use with other elements (business module,...)
     //$object->load_object_linked();
     $origin = $object->origin;
     $origin_id = $object->origin_id;
     // TODO move to external function
     if ($conf->{$origin}->enabled) {
         $outputlangs->load('orders');
         $classname = ucfirst($origin);
         $linkedobject = new $classname($this->db);
         $result = $linkedobject->fetch($origin_id);
         if ($result >= 0) {
             $Yoff = $Yoff + 4;
             $pdf->SetXY($Xoff, $Yoff);
             $pdf->SetFont('', '', $default_font_size - 2);
             $text = $linkedobject->ref;
             if ($linkedobject->ref_client) {
                 $text .= ' (' . $linkedobject->ref_client . ')';
             }
             $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
         }
     }
     //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
     //Definition Emplacement du bloc Societe
     $Xoff = 110;
     $blSocX = 90;
     $blSocY = 24;
     $blSocW = 50;
     $blSocX2 = $blSocW + $blSocX;
     // Sender name
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size - 3);
     $pdf->SetXY($blSocX, $blSocY + 1);
     $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
     $pdf->SetTextColor(0, 0, 0);
     // Sender properties
     $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
     $pdf->SetFont('', '', $default_font_size - 3);
     $pdf->SetXY($blSocX, $blSocY + 4);
     $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
     if ($object->client->code_client) {
         $Yoff += 7;
         $posy = $Yoff;
         $pdf->SetXY(100, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     //Date Expedition
     $Yoff = $Yoff + 7;
     $pdf->SetXY($blSocX - 80, $blSocY + 20);
     $pdf->SetFont('', 'B', $default_font_size - 2);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
     // Deliverer
     /*$pdf->SetXY($blSocX-80,$blSocY+23);
     		$pdf->SetFont('','', $default_font_size - 2);
     		$pdf->SetTextColor(0,0,0);
     
     		if (! empty($object->tracking_number))
     		{
     			$object->GetUrlTrackingStatus($object->tracking_number);
     			if (! empty($object->tracking_url))
     			{
     				if ($object->shipping_method_id > 0)
     				{
     					// Get code using getLabelFromKey
     					$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
     					$label=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
     				}
     				else
     				{
     					$label=$outputlangs->transnoentities("Deliverer");
     				}
     
     				$pdf->writeHTMLCell(50, 8, '', '', $label." ".$object->tracking_url, '', 'L');
     			}
     		}
     		else
     		{
     			$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
     		}*/
     /**********************************/
     //Emplacement Informations Expediteur (My Company)
     /**********************************/
     $Yoff = $blSocY;
     $blExpX = $Xoff - 20;
     $blW = 52;
     $Ydef = $Yoff;
     $pdf->Rect($blExpX, $Yoff, $blW, 26);
     $object->fetch_thirdparty();
     // If SHIPPING contact defined on order, we use it
     $usecontact = false;
     $arrayidcontact = $object->{$origin}->getIdContact('external', 'SHIPPING');
     if (count($arrayidcontact) > 0) {
         $usecontact = true;
         $result = $object->fetch_contact($arrayidcontact[0]);
     }
     // Recipient name
     if (!empty($usecontact)) {
         // On peut utiliser le nom de la societe du contact
         if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
             $socname = $object->contact->socname;
         } else {
             $socname = $object->client->nom;
         }
         $carac_client_name = $outputlangs->convToOutputCharset($socname);
     } else {
         $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
     }
     $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
     $blDestX = $blExpX + 55;
     $blW = 50;
     $Yoff = $Ydef + 1;
     // Show recipient frame
     $pdf->SetFont('', 'B', $default_font_size - 3);
     $pdf->SetXY($blDestX, $Yoff - 4);
     $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
     $pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
     // Show recipient name
     $pdf->SetFont('', 'B', $default_font_size - 3);
     $pdf->SetXY($blDestX, $Yoff);
     $pdf->MultiCell($blW, 3, $carac_client_name, 0, 'L');
     // Show recipient information
     $pdf->SetFont('', '', $default_font_size - 3);
     $pdf->SetXY($blDestX, $Yoff + dol_nboflines_bis($carac_client_name, 50) * 4);
     $pdf->MultiCell($blW, 2, $carac_client, 0, 'L');
 }
	/**
	 *   	Show header of document
	 *   	@param      pdf     		Object PDF
	 *   	@param      object			Object commercial proposal
	 *      @param      showaddress     0=no, 1=yes
	 *      @param      outputlangs    	Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs,$mysoc;
		$default_font_size = pdf_getPDFFontSize($outputlangs);
		$langs->load("orders");

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
		}

		//Prepare la suite
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		// Show barcode
		if ($conf->barcode->enabled)
		{
			$posx=105;
		}
		else
		{
			$posx=$this->marge_gauche+3;
		}
		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
		if ($conf->barcode->enabled)
		{
			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
			//$pdf->Image($logo,10, 5, 0, 24);
		}

		$pdf->SetDrawColor(128,128,128);
		if ($conf->barcode->enabled)
		{
			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
			//$pdf->Image($logo,10, 5, 0, 24);
		}


		$posx=100;
		$posy=$this->marge_haute;

		$pdf->SetFont('','B', $default_font_size + 3);
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$title=$outputlangs->transnoentities("SendingSheet");
		$pdf->MultiCell(100, 4, $title, '' , 'R');
        $posy+=1;

		$pdf->SetFont('','', $default_font_size + 2);

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');

		//Date Expedition
		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_delivery,"%d %b %Y",false,$outputlangs,true), '', 'R');

		if (! empty($object->client->code_client))
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}


		$pdf->SetFont('','', $default_font_size + 4);
	    $Yoff=25;

	    // Add list of linked orders
	    // TODO possibility to use with other document (business module,...)
	    //$object->load_object_linked();
	    
	    $origin 	= $object->origin;
		$origin_id 	= $object->origin_id;

	    // TODO move to external function
		if ($conf->$origin->enabled)
		{
			$outputlangs->load('orders');
			
			$classname = ucfirst($origin);
			$linkedobject = new $classname($this->db);
			$result=$linkedobject->fetch($origin_id);
			if ($result >= 0)
			{
				$pdf->SetFont('','', $default_font_size - 2);
				$text=$linkedobject->ref;
				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
				$Yoff = $Yoff+8;
				$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
				$pdf->MultiCell(60, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
				$Yoff = $Yoff+4;
				$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
				$pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R');
			}
		}
		
		if ($showaddress)
		{
			// Sender properties
			$carac_emetteur='';
		 	// Add internal contact of proposal if defined
			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
		 	if (sizeof($arrayidcontact) > 0)
		 	{
		 		$object->fetch_user($arrayidcontact[0]);
		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
		 	}

		 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);

			// Show sender
			$posx=$this->marge_gauche;
			$posy=42;
			$hautcadre=40;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;

			// Show sender frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
			$pdf->SetXY($posx,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);

			// Show sender name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFont('','B',$default_font_size);
			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

			// Show sender information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


			// If CUSTOMER contact defined, we use it
			$usecontact=false;
			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
			if (sizeof($arrayidcontact) > 0)
			{
				$usecontact=true;
				$result=$object->fetch_contact($arrayidcontact[0]);
			}

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show recipient
			$posy=42;
			$posx=100;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

			// Show recipient frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(80, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L');
			$pdf->rect($posx, $posy, 100, $hautcadre);
			$pdf->SetTextColor(0,0,0);

			// Show recipient name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			// Show recipient information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
		}

	}
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager, $user;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     $outputlangs->load("orders");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("Order");
     $pdf->MultiCell(100, 3, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size - 1);
     if ($object->ref_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
     }
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
     $posy += 2;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         //$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         //$pdf->MultiCell(80, 4, $user->id, 0, 'L');
         // if($object->fk_cash == '1' || $object->fk_cash == '2')
         // 	$pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura <br>Aguascalientes, Ags.<br>01(449) 917 3017", 0, 'L');
         // if($object->fk_cash == '3')
         // 	$pdf->MultiCell(80, 4, "Salida a Zacatecas Km. 4.5 <br>Aguascalientes,Ags. <br>01(449) 973 1314", 0, 'L');
         // if($object->fk_cash == '4')
         // 	$pdf->MultiCell(80, 4, "Salida a San Luis Km. 1.9 Fracc. Asturias <br>Aguascalientes, Ags. <br>01(449) 1458210", 0, 'L');
         // if($object->fk_cash == '5' || $object->fk_cash == '6' || $object->fk_cash == '7')
         // 	$pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 <br>San Juan de Los Lagos, Jal.", 0, 'L');
         // if($object->fk_cash == '8')
         // 	$pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 <br>San Juan de Los Lagos, Jal.", 0, 'L');
         // if($object->fk_cash == '9' || $object->fk_cash == '10')
         // 	$pdf->MultiCell(80, 4, "Moreno Valley #199 <br>San Juan de los Lagos, Jal.<br>01(395) 785 3005", 0, 'L');
         if ($user->id == 1) {
             $pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura Aguascalientes, Ags. 01(449) 917 3017", 0, 'L');
         }
         if ($user->id == 2) {
             $pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura Aguascalientes, Ags. 01(449) 917 3017", 0, 'L');
         }
         if ($user->id == 16) {
             $pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura Aguascalientes, Ags. 01(449) 917 3017", 0, 'L');
         }
         if ($user->id == 5) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 7) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 10) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 11) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 15) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 17) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 21) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 8) {
             $pdf->MultiCell(80, 4, "Moreno Valley #199 San Juan de los Lagos, Jal. 01(395) 785 3005", 0, 'L');
         }
         if ($user->id == 14) {
             $pdf->MultiCell(80, 4, "Moreno Valley #199 San Juan de los Lagos, Jal. 01(395) 785 3005", 0, 'L');
         }
         if ($user->id == 13) {
             $pdf->MultiCell(80, 4, "Salida a Zacatecas Km. 4.5 Aguascalientes,Ags. 01(449) 973 1314", 0, 'L');
         }
         if ($user->id == 23) {
             $pdf->MultiCell(80, 4, "Salida a Zacatecas Km. 4.5 Aguascalientes,Ags. 01(449) 973 1314", 0, 'L');
         }
         if ($user->id == 12) {
             $pdf->MultiCell(80, 4, "Salida a San Luis Km. 1.9 Fracc. Asturias Aguascalientes, Ags. 01(449) 1458210", 0, 'L');
         }
         if ($user->id == 22) {
             $pdf->MultiCell(80, 4, "Salida a San Luis Km. 1.9 Fracc. Asturias Aguascalientes, Ags. 01(449) 1458210", 0, 'L');
         }
         // If CUSTOMER contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 0);
 }
Example #4
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("interventions");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->FICHINTER_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK);
     }
     //Prepare la suite
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("InterventionCard");
     $pdf->MultiCell(100, 4, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size);
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
     if ($object->client->code_client) {
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = '';
         // Add internal contact of proposal if defined
         $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
         if (count($arrayidcontact) > 0) {
             $object->fetch_user($arrayidcontact[0]);
             $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Name") . ": " . $outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)) . "\n";
         }
         $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If CUSTOMER contact defined, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, isset($object->contact) ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         $pdf->SetTextColor(0, 0, 0);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
 }
Example #5
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     if ($object->date_valid) {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
         $pdf->SetTextColor(0, 0, 60);
     }
     if ($object->client->code_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     $posy += 2;
     // Add list of linked orders on shipment
     // Currently not supported by pdf_writeLinkedObjects, link for delivery to order is done through shipment)
     if ($object->origin == 'expedition' || $object->origin == 'shipping') {
         $Yoff = $posy - 5;
         include_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
         $shipment = new Expedition($this->db);
         $shipment->fetch($object->origin_id);
         $origin = $shipment->origin;
         $origin_id = $shipment->origin_id;
         if ($conf->{$origin}->enabled) {
             $outputlangs->load('orders');
             $classname = ucfirst($origin);
             $linkedobject = new $classname($this->db);
             $result = $linkedobject->fetch($origin_id);
             if ($result >= 0) {
                 $pdf->SetFont('', '', $default_font_size - 2);
                 $text = $linkedobject->ref;
                 if ($linkedobject->ref_client) {
                     $text .= ' (' . $linkedobject->ref_client . ')';
                 }
                 $Yoff = $Yoff + 8;
                 $pdf->SetXY($this->page_largeur - $this->marge_droite - 100, $Yoff);
                 $pdf->MultiCell(100, 2, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), 0, 'R');
                 $Yoff = $Yoff + 3;
                 $pdf->SetXY($this->page_largeur - $this->marge_droite - 60, $Yoff);
                 $pdf->MultiCell(60, 2, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
             }
         }
         $posy = $Yoff;
     }
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // Client destinataire
         $posy = 42;
         $posx = 102;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress") . ":", 0, 'L');
         // If SHIPPING contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 60);
 }
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs,$mysoc;
		$langs->load("orders");
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
		}


		$posy=$this->marge_haute;
		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		$posy = 40;

		$pdf->SetXY($this->marge_gauche,$posy+3);

		// Sender name
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

		// Sender properties
		$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY($this->marge_gauche,$posy+7);
		$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');

		// Client destinataire
		$client = new Societe($this->db);
		$client->fetch($object->socid);
		$object->client = $client;

		// If CUSTOMER contact defined on invoice, we use it
		$usecontact=false;
		$arrayidcontact=$object->getIdContact('external','CUSTOMER');
		if (sizeof($arrayidcontact) > 0)
		{
			$usecontact=true;
			$result=$object->fetch_contact($arrayidcontact[0]);
		}

		// Recipient name
		if (! empty($usecontact))
		{
			// On peut utiliser le nom de la societe du contact
			if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
			else $socname = $object->client->nom;
			$carac_client_name=$outputlangs->convToOutputCharset($socname);
		}
		else
		{
			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
		}

		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

		// Show customer/recipient
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->SetXY(102,42);
		$pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY(102,$pdf->GetY());
		$pdf->MultiCell(96, 4, $carac_client, 0, 'L');

		$pdf->rect(100, 40, 100, 40);

		$pdf->SetTextColor(200,0,0);
		$pdf->SetFont('','B', $default_font_size + 2);
		$pdf->SetXY(11, 88);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs), 0, 'L');
        $pdf->SetXY(11, 94);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
	}
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     $outputlangs->load("orders");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("InvoiceProForma");
     $pdf->MultiCell(100, 3, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size - 1);
     if ($object->ref_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
     }
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
     $posy += 2;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If CUSTOMER contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 0);
 }
	/**
	 *	\brief      Fonction generant la fiche d'intervention sur le disque
	 *	\param	    fichinter		Object fichinter
	 *	\param		outputlangs		Lang output object
	 *	\return	    int     		1=ok, 0=ko
	 */
	function write_file($fichinter,$outputlangs)
	{
		global $user,$langs,$conf,$mysoc;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		if (! is_object($outputlangs)) $outputlangs=$langs;
		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
		if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';

		$outputlangs->load("main");
		$outputlangs->load("dict");
		$outputlangs->load("companies");
		$outputlangs->load("interventions");

		if ($conf->ficheinter->dir_output)
		{
			// If $fichinter is id instead of object
			if (! is_object($fichinter))
			{
				$id = $fichinter;
				$fichinter = new Fichinter($this->db);
				$result=$fichinter->fetch($id);
				if ($result < 0)
				{
					dol_print_error($this->db,$fichinter->error);
				}
			}

            $fichinter->fetch_thirdparty();

			$fichref = dol_sanitizeFileName($fichinter->ref);
			$dir = $conf->ficheinter->dir_output;
			if (! preg_match('/specimen/i',$fichref)) $dir.= "/" . $fichref;
			$file = $dir . "/" . $fichref . ".pdf";

			if (! file_exists($dir))
			{
				if (create_exdir($dir) < 0)
				{
					$this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
					return 0;
				}
			}

			if (file_exists($dir))
			{
                $pdf=pdf_getInstance($this->format);

                if (class_exists('TCPDF'))
                {
                    $pdf->setPrintHeader(false);
                    $pdf->setPrintFooter(false);
                }
                $pdf->SetFont(pdf_getPDFFont($outputlangs));

				$pdf->Open();
				$pagenb=0;
				$pdf->SetDrawColor(128,128,128);

				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
				$pdf->SetAutoPageBreak(1,0);

				// New page
				$pdf->AddPage();
				$pagenb++;
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','', $default_font_size - 1);
				$pdf->MultiCell(0, 3, '');		// Set interline to 3

				// Pagehead

				//Affiche le filigrane brouillon - Print Draft Watermark
				if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
				{
                    pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
				}

				$posy=$this->marge_haute;

				$pdf->SetXY($this->marge_gauche,$posy);

				// Logo
				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
				if ($mysoc->logo)
				{
					if (is_readable($logo))
					{
						$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
					}
					else
					{
						$pdf->SetTextColor(200,0,0);
						$pdf->SetFont('','B', $default_font_size - 2);
						$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
						$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
					}
				}

				// Nom emetteur
				$posy=40;
				$hautcadre=40;
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','', $default_font_size - 2);

				$pdf->SetXY($this->marge_gauche,$posy);
				$pdf->SetFillColor(230,230,230);
				$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);


				$pdf->SetXY($this->marge_gauche+2,$posy+3);

				// Sender name
				$pdf->SetTextColor(0,0,60);
				$pdf->SetFont('','B', $default_font_size);
				$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

				// Sender properties
				$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

				$pdf->SetFont('','', $default_font_size - 1);
				$pdf->SetXY($this->marge_gauche+2,$posy+9);
				$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');

				$object=$fichinter;

				// Recipient name
				if (! empty($usecontact))
				{
					// On peut utiliser le nom de la societe du contact
					if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
					else $socname = $object->client->nom;
					$carac_client_name=$outputlangs->convToOutputCharset($socname);
				}
				else
				{
					$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
				}

				$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

				// Client destinataire
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','B', $default_font_size);
				$fichinter->fetch_thirdparty();
				$pdf->SetXY(102,42);
				$pdf->MultiCell(86,4, $carac_client_name, 0, 'L');
				$pdf->SetFont('','', $default_font_size - 1);
				$pdf->SetXY(102,$pdf->GetY());
				$pdf->MultiCell(66,4, $carac_client, 0, 'L');
				$pdf->rect(100, 40, 100, 40);


				$pdf->SetTextColor(0,0,100);
				$pdf->SetFont('','B', $default_font_size + 2);
				$pdf->SetXY(10,86);
				$pdf->MultiCell(120, 4, $outputlangs->transnoentities("InterventionCard")." : ".$outputlangs->convToOutputCharset($fichinter->ref), 0, 'L');

				$pdf->SetFillColor(220,220,220);
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','', $default_font_size);


				$tab_top = 100;
				$tab_top_newpage = 50;
				$tab_height = 110;
				$tab_height_newpage = 150;

				// Affiche notes
				if (! empty($fichinter->note_public))
				{
					$tab_top = 98;

					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
					$pdf->SetXY ($this->posxdesc-1, $tab_top);
					$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fichinter->note_public), 0, 'L');
					$nexY = $pdf->GetY();
					$height_note=$nexY-$tab_top;

					// Rect prend une longueur en 3eme param
					$pdf->SetDrawColor(192,192,192);
					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);

					$tab_height = $tab_height - $height_note;
					$tab_top = $nexY+6;
				}
				else
				{
					$height_note=0;
				}

				$pdf->SetXY (10, $tab_top);
				$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
				$pdf->line(10, $tab_top + 8, 200, $tab_top + 8 );

				$pdf->SetFont('','', $default_font_size - 1);

				$pdf->MultiCell(0, 3, '');		// Set interline to 3
				$pdf->SetXY (10, $tab_top + 8 );
				$desc=dol_htmlentitiesbr($fichinter->description,1);
				//print $outputlangs->convToOutputCharset($desc); exit;
				$pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
				$nexY = $pdf->GetY();

				$pdf->line(10, $nexY, 200, $nexY);

				$pdf->MultiCell(0, 3, '');		// Set interline to 3. Then writeMultiCell must use 3 also.

				//dol_syslog("desc=".dol_htmlentitiesbr($fichinter->description));
				$nblignes = sizeof($fichinter->lines);

				$curY = $pdf->GetY();
				$nexY = $pdf->GetY();

				// Loop on each lines
				for ($i = 0 ; $i < $nblignes ; $i++)
				{
					$fichinterligne = $fichinter->lines[$i];

					$valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0;
					if ($valide>0)
					{
						$curY = $nexY+3;

						$pdf->SetXY (10, $curY);
						$pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY,
						dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($fichinterligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration),1,$outputlangs->charset_output), 0, 1, 0);
						$nexY = $pdf->GetY();

						$pdf->SetXY (10, $curY + 3);
						$desc = dol_htmlentitiesbr($fichinterligne->desc,1);
						$pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY + 3, $desc, 0, 1, 0);
						$nexY+=dol_nboflines_bis($fichinterligne->desc,52,$outputlangs->charset_output)*3;
					}
				}
				//$pdf->line(10, $tab_top+$tab_height+3, 200, $tab_top+$tab_height+3);

				// Rectangle for title and all lines
				$pdf->Rect(10, $tab_top, 190, $tab_height+3);
				$pdf->SetXY (10, $pdf->GetY() + 20);
				$pdf->MultiCell(60, 5, '', 0, 'J', 0);

				$pdf->SetXY(20,220);
				$pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);

				$pdf->SetXY(20,225);
				$pdf->MultiCell(80,30, '', 1);

				$pdf->SetXY(110,220);
				$pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);

				$pdf->SetXY(110,225);
				$pdf->MultiCell(80,30, '', 1);

				$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut

				$this->_pagefoot($pdf,$fichinter,$outputlangs);
				$pdf->AliasNbPages();

				$pdf->Close();

				$pdf->Output($file,'F');
				if (! empty($conf->global->MAIN_UMASK))
				@chmod($file, octdec($conf->global->MAIN_UMASK));

				return 1;
			}
			else
			{
				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
				return 0;
			}
		}
		else
		{
			$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
			return 0;
		}
		$this->error=$langs->trans("ErrorUnknown");
		return 0;   // Erreur par defaut
	}
	function _pagehead(&$pdf, $object, $showadress=0, $outputlangs)
	{
		global $langs,$conf;
		$langs->load("main");
		$langs->load("bills");
		$langs->load("propal");
		$langs->load("companies");

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
		}

		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B',$default_font_size + 3);

		$pdf->SetXY($this->marges['g'],6);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$taille=getimagesize($logo);
				$length=$taille[0]/2.835;
				$pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}


		/*
		 * Emetteur
		 */
		$posy=$this->marges['h']+24;
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','', $default_font_size - 2);
		$pdf->SetXY($this->marges['g'],$posy-5);


		$pdf->SetXY($this->marges['g'],$posy);
		$pdf->SetFillColor(255,255,255);
		$pdf->MultiCell(82, 34, "", 0, 'R', 1);


		$pdf->SetXY($this->marges['g'],$posy+4);

		// Sender name
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

		// Sender properties
		$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY($this->marge_gauche,$posy+9);
		$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


		// Client destinataire
		$posy=45;
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','', $default_font_size - 2);
		$pdf->SetXY($this->marges['g']+100,$posy-5);
		$pdf->SetFont('','B',$default_font_size);

		// If BILLING contact defined on invoice, we use it
		$usecontact=false;
		$arrayidcontact=$object->getIdContact('external','BILLING');
		if (sizeof($arrayidcontact) > 0)
		{
			$usecontact=true;
			$result=$object->fetch_contact($arrayidcontact[0]);
		}

		// Recipient name
		if (! empty($usecontact))
		{
			// On peut utiliser le nom de la societe du contact
			if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
			else $socname = $object->client->nom;
			$carac_client_name=$outputlangs->convToOutputCharset($socname);
		}
		else
		{
			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
		}

		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

		// Show customer/recipient
		$pdf->SetFont('','B', $default_font_size);
		$pdf->SetXY($this->marges['g']+100,$posy+4);
		$pdf->MultiCell(86,4, $carac_client_name, 0, 'L');

		$pdf->SetFont('','B', $default_font_size - 1);
		$pdf->SetXY($this->marges['g']+100,$posy+8);
		$pdf->MultiCell(86,4, $carac_client, 0, 'L');

		/*
		 * ref facture
		 */
		$posy=70;
		$pdf->SetFont('','B', $default_font_size + 3);
		$pdf->SetXY($this->marges['g'],$posy-5);
		$pdf->SetTextColor(0,0,0);
		$title=$outputlangs->transnoentities("Invoice");
		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma");
		$pdf->MultiCell(100, 10, $title.' '.$outputlangs->transnoentities("Of").' '.dol_print_date($object->date,"day",false,$outputlangs,true), '' , 'L');
		$pdf->SetFont('','B', $default_font_size + 1);
		$pdf->SetXY($this->marges['g'],$posy);
		$pdf->SetTextColor(22,137,210);
		$pdf->MultiCell(100, 10, $outputlangs->transnoentities("RefBill")." : " . $outputlangs->transnoentities($object->ref), '', 'L');
		$pdf->SetTextColor(0,0,0);
		$posy+=4;

		$objectidnext=$object->getIdReplacingInvoice('validated');
		if ($object->type == 0 && $objectidnext)
		{
			$objectreplacing=new Facture($this->db);
			$objectreplacing->fetch($objectidnext);

			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'L');
		}
		if ($object->type == 1)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
		}
		if ($object->type == 2)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
		}

		if ($object->type != 2)
		{
			$posy+=5;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'L');
		}

		if ($object->client->code_client)
		{
			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'L');
		}

		// Add list of linked orders and proposals
		// TODO mutualiser
	    $object->fetchObjectLinked();

	    foreach($object->linkedObjects as $objecttype => $objects)
	    {
	    	if ($objecttype == 'propal')
	    	{
	    		$outputlangs->load('propal');
	    		$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY($this->marges['g'],$posy);
	    			$pdf->SetFont('','', $default_font_size - 1);
	    			$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref));
	    		}
			}
			else if ($objecttype == 'commande')
			{
				$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY($this->marges['g'],$posy);
					$pdf->SetFont('','', $default_font_size - 1);
					$text=$objects[$i]->ref;
					if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
					$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text));
	    		}
			}
		}

		// Amount in (at tab_top - 1)
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','', $default_font_size);
		$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie));
        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), 90);
        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
	}
Example #10
0
	/**
	 *   	\brief      Show header of page
	 *      \param      pdf             Object PDF
	 *      \param      object          Object invoice
	 *      \param      showaddress     0=no, 1=yes
	 *      \param      outputlangs		Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs;

		$outputlangs->load("main");
		$outputlangs->load("bills");
		$outputlangs->load("propal");
		$outputlangs->load("companies");

		$default_font_size = pdf_getPDFFontSize($outputlangs);

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

        if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
        {
		      pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
        }

		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);	// width=0 (auto), max height=24
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B',$default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		$pdf->SetFont('','B', $default_font_size + 3);
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$title=$outputlangs->transnoentities("Invoice");
		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat");
		$pdf->MultiCell(100, 4, $title, '' , 'R');

		$pdf->SetFont('','B', $default_font_size + 2);

		$posy+=6;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');

		$posy+=2;
		$pdf->SetFont('','', $default_font_size - 1);

		$objectidnext=$object->getIdReplacingInvoice('validated');
		if ($object->type == 0 && $objectidnext)
		{
			$objectreplacing=new Facture($this->db);
			$objectreplacing->fetch($objectidnext);

			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
		}
		if ($object->type == 1)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
		}
		if ($object->type == 2)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
		}

		$posy+=4;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R');

		if ($object->type != 2)
		{
			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R');
		}

		if ($object->client->code_client)
		{
			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}

		// Add list of linked orders and proposals
		// TODO mutualiser
	    $object->fetchObjectLinked();

	    foreach($object->linkedObjects as $objecttype => $objects)
	    {
	    	if ($objecttype == 'propal')
	    	{
	    		$outputlangs->load('propal');
	    		$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY(100,$posy);
	    			$pdf->SetFont('','', $default_font_size - 1);
	    			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R');
	    		}
			}
			else if ($objecttype == 'commande')
			{
				$outputlangs->load('orders');
				$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY(100,$posy);
	    			$pdf->SetFont('','', $default_font_size - 1);
	    			$text=$objects[$i]->ref;
	    			if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
	    			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
	    		}
	    	}
		}

		if ($showaddress)
		{
			// Sender properties
			$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

			// Show sender
			$posy=42;
			$posx=$this->marge_gauche;
			$hautcadre=40;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;

			// Show sender frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
			$pdf->SetXY($posx,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
			$pdf->SetTextColor(0,0,60);

			// Show sender name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

			// Show sender information
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');



			// If BILLING contact defined on invoice, we use it
			$usecontact=false;
			$arrayidcontact=$object->getIdContact('external','BILLING');
			if (sizeof($arrayidcontact) > 0)
			{
				$usecontact=true;
				$result=$object->fetch_contact($arrayidcontact[0]);
			}

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show recipient
			$posy=42;
			$posx=100;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

			// Show recipient frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx+2,$posy-5);
			$pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":",0,'L');
			$pdf->rect($posx, $posy, 100, $hautcadre);

			// Show recipient name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			// Show recipient information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
		}
	}
Example #11
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @param	object		$hookmanager	Hookmanager object
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
 {
     global $conf, $langs, $mysoc;
     $langs->load("orders");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     if ($showaddress) {
         $posy = 40;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         $pdf->SetXY($posx, $posy + 3);
         // Sender name
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx, $posy + 7);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // Client destinataire
         $client = new Societe($this->db);
         $client->fetch($object->socid);
         $object->client = $client;
         // If CUSTOMER contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show recipient
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - 100;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, 100, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
     $curY = 80;
     $posy = $curY;
     // Date - order
     $pdf->SetTextColor(200, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size + 1);
     $pdf->SetXY(11, $posy);
     $posy += 6;
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date, 'day', false, $outputlangs), 0, 'L');
     $pdf->SetXY(11, $posy);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order") . " " . $outputlangs->convToOutputCharset($object->ref), 0, 'L');
     $posy += 1;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
 }
    /**
     *      Show header of document
     *      @param      pdf             Object PDF
     *      @param      object          Object commercial proposal
     *      @param      showaddress     0=no, 1=yes
     *      @param      outputlangs     Object lang for output
     */
	function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
	{
		global $conf,$langs;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && ! empty($conf->global->PROPALE_DRAFT_WATERMARK))
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
		}

		$posy=42;

		$pdf->SetXY($this->marge_gauche+2,$posy);

		// Sender name
		$pdf->SetTextColor(0,0,00);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

		// Sender properties
		$carac_emetteur='';
	 	// Add internal contact of proposal if defined
		$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
	 	if (sizeof($arrayidcontact) > 0)
	 	{
	 		$object->fetch_user($arrayidcontact[0]);
	 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
	 	}

	 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);

		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY($this->marge_gauche+2,$posy+4);
		$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


		$pdf->rect(10, 40, 80, 40);

		$pdf->SetXY(10,5);
		$pdf->SetFont('','B', $default_font_size + 6);
		$pdf->SetTextColor(0,0,200);
		$pdf->MultiCell(200, 20, $outputlangs->transnoentities("CommercialProposal"), '' , 'C');

		// Cadre client destinataire
		$pdf->rect(100, 40, 100, 40);

		$pdf->SetTextColor(200,0,0);
		$pdf->SetFont('','B', $default_font_size + 2);

		$pdf->rect(10, 90, 100, 10);
		$pdf->rect(110, 90, 90, 10);

		$pdf->SetXY(10,90);
		$pdf->MultiCell(110, 10, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
		$pdf->SetXY(110,90);
		$pdf->MultiCell(100, 10, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs,true), 0, 'L');

		$posy=15;
		$pdf->SetFont('','', $default_font_size);

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');

		if ($object->ref_client)
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
		}

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');

		if ($object->client->code_client)
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}

		$posy=39;

		$pdf->SetTextColor(0,0,0);

		// If CUSTOMER contact defined, we use it
		$usecontact=false;
		$arrayidcontact=$object->getIdContact('external','CUSTOMER');
		if (sizeof($arrayidcontact) > 0)
		{
			$usecontact=true;
			$result=$object->fetch_contact($arrayidcontact[0]);
		}

		// Recipient name
		if (! empty($usecontact))
		{
			// On peut utiliser le nom de la societe du contact
			if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
			else $socname = $object->client->nom;
			$carac_client_name=$outputlangs->convToOutputCharset($socname);
		}
		else
		{
			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
		}

		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

		// Show recipient
		$pdf->SetXY(102,$posy+3);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

		// Show address
		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY(102,$posy+8);
		$pdf->MultiCell(86,4, $carac_client, 0, 'L');
	}
Example #13
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @param	object		$hookmanager	Hookmanager object
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
 {
     global $langs, $conf;
     $langs->load("main");
     $langs->load("bills");
     $langs->load("propal");
     $langs->load("companies");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->FACTURE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($this->marges['g'], 6);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         // Show sender
         $posy = 30;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         //$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Show sender information
         $pdf->SetXY($posx + 2, $posy + 8);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If BILLING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'BILLING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show recipient
         $posy = 30;
         $posx = $this->page_largeur - $this->marge_droite - 100;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, 100, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
     /*
      * ref facture
      */
     $posy = 78;
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($this->marges['g'], $posy - 5);
     $pdf->SetTextColor(0, 0, 0);
     $title = $outputlangs->transnoentities("Invoice");
     if ($object->type == 1) {
         $title = $outputlangs->transnoentities("InvoiceReplacement");
     }
     if ($object->type == 2) {
         $title = $outputlangs->transnoentities("InvoiceAvoir");
     }
     if ($object->type == 3) {
         $title = $outputlangs->transnoentities("InvoiceDeposit");
     }
     if ($object->type == 4) {
         $title = $outputlangs->transnoentities("InvoiceProForma");
     }
     $pdf->MultiCell(100, 10, $title . ' ' . $outputlangs->transnoentities("Of") . ' ' . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'L');
     $pdf->SetFont('', 'B', $default_font_size);
     $pdf->SetXY($this->marges['g'], $posy);
     $pdf->SetTextColor(22, 137, 210);
     $pdf->MultiCell(100, 10, $outputlangs->transnoentities("RefBill") . " : " . $outputlangs->transnoentities($object->ref), '', 'L');
     $pdf->SetTextColor(0, 0, 0);
     $objectidnext = $object->getIdReplacingInvoice('validated');
     if ($object->type == 0 && $objectidnext) {
         $objectreplacing = new Facture($this->db);
         $objectreplacing->fetch($objectidnext);
         $posy += 4;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplacing->ref), '', 'L');
     }
     if ($object->type == 1) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 4;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
     }
     if ($object->type == 2) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 4;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
     }
     $posy += 1;
     if ($object->type != 2) {
         $posy += 3;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance") . " : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'L');
     }
     if ($object->client->code_client) {
         $posy += 3;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'L');
     }
     $posy += 1;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
     // Amount in (at tab_top - 1)
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size - 1);
     $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency));
     $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), 90);
     $pdf->MultiCell($pdf->GetStringWidth($titre) + 3, 2, $titre);
 }
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager;
     $outputlangs->load("main");
     $outputlangs->load("trips");
     $outputlangs->load("companies");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     /*
     // ajout du fondu vert en bas de page à droite
     $image_fondue = $conf->mycompany->dir_output.'/fondu_vert_.jpg';
     $pdf->Image($image_fondue,20,107,200,190);
     
     pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
     */
     // Draft watermark
     if ($object->fk_statut == 1 && !empty($conf->global->EXPENSEREPORT_FREE_TEXT)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_FREE_TEXT);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 4);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans("ExpenseReport"), 0, 'L');
     $pdf->SetFont('', '', $default_font_size - 1);
     // Ref complete
     $posy += 8;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref") . " : " . $object->ref, '', 'L');
     // Date start period
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart") . " : " . ($object->date_debut > 0 ? dol_print_date($object->date_debut, "day", false, $outpulangs) : ''), '', 'L');
     // Date end period
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd") . " : " . ($object->date_fin > 0 ? dol_print_date($object->date_fin, "day", false, $outpulangs) : ''), '', 'L');
     // Status Expense Report
     $posy += 6;
     $pdf->SetXY($posx, $posy);
     $pdf->SetFont('', 'B', 18);
     $pdf->SetTextColor(111, 81, 124);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $object->getLibStatut(0), '', 'R');
     // Sender properties
     $carac_emetteur = '';
     $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->convToOutputCharset($this->emetteur->address);
     $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->convToOutputCharset($this->emetteur->zip) . ' ' . $outputlangs->convToOutputCharset($this->emetteur->town);
     $carac_emetteur .= "\n";
     // Phone
     if ($this->emetteur->phone) {
         $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Phone") . " : " . $outputlangs->convToOutputCharset($this->emetteur->phone);
     }
     // Fax
     if ($this->emetteur->fax) {
         $carac_emetteur .= ($carac_emetteur ? $this->emetteur->tel ? " - " : "\n" : '') . $outputlangs->transnoentities("Fax") . " : " . $outputlangs->convToOutputCharset($this->emetteur->fax);
     }
     // EMail
     if ($this->emetteur->email) {
         $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Email") . " : " . $outputlangs->convToOutputCharset($this->emetteur->email);
     }
     // Web
     if ($this->emetteur->url) {
         $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Web") . " : " . $outputlangs->convToOutputCharset($this->emetteur->url);
     }
     // Show sender
     $posy = 50;
     $posx = $this->marge_gauche;
     $hautcadre = 40;
     if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
         $posx = 118;
     }
     // Show sender frame
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size - 2);
     $pdf->SetXY($posx, $posy - 5);
     $pdf->MultiCell(66, 5, $outputlangs->transnoentities("TripSociete") . " :", '', 'L');
     $pdf->SetXY($posx, $posy);
     $pdf->SetFillColor(224, 224, 224);
     $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
     $pdf->SetTextColor(0, 0, 60);
     // Show sender name
     $pdf->SetXY($posx + 2, $posy + 3);
     $pdf->SetFont('', 'B', $default_font_size);
     $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
     // Show sender information
     $pdf->SetXY($posx + 2, $posy + 8);
     $pdf->SetFont('', '', $default_font_size - 1);
     $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
     // Show recipient
     $posy = 50;
     $posx = 100;
     // Show recipient frame
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', 'B', 8);
     $pdf->SetXY($posx, $posy - 5);
     $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF") . " :", 0, 'L');
     $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
     // Informations for trip (dates and users workflow)
     if ($object->fk_user_author > 0) {
         $userfee = new User($this->db);
         $userfee->fetch($object->fk_user_author);
         $posy += 3;
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', 10);
         $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
         $posy += 5;
         $pdf->SetXY($posx + 2, $posy);
         $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation") . " : " . dol_print_date($object->date_create, "day", false, $outpulangs), 0, 'L');
     }
     if ($object->fk_statut == 99) {
         if ($object->fk_user_refuse > 0) {
             $userfee = new User($this->db);
             $userfee->fetch($object->fk_user_refuse);
             $posy += 6;
             $pdf->SetXY($posx + 2, $posy);
             $pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
             $posy += 5;
             $pdf->SetXY($posx + 2, $posy);
             $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_REFUS") . " : " . $outputlangs->convToOutputCharset($object->detail_refuse), 0, 'L');
             $posy += 5;
             $pdf->SetXY($posx + 2, $posy);
             $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS") . " : " . dol_print_date($object->date_refuse, "day", false, $outpulangs), 0, 'L');
         }
     } else {
         if ($object->fk_statut == 4) {
             if ($object->fk_user_cancel > 0) {
                 $userfee = new User($this->db);
                 $userfee->fetch($object->fk_user_cancel);
                 $posy += 6;
                 $pdf->SetXY($posx + 2, $posy);
                 $pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
                 $posy += 5;
                 $pdf->SetXY($posx + 2, $posy);
                 $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_CANCEL") . " : " . $outputlangs->convToOutputCharset($object->detail_cancel), 0, 'L');
                 $posy += 5;
                 $pdf->SetXY($posx + 2, $posy);
                 $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_CANCEL") . " : " . dol_print_date($object->date_cancel, "day", false, $outpulangs), 0, 'L');
             }
         } else {
             if ($object->fk_user_approve > 0) {
                 $userfee = new User($this->db);
                 $userfee->fetch($object->fk_user_approve);
                 $posy += 6;
                 $pdf->SetXY($posx + 2, $posy);
                 $pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
                 $posy += 5;
                 $pdf->SetXY($posx + 2, $posy);
                 $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateApprove") . " : " . dol_print_date($object->date_approve, "day", false, $outpulangs), 0, 'L');
             }
         }
     }
     if ($object->fk_statut == 6) {
         if ($object->fk_user_paid > 0) {
             $userfee = new User($this->db);
             $userfee->fetch($object->fk_user_paid);
             $posy += 6;
             $pdf->SetXY($posx + 2, $posy);
             $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
             $posy += 5;
             $pdf->SetXY($posx + 2, $posy);
             $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_PAIEMENT") . " : " . dol_print_date($object->date_paiement, "day", false, $outpulangs), 0, 'L');
         }
     }
 }
	/**
	 *   	Show header of document
	 *   	@param      pdf     		Object PDF
	 *   	@param      object			Object commercial proposal
	 *      @param      showaddress     0=no, 1=yes
	 *      @param      outputlangs    	Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		$outputlangs->load("main");
		$outputlangs->load("bills");
		$outputlangs->load("propal");
		$outputlangs->load("companies");

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
		}

		//Prepare la suite
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B',$default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		$pdf->SetFont('','B',$default_font_size + 3);
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$title=$outputlangs->transnoentities("CommercialProposal");
		$pdf->MultiCell(100, 4, $title, '' , 'R');

		$pdf->SetFont('','B',$default_font_size + 2);

		$posy+=6;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');

		$posy+=1;
		$pdf->SetFont('','', $default_font_size);

		if ($object->ref_client)
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
		}

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');

		if ($object->client->code_client)
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}

		if ($showaddress)
		{
			// Sender properties
			$carac_emetteur='';
		 	// Add internal contact of proposal if defined
			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
		 	if (sizeof($arrayidcontact) > 0)
		 	{
		 		$object->fetch_user($arrayidcontact[0]);
		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
		 	}

		 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);

			// Show sender
			$posx=$this->marge_gauche;
			$posy=42;
			$hautcadre=40;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;

			// Show sender frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
			$pdf->SetXY($posx,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);

			// Show sender name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFont('','B',$default_font_size);
			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

			// Show sender information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


			// If CUSTOMER contact defined, we use it
			$usecontact=false;
			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
			if (sizeof($arrayidcontact) > 0)
			{
				$usecontact=true;
				$result=$object->fetch_contact($arrayidcontact[0]);
			}

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show recipient
			$posy=42;
			$posx=100;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

			// Show recipient frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(80, 4, $outputlangs->transnoentities("BillTo").":", 0, 'L');
			$pdf->rect($posx, $posy, 100, $hautcadre);
			$pdf->SetTextColor(0,0,0);

			// Show recipient name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			// Show recipient information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
		}
	}
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->FACTURE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $w = 110;
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - $w;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("Invoice");
     if ($object->type == 1) {
         $title = $outputlangs->transnoentities("InvoiceReplacement");
     }
     if ($object->type == 2) {
         $title = $outputlangs->transnoentities("InvoiceAvoir");
     }
     if ($object->type == 3) {
         $title = $outputlangs->transnoentities("InvoiceDeposit");
     }
     if ($object->type == 4) {
         $title = $outputlangs->transnoentities("InvoiceProFormat");
     }
     $pdf->MultiCell($w, 3, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size - 2);
     if ($object->ref_client) {
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
     }
     $objectidnext = $object->getIdReplacingInvoice('validated');
     if ($object->type == 0 && $objectidnext) {
         $objectreplacing = new Facture($this->db);
         $objectreplacing->fetch($objectidnext);
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
     }
     if ($object->type == 1) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
     }
     if ($object->type == 2 && !empty($object->fk_facture_source)) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
     }
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice") . " : " . dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
     if ($object->type != 2) {
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateEcheance") . " : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
     }
     if ($object->thirdparty->code_client) {
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
     }
     $posy += 1;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
         $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
         // If BILLING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'BILLING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         //Recipient name
         // On peut utiliser le nom de la societe du contact
         if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
             $thirdparty = $object->contact;
         } else {
             $thirdparty = $object->client;
         }
         $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
         $posy = $pdf->getY();
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 0);
 }
 function _pagehead(&$pdf, $object, $showaddress = 1, $outputlangs)
 {
     global $conf, $langs;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->PROPALE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
     }
     //Prepare la suite
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     //$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
     //		if ($this->emetteur->logo)
     //		{
     //			if (is_readable($logo))
     //			{
     //				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
     //			}
     //			else
     //			{
     //				$pdf->SetTextColor(200,0,0);
     //				$pdf->SetFont('','B',$default_font_size - 2);
     //				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
     //				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
     //			}
     //		}
     //		else
     //		{
     //			$text=$this->emetteur->name;
     //			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     /*}*/
     //		$pdf->SetFont('','B',$default_font_size + 3);
     //		$pdf->SetXY(100,$posy);
     //		$pdf->SetTextColor(0,0,60);
     //		$title=$outputlangs->transnoentities("CommercialProposal");
     //		$pdf->MultiCell(100, 4, $title, '' , 'R');
     //		$posy+=1;
     //		$pdf->SetFont('','', $default_font_size);
     //		if ($object->ref_client)
     //		{
     //			$posy+=5;
     //			$pdf->SetXY(100,$posy);
     //			$pdf->SetTextColor(0,0,60);
     //			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
     //		}
     //		$posy+=5;
     //		$pdf->SetXY(100,$posy);
     //		$pdf->SetTextColor(0,0,60);
     //		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
     //
     //		$posy+=5;
     //		$pdf->SetXY(100,$posy);
     //		$pdf->SetTextColor(0,0,60);
     //		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
     //código do orçamento
     $pdf->SetFont('', 'B', $default_font_size - 2);
     $posy -= 4;
     $pdf->SetXY(102, $posy - 2);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($object->ref), '', 'R');
     //código do cliente, se houver
     if ($object->client->code_client) {
         $pdf->SetXY(102, $posy - 5.5);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     //diminuir a fonte para o nome caber mais
     $pdf->SetFont('', 'N', $default_font_size - 3);
     //nome do edifício
     $pdf->SetXY(5, $posy + 6);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset(substr($object->client->nom, 0, 48)), '', 'L');
     //nome do solicitante
     $pdf->SetXY(74, $posy + 6);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset(substr($object->client->siret, 0, 60)), '', 'L');
     //status do solicitante
     $pdf->SetFont('', 'N', $default_font_size - 2);
     $pdf->SetXY(172, $posy + 6);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->idprof4), '', 'L');
     //veículo informaçao = reduzir a letra
     $pdf->SetFont('', 'N', $default_font_size - 3);
     $pdf->SetXY(5, $posy + 13.5);
     $pdf->MultiCell(50, 3, $outputlangs->convToOutputCharset(substr($object->client->como_conheceu, 0, 25)), '', 'L');
     //tel 1
     $pdf->SetFont('', 'N', $default_font_size - 1);
     $pdf->SetXY(38, $posy + 13.4);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->tel1_soli), '', 'L');
     //tel 2
     $pdf->SetXY(69, $posy + 13.4);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->tel2_soli), '', 'L');
     //tel celular
     //		$pdf->SetXY(5,$posy+21);
     //		$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->rua), '', 'L');
     //email
     $pdf->SetXY(135, $posy + 13);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->email_2), '', 'L');
     //rua
     $pdf->SetXY(5, $posy + 20);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->rua), '', 'L');
     //número
     $pdf->SetXY(91, $posy + 20);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->numero), '', 'L');
     //apto = complemento, diminuir a fonte
     $pdf->SetFont('', 'N', $default_font_size - 4);
     $pdf->SetXY(107, $posy + 20.5);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->complemento), '', 'L');
     //bairro
     $pdf->SetFont('', 'N', $default_font_size - 1);
     $pdf->SetXY(124, $posy + 20);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->bairro), '', 'L');
     //numero apartamentos/unidades
     $pdf->SetXY(163, $posy + 19.6);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->ape), '', 'L');
     //numero pavimentos
     $pdf->SetXY(188, $posy + 19.6);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->siren), '', 'L');
     //ponto de referencia
     $pdf->SetXY(5, $posy + 27);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($object->client->ponto_ref), '', 'L');
     //data visita
     $pdf->SetXY(151, $posy + 26.5);
     $time_span = strtotime(substr($object->data_hora_visita, 0, 10));
     $data_visita = gmdate('d/m/Y', $time_span);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($data_visita), '', 'L');
     //hora da visita
     $pdf->SetXY(178, $posy + 26.5);
     $hora_visita = substr($object->data_hora_visita, 10, 100);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($hora_visita), '', 'L');
     //assunto = tipo de obra tipo_obr
     $pdf->SetFont('', 'N', $default_font_size - 3);
     $pdf->SetXY(5, $posy + 34);
     //limitando o tamanho do assunto em 140 caracteres
     $pdf->MultiCell(170, 3, $outputlangs->convToOutputCharset(substr($object->tipo_obr, 0, 140)), '', 'L');
     //CNPJ ? - marca com um X se no cadastro de clientes tiver sido informado que o cliente tem CNPJ
     if (isset($object->client->cpf_cnpj)) {
         $pdf->SetFont('', 'N', $default_font_size + 6);
         $pdf->SetXY(189, $posy + 32);
         $pdf->MultiCell(100, 3, "X", '', 'L');
     }
     //rodapé
     //data visita
     $pdf->SetFont('', 'N', $default_font_size);
     $pdf->SetXY(105, $posy - 18);
     $time_span = strtotime(substr($object->data_hora_visita, 0, 10));
     $data_visita = gmdate('d/m/Y', $time_span);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($data_visita), '', 'L');
     //hora da visita
     $pdf->SetXY(131, $posy - 18);
     $hora_visita = substr($object->data_hora_visita, 10, 100);
     $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($hora_visita), '', 'L');
     //código do cliente, se houver
     if ($object->client->code_client) {
         $pdf->SetXY(79, $posy - 18);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     //código do orçamento
     $pdf->SetXY(106, $posy - 18);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($object->ref), '', 'R');
     /*if ($showaddress)
     		{
     			// Sender properties
     			$carac_emetteur='';
     		 	// Add internal contact of proposal if defined
     			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
     		 	if (sizeof($arrayidcontact) > 0)
     		 	{
     		 		$object->fetch_user($arrayidcontact[0]);
     		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
     		 	}
     
     		 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
     
     			// Show sender
     			$posx=$this->marge_gauche;
     			$posy=42;
     			$hautcadre=40;
     			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;
     
     			// Show sender frame
     			$pdf->SetTextColor(0,0,0);
     			$pdf->SetFont('','', $default_font_size - 2);
     			$pdf->SetXY($posx,$posy-5);
     			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
     			$pdf->SetXY($posx,$posy);
     			$pdf->SetFillColor(230,230,230);
     			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);*/
     // Show sender name
     //			$pdf->SetXY($posx+2,$posy+3);
     //			$pdf->SetTextColor(0,0,60);
     //			$pdf->SetFont('','B',$default_font_size);
     //			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
     //
     //			// Show sender information
     //			$pdf->SetFont('','', $default_font_size - 1);
     //			$pdf->SetXY($posx+2,$posy+8);
     //			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
     // If CUSTOMER contact defined, we use it
     /*	$usecontact=false;
     			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
     			if (sizeof($arrayidcontact) > 0)
     			{
     				$usecontact=true;
     				$result=$object->fetch_contact($arrayidcontact[0]);
     			}
     
     			// Recipient name
     			if (! empty($usecontact))
     			{
     				// On peut utiliser le nom de la societe du contact
     				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
     				else $socname = $object->client->nom;
     				$carac_client_name=$outputlangs->convToOutputCharset($socname);
     			}
     			else
     			{
     				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
     			}*/
     //			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
     // Show recipient
     //			$posy=42;
     //			$posx=100;
     //			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
     //
     //			// Show recipient frame
     //			$pdf->SetTextColor(0,0,0);
     //			$pdf->SetFont('','', $default_font_size - 2);
     //			$pdf->SetXY($posx,$posy-5);
     //			$pdf->MultiCell(80, 4, $outputlangs->transnoentities("BillTo").":", 0, 'L');
     //			$pdf->rect($posx, $posy, 100, $hautcadre);
     //			$pdf->SetTextColor(0,0,0);
     //
     //			// Show recipient name
     //			$pdf->SetXY($posx+2,$posy+3);
     //			$pdf->SetFont('','B', $default_font_size);
     //			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');
     //
     //			// Show recipient information
     //			$pdf->SetFont('','', $default_font_size - 1);
     //			$pdf->SetXY($posx+2,$posy+8);
     //			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
     //		}
 }