dolibarr  13.0.2
pdf_cyan.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5  * Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
10  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  * or see https://www.gnu.org/
25  */
26 
32 require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
33 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
37 
38 
43 {
47  public $db;
48 
52  public $name;
53 
57  public $description;
58 
62  public $update_main_doc_field;
63 
67  public $type;
68 
73  public $phpmin = array(5, 6);
74 
79  public $version = 'dolibarr';
80 
84  public $page_largeur;
85 
89  public $page_hauteur;
90 
94  public $format;
95 
99  public $marge_gauche;
100 
104  public $marge_droite;
105 
109  public $marge_haute;
110 
114  public $marge_basse;
115 
120  public $emetteur;
121 
125  public $cols;
126 
127 
133  public function __construct($db)
134  {
135  global $conf, $langs, $mysoc;
136 
137  // Translations
138  $langs->loadLangs(array("main", "bills"));
139 
140  $this->db = $db;
141  $this->name = "cyan";
142  $this->description = $langs->trans('DocModelCyanDescription');
143  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
144 
145  // Dimension page
146  $this->type = 'pdf';
147  $formatarray = pdf_getFormat();
148  $this->page_largeur = $formatarray['width'];
149  $this->page_hauteur = $formatarray['height'];
150  $this->format = array($this->page_largeur, $this->page_hauteur);
151  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
152  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
153  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
154  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
155 
156  $this->option_logo = 1; // Display logo
157  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
158  $this->option_modereg = 1; // Display payment mode
159  $this->option_condreg = 1; // Display payment terms
160  $this->option_codeproduitservice = 1; // Display product-service code
161  $this->option_multilang = 1; // Available in several languages
162  $this->option_escompte = 0; // Displays if there has been a discount
163  $this->option_credit_note = 0; // Support credit notes
164  $this->option_freetext = 1; // Support add of a personalised text
165  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
166 
167  // Get source company
168  $this->emetteur = $mysoc;
169  if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
170 
171  // Define position of columns
172  $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
173 
174 
175  $this->tabTitleHeight = 5; // default height
176 
177  // Use new system for position of columns, view $this->defineColumnField()
178 
179  $this->tva = array();
180  $this->localtax1 = array();
181  $this->localtax2 = array();
182  $this->atleastoneratenotnull = 0;
183  $this->atleastonediscount = 0;
184  }
185 
186  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
198  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
199  {
200  // phpcs:enable
201  global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
202 
203  dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
204 
205  if (!is_object($outputlangs)) $outputlangs = $langs;
206  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
207  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
208 
209  // Load translation files required by page
210  $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
211 
212  global $outputlangsbis;
213  $outputlangsbis = null;
214  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
215  $outputlangsbis = new Translate('', $conf);
216  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
217  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
218  }
219 
220  $nblines = count($object->lines);
221 
222  $hidetop = 0;
223  if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
224  $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
225  }
226 
227  // Loop on each lines to detect if there is at least one image to show
228  $realpatharray = array();
229  $this->atleastonephoto = false;
230  if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
231  {
232  $objphoto = new Product($this->db);
233 
234  for ($i = 0; $i < $nblines; $i++)
235  {
236  if (empty($object->lines[$i]->fk_product)) continue;
237 
238  $objphoto->fetch($object->lines[$i]->fk_product);
239  //var_dump($objphoto->ref);exit;
240  if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
241  {
242  $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
243  $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
244  } else {
245  $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
246  $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
247  }
248 
249  $arephoto = false;
250  foreach ($pdir as $midir)
251  {
252  if (!$arephoto)
253  {
254  if ($conf->product->entity != $objphoto->entity) {
255  $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
256  } else {
257  $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
258  }
259 
260  foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
261  {
262  if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
263  {
264  if ($obj['photo_vignette'])
265  {
266  $filename = $obj['photo_vignette'];
267  } else {
268  $filename = $obj['photo'];
269  }
270  } else {
271  $filename = $obj['photo'];
272  }
273 
274  $realpath = $dir.$filename;
275  $arephoto = true;
276  $this->atleastonephoto = true;
277  }
278  }
279  }
280 
281  if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
282  }
283  }
284 
285  if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
286 
287  if ($conf->propal->multidir_output[$conf->entity])
288  {
289  $object->fetch_thirdparty();
290 
291  $deja_regle = 0;
292 
293  // Definition of $dir and $file
294  if ($object->specimen)
295  {
296  $dir = $conf->propal->multidir_output[$conf->entity];
297  $file = $dir."/SPECIMEN.pdf";
298  } else {
299  $objectref = dol_sanitizeFileName($object->ref);
300  $dir = $conf->propal->multidir_output[$object->entity]."/".$objectref;
301  $file = $dir."/".$objectref.".pdf";
302  }
303 
304  if (!file_exists($dir))
305  {
306  if (dol_mkdir($dir) < 0)
307  {
308  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
309  return 0;
310  }
311  }
312 
313  if (file_exists($dir))
314  {
315  // Add pdfgeneration hook
316  if (!is_object($hookmanager))
317  {
318  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
319  $hookmanager = new HookManager($this->db);
320  }
321  $hookmanager->initHooks(array('pdfgeneration'));
322  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
323  global $action;
324  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
325 
326  // Set nblines with the new facture lines content after hook
327  $nblines = count($object->lines);
328  //$nbpayments = count($object->getListOfPayments());
329 
330  // Create pdf instance
331  $pdf = pdf_getInstance($this->format);
332  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
333  $pdf->SetAutoPageBreak(1, 0);
334 
335  if (class_exists('TCPDF'))
336  {
337  $pdf->setPrintHeader(false);
338  $pdf->setPrintFooter(false);
339  }
340  $pdf->SetFont(pdf_getPDFFont($outputlangs));
341  // Set path to the background PDF File
342  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
343  {
344  $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
345  $tplidx = $pdf->importPage(1);
346  }
347 
348  $pdf->Open();
349  $pagenb = 0;
350  $pdf->SetDrawColor(128, 128, 128);
351 
352  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
353  $pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
354  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
355  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
356  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
357  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
358 
359  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
360 
361  // Set $this->atleastonediscount if you have at least one discount
362  for ($i = 0; $i < $nblines; $i++)
363  {
364  if ($object->lines[$i]->remise_percent)
365  {
366  $this->atleastonediscount++;
367  }
368  }
369 
370 
371  // New page
372  $pdf->AddPage();
373  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
374  $pagenb++;
375 
376  $heightforinfotot = 40; // Height reserved to output the info and total part
377  $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
378  $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
379  $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
380  //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
381 
382  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
383  $pdf->SetFont('', '', $default_font_size - 1);
384  $pdf->MultiCell(0, 3, ''); // Set interline to 3
385  $pdf->SetTextColor(0, 0, 0);
386 
387 
388  $tab_top = 90 + $top_shift;
389  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
390 
391 
392  // Incoterm
393  $height_incoterms = 0;
394  if (!empty($conf->incoterm->enabled))
395  {
396  $desc_incoterms = $object->getIncotermsForPDF();
397  if ($desc_incoterms)
398  {
399  $tab_top -= 2;
400 
401  $pdf->SetFont('', '', $default_font_size - 1);
402  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
403  $nexY = max($pdf->GetY(), $nexY);
404  $height_incoterms = $nexY - $tab_top;
405 
406  // Rect takes a length in 3rd parameter
407  $pdf->SetDrawColor(192, 192, 192);
408  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
409 
410  $tab_top = $nexY + 6;
411  }
412  }
413 
414  // Displays notes
415  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
416  if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
417  {
418  // Get first sale rep
419  if (is_object($object->thirdparty))
420  {
421  $salereparray = $object->thirdparty->getSalesRepresentatives($user);
422  $salerepobj = new User($this->db);
423  $salerepobj->fetch($salereparray[0]['id']);
424  if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
425  }
426  }
427 
428  // Extrafields in note
429  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
430  if (!empty($extranote)) {
431  $notetoshow = dol_concatdesc($notetoshow, $extranote);
432  }
433 
434  if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
435  {
436  $tmpuser = new User($this->db);
437  $tmpuser->fetch($object->user_author_id);
438  $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
439  if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
440  if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
441  }
442 
443  $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
444 
445  $pagenb = $pdf->getPage();
446  if ($notetoshow)
447  {
448  $tab_top -= 2;
449 
450  $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
451  $pageposbeforenote = $pagenb;
452 
453  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
454  complete_substitutions_array($substitutionarray, $outputlangs, $object);
455  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
456  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
457 
458  $pdf->startTransaction();
459 
460  $pdf->SetFont('', '', $default_font_size - 1);
461  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
462  // Description
463  $pageposafternote = $pdf->getPage();
464  $posyafter = $pdf->GetY();
465 
466  if ($pageposafternote > $pageposbeforenote)
467  {
468  $pdf->rollbackTransaction(true);
469 
470  // prepare pages to receive notes
471  while ($pagenb < $pageposafternote) {
472  $pdf->AddPage();
473  $pagenb++;
474  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
475  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
476  // $this->_pagefoot($pdf,$object,$outputlangs,1);
477  $pdf->setTopMargin($tab_top_newpage);
478  // The only function to edit the bottom margin of current page to set it.
479  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
480  }
481 
482  // back to start
483  $pdf->setPage($pageposbeforenote);
484  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
485  $pdf->SetFont('', '', $default_font_size - 1);
486  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
487  $pageposafternote = $pdf->getPage();
488 
489  $posyafter = $pdf->GetY();
490 
491  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
492  {
493  $pdf->AddPage('', '', true);
494  $pagenb++;
495  $pageposafternote++;
496  $pdf->setPage($pageposafternote);
497  $pdf->setTopMargin($tab_top_newpage);
498  // The only function to edit the bottom margin of current page to set it.
499  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
500  //$posyafter = $tab_top_newpage;
501  }
502 
503 
504  // apply note frame to previous pages
505  $i = $pageposbeforenote;
506  while ($i < $pageposafternote) {
507  $pdf->setPage($i);
508 
509 
510  $pdf->SetDrawColor(128, 128, 128);
511  // Draw note frame
512  if ($i > $pageposbeforenote) {
513  $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
514  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
515  } else {
516  $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
517  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
518  }
519 
520  // Add footer
521  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
522  $this->_pagefoot($pdf, $object, $outputlangs, 1);
523 
524  $i++;
525  }
526 
527  // apply note frame to last page
528  $pdf->setPage($pageposafternote);
529  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
530  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531  $height_note = $posyafter - $tab_top_newpage;
532  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
533  } else // No pagebreak
534  {
535  $pdf->commitTransaction();
536  $posyafter = $pdf->GetY();
537  $height_note = $posyafter - $tab_top;
538  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
539 
540 
541  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
542  {
543  // not enough space, need to add page
544  $pdf->AddPage('', '', true);
545  $pagenb++;
546  $pageposafternote++;
547  $pdf->setPage($pageposafternote);
548  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
549  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
550 
551  $posyafter = $tab_top_newpage;
552  }
553  }
554  $tab_height = $tab_height - $height_note;
555  $tab_top = $posyafter + 6;
556  } else {
557  $height_note = 0;
558  }
559 
560  // Use new auto column system
561  $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
562 
563  // Table simulation to know the height of the title line
564  $pdf->startTransaction();
565  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
566  $pdf->rollbackTransaction(true);
567 
568  $nexY = $tab_top + $this->tabTitleHeight;
569 
570  // Loop on each lines
571  $pageposbeforeprintlines = $pdf->getPage();
572  $pagenb = $pageposbeforeprintlines;
573  for ($i = 0; $i < $nblines; $i++)
574  {
575  $curY = $nexY;
576  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
577  $pdf->SetTextColor(0, 0, 0);
578 
579  // Define size of image if we need it
580  $imglinesize = array();
581  if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
582 
583  $pdf->setTopMargin($tab_top_newpage);
584  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
585  $pageposbefore = $pdf->getPage();
586 
587  $showpricebeforepagebreak = 1;
588  $posYAfterImage = 0;
589  $posYAfterDescription = 0;
590 
591  if ($this->getColumnStatus('photo'))
592  {
593  // We start with Photo of product line
594  if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
595  {
596  $pdf->AddPage('', '', true);
597  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
598  $pdf->setPage($pageposbefore + 1);
599 
600  $curY = $tab_top_newpage;
601 
602  // Allows data in the first page if description is long enough to break in multiples pages
603  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
604  $showpricebeforepagebreak = 1;
605  else $showpricebeforepagebreak = 0;
606  }
607 
608 
609  if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
610  {
611  $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
612  // $pdf->Image does not increase value return by getY, so we save it manually
613  $posYAfterImage = $curY + $imglinesize['height'];
614  }
615  }
616 
617  // Description of product line
618  if ($this->getColumnStatus('desc'))
619  {
620  $pdf->startTransaction();
621 
622  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
623  $pageposafter = $pdf->getPage();
624 
625  if ($pageposafter > $pageposbefore) // There is a pagebreak
626  {
627  $pdf->rollbackTransaction(true);
628 
629  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
630 
631  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
632 
633  $pageposafter = $pdf->getPage();
634  $posyafter = $pdf->GetY();
635  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
636  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text
637  {
638  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
639  {
640  $pdf->AddPage('', '', true);
641  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
642  $pdf->setPage($pageposafter + 1);
643  }
644  } else {
645  // We found a page break
646  // Allows data in the first page if description is long enough to break in multiples pages
647  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
648  $showpricebeforepagebreak = 1;
649  else $showpricebeforepagebreak = 0;
650  }
651  } else // No pagebreak
652  {
653  $pdf->commitTransaction();
654  }
655  $posYAfterDescription = $pdf->GetY();
656  }
657 
658  $nexY = $pdf->GetY();
659  $pageposafter = $pdf->getPage();
660 
661  $pdf->setPage($pageposbefore);
662  $pdf->setTopMargin($this->marge_haute);
663  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
664 
665  // We suppose that a too long description or photo were moved completely on next page
666  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
667  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
668  }
669 
670  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
671 
672  // VAT Rate
673  if ($this->getColumnStatus('vat'))
674  {
675  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
676  $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
677  $nexY = max($pdf->GetY(), $nexY);
678  }
679 
680  // Unit price before discount
681  if ($this->getColumnStatus('subprice'))
682  {
683  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
684  $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
685  $nexY = max($pdf->GetY(), $nexY);
686  }
687 
688  // Quantity
689  // Enough for 6 chars
690  if ($this->getColumnStatus('qty'))
691  {
692  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
693  $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
694  $nexY = max($pdf->GetY(), $nexY);
695  }
696 
697 
698  // Unit
699  if ($this->getColumnStatus('unit'))
700  {
701  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
702  $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
703  $nexY = max($pdf->GetY(), $nexY);
704  }
705 
706  // Discount on line
707  if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
708  {
709  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
710  $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
711  $nexY = max($pdf->GetY(), $nexY);
712  }
713 
714  // Total excl tax line (HT)
715  if ($this->getColumnStatus('totalexcltax'))
716  {
717  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
718  $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
719  $nexY = max($pdf->GetY(), $nexY);
720  }
721 
722  // Total with tax line (TTC)
723  if ($this->getColumnStatus('totalincltax'))
724  {
725  $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
726  $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
727  $nexY = max($pdf->GetY(), $nexY);
728  }
729 
730  // Extrafields
731  if (!empty($object->lines[$i]->array_options)) {
732  foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
733  if ($this->getColumnStatus($extrafieldColKey))
734  {
735  $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
736  $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
737  $nexY = max($pdf->GetY(), $nexY);
738  }
739  }
740  }
741 
742  $parameters = array(
743  'object' => $object,
744  'i' => $i,
745  'pdf' =>& $pdf,
746  'curY' =>& $curY,
747  'nexY' =>& $nexY,
748  'outputlangs' => $outputlangs,
749  'hidedetails' => $hidedetails
750  );
751  $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
752 
753 
754  // Collection of totals by value of vat in $this->tva["rate"] = total_tva
755  if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
756  else $tvaligne = $object->lines[$i]->total_tva;
757 
758  $localtax1ligne = $object->lines[$i]->total_localtax1;
759  $localtax2ligne = $object->lines[$i]->total_localtax2;
760  $localtax1_rate = $object->lines[$i]->localtax1_tx;
761  $localtax2_rate = $object->lines[$i]->localtax2_tx;
762  $localtax1_type = $object->lines[$i]->localtax1_type;
763  $localtax2_type = $object->lines[$i]->localtax2_type;
764 
765  if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
766  if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
767  if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
768 
769  $vatrate = (string) $object->lines[$i]->tva_tx;
770 
771  // Retrieve type from database for backward compatibility with old records
772  if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
773  && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
774  {
775  $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
776  $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
777  $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
778  }
779 
780  // retrieve global local tax
781  if ($localtax1_type && $localtax1ligne != 0) {
782  $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
783  }
784  if ($localtax2_type && $localtax2ligne != 0) {
785  $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
786  }
787 
788  if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
789  if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
790  $this->tva[$vatrate] += $tvaligne;
791 
792  if ($posYAfterImage > $posYAfterDescription) $nexY = max($nexY, $posYAfterImage);
793 
794  // Add line
795  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
796  $pdf->setPage($pageposafter);
797  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
798  //$pdf->SetDrawColor(190,190,200);
799  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
800  $pdf->SetLineStyle(array('dash'=>0));
801  }
802 
803 
804 
805  // Detect if some page were added automatically and output _tableau for past pages
806  while ($pagenb < $pageposafter) {
807  $pdf->setPage($pagenb);
808  if ($pagenb == $pageposbeforeprintlines) {
809  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
810  } else {
811  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
812  }
813  $this->_pagefoot($pdf, $object, $outputlangs, 1);
814  $pagenb++;
815  $pdf->setPage($pagenb);
816  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
817  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
818  }
819 
820  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
821  if ($pagenb == $pageposafter) {
822  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
823  } else {
824  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
825  }
826  $this->_pagefoot($pdf, $object, $outputlangs, 1);
827  // New page
828  $pdf->AddPage();
829  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
830  $pagenb++;
831  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
832  }
833  }
834 
835  // Show square
836  if ($pagenb == $pageposbeforeprintlines)
837  {
838  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
839  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
840  } else {
841  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
842  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
843  }
844 
845  // Display infos area
846  $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
847 
848  // Display total zone
849  $posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
850 
851  // Display payment area
852  /*
853  if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
854  {
855  $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
856  }
857  */
858 
859  // Customer signature area
860  if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
861  {
862  $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
863  }
864 
865  // Pagefoot
866  $this->_pagefoot($pdf, $object, $outputlangs);
867  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
868 
869  //If propal merge product PDF is active
870  if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
871  {
872  require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
873 
874  $already_merged = array();
875  foreach ($object->lines as $line) {
876  if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
877  // Find the desire PDF
878  $filetomerge = new Propalmergepdfproduct($this->db);
879 
880  if ($conf->global->MAIN_MULTILANGS) {
881  $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
882  } else {
883  $filetomerge->fetch_by_product($line->fk_product);
884  }
885 
886  $already_merged[] = $line->fk_product;
887 
888  $product = new Product($this->db);
889  $product->fetch($line->fk_product);
890 
891  if ($product->entity != $conf->entity) {
892  $entity_product_file = $product->entity;
893  } else {
894  $entity_product_file = $conf->entity;
895  }
896 
897  // If PDF is selected and file is not empty
898  if (count($filetomerge->lines) > 0) {
899  foreach ($filetomerge->lines as $linefile) {
900  if (!empty($linefile->id) && !empty($linefile->file_name)) {
901  if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
902  {
903  if (!empty($conf->product->enabled)) {
904  $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
905  } elseif (!empty($conf->service->enabled)) {
906  $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
907  }
908  } else {
909  if (!empty($conf->product->enabled)) {
910  $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
911  } elseif (!empty($conf->service->enabled)) {
912  $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
913  }
914  }
915 
916  dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
917 
918  $infile = $filetomerge_dir.'/'.$linefile->file_name;
919  if (file_exists($infile) && is_readable($infile)) {
920  $pagecount = $pdf->setSourceFile($infile);
921  for ($i = 1; $i <= $pagecount; $i++) {
922  $tplIdx = $pdf->importPage($i);
923  if ($tplIdx !== false) {
924  $s = $pdf->getTemplatesize($tplIdx);
925  $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
926  $pdf->useTemplate($tplIdx);
927  } else {
928  setEventMessages(null, array($infile.' cannot be added, probably protected PDF'), 'warnings');
929  }
930  }
931  }
932  }
933  }
934  }
935  }
936  }
937  }
938 
939  $pdf->Close();
940 
941  $pdf->Output($file, 'F');
942 
943  //Add pdfgeneration hook
944  $hookmanager->initHooks(array('pdfgeneration'));
945  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
946  global $action;
947  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
948  if ($reshook < 0)
949  {
950  $this->error = $hookmanager->error;
951  $this->errors = $hookmanager->errors;
952  }
953 
954  if (!empty($conf->global->MAIN_UMASK))
955  @chmod($file, octdec($conf->global->MAIN_UMASK));
956 
957  $this->result = array('fullpath'=>$file);
958 
959  return 1; // No error
960  } else {
961  $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
962  return 0;
963  }
964  } else {
965  $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
966  return 0;
967  }
968  }
969 
979  protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
980  {
981  }
982 
992  public function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
993  {
994  global $conf, $mysoc;
995  $default_font_size = pdf_getPDFFontSize($outputlangs);
996 
997  $pdf->SetFont('', '', $default_font_size - 1);
998 
999  // If France, show VAT mention if not applicable
1000  if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
1001  {
1002  $pdf->SetFont('', 'B', $default_font_size - 2);
1003  $pdf->SetXY($this->marge_gauche, $posy);
1004  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
1005 
1006  $posy = $pdf->GetY() + 4;
1007  }
1008 
1009  $posxval = 52;
1010 
1011  // Show shipping date
1012  if (!empty($object->delivery_date))
1013  {
1014  $outputlangs->load("sendings");
1015  $pdf->SetFont('', 'B', $default_font_size - 2);
1016  $pdf->SetXY($this->marge_gauche, $posy);
1017  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
1018  $pdf->MultiCell(80, 4, $titre, 0, 'L');
1019  $pdf->SetFont('', '', $default_font_size - 2);
1020  $pdf->SetXY($posxval, $posy);
1021  $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
1022  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
1023 
1024  $posy = $pdf->GetY() + 1;
1025  } elseif ($object->availability_code || $object->availability) // Show availability conditions
1026  {
1027  $pdf->SetFont('', 'B', $default_font_size - 2);
1028  $pdf->SetXY($this->marge_gauche, $posy);
1029  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
1030  $pdf->MultiCell(80, 4, $titre, 0, 'L');
1031  $pdf->SetTextColor(0, 0, 0);
1032  $pdf->SetFont('', '', $default_font_size - 2);
1033  $pdf->SetXY($posxval, $posy);
1034  $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
1035  $lib_availability = str_replace('\n', "\n", $lib_availability);
1036  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
1037 
1038  $posy = $pdf->GetY() + 1;
1039  }
1040 
1041  // Show payments conditions
1042  if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && ($object->cond_reglement_code || $object->cond_reglement))
1043  {
1044  $pdf->SetFont('', 'B', $default_font_size - 2);
1045  $pdf->SetXY($this->marge_gauche, $posy);
1046  $titre = $outputlangs->transnoentities("PaymentConditions").':';
1047  $pdf->MultiCell(43, 4, $titre, 0, 'L');
1048 
1049  $pdf->SetFont('', '', $default_font_size - 2);
1050  $pdf->SetXY($posxval, $posy);
1051  $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);
1052  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1053  $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1054 
1055  $posy = $pdf->GetY() + 3;
1056  }
1057 
1058  if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE))
1059  {
1060  // Check a payment mode is defined
1061  /* Not required on a proposal
1062  if (empty($object->mode_reglement_code)
1063  && ! $conf->global->FACTURE_CHQ_NUMBER
1064  && ! $conf->global->FACTURE_RIB_NUMBER)
1065  {
1066  $pdf->SetXY($this->marge_gauche, $posy);
1067  $pdf->SetTextColor(200,0,0);
1068  $pdf->SetFont('','B', $default_font_size - 2);
1069  $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
1070  $pdf->SetTextColor(0,0,0);
1071 
1072  $posy=$pdf->GetY()+1;
1073  }
1074  */
1075 
1076  // Show payment mode
1077  if ($object->mode_reglement_code
1078  && $object->mode_reglement_code != 'CHQ'
1079  && $object->mode_reglement_code != 'VIR')
1080  {
1081  $pdf->SetFont('', 'B', $default_font_size - 2);
1082  $pdf->SetXY($this->marge_gauche, $posy);
1083  $titre = $outputlangs->transnoentities("PaymentMode").':';
1084  $pdf->MultiCell(80, 5, $titre, 0, 'L');
1085  $pdf->SetFont('', '', $default_font_size - 2);
1086  $pdf->SetXY($posxval, $posy);
1087  $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);
1088  $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1089 
1090  $posy = $pdf->GetY() + 2;
1091  }
1092 
1093  // Show payment mode CHQ
1094  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1095  {
1096  // Si mode reglement non force ou si force a CHQ
1097  if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1098  {
1099  $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1100 
1101  if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1102  {
1103  $account = new Account($this->db);
1104  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1105 
1106  $pdf->SetXY($this->marge_gauche, $posy);
1107  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1108  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
1109  $posy = $pdf->GetY() + 1;
1110 
1111  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1112  {
1113  $pdf->SetXY($this->marge_gauche, $posy);
1114  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1115  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1116  $posy = $pdf->GetY() + 2;
1117  }
1118  }
1119  if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1120  {
1121  $pdf->SetXY($this->marge_gauche, $posy);
1122  $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1123  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1124  $posy = $pdf->GetY() + 1;
1125 
1126  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1127  {
1128  $pdf->SetXY($this->marge_gauche, $posy);
1129  $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1130  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1131  $posy = $pdf->GetY() + 2;
1132  }
1133  }
1134  }
1135  }
1136 
1137  // If payment mode not forced or forced to VIR, show payment with BAN
1138  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1139  {
1140  if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER))
1141  {
1142  $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1143  if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1144  $account = new Account($this->db);
1145  $account->fetch($bankid);
1146 
1147  $curx = $this->marge_gauche;
1148  $cury = $posy;
1149 
1150  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1151 
1152  $posy += 2;
1153  }
1154  }
1155  }
1156 
1157  return $posy;
1158  }
1159 
1160 
1171  protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1172  {
1173  global $conf, $mysoc, $hookmanager;
1174 
1175  $default_font_size = pdf_getPDFFontSize($outputlangs);
1176 
1177  $outputlangsbis = null;
1178  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1179  $outputlangsbis = new Translate('', $conf);
1180  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1181  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1182  $default_font_size--;
1183  }
1184 
1185  $tab2_top = $posy;
1186  $tab2_hl = 4;
1187  $pdf->SetFont('', '', $default_font_size - 1);
1188 
1189  // Total table
1190  $col1x = 120; $col2x = 170;
1191  if ($this->page_largeur < 210) // To work with US executive format
1192  {
1193  $col2x -= 20;
1194  }
1195  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1196 
1197  $useborder = 0;
1198  $index = 0;
1199 
1200  // Total HT
1201  $pdf->SetFillColor(255, 255, 255);
1202  $pdf->SetXY($col1x, $tab2_top + 0);
1203  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
1204 
1205  $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1206  $pdf->SetXY($col2x, $tab2_top + 0);
1207  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
1208 
1209  // Show VAT by rates and total
1210  $pdf->SetFillColor(248, 248, 248);
1211 
1212  $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1213 
1214  $this->atleastoneratenotnull = 0;
1215  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1216  {
1217  $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1218  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1219  {
1220  // Nothing to do
1221  } else {
1222  //Local tax 1 before VAT
1223  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1224  //{
1225  foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1226  {
1227  if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1228 
1229  foreach ($localtax_rate as $tvakey => $tvaval)
1230  {
1231  if ($tvakey != 0) // On affiche pas taux 0
1232  {
1233  //$this->atleastoneratenotnull++;
1234 
1235  $index++;
1236  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1237 
1238  $tvacompl = '';
1239  if (preg_match('/\*/', $tvakey))
1240  {
1241  $tvakey = str_replace('*', '', $tvakey);
1242  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1243  }
1244  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1245  $totalvat .= ' ';
1246  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1247  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1248 
1249  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1250  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1251  }
1252  }
1253  }
1254  //}
1255  //Local tax 2 before VAT
1256  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1257  //{
1258  foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1259  {
1260  if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1261 
1262  foreach ($localtax_rate as $tvakey => $tvaval)
1263  {
1264  if ($tvakey != 0) // On affiche pas taux 0
1265  {
1266  //$this->atleastoneratenotnull++;
1267 
1268 
1269 
1270  $index++;
1271  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1272 
1273  $tvacompl = '';
1274  if (preg_match('/\*/', $tvakey))
1275  {
1276  $tvakey = str_replace('*', '', $tvakey);
1277  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1278  }
1279  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1280  $totalvat .= ' ';
1281  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1282  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1283 
1284  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1285  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1286  }
1287  }
1288  }
1289  //}
1290  // VAT
1291  foreach ($this->tva as $tvakey => $tvaval)
1292  {
1293  if ($tvakey != 0) // On affiche pas taux 0
1294  {
1295  $this->atleastoneratenotnull++;
1296 
1297  $index++;
1298  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1299 
1300  $tvacompl = '';
1301  if (preg_match('/\*/', $tvakey))
1302  {
1303  $tvakey = str_replace('*', '', $tvakey);
1304  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1305  }
1306  $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1307  $totalvat .= ' ';
1308  $totalvat .= vatrate($tvakey, 1).$tvacompl;
1309  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1310 
1311  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1312  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1313  }
1314  }
1315 
1316  //Local tax 1 after VAT
1317  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1318  //{
1319  foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1320  {
1321  if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1322 
1323  foreach ($localtax_rate as $tvakey => $tvaval)
1324  {
1325  if ($tvakey != 0) // On affiche pas taux 0
1326  {
1327  //$this->atleastoneratenotnull++;
1328 
1329  $index++;
1330  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1331 
1332  $tvacompl = '';
1333  if (preg_match('/\*/', $tvakey))
1334  {
1335  $tvakey = str_replace('*', '', $tvakey);
1336  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1337  }
1338  $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1339  $totalvat .= ' ';
1340 
1341  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1342  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1343  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1344  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1345  }
1346  }
1347  }
1348  //}
1349  //Local tax 2 after VAT
1350  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1351  //{
1352  foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1353  {
1354  if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1355 
1356  foreach ($localtax_rate as $tvakey => $tvaval)
1357  {
1358  // retrieve global local tax
1359  if ($tvakey != 0) // On affiche pas taux 0
1360  {
1361  //$this->atleastoneratenotnull++;
1362 
1363  $index++;
1364  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1365 
1366  $tvacompl = '';
1367  if (preg_match('/\*/', $tvakey))
1368  {
1369  $tvakey = str_replace('*', '', $tvakey);
1370  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1371  }
1372  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1373  $totalvat .= ' ';
1374 
1375  $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1376  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1377 
1378  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1379  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1380  }
1381  }
1382  }
1383  //}
1384 
1385  // Total TTC
1386  $index++;
1387  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1388  $pdf->SetTextColor(0, 0, 60);
1389  $pdf->SetFillColor(224, 224, 224);
1390  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : ''), $useborder, 'L', 1);
1391 
1392  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1393  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1394  }
1395  }
1396 
1397  $pdf->SetTextColor(0, 0, 0);
1398 
1399  $resteapayer = 0;
1400  /*
1401  $resteapayer = $object->total_ttc - $deja_regle;
1402  if (! empty($object->paye)) $resteapayer=0;
1403  */
1404 
1405  if ($deja_regle > 0)
1406  {
1407  // Already paid + Deposits
1408  $index++;
1409 
1410  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1411  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1412 
1413  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1414  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1415 
1416  /*
1417  if ($object->close_code == 'discount_vat')
1418  {
1419  $index++;
1420  $pdf->SetFillColor(255,255,255);
1421 
1422  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1423  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1424 
1425  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1426  $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1);
1427 
1428  $resteapayer=0;
1429  }
1430  */
1431 
1432  $index++;
1433  $pdf->SetTextColor(0, 0, 60);
1434  $pdf->SetFillColor(224, 224, 224);
1435  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1436  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
1437 
1438  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1439  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1440 
1441  $pdf->SetFont('', '', $default_font_size - 1);
1442  $pdf->SetTextColor(0, 0, 0);
1443  }
1444 
1445  $index++;
1446  return ($tab2_top + ($tab2_hl * $index));
1447  }
1448 
1449  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1464  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1465  {
1466  global $conf;
1467 
1468  // Force to disable hidetop and hidebottom
1469  $hidebottom = 0;
1470  if ($hidetop) $hidetop = -1;
1471 
1472  $currency = !empty($currency) ? $currency : $conf->currency;
1473  $default_font_size = pdf_getPDFFontSize($outputlangs);
1474 
1475  // Amount in (at tab_top - 1)
1476  $pdf->SetTextColor(0, 0, 0);
1477  $pdf->SetFont('', '', $default_font_size - 2);
1478 
1479  if (empty($hidetop))
1480  {
1481  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1482  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1483  $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1484  }
1485 
1486  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1487  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1488 
1489  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1490  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1491  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1492  }
1493  }
1494 
1495  $pdf->SetDrawColor(128, 128, 128);
1496  $pdf->SetFont('', '', $default_font_size - 1);
1497 
1498  // Output Rect
1499  $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
1500 
1501  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1502 
1503  if (empty($hidetop)) {
1504  $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
1505  }
1506  }
1507 
1508  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1519  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
1520  {
1521  global $conf, $langs;
1522 
1523  // Load traductions files required by page
1524  $outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
1525 
1526  $default_font_size = pdf_getPDFFontSize($outputlangs);
1527 
1528  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1529 
1530  // Show Draft Watermark
1531  if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
1532  {
1533  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
1534  }
1535 
1536  $pdf->SetTextColor(0, 0, 60);
1537  $pdf->SetFont('', 'B', $default_font_size + 3);
1538 
1539  $w = 100;
1540 
1541  $posy = $this->marge_haute;
1542  $posx = $this->page_largeur - $this->marge_droite - $w;
1543 
1544  $pdf->SetXY($this->marge_gauche, $posy);
1545 
1546  // Logo
1547  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1548  {
1549  if ($this->emetteur->logo)
1550  {
1551  $logodir = $conf->mycompany->dir_output;
1552  if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1553  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1554  {
1555  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1556  } else {
1557  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1558  }
1559  if (is_readable($logo)) {
1560  $height = pdf_getHeightForLogo($logo);
1561  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1562  } else {
1563  $pdf->SetTextColor(200, 0, 0);
1564  $pdf->SetFont('', 'B', $default_font_size - 2);
1565  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1566  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1567  }
1568  } else {
1569  $text = $this->emetteur->name;
1570  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1571  }
1572  }
1573 
1574  $pdf->SetFont('', 'B', $default_font_size + 3);
1575  $pdf->SetXY($posx, $posy);
1576  $pdf->SetTextColor(0, 0, 60);
1577  $title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
1578  $pdf->MultiCell($w, 4, $title, '', 'R');
1579 
1580  $pdf->SetFont('', 'B', $default_font_size);
1581 
1582  $posy += 5;
1583  $pdf->SetXY($posx, $posy);
1584  $pdf->SetTextColor(0, 0, 60);
1585  $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1586  if ($object->statut == $object::STATUS_DRAFT)
1587  {
1588  $pdf->SetTextColor(128, 0, 0);
1589  $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1590  }
1591  $pdf->MultiCell($w, 4, $textref, '', 'R');
1592 
1593  $posy += 1;
1594  $pdf->SetFont('', '', $default_font_size - 2);
1595 
1596  if ($object->ref_client)
1597  {
1598  $posy += 4;
1599  $pdf->SetXY($posx, $posy);
1600  $pdf->SetTextColor(0, 0, 60);
1601  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1602  }
1603 
1604  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1605  {
1606  $object->fetch_projet();
1607  if (!empty($object->project->ref))
1608  {
1609  $posy += 3;
1610  $pdf->SetXY($posx, $posy);
1611  $pdf->SetTextColor(0, 0, 60);
1612  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
1613  }
1614  }
1615 
1616  if (!empty($conf->global->PDF_SHOW_PROJECT))
1617  {
1618  $object->fetch_projet();
1619  if (!empty($object->project->ref))
1620  {
1621  $posy += 3;
1622  $pdf->SetXY($posx, $posy);
1623  $pdf->SetTextColor(0, 0, 60);
1624  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1625  }
1626  }
1627 
1628  $posy += 4;
1629  $pdf->SetXY($posx, $posy);
1630  $pdf->SetTextColor(0, 0, 60);
1631  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1632 
1633  $posy += 4;
1634  $pdf->SetXY($posx, $posy);
1635  $pdf->SetTextColor(0, 0, 60);
1636 
1637  $title = $outputlangs->transnoentities("DateEndPropal");
1638  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1639  $title .= ' - '.$outputlangsbis->transnoentities("DateEndPropal");
1640  }
1641  $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
1642 
1643  if ($object->thirdparty->code_client)
1644  {
1645  $posy += 4;
1646  $pdf->SetXY($posx, $posy);
1647  $pdf->SetTextColor(0, 0, 60);
1648  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1649  }
1650 
1651  // Get contact
1652  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1653  {
1654  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1655  if (count($arrayidcontact) > 0)
1656  {
1657  $usertmp = new User($this->db);
1658  $usertmp->fetch($arrayidcontact[0]);
1659  $posy += 4;
1660  $pdf->SetXY($posx, $posy);
1661  $pdf->SetTextColor(0, 0, 60);
1662  $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1663  }
1664  }
1665 
1666  $posy += 2;
1667 
1668  $top_shift = 0;
1669  // Show list of linked objects
1670  $current_y = $pdf->getY();
1671  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1672  if ($current_y < $pdf->getY())
1673  {
1674  $top_shift = $pdf->getY() - $current_y;
1675  }
1676 
1677  if ($showaddress)
1678  {
1679  // Sender properties
1680  $carac_emetteur = '';
1681  // Add internal contact of proposal if defined
1682  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1683  if (count($arrayidcontact) > 0)
1684  {
1685  $object->fetch_user($arrayidcontact[0]);
1686  $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1687  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1688  }
1689 
1690  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1691 
1692  // Show sender
1693  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1694  $posy += $top_shift;
1695  $posx = $this->marge_gauche;
1696  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1697 
1698  $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1699  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1700 
1701  // Show sender frame
1702  $pdf->SetTextColor(0, 0, 0);
1703  $pdf->SetFont('', '', $default_font_size - 2);
1704  $pdf->SetXY($posx, $posy - 5);
1705  $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1706  $pdf->SetXY($posx, $posy);
1707  $pdf->SetFillColor(230, 230, 230);
1708  $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1709  $pdf->SetTextColor(0, 0, 60);
1710 
1711  // Show sender name
1712  $pdf->SetXY($posx + 2, $posy + 3);
1713  $pdf->SetFont('', 'B', $default_font_size);
1714  $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1715  $posy = $pdf->getY();
1716 
1717  // Show sender information
1718  $pdf->SetXY($posx + 2, $posy);
1719  $pdf->SetFont('', '', $default_font_size - 1);
1720  $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1721 
1722 
1723  // If CUSTOMER contact defined, we use it
1724  $usecontact = false;
1725  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1726  if (count($arrayidcontact) > 0)
1727  {
1728  $usecontact = true;
1729  $result = $object->fetch_contact($arrayidcontact[0]);
1730  }
1731 
1732  // Recipient name
1733  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)))) {
1734  $thirdparty = $object->contact;
1735  } else {
1736  $thirdparty = $object->thirdparty;
1737  }
1738 
1739  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1740 
1741  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1742 
1743  // Show recipient
1744  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1745  if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1746  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1747  $posy += $top_shift;
1748  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1749  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1750 
1751  // Show recipient frame
1752  $pdf->SetTextColor(0, 0, 0);
1753  $pdf->SetFont('', '', $default_font_size - 2);
1754  $pdf->SetXY($posx + 2, $posy - 5);
1755  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1756  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1757 
1758  // Show recipient name
1759  $pdf->SetXY($posx + 2, $posy + 3);
1760  $pdf->SetFont('', 'B', $default_font_size);
1761  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1762 
1763  $posy = $pdf->getY();
1764 
1765  // Show recipient information
1766  $pdf->SetFont('', '', $default_font_size - 1);
1767  $pdf->SetXY($posx + 2, $posy);
1768  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1769  }
1770 
1771  $pdf->SetTextColor(0, 0, 0);
1772  return $top_shift;
1773  }
1774 
1775  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1785  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1786  {
1787  global $conf;
1788  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1789  return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1790  }
1791 
1801  protected function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
1802  {
1803  global $conf;
1804  $default_font_size = pdf_getPDFFontSize($outputlangs);
1805  $tab_top = $posy + 4;
1806  $tab_hl = 4;
1807 
1808  $posx = 120;
1809  $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1810  $useborder = 0;
1811  $index = 0;
1812  // Total HT
1813  $pdf->SetFillColor(255, 255, 255);
1814  $pdf->SetXY($posx, $tab_top + 0);
1815  $pdf->SetFont('', '', $default_font_size - 2);
1816  $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1817 
1818  $pdf->SetXY($posx, $tab_top + $tab_hl);
1819  $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
1820  if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1821  $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1822  }
1823 
1824  return ($tab_hl * 7);
1825  }
1826 
1827 
1838  public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1839  {
1840  global $conf, $hookmanager;
1841 
1842  // Default field style for content
1843  $this->defaultContentsFieldsStyle = array(
1844  'align' => 'R', // R,C,L
1845  'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1846  );
1847 
1848  // Default field style for content
1849  $this->defaultTitlesFieldsStyle = array(
1850  'align' => 'C', // R,C,L
1851  'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1852  );
1853 
1854  /*
1855  * For exemple
1856  $this->cols['theColKey'] = array(
1857  'rank' => $rank, // int : use for ordering columns
1858  'width' => 20, // the column width in mm
1859  'title' => array(
1860  'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1861  'label' => ' ', // the final label : used fore final generated text
1862  'align' => 'L', // text alignement : R,C,L
1863  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1864  ),
1865  'content' => array(
1866  'align' => 'L', // text alignement : R,C,L
1867  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1868  ),
1869  );
1870  */
1871 
1872  $rank = 0; // do not use negative rank
1873  $this->cols['desc'] = array(
1874  'rank' => $rank,
1875  'width' => false, // only for desc
1876  'status' => true,
1877  'title' => array(
1878  'textkey' => 'Designation', // use lang key is usefull in somme case with module
1879  'align' => 'L',
1880  // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1881  // 'label' => ' ', // the final label
1882  'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1883  ),
1884  'content' => array(
1885  'align' => 'L',
1886  'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1887  ),
1888  );
1889 
1890  // Image of product
1891  $rank = $rank + 10;
1892  $this->cols['photo'] = array(
1893  'rank' => $rank,
1894  'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1895  'status' => false,
1896  'title' => array(
1897  'textkey' => 'Photo',
1898  'label' => ' '
1899  ),
1900  'content' => array(
1901  'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1902  ),
1903  'border-left' => false, // remove left line separator
1904  );
1905 
1906  if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
1907  {
1908  $this->cols['photo']['status'] = true;
1909  }
1910 
1911 
1912  $rank = $rank + 10;
1913  $this->cols['vat'] = array(
1914  'rank' => $rank,
1915  'status' => false,
1916  'width' => 16, // in mm
1917  'title' => array(
1918  'textkey' => 'VAT'
1919  ),
1920  'border-left' => true, // add left line separator
1921  );
1922 
1923  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1924  {
1925  $this->cols['vat']['status'] = true;
1926  }
1927 
1928  $rank = $rank + 10;
1929  $this->cols['subprice'] = array(
1930  'rank' => $rank,
1931  'width' => 19, // in mm
1932  'status' => true,
1933  'title' => array(
1934  'textkey' => 'PriceUHT'
1935  ),
1936  'border-left' => true, // add left line separator
1937  );
1938 
1939  // Adapt dynamically the width of subprice, if text is too long.
1940  $tmpwidth = 0;
1941  $nblines = count($object->lines);
1942  for ($i = 0; $i < $nblines; $i++) {
1943  $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
1944  $tmpwidth = max($tmpwidth, $tmpwidth2);
1945  }
1946  if ($tmpwidth > 10) {
1947  $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
1948  }
1949 
1950  $rank = $rank + 10;
1951  $this->cols['qty'] = array(
1952  'rank' => $rank,
1953  'width' => 16, // in mm
1954  'status' => true,
1955  'title' => array(
1956  'textkey' => 'Qty'
1957  ),
1958  'border-left' => true, // add left line separator
1959  );
1960 
1961  $rank = $rank + 10;
1962  $this->cols['unit'] = array(
1963  'rank' => $rank,
1964  'width' => 11, // in mm
1965  'status' => false,
1966  'title' => array(
1967  'textkey' => 'Unit'
1968  ),
1969  'border-left' => true, // add left line separator
1970  );
1971  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1972  $this->cols['unit']['status'] = true;
1973  }
1974 
1975  $rank = $rank + 10;
1976  $this->cols['discount'] = array(
1977  'rank' => $rank,
1978  'width' => 13, // in mm
1979  'status' => false,
1980  'title' => array(
1981  'textkey' => 'ReductionShort'
1982  ),
1983  'border-left' => true, // add left line separator
1984  );
1985  if ($this->atleastonediscount) {
1986  $this->cols['discount']['status'] = true;
1987  }
1988 
1989  $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1990  $this->cols['totalexcltax'] = array(
1991  'rank' => $rank,
1992  'width' => 26, // in mm
1993  'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false,
1994  'title' => array(
1995  'textkey' => 'TotalHT'
1996  ),
1997  'border-left' => true, // add left line separator
1998  );
1999 
2000  $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
2001  $this->cols['totalincltax'] = array(
2002  'rank' => $rank,
2003  'width' => 26, // in mm
2004  'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true,
2005  'title' => array(
2006  'textkey' => 'TotalTTC'
2007  ),
2008  'border-left' => true, // add left line separator
2009  );
2010 
2011  // Add extrafields cols
2012  if (!empty($object->lines)) {
2013  $line = reset($object->lines);
2014  $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
2015  }
2016 
2017  $parameters = array(
2018  'object' => $object,
2019  'outputlangs' => $outputlangs,
2020  'hidedetails' => $hidedetails,
2021  'hidedesc' => $hidedesc,
2022  'hideref' => $hideref
2023  );
2024 
2025  $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
2026  if ($reshook < 0)
2027  {
2028  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2029  } elseif (empty($reshook))
2030  {
2031  $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
2032  } else {
2033  $this->cols = $hookmanager->resArray;
2034  }
2035  }
2036 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
Definition: pdf.lib.php:712
getExtrafieldContent($object, $extrafieldKey)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
__construct($db)
Constructor.
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
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
Put here description of your class.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
</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.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
Class to manage Dolibarr users.
Definition: user.class.php:44
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
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...
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
printStdColumnContent($pdf, &$curY, $colKey, $columnText= '')
print standard column content
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:222
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:1828
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
Classe mere des modeles de propale.
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.
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
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...
getColumnStatus($colKey)
get column status from column key
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition: pdf.lib.php:1952
Class to manage hooks.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1556
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1691
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
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
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1615
pdfGetHeightForHtmlContent(&$pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
Definition: pdf.lib.php:294
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
drawInfoTable(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
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
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition: pdf.lib.php:1869
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:270
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1135
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:643
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:88
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
Definition: pdf.lib.php:376
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '', $outputlangsbis=null)
Show table for lines.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
Class to generate PDF proposal Cyan.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
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...
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition: pdf.lib.php:2009