PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/modules/commande/pdf_edison.modules.php

https://github.com/asterix14/dolibarr
PHP | 640 lines | 385 code | 111 blank | 144 comment | 46 complexity | 5410439c82378bfbb13d80ebb3a5b4f9 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
  5. * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
  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. * \file htdocs/core/modules/commande/pdf_edison.modules.php
  23. * \ingroup commande
  24. * \brief Fichier de la classe permettant de generer les commandes au modele Edison
  25. */
  26. require_once(DOL_DOCUMENT_ROOT ."/core/modules/commande/modules_commande.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
  29. /**
  30. * \class pdf_edison
  31. * \brief Classe permettant de generer les commandes au modele Edison
  32. */
  33. class pdf_edison extends ModelePDFCommandes
  34. {
  35. var $emetteur; // Objet societe qui emet
  36. /**
  37. * Constructeur
  38. *
  39. * @param DoliDb $db Database access handler
  40. */
  41. function pdf_edison($db=0)
  42. {
  43. global $conf,$langs,$mysoc;
  44. $langs->load("main");
  45. $langs->load("bills");
  46. $this->db = $db;
  47. $this->name = "edison";
  48. $this->description = $langs->trans('PDFEdisonDescription');
  49. // Dimension page pour format A4
  50. $this->type = 'pdf';
  51. $formatarray=pdf_getFormat();
  52. $this->page_largeur = $formatarray['width'];
  53. $this->page_hauteur = $formatarray['height'];
  54. $this->format = array($this->page_largeur,$this->page_hauteur);
  55. $this->marge_gauche=10;
  56. $this->marge_droite=10;
  57. $this->marge_haute=10;
  58. $this->marge_basse=10;
  59. $this->option_multilang = 0; // Dispo en plusieurs langues
  60. $this->option_draft_watermark = 1; //Support add of a watermark on drafts
  61. // Recupere emmetteur
  62. $this->emetteur=$mysoc;
  63. if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // By default, if was not defined
  64. // Defini position des colonnes
  65. $this->posxdesc=$this->marge_gauche+1;
  66. $this->posxtva=111;
  67. $this->posxup=126;
  68. $this->posxqty=145;
  69. $this->posxdiscount=162;
  70. $this->postotalht=174;
  71. $this->tva=array();
  72. $this->atleastoneratenotnull=0;
  73. $this->atleastonediscount=0;
  74. }
  75. /**
  76. * Function to build pdf onto disk
  77. *
  78. * @param int $object Id of object to generate
  79. * @param object $outputlangs Lang output object
  80. * @param string $srctemplatepath Full path of source filename for generator using a template file
  81. * @param int $hidedetails Do not show line details
  82. * @param int $hidedesc Do not show desc
  83. * @param int $hideref Do not show ref
  84. * @param object $hookmanager Hookmanager object
  85. * @return int 1=OK, 0=KO
  86. */
  87. function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
  88. {
  89. global $user,$conf,$langs,$mysoc;
  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("orders");
  100. if ($conf->commande->dir_output)
  101. {
  102. // Definition of $dir and $file
  103. if ($object->specimen)
  104. {
  105. $dir = $conf->commande->dir_output;
  106. $file = $dir . "/SPECIMEN.pdf";
  107. }
  108. else
  109. {
  110. $objectref = dol_sanitizeFileName($object->ref);
  111. $dir = $conf->commande->dir_output . "/" . $objectref;
  112. $file = $dir . "/" . $objectref . ".pdf";
  113. }
  114. if (! file_exists($dir))
  115. {
  116. if (create_exdir($dir) < 0)
  117. {
  118. $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
  119. return 0;
  120. }
  121. }
  122. if (file_exists($dir))
  123. {
  124. $nblignes = count($object->lines);
  125. $pdf=pdf_getInstance($this->format);
  126. if (class_exists('TCPDF'))
  127. {
  128. $pdf->setPrintHeader(false);
  129. $pdf->setPrintFooter(false);
  130. }
  131. $pdf->SetFont(pdf_getPDFFont($outputlangs));
  132. $pdf->Open();
  133. $pagenb=0;
  134. $pdf->SetDrawColor(128,128,128);
  135. $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
  136. $pdf->SetSubject($outputlangs->transnoentities("Order"));
  137. $pdf->SetCreator("Dolibarr ".DOL_VERSION);
  138. $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
  139. $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
  140. if ($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. $pdf->SetAutoPageBreak(1,0);
  143. // New page
  144. $pdf->AddPage();
  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 = 100;
  151. $tab_height = 140;
  152. $pdf->SetFillColor(220,220,220);
  153. $pdf->SetTextColor(0,0,0);
  154. $pdf->SetFont('','', $default_font_size - 1);
  155. $pdf->SetXY(10, $tab_top + 10 );
  156. $iniY = $pdf->GetY();
  157. $curY = $pdf->GetY();
  158. $nexY = $pdf->GetY();
  159. $nblignes = count($object->lines);
  160. for ($i = 0 ; $i < $nblignes ; $i++)
  161. {
  162. $curY = $nexY;
  163. $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
  164. // Description of product line
  165. pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc,0,$hookmanager);
  166. $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
  167. $nexY = $pdf->GetY();
  168. $ref = pdf_getlineref($object, $i, $outputlangs, $hidedetails, $hookmanager);
  169. $pdf->SetXY(10, $curY);
  170. $pdf->MultiCell(20, 3, $ref, 0, 'C');
  171. $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
  172. $pdf->SetXY(133, $curY);
  173. $pdf->MultiCell(12, 3, $vat_rate, 0, 'C');
  174. $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
  175. $pdf->SetXY(145, $curY);
  176. $pdf->MultiCell(10, 3, $qty, 0, 'C');
  177. $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
  178. $pdf->SetXY(156, $curY);
  179. $pdf->MultiCell(18, 3, $up_excl_tax, 0, 'R', 0);
  180. $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
  181. $pdf->SetXY(174, $curY);
  182. $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0);
  183. $nexY+=2; // Passe espace entre les lignes
  184. // cherche nombre de lignes a venir pour savoir si place suffisante
  185. if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
  186. {
  187. //on recupere la description du produit suivant
  188. $follow_descproduitservice = $object->lines[$i+1]->desc;
  189. //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
  190. $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
  191. }
  192. else // If it's last line
  193. {
  194. $nblineFollowDesc = 0;
  195. }
  196. if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
  197. {
  198. $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
  199. // New page
  200. $pdf->AddPage();
  201. $pagenb++;
  202. $this->_pagehead($pdf, $object, 0, $outputlangs);
  203. $pdf->SetFont('','', $default_font_size - 1);
  204. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  205. $pdf->SetTextColor(0,0,0);
  206. $nexY = $tab_top + 8;
  207. }
  208. }
  209. $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
  210. $bottomlasttab=$tab_top + $tab_height + 1;
  211. // Affiche zone infos
  212. $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
  213. // Affiche zone totaux
  214. $tab2_top = 241;
  215. $tab2_lh = 4;
  216. $pdf->SetFont('','', $default_font_size);
  217. $pdf->SetXY(132, $tab2_top + 0);
  218. $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalHT"), 0, 'R', 0);
  219. $pdf->SetXY(132, $tab2_top + $tab2_lh);
  220. $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalVAT"), 0, 'R', 0);
  221. $pdf->SetXY(132, $tab2_top + ($tab2_lh*2));
  222. $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalTTC"), 1, 'R', 1);
  223. $pdf->SetXY(174, $tab2_top + 0);
  224. $pdf->MultiCell(26, $tab2_lh, price($object->total_ht), 0, 'R', 0);
  225. $pdf->SetXY(174, $tab2_top + $tab2_lh);
  226. $pdf->MultiCell(26, $tab2_lh, price($object->total_tva), 0, 'R', 0);
  227. $pdf->SetXY(174, $tab2_top + ($tab2_lh*2));
  228. $pdf->MultiCell(26, $tab2_lh, price($object->total_ttc), 1, 'R', 1);
  229. // Pied de page
  230. $this->_pagefoot($pdf,$object,$outputlangs);
  231. $pdf->AliasNbPages();
  232. $pdf->Close();
  233. $pdf->Output($file,'F');
  234. if (! empty($conf->global->MAIN_UMASK))
  235. @chmod($file, octdec($conf->global->MAIN_UMASK));
  236. return 1;
  237. }
  238. }
  239. else
  240. {
  241. $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
  242. return 0;
  243. }
  244. $this->error=$langs->transnoentities("ErrorUnknown");
  245. return 0; // Erreur par defaut
  246. }
  247. /**
  248. * \brief Affiche infos divers
  249. * \param pdf Objet PDF
  250. * \param object Objet commande
  251. * \param posy Position depart
  252. * \param outputlangs Objet langs
  253. * \return y Position pour suite
  254. */
  255. function _tableau_info(&$pdf, $object, $posy, $outputlangs)
  256. {
  257. global $conf;
  258. $default_font_size = pdf_getPDFFontSize($outputlangs);
  259. $pdf->SetFont('','', $default_font_size - 1);
  260. // If France, show VAT mention if not applicable
  261. if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
  262. {
  263. $pdf->SetFont('','B', $default_font_size - 2);
  264. $pdf->SetXY($this->marge_gauche, $posy);
  265. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
  266. $posy=$pdf->GetY()+4;
  267. }
  268. // Show payments conditions
  269. if ($object->cond_reglement_code || $object->cond_reglement)
  270. {
  271. $pdf->SetFont('','B', $default_font_size - 2);
  272. $pdf->SetXY($this->marge_gauche, $posy);
  273. $titre = $outputlangs->transnoentities("PaymentConditions").':';
  274. $pdf->MultiCell(80, 4, $titre, 0, 'L');
  275. $pdf->SetFont('','', $default_font_size - 2);
  276. $pdf->SetXY(52, $posy);
  277. $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
  278. $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
  279. $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
  280. $posy=$pdf->GetY()+3;
  281. }
  282. // Check a payment mode is defined
  283. /* Not used with orders
  284. if (empty($object->mode_reglement_code)
  285. && ! $conf->global->FACTURE_CHQ_NUMBER
  286. && ! $conf->global->FACTURE_RIB_NUMBER)
  287. {
  288. $pdf->SetXY($this->marge_gauche, $posy);
  289. $pdf->SetTextColor(200,0,0);
  290. $pdf->SetFont('','B', $default_font_size - 2);
  291. $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
  292. $pdf->SetTextColor(0,0,0);
  293. $posy=$pdf->GetY()+1;
  294. }*/
  295. // Show payment mode
  296. if ($object->mode_reglement_code
  297. && $object->mode_reglement_code != 'CHQ'
  298. && $object->mode_reglement_code != 'VIR')
  299. {
  300. $pdf->SetFont('','B', $default_font_size - 2);
  301. $pdf->SetXY($this->marge_gauche, $posy);
  302. $titre = $outputlangs->transnoentities("PaymentMode").':';
  303. $pdf->MultiCell(80, 5, $titre, 0, 'L');
  304. $pdf->SetFont('','', $default_font_size - 2);
  305. $pdf->SetXY(50, $posy);
  306. //print "xxx".$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code);exit;
  307. $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
  308. $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
  309. $posy=$pdf->GetY()+2;
  310. }
  311. // Show payment mode CHQ
  312. if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
  313. {
  314. // Si mode reglement non force ou si force a CHQ
  315. if ($conf->global->FACTURE_CHQ_NUMBER)
  316. {
  317. if ($conf->global->FACTURE_CHQ_NUMBER > 0)
  318. {
  319. $account = new Account($this->db);
  320. $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
  321. $pdf->SetXY($this->marge_gauche, $posy);
  322. $pdf->SetFont('','B', $default_font_size - 2);
  323. $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0);
  324. $posy=$pdf->GetY()+1;
  325. $pdf->SetXY($this->marge_gauche, $posy);
  326. $pdf->SetFont('','', $default_font_size - 2);
  327. $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
  328. $posy=$pdf->GetY()+2;
  329. }
  330. if ($conf->global->FACTURE_CHQ_NUMBER == -1)
  331. {
  332. $pdf->SetXY($this->marge_gauche, $posy);
  333. $pdf->SetFont('','B', $default_font_size - 2);
  334. $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->name).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0);
  335. $posy=$pdf->GetY()+1;
  336. $pdf->SetXY($this->marge_gauche, $posy);
  337. $pdf->SetFont('','', $default_font_size - 2);
  338. $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
  339. $posy=$pdf->GetY()+2;
  340. }
  341. }
  342. }
  343. // If payment mode not forced or forced to VIR, show payment with BAN
  344. /* Not enough space
  345. if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
  346. {
  347. if (! empty($conf->global->FACTURE_RIB_NUMBER))
  348. {
  349. $account = new Account($this->db);
  350. $account->fetch($conf->global->FACTURE_RIB_NUMBER);
  351. $curx=$this->marge_gauche;
  352. $cury=$posy;
  353. $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account);
  354. $posy+=2;
  355. }
  356. }
  357. */
  358. return $posy;
  359. }
  360. /**
  361. * Enter description here...
  362. *
  363. * @param $pdf
  364. * @param $tab_top
  365. * @param $tab_height
  366. * @param $nexY
  367. * @param $outputlangs
  368. */
  369. function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
  370. {
  371. global $langs,$conf;
  372. $langs->load("main");
  373. $langs->load("bills");
  374. $default_font_size = pdf_getPDFFontSize($outputlangs);
  375. $pdf->SetFont('','', $default_font_size - 1);
  376. $pdf->SetXY(30,$tab_top + 2);
  377. $pdf->MultiCell(20,4,$outputlangs->transnoentities("Designation"),0,'L');
  378. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
  379. {
  380. $pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
  381. $pdf->SetXY(133,$tab_top + 2);
  382. $pdf->MultiCell(12,4,$outputlangs->transnoentities("VAT"),'','C');
  383. }
  384. $pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
  385. $pdf->SetXY(145,$tab_top + 2);
  386. $pdf->MultiCell(12,4,$outputlangs->transnoentities("Qty"),'','C');
  387. $pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
  388. $pdf->SetXY(157,$tab_top + 2);
  389. $pdf->MultiCell(16,4,$outputlangs->transnoentities("PriceUHT"),'','C');
  390. $pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
  391. $pdf->SetXY(175,$tab_top + 2);
  392. $pdf->MultiCell(30,4,$outputlangs->transnoentities("TotalHT"),'','C');
  393. // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top);
  394. $pdf->Rect(10, $tab_top, 190, $tab_height);
  395. $pdf->line(10, $tab_top + 8, 200, $tab_top + 8);
  396. $pdf->SetTextColor(0,0,0);
  397. $pdf->SetFont('','', $default_font_size-1);
  398. $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie));
  399. $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
  400. $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
  401. }
  402. /**
  403. * Show header of page
  404. *
  405. * @param pdf Objet PDF
  406. * @param object Objet commande
  407. * @param showaddress 0=no, 1=yes
  408. * @param outputlangs Object lang for output
  409. */
  410. function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
  411. {
  412. global $conf,$langs,$mysoc;
  413. $langs->load("orders");
  414. $default_font_size = pdf_getPDFFontSize($outputlangs);
  415. pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
  416. //Affiche le filigrane brouillon - Print Draft Watermark
  417. if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
  418. {
  419. pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
  420. }
  421. $posy=$this->marge_haute;
  422. $pdf->SetXY($this->marge_gauche,$posy);
  423. // Logo
  424. $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
  425. if ($this->emetteur->logo)
  426. {
  427. if (is_readable($logo))
  428. {
  429. $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
  430. }
  431. else
  432. {
  433. $pdf->SetTextColor(200,0,0);
  434. $pdf->SetFont('','B', $default_font_size - 2);
  435. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
  436. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
  437. }
  438. }
  439. else
  440. {
  441. $text=$this->emetteur->name;
  442. $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
  443. }
  444. if ($showaddress)
  445. {
  446. $posy = 40;
  447. $posx=$this->marge_gauche;
  448. if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
  449. $hautcadre=40;
  450. $pdf->SetXY($posx,$posy+3);
  451. // Sender name
  452. $pdf->SetTextColor(0,0,60);
  453. $pdf->SetFont('','B', $default_font_size);
  454. $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
  455. // Sender properties
  456. $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
  457. $pdf->SetFont('','', $default_font_size - 1);
  458. $pdf->SetXY($posx,$posy+7);
  459. $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
  460. // Client destinataire
  461. $client = new Societe($this->db);
  462. $client->fetch($object->socid);
  463. $object->client = $client;
  464. // If CUSTOMER contact defined on invoice, we use it
  465. $usecontact=false;
  466. $arrayidcontact=$object->getIdContact('external','CUSTOMER');
  467. if (count($arrayidcontact) > 0)
  468. {
  469. $usecontact=true;
  470. $result=$object->fetch_contact($arrayidcontact[0]);
  471. }
  472. // Recipient name
  473. if (! empty($usecontact))
  474. {
  475. // On peut utiliser le nom de la societe du contact
  476. if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
  477. else $socname = $object->client->nom;
  478. $carac_client_name=$outputlangs->convToOutputCharset($socname);
  479. }
  480. else
  481. {
  482. $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
  483. }
  484. $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
  485. // Show recipient
  486. $posy=42;
  487. $posx=$this->page_largeur-$this->marge_droite-100;
  488. if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
  489. // Show recipient frame
  490. $pdf->SetTextColor(0,0,0);
  491. $pdf->SetFont('','', $default_font_size - 2);
  492. $pdf->SetXY($posx+2,$posy-5);
  493. $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":",0,'L');
  494. $pdf->rect($posx, $posy, 100, $hautcadre);
  495. // Show recipient name
  496. $pdf->SetXY($posx+2,$posy+3);
  497. $pdf->SetFont('','B', $default_font_size);
  498. $pdf->MultiCell(96,4, $carac_client_name, 0, 'L');
  499. // Show recipient information
  500. $pdf->SetFont('','', $default_font_size - 1);
  501. $pdf->SetXY($posx+2,$posy+8);
  502. $pdf->MultiCell(86,4, $carac_client, 0, 'L');
  503. }
  504. // Date - order
  505. $pdf->SetTextColor(200,0,0);
  506. $pdf->SetFont('','B', $default_font_size + 2);
  507. $pdf->SetXY(11, 88);
  508. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs), 0, 'L');
  509. $pdf->SetXY(11, 94);
  510. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
  511. }
  512. /**
  513. * Show footer of page
  514. * Need this->emetteur object
  515. *
  516. * @param pdf PDF factory
  517. * @param object Object invoice
  518. * @param outputlangs Object lang for output
  519. */
  520. function _pagefoot(&$pdf,$object,$outputlangs)
  521. {
  522. return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
  523. }
  524. }
  525. ?>