PageRenderTime 50ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php

https://bitbucket.org/speedealing/speedealing
PHP | 604 lines | 383 code | 90 blank | 131 comment | 45 complexity | 19d5e74fd78decf6e0839a09e85f70e9 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  6. * Copyright (C) 2011 Fabrice CHERRIER
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. * or see http://www.gnu.org/
  21. */
  22. /**
  23. * \file htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
  24. * \ingroup ficheinter
  25. * \brief Fichier de la classe permettant de generer les fiches d'intervention au modele Soleil
  26. */
  27. require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  31. /**
  32. * Class to build interventions documents with model Soleil
  33. */
  34. class pdf_soleil extends ModelePDFFicheinter
  35. {
  36. var $db;
  37. var $name;
  38. var $description;
  39. var $type;
  40. var $phpmin = array(4,3,0); // Minimum version of PHP required by module
  41. var $version = 'dolibarr';
  42. var $page_largeur;
  43. var $page_hauteur;
  44. var $format;
  45. var $marge_gauche;
  46. var $marge_droite;
  47. var $marge_haute;
  48. var $marge_basse;
  49. /**
  50. * Constructor
  51. *
  52. * @param DoliDB $db Database handler
  53. */
  54. function __construct($db = '')
  55. {
  56. global $conf,$langs,$mysoc;
  57. $this->db = $db;
  58. $this->name = 'soleil';
  59. $this->description = $langs->trans("DocumentModelStandard");
  60. // Dimension page pour format A4
  61. $this->type = 'pdf';
  62. $formatarray=pdf_getFormat();
  63. $this->page_largeur = $formatarray['width'];
  64. $this->page_hauteur = $formatarray['height'];
  65. $this->format = array($this->page_largeur,$this->page_hauteur);
  66. $this->marge_gauche=10;
  67. $this->marge_droite=10;
  68. $this->marge_haute=10;
  69. $this->marge_basse=10;
  70. $this->option_logo = 1; // Affiche logo
  71. $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
  72. $this->option_modereg = 0; // Affiche mode reglement
  73. $this->option_condreg = 0; // Affiche conditions reglement
  74. $this->option_codeproduitservice = 0; // Affiche code produit-service
  75. $this->option_multilang = 0; // Dispo en plusieurs langues
  76. $this->option_draft_watermark = 1; //Support add of a watermark on drafts
  77. // Get source company
  78. $this->emetteur=$mysoc;
  79. if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined
  80. // Defini position des colonnes
  81. $this->posxdesc=$this->marge_gauche+1;
  82. }
  83. /**
  84. * Function to build pdf onto disk
  85. *
  86. * @param int $object Id of object to generate
  87. * @param object $outputlangs Lang output object
  88. * @param string $srctemplatepath Full path of source filename for generator using a template file
  89. * @param int $hidedetails Do not show line details
  90. * @param int $hidedesc Do not show desc
  91. * @param int $hideref Do not show ref
  92. * @return int 1=OK, 0=KO
  93. */
  94. function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
  95. {
  96. global $user,$langs,$conf,$mysoc;
  97. if (! is_object($outputlangs)) $outputlangs=$langs;
  98. // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
  99. if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
  100. $outputlangs->load("main");
  101. $outputlangs->load("dict");
  102. $outputlangs->load("companies");
  103. $outputlangs->load("interventions");
  104. $default_font_size = pdf_getPDFFontSize($outputlangs);
  105. if ($conf->ficheinter->dir_output)
  106. {
  107. $object->fetch_thirdparty();
  108. $objectref = dol_sanitizeFileName($object->ref);
  109. $dir = $conf->ficheinter->dir_output;
  110. if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
  111. $file = $dir . "/" . $objectref . ".pdf";
  112. if (! file_exists($dir))
  113. {
  114. if (dol_mkdir($dir) < 0)
  115. {
  116. $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
  117. return 0;
  118. }
  119. }
  120. if (file_exists($dir))
  121. {
  122. $pdf=pdf_getInstance($this->format);
  123. $heightforinfotot = 50; // Height reserved to output the info and total part
  124. $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
  125. $pdf->SetAutoPageBreak(1,0);
  126. if (class_exists('TCPDF'))
  127. {
  128. $pdf->setPrintHeader(false);
  129. $pdf->setPrintFooter(false);
  130. }
  131. $pdf->SetFont(pdf_getPDFFont($outputlangs));
  132. // Set path to the background PDF File
  133. if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
  134. {
  135. $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
  136. $tplidx = $pdf->importPage(1);
  137. }
  138. $pdf->Open();
  139. $pagenb=0;
  140. $pdf->SetDrawColor(128,128,128);
  141. $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
  142. $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
  143. $pdf->SetCreator("Speedealing ".DOL_VERSION);
  144. $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
  145. $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
  146. if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
  147. $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
  148. // New page
  149. $pdf->AddPage();
  150. if (! empty($tplidx)) $pdf->useTemplate($tplidx);
  151. $pagenb++;
  152. $this->_pagehead($pdf, $object, 1, $outputlangs);
  153. $pdf->SetFont('','', $default_font_size - 1);
  154. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  155. $pdf->SetTextColor(0,0,0);
  156. $tab_top = 90;
  157. $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
  158. $tab_height = 130;
  159. $tab_height_newpage = 150;
  160. // Affiche notes
  161. if (! empty($object->note_public))
  162. {
  163. $tab_top = 88;
  164. $pdf->SetFont('','', $default_font_size - 1);
  165. $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
  166. $nexY = $pdf->GetY();
  167. $height_note=$nexY-$tab_top;
  168. // Rect prend une longueur en 3eme param
  169. $pdf->SetDrawColor(192,192,192);
  170. $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
  171. $tab_height = $tab_height - $height_note;
  172. $tab_top = $nexY+6;
  173. }
  174. else
  175. {
  176. $height_note=0;
  177. }
  178. $iniY = $tab_top + 7;
  179. $curY = $tab_top + 7;
  180. $nexY = $tab_top + 7;
  181. $pdf->SetXY($this->marge_gauche, $tab_top);
  182. $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
  183. $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
  184. $pdf->SetFont('', '', $default_font_size - 1);
  185. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  186. $pdf->SetXY($this->marge_gauche, $tab_top + 8);
  187. $text=$object->description;
  188. if ($object->duree > 0)
  189. {
  190. $totaltime=convertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
  191. $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
  192. }
  193. $desc=dol_htmlentitiesbr($text,1);
  194. //print $outputlangs->convToOutputCharset($desc); exit;
  195. $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
  196. $nexY = $pdf->GetY();
  197. $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
  198. $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
  199. $nblines = count($object->lines);
  200. // Loop on each lines
  201. for ($i = 0; $i < $nblines; $i++)
  202. {
  203. $objectligne = $object->lines[$i];
  204. $valide = $objectligne->id ? $objectligne->fetch($objectligne->id) : 0;
  205. if ($valide > 0 || $object->specimen)
  206. {
  207. $curY = $nexY;
  208. $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
  209. $pdf->SetTextColor(0,0,0);
  210. $pdf->setTopMargin($tab_top_newpage);
  211. $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
  212. $pageposbefore=$pdf->getPage();
  213. // Description of product line
  214. $txt='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration),1,$outputlangs->charset_output).'</strong>';
  215. $desc=dol_htmlentitiesbr($objectligne->desc,1);
  216. $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
  217. $nexY = $pdf->GetY();
  218. $pageposafter=$pdf->getPage();
  219. $pdf->setPage($pageposbefore);
  220. $pdf->setTopMargin($this->marge_haute);
  221. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  222. // We suppose that a too long description is moved completely on next page
  223. if ($pageposafter > $pageposbefore) {
  224. $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
  225. }
  226. $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
  227. // Detect if some page were added automatically and output _tableau for past pages
  228. while ($pagenb < $pageposafter)
  229. {
  230. $pdf->setPage($pagenb);
  231. if ($pagenb == 1)
  232. {
  233. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  234. }
  235. else
  236. {
  237. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  238. }
  239. $this->_pagefoot($pdf,$object,$outputlangs);
  240. $pagenb++;
  241. $pdf->setPage($pagenb);
  242. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  243. }
  244. if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
  245. {
  246. if ($pagenb == 1)
  247. {
  248. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  249. }
  250. else
  251. {
  252. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  253. }
  254. $this->_pagefoot($pdf,$object,$outputlangs);
  255. // New page
  256. $pdf->AddPage();
  257. if (! empty($tplidx)) $pdf->useTemplate($tplidx);
  258. $pagenb++;
  259. }
  260. }
  261. }
  262. // Show square
  263. if ($pagenb == 1)
  264. {
  265. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0);
  266. $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
  267. }
  268. else
  269. {
  270. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0);
  271. $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
  272. }
  273. $this->_pagefoot($pdf,$object,$outputlangs);
  274. $pdf->AliasNbPages();
  275. $pdf->Close();
  276. $pdf->Output($file,'F');
  277. if (! empty($conf->global->MAIN_UMASK))
  278. @chmod($file, octdec($conf->global->MAIN_UMASK));
  279. return 1;
  280. }
  281. else
  282. {
  283. $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
  284. return 0;
  285. }
  286. }
  287. else
  288. {
  289. $this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
  290. return 0;
  291. }
  292. $this->error=$langs->trans("ErrorUnknown");
  293. return 0; // Erreur par defaut
  294. }
  295. /**
  296. * Show table for lines
  297. *
  298. * @param PDF &$pdf Object PDF
  299. * @param string $tab_top Top position of table
  300. * @param string $tab_height Height of table (rectangle)
  301. * @param int $nexY Y
  302. * @param Translate $outputlangs Langs object
  303. * @param int $hidetop Hide top bar of array
  304. * @param int $hidebottom Hide bottom bar of array
  305. * @return void
  306. */
  307. function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
  308. {
  309. global $conf;
  310. // Force to disable hidetop and hidebottom
  311. $hidebottom=0;
  312. if ($hidetop) $hidetop=-1;
  313. $default_font_size = pdf_getPDFFontSize($outputlangs);
  314. /*
  315. $pdf->SetXY($this->marge_gauche, $tab_top);
  316. $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
  317. $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
  318. $pdf->SetFont('','', $default_font_size - 1);
  319. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  320. $pdf->SetXY($this->marge_gauche, $tab_top + 8);
  321. $text=$object->description;
  322. if ($object->duree > 0)
  323. {
  324. $totaltime=convertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
  325. $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
  326. }
  327. $desc=dol_htmlentitiesbr($text,1);
  328. //print $outputlangs->convToOutputCharset($desc); exit;
  329. $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
  330. $nexY = $pdf->GetY();
  331. $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
  332. $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
  333. */
  334. // Output Rect
  335. $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
  336. if (empty($hidebottom))
  337. {
  338. $pdf->SetXY(20,230);
  339. $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
  340. $pdf->SetXY(20,235);
  341. $pdf->MultiCell(80,25, '', 1);
  342. $pdf->SetXY(110,230);
  343. $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
  344. $pdf->SetXY(110,235);
  345. $pdf->MultiCell(80,25, '', 1);
  346. }
  347. }
  348. /**
  349. * Show top header of page.
  350. *
  351. * @param PDF &$pdf Object PDF
  352. * @param Object $object Object to show
  353. * @param int $showaddress 0=no, 1=yes
  354. * @param Translate $outputlangs Object lang for output
  355. * @return void
  356. */
  357. function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
  358. {
  359. global $conf,$langs;
  360. $default_font_size = pdf_getPDFFontSize($outputlangs);
  361. $outputlangs->load("main");
  362. $outputlangs->load("dict");
  363. $outputlangs->load("companies");
  364. $outputlangs->load("interventions");
  365. pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
  366. //Affiche le filigrane brouillon - Print Draft Watermark
  367. if($object->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
  368. {
  369. pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
  370. }
  371. //Prepare la suite
  372. $pdf->SetTextColor(0,0,60);
  373. $pdf->SetFont('','B', $default_font_size + 3);
  374. $posx=$this->page_largeur-$this->marge_droite-100;
  375. $posy=$this->marge_haute;
  376. $pdf->SetXY($this->marge_gauche,$posy);
  377. // Logo
  378. $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
  379. if ($this->emetteur->logo)
  380. {
  381. if (is_readable($logo))
  382. {
  383. $height=pdf_getHeightForLogo($logo);
  384. $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
  385. }
  386. else
  387. {
  388. $pdf->SetTextColor(200,0,0);
  389. $pdf->SetFont('','B',$default_font_size - 2);
  390. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
  391. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
  392. }
  393. }
  394. else
  395. {
  396. $text=$this->emetteur->name;
  397. $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
  398. }
  399. $pdf->SetFont('','B',$default_font_size + 3);
  400. $pdf->SetXY($posx,$posy);
  401. $pdf->SetTextColor(0,0,60);
  402. $title=$outputlangs->transnoentities("InterventionCard");
  403. $pdf->MultiCell(100, 4, $title, '', 'R');
  404. $pdf->SetFont('','B',$default_font_size + 2);
  405. $posy+=5;
  406. $pdf->SetXY($posx,$posy);
  407. $pdf->SetTextColor(0,0,60);
  408. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
  409. $posy+=1;
  410. $pdf->SetFont('','', $default_font_size);
  411. $posy+=4;
  412. $pdf->SetXY($posx,$posy);
  413. $pdf->SetTextColor(0,0,60);
  414. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
  415. if ($object->client->code_client)
  416. {
  417. $posy+=4;
  418. $pdf->SetXY($posx,$posy);
  419. $pdf->SetTextColor(0,0,60);
  420. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
  421. }
  422. if ($showaddress)
  423. {
  424. // Sender properties
  425. $carac_emetteur='';
  426. // Add internal contact of proposal if defined
  427. $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
  428. if (count($arrayidcontact) > 0)
  429. {
  430. $object->fetch_user($arrayidcontact[0]);
  431. $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
  432. }
  433. $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
  434. // Show sender
  435. $posy=42;
  436. $posx=$this->marge_gauche;
  437. if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
  438. $hautcadre=40;
  439. // Show sender frame
  440. $pdf->SetTextColor(0,0,0);
  441. $pdf->SetFont('','', $default_font_size - 2);
  442. $pdf->SetXY($posx,$posy-5);
  443. $pdf->SetXY($posx,$posy);
  444. $pdf->SetFillColor(230,230,230);
  445. $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
  446. // Show sender name
  447. $pdf->SetXY($posx+2,$posy+3);
  448. $pdf->SetTextColor(0,0,60);
  449. $pdf->SetFont('','B',$default_font_size);
  450. $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
  451. // Show sender information
  452. $pdf->SetFont('','', $default_font_size - 1);
  453. $pdf->SetXY($posx+2,$posy+8);
  454. $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
  455. // If CUSTOMER contact defined, we use it
  456. $usecontact=false;
  457. $arrayidcontact=$object->getIdContact('external','CUSTOMER');
  458. if (count($arrayidcontact) > 0)
  459. {
  460. $usecontact=true;
  461. $result=$object->fetch_contact($arrayidcontact[0]);
  462. }
  463. // Recipient name
  464. if (! empty($usecontact))
  465. {
  466. // On peut utiliser le nom de la societe du contact
  467. if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
  468. else $socname = $object->client->nom;
  469. $carac_client_name=$outputlangs->convToOutputCharset($socname);
  470. }
  471. else
  472. {
  473. $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
  474. }
  475. $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target');
  476. // Show recipient
  477. $posy=42;
  478. $posx=$this->page_largeur-$this->marge_droite-100;
  479. if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
  480. // Show recipient frame
  481. $pdf->SetTextColor(0,0,0);
  482. $pdf->SetFont('','', $default_font_size - 2);
  483. $pdf->SetXY($posx,$posy-5);
  484. $pdf->Rect($posx, $posy, 100, $hautcadre);
  485. $pdf->SetTextColor(0,0,0);
  486. // Show recipient name
  487. $pdf->SetXY($posx+2,$posy+3);
  488. $pdf->SetFont('','B', $default_font_size);
  489. $pdf->MultiCell(100,4, $carac_client_name, 0, 'L');
  490. // Show recipient information
  491. $pdf->SetFont('','', $default_font_size - 1);
  492. $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
  493. $pdf->MultiCell(100,4, $carac_client, 0, 'L');
  494. }
  495. }
  496. /**
  497. * Show footer of page. Need this->emetteur object
  498. *
  499. * @param PDF &$pdf PDF
  500. * @param Object $object Object to show
  501. * @param Translate $outputlangs Object lang for output
  502. * @return void
  503. */
  504. function _pagefoot(&$pdf,$object,$outputlangs)
  505. {
  506. return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
  507. }
  508. }
  509. ?>