PageRenderTime 64ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/propal/core/modules/propale/doc/pdf_azur.modules.php

https://bitbucket.org/speedealing/speedealing
PHP | 1065 lines | 698 code | 170 blank | 197 comment | 140 complexity | 11692c3d813cbba5a40e466e4c436900 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
  5. * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
  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 3 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/propale/doc/pdf_azur.modules.php
  23. * \ingroup propale
  24. * \brief Fichier de la classe permettant de generer les propales au modele Azur
  25. */
  26. require_once DOL_DOCUMENT_ROOT . '/propal/core/modules/propale/modules_propale.php';
  27. require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
  28. //require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. require_once DOL_DOCUMENT_ROOT . '/societe/lib/societe.lib.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
  31. require_once DOL_DOCUMENT_ROOT . '/core/lib/pdf.lib.php';
  32. /**
  33. * Classe permettant de generer les propales au modele Azur
  34. */
  35. class pdf_azur extends ModelePDFPropales {
  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. var $emetteur; // Objet societe qui emet
  50. /**
  51. * Constructor
  52. *
  53. * @param DoliDB $db Database handler
  54. */
  55. function __construct($db = '') {
  56. global $conf, $langs, $mysoc;
  57. $langs->load("main");
  58. $langs->load("bills");
  59. $this->db = $db;
  60. $this->name = "azur";
  61. $this->description = $langs->trans('DocModelAzurDescription');
  62. // Dimension page pour format A4
  63. $this->type = 'pdf';
  64. $formatarray = pdf_getFormat();
  65. $this->page_largeur = $formatarray['width'];
  66. $this->page_hauteur = $formatarray['height'];
  67. $this->format = array($this->page_largeur, $this->page_hauteur);
  68. $this->marge_gauche = 10;
  69. $this->marge_droite = 10;
  70. $this->marge_haute = 10;
  71. $this->marge_basse = 10;
  72. $this->option_logo = 1; // Affiche logo
  73. $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
  74. $this->option_modereg = 1; // Affiche mode reglement
  75. $this->option_condreg = 1; // Affiche conditions reglement
  76. $this->option_codeproduitservice = 1; // Affiche code produit-service
  77. $this->option_multilang = 1; // Dispo en plusieurs langues
  78. $this->option_escompte = 1; // Affiche si il y a eu escompte
  79. $this->option_credit_note = 1; // Support credit notes
  80. $this->option_freetext = 1; // Support add of a personalised text
  81. $this->option_draft_watermark = 1; //Support add of a watermark on drafts
  82. $this->franchise = !$mysoc->tva_assuj;
  83. // Get source company
  84. $this->emetteur = $mysoc;
  85. if (!$this->emetteur->country_code)
  86. $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
  87. // Defini position des colonnes
  88. $this->posxdesc = $this->marge_gauche + 1;
  89. $this->posxtva = 111;
  90. $this->posxup = 126;
  91. $this->posxqty = 145;
  92. $this->posxdiscount = 162;
  93. $this->postotalht = 174;
  94. $this->tva = array();
  95. $this->localtax1 = array();
  96. $this->localtax2 = array();
  97. $this->atleastoneratenotnull = 0;
  98. $this->atleastonediscount = 0;
  99. }
  100. /**
  101. * Function to build pdf onto disk
  102. *
  103. * @param Object $object Object to generate
  104. * @param Translate $outputlangs Lang output object
  105. * @param string $srctemplatepath Full path of source filename for generator using a template file
  106. * @param int $hidedetails Do not show line details
  107. * @param int $hidedesc Do not show desc
  108. * @param int $hideref Do not show ref
  109. * @return int 1=OK, 0=KO
  110. */
  111. function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) {
  112. global $user, $langs, $conf, $hookmanager;
  113. if (!is_object($outputlangs))
  114. $outputlangs = $langs;
  115. // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
  116. if (!empty($conf->global->MAIN_USE_FPDF))
  117. $outputlangs->charset_output = 'ISO-8859-1';
  118. $outputlangs->load("main");
  119. $outputlangs->load("dict");
  120. $outputlangs->load("companies");
  121. $outputlangs->load("bills");
  122. $outputlangs->load("propal");
  123. $outputlangs->load("products");
  124. $default_font_size = pdf_getPDFFontSize($outputlangs);
  125. if ($conf->propal->dir_output) {
  126. $object->fetch_thirdparty();
  127. // $deja_regle = 0;
  128. // Definition of $dir and $file
  129. if ($object->specimen) {
  130. $dir = $conf->propal->dir_output;
  131. $file = $dir . "/SPECIMEN.pdf";
  132. } else {
  133. $objectref = dol_sanitizeFileName($object->ref);
  134. $dir = $conf->propal->dir_output . "/" . $objectref;
  135. $file = $dir . "/" . $objectref . ".pdf";
  136. }
  137. if (!file_exists($dir)) {
  138. if (dol_mkdir($dir) < 0) {
  139. $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
  140. return 0;
  141. }
  142. }
  143. if (file_exists($dir)) {
  144. $nblignes = count($object->lines);
  145. // Create pdf instance
  146. $pdf = pdf_getInstance($this->format);
  147. $heightforinfotot = 50; // Height reserved to output the info and total part
  148. $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
  149. $pdf->SetAutoPageBreak(1, 0);
  150. if (class_exists('TCPDF')) {
  151. $pdf->setPrintHeader(false);
  152. $pdf->setPrintFooter(false);
  153. }
  154. $pdf->SetFont(pdf_getPDFFont($outputlangs));
  155. // Set path to the background PDF File
  156. if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
  157. $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
  158. $tplidx = $pdf->importPage(1);
  159. }
  160. $pdf->Open();
  161. $pagenb = 0;
  162. $pdf->SetDrawColor(128, 128, 128);
  163. $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
  164. $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal"));
  165. $pdf->SetCreator("Speedealing " . DOL_VERSION);
  166. $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
  167. $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("CommercialProposal"));
  168. if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION))
  169. $pdf->SetCompression(false);
  170. $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
  171. // Positionne $this->atleastonediscount si on a au moins une remise
  172. for ($i = 0; $i < $nblignes; $i++) {
  173. if ($object->lines[$i]->remise_percent) {
  174. $this->atleastonediscount++;
  175. }
  176. }
  177. // New page
  178. $pdf->AddPage();
  179. if (!empty($tplidx))
  180. $pdf->useTemplate($tplidx);
  181. $pagenb++;
  182. $this->_pagehead($pdf, $object, 1, $outputlangs);
  183. $pdf->SetFont('', '', $default_font_size - 1);
  184. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  185. $pdf->SetTextColor(0, 0, 0);
  186. $tab_top = 90;
  187. $tab_top_middlepage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
  188. $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
  189. $tab_height = 130;
  190. $tab_height_middlepage = 200;
  191. $tab_height_newpage = 150;
  192. // Affiche notes
  193. if (!empty($object->note_public)) {
  194. $tab_top = 88;
  195. $pdf->SetFont('', '', $default_font_size - 1);
  196. $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
  197. $nexY = $pdf->GetY();
  198. $height_note = $nexY - $tab_top;
  199. // Rect prend une longueur en 3eme param
  200. $pdf->SetDrawColor(192, 192, 192);
  201. $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
  202. $tab_height = $tab_height - $height_note;
  203. $tab_top = $nexY + 6;
  204. } else {
  205. $height_note = 0;
  206. }
  207. $iniY = $tab_top + 7;
  208. $curY = $tab_top + 7;
  209. $nexY = $tab_top + 7;
  210. // Loop on each lines
  211. for ($i = 0; $i < $nblignes; $i++) {
  212. $curY = $nexY;
  213. $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
  214. $pdf->SetTextColor(0, 0, 0);
  215. $pdf->setTopMargin($tab_top_newpage);
  216. $pdf->setPageOrientation('', 1, $this->marge_basse + $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
  217. $pageposbefore = $pdf->getPage();
  218. // Description of product line
  219. $curX = $this->posxdesc - 1;
  220. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
  221. $nexY = $pdf->GetY();
  222. $pageposafter = $pdf->getPage();
  223. $pdf->setPage($pageposbefore);
  224. $pdf->setTopMargin($this->marge_haute);
  225. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  226. // We suppose that a too long description is moved completely on next page
  227. if ($pageposafter > $pageposbefore) {
  228. $pdf->setPage($pageposafter);
  229. $curY = $tab_top_newpage;
  230. }
  231. $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
  232. // VAT Rate
  233. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
  234. $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
  235. $pdf->SetXY($this->posxtva, $curY);
  236. $pdf->MultiCell($this->posxup - $this->posxtva - 1, 4, $vat_rate, 0, 'R');
  237. }
  238. // Unit price before discount
  239. $up_excl_tax = price($object->lines[$i]->pu_ht);//pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
  240. $pdf->SetXY($this->posxup, $curY);
  241. $pdf->MultiCell($this->posxqty - $this->posxup - 1, 4, $up_excl_tax, 0, 'R', 0);
  242. // Quantity
  243. $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
  244. $pdf->SetXY($this->posxqty, $curY);
  245. $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 4, $qty, 0, 'R');
  246. // Discount on line
  247. $pdf->SetXY($this->posxdiscount, $curY);
  248. if ($object->lines[$i]->remise_percent) {
  249. $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
  250. $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 4, $remise_percent, 0, 'R');
  251. }
  252. // Total HT line
  253. $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
  254. $pdf->SetXY($this->postotalht, $curY);
  255. $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 4, $total_excl_tax, 0, 'R', 0);
  256. // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
  257. $tvaligne = $object->lines[$i]->total_tva;
  258. $localtax1ligne = $object->lines[$i]->total_localtax1;
  259. $localtax2ligne = $object->lines[$i]->total_localtax2;
  260. if ($object->remise_percent)
  261. $tvaligne-=($tvaligne * $object->remise_percent) / 100;
  262. if ($object->remise_percent)
  263. $localtax1ligne-=($localtax1ligne * $object->remise_percent) / 100;
  264. if ($object->remise_percent)
  265. $localtax2ligne-=($localtax2ligne * $object->remise_percent) / 100;
  266. $vatrate = (string) $object->lines[$i]->tva_tx;
  267. $localtax1rate = (string) $object->lines[$i]->localtax1_tx;
  268. $localtax2rate = (string) $object->lines[$i]->localtax2_tx;
  269. if (($object->lines[$i]->info_bits & 0x01) == 0x01)
  270. $vatrate.='*';
  271. if (!isset($this->tva[$vatrate]))
  272. $this->tva[$vatrate] = '';
  273. if (!isset($this->localtax1[$localtax1rate]))
  274. $this->localtax1[$localtax1rate] = '';
  275. if (!isset($this->localtax2[$localtax2rate]))
  276. $this->localtax2[$localtax2rate] = '';
  277. $this->tva[$vatrate] += $tvaligne;
  278. $this->localtax1[$localtax1rate]+=$localtax1ligne;
  279. $this->localtax2[$localtax2rate]+=$localtax2ligne;
  280. $nexY+=2; // Passe espace entre les lignes
  281. // Detect if some page were added automatically and output _tableau for past pages
  282. while ($pagenb < $pageposafter) {
  283. $pdf->setPage($pagenb);
  284. if ($pagenb == 1) {
  285. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  286. } else {
  287. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  288. }
  289. $this->_pagefoot($pdf, $object, $outputlangs);
  290. $pagenb++;
  291. $pdf->setPage($pagenb);
  292. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  293. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD))
  294. $this->_pagehead($pdf, $object, 0, $outputlangs);
  295. }
  296. if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
  297. if ($pagenb == 1) {
  298. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  299. } else {
  300. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  301. }
  302. $this->_pagefoot($pdf, $object, $outputlangs);
  303. // New page
  304. $pdf->AddPage();
  305. if (!empty($tplidx))
  306. $pdf->useTemplate($tplidx);
  307. $pagenb++;
  308. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD))
  309. $this->_pagehead($pdf, $object, 0, $outputlangs);
  310. }
  311. }
  312. // Show square
  313. if ($pagenb == 1) {
  314. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0);
  315. $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfooter + 1;
  316. } else {
  317. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0);
  318. $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfooter + 1;
  319. }
  320. // Affiche zone infos
  321. $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
  322. // Affiche zone totaux
  323. //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
  324. $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
  325. // Affiche zone versements
  326. /*
  327. if ($deja_regle)
  328. {
  329. $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
  330. }
  331. */
  332. // Pied de page
  333. $this->_pagefoot($pdf, $object, $outputlangs);
  334. $pdf->AliasNbPages();
  335. $pdf->Close();
  336. $pdf->Output($file, 'F');
  337. //Add pdfgeneration hook
  338. $hookmanager->initHooks(array('pdfgeneration'));
  339. $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
  340. global $action;
  341. $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  342. if (!empty($conf->global->MAIN_UMASK))
  343. @chmod($file, octdec($conf->global->MAIN_UMASK));
  344. return 1; // Pas d'erreur
  345. }
  346. else {
  347. $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
  348. return 0;
  349. }
  350. } else {
  351. $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
  352. return 0;
  353. }
  354. $this->error = $langs->trans("ErrorUnknown");
  355. return 0; // Erreur par defaut
  356. }
  357. /**
  358. * Show payments table
  359. *
  360. * @param PDF &$pdf Object PDF
  361. * @param Object $object Object invoice
  362. * @param int $posy Position y in PDF
  363. * @param Translate $outputlangs Object langs for output
  364. * @return int <0 if KO, >0 if OK
  365. */
  366. function _tableau_versements(&$pdf, $object, $posy, $outputlangs) {
  367. }
  368. /**
  369. * Show miscellaneous information (payment mode, payment term, ...)
  370. *
  371. * @param PDF &$pdf Object PDF
  372. * @param Object $object Object to show
  373. * @param int $posy Y
  374. * @param Translate $outputlangs Langs object
  375. * @return void
  376. */
  377. function _tableau_info(&$pdf, $object, $posy, $outputlangs) {
  378. global $conf;
  379. $default_font_size = pdf_getPDFFontSize($outputlangs);
  380. $pdf->SetFont('', '', $default_font_size - 1);
  381. // If France, show VAT mention if not applicable
  382. if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) {
  383. $pdf->SetFont('', 'B', $default_font_size - 2);
  384. $pdf->SetXY($this->marge_gauche, $posy);
  385. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
  386. $posy = $pdf->GetY() + 4;
  387. }
  388. // Show shipping date
  389. if (/* isset($object->type) && $object->type != 2 && */ $object->date_livraison) {
  390. $outputlangs->load("sendings");
  391. $pdf->SetFont('', 'B', $default_font_size - 2);
  392. $pdf->SetXY($this->marge_gauche, $posy);
  393. $titre = $outputlangs->transnoentities("DateDeliveryPlanned") . ':';
  394. $pdf->MultiCell(80, 4, $titre, 0, 'L');
  395. $pdf->SetFont('', '', $default_font_size - 2);
  396. $pdf->SetXY(82, $posy);
  397. $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
  398. $pdf->MultiCell(80, 4, $dlp, 0, 'L');
  399. $posy = $pdf->GetY() + 1;
  400. }
  401. // elseif (isset($object->type) && $object->type != 2 && ($object->availability_code || $object->availability)) // Show availability conditions
  402. elseif (isset($object->availability_code) && !empty($object->availability_code)) { // Show availability conditions
  403. $pdf->SetFont('', 'B', $default_font_size - 2);
  404. $pdf->SetXY($this->marge_gauche, $posy);
  405. $titre = $outputlangs->transnoentities("AvailabilityPeriod") . ':';
  406. $pdf->MultiCell(80, 4, $titre, 0, 'L');
  407. $pdf->SetTextColor(0, 0, 0);
  408. $pdf->SetFont('', '', $default_font_size - 2);
  409. $pdf->SetXY(82, $posy);
  410. // $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
  411. $lib_availability = $outputlangs->transnoentities($object->getExtraFieldLabel('availability_code')) != ($object->getExtraFieldLabel('availability_code')) ? $outputlangs->transnoentities($object->getExtraFieldLabel('availability_code')) : $outputlangs->convToOutputCharset($object->getExtraFieldLabel('availability_code'));
  412. $lib_availability = str_replace('\n', "\n", $lib_availability);
  413. $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
  414. $posy = $pdf->GetY() + 1;
  415. }
  416. // Show payments conditions
  417. if (/*isset($object->type) && $object->type != 2 && */($object->cond_reglement_code)) {
  418. $pdf->SetFont('', 'B', $default_font_size - 2);
  419. $pdf->SetXY($this->marge_gauche, $posy);
  420. $titre = $outputlangs->transnoentities("PaymentConditions") . ':';
  421. $pdf->MultiCell(80, 4, $titre, 0, 'L');
  422. $pdf->SetFont('', '', $default_font_size - 2);
  423. $pdf->SetXY(52, $posy);
  424. $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition" . $object->getExtraFieldLabel('cond_reglement_code')) != ('PaymentCondition' . $object->getExtraFieldLabel('cond_reglement_code')) ? $outputlangs->transnoentities("PaymentCondition" . $object->getExtraFieldLabel('cond_reglement_code')) : $outputlangs->convToOutputCharset($object->getExtraFieldLabel('cond_reglement_code'));
  425. $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
  426. $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
  427. $posy = $pdf->GetY() + 3;
  428. }
  429. if (/*isset($object->type) && $object->type != 2*/ true) {
  430. // Check a payment mode is defined
  431. if (empty($object->mode_reglement_code)
  432. && !$conf->global->FACTURE_CHQ_NUMBER
  433. && !$conf->global->FACTURE_RIB_NUMBER) {
  434. $pdf->SetXY($this->marge_gauche, $posy);
  435. $pdf->SetTextColor(200, 0, 0);
  436. $pdf->SetFont('', 'B', $default_font_size - 2);
  437. $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"), 0, 'L', 0);
  438. $pdf->SetTextColor(0, 0, 0);
  439. $posy = $pdf->GetY() + 1;
  440. }
  441. // Show payment mode
  442. if (isset($object->mode_reglement_code) && !empty($object->mode_reglement_code)
  443. && $object->mode_reglement_code != 'CHQ'
  444. && $object->mode_reglement_code != 'VIR') {
  445. $pdf->SetFont('', 'B', $default_font_size - 2);
  446. $pdf->SetXY($this->marge_gauche, $posy);
  447. $titre = $outputlangs->transnoentities("PaymentMode") . ':';
  448. $pdf->MultiCell(80, 5, $titre, 0, 'L');
  449. $pdf->SetFont('', '', $default_font_size - 2);
  450. $pdf->SetXY(50, $posy);
  451. $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_code);
  452. $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
  453. $posy = $pdf->GetY() + 2;
  454. }
  455. // Show payment mode CHQ
  456. if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
  457. // Si mode reglement non force ou si force a CHQ
  458. if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
  459. if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
  460. $account = new Account($this->db);
  461. $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
  462. $pdf->SetXY($this->marge_gauche, $posy);
  463. $pdf->SetFont('', 'B', $default_font_size - 3);
  464. $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio) . ':', 0, 'L', 0);
  465. $posy = $pdf->GetY() + 1;
  466. $pdf->SetXY($this->marge_gauche, $posy);
  467. $pdf->SetFont('', '', $default_font_size - 3);
  468. $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
  469. $posy = $pdf->GetY() + 2;
  470. }
  471. if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
  472. $pdf->SetXY($this->marge_gauche, $posy);
  473. $pdf->SetFont('', 'B', $default_font_size - 3);
  474. $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort') . ' ' . $outputlangs->convToOutputCharset($this->emetteur->name) . ' ' . $outputlangs->transnoentities('SendTo') . ':', 0, 'L', 0);
  475. $posy = $pdf->GetY() + 1;
  476. $pdf->SetXY($this->marge_gauche, $posy);
  477. $pdf->SetFont('', '', $default_font_size - 3);
  478. $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
  479. $posy = $pdf->GetY() + 2;
  480. }
  481. }
  482. }
  483. // If payment mode not forced or forced to VIR, show payment with BAN
  484. if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
  485. if (!empty($conf->global->FACTURE_RIB_NUMBER)) {
  486. $account = new Account($this->db);
  487. $account->fetch($conf->global->FACTURE_RIB_NUMBER);
  488. $curx = $this->marge_gauche;
  489. $cury = $posy;
  490. $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
  491. $posy+=2;
  492. }
  493. }
  494. }
  495. return $posy;
  496. }
  497. /**
  498. * Show total to pay
  499. *
  500. * @param PDF &$pdf Object PDF
  501. * @param Facture $object Object invoice
  502. * @param int $deja_regle Montant deja regle
  503. * @param int $posy Position depart
  504. * @param Translate $outputlangs Objet langs
  505. * @return int Position pour suite
  506. */
  507. function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) {
  508. global $conf, $mysoc;
  509. $default_font_size = pdf_getPDFFontSize($outputlangs);
  510. $tab2_top = $posy;
  511. $tab2_hl = 4;
  512. $pdf->SetFont('', '', $default_font_size - 1);
  513. // Tableau total
  514. $col1x = 120;
  515. $col2x = 170;
  516. $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
  517. $index = 0;
  518. // Total HT
  519. $pdf->SetFillColor(255, 255, 255);
  520. $pdf->SetXY($col1x, $tab2_top + 0);
  521. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
  522. $pdf->SetXY($col2x, $tab2_top + 0);
  523. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1);
  524. // Show VAT by rates and total
  525. $pdf->SetFillColor(248, 248, 248);
  526. $this->atleastoneratenotnull = 0;
  527. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
  528. $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
  529. if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
  530. // Nothing to do
  531. } else {
  532. foreach ($this->tva as $tvakey => $tvaval) {
  533. if ($tvakey > 0) { // On affiche pas taux 0
  534. $this->atleastoneratenotnull++;
  535. $index++;
  536. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  537. $tvacompl = '';
  538. if (preg_match('/\*/', $tvakey)) {
  539. $tvakey = str_replace('*', '', $tvakey);
  540. $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
  541. }
  542. $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
  543. $totalvat.=vatrate($tvakey, 1) . $tvacompl;
  544. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
  545. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  546. $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
  547. }
  548. }
  549. if (!$this->atleastoneratenotnull) { // If no vat at all
  550. $index++;
  551. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  552. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
  553. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  554. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
  555. // Total LocalTax1
  556. if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) {
  557. $index++;
  558. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  559. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1" . $mysoc->pays_code), 0, 'L', 1);
  560. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  561. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1);
  562. }
  563. // Total LocalTax2
  564. if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) {
  565. $index++;
  566. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  567. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2" . $mysoc->pays_code), 0, 'L', 1);
  568. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  569. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1);
  570. }
  571. } else {
  572. if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on') {
  573. //Local tax 1
  574. foreach ($this->localtax1 as $tvakey => $tvaval) {
  575. if ($tvakey != 0) { // On affiche pas taux 0
  576. //$this->atleastoneratenotnull++;
  577. $index++;
  578. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  579. $tvacompl = '';
  580. if (preg_match('/\*/', $tvakey)) {
  581. $tvakey = str_replace('*', '', $tvakey);
  582. $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
  583. }
  584. $totalvat = $outputlangs->transnoentities("TotalLT1" . $mysoc->pays_code) . ' ';
  585. $totalvat.=vatrate($tvakey, 1) . $tvacompl;
  586. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
  587. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  588. $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
  589. }
  590. }
  591. }
  592. if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on') {
  593. //Local tax 2
  594. foreach ($this->localtax2 as $tvakey => $tvaval) {
  595. if ($tvakey != 0) { // On affiche pas taux 0
  596. //$this->atleastoneratenotnull++;
  597. $index++;
  598. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  599. $tvacompl = '';
  600. if (preg_match('/\*/', $tvakey)) {
  601. $tvakey = str_replace('*', '', $tvakey);
  602. $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
  603. }
  604. $totalvat = $outputlangs->transnoentities("TotalLT2" . $mysoc->pays_code) . ' ';
  605. $totalvat.=vatrate($tvakey, 1) . $tvacompl;
  606. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
  607. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  608. $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
  609. }
  610. }
  611. }
  612. }
  613. $useborder = 0;
  614. // Total TTC
  615. $index++;
  616. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  617. $pdf->SetTextColor(0, 0, 60);
  618. $pdf->SetFillColor(224, 224, 224);
  619. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
  620. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  621. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
  622. }
  623. }
  624. $pdf->SetTextColor(0, 0, 0);
  625. /*
  626. $resteapayer = $object->total_ttc - $deja_regle;
  627. if (! empty($object->paye)) $resteapayer=0;
  628. */
  629. if ($deja_regle > 0) {
  630. $index++;
  631. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  632. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
  633. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  634. $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
  635. /*
  636. if ($object->close_code == 'discount_vat')
  637. {
  638. $index++;
  639. $pdf->SetFillColor(255,255,255);
  640. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  641. $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
  642. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  643. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);
  644. $resteapayer=0;
  645. }
  646. */
  647. $index++;
  648. $pdf->SetTextColor(0, 0, 60);
  649. $pdf->SetFillColor(224, 224, 224);
  650. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  651. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
  652. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  653. $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
  654. // Fin
  655. $pdf->SetFont('', '', $default_font_size - 1);
  656. $pdf->SetTextColor(0, 0, 0);
  657. }
  658. $index++;
  659. return ($tab2_top + ($tab2_hl * $index));
  660. }
  661. /**
  662. * Show table for lines
  663. *
  664. * @param PDF &$pdf Object PDF
  665. * @param string $tab_top Top position of table
  666. * @param string $tab_height Height of table (rectangle)
  667. * @param int $nexY Y
  668. * @param Translate $outputlangs Langs object
  669. * @param int $hidetop Hide top bar of array
  670. * @param int $hidebottom Hide bottom bar of array
  671. * @return void
  672. */
  673. function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) {
  674. global $conf;
  675. // Force to disable hidetop and hidebottom
  676. $hidebottom = 0;
  677. if ($hidetop)
  678. $hidetop = -1;
  679. $default_font_size = pdf_getPDFFontSize($outputlangs);
  680. // Amount in (at tab_top - 1)
  681. $pdf->SetTextColor(0, 0, 0);
  682. $pdf->SetFont('', '', $default_font_size - 2);
  683. if (empty($hidetop)) {
  684. $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency));
  685. $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
  686. $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
  687. }
  688. $pdf->SetDrawColor(128, 128, 128);
  689. $pdf->SetFont('', '', $default_font_size - 1);
  690. // Output Rect
  691. $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
  692. if (empty($hidetop)) {
  693. $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
  694. $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
  695. $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
  696. }
  697. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
  698. $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
  699. if (empty($hidetop)) {
  700. $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
  701. $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
  702. }
  703. }
  704. $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
  705. if (empty($hidetop)) {
  706. $pdf->SetXY($this->posxup - 1, $tab_top + 1);
  707. $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
  708. }
  709. $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
  710. if (empty($hidetop)) {
  711. $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
  712. $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
  713. }
  714. $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
  715. if (empty($hidetop)) {
  716. if ($this->atleastonediscount) {
  717. $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
  718. $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
  719. }
  720. }
  721. if ($this->atleastonediscount) {
  722. $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
  723. }
  724. if (empty($hidetop)) {
  725. $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
  726. $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
  727. }
  728. }
  729. /**
  730. * Show top header of page.
  731. *
  732. * @param PDF &$pdf Object PDF
  733. * @param Object $object Object to show
  734. * @param int $showaddress 0=no, 1=yes
  735. * @param Translate $outputlangs Object lang for output
  736. * @return void
  737. */
  738. function _pagehead(&$pdf, $object, $showaddress, $outputlangs) {
  739. global $conf, $langs;
  740. $outputlangs->load("main");
  741. $outputlangs->load("bills");
  742. $outputlangs->load("propal");
  743. $outputlangs->load("companies");
  744. $default_font_size = pdf_getPDFFontSize($outputlangs);
  745. pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
  746. // Show Draft Watermark
  747. if ($object->Status == "DRAFT" && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) {
  748. pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
  749. }
  750. $pdf->SetTextColor(0, 0, 60);
  751. $pdf->SetFont('', 'B', $default_font_size + 3);
  752. $posy = $this->marge_haute;
  753. $posx = $this->page_largeur - $this->marge_droite - 100;
  754. $pdf->SetXY($this->marge_gauche, $posy);
  755. // Logo
  756. $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
  757. if ($this->emetteur->logo) {
  758. if (is_readable($logo)) {
  759. $height = pdf_getHeightForLogo($logo);
  760. $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
  761. } else {
  762. $pdf->SetTextColor(200, 0, 0);
  763. $pdf->SetFont('', 'B', $default_font_size - 2);
  764. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
  765. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
  766. }
  767. } else {
  768. $text = $this->emetteur->name;
  769. $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
  770. }
  771. $pdf->SetFont('', 'B', $default_font_size + 3);
  772. $pdf->SetXY($posx, $posy);
  773. $pdf->SetTextColor(0, 0, 60);
  774. $title = $outputlangs->transnoentities("CommercialProposal");
  775. $pdf->MultiCell(100, 4, $title, '', 'R');
  776. $pdf->SetFont('', 'B', $default_font_size);
  777. $posy+=5;
  778. $pdf->SetXY($posx, $posy);
  779. $pdf->SetTextColor(0, 0, 60);
  780. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
  781. $posy+=1;
  782. $pdf->SetFont('', '', $default_font_size - 1);
  783. if ($object->ref_client) {
  784. $posy+=5;
  785. $pdf->SetXY($posx, $posy);
  786. $pdf->SetTextColor(0, 0, 60);
  787. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
  788. }
  789. $posy+=4;
  790. $pdf->SetXY($posx, $posy);
  791. $pdf->SetTextColor(0, 0, 60);
  792. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
  793. $posy+=4;
  794. $pdf->SetXY($posx, $posy);
  795. $pdf->SetTextColor(0, 0, 60);
  796. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal") . " : " . dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
  797. if ($object->thirdparty->code_client) {
  798. $posy+=4;
  799. $pdf->SetXY($posx, $posy);
  800. $pdf->SetTextColor(0, 0, 60);
  801. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
  802. }
  803. $posy+=2;
  804. // Show list of linked objects
  805. $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
  806. if ($showaddress) {
  807. // Sender properties
  808. $carac_emetteur = '';
  809. // Add internal contact of proposal if defined
  810. $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
  811. if (count($arrayidcontact) > 0) {
  812. $object->fetch_user($arrayidcontact[0]);
  813. $carac_emetteur .= ($carac_emetteur ? "\n" : '' ) . $outputlangs->transnoentities("Name") . ": " . $outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)) . "\n";
  814. }
  815. $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur);
  816. // Show sender
  817. $posy = 42;
  818. $posx = $this->marge_gauche;
  819. if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))
  820. $posx = $this->page_largeur - $this->marge_droite - 80;
  821. $hautcadre = 40;
  822. // Show sender frame
  823. $pdf->SetTextColor(0, 0, 0);
  824. $pdf->SetFont('', '', $default_font_size - 2);
  825. $pdf->SetXY($posx, $posy - 5);
  826. $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
  827. $pdf->SetXY($posx, $posy);
  828. $pdf->SetFillColor(230, 230, 230);
  829. $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
  830. $pdf->SetTextColor(0, 0, 60);
  831. // Show sender name
  832. $pdf->SetXY($posx + 2, $posy + 3);
  833. $pdf->SetFont('', 'B', $default_font_size);
  834. $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
  835. // Show sender information
  836. $pdf->SetXY($posx + 2, $posy + 8);
  837. $pdf->SetFont('', '', $default_font_size - 1);
  838. $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
  839. // If CUSTOMER contact defined, we use it
  840. $usecontact = false;
  841. $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
  842. if (count($arrayidcontact) > 0) {
  843. $usecontact = true;
  844. $result = $object->fetch_contact($arrayidcontact[0]);
  845. }
  846. // Recipient name
  847. if (!empty($usecontact)) {
  848. // On peut utiliser le nom de la societe du contact
  849. if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
  850. $socname = $object->contact->socname;
  851. else
  852. $socname = $object->thirdparty->name;
  853. $carac_client_name = $outputlangs->convToOutputCharset($socname);
  854. }
  855. else {
  856. $carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
  857. }
  858. $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target');
  859. // Show recipient
  860. $posy = 42;
  861. $posx = $this->page_largeur - $this->marge_droite - 100;
  862. if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))
  863. $posx = $this->marge_gauche;
  864. // Show recipient frame
  865. $pdf->SetTextColor(0, 0, 0);
  866. $pdf->SetFont('', '', $default_font_size - 2);
  867. $pdf->SetXY($posx + 2, $posy - 5);
  868. $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
  869. $pdf->Rect($posx, $posy, 100, $hautcadre);
  870. // Show recipient name
  871. $pdf->SetXY($posx + 2, $posy + 3);
  872. $pdf->SetFont('', 'B', $default_font_size);
  873. $pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
  874. // Show recipient information
  875. $pdf->SetFont('', '', $default_font_size - 1);
  876. $pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
  877. $pdf->MultiCell(86, 4, $carac_cli

Large files files are truncated, but you can click here to view the full file