dolibarr  16.0.1
pdf_aurore.modules.php
1 <?php
2 /* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5  * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  * or see https://www.gnu.org/
22  */
23 
29 require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
30 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34 
35 
40 {
44  public $db;
45 
49  public $name;
50 
54  public $description;
55 
59  public $update_main_doc_field;
60 
64  public $type;
65 
70  public $phpmin = array(5, 6);
71 
76  public $version = 'dolibarr';
77 
81  public $page_largeur;
82 
86  public $page_hauteur;
87 
91  public $format;
92 
96  public $marge_gauche;
97 
101  public $marge_droite;
102 
106  public $marge_haute;
107 
111  public $marge_basse;
112 
117  public $emetteur;
118 
119 
125  public function __construct($db)
126  {
127  global $conf, $langs, $mysoc;
128 
129  // Translations
130  $langs->loadLangs(array("main", "bills"));
131 
132  $this->db = $db;
133  $this->name = "aurore";
134  $this->description = $langs->trans('DocModelAuroreDescription');
135  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
136 
137  // Page size for A4 format
138  $this->type = 'pdf';
139  $formatarray = pdf_getFormat();
140  $this->page_largeur = $formatarray['width'];
141  $this->page_hauteur = $formatarray['height'];
142  $this->format = array($this->page_largeur, $this->page_hauteur);
143  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
144  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
145  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
146  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
147 
148  $this->option_logo = 1; // Display logo
149  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
150  $this->option_modereg = 1; // Display payment mode
151  $this->option_condreg = 1; // Display payment terms
152  $this->option_multilang = 1; // Available in several languages
153  $this->option_escompte = 1; // Displays if there has been a discount
154  $this->option_credit_note = 1; // Support credit notes
155  $this->option_freetext = 1; // Support add of a personalised text
156  $this->option_draft_watermark = 1; //Support add of a watermark on drafts
157  $this->watermark = '';
158 
159  // Get source company
160  $this->emetteur = $mysoc;
161  if (empty($this->emetteur->country_code)) {
162  $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
163  }
164 
165  // Define position of columns
166  $this->posxdesc = $this->marge_gauche + 1;
167  $this->posxdiscount = 162;
168  $this->postotalht = 174;
169 
170  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
171  $this->posxtva = 101;
172  $this->posxup = 118;
173  $this->posxqty = 135;
174  $this->posxunit = 151;
175  } else {
176  $this->posxtva = 102;
177  $this->posxup = 126;
178  $this->posxqty = 145;
179  $this->posxunit = 162;
180  }
181 
182  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
183  $this->posxup = $this->posxtva;
184  }
185  $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
186  if ($this->page_largeur < 210) { // To work with US executive format
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->tva_array = array();
198  $this->localtax1 = array();
199  $this->localtax2 = array();
200  $this->atleastoneratenotnull = 0;
201  $this->atleastonediscount = 0;
202  }
203 
204  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
216  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
217  {
218  // phpcs:enable
219  global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
220 
221  if (!is_object($outputlangs)) {
222  $outputlangs = $langs;
223  }
224  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
225  if (!empty($conf->global->MAIN_USE_FPDF)) {
226  $outputlangs->charset_output = 'ISO-8859-1';
227  }
228 
229  // Load traductions files required by page
230  $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
231 
232  // Show Draft Watermark
233  if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK))) {
234  $this->watermark = $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK;
235  }
236 
237  $nblines = count($object->lines);
238 
239  // Loop on each lines to detect if there is at least one image to show
240  $realpatharray = array();
241  if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) {
242  for ($i = 0; $i < $nblines; $i++) {
243  if (empty($object->lines[$i]->fk_product)) {
244  continue;
245  }
246 
247  $objphoto = new Product($this->db);
248  $objphoto->fetch($object->lines[$i]->fk_product);
249 
250  if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
251  $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
252  $dir = $conf->product->dir_output.'/'.$pdir;
253  } else {
254  $pdir = get_exdir(0, 0, 0, 0, $objphoto, 'product');
255  $dir = $conf->product->dir_output.'/'.$pdir;
256  }
257 
258  $realpath = '';
259  foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
260  if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
261  if ($obj['photo_vignette']) {
262  $filename = $obj['photo_vignette'];
263  } else {
264  $filename = $obj['photo'];
265  }
266  } else {
267  $filename = $obj['photo'];
268  }
269  $realpath = $dir.$filename;
270  break;
271  }
272 
273  if ($realpath) {
274  $realpatharray[$i] = $realpath;
275  }
276  }
277  }
278  if (count($realpatharray) == 0) {
279  $this->posxpicture = $this->posxtva;
280  }
281 
282  if ($conf->supplier_proposal->dir_output) {
283  $object->fetch_thirdparty();
284 
285  // $deja_regle = 0;
286 
287  // Definition of $dir and $file
288  if ($object->specimen) {
289  $dir = $conf->supplier_proposal->dir_output;
290  $file = $dir."/SPECIMEN.pdf";
291  } else {
292  $objectref = dol_sanitizeFileName($object->ref);
293  $dir = $conf->supplier_proposal->dir_output."/".$objectref;
294  $file = $dir."/".$objectref.".pdf";
295  }
296 
297  if (!file_exists($dir)) {
298  if (dol_mkdir($dir) < 0) {
299  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
300  return 0;
301  }
302  }
303 
304  if (file_exists($dir)) {
305  // Add pdfgeneration hook
306  if (!is_object($hookmanager)) {
307  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
308  $hookmanager = new HookManager($this->db);
309  }
310  $hookmanager->initHooks(array('pdfgeneration'));
311  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
312  global $action;
313  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
314 
315  // Create pdf instance
316  $pdf = pdf_getInstance($this->format);
317  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
318  $heightforinfotot = 50; // Height reserved to output the info and total part
319  $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
320  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
321  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
322  $heightforfooter += 6;
323  }
324  $pdf->SetAutoPageBreak(1, 0);
325 
326  if (class_exists('TCPDF')) {
327  $pdf->setPrintHeader(false);
328  $pdf->setPrintFooter(false);
329  }
330  $pdf->SetFont(pdf_getPDFFont($outputlangs));
331  // Set path to the background PDF File
332  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
333  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
334  $tplidx = $pdf->importPage(1);
335  }
336 
337  $pdf->Open();
338  $pagenb = 0;
339  $pdf->SetDrawColor(128, 128, 128);
340 
341  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
342  $pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
343  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
344  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
345  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
346  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
347  $pdf->SetCompression(false);
348  }
349 
350  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
351 
352  // Positionne $this->atleastonediscount si on a au moins une remise
353  for ($i = 0; $i < $nblines; $i++) {
354  if ($object->lines[$i]->remise_percent) {
355  $this->atleastonediscount++;
356  }
357  }
358  if (empty($this->atleastonediscount)) {
359  $delta = ($this->postotalht - $this->posxdiscount);
360  $this->posxpicture += $delta;
361  $this->posxtva += $delta;
362  $this->posxup += $delta;
363  $this->posxqty += $delta;
364  $this->posxunit += $delta;
365  $this->posxdiscount += $delta;
366  // post of fields after are not modified, stay at same position
367  }
368 
369  // New page
370  $pdf->AddPage();
371  if (!empty($tplidx)) {
372  $pdf->useTemplate($tplidx);
373  }
374  $pagenb++;
375  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
376  $pdf->SetFont('', '', $default_font_size - 1);
377  $pdf->MultiCell(0, 3, ''); // Set interline to 3
378  $pdf->SetTextColor(0, 0, 0);
379 
380  $tab_top = 90 + $top_shift;
381  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
382 
383  // Affiche notes
384  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
385  if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
386  // Get first sale rep
387  if (is_object($object->thirdparty)) {
388  $salereparray = $object->thirdparty->getSalesRepresentatives($user);
389  $salerepobj = new User($this->db);
390  $salerepobj->fetch($salereparray[0]['id']);
391  if (!empty($salerepobj->signature)) {
392  $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
393  }
394  }
395  }
396  if ($notetoshow) {
397  $tab_top -= 2;
398 
399  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
400  complete_substitutions_array($substitutionarray, $outputlangs, $object);
401  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
402  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
403 
404  $pdf->SetFont('', '', $default_font_size - 1);
405  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
406  $nexY = $pdf->GetY();
407  $height_note = $nexY - $tab_top;
408 
409  // Rect takes a length in 3rd parameter
410  $pdf->SetDrawColor(192, 192, 192);
411  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
412 
413  $tab_top = $nexY + 6;
414  }
415 
416  $iniY = $tab_top + 7;
417  $curY = $tab_top + 7;
418  $nexY = $tab_top + 7;
419 
420  // Loop on each lines
421  for ($i = 0; $i < $nblines; $i++) {
422  $curY = $nexY;
423  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
424  $pdf->SetTextColor(0, 0, 0);
425 
426  // Define size of image if we need it
427  $imglinesize = array();
428  if (!empty($realpatharray[$i])) {
429  $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
430  }
431 
432  $pdf->setTopMargin($tab_top_newpage);
433  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
434  $pageposbefore = $pdf->getPage();
435 
436  $showpricebeforepagebreak = 1;
437  $posYAfterImage = 0;
438  $posYAfterDescription = 0;
439 
440  // We start with Photo of product line
441  if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
442  $pdf->AddPage('', '', true);
443  if (!empty($tplidx)) {
444  $pdf->useTemplate($tplidx);
445  }
446  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
447  $this->_pagehead($pdf, $object, 0, $outputlangs);
448  }
449  $pdf->setPage($pageposbefore + 1);
450 
451  $curY = $tab_top_newpage;
452 
453  // Allows data in the first page if description is long enough to break in multiples pages
454  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
455  $showpricebeforepagebreak = 1;
456  } else {
457  $showpricebeforepagebreak = 0;
458  }
459  }
460 
461  if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) {
462  $curX = $this->posxpicture - 1;
463  $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
464  // $pdf->Image does not increase value return by getY, so we save it manually
465  $posYAfterImage = $curY + $imglinesize['height'];
466  }
467 
468  // Description of product line
469  $curX = $this->posxdesc - 1;
470 
471  $pdf->startTransaction();
472  if ($posYAfterImage > 0) {
473  $descWidth = $this->posxpicture - $curX;
474  } else {
475  $descWidth = $this->posxtva - $curX;
476  }
477  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
478 
479  $pageposafter = $pdf->getPage();
480  if ($pageposafter > $pageposbefore) { // There is a pagebreak
481  $pdf->rollbackTransaction(true);
482  $pageposafter = $pageposbefore;
483  //print $pageposafter.'-'.$pageposbefore;exit;
484  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
485  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
486 
487  $pageposafter = $pdf->getPage();
488  $posyafter = $pdf->GetY();
489  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
490  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
491  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
492  $pdf->AddPage('', '', true);
493  if (!empty($tplidx)) {
494  $pdf->useTemplate($tplidx);
495  }
496  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
497  $this->_pagehead($pdf, $object, 0, $outputlangs);
498  }
499  $pdf->setPage($pageposafter + 1);
500  }
501  } else {
502  // We found a page break
503  // Allows data in the first page if description is long enough to break in multiples pages
504  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
505  $showpricebeforepagebreak = 1;
506  } else {
507  $showpricebeforepagebreak = 0;
508  }
509  }
510  } else // No pagebreak
511  {
512  $pdf->commitTransaction();
513  }
514  $posYAfterDescription = $pdf->GetY();
515 
516  $nexY = $pdf->GetY();
517  $pageposafter = $pdf->getPage();
518 
519  $pdf->setPage($pageposbefore);
520  $pdf->setTopMargin($this->marge_haute);
521  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
522 
523  // We suppose that a too long description or photo were moved completely on next page
524  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
525  $pdf->setPage($pageposafter);
526  $curY = $tab_top_newpage;
527  }
528 
529  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
530 
531  // VAT Rate
532  /*
533  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
534  {
535  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
536  $pdf->SetXY($this->posxtva, $curY);
537  $pdf->MultiCell($this->posxup-$this->posxtva-3, 3, $vat_rate, 0, 'R');
538  }
539 
540  // Unit price before discount
541  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
542  $pdf->SetXY($this->posxup, $curY);
543  if ($up_excl_tax > 0)
544  $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
545  */
546 
547  // Quantity
548  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
549  $pdf->SetXY($this->posxqty, $curY);
550  $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
551 
552  // Unit
553  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
554  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
555  $pdf->SetXY($this->posxunit, $curY);
556  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
557  }
558 
559  // Discount on line
560  /*
561  if ($object->lines[$i]->remise_percent)
562  {
563  $pdf->SetXY($this->posxdiscount-2, $curY);
564  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
565  $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
566  }
567 
568  // Total HT line
569  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
570  $pdf->SetXY($this->postotalht, $curY);
571  if ($total_excl_tax > 0)
572  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
573  */
574 
575  // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
576  if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) {
577  $tvaligne = $object->lines[$i]->multicurrency_total_tva;
578  } else {
579  $tvaligne = $object->lines[$i]->total_tva;
580  }
581 
582  $localtax1ligne = $object->lines[$i]->total_localtax1;
583  $localtax2ligne = $object->lines[$i]->total_localtax2;
584  $localtax1_rate = $object->lines[$i]->localtax1_tx;
585  $localtax2_rate = $object->lines[$i]->localtax2_tx;
586  $localtax1_type = $object->lines[$i]->localtax1_type;
587  $localtax2_type = $object->lines[$i]->localtax2_type;
588 
589  if ($object->remise_percent) {
590  $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
591  }
592  if ($object->remise_percent) {
593  $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
594  }
595  if ($object->remise_percent) {
596  $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
597  }
598 
599  $vatrate = (string) $object->lines[$i]->tva_tx;
600 
601  // Retrieve type from database for backward compatibility with old records
602  if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
603  && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
604  $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
605  $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
606  $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
607  }
608 
609  // retrieve global local tax
610  if ($localtax1_type && $localtax1ligne != 0) {
611  $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
612  }
613  if ($localtax2_type && $localtax2ligne != 0) {
614  $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
615  }
616 
617  if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
618  $vatrate .= '*';
619  }
620 
621  // Fill $this->tva and $this->tva_array
622  if (!isset($this->tva[$vatrate])) {
623  $this->tva[$vatrate] = 0;
624  }
625  $this->tva[$vatrate] += $tvaligne;
626  $vatcode = $object->lines[$i]->vat_src_code;
627  if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
628  $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
629  }
630  $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
631 
632  if ($posYAfterImage > $posYAfterDescription) {
633  $nexY = $posYAfterImage;
634  }
635 
636  // Add line
637  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
638  $pdf->setPage($pageposafter);
639  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
640  //$pdf->SetDrawColor(190,190,200);
641  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
642  $pdf->SetLineStyle(array('dash'=>0));
643  }
644 
645  $nexY += 2; // Add space between lines
646 
647  // Detect if some page were added automatically and output _tableau for past pages
648  while ($pagenb < $pageposafter) {
649  $pdf->setPage($pagenb);
650  if ($pagenb == 1) {
651  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
652  } else {
653  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
654  }
655  $this->_pagefoot($pdf, $object, $outputlangs, 1);
656  $pagenb++;
657  $pdf->setPage($pagenb);
658  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
659  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
660  $this->_pagehead($pdf, $object, 0, $outputlangs);
661  }
662  if (!empty($tplidx)) {
663  $pdf->useTemplate($tplidx);
664  }
665  }
666  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
667  if ($pagenb == 1) {
668  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
669  } else {
670  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
671  }
672  $this->_pagefoot($pdf, $object, $outputlangs, 1);
673  // New page
674  $pdf->AddPage();
675  if (!empty($tplidx)) {
676  $pdf->useTemplate($tplidx);
677  }
678  $pagenb++;
679  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
680  $this->_pagehead($pdf, $object, 0, $outputlangs);
681  }
682  }
683  }
684 
685  // Show square
686  if ($pagenb == 1) {
687  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
688  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
689  } else {
690  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
691  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
692  }
693 
694  // Affiche zone infos
695  $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
696 
697  // Affiche zone totaux
698  //$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
699 
700  // Affiche zone versements
701  /*
702  if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
703  {
704  $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
705  }
706  */
707 
708  // Pied de page
709  $this->_pagefoot($pdf, $object, $outputlangs);
710  if (method_exists($pdf, 'AliasNbPages')) {
711  $pdf->AliasNbPages();
712  }
713 
714  $pdf->Close();
715 
716  $pdf->Output($file, 'F');
717 
718  //Add pdfgeneration hook
719  $hookmanager->initHooks(array('pdfgeneration'));
720  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
721  global $action;
722  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
723  if ($reshook < 0) {
724  $this->error = $hookmanager->error;
725  $this->errors = $hookmanager->errors;
726  }
727 
728  if (!empty($conf->global->MAIN_UMASK)) {
729  @chmod($file, octdec($conf->global->MAIN_UMASK));
730  }
731 
732  $this->result = array('fullpath'=>$file);
733 
734  return 1; // No error
735  } else {
736  $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
737  return 0;
738  }
739  } else {
740  $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR");
741  return 0;
742  }
743  }
744 
745  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
746  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
756  protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
757  {
758  // phpcs:enable
759  }
760 
761  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
762  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
772  protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
773  {
774  // phpcs:enable
775  global $conf;
776  $default_font_size = pdf_getPDFFontSize($outputlangs);
777 
778  $pdf->SetFont('', '', $default_font_size - 1);
779 
780  $posxval = 52;
781 
782  // Show shipping date
783  if (!empty($object->delivery_date)) {
784  $outputlangs->load("sendings");
785  $pdf->SetFont('', 'B', $default_font_size - 2);
786  $pdf->SetXY($this->marge_gauche, $posy);
787  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
788  $pdf->MultiCell(80, 4, $titre, 0, 'L');
789  $pdf->SetFont('', '', $default_font_size - 2);
790  $pdf->SetXY($posxval, $posy);
791  $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
792  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
793 
794  $posy = $pdf->GetY() + 1;
795  } else {
796  $outputlangs->load("sendings");
797  $pdf->SetFont('', 'B', $default_font_size - 2);
798  $pdf->SetXY($this->marge_gauche, $posy);
799  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
800  $pdf->MultiCell(80, 4, $titre, 0, 'L');
801  $pdf->SetFont('', '', $default_font_size - 2);
802  $pdf->SetXY($posxval, $posy);
803  //$dlp=dol_print_date($object->delivery_date,"daytext",false,$outputlangs,true);
804  $pdf->MultiCell(80, 4, '', 0, 'L');
805 
806  $posy = $pdf->GetY() + 1;
807  }
808  /* PHFAVRE
809  elseif ($object->availability_code || $object->availability) // Show availability conditions
810  {
811  $pdf->SetFont('','B', $default_font_size - 2);
812  $pdf->SetXY($this->marge_gauche, $posy);
813  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
814  $pdf->MultiCell(80, 4, $titre, 0, 'L');
815  $pdf->SetTextColor(0,0,0);
816  $pdf->SetFont('','', $default_font_size - 2);
817  $pdf->SetXY($posxval, $posy);
818  $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
819  $lib_availability=str_replace('\n',"\n",$lib_availability);
820  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
821 
822  $posy=$pdf->GetY()+1;
823  }*/
824 
825  // Show payments conditions
826  if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) {
827  $pdf->SetFont('', 'B', $default_font_size - 2);
828  $pdf->SetXY($this->marge_gauche, $posy);
829  $titre = $outputlangs->transnoentities("PaymentConditions").':';
830  $pdf->MultiCell(80, 4, $titre, 0, 'L');
831 
832  $pdf->SetFont('', '', $default_font_size - 2);
833  $pdf->SetXY($posxval, $posy);
834  $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);
835  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
836  $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
837 
838  $posy = $pdf->GetY() + 3;
839  }
840 
841  if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE)) {
842  // Show payment mode
843  if ($object->mode_reglement_code
844  && $object->mode_reglement_code != 'CHQ'
845  && $object->mode_reglement_code != 'VIR') {
846  $pdf->SetFont('', 'B', $default_font_size - 2);
847  $pdf->SetXY($this->marge_gauche, $posy - 2);
848  $titre = $outputlangs->transnoentities("PaymentMode").':';
849  $pdf->MultiCell(80, 5, $titre, 0, 'L');
850  $pdf->SetFont('', '', $default_font_size - 2);
851  $pdf->SetXY($posxval, $posy - 2);
852  $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);
853  $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
854 
855  $posy = $pdf->GetY() + 2;
856  }
857 
858  // Show payment mode CHQ
859  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
860  // Si mode reglement non force ou si force a CHQ
861  if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
862  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
863 
864  if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
865  $account = new Account($this->db);
866  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
867 
868  $pdf->SetXY($this->marge_gauche, $posy);
869  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
870  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
871  $posy = $pdf->GetY() + 1;
872 
873  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
874  $pdf->SetXY($this->marge_gauche, $posy);
875  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
876  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
877  $posy = $pdf->GetY() + 2;
878  }
879  }
880  if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
881  $pdf->SetXY($this->marge_gauche, $posy);
882  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
883  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
884  $posy = $pdf->GetY() + 1;
885 
886  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
887  $pdf->SetXY($this->marge_gauche, $posy);
888  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
889  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
890  $posy = $pdf->GetY() + 2;
891  }
892  }
893  }
894  }
895 
896  // If payment mode not forced or forced to VIR, show payment with BAN
897  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
898  if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
899  $bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
900  $account = new Account($this->db);
901  $account->fetch($bankid);
902 
903  $curx = $this->marge_gauche;
904  $cury = $posy;
905 
906  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
907 
908  $posy += 2;
909  }
910  }
911  }
912 
913  return $posy;
914  }
915 
916  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
917  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
928  protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
929  {
930  // phpcs:enable
931  global $conf, $mysoc;
932  $default_font_size = pdf_getPDFFontSize($outputlangs);
933 
934  $tab2_top = $posy;
935  $tab2_hl = 4;
936  $pdf->SetFont('', '', $default_font_size - 1);
937 
938  // Tableau total
939  $col1x = 120;
940  $col2x = 170;
941  if ($this->page_largeur < 210) { // To work with US executive format
942  $col2x -= 20;
943  }
944  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
945 
946  $useborder = 0;
947  $index = 0;
948 
949  // Total HT
950  $pdf->SetFillColor(255, 255, 255);
951  $pdf->SetXY($col1x, $tab2_top + 0);
952  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
953 
954  $pdf->SetXY($col2x, $tab2_top + 0);
955  $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
956 
957  // Show VAT by rates and total
958  $pdf->SetFillColor(248, 248, 248);
959 
960  $this->atleastoneratenotnull = 0;
961  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
962  $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
964  // Nothing to do
965  } else {
966  //Local tax 1 before VAT
967  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
968  //{
969  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
970  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
971  continue;
972  }
973 
974  foreach ($localtax_rate as $tvakey => $tvaval) {
975  if ($tvakey != 0) { // On affiche pas taux 0
976  //$this->atleastoneratenotnull++;
977 
978  $index++;
979  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
980 
981  $tvacompl = '';
982  if (preg_match('/\*/', $tvakey)) {
983  $tvakey = str_replace('*', '', $tvakey);
984  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
985  }
986  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
987  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
988  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
989 
990  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
991  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
992  }
993  }
994  }
995  //}
996  //Local tax 2 before VAT
997  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
998  //{
999  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1000  if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1001  continue;
1002  }
1003 
1004  foreach ($localtax_rate as $tvakey => $tvaval) {
1005  if ($tvakey != 0) { // On affiche pas taux 0
1006  //$this->atleastoneratenotnull++;
1007 
1008 
1009 
1010  $index++;
1011  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1012 
1013  $tvacompl = '';
1014  if (preg_match('/\*/', $tvakey)) {
1015  $tvakey = str_replace('*', '', $tvakey);
1016  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1017  }
1018  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1019  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1020  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1021 
1022  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1023  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1024  }
1025  }
1026  }
1027  //}
1028  // VAT
1029  foreach ($this->tva as $tvakey => $tvaval) {
1030  if ($tvakey > 0) { // On affiche pas taux 0
1031  $this->atleastoneratenotnull++;
1032 
1033  $index++;
1034  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1035 
1036  $tvacompl = '';
1037  if (preg_match('/\*/', $tvakey)) {
1038  $tvakey = str_replace('*', '', $tvakey);
1039  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1040  }
1041  $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1042  $totalvat .= vatrate($tvakey, 1).$tvacompl;
1043  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1044 
1045  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1046  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1047  }
1048  }
1049 
1050  //Local tax 1 after VAT
1051  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1052  //{
1053  foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1054  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1055  continue;
1056  }
1057 
1058  foreach ($localtax_rate as $tvakey => $tvaval) {
1059  if ($tvakey != 0) { // On affiche pas taux 0
1060  //$this->atleastoneratenotnull++;
1061 
1062  $index++;
1063  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1064 
1065  $tvacompl = '';
1066  if (preg_match('/\*/', $tvakey)) {
1067  $tvakey = str_replace('*', '', $tvakey);
1068  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1069  }
1070  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1071 
1072  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1073  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1074  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1075  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1076  }
1077  }
1078  }
1079  //}
1080  //Local tax 2 after VAT
1081  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1082  //{
1083  foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1084  if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1085  continue;
1086  }
1087 
1088  foreach ($localtax_rate as $tvakey => $tvaval) {
1089  // retrieve global local tax
1090  if ($tvakey != 0) { // On affiche pas taux 0
1091  //$this->atleastoneratenotnull++;
1092 
1093  $index++;
1094  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1095 
1096  $tvacompl = '';
1097  if (preg_match('/\*/', $tvakey)) {
1098  $tvakey = str_replace('*', '', $tvakey);
1099  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1100  }
1101  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
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"), $useborder, 'L', 1);
1119 
1120  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1121  $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1122  }
1123  }
1124 
1125  $pdf->SetTextColor(0, 0, 0);
1126 
1127  $resteapayer = $object->total_ttc - $deja_regle;
1128  if (!empty($object->paye)) {
1129  $resteapayer = 0;
1130  }
1131 
1132  if ($deja_regle > 0) {
1133  $index++;
1134 
1135  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1136  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1137 
1138  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1139  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1140 
1141  /*
1142  if ($object->close_code == 'discount_vat')
1143  {
1144  $index++;
1145  $pdf->SetFillColor(255,255,255);
1146 
1147  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1148  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1149 
1150  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1151  $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1);
1152 
1153  $resteapayer=0;
1154  }
1155  */
1156 
1157  $index++;
1158  $pdf->SetTextColor(0, 0, 60);
1159  $pdf->SetFillColor(224, 224, 224);
1160  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1161  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1162 
1163  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1164  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1165 
1166  $pdf->SetFont('', '', $default_font_size - 1);
1167  $pdf->SetTextColor(0, 0, 0);
1168  }
1169 
1170  $index++;
1171  return ($tab2_top + ($tab2_hl * $index));
1172  }
1173 
1174  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1188  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1189  {
1190  global $conf;
1191 
1192  // Force to disable hidetop and hidebottom
1193  $hidebottom = 0;
1194  if ($hidetop) {
1195  $hidetop = -1;
1196  }
1197 
1198  $currency = !empty($currency) ? $currency : $conf->currency;
1199  $default_font_size = pdf_getPDFFontSize($outputlangs);
1200 
1201  // Amount in (at tab_top - 1)
1202  $pdf->SetTextColor(0, 0, 0);
1203  $pdf->SetFont('', '', $default_font_size - 2);
1204 
1205  if (empty($hidetop)) {
1206  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1207  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1208  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1209 
1210  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1211  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1212  $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));
1213  }
1214  }
1215 
1216  $pdf->SetDrawColor(128, 128, 128);
1217  $pdf->SetFont('', '', $default_font_size - 1);
1218 
1219  // Output Rect
1220  $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
1221 
1222  if (empty($hidetop)) {
1223  $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
1224 
1225  $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1226  $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1227  }
1228 
1229  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1230  $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1231  //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1232  if (empty($hidetop)) {
1233  $pdf->SetXY($this->posxtva - 5, $tab_top + 1);
1234  $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1235  }
1236  }
1237 
1238  $pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height);
1239  if (empty($hidetop)) {
1240  $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1241  $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1242  }
1243 
1244  $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1245  if (empty($hidetop)) {
1246  $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1247  $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1248  }
1249 
1250  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1251  $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1252  if (empty($hidetop)) {
1253  $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1254  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
1255  }
1256  }
1257 
1258  $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1259  if (empty($hidetop)) {
1260  if ($this->atleastonediscount) {
1261  $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1262  $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1263  }
1264  }
1265  if ($this->atleastonediscount) {
1266  $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1267  }
1268  if (empty($hidetop)) {
1269  $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1270  $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1271  }
1272  }
1273 
1274  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1284  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1285  {
1286  global $conf, $langs;
1287 
1288  // Load traductions files required by page
1289  $outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies"));
1290 
1291  $default_font_size = pdf_getPDFFontSize($outputlangs);
1292 
1293  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1294 
1295  $pdf->SetTextColor(0, 0, 60);
1296  $pdf->SetFont('', 'B', $default_font_size + 3);
1297 
1298  $posy = $this->marge_haute;
1299  $posx = $this->page_largeur - $this->marge_droite - 100;
1300 
1301  $pdf->SetXY($this->marge_gauche, $posy);
1302 
1303  // Logo
1304  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1305  if ($this->emetteur->logo) {
1306  $logodir = $conf->mycompany->dir_output;
1307  if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1308  $logodir = $conf->mycompany->multidir_output[$object->entity];
1309  }
1310  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1311  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1312  } else {
1313  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1314  }
1315  if (is_readable($logo)) {
1316  $height = pdf_getHeightForLogo($logo);
1317  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1318  } else {
1319  $pdf->SetTextColor(200, 0, 0);
1320  $pdf->SetFont('', 'B', $default_font_size - 2);
1321  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1322  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1323  }
1324  } else {
1325  $text = $this->emetteur->name;
1326  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1327  }
1328  }
1329 
1330  $pdf->SetFont('', 'B', $default_font_size + 3);
1331  $pdf->SetXY($posx, $posy);
1332  $pdf->SetTextColor(0, 0, 60);
1333  $title = $outputlangs->transnoentities("CommercialAsk");
1334  $pdf->MultiCell(100, 4, $title, '', 'R');
1335 
1336  $pdf->SetFont('', 'B', $default_font_size);
1337 
1338  $posy += 5;
1339  $pdf->SetXY($posx, $posy);
1340  $pdf->SetTextColor(0, 0, 60);
1341  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1342 
1343  $posy += 1;
1344  $pdf->SetFont('', '', $default_font_size - 2);
1345 
1346  if ($object->ref_client) {
1347  $posy += 4;
1348  $pdf->SetXY($posx, $posy);
1349  $pdf->SetTextColor(0, 0, 60);
1350  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
1351  }
1352  /* PHFAVRE
1353  $posy+=4;
1354  $pdf->SetXY($posx,$posy);
1355  $pdf->SetTextColor(0,0,60);
1356  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->delivery_date, "day", false, $outputlangs, true), '', 'R');
1357  */
1358 
1359  if ($object->thirdparty->code_fournisseur) {
1360  $posy += 4;
1361  $pdf->SetXY($posx, $posy);
1362  $pdf->SetTextColor(0, 0, 60);
1363  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1364  }
1365 
1366  // Get contact
1367  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1368  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1369  if (count($arrayidcontact) > 0) {
1370  $usertmp = new User($this->db);
1371  $usertmp->fetch($arrayidcontact[0]);
1372  $posy += 4;
1373  $pdf->SetXY($posx, $posy);
1374  $pdf->SetTextColor(0, 0, 60);
1375  $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1376  }
1377  }
1378 
1379  $posy += 2;
1380 
1381  $top_shift = 0;
1382  // Show list of linked objects
1383  $current_y = $pdf->getY();
1384  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1385  if ($current_y < $pdf->getY()) {
1386  $top_shift = $pdf->getY() - $current_y;
1387  }
1388 
1389  if ($showaddress) {
1390  // Sender properties
1391  $carac_emetteur = '';
1392  // Add internal contact of proposal if defined
1393  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1394  if (count($arrayidcontact) > 0) {
1395  $object->fetch_user($arrayidcontact[0]);
1396  $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1397  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1398  }
1399 
1400  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1401 
1402  // Show sender
1403  $posy = 42 + $top_shift;
1404  $posx = $this->marge_gauche;
1405  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1406  $posx = $this->page_largeur - $this->marge_droite - 80;
1407  }
1408  $hautcadre = 40;
1409 
1410  // Show sender frame
1411  $pdf->SetTextColor(0, 0, 0);
1412  $pdf->SetFont('', '', $default_font_size - 2);
1413  $pdf->SetXY($posx, $posy - 5);
1414  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L');
1415  $pdf->SetXY($posx, $posy);
1416  $pdf->SetFillColor(230, 230, 230);
1417  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1418  $pdf->SetTextColor(0, 0, 60);
1419 
1420  // Show sender name
1421  $pdf->SetXY($posx + 2, $posy + 3);
1422  $pdf->SetFont('', 'B', $default_font_size);
1423  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1424  $posy = $pdf->getY();
1425 
1426  // Show sender information
1427  $pdf->SetXY($posx + 2, $posy);
1428  $pdf->SetFont('', '', $default_font_size - 1);
1429  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1430 
1431 
1432  // If CUSTOMER contact defined, we use it
1433  $usecontact = false;
1434  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1435  if (count($arrayidcontact) > 0) {
1436  $usecontact = true;
1437  $result = $object->fetch_contact($arrayidcontact[0]);
1438  }
1439 
1440  // Recipient name
1441  if (!empty($usecontact)) {
1442  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)))) {
1443  $socname = $object->contact;
1444  } else {
1445  $socname = $object->thirdparty;
1446  }
1447  } else {
1448  $socname = $object->thirdparty;
1449  }
1450 
1451  $carac_client_name = pdfBuildThirdpartyName($socname, $outputlangs);
1452 
1453  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1454 
1455  // Show recipient
1456  $widthrecbox = 100;
1457  if ($this->page_largeur < 210) {
1458  $widthrecbox = 84; // To work with US executive format
1459  }
1460  $posy = 42 + $top_shift;
1461  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1462  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1463  $posx = $this->marge_gauche;
1464  }
1465 
1466  // Show recipient frame
1467  $pdf->SetTextColor(0, 0, 0);
1468  $pdf->SetFont('', '', $default_font_size - 2);
1469  $pdf->SetXY($posx + 2, $posy - 5);
1470  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, 'L');
1471  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1472 
1473  // Show recipient name
1474  $pdf->SetXY($posx + 2, $posy + 3);
1475  $pdf->SetFont('', 'B', $default_font_size);
1476  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1477 
1478  // Show recipient information
1479  $pdf->SetFont('', '', $default_font_size - 1);
1480  $pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
1481  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1482  }
1483 
1484  $pdf->SetTextColor(0, 0, 0);
1485  return $top_shift;
1486  }
1487 
1488  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1498  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1499  {
1500  global $conf;
1501  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502  return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1503  }
1504 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
__construct($db)
Constructor.
dol_nboflines_bis($text, $maxlinesize=0, $charset= 'UTF-8')
Return nb of lines of a formated text with and (WARNING: string must not have mixed and br sepa...
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
Definition: pdf.lib.php:812
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:386
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:711
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '')
Show table for lines.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark= '')
Show footer of page for PDF generation.
Definition: pdf.lib.php:989
$conf db
API class for accounts.
Definition: inc.php:41
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:288
Class to manage products or services.
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
Classe mere des modeles de propale.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:2088
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:122
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...
Class to manage bank accounts.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
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...
Class to manage hooks.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1927
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...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition: pdf.lib.php:2470
Class to generate PDF supplier proposal Aurore.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
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:313
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1309
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:737
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:126
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
Definition: pdf.lib.php:427
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:1345
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;…&#39; if string larger than length. ...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
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...
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...