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