dolibarr  13.0.2
pdf_crabe.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-2014 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10  * Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
11  * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  * or see https://www.gnu.org/
26  */
27 
34 require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
35 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
39 
40 
45 {
49  public $db;
50 
54  public $name;
55 
59  public $description;
60 
64  public $update_main_doc_field;
65 
69  public $type;
70 
75  public $phpmin = array(5, 6);
76 
81  public $version = 'dolibarr';
82 
86  public $page_largeur;
87 
91  public $page_hauteur;
92 
96  public $format;
97 
101  public $marge_gauche;
102 
106  public $marge_droite;
107 
111  public $marge_haute;
112 
116  public $marge_basse;
117 
122  public $emetteur;
123 
127  public $situationinvoice;
128 
132  public $posxprogress;
133 
134 
140  public function __construct($db)
141  {
142  global $conf, $langs, $mysoc;
143 
144  // Translations
145  $langs->loadLangs(array("main", "bills"));
146 
147  $this->db = $db;
148  $this->name = "crabe";
149  $this->description = $langs->trans('PDFCrabeDescription');
150  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
151 
152  // Dimension page
153  $this->type = 'pdf';
154  $formatarray = pdf_getFormat();
155  $this->page_largeur = $formatarray['width'];
156  $this->page_hauteur = $formatarray['height'];
157  $this->format = array($this->page_largeur, $this->page_hauteur);
158  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
159  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
160  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
161  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
162 
163  $this->option_logo = 1; // Display logo
164  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
165  $this->option_modereg = 1; // Display payment mode
166  $this->option_condreg = 1; // Display payment terms
167  $this->option_codeproduitservice = 1; // Display product-service code
168  $this->option_multilang = 1; // Available in several languages
169  $this->option_escompte = 1; // Displays if there has been a discount
170  $this->option_credit_note = 1; // Support credit notes
171  $this->option_freetext = 1; // Support add of a personalised text
172  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
173 
174  // Get source company
175  $this->emetteur = $mysoc;
176  if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
177 
178  // Define position of columns
179  $this->posxdesc = $this->marge_gauche + 1;
180  if (!empty($conf->global->PRODUCT_USE_UNITS))
181  {
182  $this->posxtva = 101;
183  $this->posxup = 118;
184  $this->posxqty = 135;
185  $this->posxunit = 151;
186  } else {
187  $this->posxtva = 110;
188  $this->posxup = 126;
189  $this->posxqty = 145;
190  $this->posxunit = 162;
191  }
192  $this->posxprogress = 151; // Only displayed for situation invoices
193  $this->posxdiscount = 162;
194  $this->posxprogress = 174;
195  $this->postotalht = 174;
196  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
197  $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
198  if ($this->page_largeur < 210) // To work with US executive format
199  {
200  $this->posxpicture -= 20;
201  $this->posxtva -= 20;
202  $this->posxup -= 20;
203  $this->posxqty -= 20;
204  $this->posxunit -= 20;
205  $this->posxdiscount -= 20;
206  $this->posxprogress -= 20;
207  $this->postotalht -= 20;
208  }
209 
210  $this->tva = array();
211  $this->localtax1 = array();
212  $this->localtax2 = array();
213  $this->atleastoneratenotnull = 0;
214  $this->atleastonediscount = 0;
215  $this->situationinvoice = false;
216  }
217 
218 
219  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
231  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
232  {
233  // phpcs:enable
234  global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
235 
236  dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
237 
238  if (!is_object($outputlangs)) $outputlangs = $langs;
239  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
240  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
241 
242  // Load translation files required by the page
243  $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
244 
245  $nblines = count($object->lines);
246 
247  // Loop on each lines to detect if there is at least one image to show
248  $realpatharray = array();
249  if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
250  {
251  for ($i = 0; $i < $nblines; $i++)
252  {
253  if (empty($object->lines[$i]->fk_product)) continue;
254 
255  $objphoto = new Product($this->db);
256  $objphoto->fetch($object->lines[$i]->fk_product);
257 
258  $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
259  $dir = $conf->product->dir_output.'/'.$pdir;
260 
261  $realpath = '';
262  foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
263  {
264  $filename = $obj['photo'];
265  //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
266  $realpath = $dir.$filename;
267  break;
268  }
269 
270  if ($realpath) $realpatharray[$i] = $realpath;
271  }
272  }
273  if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
274 
275  if ($conf->facture->dir_output)
276  {
277  $object->fetch_thirdparty();
278 
279  $deja_regle = $object->getSommePaiement((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
280  $amount_credit_notes_included = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
281  $amount_deposits_included = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
282 
283  // Definition of $dir and $file
284  if ($object->specimen)
285  {
286  $dir = $conf->facture->dir_output;
287  $file = $dir."/SPECIMEN.pdf";
288  } else {
289  $objectref = dol_sanitizeFileName($object->ref);
290  $dir = $conf->facture->dir_output."/".$objectref;
291  $file = $dir."/".$objectref.".pdf";
292  }
293  if (!file_exists($dir))
294  {
295  if (dol_mkdir($dir) < 0)
296  {
297  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
298  return 0;
299  }
300  }
301 
302  if (file_exists($dir))
303  {
304  // Add pdfgeneration hook
305  if (!is_object($hookmanager))
306  {
307  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
308  $hookmanager = new HookManager($this->db);
309  }
310  $hookmanager->initHooks(array('pdfgeneration'));
311  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
312  global $action;
313  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
314 
315  // Set nblines with the new facture lines content after hook
316  $nblines = count($object->lines);
317  $nbpayments = count($object->getListOfPayments());
318 
319  // Create pdf instance
320  $pdf = pdf_getInstance($this->format);
321  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
322  $pdf->SetAutoPageBreak(1, 0);
323 
324  $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
325  if ($heightforinfotot > 220) $heightforinfotot = 220;
326  $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
327  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
328  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
329 
330  if (class_exists('TCPDF'))
331  {
332  $pdf->setPrintHeader(false);
333  $pdf->setPrintFooter(false);
334  }
335  $pdf->SetFont(pdf_getPDFFont($outputlangs));
336 
337  // Set path to the background PDF File
338  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
339  {
340  $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
341  $tplidx = $pdf->importPage(1);
342  }
343 
344  $pdf->Open();
345  $pagenb = 0;
346  $pdf->SetDrawColor(128, 128, 128);
347 
348  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
349  $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
350  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
351  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
352  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
353  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
354 
355  // Set certificate
356  $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
357  // If user has no certificate, we try to take the company one
358  if (!$cert) {
359  $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
360  }
361  // If a certificate is found
362  if ($cert) {
363  $info = array(
364  'Name' => $this->emetteur->name,
365  'Location' => getCountry($this->emetteur->country_code, 0),
366  'Reason' => 'INVOICE',
367  'ContactInfo' => $this->emetteur->email
368  );
369  $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
370  }
371 
372  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
373 
374  // Set $this->atleastonediscount if you have at least one discount
375  for ($i = 0; $i < $nblines; $i++)
376  {
377  if ($object->lines[$i]->remise_percent)
378  {
379  $this->atleastonediscount++;
380  }
381  }
382  if (empty($this->atleastonediscount)) // retrieve space not used by discount
383  {
384  $delta = ($this->posxprogress - $this->posxdiscount);
385  $this->posxpicture += $delta;
386  $this->posxtva += $delta;
387  $this->posxup += $delta;
388  $this->posxqty += $delta;
389  $this->posxunit += $delta;
390  $this->posxdiscount += $delta;
391  // post of fields after are not modified, stay at same position
392  }
393 
394  $progress_width = 0;
395  // Situation invoice handling
396  if ($object->situation_cycle_ref && empty($conf->global->MAIN_PDF_HIDE_SITUATION))
397  {
398  $this->situationinvoice = true;
399  $progress_width = 10;
400  $this->posxpicture -= $progress_width;
401  $this->posxtva -= $progress_width;
402  $this->posxup -= $progress_width;
403  $this->posxqty -= $progress_width;
404  $this->posxunit -= $progress_width;
405  $this->posxdiscount -= $progress_width;
406  $this->posxprogress -= $progress_width;
407  }
408 
409  // New page
410  $pdf->AddPage();
411  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
412  $pagenb++;
413 
414  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
415  $pdf->SetFont('', '', $default_font_size - 1);
416  $pdf->MultiCell(0, 3, ''); // Set interline to 3
417  $pdf->SetTextColor(0, 0, 0);
418 
419  $tab_top = 90 + $top_shift;
420  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
421 
422  // Incoterm
423  if (!empty($conf->incoterm->enabled))
424  {
425  $desc_incoterms = $object->getIncotermsForPDF();
426  if ($desc_incoterms)
427  {
428  $tab_top -= 2;
429 
430  $pdf->SetFont('', '', $default_font_size - 1);
431  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
432  $nexY = $pdf->GetY();
433  $height_incoterms = $nexY - $tab_top;
434 
435  // Rect takes a length in 3rd parameter
436  $pdf->SetDrawColor(192, 192, 192);
437  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
438 
439  $tab_top = $nexY + 6;
440  }
441  }
442 
443  // Display notes
444  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
445  if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
446  {
447  // Get first sale rep
448  if (is_object($object->thirdparty))
449  {
450  $salereparray = $object->thirdparty->getSalesRepresentatives($user);
451  $salerepobj = new User($this->db);
452  $salerepobj->fetch($salereparray[0]['id']);
453  if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
454  }
455  }
456  // Extrafields in note
457  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
458  if (!empty($extranote)) {
459  $notetoshow = dol_concatdesc($notetoshow, $extranote);
460  }
461  if ($notetoshow)
462  {
463  $tab_top -= 2;
464 
465  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
466  complete_substitutions_array($substitutionarray, $outputlangs, $object);
467 
468  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
469  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
470 
471  $pdf->SetFont('', '', $default_font_size - 1);
472  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
473  $nexY = $pdf->GetY();
474  $height_note = $nexY - $tab_top;
475 
476  // Rect takes a length in 3rd parameter
477  $pdf->SetDrawColor(192, 192, 192);
478  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
479 
480  $tab_top = $nexY + 6;
481  }
482 
483  $iniY = $tab_top + 7;
484  $curY = $tab_top + 7;
485  $nexY = $tab_top + 7;
486 
487  // Loop on each lines
488  for ($i = 0; $i < $nblines; $i++)
489  {
490  $curY = $nexY;
491  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
492  $pdf->SetTextColor(0, 0, 0);
493 
494  // Define size of image if we need it
495  $imglinesize = array();
496  if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
497 
498  $pdf->setTopMargin($tab_top_newpage);
499  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
500  $pageposbefore = $pdf->getPage();
501 
502  $showpricebeforepagebreak = 1;
503  $posYAfterImage = 0;
504  $posYAfterDescription = 0;
505 
506  // We start with Photo of product line
507  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
508  {
509  $pdf->AddPage('', '', true);
510  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
511  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
512  $pdf->setPage($pageposbefore + 1);
513 
514  $curY = $tab_top_newpage;
515 
516  // Allows data in the first page if description is long enough to break in multiples pages
517  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
518  $showpricebeforepagebreak = 1;
519  else $showpricebeforepagebreak = 0;
520  }
521 
522  if (isset($imglinesize['width']) && isset($imglinesize['height']))
523  {
524  $curX = $this->posxpicture - 1;
525  $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
526  // $pdf->Image does not increase value return by getY, so we save it manually
527  $posYAfterImage = $curY + $imglinesize['height'];
528  }
529 
530  // Description of product line
531  $curX = $this->posxdesc - 1;
532 
533  $pdf->startTransaction();
534  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
535  $pageposafter = $pdf->getPage();
536  if ($pageposafter > $pageposbefore) // There is a pagebreak
537  {
538  $pdf->rollbackTransaction(true);
539  $pageposafter = $pageposbefore;
540  //print $pageposafter.'-'.$pageposbefore;exit;
541  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
542  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
543  $pageposafter = $pdf->getPage();
544  $posyafter = $pdf->GetY();
545  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
546  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
547  {
548  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
549  {
550  $pdf->AddPage('', '', true);
551  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
552  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
553  $pdf->setPage($pageposafter + 1);
554  }
555  } else {
556  // We found a page break
557 
558  // Allows data in the first page if description is long enough to break in multiples pages
559  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
560  $showpricebeforepagebreak = 1;
561  else $showpricebeforepagebreak = 0;
562  }
563  } else // No pagebreak
564  {
565  $pdf->commitTransaction();
566  }
567  $posYAfterDescription = $pdf->GetY();
568 
569  $nexY = $pdf->GetY();
570  $pageposafter = $pdf->getPage();
571  $pdf->setPage($pageposbefore);
572  $pdf->setTopMargin($this->marge_haute);
573  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
574 
575  // We suppose that a too long description or photo were moved completely on next page
576  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
577  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
578  }
579 
580  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
581 
582  // VAT Rate
583  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
584  {
585  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
586  $pdf->SetXY($this->posxtva - 5, $curY);
587  $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
588  }
589 
590  // Unit price before discount
591  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
592  $pdf->SetXY($this->posxup, $curY);
593  $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
594 
595  // Quantity
596  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
597  $pdf->SetXY($this->posxqty, $curY);
598  $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
599 
600  // Unit
601  if (!empty($conf->global->PRODUCT_USE_UNITS))
602  {
603  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
604  $pdf->SetXY($this->posxunit, $curY);
605  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
606  }
607 
608  // Discount on line
609  if ($object->lines[$i]->remise_percent)
610  {
611  $pdf->SetXY($this->posxdiscount - 2, $curY);
612  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
613  $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
614  }
615 
616  // Situation progress
617  if ($this->situationinvoice)
618  {
619  $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
620  $pdf->SetXY($this->posxprogress, $curY);
621  $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
622  }
623 
624  // Total HT line
625  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
626  $pdf->SetXY($this->postotalht, $curY);
627  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
628 
629 
630  $sign = 1;
631  if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
632  // Collection of totals by value of VAT in $this->tva["taux"]=total_tva
633  $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
634  if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
635  {
636  if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
637  else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
638  } else {
639  if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
640  else $tvaligne = $sign * $object->lines[$i]->total_tva;
641  }
642 
643  $localtax1ligne = $object->lines[$i]->total_localtax1;
644  $localtax2ligne = $object->lines[$i]->total_localtax2;
645  $localtax1_rate = $object->lines[$i]->localtax1_tx;
646  $localtax2_rate = $object->lines[$i]->localtax2_tx;
647  $localtax1_type = $object->lines[$i]->localtax1_type;
648  $localtax2_type = $object->lines[$i]->localtax2_type;
649 
650  if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
651  if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
652  if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
653 
654  $vatrate = (string) $object->lines[$i]->tva_tx;
655 
656  // Retrieve type from database for backward compatibility with old records
657  if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
658  && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
659  {
660  $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
661  $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
662  $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
663  }
664 
665  // retrieve global local tax
666  if ($localtax1_type && $localtax1ligne != 0)
667  $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
668  if ($localtax2_type && $localtax2ligne != 0)
669  $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
670 
671  if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
672  if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
673  $this->tva[$vatrate] += $tvaligne;
674 
675  if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
676 
677  // Add line
678  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
679  {
680  $pdf->setPage($pageposafter);
681  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
682  //$pdf->SetDrawColor(190,190,200);
683  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
684  $pdf->SetLineStyle(array('dash'=>0));
685  }
686 
687  $nexY += 2; // Add space between lines
688 
689  // Detect if some page were added automatically and output _tableau for past pages
690  while ($pagenb < $pageposafter)
691  {
692  $pdf->setPage($pagenb);
693  if ($pagenb == 1)
694  {
695  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
696  } else {
697  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
698  }
699  $this->_pagefoot($pdf, $object, $outputlangs, 1);
700  $pagenb++;
701  $pdf->setPage($pagenb);
702  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
703  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
704  }
705  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
706  {
707  if ($pagenb == 1)
708  {
709  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
710  } else {
711  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
712  }
713  $this->_pagefoot($pdf, $object, $outputlangs, 1);
714  // New page
715  $pdf->AddPage();
716  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
717  $pagenb++;
718  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
719  }
720  }
721 
722  // Show square
723  if ($pagenb == 1)
724  {
725  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
726  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
727  } else {
728  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
729  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
730  }
731 
732  // Display info area
733  $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
734 
735  // Display total area
736  $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
737 
738  // Display Payments area
739  if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
740  {
741  $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter);
742  }
743 
744  // Pagefoot
745  $this->_pagefoot($pdf, $object, $outputlangs);
746  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
747 
748  $pdf->Close();
749 
750  $pdf->Output($file, 'F');
751 
752  // Add pdfgeneration hook
753  $hookmanager->initHooks(array('pdfgeneration'));
754  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
755  global $action;
756  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
757  if ($reshook < 0)
758  {
759  $this->error = $hookmanager->error;
760  $this->errors = $hookmanager->errors;
761  }
762 
763  if (!empty($conf->global->MAIN_UMASK))
764  @chmod($file, octdec($conf->global->MAIN_UMASK));
765 
766  $this->result = array('fullpath'=>$file);
767 
768  return 1; // No error
769  } else {
770  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
771  return 0;
772  }
773  } else {
774  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
775  return 0;
776  }
777  }
778 
779 
780  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
781  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
792  protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0)
793  {
794  // phpcs:enable
795  global $conf;
796 
797  $sign = 1;
798  if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
799 
800  $current_page = $pdf->getPage();
801  $tab3_posx = 120;
802  $tab3_top = $posy + 8;
803  $tab3_width = 80;
804  $tab3_height = 4;
805  if ($this->page_largeur < 210) // To work with US executive format
806  {
807  $tab3_posx -= 20;
808  }
809 
810  $default_font_size = pdf_getPDFFontSize($outputlangs);
811 
812  $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
813 
814  $y = 0;
815 
816  $pdf->SetFont('', '', $default_font_size - 4);
817 
818 
819  // Loop on each discount available (deposits and credit notes and excess of payment included)
820  $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
821  $sql .= " re.description, re.fk_facture_source,";
822  $sql .= " f.type, f.datef";
823  $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
824  $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
825  $resql = $this->db->query($sql);
826  if ($resql)
827  {
828  $num = $this->db->num_rows($resql);
829  $i = 0;
830  $invoice = new Facture($this->db);
831  while ($i < $num)
832  {
833  $y += 3;
834  if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter))
835  {
836  $y = 0;
837  $current_page++;
838  $pdf->AddPage('', '', true);
839  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
840  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
841  $pdf->setPage($current_page);
842  $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
843  }
844 
845  $obj = $this->db->fetch_object($resql);
846 
847  if ($obj->type == 2) $text = $outputlangs->transnoentities("CreditNote");
848  elseif ($obj->type == 3) $text = $outputlangs->transnoentities("Deposit");
849  elseif ($obj->type == 0) $text = $outputlangs->transnoentities("ExcessReceived");
850  else $text = $outputlangs->transnoentities("UnknownType");
851 
852  $invoice->fetch($obj->fk_facture_source);
853 
854  $pdf->SetXY($tab3_posx, $tab3_top + $y);
855  $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
856  $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
857  $pdf->MultiCell(20, 3, price((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
858  $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
859  $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
860  $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
861  $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
862 
863  $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
864 
865  $i++;
866  }
867  } else {
868  $this->error = $this->db->lasterror();
869  return -1;
870  }
871 
872  // Loop on each payment
873  // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
874  $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
875  $sql .= " cp.code";
876  $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
877  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
878  $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
879  //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
880  $sql .= " ORDER BY p.datep";
881 
882  $resql = $this->db->query($sql);
883  if ($resql)
884  {
885  $num = $this->db->num_rows($resql);
886  $i = 0;
887  while ($i < $num) {
888  $y += 3;
889  if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter))
890  {
891  $y = 0;
892  $current_page++;
893  $pdf->AddPage('', '', true);
894  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
895  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
896  $pdf->setPage($current_page);
897  $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
898  }
899 
900  $row = $this->db->fetch_object($resql);
901 
902  $pdf->SetXY($tab3_posx, $tab3_top + $y);
903  $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
904  $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
905  $pdf->MultiCell(20, 3, price($sign * ((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
906  $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
907  $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
908 
909  $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
910  $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
911  $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
912 
913  $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
914 
915  $i++;
916  }
917 
918  return $tab3_top + $y + 3;
919  } else {
920  $this->error = $this->db->lasterror();
921  return -1;
922  }
923  }
924 
925  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
926  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
940  protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
941  {
942  // phpcs:enable
943  $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
944  if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
945 
946  $pdf->SetFont('', '', $default_font_size - 3);
947  $pdf->SetXY($tab3_posx, $tab3_top - 4);
948  $pdf->MultiCell(60, 3, $title, 0, 'L', 0);
949 
950  $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
951 
952  $pdf->SetFont('', '', $default_font_size - 4);
953  $pdf->SetXY($tab3_posx, $tab3_top);
954  $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
955  $pdf->SetXY($tab3_posx + 21, $tab3_top);
956  $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
957  $pdf->SetXY($tab3_posx + 40, $tab3_top);
958  $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
959  $pdf->SetXY($tab3_posx + 58, $tab3_top);
960  $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
961 
962  $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
963  }
964 
965  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
966  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
976  protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
977  {
978  // phpcs:enable
979  global $conf, $mysoc;
980 
981  $default_font_size = pdf_getPDFFontSize($outputlangs);
982 
983  $pdf->SetFont('', '', $default_font_size - 1);
984 
985  // If France, show VAT mention if not applicable
986  if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
987  {
988  $pdf->SetFont('', 'B', $default_font_size - 2);
989  $pdf->SetXY($this->marge_gauche, $posy);
990  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
991 
992  $posy = $pdf->GetY() + 4;
993  }
994 
995  $posxval = 52;
996 
997  // Show payments conditions
998  if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
999  {
1000  $pdf->SetFont('', 'B', $default_font_size - 2);
1001  $pdf->SetXY($this->marge_gauche, $posy);
1002  $titre = $outputlangs->transnoentities("PaymentConditions").':';
1003  $pdf->MultiCell(43, 4, $titre, 0, 'L');
1004 
1005  $pdf->SetFont('', '', $default_font_size - 2);
1006  $pdf->SetXY($posxval, $posy);
1007  $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);
1008  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1009  $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1010 
1011  $posy = $pdf->GetY() + 3;
1012  }
1013 
1014  if ($object->type != 2)
1015  {
1016  // Check a payment mode is defined
1017  if (empty($object->mode_reglement_code)
1018  && empty($conf->global->FACTURE_CHQ_NUMBER)
1019  && empty($conf->global->FACTURE_RIB_NUMBER))
1020  {
1021  $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
1022  }
1023  // Avoid having any valid PDF with setup that is not complete
1024  elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1025  || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)))
1026  {
1027  $outputlangs->load("errors");
1028 
1029  $pdf->SetXY($this->marge_gauche, $posy);
1030  $pdf->SetTextColor(200, 0, 0);
1031  $pdf->SetFont('', 'B', $default_font_size - 2);
1032  $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1033  $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
1034  $pdf->SetTextColor(0, 0, 0);
1035 
1036  $posy = $pdf->GetY() + 1;
1037  }
1038 
1039  // Show payment mode
1040  if ($object->mode_reglement_code
1041  && $object->mode_reglement_code != 'CHQ'
1042  && $object->mode_reglement_code != 'VIR')
1043  {
1044  $pdf->SetFont('', 'B', $default_font_size - 2);
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 - 2);
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  // Show online payment link
1055  $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
1056  if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
1057  require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
1058  global $langs;
1059 
1060  $langs->loadLangs(array('payment', 'paybox'));
1061  $servicename = $langs->transnoentities('Online');
1062  $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', '');
1063  $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';
1064 
1065  $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
1066  }
1067 
1068 
1069  $posy = $pdf->GetY() + 2;
1070  }
1071 
1072  // Show payment mode CHQ
1073  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1074  {
1075  // If payment mode unregulated or payment mode forced to CHQ
1076  if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1077  {
1078  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1079 
1080  if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1081  {
1082  $account = new Account($this->db);
1083  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1084 
1085  $pdf->SetXY($this->marge_gauche, $posy);
1086  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1087  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
1088  $posy = $pdf->GetY() + 1;
1089 
1090  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1091  {
1092  $pdf->SetXY($this->marge_gauche, $posy);
1093  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1094  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1095  $posy = $pdf->GetY() + 2;
1096  }
1097  }
1098  if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1099  {
1100  $pdf->SetXY($this->marge_gauche, $posy);
1101  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1102  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1103  $posy = $pdf->GetY() + 1;
1104 
1105  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1106  {
1107  $pdf->SetXY($this->marge_gauche, $posy);
1108  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1109  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1110  $posy = $pdf->GetY() + 2;
1111  }
1112  }
1113  }
1114  }
1115 
1116  // If payment mode not forced or forced to VIR, show payment with BAN
1117  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1118  {
1119  if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
1120  $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1121  if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1122  $account = new Account($this->db);
1123  $account->fetch($bankid);
1124 
1125  $curx = $this->marge_gauche;
1126  $cury = $posy;
1127 
1128  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1129 
1130  $posy += 2;
1131  }
1132  }
1133  }
1134 
1135  return $posy;
1136  }
1137 
1138 
1139  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1140  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1151  protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1152  {
1153  // phpcs:enable
1154  global $conf, $mysoc;
1155 
1156  $sign = 1;
1157  if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1158 
1159  $default_font_size = pdf_getPDFFontSize($outputlangs);
1160 
1161  $tab2_top = $posy;
1162  $tab2_hl = 4;
1163  $pdf->SetFont('', '', $default_font_size - 1);
1164 
1165  // Total table
1166  $col1x = 120; $col2x = 170;
1167  if ($this->page_largeur < 210) // To work with US executive format
1168  {
1169  $col2x -= 20;
1170  }
1171  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1172 
1173  $useborder = 0;
1174  $index = 0;
1175 
1176  // Total HT
1177  $pdf->SetFillColor(255, 255, 255);
1178  $pdf->SetXY($col1x, $tab2_top + 0);
1179  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1180 
1181  $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1182  $pdf->SetXY($col2x, $tab2_top + 0);
1183  $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
1184 
1185  // Show VAT by rates and total
1186  $pdf->SetFillColor(248, 248, 248);
1187 
1188  $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1189 
1190  $this->atleastoneratenotnull = 0;
1191  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1192  {
1193  $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1194  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1195  {
1196  // Nothing to do
1197  } else {
1198  // FIXME amount of vat not supported with multicurrency
1199 
1200  //Local tax 1 before VAT
1201  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1202  //{
1203  foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1204  {
1205  if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1206 
1207  foreach ($localtax_rate as $tvakey => $tvaval)
1208  {
1209  if ($tvakey != 0) // On affiche pas taux 0
1210  {
1211  //$this->atleastoneratenotnull++;
1212 
1213  $index++;
1214  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1215 
1216  $tvacompl = '';
1217  if (preg_match('/\*/', $tvakey))
1218  {
1219  $tvakey = str_replace('*', '', $tvakey);
1220  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1221  }
1222 
1223  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
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  //Local tax 2 before VAT
1234  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1235  //{
1236  foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1237  {
1238  if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1239 
1240  foreach ($localtax_rate as $tvakey => $tvaval)
1241  {
1242  if ($tvakey != 0) // On affiche pas taux 0
1243  {
1244  //$this->atleastoneratenotnull++;
1245 
1246 
1247 
1248  $index++;
1249  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1250 
1251  $tvacompl = '';
1252  if (preg_match('/\*/', $tvakey))
1253  {
1254  $tvakey = str_replace('*', '', $tvakey);
1255  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1256  }
1257  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1258  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1259  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1260 
1261  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1262  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1263  }
1264  }
1265  }
1266 
1267  //}
1268 
1269  // VAT
1270  foreach ($this->tva as $tvakey => $tvaval)
1271  {
1272  if ($tvakey != 0) // On affiche pas taux 0
1273  {
1274  $this->atleastoneratenotnull++;
1275 
1276  $index++;
1277  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1278 
1279  $tvacompl = '';
1280  if (preg_match('/\*/', $tvakey))
1281  {
1282  $tvakey = str_replace('*', '', $tvakey);
1283  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1284  }
1285  $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1286  $totalvat .= vatrate($tvakey, 1).$tvacompl;
1287  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1288 
1289  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1290  $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval, 'MT'), 0, $outputlangs), 0, 'R', 1);
1291  }
1292  }
1293 
1294  //Local tax 1 after VAT
1295  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1296  //{
1297  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1298  if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1299 
1300  foreach ($localtax_rate as $tvakey => $tvaval)
1301  {
1302  if ($tvakey != 0) // On affiche pas taux 0
1303  {
1304  //$this->atleastoneratenotnull++;
1305 
1306  $index++;
1307  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1308 
1309  $tvacompl = '';
1310  if (preg_match('/\*/', $tvakey))
1311  {
1312  $tvakey = str_replace('*', '', $tvakey);
1313  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1314  }
1315  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1316  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1317 
1318  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1319  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1320  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1321  }
1322  }
1323  }
1324  //}
1325  //Local tax 2 after VAT
1326  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1327  //{
1328  foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1329  {
1330  if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1331 
1332  foreach ($localtax_rate as $tvakey => $tvaval)
1333  {
1334  //$this->atleastoneratenotnull++;
1335 
1336  $index++;
1337  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1338 
1339  $tvacompl = '';
1340  if (preg_match('/\*/', $tvakey))
1341  {
1342  $tvakey = str_replace('*', '', $tvakey);
1343  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1344  }
1345  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1346 
1347  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1348  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1349 
1350  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1351  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1352  }
1353  }
1354  //}
1355 
1356  // Revenue stamp
1357  if (price2num($object->revenuestamp) != 0)
1358  {
1359  $index++;
1360  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1361  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1362 
1363  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1364  $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
1365  }
1366 
1367  // Total TTC
1368  $index++;
1369  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1370  $pdf->SetTextColor(0, 0, 60);
1371  $pdf->SetFillColor(224, 224, 224);
1372  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1373 
1374  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1375  $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1376 
1377  // Retained warranty
1378  if ($object->displayRetainedWarranty())
1379  {
1380  $pdf->SetTextColor(40, 40, 40);
1381  $pdf->SetFillColor(255, 255, 255);
1382 
1383  $retainedWarranty = $object->getRetainedWarrantyAmount();
1384  $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1385 
1386  // Billed - retained warranty
1387  $index++;
1388  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1389  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
1390 
1391  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1392  $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
1393 
1394  // retained warranty
1395  $index++;
1396  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1397 
1398  $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
1399  $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
1400 
1401  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
1402  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1403  $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
1404  }
1405  }
1406  }
1407 
1408  $pdf->SetTextColor(0, 0, 0);
1409  $creditnoteamount = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
1410  $depositsamount = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1411  //print "x".$creditnoteamount."-".$depositsamount;exit;
1412  $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1413  if (!empty($object->paye)) $resteapayer = 0;
1414 
1415  if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1416  {
1417  // Already paid + Deposits
1418  $index++;
1419  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1420  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1421  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1422  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
1423 
1424  // Credit note
1425  if ($creditnoteamount)
1426  {
1427  $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
1428  $index++;
1429  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1430  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
1431  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1432  $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
1433  }
1434 
1435  // Escompte
1436  if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
1437  {
1438  $index++;
1439  $pdf->SetFillColor(255, 255, 255);
1440 
1441  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1442  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1443  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1444  $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
1445 
1446  $resteapayer = 0;
1447  }
1448 
1449  $index++;
1450  $pdf->SetTextColor(0, 0, 60);
1451  $pdf->SetFillColor(224, 224, 224);
1452  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1453  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1454  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1455  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1456 
1457  $pdf->SetFont('', '', $default_font_size - 1);
1458  $pdf->SetTextColor(0, 0, 0);
1459  }
1460 
1461  $index++;
1462  return ($tab2_top + ($tab2_hl * $index));
1463  }
1464 
1465  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1479  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1480  {
1481  global $conf;
1482 
1483  // Force to disable hidetop and hidebottom
1484  $hidebottom = 0;
1485  if ($hidetop) $hidetop = -1;
1486 
1487  $currency = !empty($currency) ? $currency : $conf->currency;
1488  $default_font_size = pdf_getPDFFontSize($outputlangs);
1489 
1490  // Amount in (at tab_top - 1)
1491  $pdf->SetTextColor(0, 0, 0);
1492  $pdf->SetFont('', '', $default_font_size - 2);
1493 
1494  if (empty($hidetop))
1495  {
1496  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1497  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1498  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1499 
1500  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1501  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1502  }
1503 
1504  $pdf->SetDrawColor(128, 128, 128);
1505  $pdf->SetFont('', '', $default_font_size - 1);
1506 
1507  // Output Rect
1508  $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
1509 
1510  if (empty($hidetop))
1511  {
1512  $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
1513 
1514  $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1515  $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1516  }
1517 
1518  if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
1519  {
1520  $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1521  if (empty($hidetop))
1522  {
1523  //$pdf->SetXY($this->posxpicture-1, $tab_top+1);
1524  //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
1525  }
1526  }
1527 
1528  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1529  {
1530  $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1531  if (empty($hidetop))
1532  {
1533  $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1534  $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1535  }
1536  }
1537 
1538  $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1539  if (empty($hidetop))
1540  {
1541  $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1542  $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1543  }
1544 
1545  $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1546  if (empty($hidetop))
1547  {
1548  $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1549  $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1550  }
1551 
1552  if (!empty($conf->global->PRODUCT_USE_UNITS))
1553  {
1554  $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1555  if (empty($hidetop)) {
1556  $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1557  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
1558  }
1559  }
1560 
1561  if ($this->atleastonediscount)
1562  {
1563  $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1564  if (empty($hidetop))
1565  {
1566  $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1567  $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1568  }
1569  }
1570 
1571  if ($this->situationinvoice) {
1572  $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1573  if (empty($hidetop)) {
1574  $pdf->SetXY($this->posxprogress, $tab_top + 1);
1575  $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
1576  }
1577  }
1578 
1579  $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1580  if (empty($hidetop))
1581  {
1582  $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1583  $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1584  }
1585  }
1586 
1587  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1597  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1598  {
1599  global $conf, $langs;
1600 
1601  // Load traductions files required by page
1602  $outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
1603 
1604  $default_font_size = pdf_getPDFFontSize($outputlangs);
1605 
1606  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1607 
1608  // Show Draft Watermark
1609  if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
1610  {
1611  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
1612  }
1613 
1614  $pdf->SetTextColor(0, 0, 60);
1615  $pdf->SetFont('', 'B', $default_font_size + 3);
1616 
1617  $w = 110;
1618 
1619  $posy = $this->marge_haute;
1620  $posx = $this->page_largeur - $this->marge_droite - $w;
1621 
1622  $pdf->SetXY($this->marge_gauche, $posy);
1623 
1624  // Logo
1625  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1626  {
1627  if ($this->emetteur->logo)
1628  {
1629  $logodir = $conf->mycompany->dir_output;
1630  if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1631  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1632  {
1633  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1634  } else {
1635  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1636  }
1637  if (is_readable($logo))
1638  {
1639  $height = pdf_getHeightForLogo($logo);
1640  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1641  } else {
1642  $pdf->SetTextColor(200, 0, 0);
1643  $pdf->SetFont('', 'B', $default_font_size - 2);
1644  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1645  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1646  }
1647  } else {
1648  $text = $this->emetteur->name;
1649  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1650  }
1651  }
1652 
1653  $pdf->SetFont('', 'B', $default_font_size + 3);
1654  $pdf->SetXY($posx, $posy);
1655  $pdf->SetTextColor(0, 0, 60);
1656  $title = $outputlangs->transnoentities("PdfInvoiceTitle");
1657  if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
1658  if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
1659  if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
1660  if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
1661  if ($this->situationinvoice) $title = $outputlangs->transnoentities("PDFInvoiceSituation");
1662  $pdf->MultiCell($w, 3, $title, '', 'R');
1663 
1664  $pdf->SetFont('', 'B', $default_font_size);
1665 
1666  $posy += 5;
1667  $pdf->SetXY($posx, $posy);
1668  $pdf->SetTextColor(0, 0, 60);
1669  $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1670  if ($object->statut == Facture::STATUS_DRAFT)
1671  {
1672  $pdf->SetTextColor(128, 0, 0);
1673  $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1674  }
1675  $pdf->MultiCell($w, 4, $textref, '', 'R');
1676 
1677  $posy += 1;
1678  $pdf->SetFont('', '', $default_font_size - 2);
1679 
1680  if ($object->ref_client)
1681  {
1682  $posy += 4;
1683  $pdf->SetXY($posx, $posy);
1684  $pdf->SetTextColor(0, 0, 60);
1685  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1686  }
1687 
1688  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1689  {
1690  $object->fetch_projet();
1691  if (!empty($object->project->ref))
1692  {
1693  $posy += 3;
1694  $pdf->SetXY($posx, $posy);
1695  $pdf->SetTextColor(0, 0, 60);
1696  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
1697  }
1698  }
1699 
1700  if (!empty($conf->global->PDF_SHOW_PROJECT))
1701  {
1702  $object->fetch_projet();
1703  if (!empty($object->project->ref))
1704  {
1705  $posy += 3;
1706  $pdf->SetXY($posx, $posy);
1707  $pdf->SetTextColor(0, 0, 60);
1708  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1709  }
1710  }
1711 
1712  $objectidnext = $object->getIdReplacingInvoice('validated');
1713  if ($object->type == 0 && $objectidnext)
1714  {
1715  $objectreplacing = new Facture($this->db);
1716  $objectreplacing->fetch($objectidnext);
1717 
1718  $posy += 3;
1719  $pdf->SetXY($posx, $posy);
1720  $pdf->SetTextColor(0, 0, 60);
1721  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
1722  }
1723  if ($object->type == 1)
1724  {
1725  $objectreplaced = new Facture($this->db);
1726  $objectreplaced->fetch($object->fk_facture_source);
1727 
1728  $posy += 4;
1729  $pdf->SetXY($posx, $posy);
1730  $pdf->SetTextColor(0, 0, 60);
1731  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1732  }
1733  if ($object->type == 2 && !empty($object->fk_facture_source))
1734  {
1735  $objectreplaced = new Facture($this->db);
1736  $objectreplaced->fetch($object->fk_facture_source);
1737 
1738  $posy += 3;
1739  $pdf->SetXY($posx, $posy);
1740  $pdf->SetTextColor(0, 0, 60);
1741  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1742  }
1743 
1744  $posy += 4;
1745  $pdf->SetXY($posx, $posy);
1746  $pdf->SetTextColor(0, 0, 60);
1747  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
1748 
1749  if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
1750  {
1751  $posy += 4;
1752  $pdf->SetXY($posx, $posy);
1753  $pdf->SetTextColor(0, 0, 60);
1754  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R');
1755  }
1756 
1757  if ($object->type != 2)
1758  {
1759  $posy += 3;
1760  $pdf->SetXY($posx, $posy);
1761  $pdf->SetTextColor(0, 0, 60);
1762  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
1763  }
1764 
1765  if ($object->thirdparty->code_client)
1766  {
1767  $posy += 3;
1768  $pdf->SetXY($posx, $posy);
1769  $pdf->SetTextColor(0, 0, 60);
1770  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1771  }
1772 
1773  // Get contact
1774  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1775  {
1776  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1777  if (count($arrayidcontact) > 0)
1778  {
1779  $usertmp = new User($this->db);
1780  $usertmp->fetch($arrayidcontact[0]);
1781  $posy += 4;
1782  $pdf->SetXY($posx, $posy);
1783  $pdf->SetTextColor(0, 0, 60);
1784  $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1785  }
1786  }
1787 
1788  $posy += 1;
1789 
1790  $top_shift = 0;
1791  // Show list of linked objects
1792  $current_y = $pdf->getY();
1793  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1794  if ($current_y < $pdf->getY())
1795  {
1796  $top_shift = $pdf->getY() - $current_y;
1797  }
1798 
1799  if ($showaddress)
1800  {
1801  // Sender properties
1802  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1803 
1804  // Show sender
1805  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1806  $posy += $top_shift;
1807  $posx = $this->marge_gauche;
1808  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1809 
1810  $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1811  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1812 
1813 
1814  // Show sender frame
1815  $pdf->SetTextColor(0, 0, 0);
1816  $pdf->SetFont('', '', $default_font_size - 2);
1817  $pdf->SetXY($posx, $posy - 5);
1818  $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1819  $pdf->SetXY($posx, $posy);
1820  $pdf->SetFillColor(230, 230, 230);
1821  $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1822  $pdf->SetTextColor(0, 0, 60);
1823 
1824  // Show sender name
1825  $pdf->SetXY($posx + 2, $posy + 3);
1826  $pdf->SetFont('', 'B', $default_font_size);
1827  $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1828  $posy = $pdf->getY();
1829 
1830  // Show sender information
1831  $pdf->SetXY($posx + 2, $posy);
1832  $pdf->SetFont('', '', $default_font_size - 1);
1833  $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1834 
1835 
1836 
1837  // If BILLING contact defined on invoice, we use it
1838  $usecontact = false;
1839  $arrayidcontact = $object->getIdContact('external', 'BILLING');
1840  if (count($arrayidcontact) > 0)
1841  {
1842  $usecontact = true;
1843  $result = $object->fetch_contact($arrayidcontact[0]);
1844  }
1845 
1846  // Recipient name
1847  if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1848  $thirdparty = $object->contact;
1849  } else {
1850  $thirdparty = $object->thirdparty;
1851  }
1852 
1853  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1854 
1855  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1856 
1857  // Show recipient
1858  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1859  if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1860  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1861  $posy += $top_shift;
1862  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1863  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1864 
1865  // Show recipient frame
1866  $pdf->SetTextColor(0, 0, 0);
1867  $pdf->SetFont('', '', $default_font_size - 2);
1868  $pdf->SetXY($posx + 2, $posy - 5);
1869  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1870  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1871 
1872  // Show recipient name
1873  $pdf->SetXY($posx + 2, $posy + 3);
1874  $pdf->SetFont('', 'B', $default_font_size);
1875  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1876 
1877  $posy = $pdf->getY();
1878 
1879  // Show recipient information
1880  $pdf->SetFont('', '', $default_font_size - 1);
1881  $pdf->SetXY($posx + 2, $posy);
1882  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1883  }
1884 
1885  $pdf->SetTextColor(0, 0, 0);
1886  return $top_shift;
1887  }
1888 
1889  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1899  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1900  {
1901  global $conf;
1902  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1903  return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1904  }
1905 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
Definition: pdf.lib.php:712
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:342
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:620
Class to generate the customer invoice PDF with template Crabe.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:663
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
Function _tableau_versements_header.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:750
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:245
Class to manage products or services.
Class to manage Dolibarr users.
Definition: user.class.php:44
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...
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:222
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:1828
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
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...
$conf db
API class for accounts.
Definition: inc.php:54
Class to manage bank accounts.
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...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '')
Show table for lines.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition: pdf.lib.php:1952
Class to manage hooks.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1556
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1691
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
Definition: pdf.lib.php:887
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1615
Parent class of invoice document generators.
_tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter=0)
Show payments table.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
const STATUS_DRAFT
Draft status.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
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:2221
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition: pdf.lib.php:1869
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
Definition: pdf.lib.php:1906
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:270
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1135
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:643
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:88
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:376
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition: pdf.lib.php:1174
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
Class to manage invoices.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
__construct($db)
Constructor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
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 &quot;subst...