dolibarr  18.0.0
pdf_eratosthene.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5  * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
10  * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  * or see https://www.gnu.org/
25  */
26 
33 require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
34 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
38 
39 
44 {
48  public $db;
49 
53  public $entity;
54 
58  public $name;
59 
63  public $description;
64 
68  public $update_main_doc_field;
69 
73  public $type;
74 
79  public $version = 'dolibarr';
80 
84  public $page_largeur;
85 
89  public $page_hauteur;
90 
94  public $format;
95 
99  public $marge_gauche;
100 
104  public $marge_droite;
105 
109  public $marge_haute;
110 
114  public $marge_basse;
115 
120  public $emetteur;
121 
125  public $cols;
126 
127 
133  public function __construct($db)
134  {
135  global $conf, $langs, $mysoc;
136 
137  // Translations
138  $langs->loadLangs(array("main", "bills", "products"));
139 
140  $this->db = $db;
141  $this->name = "eratosthene";
142  $this->description = $langs->trans('PDFEratostheneDescription');
143  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
144 
145  // Dimension page
146  $this->type = 'pdf';
147  $formatarray = pdf_getFormat();
148  $this->page_largeur = $formatarray['width'];
149  $this->page_hauteur = $formatarray['height'];
150  $this->format = array($this->page_largeur, $this->page_hauteur);
151  $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
152  $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
153  $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
154  $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
155 
156  $this->option_logo = 1; // Display logo
157  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
158  $this->option_modereg = 1; // Display payment mode
159  $this->option_condreg = 1; // Display payment terms
160  $this->option_multilang = 1; // Available in several languages
161  $this->option_escompte = 0; // Displays if there has been a discount
162  $this->option_credit_note = 0; // Support credit notes
163  $this->option_freetext = 1; // Support add of a personalised text
164  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
165  $this->watermark = '';
166 
167  // Get source company
168  $this->emetteur = $mysoc;
169  if (empty($this->emetteur->country_code)) {
170  $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
171  }
172 
173  // Define position of columns
174  $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
175 
176 
177  $this->tabTitleHeight = 5; // default height
178 
179  // Use new system for position of columns, view $this->defineColumnField()
180 
181  $this->tva = array();
182  $this->tva_array = array();
183  $this->localtax1 = array();
184  $this->localtax2 = array();
185  $this->atleastoneratenotnull = 0;
186  $this->atleastonediscount = 0;
187  }
188 
189  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
201  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
202  {
203  // phpcs:enable
204  global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
205 
206  if (!is_object($outputlangs)) {
207  $outputlangs = $langs;
208  }
209  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
210  if (!empty($conf->global->MAIN_USE_FPDF)) {
211  $outputlangs->charset_output = 'ISO-8859-1';
212  }
213 
214  // Load translation files required by the page
215  $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
216 
217  // Show Draft Watermark
218  if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) {
219  $this->watermark = getDolGlobalString('COMMANDE_DRAFT_WATERMARK');
220  }
221 
222  global $outputlangsbis;
223  $outputlangsbis = null;
224  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
225  $outputlangsbis = new Translate('', $conf);
226  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
227  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
228  }
229 
230  $nblines = count($object->lines);
231 
232  $hidetop = 0;
233  if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
234  $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
235  }
236 
237  // Loop on each lines to detect if there is at least one image to show
238  $realpatharray = array();
239  $this->atleastonephoto = false;
240  if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
241  $objphoto = new Product($this->db);
242 
243  for ($i = 0; $i < $nblines; $i++) {
244  if (empty($object->lines[$i]->fk_product)) {
245  continue;
246  }
247 
248  $objphoto->fetch($object->lines[$i]->fk_product);
249  //var_dump($objphoto->ref);exit;
250  if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
251  $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
252  $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
253  } else {
254  $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
255  $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
256  }
257 
258  $arephoto = false;
259  foreach ($pdir as $midir) {
260  if (!$arephoto) {
261  if ($conf->entity != $objphoto->entity) {
262  $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
263  } else {
264  $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
265  }
266 
267  foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
268  if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
269  if ($obj['photo_vignette']) {
270  $filename = $obj['photo_vignette'];
271  } else {
272  $filename = $obj['photo'];
273  }
274  } else {
275  $filename = $obj['photo'];
276  }
277 
278  $realpath = $dir.$filename;
279  $arephoto = true;
280  $this->atleastonephoto = true;
281  }
282  }
283  }
284 
285  if ($realpath && $arephoto) {
286  $realpatharray[$i] = $realpath;
287  }
288  }
289  }
290 
291 
292 
293  if (getMultidirOutput($object)) {
294  $object->fetch_thirdparty();
295 
296  $deja_regle = 0;
297 
298  // Definition of $dir and $file
299  if ($object->specimen) {
300  $dir = getMultidirOutput($object);
301  $file = $dir."/SPECIMEN.pdf";
302  } else {
303  $objectref = dol_sanitizeFileName($object->ref);
304  $dir = getMultidirOutput($object)."/".$objectref;
305  $file = $dir."/".$objectref.".pdf";
306  }
307 
308  if (!file_exists($dir)) {
309  if (dol_mkdir($dir) < 0) {
310  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
311  return 0;
312  }
313  }
314 
315  if (file_exists($dir)) {
316  // Add pdfgeneration hook
317  if (!is_object($hookmanager)) {
318  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
319  $hookmanager = new HookManager($this->db);
320  }
321  $hookmanager->initHooks(array('pdfgeneration'));
322  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
323  global $action;
324  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
325 
326  // Set nblines with the new command lines content after hook
327  $nblines = count($object->lines);
328 
329  // Create pdf instance
330  $pdf = pdf_getInstance($this->format);
331  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
332  $pdf->SetAutoPageBreak(1, 0);
333 
334  $heightforinfotot = 40; // Height reserved to output the info and total part
335  $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
336  $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
337 
338  if (class_exists('TCPDF')) {
339  $pdf->setPrintHeader(false);
340  $pdf->setPrintFooter(false);
341  }
342  $pdf->SetFont(pdf_getPDFFont($outputlangs));
343  // Set path to the background PDF File
344  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
345  $logodir = $conf->mycompany->dir_output;
346  if (!empty($conf->mycompany->multidir_output[$object->entity])) {
347  $logodir = $conf->mycompany->multidir_output[$object->entity];
348  }
349  $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
350  $tplidx = $pdf->importPage(1);
351  }
352 
353  $pdf->Open();
354  $pagenb = 0;
355  $pdf->SetDrawColor(128, 128, 128);
356 
357  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
358  $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
359  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
360  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
361  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
362  if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
363  $pdf->SetCompression(false);
364  }
365 
366  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
367 
368  // Set $this->atleastonediscount if you have at least one discount
369  for ($i = 0; $i < $nblines; $i++) {
370  if ($object->lines[$i]->remise_percent) {
371  $this->atleastonediscount++;
372  }
373  }
374 
375 
376  // New page
377  $pdf->AddPage();
378  if (!empty($tplidx)) {
379  $pdf->useTemplate($tplidx);
380  }
381  $pagenb++;
382  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
383  $pdf->SetFont('', '', $default_font_size - 1);
384  $pdf->MultiCell(0, 3, ''); // Set interline to 3
385  $pdf->SetTextColor(0, 0, 0);
386 
387 
388  $tab_top = 90 + $top_shift;
389  $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
390 
391  $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
392 
393  // Incoterm
394  $height_incoterms = 0;
395  if (isModEnabled('incoterm')) {
396  $desc_incoterms = $object->getIncotermsForPDF();
397  if ($desc_incoterms) {
398  $tab_top -= 2;
399 
400  $pdf->SetFont('', '', $default_font_size - 1);
401  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
402  $nexY = max($pdf->GetY(), $nexY);
403  $height_incoterms = $nexY - $tab_top;
404 
405  // Rect takes a length in 3rd parameter
406  $pdf->SetDrawColor(192, 192, 192);
407  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
408 
409  $tab_top = $nexY + 6;
410  }
411  }
412 
413  // Displays notes
414  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
415  if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
416  // Get first sale rep
417  if (is_object($object->thirdparty)) {
418  $salereparray = $object->thirdparty->getSalesRepresentatives($user);
419  $salerepobj = new User($this->db);
420  $salerepobj->fetch($salereparray[0]['id']);
421  if (!empty($salerepobj->signature)) {
422  $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
423  }
424  }
425  }
426 
427  // Extrafields in note
428  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
429  if (!empty($extranote)) {
430  $notetoshow = dol_concatdesc($notetoshow, $extranote);
431  }
432 
433  $pagenb = $pdf->getPage();
434  if ($notetoshow) {
435  $tab_top -= 2;
436 
437  $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
438  $pageposbeforenote = $pagenb;
439 
440  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
441  complete_substitutions_array($substitutionarray, $outputlangs, $object);
442  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
443  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
444 
445  $pdf->startTransaction();
446 
447  $pdf->SetFont('', '', $default_font_size - 1);
448  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
449  // Description
450  $pageposafternote = $pdf->getPage();
451  $posyafter = $pdf->GetY();
452 
453  if ($pageposafternote > $pageposbeforenote) {
454  $pdf->rollbackTransaction(true);
455 
456  // prepare pages to receive notes
457  while ($pagenb < $pageposafternote) {
458  $pdf->AddPage();
459  $pagenb++;
460  if (!empty($tplidx)) {
461  $pdf->useTemplate($tplidx);
462  }
463  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
464  $this->_pagehead($pdf, $object, 0, $outputlangs);
465  }
466  // $this->_pagefoot($pdf,$object,$outputlangs,1);
467  $pdf->setTopMargin($tab_top_newpage);
468  // The only function to edit the bottom margin of current page to set it.
469  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
470  }
471 
472  // back to start
473  $pdf->setPage($pageposbeforenote);
474  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
475  $pdf->SetFont('', '', $default_font_size - 1);
476  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
477  $pageposafternote = $pdf->getPage();
478 
479  $posyafter = $pdf->GetY();
480 
481  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
482  $pdf->AddPage('', '', true);
483  $pagenb++;
484  $pageposafternote++;
485  $pdf->setPage($pageposafternote);
486  $pdf->setTopMargin($tab_top_newpage);
487  // The only function to edit the bottom margin of current page to set it.
488  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
489  //$posyafter = $tab_top_newpage;
490  }
491 
492 
493  // apply note frame to previous pages
494  $i = $pageposbeforenote;
495  while ($i < $pageposafternote) {
496  $pdf->setPage($i);
497 
498 
499  $pdf->SetDrawColor(128, 128, 128);
500  // Draw note frame
501  if ($i > $pageposbeforenote) {
502  $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
503  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
504  } else {
505  $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
506  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
507  }
508 
509  // Add footer
510  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
511  $this->_pagefoot($pdf, $object, $outputlangs, 1);
512 
513  $i++;
514  }
515 
516  // apply note frame to last page
517  $pdf->setPage($pageposafternote);
518  if (!empty($tplidx)) {
519  $pdf->useTemplate($tplidx);
520  }
521  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
522  $this->_pagehead($pdf, $object, 0, $outputlangs);
523  }
524  $height_note = $posyafter - $tab_top_newpage;
525  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
526  } else {
527  // No pagebreak
528  $pdf->commitTransaction();
529  $posyafter = $pdf->GetY();
530  $height_note = $posyafter - $tab_top;
531  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
532 
533 
534  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
535  // not enough space, need to add page
536  $pdf->AddPage('', '', true);
537  $pagenb++;
538  $pageposafternote++;
539  $pdf->setPage($pageposafternote);
540  if (!empty($tplidx)) {
541  $pdf->useTemplate($tplidx);
542  }
543  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
544  $this->_pagehead($pdf, $object, 0, $outputlangs);
545  }
546 
547  $posyafter = $tab_top_newpage;
548  }
549  }
550 
551  $tab_height = $tab_height - $height_note;
552  $tab_top = $posyafter + 6;
553  } else {
554  $height_note = 0;
555  }
556 
557 
558  // Use new auto column system
559  $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
560 
561  // Table simulation to know the height of the title line
562  $pdf->startTransaction();
563  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
564  $pdf->rollbackTransaction(true);
565 
566  $nexY = $tab_top + $this->tabTitleHeight;
567 
568  // Loop on each lines
569  $pageposbeforeprintlines = $pdf->getPage();
570  $pagenb = $pageposbeforeprintlines;
571  for ($i = 0; $i < $nblines; $i++) {
572  $curY = $nexY;
573  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
574  $pdf->SetTextColor(0, 0, 0);
575 
576  // Define size of image if we need it
577  $imglinesize = array();
578  if (!empty($realpatharray[$i])) {
579  $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
580  }
581 
582  $pdf->setTopMargin($tab_top_newpage);
583  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
584  $pageposbefore = $pdf->getPage();
585 
586 
587  $showpricebeforepagebreak = 1;
588  $posYAfterImage = 0;
589  $posYAfterDescription = 0;
590 
591  if ($this->getColumnStatus('photo')) {
592  // We start with Photo of product line
593  if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
594  $pdf->AddPage('', '', true);
595  if (!empty($tplidx)) {
596  $pdf->useTemplate($tplidx);
597  }
598  $pdf->setPage($pageposbefore + 1);
599 
600  $curY = $tab_top_newpage;
601 
602  // Allows data in the first page if description is long enough to break in multiples pages
603  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
604  $showpricebeforepagebreak = 1;
605  } else {
606  $showpricebeforepagebreak = 0;
607  }
608  }
609 
610  if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
611  $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
612  // $pdf->Image does not increase value return by getY, so we save it manually
613  $posYAfterImage = $curY + $imglinesize['height'];
614  }
615  }
616 
617  // Description of product line
618  if ($this->getColumnStatus('desc')) {
619  $pdf->startTransaction();
620 
621  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
622  $pageposafter = $pdf->getPage();
623 
624  if ($pageposafter > $pageposbefore) { // There is a pagebreak
625  $pdf->rollbackTransaction(true);
626  $pageposafter = $pageposbefore;
627  //print $pageposafter.'-'.$pageposbefore;exit;
628  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
629 
630  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
631  $pageposafter = $pdf->getPage();
632  $posyafter = $pdf->GetY();
633  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
634  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
635  $pdf->AddPage('', '', true);
636  if (!empty($tplidx)) {
637  $pdf->useTemplate($tplidx);
638  }
639  //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
640  $pdf->setPage($pageposafter + 1);
641  }
642  } else {
643  // We found a page break
644  // Allows data in the first page if description is long enough to break in multiples pages
645  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
646  $showpricebeforepagebreak = 1;
647  } else {
648  $showpricebeforepagebreak = 0;
649  }
650  }
651  } else // No pagebreak
652  {
653  $pdf->commitTransaction();
654  }
655  $posYAfterDescription = $pdf->GetY();
656  }
657 
658 
659  $nexY = max($pdf->GetY(), $posYAfterImage);
660 
661 
662  $pageposafter = $pdf->getPage();
663 
664  $pdf->setPage($pageposbefore);
665  $pdf->setTopMargin($this->marge_haute);
666  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
667 
668  // We suppose that a too long description or photo were moved completely on next page
669  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
670  $pdf->setPage($pageposafter);
671  $curY = $tab_top_newpage;
672  }
673 
674  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
675 
676  // VAT Rate
677  if ($this->getColumnStatus('vat')) {
678  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
679  $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
680  $nexY = max($pdf->GetY(), $nexY);
681  }
682 
683  // Unit price before discount
684  if ($this->getColumnStatus('subprice')) {
685  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
686  $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
687  $nexY = max($pdf->GetY(), $nexY);
688  }
689 
690  // Quantity
691  // Enough for 6 chars
692  if ($this->getColumnStatus('qty')) {
693  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
694  $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
695  $nexY = max($pdf->GetY(), $nexY);
696  }
697 
698 
699  // Unit
700  if ($this->getColumnStatus('unit')) {
701  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
702  $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
703  $nexY = max($pdf->GetY(), $nexY);
704  }
705 
706  // Discount on line
707  if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
708  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
709  $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
710  $nexY = max($pdf->GetY(), $nexY);
711  }
712 
713  // Total excl tax line (HT)
714  if ($this->getColumnStatus('totalexcltax')) {
715  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
716  $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
717  $nexY = max($pdf->GetY(), $nexY);
718  }
719 
720  // Total with tax line (TTC)
721  if ($this->getColumnStatus('totalincltax')) {
722  $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
723  $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
724  $nexY = max($pdf->GetY(), $nexY);
725  }
726 
727  // Extrafields
728  if (!empty($object->lines[$i]->array_options)) {
729  foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
730  if ($this->getColumnStatus($extrafieldColKey)) {
731  $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
732  $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
733  $nexY = max($pdf->GetY(), $nexY);
734  }
735  }
736  }
737 
738  $parameters = array(
739  'object' => $object,
740  'i' => $i,
741  'pdf' =>& $pdf,
742  'curY' =>& $curY,
743  'nexY' =>& $nexY,
744  'outputlangs' => $outputlangs,
745  'hidedetails' => $hidedetails
746  );
747  $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
748 
749 
750  // Collection of totals by value of vat in $this->tva["rate"] = total_tva
751  if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
752  $tvaligne = $object->lines[$i]->multicurrency_total_tva;
753  } else {
754  $tvaligne = $object->lines[$i]->total_tva;
755  }
756 
757  $localtax1ligne = $object->lines[$i]->total_localtax1;
758  $localtax2ligne = $object->lines[$i]->total_localtax2;
759  $localtax1_rate = $object->lines[$i]->localtax1_tx;
760  $localtax2_rate = $object->lines[$i]->localtax2_tx;
761  $localtax1_type = $object->lines[$i]->localtax1_type;
762  $localtax2_type = $object->lines[$i]->localtax2_type;
763 
764  // TODO remise_percent is an obsolete field for object parent
765  /*if ($object->remise_percent) {
766  $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
767  }
768  if ($object->remise_percent) {
769  $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
770  }
771  if ($object->remise_percent) {
772  $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
773  }*/
774 
775  $vatrate = (string) $object->lines[$i]->tva_tx;
776 
777  // Retrieve type from database for backward compatibility with old records
778  if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
779  && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
780  $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
781  $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
782  $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
783  }
784 
785  // retrieve global local tax
786  if ($localtax1_type && $localtax1ligne != 0) {
787  if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
788  $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
789  } else {
790  $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
791  }
792  }
793  if ($localtax2_type && $localtax2ligne != 0) {
794  if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
795  $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
796  } else {
797  $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
798  }
799  }
800 
801  if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
802  $vatrate .= '*';
803  }
804 
805  // Fill $this->tva and $this->tva_array
806  if (!isset($this->tva[$vatrate])) {
807  $this->tva[$vatrate] = 0;
808  }
809  $this->tva[$vatrate] += $tvaligne;
810  $vatcode = $object->lines[$i]->vat_src_code;
811  if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
812  $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
813  }
814  $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
815 
816  // Add line
817  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
818  $pdf->setPage($pageposafter);
819  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
820  //$pdf->SetDrawColor(190,190,200);
821  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
822  $pdf->SetLineStyle(array('dash'=>0));
823  }
824 
825 
826  // Detect if some page were added automatically and output _tableau for past pages
827  while ($pagenb < $pageposafter) {
828  $pdf->setPage($pagenb);
829  if ($pagenb == $pageposbeforeprintlines) {
830  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
831  } else {
832  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
833  }
834  $this->_pagefoot($pdf, $object, $outputlangs, 1);
835  $pagenb++;
836  $pdf->setPage($pagenb);
837  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
838  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
839  $this->_pagehead($pdf, $object, 0, $outputlangs);
840  }
841  if (!empty($tplidx)) {
842  $pdf->useTemplate($tplidx);
843  }
844  }
845  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
846  if ($pagenb == $pageposafter) {
847  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
848  } else {
849  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
850  }
851  $this->_pagefoot($pdf, $object, $outputlangs, 1);
852  // New page
853  $pdf->AddPage();
854  if (!empty($tplidx)) {
855  $pdf->useTemplate($tplidx);
856  }
857  $pagenb++;
858  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
859  $this->_pagehead($pdf, $object, 0, $outputlangs);
860  }
861  }
862  }
863 
864  // Show square
865  if ($pagenb == $pageposbeforeprintlines) {
866  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
867  } else {
868  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
869  }
870  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
871 
872  // Display infos area
873  $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
874 
875  // Display total zone
876  $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
877 
878  // Affiche zone versements
879  /*
880  if ($deja_regle)
881  {
882  $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
883  }
884  */
885 
886  // Pied de page
887  $this->_pagefoot($pdf, $object, $outputlangs);
888  if (method_exists($pdf, 'AliasNbPages')) {
889  $pdf->AliasNbPages();
890  }
891 
892  $pdf->Close();
893 
894  $pdf->Output($file, 'F');
895 
896  // Add pdfgeneration hook
897  $hookmanager->initHooks(array('pdfgeneration'));
898  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
899  global $action;
900  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
901  if ($reshook < 0) {
902  $this->error = $hookmanager->error;
903  $this->errors = $hookmanager->errors;
904  }
905 
906  dolChmod($file);
907 
908  $this->result = array('fullpath'=>$file);
909 
910  return 1; // No error
911  } else {
912  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
913  return 0;
914  }
915  } else {
916  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
917  return 0;
918  }
919  }
920 
930  protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
931  {
932  return 0;
933  }
934 
944  protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
945  {
946  global $conf, $mysoc;
947  $default_font_size = pdf_getPDFFontSize($outputlangs);
948 
949  $pdf->SetFont('', '', $default_font_size - 1);
950 
951  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
952 
953  // If France, show VAT mention if not applicable
954  if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
955  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
956  $pdf->SetXY($this->marge_gauche, $posy);
957  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
958 
959  $posy = $pdf->GetY() + 4;
960  }
961 
962  $posxval = 52;
963 
964  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
965 
966  // Show payments conditions
967  if ($object->cond_reglement_code || $object->cond_reglement) {
968  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
969  $pdf->SetXY($this->marge_gauche, $posy);
970  $titre = $outputlangs->transnoentities("PaymentConditions").':';
971  $pdf->MultiCell(43, 4, $titre, 0, 'L');
972 
973  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
974  $pdf->SetXY($posxval, $posy);
975  $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 ? $object->cond_reglement_doc : $object->cond_reglement_label);
976  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
977  if ($object->deposit_percent > 0) {
978  $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
979  }
980  $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
981 
982  $posy = $pdf->GetY() + 3;
983  }
984 
985  // Check a payment mode is defined
986  /* Not used with orders
987  if (empty($object->mode_reglement_code)
988  && ! $conf->global->FACTURE_CHQ_NUMBER
989  && ! $conf->global->FACTURE_RIB_NUMBER)
990  {
991  $pdf->SetXY($this->marge_gauche, $posy);
992  $pdf->SetTextColor(200,0,0);
993  $pdf->SetFont('','B', $default_font_size - 2);
994  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
995  $pdf->SetTextColor(0,0,0);
996 
997  $posy=$pdf->GetY()+1;
998  }
999  */
1000  /* TODO
1001  else if (!empty($object->availability_code))
1002  {
1003  $pdf->SetXY($this->marge_gauche, $posy);
1004  $pdf->SetTextColor(200,0,0);
1005  $pdf->SetFont('','B', $default_font_size - 2);
1006  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
1007  $pdf->SetTextColor(0,0,0);
1008 
1009  $posy=$pdf->GetY()+1;
1010  }*/
1011 
1012  // Show planed date of delivery
1013  if (!empty($object->delivery_date)) {
1014  $outputlangs->load("sendings");
1015  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1016  $pdf->SetXY($this->marge_gauche, $posy);
1017  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
1018  $pdf->MultiCell(80, 4, $titre, 0, 'L');
1019  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1020  $pdf->SetXY($posxval, $posy);
1021  $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
1022  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
1023 
1024  $posy = $pdf->GetY() + 1;
1025  } elseif ($object->availability_code || $object->availability) { // Show availability conditions
1026  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1027  $pdf->SetXY($this->marge_gauche, $posy);
1028  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
1029  $pdf->MultiCell(80, 4, $titre, 0, 'L');
1030  $pdf->SetTextColor(0, 0, 0);
1031  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1032  $pdf->SetXY($posxval, $posy);
1033  $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
1034  $lib_availability = str_replace('\n', "\n", $lib_availability);
1035  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
1036 
1037  $posy = $pdf->GetY() + 1;
1038  }
1039 
1040  // Show payment mode
1041  if ($object->mode_reglement_code
1042  && $object->mode_reglement_code != 'CHQ'
1043  && $object->mode_reglement_code != 'VIR') {
1044  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1045  $pdf->SetXY($this->marge_gauche, $posy);
1046  $titre = $outputlangs->transnoentities("PaymentMode").':';
1047  $pdf->MultiCell(80, 5, $titre, 0, 'L');
1048 
1049  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1050  $pdf->SetXY($posxval, $posy);
1051  $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);
1052  $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1053 
1054  $posy = $pdf->GetY() + 2;
1055  }
1056 
1057  // Show payment mode CHQ
1058  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
1059  // Si mode reglement non force ou si force a CHQ
1060  if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1061  if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1062  $account = new Account($this->db);
1063  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1064 
1065  $pdf->SetXY($this->marge_gauche, $posy);
1066  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1067  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
1068  $posy = $pdf->GetY() + 1;
1069 
1070  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1071  $pdf->SetXY($this->marge_gauche, $posy);
1072  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1073  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1074  $posy = $pdf->GetY() + 2;
1075  }
1076  }
1077  if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1078  $pdf->SetXY($this->marge_gauche, $posy);
1079  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1080  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1081  $posy = $pdf->GetY() + 1;
1082 
1083  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1084  $pdf->SetXY($this->marge_gauche, $posy);
1085  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1086  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1087  $posy = $pdf->GetY() + 2;
1088  }
1089  }
1090  }
1091  }
1092 
1093  // If payment mode not forced or forced to VIR, show payment with BAN
1094  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1095  if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1096  $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1097  if ($object->fk_bank > 0) {
1098  $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1099  }
1100  $account = new Account($this->db);
1101  $account->fetch($bankid);
1102 
1103  $curx = $this->marge_gauche;
1104  $cury = $posy;
1105 
1106  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1107 
1108  $posy += 2;
1109  }
1110  }
1111 
1112  return $posy;
1113  }
1114 
1115 
1127  protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
1128  {
1129  global $conf, $mysoc, $hookmanager;
1130 
1131  $default_font_size = pdf_getPDFFontSize($outputlangs);
1132 
1133  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1134  $outputlangsbis = new Translate('', $conf);
1135  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1136  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1137  $default_font_size--;
1138  }
1139 
1140  $tab2_top = $posy;
1141  $tab2_hl = 4;
1142  $pdf->SetFont('', '', $default_font_size - 1);
1143 
1144  // Total table
1145  $col1x = 120;
1146  $col2x = 170;
1147  if ($this->page_largeur < 210) { // To work with US executive format
1148  $col2x -= 20;
1149  }
1150  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1151 
1152  $useborder = 0;
1153  $index = 0;
1154 
1155  // Total HT
1156  $pdf->SetFillColor(255, 255, 255);
1157  $pdf->SetXY($col1x, $tab2_top);
1158  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
1159  $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1160  $pdf->SetXY($col2x, $tab2_top);
1161  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
1162 
1163  // Show VAT by rates and total
1164  $pdf->SetFillColor(248, 248, 248);
1165 
1166  $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1167 
1168  $this->atleastoneratenotnull = 0;
1169  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1170  $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1171  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1172  // Nothing to do
1173  } else {
1174  //Local tax 1 before VAT
1175  //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1176  //{
1177  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1178  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1179  continue;
1180  }
1181  foreach ($localtax_rate as $tvakey => $tvaval) {
1182  if ($tvakey != 0) { // On affiche pas taux 0
1183  //$this->atleastoneratenotnull++;
1184  $index++;
1185  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1186 
1187  $tvacompl = '';
1188  if (preg_match('/\*/', $tvakey)) {
1189  $tvakey = str_replace('*', '', $tvakey);
1190  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1191  }
1192  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1193  $totalvat .= ' ';
1194  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1195  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1196 
1197  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1198  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1199  }
1200  }
1201  }
1202  //}
1203  //Local tax 2 before VAT
1204  //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1205  //{
1206  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1207  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1208  continue;
1209  }
1210  foreach ($localtax_rate as $tvakey => $tvaval) {
1211  if ($tvakey != 0) { // On affiche pas taux 0
1212  //$this->atleastoneratenotnull++;
1213 
1214  $index++;
1215  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1216 
1217  $tvacompl = '';
1218  if (preg_match('/\*/', $tvakey)) {
1219  $tvakey = str_replace('*', '', $tvakey);
1220  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1221  }
1222  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1223  $totalvat .= ' ';
1224  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1225  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1226 
1227  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1228  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1229  }
1230  }
1231  }
1232  //}
1233 
1234  // VAT
1235  foreach ($this->tva_array as $tvakey => $tvaval) {
1236  if ($tvakey != 0) { // On affiche pas taux 0
1237  $this->atleastoneratenotnull++;
1238 
1239  $index++;
1240  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1241 
1242  $tvacompl = '';
1243  if (preg_match('/\*/', $tvakey)) {
1244  $tvakey = str_replace('*', '', $tvakey);
1245  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1246  }
1247  $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1248  $totalvat .= ' ';
1249  if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
1250  $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
1251  } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
1252  $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl;
1253  } else {
1254  $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
1255  }
1256  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1257 
1258  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1259  $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
1260  }
1261  }
1262 
1263  //Local tax 1 after VAT
1264  //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1265  //{
1266  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1267  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1268  continue;
1269  }
1270 
1271  foreach ($localtax_rate as $tvakey => $tvaval) {
1272  if ($tvakey != 0) { // On affiche pas taux 0
1273  //$this->atleastoneratenotnull++;
1274 
1275  $index++;
1276  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1277 
1278  $tvacompl = '';
1279  if (preg_match('/\*/', $tvakey)) {
1280  $tvakey = str_replace('*', '', $tvakey);
1281  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1282  }
1283  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1284  $totalvat .= ' ';
1285  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1286 
1287  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1288  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1289  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1290  }
1291  }
1292  }
1293  //}
1294  //Local tax 2 after VAT
1295  //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1296  //{
1297  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1298  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1299  continue;
1300  }
1301 
1302  foreach ($localtax_rate as $tvakey => $tvaval) {
1303  // retrieve global local tax
1304  if ($tvakey != 0) { // On affiche pas taux 0
1305  //$this->atleastoneratenotnull++;
1306 
1307  $index++;
1308  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1309 
1310  $tvacompl = '';
1311  if (preg_match('/\*/', $tvakey)) {
1312  $tvakey = str_replace('*', '', $tvakey);
1313  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1314  }
1315  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1316  $totalvat .= ' ';
1317 
1318  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1319  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1320 
1321  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1322  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1323  }
1324  }
1325  }
1326  //}
1327 
1328  // Total TTC
1329  $index++;
1330  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1331  $pdf->SetTextColor(0, 0, 60);
1332  $pdf->SetFillColor(224, 224, 224);
1333  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1);
1334 
1335  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1336  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1337  }
1338  }
1339 
1340  $pdf->SetTextColor(0, 0, 0);
1341 
1342  $creditnoteamount = 0;
1343  $depositsamount = 0;
1344  //$creditnoteamount=$object->getSumCreditNotesUsed();
1345  //$depositsamount=$object->getSumDepositsUsed();
1346  //print "x".$creditnoteamount."-".$depositsamount;exit;
1347  $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1348  if (!empty($object->paye)) {
1349  $resteapayer = 0;
1350  }
1351 
1352  if ($deja_regle > 0) {
1353  // Already paid + Deposits
1354  $index++;
1355 
1356  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1357  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1358  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1359  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1360 
1361  $index++;
1362  $pdf->SetTextColor(0, 0, 60);
1363  $pdf->SetFillColor(224, 224, 224);
1364  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1365  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
1366 
1367  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1368  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1369 
1370  $pdf->SetFont('', '', $default_font_size - 1);
1371  $pdf->SetTextColor(0, 0, 0);
1372  }
1373 
1374  $index++;
1375  return ($tab2_top + ($tab2_hl * $index));
1376  }
1377 
1378  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1393  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1394  {
1395  global $conf;
1396 
1397  // Force to disable hidetop and hidebottom
1398  $hidebottom = 0;
1399  if ($hidetop) {
1400  $hidetop = -1;
1401  }
1402 
1403  $currency = !empty($currency) ? $currency : $conf->currency;
1404  $default_font_size = pdf_getPDFFontSize($outputlangs);
1405 
1406  // Amount in (at tab_top - 1)
1407  $pdf->SetTextColor(0, 0, 0);
1408  $pdf->SetFont('', '', $default_font_size - 2);
1409 
1410  if (empty($hidetop)) {
1411  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1412  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1413  $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1414  }
1415 
1416  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1417  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1418 
1419  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1420  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1421  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1422  }
1423  }
1424 
1425  $pdf->SetDrawColor(128, 128, 128);
1426  $pdf->SetFont('', '', $default_font_size - 1);
1427 
1428  // Output Rect
1429  $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
1430 
1431 
1432  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1433 
1434  if (empty($hidetop)) {
1435  $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
1436  }
1437  }
1438 
1439  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1440  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1452  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
1453  {
1454  // phpcs:enable
1455  global $conf, $langs, $hookmanager, $mysoc;
1456 
1457  $ltrdirection = 'L';
1458  if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
1459 
1460  // Load traductions files required by page
1461  $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1462 
1463  $default_font_size = pdf_getPDFFontSize($outputlangs);
1464 
1465  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1466 
1467  $pdf->SetTextColor(0, 0, 60);
1468  $pdf->SetFont('', 'B', $default_font_size + 3);
1469 
1470  $w = 100;
1471 
1472  $posy = $this->marge_haute;
1473  $posx = $this->page_largeur - $this->marge_droite - $w;
1474 
1475  $pdf->SetXY($this->marge_gauche, $posy);
1476 
1477  // Logo
1478  if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1479  if ($this->emetteur->logo) {
1480  $logodir = $conf->mycompany->dir_output;
1481  if (!empty(getMultidirOutput($mysoc, 'mycompany'))) {
1482  $logodir = getMultidirOutput($mysoc, 'mycompany');
1483  }
1484  if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1485  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1486  } else {
1487  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1488  }
1489  if (is_readable($logo)) {
1490  $height = pdf_getHeightForLogo($logo);
1491  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1492  } else {
1493  $pdf->SetTextColor(200, 0, 0);
1494  $pdf->SetFont('', 'B', $default_font_size - 2);
1495  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1496  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1497  }
1498  } else {
1499  $text = $this->emetteur->name;
1500  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1501  }
1502  }
1503 
1504  $pdf->SetFont('', 'B', $default_font_size + 3);
1505  $pdf->SetXY($posx, $posy);
1506  $pdf->SetTextColor(0, 0, 60);
1507  $title = $outputlangs->transnoentities($titlekey);
1508  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1509  $title .= ' - ';
1510  $title .= $outputlangsbis->transnoentities($titlekey);
1511  }
1512  $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1513  if ($object->statut == $object::STATUS_DRAFT) {
1514  $pdf->SetTextColor(128, 0, 0);
1515  $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1516  }
1517 
1518  $pdf->MultiCell($w, 3, $title, '', 'R');
1519 
1520  $pdf->SetFont('', 'B', $default_font_size);
1521 
1522  /*
1523  $posy += 5;
1524  $pdf->SetXY($posx, $posy);
1525  $pdf->SetTextColor(0, 0, 60);
1526  $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1527  if ($object->statut == $object::STATUS_DRAFT) {
1528  $pdf->SetTextColor(128, 0, 0);
1529  $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1530  }
1531  $pdf->MultiCell($w, 4, $textref, '', 'R');
1532  */
1533 
1534  $posy += 3;
1535  $pdf->SetFont('', '', $default_font_size - 2);
1536 
1537  if ($object->ref_client) {
1538  $posy += 4;
1539  $pdf->SetXY($posx, $posy);
1540  $pdf->SetTextColor(0, 0, 60);
1541  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
1542  }
1543 
1544  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1545  $object->fetch_projet();
1546  if (!empty($object->project->ref)) {
1547  $posy += 3;
1548  $pdf->SetXY($posx, $posy);
1549  $pdf->SetTextColor(0, 0, 60);
1550  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1551  }
1552  }
1553 
1554  if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1555  $object->fetch_projet();
1556  if (!empty($object->project->ref)) {
1557  $outputlangs->load("projects");
1558  $posy += 3;
1559  $pdf->SetXY($posx, $posy);
1560  $pdf->SetTextColor(0, 0, 60);
1561  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1562  }
1563  }
1564 
1565  $posy += 4;
1566 
1567  $pdf->SetXY($posx, $posy);
1568  $pdf->SetTextColor(0, 0, 60);
1569  $title = $outputlangs->transnoentities("OrderDate");
1570  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1571  $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
1572  }
1573  $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1574 
1575  if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1576  $posy += 4;
1577  $pdf->SetXY($posx, $posy);
1578  $pdf->SetTextColor(0, 0, 60);
1579  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1580  }
1581 
1582  // Get contact
1583  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1584  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1585  if (count($arrayidcontact) > 0) {
1586  $usertmp = new User($this->db);
1587  $usertmp->fetch($arrayidcontact[0]);
1588  $posy += 4;
1589  $pdf->SetXY($posx, $posy);
1590  $pdf->SetTextColor(0, 0, 60);
1591  $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1592  }
1593  }
1594 
1595  $posy += 2;
1596 
1597  $top_shift = 0;
1598  // Show list of linked objects
1599  $current_y = $pdf->getY();
1600  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1601  if ($current_y < $pdf->getY()) {
1602  $top_shift = $pdf->getY() - $current_y;
1603  }
1604 
1605  if ($showaddress) {
1606  // Sender properties
1607  $carac_emetteur = '';
1608  // Add internal contact of object if defined
1609  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1610  if (count($arrayidcontact) > 0) {
1611  $object->fetch_user($arrayidcontact[0]);
1612  $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1613  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1614  $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1615  $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1616  $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1617  $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1618  $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1619  $carac_emetteur .= "\n";
1620  }
1621 
1622  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1623 
1624  // Show sender
1625  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1626  $posy += $top_shift;
1627  $posx = $this->marge_gauche;
1628  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1629  $posx = $this->page_largeur - $this->marge_droite - 80;
1630  }
1631 
1632  $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1633  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1634 
1635 
1636  // Show sender frame
1637  if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1638  $pdf->SetTextColor(0, 0, 0);
1639  $pdf->SetFont('', '', $default_font_size - 2);
1640  $pdf->SetXY($posx, $posy - 5);
1641  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1642  $pdf->SetXY($posx, $posy);
1643  $pdf->SetFillColor(230, 230, 230);
1644  $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1645  $pdf->SetTextColor(0, 0, 60);
1646  }
1647 
1648  // Show sender name
1649  if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1650  $pdf->SetXY($posx + 2, $posy + 3);
1651  $pdf->SetFont('', 'B', $default_font_size);
1652  $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1653  $posy = $pdf->getY();
1654  }
1655 
1656  // Show sender information
1657  $pdf->SetXY($posx + 2, $posy);
1658  $pdf->SetFont('', '', $default_font_size - 1);
1659  $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1660 
1661  // If CUSTOMER contact defined, we use it
1662  $usecontact = false;
1663  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1664  if (count($arrayidcontact) > 0) {
1665  $usecontact = true;
1666  $result = $object->fetch_contact($arrayidcontact[0]);
1667  }
1668 
1669  //Recipient name
1670  if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1671  $thirdparty = $object->contact;
1672  } else {
1673  $thirdparty = $object->thirdparty;
1674  }
1675 
1676  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1677 
1678  $mode = 'target';
1679  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
1680 
1681  // Show recipient
1682  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1683  if ($this->page_largeur < 210) {
1684  $widthrecbox = 84; // To work with US executive format
1685  }
1686  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1687  $posy += $top_shift;
1688  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1689  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1690  $posx = $this->marge_gauche;
1691  }
1692 
1693  // Show recipient frame
1694  if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1695  $pdf->SetTextColor(0, 0, 0);
1696  $pdf->SetFont('', '', $default_font_size - 2);
1697  $pdf->SetXY($posx + 2, $posy - 5);
1698  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1699  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1700  }
1701 
1702  // Show recipient name
1703  $pdf->SetXY($posx + 2, $posy + 3);
1704  $pdf->SetFont('', 'B', $default_font_size);
1705  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1706 
1707  $posy = $pdf->getY();
1708 
1709  // Show recipient information
1710  $pdf->SetFont('', '', $default_font_size - 1);
1711  $pdf->SetXY($posx + 2, $posy);
1712  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1713  }
1714 
1715  $pdf->SetTextColor(0, 0, 0);
1716  return $top_shift;
1717  }
1718 
1719  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1720  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1730  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1731  {
1732  // phpcs:enable
1733  $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1734  return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1735  }
1736 
1737 
1738 
1749  public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1750  {
1751  global $conf, $hookmanager;
1752 
1753  // Default field style for content
1754  $this->defaultContentsFieldsStyle = array(
1755  'align' => 'R', // R,C,L
1756  'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1757  );
1758 
1759  // Default field style for content
1760  $this->defaultTitlesFieldsStyle = array(
1761  'align' => 'C', // R,C,L
1762  'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1763  );
1764 
1765  /*
1766  * For exemple
1767  $this->cols['theColKey'] = array(
1768  'rank' => $rank, // int : use for ordering columns
1769  'width' => 20, // the column width in mm
1770  'title' => array(
1771  'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1772  'label' => ' ', // the final label : used fore final generated text
1773  'align' => 'L', // text alignement : R,C,L
1774  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1775  ),
1776  'content' => array(
1777  'align' => 'L', // text alignement : R,C,L
1778  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1779  ),
1780  );
1781  */
1782 
1783  $rank = 0; // do not use negative rank
1784  $this->cols['desc'] = array(
1785  'rank' => $rank,
1786  'width' => false, // only for desc
1787  'status' => true,
1788  'title' => array(
1789  'textkey' => 'Designation', // use lang key is usefull in somme case with module
1790  'align' => 'L',
1791  // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1792  // 'label' => ' ', // the final label
1793  'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1794  ),
1795  'content' => array(
1796  'align' => 'L',
1797  'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1798  ),
1799  );
1800 
1801  // Image of product
1802  $rank = $rank + 10;
1803  $this->cols['photo'] = array(
1804  'rank' => $rank,
1805  'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1806  'status' => false,
1807  'title' => array(
1808  'textkey' => 'Photo',
1809  'label' => ' '
1810  ),
1811  'content' => array(
1812  'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1813  ),
1814  'border-left' => false, // remove left line separator
1815  );
1816 
1817  if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE) && !empty($this->atleastonephoto)) {
1818  $this->cols['photo']['status'] = true;
1819  }
1820 
1821  $rank = $rank + 10;
1822  $this->cols['vat'] = array(
1823  'rank' => $rank,
1824  'status' => false,
1825  'width' => 16, // in mm
1826  'title' => array(
1827  'textkey' => 'VAT'
1828  ),
1829  'border-left' => true, // add left line separator
1830  );
1831 
1832  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1833  $this->cols['vat']['status'] = true;
1834  }
1835 
1836  $rank = $rank + 10;
1837  $this->cols['subprice'] = array(
1838  'rank' => $rank,
1839  'width' => 19, // in mm
1840  'status' => true,
1841  'title' => array(
1842  'textkey' => 'PriceUHT'
1843  ),
1844  'border-left' => true, // add left line separator
1845  );
1846 
1847  // Adapt dynamically the width of subprice, if text is too long.
1848  $tmpwidth = 0;
1849  $nblines = count($object->lines);
1850  for ($i = 0; $i < $nblines; $i++) {
1851  $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
1852  $tmpwidth = max($tmpwidth, $tmpwidth2);
1853  }
1854  if ($tmpwidth > 10) {
1855  $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
1856  }
1857 
1858  $rank = $rank + 10;
1859  $this->cols['qty'] = array(
1860  'rank' => $rank,
1861  'width' => 16, // in mm
1862  'status' => true,
1863  'title' => array(
1864  'textkey' => 'Qty'
1865  ),
1866  'border-left' => true, // add left line separator
1867  );
1868 
1869  $rank = $rank + 10;
1870  $this->cols['unit'] = array(
1871  'rank' => $rank,
1872  'width' => 11, // in mm
1873  'status' => false,
1874  'title' => array(
1875  'textkey' => 'Unit'
1876  ),
1877  'border-left' => true, // add left line separator
1878  );
1879  if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1880  $this->cols['unit']['status'] = true;
1881  }
1882 
1883  $rank = $rank + 10;
1884  $this->cols['discount'] = array(
1885  'rank' => $rank,
1886  'width' => 13, // in mm
1887  'status' => false,
1888  'title' => array(
1889  'textkey' => 'ReductionShort'
1890  ),
1891  'border-left' => true, // add left line separator
1892  );
1893  if ($this->atleastonediscount) {
1894  $this->cols['discount']['status'] = true;
1895  }
1896 
1897  $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1898  $this->cols['totalexcltax'] = array(
1899  'rank' => $rank,
1900  'width' => 26, // in mm
1901  'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false,
1902  'title' => array(
1903  'textkey' => 'TotalHTShort'
1904  ),
1905  'border-left' => true, // add left line separator
1906  );
1907 
1908  $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
1909  $this->cols['totalincltax'] = array(
1910  'rank' => $rank,
1911  'width' => 26, // in mm
1912  'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true,
1913  'title' => array(
1914  'textkey' => 'TotalTTCShort'
1915  ),
1916  'border-left' => true, // add left line separator
1917  );
1918 
1919  // Add extrafields cols
1920  if (!empty($object->lines)) {
1921  $line = reset($object->lines);
1922  $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1923  }
1924 
1925  $parameters = array(
1926  'object' => $object,
1927  'outputlangs' => $outputlangs,
1928  'hidedetails' => $hidedetails,
1929  'hidedesc' => $hidedesc,
1930  'hideref' => $hideref
1931  );
1932 
1933  $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1934  if ($reshook < 0) {
1935  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1936  } elseif (empty($reshook)) {
1937  $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1938  } else {
1939  $this->cols = $hookmanager->resArray;
1940  }
1941  }
1942 }
make_substitutions
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Definition: functions.lib.php:8366
pdf_getlinevatrate
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1830
ModelePDFCommandes
Parent class for orders models.
Definition: modules_commande.php:40
getLocalTaxesFromRate
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
Definition: functions.lib.php:6398
pdf_getSizeForImage
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition: pdf.lib.php:2520
pdf_getlineqty
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1977
pdf_getlineupexcltax
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1892
dol_trunc
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
Definition: functions.lib.php:4059
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1323
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
pdf_getlineremisepercent
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition: pdf.lib.php:2181
pdf_getFormat
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:85
CommonDocGenerator\getColumnContentXStart
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
Definition: commondocgenerator.class.php:1165
pdf_eratosthene\_pagefoot
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Definition: pdf_eratosthene.modules.php:1730
pdf_eratosthene\write_file
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
Definition: pdf_eratosthene.modules.php:201
pdf_getInstance
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:127
CommonDocGenerator\printStdColumnContent
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
Definition: commondocgenerator.class.php:1239
pdf_eratosthene\_tableau
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
Definition: pdf_eratosthene.modules.php:1393
pdf_getPDFFont
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:266
pdf_eratosthene\drawTotalTable
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
Definition: pdf_eratosthene.modules.php:1127
Translate
Class to manage translations.
Definition: translate.class.php:30
CommonDocGenerator\pdfTabTitles
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
Definition: commondocgenerator.class.php:1582
pdf_getlineunit
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:2138
name
$conf db name
Definition: repair.php:123
CommonDocGenerator\getExtrafieldContent
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
Definition: commondocgenerator.class.php:1324
pdf_eratosthene\_pagehead
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
Definition: pdf_eratosthene.modules.php:1452
pdf_eratosthene\defineColumnField
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
Definition: pdf_eratosthene.modules.php:1749
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5955
CommonDocGenerator\prepareArrayColumnField
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
Definition: commondocgenerator.class.php:1082
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2675
dol_concatdesc
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
Definition: functions.lib.php:7734
dolChmod
dolChmod($filepath, $newmask='')
Change mod of a file.
Definition: functions.lib.php:7007
pdfBuildThirdpartyName
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:387
pdf_pagehead
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:721
get_exdir
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
Definition: functions.lib.php:6882
pdf_bank
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
Definition: pdf.lib.php:828
getMultidirOutput
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists('str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists('str_contains')) getMultidirOutput($object, $module='')
Return the full path of the directory where a module (or an object of a module) stores its files.
Definition: functions.lib.php:123
pdf_getHeightForLogo
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:314
pdf_getlinetotalwithtax
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition: pdf.lib.php:2331
CommonDocGenerator\printRect
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Definition: commondocgenerator.class.php:1038
pdf_writeLinkedObjects
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1333
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:7046
pdf_build_address
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
Definition: pdf.lib.php:435
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
convertBackOfficeMediasLinksToPublicLinks
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
Definition: functions2.lib.php:2726
pdf_eratosthene\__construct
__construct($db)
Constructor.
Definition: pdf_eratosthene.modules.php:133
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3997
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
pdf_eratosthene
Class to generate PDF orders with template Eratosthene.
Definition: pdf_eratosthene.modules.php:43
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
User
Class to manage Dolibarr users.
Definition: user.class.php:47
Product
Class to manage products or services.
Definition: product.class.php:46
pdf_eratosthene\drawInfoTable
drawInfoTable(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
Definition: pdf_eratosthene.modules.php:944
dol_htmlentitiesbr
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
Definition: functions.lib.php:7469
pdf_getSubstitutionArray
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:753
CommonDocGenerator\printColDescContent
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
Definition: commondocgenerator.class.php:1287
pdf_getPDFFontSize
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:289
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5829
pdf_eratosthene\drawPaymentsTable
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
Definition: pdf_eratosthene.modules.php:930
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6936
pdf_getlinetotalexcltax
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition: pdf.lib.php:2275
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:120
CommonDocGenerator\defineColumnExtrafield
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Definition: commondocgenerator.class.php:1663
CommonDocGenerator\getColumnStatus
getColumnStatus($colKey)
get column status from column key
Definition: commondocgenerator.class.php:1563
Account
Class to manage bank accounts.
Definition: account.class.php:40
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30
complete_substitutions_array
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
Definition: functions.lib.php:8489
vatrate
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
Definition: functions.lib.php:5780
pdf_pagefoot
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition: pdf.lib.php:1005
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25