PageRenderTime 149ms CodeModel.GetById 60ms app.highlight 35ms RepoModel.GetById 46ms app.codeStats 0ms

/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php

https://github.com/asterix14/dolibarr
PHP | 665 lines | 406 code | 116 blank | 143 comment | 43 complexity | edc8f4f0f7185c1f257ff4abb16afe09 MD5 | raw file
  1<?php
  2/* Copyright (C) 2004-2008 Laurent Destailleur   <eldy@users.sourceforge.net>
  3 * Copyright (C) 2005-2009 Regis Houssin         <regis@dolibarr.fr>
  4 * Copyright (C) 2007      Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
  5 * Copyright (C) 2008      Chiptronik
  6
  7 * This program is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License as published by
  9 * the Free Software Foundation; either version 2 of the License, or
 10 * (at your option) any later version.
 11 *
 12 * This program is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 * GNU General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 19 * or see http://www.gnu.org/
 20 */
 21
 22/**
 23 *	\file       htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
 24 *	\ingroup    livraison
 25 *	\brief      File of class to manage receving receipts with template Typhon
 26 *	\author	    Laurent Destailleur
 27 */
 28
 29require_once(DOL_DOCUMENT_ROOT."/core/modules/livraison/modules_livraison.php");
 30require_once(DOL_DOCUMENT_ROOT."/livraison/class/livraison.class.php");
 31require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
 32require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
 33
 34
 35/**
 36 *	\class      pdf_typhon
 37 *	\brief      Classe permettant de generer les bons de livraison au modele Typho
 38 */
 39
 40class pdf_typhon extends ModelePDFDeliveryOrder
 41{
 42	var $emetteur;	// Objet societe qui emet
 43
 44	/**
 45	 *	Constructor
 46	 *
 47	 *  @param		DoliDB		$DB      Database handler
 48	 */
 49	function pdf_typhon($db)
 50	{
 51		global $conf,$langs,$mysoc;
 52
 53		$langs->load("main");
 54		$langs->load("bills");
 55		$langs->load("sendings");
 56		$langs->load("companies");
 57
 58		$this->db = $db;
 59		$this->name = "typhon";
 60		$this->description = $langs->trans("DocumentModelTyphon");
 61
 62		// Dimension page pour format A4
 63		$this->type = 'pdf';
 64		$formatarray=pdf_getFormat();
 65		$this->page_largeur = $formatarray['width'];
 66		$this->page_hauteur = $formatarray['height'];
 67		$this->format = array($this->page_largeur,$this->page_hauteur);
 68		$this->marge_gauche=10;
 69		$this->marge_droite=10;
 70		$this->marge_haute=10;
 71		$this->marge_basse=10;
 72
 73		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
 74		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
 75		$this->option_codeproduitservice = 1;      // Affiche code produit-service
 76
 77		$this->franchise=!$mysoc->tva_assuj;
 78
 79		// Recupere emmetteur
 80		$this->emetteur=$mysoc;
 81		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'�tait pas d�fini
 82
 83		// Defini position des colonnes
 84		$this->posxdesc=$this->marge_gauche+1;
 85		$this->posxcomm=120;
 86		//$this->posxtva=111;
 87		$this->posxup=132;
 88		$this->posxqty=168;
 89		$this->posxdiscount=162;
 90		$this->postotalht=177;
 91
 92		$this->tva=array();
 93		$this->atleastoneratenotnull=0;
 94		$this->atleastonediscount=0;
 95	}
 96
 97
 98	/**
 99	 *	Fonction generant le bon de livraison sur le disque
100	 *	@param	    object   		Object livraison a generer
101	 *	@param		outputlangs		Lang output object
102	 *	@return	    int         	1 if OK, <=0 if KO
103	 */
104	function write_file($object,$outputlangs)
105	{
106		global $user,$langs,$conf;
107		$default_font_size = pdf_getPDFFontSize($outputlangs);
108
109		if (! is_object($outputlangs)) $outputlangs=$langs;
110		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
111		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
112
113		$outputlangs->load("main");
114		$outputlangs->load("dict");
115		$outputlangs->load("companies");
116		$outputlangs->load("bills");
117		$outputlangs->load("products");
118		$outputlangs->load("deliveries");
119		$outputlangs->load("sendings");
120
121		if ($conf->expedition->dir_output."/receipt")
122		{
123			$object->fetch_thirdparty();
124
125			$nblines = count($object->lines);
126
127			$objectref = dol_sanitizeFileName($object->ref);
128			$dir = $conf->expedition->dir_output."/receipt";
129			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
130			$file = $dir . "/" . $objectref . ".pdf";
131
132			if (! file_exists($dir))
133			{
134				if (create_exdir($dir) < 0)
135				{
136					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
137					return 0;
138				}
139			}
140
141			if (file_exists($dir))
142			{
143                $pdf=pdf_getInstance($this->format);
144
145                if (class_exists('TCPDF'))
146                {
147                    $pdf->setPrintHeader(false);
148                    $pdf->setPrintFooter(false);
149                }
150                $pdf->SetFont(pdf_getPDFFont($outputlangs));
151
152				// Complete object by loading several other informations
153				$expedition=new Expedition($this->db);
154				$result = $expedition->fetch($object->expedition_id);
155
156				$commande = new Commande($this->db);
157				if ($expedition->origin == 'commande')
158				{
159					$commande->fetch($expedition->origin_id);
160				}
161				$object->commande=$commande;
162
163
164				$pdf->Open();
165				$pagenb=0;
166				$pdf->SetDrawColor(128,128,128);
167
168				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
169				$pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder"));
170				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
171				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
172				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("DeliveryOrder"));
173				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
174
175				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
176				$pdf->SetAutoPageBreak(1,0);
177
178				/*
179				 // Positionne $this->atleastonediscount si on a au moins une remise
180				 for ($i = 0 ; $i < $nblignes ; $i++)
181				 {
182				 if ($object->lines[$i]->remise_percent)
183				 {
184				 $this->atleastonediscount++;
185				 }
186				 }
187				 */
188
189				// New page
190				$pdf->AddPage();
191				$pagenb++;
192				$this->_pagehead($pdf, $object, 1, $outputlangs);
193				$pdf->SetFont('','', $default_font_size - 1);
194				$pdf->MultiCell(0, 3, '');		// Set interline to 3
195				$pdf->SetTextColor(0,0,0);
196
197				$tab_top = 90;
198				$tab_top_newpage = 50;
199				$tab_height = 110;
200				$tab_height_newpage = 150;
201
202				// Affiche notes
203				if (! empty($object->note_public))
204				{
205					$tab_top = 88;
206
207					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
208					$pdf->SetXY($this->posxdesc-1, $tab_top);
209					$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'L');
210					$nexY = $pdf->GetY();
211					$height_note=$nexY-$tab_top;
212
213					// Rect prend une longueur en 3eme param
214					$pdf->SetDrawColor(192,192,192);
215					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
216
217					$tab_height = $tab_height - $height_note;
218					$tab_top = $nexY+6;
219				}
220				else
221				{
222					$height_note=0;
223				}
224
225				$iniY = $tab_top + 7;
226				$curY = $tab_top + 7;
227				$nexY = $tab_top + 7;
228
229				// Boucle sur les lignes
230				for ($i = 0 ; $i < $nblines ; $i++)
231				{
232					$curY = $nexY;
233
234                    $pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
235
236                    // Description de la ligne produit
237					//$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs);
238					pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY);
239					//$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
240
241					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
242					$nexY = $pdf->GetY();
243
244					/*
245					 // TVA
246					 $pdf->SetXY($this->posxtva, $curY);
247					 $pdf->MultiCell(10, 4, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R');
248
249					 // Prix unitaire HT avant remise
250					 $pdf->SetXY($this->posxup, $curY);
251					 $pdf->MultiCell(20, 4, price($object->lines[$i]->subprice), 0, 'R', 0);
252					 */
253					// Quantity
254					$pdf->SetXY($this->posxqty, $curY);
255					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'R');
256					/*
257					 // Remise sur ligne
258					 $pdf->SetXY($this->posxdiscount, $curY);
259					 if ($object->lines[$i]->remise_percent)
260					 {
261					 $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R');
262					 }
263
264					 // Total HT ligne
265					 $pdf->SetXY($this->postotalht, $curY);
266					 $total = price($object->lines[$i]->price * $object->lines[$i]->qty);
267					 $pdf->MultiCell(23, 3, $total, 0, 'R', 0);
268
269					 // Collecte des totaux par valeur de tva
270					 // dans le tableau tva["taux"]=total_tva
271					 $tvaligne=$object->lines[$i]->price * $object->lines[$i]->qty;
272					 if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
273					 $this->tva[ (string) $object->lines[$i]->tva_tx ] += $tvaligne;
274					 */
275					$nexY+=2;    // Passe espace entre les lignes
276
277					// Cherche nombre de lignes a venir pour savoir si place suffisante
278					if ($i < ($nblines - 1) && empty($hidedesc))	// If it's not last line
279					{
280						//on recupere la description du produit suivant
281						$follow_descproduitservice = $object->lines[$i+1]->desc;
282						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
283						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
284					}
285					else	// If it's last line
286					{
287						$nblineFollowDesc = 0;
288					}
289
290					// Test if a new page is required
291					if ($pagenb == 1)
292					{
293						$tab_top_in_current_page=$tab_top;
294						$tab_height_in_current_page=$tab_height;
295					}
296					else
297					{
298						$tab_top_in_current_page=$tab_top_newpage;
299						$tab_height_in_current_page=$tab_height_newpage;
300					}
301					if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1))
302					{
303						if ($pagenb == 1)
304						{
305							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
306						}
307						else
308						{
309							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
310						}
311
312						$this->_pagefoot($pdf, $object, $outputlangs);
313
314						// New page
315						$pdf->AddPage();
316						$pagenb++;
317						$this->_pagehead($pdf, $object, 0, $outputlangs);
318						$pdf->SetFont('','', $default_font_size - 1);
319						$pdf->MultiCell(0, 3, '');		// Set interline to 3
320						$pdf->SetTextColor(0,0,0);
321
322						$nexY = $tab_top_newpage + 7;
323					}
324				}
325
326				// Show square
327				if ($pagenb == 1)
328				{
329					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
330					$bottomlasttab=$tab_top + $tab_height + 1;
331				}
332				else
333				{
334					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
335					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
336				}
337
338
339				/*
340				 * Pied de page
341				 */
342				$this->_pagefoot($pdf,$object,$outputlangs);
343
344				// Check product remaining to be delivered
345				// TODO doit etre modifie
346				//$waitingDelivery = $object->getRemainingDelivered();
347
348				if (is_array($waitingDelivery) & !empty($waitingDelivery))
349				{
350					$pdf->AddPage('P', 'A4');
351
352					$this->_pagehead($pdf, $object, 1, $outputlangs);
353					$pdf-> SetY(90);
354
355					$w=array(40,100,50);
356					$header=array($outputlangs->transnoentities('Reference'),
357								  $outputlangs->transnoentities('Label'),
358								  $outputlangs->transnoentities('Qty')
359								  );
360
361    				// Header
362    				$num = count($header);
363   					for($i = 0; $i < $num; $i++)
364   					{
365   						$pdf->Cell($w[$i],7,$header[$i],1,0,'C');
366   					}
367
368			    	$pdf->Ln();
369
370			    	// Data
371					foreach($waitingDelivery as $value)
372					{
373						$pdf->Cell($w[0], 6, $value['ref'], 1, 0, 'L');
374						$pdf->Cell($w[1], 6, $value['label'], 1, 0, 'L');
375						$pdf->Cell($w[2], 6, $value['qty'], 1, 1, 'R');
376
377						if ($pdf->GetY() > 250)
378						{
379							$this->_pagefoot($pdf,$object,$outputlangs);
380
381							$pdf->AddPage('P', 'A4');
382
383							$pdf->SetFont('','', $default_font_size - 1);
384							$this->_pagehead($pdf, $object, 0, $outputlangs);
385
386							$pdf-> SetY(40);
387							
388							$num = count($header);
389							for($i = 0; $i < $num; $i++)
390							{
391								$pdf->Cell($w[$i],7,$header[$i],1,0,'C');
392							}
393
394							$pdf->Ln();
395						}
396					}
397
398					$this->_pagefoot($pdf,$object,$outputlangs);
399
400				}
401
402				$pdf->AliasNbPages();
403
404				$pdf->Close();
405
406				$pdf->Output($file,'F');
407				if (! empty($conf->global->MAIN_UMASK))
408				@chmod($file, octdec($conf->global->MAIN_UMASK));
409
410				return 1;   // Pas d'erreur
411			}
412			else
413			{
414				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
415				return 0;
416			}
417		}
418
419		$this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR");
420		return 0;
421	}
422
423
424	/*
425	 *   \brief      Affiche la grille des lignes
426	 *   \param      pdf     objet PDF
427	 */
428	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
429	{
430		global $conf,$mysoc;
431		$default_font_size = pdf_getPDFFontSize($outputlangs);
432
433		$pdf->SetDrawColor(128,128,128);
434
435		// Rect prend une longueur en 3eme param
436		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
437		// line prend une position y en 3eme param
438		$pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6);
439
440		$pdf->SetTextColor(0,0,0);
441		$pdf->SetFont('','', $default_font_size - 1);
442
443		$pdf->SetXY($this->posxdesc-1, $tab_top+1);
444		$pdf->MultiCell(80,2, $outputlangs->transnoentities("Designation"),'','L');
445
446		// Modif SEB pour avoir une col en plus pour les commentaires clients
447		$pdf->line($this->posxcomm, $tab_top, $this->posxcomm, $tab_top + $tab_height);
448		$pdf->SetXY($this->posxcomm, $tab_top+1);
449		$pdf->MultiCell(80,2, $outputlangs->transnoentities("Comments"),'','L');
450
451		// Qty
452		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
453		$pdf->SetXY($this->posxqty-1, $tab_top+1);
454		$pdf->MultiCell(30, 2, $outputlangs->transnoentities("QtyShipped"),'','R');
455
456		// Modif Seb cadres signatures
457		$pdf->SetFont('','', $default_font_size);
458		$larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3;
459		$pdf->Rect($this->marge_gauche, ($tab_top + $tab_height + 3), $larg_sign, 25 );
460		$pdf->SetXY($this->marge_gauche + 2, $tab_top + $tab_height + 5);
461		$pdf->MultiCell($larg_sign,2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":",'','L');
462
463		$pdf->Rect(2*$larg_sign+$this->marge_gauche, ($tab_top + $tab_height + 3), $larg_sign, 25 );
464		$pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $tab_top + $tab_height + 5);
465		$pdf->MultiCell($larg_sign,2, $outputlangs->trans("ForCustomer").':','','L');
466
467	}
468
469	/**
470	 *   	Show header of page
471	 *
472	 *   	@param      $pdf     		Object PDF
473	 *   	@param      $object     	Object order
474	 *      @param      $showaddress    0=no, 1=yes
475	 *      @param      $outputlangs	Object lang for output
476	 */
477	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
478	{
479		global $langs,$conf,$mysoc;
480		$default_font_size = pdf_getPDFFontSize($outputlangs);
481
482		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
483
484		$pdf->SetTextColor(0,0,60);
485		$pdf->SetFont('','B', $default_font_size + 3);
486
487        $posx=$this->page_largeur-$this->marge_droite-100;
488		$posy=$this->marge_haute;
489
490		$pdf->SetXY($this->marge_gauche,$posy);
491
492		// Logo
493		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
494		if ($mysoc->logo)
495		{
496			if (is_readable($logo))
497			{
498				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 22);
499			}
500			else
501			{
502				$pdf->SetTextColor(200,0,0);
503				$pdf->SetFont('','B', $default_font_size - 2);
504				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
505				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
506			}
507		}
508		else $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
509
510		$pdf->SetFont('','B', $default_font_size + 2);
511		$pdf->SetXY($posx,$posy);
512		$pdf->SetTextColor(0,0,60);
513		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryOrder")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
514
515		$pdf->SetFont('','',$default_font_size + 2);
516
517		$posy+=5;
518		$pdf->SetXY($posx,$posy);
519		$pdf->SetTextColor(0,0,60);
520		if ($object->date_valid)
521		{
522			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(($object->date_delivery?$object->date_delivery:$date->valid),"%d %b %Y",false,$outputlangs,true), '', 'R');
523		}
524		else
525		{
526			$pdf->SetTextColor(255,0,0);
527			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
528			$pdf->SetTextColor(0,0,60);
529		}
530
531		if ($object->client->code_client)
532		{
533			$posy+=5;
534			$pdf->SetXY($posx,$posy);
535			$pdf->SetTextColor(0,0,60);
536			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
537		}
538
539		$pdf->SetTextColor(0,0,60);
540
541		// Add origin linked objects
542		// TODO extend to other objects
543	    $object->fetchObjectLinked('','',$object->id,'delivery');
544
545	    if (! empty($object->linkedObjects))
546		{
547			$outputlangs->load('orders');
548
549			foreach($object->linkedObjects as $elementtype => $objects)
550			{
551				$object->fetchObjectLinked('','',$objects[0]->id,$objects[0]->element);
552
553				foreach($object->linkedObjects as $elementtype => $objects)
554				{
555					$num=count($objects);
556					for ($i=0;$i<$num;$i++)
557					{
558						$order=new Commande($this->db);
559						$result=$order->fetch($objects[$i]->id);
560						if ($result >= 0)
561						{
562							$posy+=5;
563							$pdf->SetXY($posx,$posy);
564							$pdf->SetFont('','', $default_font_size - 1);
565							$text=$order->ref;
566							if ($order->ref_client) $text.=' ('.$order->ref_client.')';
567							$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
568						}
569					}
570				}
571			}
572		}
573
574		if ($showaddress)
575		{
576			// Emetteur
577			$posy=42;
578			$hautcadre=40;
579			$pdf->SetTextColor(0,0,0);
580			$pdf->SetFont('','', $default_font_size - 2);
581			$pdf->SetXY($this->marge_gauche,$posy-5);
582			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":");
583
584
585			$pdf->SetXY($this->marge_gauche,$posy);
586			$pdf->SetFillColor(230,230,230);
587			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
588
589
590			$pdf->SetXY($this->marge_gauche+2,$posy+3);
591
592			// Nom emetteur
593			$pdf->SetTextColor(0,0,60);
594			$pdf->SetFont('','B',$default_font_size);
595			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
596
597			// Sender properties
598			$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
599
600			$pdf->SetFont('','', $default_font_size - 1);
601			$pdf->SetXY($this->marge_gauche+2,$posy+9);
602			$pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
603
604			// Client destinataire
605			$posy=42;
606			$pdf->SetTextColor(0,0,0);
607			$pdf->SetFont('','', $default_font_size - 2);
608			$pdf->SetXY(102,$posy-5);
609			$pdf->MultiCell(80,5, $outputlangs->transnoentities("DeliveryAddress").":", 0, 'L');
610
611			// Cadre client destinataire
612			$pdf->rect(100, $posy, 100, $hautcadre);
613
614			// If SHIPPING contact defined on invoice, we use it
615			$usecontact=false;
616			$arrayidcontact=$object->commande->getIdContact('external','SHIPPING');
617			if (count($arrayidcontact) > 0)
618			{
619				$usecontact=true;
620				$result=$object->fetch_contact($arrayidcontact[0]);
621			}
622
623			// Recipient name
624			if (! empty($usecontact))
625			{
626				// On peut utiliser le nom de la societe du contact
627				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
628				else $socname = $object->client->nom;
629				$carac_client_name=$outputlangs->convToOutputCharset($socname);
630			}
631			else
632			{
633				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
634			}
635
636			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
637
638			// Show customer/recipient
639			$pdf->SetXY(102,$posy+3);
640			$pdf->SetFont('','B', $default_font_size);
641			$pdf->MultiCell(106,4, $carac_client_name, 0, 'L');
642
643			$pdf->SetFont('','', $default_font_size - 1);
644			$pdf->SetXY(102,$posy+8);
645			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
646		}
647
648	}
649
650	/**
651	 *   	Show footer of page
652	 * 		Need this->emetteur object
653	 *
654	 *   	@param      pdf     		PDF factory
655	 * 		@param		object			Object invoice
656	 *      @param      outputlangs		Object lang for output
657	 */
658	function _pagefoot(&$pdf,$object,$outputlangs)
659	{
660		return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
661	}
662
663}
664
665?>