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