dolibarr  16.0.5
pdf_einstein.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-2018 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 $phpmin = array(5, 6);
80 
85  public $version = 'dolibarr';
86 
90  public $page_largeur;
91 
95  public $page_hauteur;
96 
100  public $format;
101 
105  public $marge_gauche;
106 
110  public $marge_droite;
111 
115  public $marge_haute;
116 
120  public $marge_basse;
121 
126  public $emetteur;
127 
128 
134  public function __construct($db)
135  {
136  global $conf, $langs, $mysoc;
137 
138  // Translations
139  $langs->loadLangs(array("main", "bills", "products"));
140 
141  $this->db = $db;
142  $this->name = "einstein";
143  $this->description = $langs->trans('PDFEinsteinDescription');
144  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
145 
146  // Dimension page
147  $this->type = 'pdf';
148  $formatarray = pdf_getFormat();
149  $this->page_largeur = $formatarray['width'];
150  $this->page_hauteur = $formatarray['height'];
151  $this->format = array($this->page_largeur, $this->page_hauteur);
152  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
153  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
154  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
155  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
156 
157  $this->option_logo = 1; // Display logo
158  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
159  $this->option_modereg = 1; // Display payment mode
160  $this->option_condreg = 1; // Display payment terms
161  $this->option_multilang = 1; // Available in several languages
162  $this->option_escompte = 0; // Displays if there has been a discount
163  $this->option_credit_note = 0; // Support credit notes
164  $this->option_freetext = 1; // Support add of a personalised text
165  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
166  $this->watermark = '';
167 
168  // Get source company
169  $this->emetteur = $mysoc;
170  if (empty($this->emetteur->country_code)) {
171  $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
172  }
173 
174  // Define position of columns
175  $this->posxdesc = $this->marge_gauche + 1;
176  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
177  $this->posxtva = 101;
178  $this->posxup = 118;
179  $this->posxqty = 135;
180  $this->posxunit = 151;
181  } else {
182  $this->posxtva = 110;
183  $this->posxup = 126;
184  $this->posxqty = 145;
185  $this->posxunit = 162;
186  }
187  $this->posxdiscount = 162;
188  $this->postotalht = 174;
189  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
190  $this->posxtva = $this->posxup;
191  }
192  $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
193  if ($this->page_largeur < 210) { // To work with US executive format
194  $this->posxpicture -= 20;
195  $this->posxtva -= 20;
196  $this->posxup -= 20;
197  $this->posxqty -= 20;
198  $this->posxunit -= 20;
199  $this->posxdiscount -= 20;
200  $this->postotalht -= 20;
201  }
202 
203  $this->tva = array();
204  $this->tva_array = array();
205  $this->localtax1 = array();
206  $this->localtax2 = array();
207  $this->atleastoneratenotnull = 0;
208  $this->atleastonediscount = 0;
209  }
210 
211  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
223  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
224  {
225  // phpcs:enable
226  global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
227 
228  if (!is_object($outputlangs)) {
229  $outputlangs = $langs;
230  }
231  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
232  if (!empty($conf->global->MAIN_USE_FPDF)) {
233  $outputlangs->charset_output = 'ISO-8859-1';
234  }
235 
236  // Load translation files required by the page
237  $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
238 
239  // Show Draft Watermark
240  if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
241  $this->watermark = $conf->global->COMMANDE_DRAFT_WATERMARK;
242  }
243 
244  global $outputlangsbis;
245  $outputlangsbis = null;
246  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
247  $outputlangsbis = new Translate('', $conf);
248  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
249  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
250  }
251 
252  $nblines = count($object->lines);
253 
254  if ($conf->commande->multidir_output[$conf->entity]) {
255  $object->fetch_thirdparty();
256 
257  $deja_regle = 0;
258 
259  // Definition of $dir and $file
260  if ($object->specimen) {
261  $dir = $conf->commande->multidir_output[$conf->entity];
262  $file = $dir."/SPECIMEN.pdf";
263  } else {
264  $objectref = dol_sanitizeFileName($object->ref);
265  $dir = $conf->commande->multidir_output[$object->entity]."/".$objectref;
266  $file = $dir."/".$objectref.".pdf";
267  }
268 
269  if (!file_exists($dir)) {
270  if (dol_mkdir($dir) < 0) {
271  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
272  return 0;
273  }
274  }
275 
276  if (file_exists($dir)) {
277  // Add pdfgeneration hook
278  if (!is_object($hookmanager)) {
279  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
280  $hookmanager = new HookManager($this->db);
281  }
282  $hookmanager->initHooks(array('pdfgeneration'));
283  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
284  global $action;
285  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
286 
287  // Set nblines with the new command lines content after hook
288  $nblines = count($object->lines);
289 
290  // Create pdf instance
291  $pdf = pdf_getInstance($this->format);
292  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
293  $pdf->SetAutoPageBreak(1, 0);
294 
295  $heightforinfotot = 40; // Height reserved to output the info and total part
296  $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
297  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
298  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
299  $heightforfooter += 6;
300  }
301 
302  if (class_exists('TCPDF')) {
303  $pdf->setPrintHeader(false);
304  $pdf->setPrintFooter(false);
305  }
306  $pdf->SetFont(pdf_getPDFFont($outputlangs));
307  // Set path to the background PDF File
308  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
309  $logodir = $conf->mycompany->dir_output;
310  if (!empty($conf->mycompany->multidir_output[$object->entity])) {
311  $logodir = $conf->mycompany->multidir_output[$object->entity];
312  }
313  $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
314  $tplidx = $pdf->importPage(1);
315  }
316 
317  $pdf->Open();
318  $pagenb = 0;
319  $pdf->SetDrawColor(128, 128, 128);
320 
321  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
322  $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
323  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
324  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
325  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
326  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
327  $pdf->SetCompression(false);
328  }
329 
330  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
331 
332  // Set $this->atleastonediscount if you have at least one discount
333  for ($i = 0; $i < $nblines; $i++) {
334  if ($object->lines[$i]->remise_percent) {
335  $this->atleastonediscount++;
336  }
337  }
338  if (empty($this->atleastonediscount)) {
339  $delta = ($this->postotalht - $this->posxdiscount);
340  $this->posxpicture += $delta;
341  $this->posxtva += $delta;
342  $this->posxup += $delta;
343  $this->posxqty += $delta;
344  $this->posxunit += $delta;
345  $this->posxdiscount += $delta;
346  // post of fields after are not modified, stay at same position
347  }
348 
349  // New page
350  $pdf->AddPage();
351  if (!empty($tplidx)) {
352  $pdf->useTemplate($tplidx);
353  }
354  $pagenb++;
355  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null));
356  $pdf->SetFont('', '', $default_font_size - 1);
357  $pdf->MultiCell(0, 3, ''); // Set interline to 3
358  $pdf->SetTextColor(0, 0, 0);
359 
360 
361  $tab_top = 90 + $top_shift;
362  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
363 
364  // Incoterm
365  $height_incoterms = 0;
366  if (!empty($conf->incoterm->enabled)) {
367  $desc_incoterms = $object->getIncotermsForPDF();
368  if ($desc_incoterms) {
369  $tab_top -= 2;
370 
371  $pdf->SetFont('', '', $default_font_size - 1);
372  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
373  $nexY = $pdf->GetY();
374  $height_incoterms = $nexY - $tab_top;
375 
376  // Rect takes a length in 3rd parameter
377  $pdf->SetDrawColor(192, 192, 192);
378  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
379 
380  $tab_top = $nexY + 6;
381  }
382  }
383 
384  // Displays notes
385  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
386  if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
387  // Get first sale rep
388  if (is_object($object->thirdparty)) {
389  $salereparray = $object->thirdparty->getSalesRepresentatives($user);
390  $salerepobj = new User($this->db);
391  $salerepobj->fetch($salereparray[0]['id']);
392  if (!empty($salerepobj->signature)) {
393  $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
394  }
395  }
396  }
397  // Extrafields in note
398  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
399  if (!empty($extranote)) {
400  $notetoshow = dol_concatdesc($notetoshow, $extranote);
401  }
402 
403  if ($notetoshow) {
404  $tab_top -= 2;
405 
406  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
407  complete_substitutions_array($substitutionarray, $outputlangs, $object);
408  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
409  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
410 
411  $pdf->SetFont('', '', $default_font_size - 1);
412  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
413  $nexY = $pdf->GetY();
414  $height_note = $nexY - $tab_top;
415 
416  // Rect takes a length in 3rd parameter
417  $pdf->SetDrawColor(192, 192, 192);
418  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
419 
420  $tab_top = $nexY + 6;
421  }
422 
423  $iniY = $tab_top + 7;
424  $curY = $tab_top + 7;
425  $nexY = $tab_top + 7;
426 
427  // Loop on each lines
428  for ($i = 0; $i < $nblines; $i++) {
429  $curY = $nexY;
430  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
431  $pdf->SetTextColor(0, 0, 0);
432 
433  $pdf->setTopMargin($tab_top_newpage);
434  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
435  $pageposbefore = $pdf->getPage();
436 
437  // Description of product line
438  $curX = $this->posxdesc - 1;
439 
440  $showpricebeforepagebreak = 1;
441 
442  $pdf->startTransaction();
443  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
444  $pageposafter = $pdf->getPage();
445  if ($pageposafter > $pageposbefore) { // There is a pagebreak
446  $pdf->rollbackTransaction(true);
447  $pageposafter = $pageposbefore;
448  //print $pageposafter.'-'.$pageposbefore;exit;
449  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
450  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
451  $pageposafter = $pdf->getPage();
452  $posyafter = $pdf->GetY();
453  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
454  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
455  $pdf->AddPage('', '', true);
456  if (!empty($tplidx)) {
457  $pdf->useTemplate($tplidx);
458  }
459  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
460  $this->_pagehead($pdf, $object, 0, $outputlangs);
461  }
462  $pdf->setPage($pageposafter + 1);
463  }
464  } else {
465  // We found a page break
466  // Allows data in the first page if description is long enough to break in multiples pages
467  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
468  $showpricebeforepagebreak = 1;
469  } else {
470  $showpricebeforepagebreak = 0;
471  }
472  }
473  } else // No pagebreak
474  {
475  $pdf->commitTransaction();
476  }
477  $posYAfterDescription = $pdf->GetY();
478 
479  $nexY = $pdf->GetY();
480  $pageposafter = $pdf->getPage();
481 
482  $pdf->setPage($pageposbefore);
483  $pdf->setTopMargin($this->marge_haute);
484  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
485 
486  // We suppose that a too long description is moved completely on next page
487  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
488  $pdf->setPage($pageposafter);
489  $curY = $tab_top_newpage;
490  }
491 
492  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
493 
494  // VAT Rate
495  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
496  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
497  $pdf->SetXY($this->posxtva - 5, $curY);
498  $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
499  }
500 
501  // Unit price before discount
502  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
503  $pdf->SetXY($this->posxup, $curY);
504  $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
505 
506  // Quantity
507  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
508  $pdf->SetXY($this->posxqty, $curY);
509  $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
510 
511  // Unit
512  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
513  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
514  $pdf->SetXY($this->posxunit, $curY);
515  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
516  }
517 
518  // Discount on line
519  $pdf->SetXY($this->posxdiscount, $curY);
520  if ($object->lines[$i]->remise_percent) {
521  $pdf->SetXY($this->posxdiscount - 2, $curY);
522  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
523  $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
524  }
525 
526  // Total HT line
527  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
528  $pdf->SetXY($this->postotalht, $curY);
529  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
530 
531  // Collection of totals by value of vat in $this->vat["rate"] = total_tva
532  if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) {
533  $tvaligne = $object->lines[$i]->multicurrency_total_tva;
534  } else {
535  $tvaligne = $object->lines[$i]->total_tva;
536  }
537 
538  $localtax1ligne = $object->lines[$i]->total_localtax1;
539  $localtax2ligne = $object->lines[$i]->total_localtax2;
540  $localtax1_rate = $object->lines[$i]->localtax1_tx;
541  $localtax2_rate = $object->lines[$i]->localtax2_tx;
542  $localtax1_type = $object->lines[$i]->localtax1_type;
543  $localtax2_type = $object->lines[$i]->localtax2_type;
544 
545  if ($object->remise_percent) {
546  $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
547  }
548  if ($object->remise_percent) {
549  $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
550  }
551  if ($object->remise_percent) {
552  $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
553  }
554 
555  $vatrate = (string) $object->lines[$i]->tva_tx;
556 
557  // Retrieve type from database for backward compatibility with old records
558  if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
559  && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
560  $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
561  $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
562  $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
563  }
564 
565  // retrieve global local tax
566  if ($localtax1_type && $localtax1ligne != 0) {
567  $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
568  }
569  if ($localtax2_type && $localtax2ligne != 0) {
570  $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
571  }
572 
573  if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
574  $vatrate .= '*';
575  }
576 
577  // Fill $this->tva and $this->tva_array
578  if (!isset($this->tva[$vatrate])) {
579  $this->tva[$vatrate] = 0;
580  }
581  $this->tva[$vatrate] += $tvaligne;
582  $vatcode = $object->lines[$i]->vat_src_code;
583  if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
584  $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
585  }
586  $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
587 
588  // Add line
589  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
590  $pdf->setPage($pageposafter);
591  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
592  //$pdf->SetDrawColor(190,190,200);
593  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
594  $pdf->SetLineStyle(array('dash'=>0));
595  }
596 
597  $nexY += 2; // Add space between lines
598 
599  // Detect if some page were added automatically and output _tableau for past pages
600  while ($pagenb < $pageposafter) {
601  $pdf->setPage($pagenb);
602  if ($pagenb == 1) {
603  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
604  } else {
605  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
606  }
607  $this->_pagefoot($pdf, $object, $outputlangs, 1);
608  $pagenb++;
609  $pdf->setPage($pagenb);
610  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
611  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
612  $this->_pagehead($pdf, $object, 0, $outputlangs);
613  }
614  if (!empty($tplidx)) {
615  $pdf->useTemplate($tplidx);
616  }
617  }
618  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
619  if ($pagenb == 1) {
620  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
621  } else {
622  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
623  }
624  $this->_pagefoot($pdf, $object, $outputlangs, 1);
625  // New page
626  $pdf->AddPage();
627  if (!empty($tplidx)) {
628  $pdf->useTemplate($tplidx);
629  }
630  $pagenb++;
631  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
632  $this->_pagehead($pdf, $object, 0, $outputlangs);
633  }
634  }
635  }
636 
637  // Show square
638  if ($pagenb == 1) {
639  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
640  } else {
641  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
642  }
643  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
644 
645  // Display infos area
646  $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
647 
648  // Display total zone
649  $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
650 
651  // Affiche zone versements
652  /*
653  if ($deja_regle)
654  {
655  $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
656  }
657  */
658 
659  // Pied de page
660  $this->_pagefoot($pdf, $object, $outputlangs);
661  if (method_exists($pdf, 'AliasNbPages')) {
662  $pdf->AliasNbPages();
663  }
664 
665  $pdf->Close();
666 
667  $pdf->Output($file, 'F');
668 
669  // Add pdfgeneration hook
670  $hookmanager->initHooks(array('pdfgeneration'));
671  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
672  global $action;
673  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
674  if ($reshook < 0) {
675  $this->error = $hookmanager->error;
676  $this->errors = $hookmanager->errors;
677  }
678 
679  if (!empty($conf->global->MAIN_UMASK)) {
680  @chmod($file, octdec($conf->global->MAIN_UMASK));
681  }
682 
683  $this->result = array('fullpath'=>$file);
684 
685  return 1; // No error
686  } else {
687  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
688  return 0;
689  }
690  } else {
691  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
692  return 0;
693  }
694  }
695 
696  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
697  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
707  protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
708  {
709  // phpcs:enable
710  }
711 
712  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
713  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
723  protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
724  {
725  // phpcs:enable
726  global $conf, $mysoc;
727  $default_font_size = pdf_getPDFFontSize($outputlangs);
728 
729  $pdf->SetFont('', '', $default_font_size - 1);
730 
731  // If France, show VAT mention if not applicable
732  if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
733  $pdf->SetFont('', 'B', $default_font_size - 2);
734  $pdf->SetXY($this->marge_gauche, $posy);
735  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
736 
737  $posy = $pdf->GetY() + 4;
738  }
739 
740  $posxval = 52;
741 
742  // Show payments conditions
743  if ($object->cond_reglement_code || $object->cond_reglement) {
744  $pdf->SetFont('', 'B', $default_font_size - 2);
745  $pdf->SetXY($this->marge_gauche, $posy);
746  $titre = $outputlangs->transnoentities("PaymentConditions").':';
747  $pdf->MultiCell(43, 4, $titre, 0, 'L');
748 
749  $pdf->SetFont('', '', $default_font_size - 2);
750  $pdf->SetXY($posxval, $posy);
751  $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);
752  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
753  if ($object->deposit_percent > 0) {
754  $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
755  }
756  $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
757 
758  $posy = $pdf->GetY() + 3;
759  }
760 
761  // Check a payment mode is defined
762  /* Not used with orders
763  if (empty($object->mode_reglement_code)
764  && ! $conf->global->FACTURE_CHQ_NUMBER
765  && ! $conf->global->FACTURE_RIB_NUMBER)
766  {
767  $pdf->SetXY($this->marge_gauche, $posy);
768  $pdf->SetTextColor(200,0,0);
769  $pdf->SetFont('','B', $default_font_size - 2);
770  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
771  $pdf->SetTextColor(0,0,0);
772 
773  $posy=$pdf->GetY()+1;
774  }
775  */
776  /* TODO
777  else if (! empty($object->availability_code))
778  {
779  $pdf->SetXY($this->marge_gauche, $posy);
780  $pdf->SetTextColor(200,0,0);
781  $pdf->SetFont('','B', $default_font_size - 2);
782  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
783  $pdf->SetTextColor(0,0,0);
784 
785  $posy=$pdf->GetY()+1;
786  }*/
787 
788  // Show planed date of delivery
789  if (!empty($object->delivery_date)) {
790  $outputlangs->load("sendings");
791  $pdf->SetFont('', 'B', $default_font_size - 2);
792  $pdf->SetXY($this->marge_gauche, $posy);
793  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
794  $pdf->MultiCell(80, 4, $titre, 0, 'L');
795  $pdf->SetFont('', '', $default_font_size - 2);
796  $pdf->SetXY($posxval, $posy);
797  $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
798  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
799 
800  $posy = $pdf->GetY() + 1;
801  } elseif ($object->availability_code || $object->availability) {
802  // Show availability conditions
803  $pdf->SetFont('', 'B', $default_font_size - 2);
804  $pdf->SetXY($this->marge_gauche, $posy);
805  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
806  $pdf->MultiCell(80, 4, $titre, 0, 'L');
807  $pdf->SetTextColor(0, 0, 0);
808  $pdf->SetFont('', '', $default_font_size - 2);
809  $pdf->SetXY($posxval, $posy);
810  $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 : '');
811  $lib_availability = str_replace('\n', "\n", $lib_availability);
812  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
813 
814  $posy = $pdf->GetY() + 1;
815  }
816 
817  // Show payment mode
818  if ($object->mode_reglement_code
819  && $object->mode_reglement_code != 'CHQ'
820  && $object->mode_reglement_code != 'VIR') {
821  $pdf->SetFont('', 'B', $default_font_size - 2);
822  $pdf->SetXY($this->marge_gauche, $posy);
823  $titre = $outputlangs->transnoentities("PaymentMode").':';
824  $pdf->MultiCell(80, 5, $titre, 0, 'L');
825 
826  $pdf->SetFont('', '', $default_font_size - 2);
827  $pdf->SetXY($posxval, $posy);
828  $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);
829  $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
830 
831  $posy = $pdf->GetY() + 2;
832  }
833 
834  // Show payment mode CHQ
835  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
836  // Si mode reglement non force ou si force a CHQ
837  if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
838  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
839 
840  if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
841  $account = new Account($this->db);
842  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
843 
844  $pdf->SetXY($this->marge_gauche, $posy);
845  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
846  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
847  $posy = $pdf->GetY() + 1;
848 
849  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
850  $pdf->SetXY($this->marge_gauche, $posy);
851  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
852  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
853  $posy = $pdf->GetY() + 2;
854  }
855  }
856  if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
857  $pdf->SetXY($this->marge_gauche, $posy);
858  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
859  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
860  $posy = $pdf->GetY() + 1;
861 
862  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
863  $pdf->SetXY($this->marge_gauche, $posy);
864  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
865  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
866  $posy = $pdf->GetY() + 2;
867  }
868  }
869  }
870  }
871 
872  // If payment mode not forced or forced to VIR, show payment with BAN
873  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
874  if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
875  $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
876  if ($object->fk_bank > 0) {
877  $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
878  }
879  $account = new Account($this->db);
880  $account->fetch($bankid);
881 
882  $curx = $this->marge_gauche;
883  $cury = $posy;
884 
885  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
886 
887  $posy += 2;
888  }
889  }
890 
891  return $posy;
892  }
893 
894  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
895  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
907  protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
908  {
909  // phpcs:enable
910  global $conf, $mysoc, $hookmanager;
911 
912  $default_font_size = pdf_getPDFFontSize($outputlangs);
913 
914  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
915  $outputlangsbis = new Translate('', $conf);
916  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
917  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
918  $default_font_size--;
919  }
920 
921  $tab2_top = $posy;
922  $tab2_hl = 4;
923  $pdf->SetFont('', '', $default_font_size - 1);
924 
925  // Total table
926  $col1x = 120;
927  $col2x = 170;
928  if ($this->page_largeur < 210) { // To work with US executive format
929  $col2x -= 20;
930  }
931  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
932 
933  $useborder = 0;
934  $index = 0;
935 
936  // Total HT
937  $pdf->SetFillColor(255, 255, 255);
938  $pdf->SetXY($col1x, $tab2_top + 0);
939  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
940 
941  $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
942  $pdf->SetXY($col2x, $tab2_top + 0);
943  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
944 
945  // Show VAT by rates and total
946  $pdf->SetFillColor(248, 248, 248);
947 
948  $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
949 
950  $this->atleastoneratenotnull = 0;
951  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
952  $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
953  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
954  // Nothing to do
955  } else {
956  //Local tax 1 before VAT
957  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
958  //{
959  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
960  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
961  continue;
962  }
963  foreach ($localtax_rate as $tvakey => $tvaval) {
964  if ($tvakey != 0) { // On affiche pas taux 0
965  //$this->atleastoneratenotnull++;
966 
967  $index++;
968  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
969 
970  $tvacompl = '';
971  if (preg_match('/\*/', $tvakey)) {
972  $tvakey = str_replace('*', '', $tvakey);
973  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
974  }
975  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
976  $totalvat .= ' ';
977  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
978  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
979 
980  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
981  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
982  }
983  }
984  }
985  //}
986  //Local tax 2 before VAT
987  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
988  //{
989  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
990  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
991  continue;
992  }
993  foreach ($localtax_rate as $tvakey => $tvaval) {
994  if ($tvakey != 0) { // On affiche pas taux 0
995  //$this->atleastoneratenotnull++;
996 
997  $index++;
998  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
999 
1000  $tvacompl = '';
1001  if (preg_match('/\*/', $tvakey)) {
1002  $tvakey = str_replace('*', '', $tvakey);
1003  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1004  }
1005  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1006  $totalvat .= ' ';
1007  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1008  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1009 
1010  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1011  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1012  }
1013  }
1014  }
1015  //}
1016 
1017  // VAT
1018  foreach ($this->tva_array as $tvakey => $tvaval) {
1019  if ($tvakey != 0) { // On affiche pas taux 0
1020  $this->atleastoneratenotnull++;
1021 
1022  $index++;
1023  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1024 
1025  $tvacompl = '';
1026  if (preg_match('/\*/', $tvakey)) {
1027  $tvakey = str_replace('*', '', $tvakey);
1028  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1029  }
1030  $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1031  $totalvat .= ' ';
1032  if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
1033  $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
1034  } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
1035  $totalvat .= $tvaval['vatcode'].$tvacompl;
1036  } else {
1037  $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
1038  }
1039  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1040 
1041  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1042  $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
1043  }
1044  }
1045 
1046  //Local tax 1 after VAT
1047  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1048  //{
1049  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1050  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1051  continue;
1052  }
1053 
1054  foreach ($localtax_rate as $tvakey => $tvaval) {
1055  if ($tvakey != 0) { // On affiche pas taux 0
1056  //$this->atleastoneratenotnull++;
1057 
1058  $index++;
1059  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1060 
1061  $tvacompl = '';
1062  if (preg_match('/\*/', $tvakey)) {
1063  $tvakey = str_replace('*', '', $tvakey);
1064  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1065  }
1066  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1067  $totalvat .= ' ';
1068 
1069  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1070  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1071  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1072  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1073  }
1074  }
1075  }
1076  //}
1077  //Local tax 2 after VAT
1078  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1079  //{
1080  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1081  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1082  continue;
1083  }
1084 
1085  foreach ($localtax_rate as $tvakey => $tvaval) {
1086  // retrieve global local tax
1087  if ($tvakey != 0) { // On affiche pas taux 0
1088  //$this->atleastoneratenotnull++;
1089 
1090  $index++;
1091  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1092 
1093  $tvacompl = '';
1094  if (preg_match('/\*/', $tvakey)) {
1095  $tvakey = str_replace('*', '', $tvakey);
1096  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1097  }
1098  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1099  $totalvat .= ' ';
1100 
1101  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1102  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1103 
1104  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1106  }
1107  }
1108  }
1109  //}
1110 
1111  // Total TTC
1112  $index++;
1113  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1114  $pdf->SetTextColor(0, 0, 60);
1115  $pdf->SetFillColor(224, 224, 224);
1116  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1);
1117 
1118  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1119  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1120  }
1121  }
1122 
1123  $pdf->SetTextColor(0, 0, 0);
1124 
1125  $creditnoteamount = 0;
1126  $depositsamount = 0;
1127  //$creditnoteamount=$object->getSumCreditNotesUsed();
1128  //$depositsamount=$object->getSumDepositsUsed();
1129  //print "x".$creditnoteamount."-".$depositsamount;exit;
1130  $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1131  if (!empty($object->paye)) {
1132  $resteapayer = 0;
1133  }
1134 
1135  if ($deja_regle > 0) {
1136  // Already paid + Deposits
1137  $index++;
1138 
1139  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1140  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1141  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1142  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1143 
1144  $index++;
1145  $pdf->SetTextColor(0, 0, 60);
1146  $pdf->SetFillColor(224, 224, 224);
1147  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1148  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
1149 
1150  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1151  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1152 
1153  $pdf->SetFont('', '', $default_font_size - 1);
1154  $pdf->SetTextColor(0, 0, 0);
1155  }
1156 
1157  $index++;
1158  return ($tab2_top + ($tab2_hl * $index));
1159  }
1160 
1161  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1176  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1177  {
1178  global $conf;
1179 
1180  // Force to disable hidetop and hidebottom
1181  $hidebottom = 0;
1182  if ($hidetop) {
1183  $hidetop = -1;
1184  }
1185 
1186  $currency = !empty($currency) ? $currency : $conf->currency;
1187  $default_font_size = pdf_getPDFFontSize($outputlangs);
1188 
1189  // Amount in (at tab_top - 1)
1190  $pdf->SetTextColor(0, 0, 0);
1191  $pdf->SetFont('', '', $default_font_size - 2);
1192 
1193  if (empty($hidetop)) {
1194  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1195  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1196  $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1197  }
1198 
1199  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1200  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1201 
1202  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1203  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1204  $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));
1205  }
1206  }
1207 
1208  $pdf->SetDrawColor(128, 128, 128);
1209  $pdf->SetFont('', '', $default_font_size - 1);
1210 
1211  // Output Rect
1212  $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
1213 
1214  if (empty($hidetop)) {
1215  $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
1216 
1217  $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1218  $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1219  }
1220 
1221  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1222  $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1223  if (empty($hidetop)) {
1224  $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1225  $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1226  }
1227  }
1228 
1229  $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1230  if (empty($hidetop)) {
1231  $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1232  $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1233  }
1234 
1235  $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1236  if (empty($hidetop)) {
1237  $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1238  $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1239  }
1240 
1241  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1242  $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1243  if (empty($hidetop)) {
1244  $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1245  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
1246  }
1247  }
1248 
1249  $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1250  if (empty($hidetop)) {
1251  if ($this->atleastonediscount) {
1252  $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1253  $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1254  }
1255  }
1256 
1257  if ($this->atleastonediscount) {
1258  $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1259  }
1260  if (empty($hidetop)) {
1261  $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1262  $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1263  }
1264  }
1265 
1266  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1267  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1279  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
1280  {
1281  // phpcs:enable
1282  global $conf, $langs, $hookmanager;
1283 
1284  $ltrdirection = 'L';
1285  if ($outputlangs->trans("DIRECTION") == 'rtl') {
1286  $ltrdirection = 'R';
1287  }
1288 
1289  // Load traductions files required by page
1290  $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1291 
1292  $default_font_size = pdf_getPDFFontSize($outputlangs);
1293 
1294  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1295 
1296  $pdf->SetTextColor(0, 0, 60);
1297  $pdf->SetFont('', 'B', $default_font_size + 3);
1298 
1299  $w = 100;
1300 
1301  $posy = $this->marge_haute;
1302  $posx = $this->page_largeur - $this->marge_droite - $w;
1303 
1304  $pdf->SetXY($this->marge_gauche, $posy);
1305 
1306  // Logo
1307  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1308  if ($this->emetteur->logo) {
1309  $logodir = $conf->mycompany->dir_output;
1310  if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1311  $logodir = $conf->mycompany->multidir_output[$object->entity];
1312  }
1313  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1314  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1315  } else {
1316  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1317  }
1318  if (is_readable($logo)) {
1319  $height = pdf_getHeightForLogo($logo);
1320  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1321  } else {
1322  $pdf->SetTextColor(200, 0, 0);
1323  $pdf->SetFont('', 'B', $default_font_size - 2);
1324  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1325  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1326  }
1327  } else {
1328  $text = $this->emetteur->name;
1329  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1330  }
1331  }
1332 
1333  $pdf->SetFont('', 'B', $default_font_size + 3);
1334  $pdf->SetXY($posx, $posy);
1335  $pdf->SetTextColor(0, 0, 60);
1336  $title = $outputlangs->transnoentities($titlekey);
1337  $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1338  if ($object->statut == $object::STATUS_DRAFT) {
1339  $pdf->SetTextColor(128, 0, 0);
1340  $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1341  }
1342  $pdf->MultiCell($w, 3, $title, '', 'R');
1343 
1344  $pdf->SetFont('', 'B', $default_font_size);
1345 
1346  /*
1347  $posy += 5;
1348  $pdf->SetXY($posx, $posy);
1349  $pdf->SetTextColor(0, 0, 60);
1350  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1351  */
1352 
1353  $posy += 3;
1354  $pdf->SetFont('', '', $default_font_size - 1);
1355 
1356  if ($object->ref_client) {
1357  $posy += 5;
1358  $pdf->SetXY($posx, $posy);
1359  $pdf->SetTextColor(0, 0, 60);
1360  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1361  }
1362 
1363  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1364  $object->fetch_projet();
1365  if (!empty($object->project->ref)) {
1366  $posy += 3;
1367  $pdf->SetXY($posx, $posy);
1368  $pdf->SetTextColor(0, 0, 60);
1369  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1370  }
1371  }
1372 
1373  if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1374  $object->fetch_projet();
1375  if (!empty($object->project->ref)) {
1376  $outputlangs->load("projects");
1377  $posy += 3;
1378  $pdf->SetXY($posx, $posy);
1379  $pdf->SetTextColor(0, 0, 60);
1380  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1381  }
1382  }
1383 
1384  $posy += 4;
1385  $pdf->SetXY($posx, $posy);
1386  $pdf->SetTextColor(0, 0, 60);
1387  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1388 
1389  if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1390  $posy += 4;
1391  $pdf->SetXY($posx, $posy);
1392  $pdf->SetTextColor(0, 0, 60);
1393  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1394  }
1395 
1396  // Get contact
1397  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1398  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1399  if (count($arrayidcontact) > 0) {
1400  $usertmp = new User($this->db);
1401  $usertmp->fetch($arrayidcontact[0]);
1402  $posy += 4;
1403  $pdf->SetXY($posx, $posy);
1404  $pdf->SetTextColor(0, 0, 60);
1405  $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1406  }
1407  }
1408 
1409  $posy += 2;
1410 
1411  $top_shift = 0;
1412  // Show list of linked objects
1413  $current_y = $pdf->getY();
1414  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1415  if ($current_y < $pdf->getY()) {
1416  $top_shift = $pdf->getY() - $current_y;
1417  }
1418 
1419  if ($showaddress) {
1420  // Sender properties
1421  $carac_emetteur = '';
1422  // Add internal contact of proposal if defined
1423  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1424  if (count($arrayidcontact) > 0) {
1425  $object->fetch_user($arrayidcontact[0]);
1426  $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1427  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1428  }
1429 
1430  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1431 
1432  // Show sender
1433  $posy = 42 + $top_shift;
1434  $posx = $this->marge_gauche;
1435  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1436  $posx = $this->page_largeur - $this->marge_droite - 80;
1437  }
1438  $hautcadre = 40;
1439 
1440  // Show sender frame
1441  if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1442  $pdf->SetTextColor(0, 0, 0);
1443  $pdf->SetFont('', '', $default_font_size - 2);
1444  $pdf->SetXY($posx, $posy - 5);
1445  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1446  $pdf->SetXY($posx, $posy);
1447  $pdf->SetFillColor(230, 230, 230);
1448  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1449  $pdf->SetTextColor(0, 0, 60);
1450  }
1451 
1452  // Show sender name
1453  if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1454  $pdf->SetXY($posx + 2, $posy + 3);
1455  $pdf->SetFont('', 'B', $default_font_size);
1456  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1457  $posy = $pdf->getY();
1458  }
1459 
1460  // Show sender information
1461  $pdf->SetXY($posx + 2, $posy);
1462  $pdf->SetFont('', '', $default_font_size - 1);
1463  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1464 
1465 
1466  // If CUSTOMER contact defined, we use it
1467  $usecontact = false;
1468  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1469  if (count($arrayidcontact) > 0) {
1470  $usecontact = true;
1471  $result = $object->fetch_contact($arrayidcontact[0]);
1472  }
1473 
1474  // Recipient name
1475  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)))) {
1476  $thirdparty = $object->contact;
1477  } else {
1478  $thirdparty = $object->thirdparty;
1479  }
1480 
1481  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1482 
1483  $mode = 'target';
1484  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
1485 
1486  // Show recipient
1487  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1488  if ($this->page_largeur < 210) {
1489  $widthrecbox = 84; // To work with US executive format
1490  }
1491  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1492  $posy += $top_shift;
1493  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1494  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1495  $posx = $this->marge_gauche;
1496  }
1497 
1498  // Show recipient frame
1499  if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1500  $pdf->SetTextColor(0, 0, 0);
1501  $pdf->SetFont('', '', $default_font_size - 2);
1502  $pdf->SetXY($posx + 2, $posy - 5);
1503  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1504  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1505  }
1506 
1507  // Show recipient name
1508  $pdf->SetXY($posx + 2, $posy + 3);
1509  $pdf->SetFont('', 'B', $default_font_size);
1510  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1511 
1512  $posy = $pdf->getY();
1513 
1514  // Show recipient information
1515  $pdf->SetFont('', '', $default_font_size - 1);
1516  $pdf->SetXY($posx + 2, $posy);
1517  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1518  }
1519 
1520  $pdf->SetTextColor(0, 0, 0);
1521  return $top_shift;
1522  }
1523 
1524  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1525  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1535  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1536  {
1537  // phpcs:enable
1538  global $conf;
1539  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1540  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);
1541  }
1542 }
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:7838
pdf_getlinevatrate
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1780
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:6097
db
$conf db
API class for accounts.
Definition: inc.php:41
pdf_einstein\_pagefoot
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Definition: pdf_einstein.modules.php:1535
pdf_getlineqty
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1927
pdf_getlineupexcltax
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1842
pdf_writelinedesc
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:1345
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
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:2131
pdf_getFormat
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
pdf_getInstance
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:126
pdf_getPDFFont
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
Translate
Class to manage translations.
Definition: translate.class.php:30
pdf_getlineunit
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:2088
pdf_einstein\_tableau_tot
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
Definition: pdf_einstein.modules.php:907
name
$conf db name
Definition: repair.php:122
pdf_einstein\_tableau
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
Definition: pdf_einstein.modules.php:1176
pdf_einstein\write_file
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
Definition: pdf_einstein.modules.php:223
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
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:2514
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:7248
pdfBuildThirdpartyName
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:386
pdf_pagehead
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:711
pdf_einstein\_tableau_versements
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
Definition: pdf_einstein.modules.php:707
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:812
pdf_getHeightForLogo
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:313
CommonDocGenerator\printRect
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Definition: commondocgenerator.class.php:977
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:1309
pdf_einstein\__construct
__construct($db)
Constructor.
Definition: pdf_einstein.modules.php:134
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:427
pdf_einstein
Class to generate PDF orders with template Einstein.
Definition: pdf_einstein.modules.php:43
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:2711
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
pdf_einstein\_pagehead
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
Definition: pdf_einstein.modules.php:1279
User
Class to manage Dolibarr users.
Definition: user.class.php:44
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:6991
pdf_einstein\_tableau_info
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
Definition: pdf_einstein.modules.php:723
pdf_getPDFFontSize
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:288
pdf_getSubstitutionArray
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:737
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:5541
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
pdf_getlinetotalexcltax
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition: pdf.lib.php:2225
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
Account
Class to manage bank accounts.
Definition: account.class.php:38
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:7960
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:5492
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:989
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25