PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php

https://bitbucket.org/speedealing/speedealing
PHP | 645 lines | 427 code | 98 blank | 120 comment | 55 complexity | 97b01633c8841a1739956c1d001a8df7 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  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 3 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/expedition/doc/pdf_expedition_rouget.modules.php
  22. * \ingroup expedition
  23. * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget
  24. */
  25. require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  28. /**
  29. * Classe permettant de generer les borderaux envoi au modele Rouget
  30. */
  31. class pdf_expedition_rouget extends ModelePdfExpedition
  32. {
  33. var $emetteur; // Objet societe qui emet
  34. /**
  35. * Constructor
  36. *
  37. * @param DoliDB $db Database handler
  38. */
  39. function __construct($db=0)
  40. {
  41. global $conf,$langs,$mysoc;
  42. $this->db = $db;
  43. $this->name = "rouget";
  44. $this->description = $langs->trans("DocumentModelSimple");
  45. $this->type = 'pdf';
  46. $formatarray=pdf_getFormat();
  47. $this->page_largeur = $formatarray['width'];
  48. $this->page_hauteur = $formatarray['height'];
  49. $this->format = array($this->page_largeur,$this->page_hauteur);
  50. $this->marge_gauche=10;
  51. $this->marge_droite=10;
  52. $this->marge_haute=10;
  53. $this->marge_basse=10;
  54. $this->option_logo = 1;
  55. // Recupere emmetteur
  56. $this->emetteur=$mysoc;
  57. if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // By default if not defined
  58. // Defini position des colonnes
  59. $this->posxdesc=$this->marge_gauche+1;
  60. $this->posxqtyordered=120;
  61. $this->posxqtytoship=160;
  62. }
  63. /**
  64. * Function to build pdf onto disk
  65. *
  66. * @param Object &$object Object expedition to generate (or id if old method)
  67. * @param Translate $outputlangs Lang output object
  68. * @param string $srctemplatepath Full path of source filename for generator using a template file
  69. * @param int $hidedetails Do not show line details
  70. * @param int $hidedesc Do not show desc
  71. * @param int $hideref Do not show ref
  72. * @return int 1=OK, 0=KO
  73. */
  74. function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
  75. {
  76. global $user,$conf,$langs;
  77. $default_font_size = pdf_getPDFFontSize($outputlangs);
  78. $object->fetch_thirdparty();
  79. if (! is_object($outputlangs)) $outputlangs=$langs;
  80. // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
  81. if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
  82. $outputlangs->load("main");
  83. $outputlangs->load("dict");
  84. $outputlangs->load("companies");
  85. $outputlangs->load("bills");
  86. $outputlangs->load("products");
  87. $outputlangs->load("propal");
  88. $outputlangs->load("deliveries");
  89. $outputlangs->load("sendings");
  90. if ($conf->expedition->dir_output)
  91. {
  92. // Definition de $dir et $file
  93. if ($object->specimen)
  94. {
  95. $dir = $conf->expedition->dir_output."/sending";
  96. $file = $dir . "/SPECIMEN.pdf";
  97. }
  98. else
  99. {
  100. $expref = dol_sanitizeFileName($object->ref);
  101. $dir = $conf->expedition->dir_output."/sending/" . $expref;
  102. $file = $dir . "/" . $expref . ".pdf";
  103. }
  104. if (! file_exists($dir))
  105. {
  106. if (dol_mkdir($dir) < 0)
  107. {
  108. $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
  109. return 0;
  110. }
  111. }
  112. if (file_exists($dir))
  113. {
  114. $nblignes = count($object->lines);
  115. $pdf=pdf_getInstance($this->format);
  116. $heightforinfotot = 0; // Height reserved to output the info and total part
  117. $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
  118. $pdf->SetAutoPageBreak(1,0);
  119. if (class_exists('TCPDF'))
  120. {
  121. $pdf->setPrintHeader(false);
  122. $pdf->setPrintFooter(false);
  123. }
  124. $pdf->SetFont(pdf_getPDFFont($outputlangs));
  125. // Set path to the background PDF File
  126. if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
  127. {
  128. $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
  129. $tplidx = $pdf->importPage(1);
  130. }
  131. $pdf->Open();
  132. $pagenb=0;
  133. $pdf->SetDrawColor(128,128,128);
  134. $pdf->AliasNbPages();
  135. $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
  136. $pdf->SetSubject($outputlangs->transnoentities("Sending"));
  137. $pdf->SetCreator("Speedealing ".DOL_VERSION);
  138. $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
  139. $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Sending"));
  140. if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
  141. $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
  142. // New page
  143. $pdf->AddPage();
  144. if (! empty($tplidx)) $pdf->useTemplate($tplidx);
  145. $pagenb++;
  146. $this->_pagehead($pdf, $object, 1, $outputlangs);
  147. $pdf->SetFont('','', $default_font_size - 1);
  148. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  149. $pdf->SetTextColor(0,0,0);
  150. $tab_top = 90;
  151. $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
  152. $tab_height = 130;
  153. $tab_height_newpage = 150;
  154. if (! empty($object->note_public) || ! empty($object->tracking_number))
  155. {
  156. $tab_top = 88;
  157. // Tracking number
  158. if (! empty($object->tracking_number))
  159. {
  160. $object->GetUrlTrackingStatus($object->tracking_number);
  161. if (! empty($object->tracking_url))
  162. {
  163. if ($object->expedition_method_id > 0)
  164. {
  165. // Get code using getLabelFromKey
  166. $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code');
  167. $label=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
  168. $label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
  169. $pdf->SetFont('','B', $default_font_size - 2);
  170. $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L');
  171. }
  172. }
  173. }
  174. // Affiche notes
  175. if (! empty($object->note_public))
  176. {
  177. $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
  178. $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
  179. }
  180. $nexY = $pdf->GetY();
  181. $height_note=$nexY-$tab_top;
  182. // Rect prend une longueur en 3eme param
  183. $pdf->SetDrawColor(192,192,192);
  184. $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
  185. $tab_height = $tab_height - $height_note;
  186. $tab_top = $nexY+6;
  187. }
  188. else
  189. {
  190. $height_note=0;
  191. }
  192. $iniY = $tab_top + 7;
  193. $curY = $tab_top + 7;
  194. $nexY = $tab_top + 7;
  195. $num=count($object->lines);
  196. // Loop on each lines
  197. for ($i = 0; $i < $num; $i++)
  198. {
  199. $curY = $nexY;
  200. $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
  201. $pdf->SetTextColor(0,0,0);
  202. $pdf->setTopMargin($tab_top_newpage);
  203. $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
  204. $pageposbefore=$pdf->getPage();
  205. // Description de la ligne produit
  206. pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1);
  207. $nexY = $pdf->GetY();
  208. $pageposafter=$pdf->getPage();
  209. $pdf->setPage($pageposbefore);
  210. $pdf->setTopMargin($this->marge_haute);
  211. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  212. // We suppose that a too long description is moved completely on next page
  213. if ($pageposafter > $pageposbefore) {
  214. $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
  215. }
  216. $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
  217. $pdf->SetXY($this->posxqtyordered+5, $curY);
  218. $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked,'','C');
  219. $pdf->SetXY($this->posxqtytoship+5, $curY);
  220. $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped,'','C');
  221. $nexY+=2; // Passe espace entre les lignes
  222. // Detect if some page were added automatically and output _tableau for past pages
  223. while ($pagenb < $pageposafter)
  224. {
  225. $pdf->setPage($pagenb);
  226. if ($pagenb == 1)
  227. {
  228. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  229. }
  230. else
  231. {
  232. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  233. }
  234. $this->_pagefoot($pdf,$object,$outputlangs);
  235. $pagenb++;
  236. $pdf->setPage($pagenb);
  237. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  238. }
  239. if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
  240. {
  241. if ($pagenb == 1)
  242. {
  243. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  244. }
  245. else
  246. {
  247. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  248. }
  249. $this->_pagefoot($pdf,$object,$outputlangs);
  250. // New page
  251. $pdf->AddPage();
  252. if (! empty($tplidx)) $pdf->useTemplate($tplidx);
  253. $pagenb++;
  254. }
  255. }
  256. // Show square
  257. if ($pagenb == 1)
  258. {
  259. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforinfotot, 0, $outputlangs, 0, 0);
  260. $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforinfotot + 1;
  261. }
  262. else
  263. {
  264. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforinfotot, 0, $outputlangs, 1, 0);
  265. $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforinfotot + 1;
  266. }
  267. // Pied de page
  268. $this->_pagefoot($pdf,$object,$outputlangs);
  269. $pdf->AliasNbPages();
  270. $pdf->Close();
  271. $pdf->Output($file,'F');
  272. if (! empty($conf->global->MAIN_UMASK))
  273. @chmod($file, octdec($conf->global->MAIN_UMASK));
  274. return 1;
  275. }
  276. else
  277. {
  278. $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
  279. return 0;
  280. }
  281. }
  282. else
  283. {
  284. $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
  285. return 0;
  286. }
  287. $this->error=$langs->transnoentities("ErrorUnknown");
  288. return 0; // Erreur par defaut
  289. }
  290. /**
  291. * Show table for lines
  292. *
  293. * @param PDF &$pdf Object PDF
  294. * @param string $tab_top Top position of table
  295. * @param string $tab_height Height of table (rectangle)
  296. * @param int $nexY Y
  297. * @param Translate $outputlangs Langs object
  298. * @param int $hidetop Hide top bar of array
  299. * @param int $hidebottom Hide bottom bar of array
  300. * @return void
  301. */
  302. function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
  303. {
  304. global $conf;
  305. // Force to disable hidetop and hidebottom
  306. $hidebottom=0;
  307. if ($hidetop) $hidetop=-1;
  308. $default_font_size = pdf_getPDFFontSize($outputlangs);
  309. // Amount in (at tab_top - 1)
  310. $pdf->SetTextColor(0,0,0);
  311. $pdf->SetFont('','',$default_font_size - 1);
  312. // Output Rect
  313. $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
  314. $pdf->SetDrawColor(128,128,128);
  315. $pdf->SetFont('','',$default_font_size - 1);
  316. if (empty($hidetop))
  317. {
  318. $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
  319. $pdf->SetXY($this->posxdesc-1, $tab_top+1);
  320. $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Description"), '', 'L');
  321. }
  322. $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
  323. if (empty($hidetop))
  324. {
  325. $pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
  326. $pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyOrdered"),'','C');
  327. }
  328. $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
  329. if (empty($hidetop))
  330. {
  331. $pdf->SetXY($this->posxqtytoship-1, $tab_top+1);
  332. $pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyToShip"),'','C');
  333. }
  334. }
  335. /**
  336. * Show top header of page.
  337. *
  338. * @param PDF &$pdf Object PDF
  339. * @param Object $object Object to show
  340. * @param int $showaddress 0=no, 1=yes
  341. * @param Translate $outputlangs Object lang for output
  342. * @return void
  343. */
  344. function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
  345. {
  346. global $conf,$langs,$mysoc;
  347. $default_font_size = pdf_getPDFFontSize($outputlangs);
  348. $langs->load("orders");
  349. pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
  350. //Affiche le filigrane brouillon - Print Draft Watermark
  351. if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
  352. {
  353. pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
  354. }
  355. //Prepare la suite
  356. $pdf->SetTextColor(0,0,60);
  357. $pdf->SetFont('','B', $default_font_size + 3);
  358. $posx=$this->page_largeur-$this->marge_droite-100;
  359. $posy=$this->marge_haute;
  360. $pdf->SetXY($this->marge_gauche,$posy);
  361. // Logo
  362. $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
  363. if ($this->emetteur->logo)
  364. {
  365. if (is_readable($logo))
  366. {
  367. $height=pdf_getHeightForLogo($logo);
  368. $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
  369. }
  370. else
  371. {
  372. $pdf->SetTextColor(200,0,0);
  373. $pdf->SetFont('','B', $default_font_size - 2);
  374. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
  375. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
  376. }
  377. }
  378. else
  379. {
  380. $text=$this->emetteur->name;
  381. $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
  382. }
  383. // Show barcode
  384. if (! empty($conf->barcode->enabled))
  385. {
  386. $posx=105;
  387. }
  388. else
  389. {
  390. $posx=$this->marge_gauche+3;
  391. }
  392. //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
  393. if (! empty($conf->barcode->enabled))
  394. {
  395. // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
  396. //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
  397. //$pdf->Image($logo,10, 5, 0, 24);
  398. }
  399. $pdf->SetDrawColor(128,128,128);
  400. if (! empty($conf->barcode->enabled))
  401. {
  402. // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
  403. //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
  404. //$pdf->Image($logo,10, 5, 0, 24);
  405. }
  406. $posx=$this->page_largeur - 100 - $this->marge_droite;
  407. $posy=$this->marge_haute;
  408. $pdf->SetFont('','B', $default_font_size + 2);
  409. $pdf->SetXY($posx,$posy);
  410. $pdf->SetTextColor(0,0,60);
  411. $title=$outputlangs->transnoentities("SendingSheet");
  412. $pdf->MultiCell(100, 4, $title, '', 'R');
  413. $posy+=1;
  414. $pdf->SetFont('','', $default_font_size + 1);
  415. $posy+=4;
  416. $pdf->SetXY($posx,$posy);
  417. $pdf->SetTextColor(0,0,60);
  418. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
  419. //Date Expedition
  420. $posy+=4;
  421. $pdf->SetXY($posx,$posy);
  422. $pdf->SetTextColor(0,0,60);
  423. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_creation,"daytext",false,$outputlangs,true), '', 'R');
  424. if (! empty($object->client->code_client))
  425. {
  426. $posy+=4;
  427. $pdf->SetXY($posx,$posy);
  428. $pdf->SetTextColor(0,0,60);
  429. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
  430. }
  431. $pdf->SetFont('','', $default_font_size + 3);
  432. $Yoff=25;
  433. // Add list of linked orders
  434. // TODO possibility to use with other document (business module,...)
  435. //$object->load_object_linked();
  436. $origin = $object->origin;
  437. $origin_id = $object->origin_id;
  438. // TODO move to external function
  439. if ($conf->$origin->enabled)
  440. {
  441. $outputlangs->load('orders');
  442. $classname = ucfirst($origin);
  443. $linkedobject = new $classname($this->db);
  444. $result=$linkedobject->fetch($origin_id);
  445. if ($result >= 0)
  446. {
  447. $pdf->SetFont('','', $default_font_size - 2);
  448. $text=$linkedobject->ref;
  449. if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
  450. $Yoff = $Yoff+8;
  451. $pdf->SetXY($this->page_largeur - $this->marge_droite - 100,$Yoff);
  452. $pdf->MultiCell(100, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
  453. $Yoff = $Yoff+4;
  454. $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
  455. $pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"daytext",false,$outputlangs,true), 0, 'R');
  456. }
  457. }
  458. if ($showaddress)
  459. {
  460. // Sender properties
  461. $carac_emetteur='';
  462. // Add internal contact of proposal if defined
  463. $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
  464. if (count($arrayidcontact) > 0)
  465. {
  466. $object->fetch_user($arrayidcontact[0]);
  467. $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
  468. }
  469. $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
  470. // Show sender
  471. $posx=$this->marge_gauche;
  472. $posy=42;
  473. $hautcadre=40;
  474. if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur - 80 - $this->marge_droite;
  475. // Show sender frame
  476. $pdf->SetTextColor(0,0,0);
  477. $pdf->SetFont('','', $default_font_size - 2);
  478. $pdf->SetXY($posx,$posy-5);
  479. $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
  480. $pdf->SetXY($posx,$posy);
  481. $pdf->SetFillColor(230,230,230);
  482. $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
  483. // Show sender name
  484. $pdf->SetXY($posx+2,$posy+3);
  485. $pdf->SetTextColor(0,0,60);
  486. $pdf->SetFont('','B',$default_font_size);
  487. $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
  488. // Show sender information
  489. $pdf->SetFont('','', $default_font_size - 1);
  490. $pdf->SetXY($posx+2,$posy+8);
  491. $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
  492. // If SHIPPING contact defined, we use it
  493. $usecontact=false;
  494. $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
  495. if (count($arrayidcontact) > 0)
  496. {
  497. $usecontact=true;
  498. $result=$object->fetch_contact($arrayidcontact[0]);
  499. }
  500. // Recipient name
  501. if (! empty($usecontact))
  502. {
  503. // On peut utiliser le nom de la societe du contact
  504. if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
  505. else $socname = $object->client->nom;
  506. $carac_client_name=$outputlangs->convToOutputCharset($socname);
  507. }
  508. else
  509. {
  510. $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
  511. }
  512. $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
  513. // Show recipient
  514. $posy=42;
  515. $posx=$this->page_largeur - 100 - $this->marge_droite;
  516. if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
  517. // Show recipient frame
  518. $pdf->SetTextColor(0,0,0);
  519. $pdf->SetFont('','', $default_font_size - 2);
  520. $pdf->SetXY($posx,$posy-5);
  521. $pdf->MultiCell(80, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L');
  522. $pdf->Rect($posx, $posy, 100, $hautcadre);
  523. $pdf->SetTextColor(0,0,0);
  524. // Show recipient name
  525. $pdf->SetXY($posx+2,$posy+3);
  526. $pdf->SetFont('','B', $default_font_size);
  527. $pdf->MultiCell(96,4, $carac_client_name, 0, 'L');
  528. // Show recipient information
  529. $pdf->SetFont('','', $default_font_size - 1);
  530. $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
  531. $pdf->MultiCell(86,4, $carac_client, 0, 'L');
  532. }
  533. }
  534. /**
  535. * Show footer of page. Need this->emetteur object
  536. *
  537. * @param PDF &$pdf PDF
  538. * @param Object $object Object to show
  539. * @param Translate $outputlangs Object lang for output
  540. * @return void
  541. */
  542. function _pagefoot(&$pdf,$object,$outputlangs)
  543. {
  544. return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
  545. }
  546. }
  547. ?>