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