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