dolibarr  17.0.4
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(7, 0);
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 = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
153  $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
154  $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
155  $this->marge_basse = getDolGlobalInt('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 = 106;
183  $this->posxup = 122;
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 (getDolGlobalString('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 = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
363 
364  // Incoterm
365  $height_incoterms = 0;
366  if (isModEnabled('incoterm')) {
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 (!getDolGlobalInt('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 (isModEnabled("multicurrency") && $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 (!getDolGlobalInt('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 (!getDolGlobalInt('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  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
732 
733  // If France, show VAT mention if not applicable
734  if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
735  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
736  $pdf->SetXY($this->marge_gauche, $posy);
737  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
738 
739  $posy = $pdf->GetY() + 4;
740  }
741 
742  $posxval = 52;
743 
744  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
745 
746  // Show payments conditions
747  if ($object->cond_reglement_code || $object->cond_reglement) {
748  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
749  $pdf->SetXY($this->marge_gauche, $posy);
750  $titre = $outputlangs->transnoentities("PaymentConditions").':';
751  $pdf->MultiCell(43, 4, $titre, 0, 'L');
752 
753  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
754  $pdf->SetXY($posxval, $posy);
755  $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);
756  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
757  if ($object->deposit_percent > 0) {
758  $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
759  }
760  $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
761 
762  $posy = $pdf->GetY() + 3;
763  }
764 
765  // Check a payment mode is defined
766  /* Not used with orders
767  if (empty($object->mode_reglement_code)
768  && ! $conf->global->FACTURE_CHQ_NUMBER
769  && ! $conf->global->FACTURE_RIB_NUMBER)
770  {
771  $pdf->SetXY($this->marge_gauche, $posy);
772  $pdf->SetTextColor(200,0,0);
773  $pdf->SetFont('','B', $default_font_size - 2);
774  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
775  $pdf->SetTextColor(0,0,0);
776 
777  $posy=$pdf->GetY()+1;
778  }
779  */
780  /* TODO
781  else if (!empty($object->availability_code))
782  {
783  $pdf->SetXY($this->marge_gauche, $posy);
784  $pdf->SetTextColor(200,0,0);
785  $pdf->SetFont('','B', $default_font_size - 2);
786  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
787  $pdf->SetTextColor(0,0,0);
788 
789  $posy=$pdf->GetY()+1;
790  }*/
791 
792  // Show planed date of delivery
793  if (!empty($object->delivery_date)) {
794  $outputlangs->load("sendings");
795  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
796  $pdf->SetXY($this->marge_gauche, $posy);
797  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
798  $pdf->MultiCell(80, 4, $titre, 0, 'L');
799  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
800  $pdf->SetXY($posxval, $posy);
801  $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
802  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
803 
804  $posy = $pdf->GetY() + 1;
805  } elseif ($object->availability_code || $object->availability) {
806  // Show availability conditions
807  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
808  $pdf->SetXY($this->marge_gauche, $posy);
809  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
810  $pdf->MultiCell(80, 4, $titre, 0, 'L');
811  $pdf->SetTextColor(0, 0, 0);
812  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
813  $pdf->SetXY($posxval, $posy);
814  $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 : '');
815  $lib_availability = str_replace('\n', "\n", $lib_availability);
816  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
817 
818  $posy = $pdf->GetY() + 1;
819  }
820 
821  // Show payment mode
822  if ($object->mode_reglement_code
823  && $object->mode_reglement_code != 'CHQ'
824  && $object->mode_reglement_code != 'VIR') {
825  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
826  $pdf->SetXY($this->marge_gauche, $posy);
827  $titre = $outputlangs->transnoentities("PaymentMode").':';
828  $pdf->MultiCell(80, 5, $titre, 0, 'L');
829 
830  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
831  $pdf->SetXY($posxval, $posy);
832  $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);
833  $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
834 
835  $posy = $pdf->GetY() + 2;
836  }
837 
838  // Show payment mode CHQ
839  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
840  // Si mode reglement non force ou si force a CHQ
841  if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
842  if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
843  $account = new Account($this->db);
844  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
845 
846  $pdf->SetXY($this->marge_gauche, $posy);
847  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
848  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
849  $posy = $pdf->GetY() + 1;
850 
851  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
852  $pdf->SetXY($this->marge_gauche, $posy);
853  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
854  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
855  $posy = $pdf->GetY() + 2;
856  }
857  }
858  if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
859  $pdf->SetXY($this->marge_gauche, $posy);
860  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
861  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
862  $posy = $pdf->GetY() + 1;
863 
864  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
865  $pdf->SetXY($this->marge_gauche, $posy);
866  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
867  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
868  $posy = $pdf->GetY() + 2;
869  }
870  }
871  }
872  }
873 
874  // If payment mode not forced or forced to VIR, show payment with BAN
875  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
876  if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
877  $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
878  if ($object->fk_bank > 0) {
879  $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
880  }
881  $account = new Account($this->db);
882  $account->fetch($bankid);
883 
884  $curx = $this->marge_gauche;
885  $cury = $posy;
886 
887  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
888 
889  $posy += 2;
890  }
891  }
892 
893  return $posy;
894  }
895 
896  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
897  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
909  protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
910  {
911  // phpcs:enable
912  global $conf, $mysoc, $hookmanager;
913 
914  $default_font_size = pdf_getPDFFontSize($outputlangs);
915 
916  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
917  $outputlangsbis = new Translate('', $conf);
918  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
919  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
920  $default_font_size--;
921  }
922 
923  $tab2_top = $posy;
924  $tab2_hl = 4;
925  $pdf->SetFont('', '', $default_font_size - 1);
926 
927  // Total table
928  $col1x = 120;
929  $col2x = 170;
930  if ($this->page_largeur < 210) { // To work with US executive format
931  $col2x -= 20;
932  }
933  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
934 
935  $useborder = 0;
936  $index = 0;
937 
938  // Total HT
939  $pdf->SetFillColor(255, 255, 255);
940  $pdf->SetXY($col1x, $tab2_top + 0);
941  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
942 
943  $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
944  $pdf->SetXY($col2x, $tab2_top + 0);
945  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
946 
947  // Show VAT by rates and total
948  $pdf->SetFillColor(248, 248, 248);
949 
950  $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
951 
952  $this->atleastoneratenotnull = 0;
953  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
954  $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
955  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
956  // Nothing to do
957  } else {
958  //Local tax 1 before VAT
959  //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
960  //{
961  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
962  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
963  continue;
964  }
965  foreach ($localtax_rate as $tvakey => $tvaval) {
966  if ($tvakey != 0) { // On affiche pas taux 0
967  //$this->atleastoneratenotnull++;
968 
969  $index++;
970  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
971 
972  $tvacompl = '';
973  if (preg_match('/\*/', $tvakey)) {
974  $tvakey = str_replace('*', '', $tvakey);
975  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
976  }
977  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
978  $totalvat .= ' ';
979  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
980  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
981 
982  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
983  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
984  }
985  }
986  }
987  //}
988  //Local tax 2 before VAT
989  //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
990  //{
991  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
992  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
993  continue;
994  }
995  foreach ($localtax_rate as $tvakey => $tvaval) {
996  if ($tvakey != 0) { // On affiche pas taux 0
997  //$this->atleastoneratenotnull++;
998 
999  $index++;
1000  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1001 
1002  $tvacompl = '';
1003  if (preg_match('/\*/', $tvakey)) {
1004  $tvakey = str_replace('*', '', $tvakey);
1005  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1006  }
1007  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1008  $totalvat .= ' ';
1009  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1010  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1011 
1012  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1013  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1014  }
1015  }
1016  }
1017  //}
1018 
1019  // VAT
1020  foreach ($this->tva_array as $tvakey => $tvaval) {
1021  if ($tvakey != 0) { // On affiche pas taux 0
1022  $this->atleastoneratenotnull++;
1023 
1024  $index++;
1025  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1026 
1027  $tvacompl = '';
1028  if (preg_match('/\*/', $tvakey)) {
1029  $tvakey = str_replace('*', '', $tvakey);
1030  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1031  }
1032  $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1033  $totalvat .= ' ';
1034  if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
1035  $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
1036  } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
1037  $totalvat .= $tvaval['vatcode'].$tvacompl;
1038  } else {
1039  $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
1040  }
1041  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1042 
1043  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1044  $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
1045  }
1046  }
1047 
1048  //Local tax 1 after VAT
1049  //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1050  //{
1051  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1052  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1053  continue;
1054  }
1055 
1056  foreach ($localtax_rate as $tvakey => $tvaval) {
1057  if ($tvakey != 0) { // On affiche pas taux 0
1058  //$this->atleastoneratenotnull++;
1059 
1060  $index++;
1061  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1062 
1063  $tvacompl = '';
1064  if (preg_match('/\*/', $tvakey)) {
1065  $tvakey = str_replace('*', '', $tvakey);
1066  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1067  }
1068  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1069  $totalvat .= ' ';
1070 
1071  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1072  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1073  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1075  }
1076  }
1077  }
1078  //}
1079  //Local tax 2 after VAT
1080  //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1081  //{
1082  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1083  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1084  continue;
1085  }
1086 
1087  foreach ($localtax_rate as $tvakey => $tvaval) {
1088  // retrieve global local tax
1089  if ($tvakey != 0) { // On affiche pas taux 0
1090  //$this->atleastoneratenotnull++;
1091 
1092  $index++;
1093  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094 
1095  $tvacompl = '';
1096  if (preg_match('/\*/', $tvakey)) {
1097  $tvakey = str_replace('*', '', $tvakey);
1098  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1099  }
1100  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1101  $totalvat .= ' ';
1102 
1103  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1104  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1105 
1106  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1107  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1108  }
1109  }
1110  }
1111  //}
1112 
1113  // Total TTC
1114  $index++;
1115  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1116  $pdf->SetTextColor(0, 0, 60);
1117  $pdf->SetFillColor(224, 224, 224);
1118  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1);
1119 
1120  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1121  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1122  }
1123  }
1124 
1125  $pdf->SetTextColor(0, 0, 0);
1126 
1127  $creditnoteamount = 0;
1128  $depositsamount = 0;
1129  //$creditnoteamount=$object->getSumCreditNotesUsed();
1130  //$depositsamount=$object->getSumDepositsUsed();
1131  //print "x".$creditnoteamount."-".$depositsamount;exit;
1132  $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1133  if (!empty($object->paye)) {
1134  $resteapayer = 0;
1135  }
1136 
1137  if ($deja_regle > 0) {
1138  // Already paid + Deposits
1139  $index++;
1140 
1141  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1142  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1143  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1144  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1145 
1146  $index++;
1147  $pdf->SetTextColor(0, 0, 60);
1148  $pdf->SetFillColor(224, 224, 224);
1149  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1150  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
1151 
1152  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1153  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1154 
1155  $pdf->SetFont('', '', $default_font_size - 1);
1156  $pdf->SetTextColor(0, 0, 0);
1157  }
1158 
1159  $index++;
1160  return ($tab2_top + ($tab2_hl * $index));
1161  }
1162 
1163  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1178  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1179  {
1180  global $conf;
1181 
1182  // Force to disable hidetop and hidebottom
1183  $hidebottom = 0;
1184  if ($hidetop) {
1185  $hidetop = -1;
1186  }
1187 
1188  $currency = !empty($currency) ? $currency : $conf->currency;
1189  $default_font_size = pdf_getPDFFontSize($outputlangs);
1190 
1191  // Amount in (at tab_top - 1)
1192  $pdf->SetTextColor(0, 0, 0);
1193  $pdf->SetFont('', '', $default_font_size - 2);
1194 
1195  if (empty($hidetop)) {
1196  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1197  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1198  $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1199  }
1200 
1201  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1202  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1203 
1204  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1205  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1206  $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));
1207  }
1208  }
1209 
1210  $pdf->SetDrawColor(128, 128, 128);
1211  $pdf->SetFont('', '', $default_font_size - 1);
1212 
1213  // Output Rect
1214  $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
1215 
1216  if (empty($hidetop)) {
1217  $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
1218 
1219  $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1220  $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1221  }
1222 
1223  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1224  $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1225  if (empty($hidetop)) {
1226  $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1227  $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1228  }
1229  }
1230 
1231  $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1232  if (empty($hidetop)) {
1233  $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1234  $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1235  }
1236 
1237  $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1238  if (empty($hidetop)) {
1239  $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1240  $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1241  }
1242 
1243  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1244  $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245  if (empty($hidetop)) {
1246  $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1247  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
1248  }
1249  }
1250 
1251  $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1252  if (empty($hidetop)) {
1253  if ($this->atleastonediscount) {
1254  $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1255  $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1256  }
1257  }
1258 
1259  if ($this->atleastonediscount) {
1260  $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1261  }
1262  if (empty($hidetop)) {
1263  $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1264  $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
1265  }
1266  }
1267 
1268  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1269  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1281  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
1282  {
1283  // phpcs:enable
1284  global $conf, $langs, $hookmanager;
1285 
1286  $ltrdirection = 'L';
1287  if ($outputlangs->trans("DIRECTION") == 'rtl') {
1288  $ltrdirection = 'R';
1289  }
1290 
1291  // Load traductions files required by page
1292  $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1293 
1294  $default_font_size = pdf_getPDFFontSize($outputlangs);
1295 
1296  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1297 
1298  $pdf->SetTextColor(0, 0, 60);
1299  $pdf->SetFont('', 'B', $default_font_size + 3);
1300 
1301  $w = 100;
1302 
1303  $posy = $this->marge_haute;
1304  $posx = $this->page_largeur - $this->marge_droite - $w;
1305 
1306  $pdf->SetXY($this->marge_gauche, $posy);
1307 
1308  // Logo
1309  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1310  if ($this->emetteur->logo) {
1311  $logodir = $conf->mycompany->dir_output;
1312  if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1313  $logodir = $conf->mycompany->multidir_output[$object->entity];
1314  }
1315  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1316  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1317  } else {
1318  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1319  }
1320  if (is_readable($logo)) {
1321  $height = pdf_getHeightForLogo($logo);
1322  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1323  } else {
1324  $pdf->SetTextColor(200, 0, 0);
1325  $pdf->SetFont('', 'B', $default_font_size - 2);
1326  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1327  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1328  }
1329  } else {
1330  $text = $this->emetteur->name;
1331  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1332  }
1333  }
1334 
1335  $pdf->SetFont('', 'B', $default_font_size + 3);
1336  $pdf->SetXY($posx, $posy);
1337  $pdf->SetTextColor(0, 0, 60);
1338  $title = $outputlangs->transnoentities($titlekey);
1339  $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1340  if ($object->statut == $object::STATUS_DRAFT) {
1341  $pdf->SetTextColor(128, 0, 0);
1342  $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1343  }
1344  $pdf->MultiCell($w, 3, $title, '', 'R');
1345 
1346  $pdf->SetFont('', 'B', $default_font_size);
1347 
1348  /*
1349  $posy += 5;
1350  $pdf->SetXY($posx, $posy);
1351  $pdf->SetTextColor(0, 0, 60);
1352  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1353  */
1354 
1355  $posy += 3;
1356  $pdf->SetFont('', '', $default_font_size - 1);
1357 
1358  if ($object->ref_client) {
1359  $posy += 5;
1360  $pdf->SetXY($posx, $posy);
1361  $pdf->SetTextColor(0, 0, 60);
1362  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1363  }
1364 
1365  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1366  $object->fetch_projet();
1367  if (!empty($object->project->ref)) {
1368  $posy += 3;
1369  $pdf->SetXY($posx, $posy);
1370  $pdf->SetTextColor(0, 0, 60);
1371  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1372  }
1373  }
1374 
1375  if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1376  $object->fetch_projet();
1377  if (!empty($object->project->ref)) {
1378  $outputlangs->load("projects");
1379  $posy += 3;
1380  $pdf->SetXY($posx, $posy);
1381  $pdf->SetTextColor(0, 0, 60);
1382  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1383  }
1384  }
1385 
1386  $posy += 4;
1387  $pdf->SetXY($posx, $posy);
1388  $pdf->SetTextColor(0, 0, 60);
1389  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1390 
1391  if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1392  $posy += 4;
1393  $pdf->SetXY($posx, $posy);
1394  $pdf->SetTextColor(0, 0, 60);
1395  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1396  }
1397 
1398  // Get contact
1399  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1400  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1401  if (count($arrayidcontact) > 0) {
1402  $usertmp = new User($this->db);
1403  $usertmp->fetch($arrayidcontact[0]);
1404  $posy += 4;
1405  $pdf->SetXY($posx, $posy);
1406  $pdf->SetTextColor(0, 0, 60);
1407  $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1408  }
1409  }
1410 
1411  $posy += 2;
1412 
1413  $top_shift = 0;
1414  // Show list of linked objects
1415  $current_y = $pdf->getY();
1416  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1417  if ($current_y < $pdf->getY()) {
1418  $top_shift = $pdf->getY() - $current_y;
1419  }
1420 
1421  if ($showaddress) {
1422  // Sender properties
1423  $carac_emetteur = '';
1424  // Add internal contact of proposal if defined
1425  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1426  if (count($arrayidcontact) > 0) {
1427  $object->fetch_user($arrayidcontact[0]);
1428  $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1429  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1430  }
1431 
1432  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1433 
1434  // Show sender
1435  $posy = 42 + $top_shift;
1436  $posx = $this->marge_gauche;
1437  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1438  $posx = $this->page_largeur - $this->marge_droite - 80;
1439  }
1440  $hautcadre = 40;
1441 
1442  // Show sender frame
1443  if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1444  $pdf->SetTextColor(0, 0, 0);
1445  $pdf->SetFont('', '', $default_font_size - 2);
1446  $pdf->SetXY($posx, $posy - 5);
1447  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1448  $pdf->SetXY($posx, $posy);
1449  $pdf->SetFillColor(230, 230, 230);
1450  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1451  $pdf->SetTextColor(0, 0, 60);
1452  }
1453 
1454  // Show sender name
1455  if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1456  $pdf->SetXY($posx + 2, $posy + 3);
1457  $pdf->SetFont('', 'B', $default_font_size);
1458  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1459  $posy = $pdf->getY();
1460  }
1461 
1462  // Show sender information
1463  $pdf->SetXY($posx + 2, $posy);
1464  $pdf->SetFont('', '', $default_font_size - 1);
1465  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1466 
1467 
1468  // If CUSTOMER contact defined, we use it
1469  $usecontact = false;
1470  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1471  if (count($arrayidcontact) > 0) {
1472  $usecontact = true;
1473  $result = $object->fetch_contact($arrayidcontact[0]);
1474  }
1475 
1476  // Recipient name
1477  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)))) {
1478  $thirdparty = $object->contact;
1479  } else {
1480  $thirdparty = $object->thirdparty;
1481  }
1482 
1483  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1484 
1485  $mode = 'target';
1486  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
1487 
1488  // Show recipient
1489  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1490  if ($this->page_largeur < 210) {
1491  $widthrecbox = 84; // To work with US executive format
1492  }
1493  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1494  $posy += $top_shift;
1495  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1496  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1497  $posx = $this->marge_gauche;
1498  }
1499 
1500  // Show recipient frame
1501  if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1502  $pdf->SetTextColor(0, 0, 0);
1503  $pdf->SetFont('', '', $default_font_size - 2);
1504  $pdf->SetXY($posx + 2, $posy - 5);
1505  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1506  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1507  }
1508 
1509  // Show recipient name
1510  $pdf->SetXY($posx + 2, $posy + 3);
1511  $pdf->SetFont('', 'B', $default_font_size);
1512  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1513 
1514  $posy = $pdf->getY();
1515 
1516  // Show recipient information
1517  $pdf->SetFont('', '', $default_font_size - 1);
1518  $pdf->SetXY($posx + 2, $posy);
1519  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1520  }
1521 
1522  $pdf->SetTextColor(0, 0, 0);
1523  return $top_shift;
1524  }
1525 
1526  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1527  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1537  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1538  {
1539  // phpcs:enable
1540  $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1541  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);
1542  }
1543 }
Class to manage bank accounts.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage hooks.
Parent class for orders models.
Class to manage translations.
Class to manage Dolibarr users.
Definition: user.class.php:47
Class to generate PDF orders with template Einstein.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
__construct($db)
Constructor.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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...
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
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...
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition: pdf.lib.php:2269
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:288
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
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:1359
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:313
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:1001
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1886
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1824
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:2132
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:749
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:723
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1323
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
Definition: pdf.lib.php:824
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
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:434
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition: pdf.lib.php:2175
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1971
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:126
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:386
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:122
$conf db
API class for accounts.
Definition: inc.php:41