dolibarr  13.0.2
pdf_standard_recruitmentjobposition.modules.php
1 <?php
2 /* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5  * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
11  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  * or see https://www.gnu.org/
26  */
27 
34 dol_include_once('/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php');
35 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
39 
40 
45 {
49  public $db;
50 
54  public $name;
55 
59  public $description;
60 
64  public $update_main_doc_field;
65 
69  public $type;
70 
75  public $phpmin = array(5, 5);
76 
81  public $version = 'dolibarr';
82 
86  public $page_largeur;
87 
91  public $page_hauteur;
92 
96  public $format;
97 
101  public $marge_gauche;
102 
106  public $marge_droite;
107 
111  public $marge_haute;
112 
116  public $marge_basse;
117 
122  public $emetteur;
123 
127  public $situationinvoice;
128 
129 
133  public $cols;
134 
135 
141  public function __construct($db)
142  {
143  global $conf, $langs, $mysoc;
144 
145  // Translations
146  $langs->loadLangs(array("main", "bills"));
147 
148  $this->db = $db;
149  $this->name = "standard";
150  $this->description = $langs->trans('DocumentModelStandardPDF');
151  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
152 
153  // Dimension page
154  $this->type = 'pdf';
155  $formatarray = pdf_getFormat();
156  $this->page_largeur = $formatarray['width'];
157  $this->page_hauteur = $formatarray['height'];
158  $this->format = array($this->page_largeur, $this->page_hauteur);
159  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
160  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
161  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
162  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
163 
164  $this->option_logo = 1; // Display logo
165  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
166  $this->option_modereg = 1; // Display payment mode
167  $this->option_condreg = 1; // Display payment terms
168  $this->option_codeproduitservice = 1; // Display product-service code
169  $this->option_multilang = 1; // Available in several languages
170  $this->option_escompte = 1; // Displays if there has been a discount
171  $this->option_credit_note = 1; // Support credit notes
172  $this->option_freetext = 1; // Support add of a personalised text
173  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
174 
175  // Get source company
176  $this->emetteur = $mysoc;
177  if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
178 
179  // Define position of columns
180  $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
181 
182 
183  $this->tabTitleHeight = 5; // default height
184 
185  // Use new system for position of columns, view $this->defineColumnField()
186 
187  $this->tva = array();
188  $this->localtax1 = array();
189  $this->localtax2 = array();
190  $this->atleastoneratenotnull = 0;
191  $this->atleastonediscount = 0;
192  $this->situationinvoice = false;
193  }
194 
195 
196  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
208  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
209  {
210  // phpcs:enable
211  global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
212 
213  dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
214 
215  if (!is_object($outputlangs)) $outputlangs = $langs;
216  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
217  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
218 
219  // Load translation files required by the page
220  $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
221 
222  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
223  global $outputlangsbis;
224  $outputlangsbis = new Translate('', $conf);
225  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
226  $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
227  }
228 
229  $nblines = (is_array($object->lines) ? count($object->lines) : 0);
230 
231  $hidetop = 0;
232  if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
233  $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
234  }
235 
236  // Loop on each lines to detect if there is at least one image to show
237  $realpatharray = array();
238  $this->atleastonephoto = false;
239  /*
240  if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE))
241  {
242  $objphoto = new Product($this->db);
243 
244  for ($i = 0; $i < $nblines; $i++)
245  {
246  if (empty($object->lines[$i]->fk_product)) continue;
247 
248  $objphoto->fetch($object->lines[$i]->fk_product);
249  //var_dump($objphoto->ref);exit;
250  if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
251  {
252  $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
253  $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
254  } else {
255  $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
256  $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
257  }
258 
259  $arephoto = false;
260  foreach ($pdir as $midir)
261  {
262  if (!$arephoto)
263  {
264  $dir = $conf->product->dir_output.'/'.$midir;
265 
266  foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
267  {
268  if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
269  {
270  if ($obj['photo_vignette'])
271  {
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) $realpatharray[$i] = $realpath;
288  }
289  }
290  */
291 
292  //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
293 
294  if ($conf->recruitment->dir_output.'/recruitmentjobposition')
295  {
296  $object->fetch_thirdparty();
297 
298  // Definition of $dir and $file
299  if ($object->specimen)
300  {
301  $dir = $conf->recruitment->dir_output.'/recruitmentjobposition';
302  $file = $dir."/SPECIMEN.pdf";
303  } else {
304  $objectref = dol_sanitizeFileName($object->ref);
305  $dir = $conf->recruitment->dir_output.'/recruitmentjobposition/'.$objectref;
306  $file = $dir."/".$objectref.".pdf";
307  }
308  if (!file_exists($dir))
309  {
310  if (dol_mkdir($dir) < 0)
311  {
312  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
313  return 0;
314  }
315  }
316 
317  if (file_exists($dir))
318  {
319  // Add pdfgeneration hook
320  if (!is_object($hookmanager))
321  {
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 facture lines content after hook
331  $nblines = (is_array($object->lines) ? count($object->lines) : 0);
332 
333  // Create pdf instance
334  $pdf = pdf_getInstance($this->format);
335  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
336  $pdf->SetAutoPageBreak(1, 0);
337 
338  $heightforinfotot = 50; // Height reserved to output the info and total part and payment part
339  $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
340  $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)
341 
342  if (class_exists('TCPDF'))
343  {
344  $pdf->setPrintHeader(false);
345  $pdf->setPrintFooter(false);
346  }
347  $pdf->SetFont(pdf_getPDFFont($outputlangs));
348 
349  // Set path to the background PDF File
350  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
351  {
352  $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
353  $tplidx = $pdf->importPage(1);
354  }
355 
356  $pdf->Open();
357  $pagenb = 0;
358  $pdf->SetDrawColor(128, 128, 128);
359 
360  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
361  $pdf->SetSubject($object->label);
362  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
363  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
364  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$object->label." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
365  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
366 
367  // Set certificate
368  $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
369  // If user has no certificate, we try to take the company one
370  if (!$cert) {
371  $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
372  }
373  // If a certificate is found
374  if ($cert) {
375  $info = array(
376  'Name' => $this->emetteur->name,
377  'Location' => getCountry($this->emetteur->country_code, 0),
378  'Reason' => 'MYOBJECT',
379  'ContactInfo' => $this->emetteur->email
380  );
381  $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
382  }
383 
384  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
385 
386  // New page
387  $pdf->AddPage();
388  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
389  $pagenb++;
390 
391  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
392  $pdf->SetFont('', '', $default_font_size - 1);
393  $pdf->MultiCell(0, 3, ''); // Set interline to 3
394  $pdf->SetTextColor(0, 0, 0);
395 
396  $tab_top = 90 + $top_shift;
397  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
398  $tab_height = 130 - $top_shift;
399  $tab_height_newpage = 150;
400  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
401 
402  $nexY = $tab_top - 1;
403 
404  // Display notes
405  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
406  // Extrafields in note
407  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
408  if (!empty($extranote))
409  {
410  $notetoshow = dol_concatdesc($notetoshow, $extranote);
411  }
412 
413  $pagenb = $pdf->getPage();
414  if ($notetoshow)
415  {
416  $tab_top -= 2;
417 
418  $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
419  $pageposbeforenote = $pagenb;
420 
421  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
422  complete_substitutions_array($substitutionarray, $outputlangs, $object);
423  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
424  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
425 
426  $pdf->startTransaction();
427 
428  $pdf->SetFont('', '', $default_font_size - 1);
429  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
430  // Description
431  $pageposafternote = $pdf->getPage();
432  $posyafter = $pdf->GetY();
433 
434  if ($pageposafternote > $pageposbeforenote)
435  {
436  $pdf->rollbackTransaction(true);
437 
438  // prepare pages to receive notes
439  while ($pagenb < $pageposafternote) {
440  $pdf->AddPage();
441  $pagenb++;
442  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
443  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
444  // $this->_pagefoot($pdf,$object,$outputlangs,1);
445  $pdf->setTopMargin($tab_top_newpage);
446  // The only function to edit the bottom margin of current page to set it.
447  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
448  }
449 
450  // back to start
451  $pdf->setPage($pageposbeforenote);
452  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
453  $pdf->SetFont('', '', $default_font_size - 1);
454  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
455  $pageposafternote = $pdf->getPage();
456 
457  $posyafter = $pdf->GetY();
458 
459  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
460  {
461  $pdf->AddPage('', '', true);
462  $pagenb++;
463  $pageposafternote++;
464  $pdf->setPage($pageposafternote);
465  $pdf->setTopMargin($tab_top_newpage);
466  // The only function to edit the bottom margin of current page to set it.
467  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
468  //$posyafter = $tab_top_newpage;
469  }
470 
471 
472  // apply note frame to previous pages
473  $i = $pageposbeforenote;
474  while ($i < $pageposafternote) {
475  $pdf->setPage($i);
476 
477 
478  $pdf->SetDrawColor(128, 128, 128);
479  // Draw note frame
480  if ($i > $pageposbeforenote) {
481  $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
482  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
483  } else {
484  $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
485  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
486  }
487 
488  // Add footer
489  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
490  $this->_pagefoot($pdf, $object, $outputlangs, 1);
491 
492  $i++;
493  }
494 
495  // apply note frame to last page
496  $pdf->setPage($pageposafternote);
497  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
498  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
499  $height_note = $posyafter - $tab_top_newpage;
500  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
501  } else // No pagebreak
502  {
503  $pdf->commitTransaction();
504  $posyafter = $pdf->GetY();
505  $height_note = $posyafter - $tab_top;
506  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
507 
508  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
509  {
510  // not enough space, need to add page
511  $pdf->AddPage('', '', true);
512  $pagenb++;
513  $pageposafternote++;
514  $pdf->setPage($pageposafternote);
515  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
516  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
517 
518  $posyafter = $tab_top_newpage;
519  }
520  }
521 
522  $tab_height = $tab_height - $height_note;
523  $tab_top = $posyafter + 6;
524  } else {
525  $height_note = 0;
526  }
527 
528  // Use new auto column system
529  $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
530 
531  // Table simulation to know the height of the title line
532  $pdf->startTransaction();
533  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
534  $pdf->rollbackTransaction(true);
535 
536  $nexY = $tab_top + $this->tabTitleHeight;
537 
538  // Loop on each lines
539  $pageposbeforeprintlines = $pdf->getPage();
540  $pagenb = $pageposbeforeprintlines;
541  for ($i = 0; $i < $nblines; $i++)
542  {
543  $curY = $nexY;
544  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
545  $pdf->SetTextColor(0, 0, 0);
546 
547  // Define size of image if we need it
548  $imglinesize = array();
549  if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
550 
551  $pdf->setTopMargin($tab_top_newpage);
552  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
553  $pageposbefore = $pdf->getPage();
554 
555  $showpricebeforepagebreak = 1;
556  $posYAfterImage = 0;
557 
558  if ($this->getColumnStatus('photo'))
559  {
560  // We start with Photo of product line
561  if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
562  {
563  $pdf->AddPage('', '', true);
564  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
565  $pdf->setPage($pageposbefore + 1);
566 
567  $curY = $tab_top_newpage;
568 
569  // Allows data in the first page if description is long enough to break in multiples pages
570  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
571  $showpricebeforepagebreak = 1;
572  else $showpricebeforepagebreak = 0;
573  }
574 
575  if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
576  {
577  $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
578  // $pdf->Image does not increase value return by getY, so we save it manually
579  $posYAfterImage = $curY + $imglinesize['height'];
580  }
581  }
582 
583  // Description of product line
584  if ($this->getColumnStatus('desc'))
585  {
586  $pdf->startTransaction();
587 
588  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
589  $pageposafter = $pdf->getPage();
590 
591  if ($pageposafter > $pageposbefore) // There is a pagebreak
592  {
593  $pdf->rollbackTransaction(true);
594  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
595 
596  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
597 
598  $pageposafter = $pdf->getPage();
599  $posyafter = $pdf->GetY();
600  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
601  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
602  {
603  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
604  {
605  $pdf->AddPage('', '', true);
606  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
607  $pdf->setPage($pageposafter + 1);
608  }
609  } else {
610  // We found a page break
611  // Allows data in the first page if description is long enough to break in multiples pages
612  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
613  $showpricebeforepagebreak = 1;
614  else $showpricebeforepagebreak = 0;
615  }
616  } else // No pagebreak
617  {
618  $pdf->commitTransaction();
619  }
620  }
621 
622  $nexY = $pdf->GetY();
623  $pageposafter = $pdf->getPage();
624  $pdf->setPage($pageposbefore);
625  $pdf->setTopMargin($this->marge_haute);
626  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
627 
628  // We suppose that a too long description or photo were moved completely on next page
629  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
630  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
631  }
632 
633  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
634 
635 
636 
637  $parameters = array(
638  'object' => $object,
639  'i' => $i,
640  'pdf' =>& $pdf,
641  'curY' =>& $curY,
642  'nexY' =>& $nexY,
643  'outputlangs' => $outputlangs,
644  'hidedetails' => $hidedetails
645  );
646  $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
647 
648 
649 
650  // Detect if some page were added automatically and output _tableau for past pages
651  while ($pagenb < $pageposafter) {
652  $pdf->setPage($pagenb);
653  if ($pagenb == $pageposbeforeprintlines) {
654  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
655  } else {
656  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
657  }
658  $this->_pagefoot($pdf, $object, $outputlangs, 1);
659  $pagenb++;
660  $pdf->setPage($pagenb);
661  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
662  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
663  }
664 
665  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
666  if ($pagenb == $pageposafter) {
667  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
668  } else {
669  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
670  }
671  $this->_pagefoot($pdf, $object, $outputlangs, 1);
672  // New page
673  $pdf->AddPage();
674  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
675  $pagenb++;
676  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
677  }
678  }
679 
680  // Show square
681  if ($pagenb == $pageposbeforeprintlines)
682  {
683  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
684  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
685  } else {
686  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
687  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
688  }
689 
690  // Display infos area
691  //$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
692 
693  // Display total zone
694  //$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
695 
696  // Display payment area
697  /*
698  if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
699  {
700  $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
701  }
702  */
703 
704  // Pagefoot
705  $this->_pagefoot($pdf, $object, $outputlangs);
706  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
707 
708  $pdf->Close();
709 
710  $pdf->Output($file, 'F');
711 
712  // Add pdfgeneration hook
713  $hookmanager->initHooks(array('pdfgeneration'));
714  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
715  global $action;
716  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
717  if ($reshook < 0)
718  {
719  $this->error = $hookmanager->error;
720  $this->errors = $hookmanager->errors;
721  }
722 
723  if (!empty($conf->global->MAIN_UMASK))
724  @chmod($file, octdec($conf->global->MAIN_UMASK));
725 
726  $this->result = array('fullpath'=>$file);
727 
728  return 1; // No error
729  } else {
730  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
731  return 0;
732  }
733  } else {
734  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
735  return 0;
736  }
737  }
738 
739  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
747  public static function liste_modeles($db, $maxfilenamelength = 0)
748  {
749  // phpcs:enable
750  return parent::liste_modeles($db, $maxfilenamelength); // TODO: Change the autogenerated stub
751  }
752 
753  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
768  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
769  {
770  global $conf;
771 
772  // Force to disable hidetop and hidebottom
773  $hidebottom = 0;
774  if ($hidetop) $hidetop = -1;
775 
776  $currency = !empty($currency) ? $currency : $conf->currency;
777  $default_font_size = pdf_getPDFFontSize($outputlangs);
778 
779  // Amount in (at tab_top - 1)
780  $pdf->SetTextColor(0, 0, 0);
781  $pdf->SetFont('', '', $default_font_size - 2);
782 
783  if (empty($hidetop))
784  {
785  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
786  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
787  $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));
788  }
789  }
790 
791  $pdf->SetDrawColor(128, 128, 128);
792  $pdf->SetFont('', '', $default_font_size - 1);
793 
794  // Output Rect
795  $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
796 
797 
798  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
799 
800  if (empty($hidetop)) {
801  $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
802  }
803  }
804 
805  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
816  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
817  {
818  global $conf, $langs;
819 
820  // Load traductions files required by page
821  $outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
822 
823  $default_font_size = pdf_getPDFFontSize($outputlangs);
824 
825  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
826 
827  // Show Draft Watermark
828  if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
829  {
830  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
831  }
832 
833  $pdf->SetTextColor(0, 0, 60);
834  $pdf->SetFont('', 'B', $default_font_size + 3);
835 
836  $w = 110;
837 
838  $posy = $this->marge_haute;
839  $posx = $this->page_largeur - $this->marge_droite - $w;
840 
841  $pdf->SetXY($this->marge_gauche, $posy);
842 
843  // Logo
844  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
845  {
846  if ($this->emetteur->logo)
847  {
848  $logodir = $conf->mycompany->dir_output;
849  if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
850  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
851  {
852  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
853  } else {
854  $logo = $logodir.'/logos/'.$this->emetteur->logo;
855  }
856  if (is_readable($logo))
857  {
858  $height = pdf_getHeightForLogo($logo);
859  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
860  } else {
861  $pdf->SetTextColor(200, 0, 0);
862  $pdf->SetFont('', 'B', $default_font_size - 2);
863  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
864  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
865  }
866  } else {
867  $text = $this->emetteur->name;
868  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
869  }
870  }
871 
872  $pdf->SetFont('', 'B', $default_font_size + 3);
873  $pdf->SetXY($posx, $posy);
874  $pdf->SetTextColor(0, 0, 60);
875  $title = $object->label;
876  /*if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
877  $title .= ' - ';
878  $title .= $outputlangsbis->transnoentities("JobPosition");
879  }*/
880  $pdf->MultiCell($w, 3, $title, '', 'R');
881 
882  $pdf->SetFont('', 'B', $default_font_size);
883 
884  $posy += 5;
885  $pdf->SetXY($posx, $posy);
886  $pdf->SetTextColor(0, 0, 60);
887  $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
888  if ($object->statut == $object::STATUS_DRAFT)
889  {
890  $pdf->SetTextColor(128, 0, 0);
891  $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
892  }
893  $pdf->MultiCell($w, 4, $textref, '', 'R');
894 
895  $posy += 1;
896  $pdf->SetFont('', '', $default_font_size - 2);
897 
898  if ($object->ref_client)
899  {
900  $posy += 4;
901  $pdf->SetXY($posx, $posy);
902  $pdf->SetTextColor(0, 0, 60);
903  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
904  }
905 
906  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
907  {
908  $object->fetch_projet();
909  if (!empty($object->project->ref))
910  {
911  $posy += 3;
912  $pdf->SetXY($posx, $posy);
913  $pdf->SetTextColor(0, 0, 60);
914  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
915  }
916  }
917 
918  if (!empty($conf->global->PDF_SHOW_PROJECT))
919  {
920  $object->fetch_projet();
921  if (!empty($object->project->ref))
922  {
923  $posy += 3;
924  $pdf->SetXY($posx, $posy);
925  $pdf->SetTextColor(0, 0, 60);
926  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
927  }
928  }
929 
930  $posy += 4;
931  $pdf->SetXY($posx, $posy);
932  $pdf->SetTextColor(0, 0, 60);
933 
934  $title = $outputlangs->transnoentities("Date");
935  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
936  $title .= ' - '.$outputlangsbis->transnoentities("Date");
937  }
938  $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_creation, "day", false, $outputlangs), '', 'R');
939 
940  if ($object->thirdparty->code_client)
941  {
942  $posy += 3;
943  $pdf->SetXY($posx, $posy);
944  $pdf->SetTextColor(0, 0, 60);
945  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
946  }
947 
948  $posy += 1;
949 
950  $top_shift = 0;
951  // Show list of linked objects
952  $current_y = $pdf->getY();
953  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
954  if ($current_y < $pdf->getY())
955  {
956  $top_shift = $pdf->getY() - $current_y;
957  }
958 
959  if ($showaddress)
960  {
961  // Sender properties
962  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
963 
964  // Show sender
965  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
966  $posy += $top_shift;
967  $posx = $this->marge_gauche;
968  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
969 
970  $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
971  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
972 
973 
974  // Show sender frame
975  $pdf->SetTextColor(0, 0, 0);
976  $pdf->SetFont('', '', $default_font_size - 2);
977  $pdf->SetXY($posx, $posy - 5);
978  $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
979  $pdf->SetXY($posx, $posy);
980  $pdf->SetFillColor(230, 230, 230);
981  $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
982  $pdf->SetTextColor(0, 0, 60);
983 
984  // Show sender name
985  $pdf->SetXY($posx + 2, $posy + 3);
986  $pdf->SetFont('', 'B', $default_font_size);
987  $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
988  $posy = $pdf->getY();
989 
990  // Show sender information
991  $pdf->SetXY($posx + 2, $posy);
992  $pdf->SetFont('', '', $default_font_size - 1);
993  $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
994 
995  // If BILLING contact defined on invoice, we use it
996  $usecontact = false;
997  $arrayidcontact = $object->getIdContact('external', 'BILLING');
998  if (count($arrayidcontact) > 0)
999  {
1000  $usecontact = true;
1001  $result = $object->fetch_contact($arrayidcontact[0]);
1002  }
1003 
1004  // Recipient name
1005  /*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)))) {
1006  $thirdparty = $object->contact;
1007  } else {
1008  $thirdparty = $object->thirdparty;
1009  }
1010 
1011  if (is_object($thirdparty)) {
1012  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1013  }
1014 
1015  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1016 
1017  // Show recipient
1018  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1019  if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1020  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1021  $posy += $top_shift;
1022  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1023  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1024 
1025  // Show recipient frame
1026  $pdf->SetTextColor(0, 0, 0);
1027  $pdf->SetFont('', '', $default_font_size - 2);
1028  $pdf->SetXY($posx + 2, $posy - 5);
1029  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1030  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1031 
1032  // Show recipient name
1033  $pdf->SetXY($posx + 2, $posy + 3);
1034  $pdf->SetFont('', 'B', $default_font_size);
1035  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1036 
1037  $posy = $pdf->getY();
1038 
1039  // Show recipient information
1040  $pdf->SetFont('', '', $default_font_size - 1);
1041  $pdf->SetXY($posx + 2, $posy);
1042  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1043  */
1044  }
1045 
1046  $pdf->SetTextColor(0, 0, 0);
1047  return $top_shift;
1048  }
1049 
1050  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1060  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1061  {
1062  global $conf;
1063  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1064  return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1065  }
1066 
1077  public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1078  {
1079  global $conf, $hookmanager;
1080 
1081  // Default field style for content
1082  $this->defaultContentsFieldsStyle = array(
1083  'align' => 'R', // R,C,L
1084  'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1085  );
1086 
1087  // Default field style for content
1088  $this->defaultTitlesFieldsStyle = array(
1089  'align' => 'C', // R,C,L
1090  'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1091  );
1092 
1093  /*
1094  * For exemple
1095  $this->cols['theColKey'] = array(
1096  'rank' => $rank, // int : use for ordering columns
1097  'width' => 20, // the column width in mm
1098  'title' => array(
1099  'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1100  'label' => ' ', // the final label : used fore final generated text
1101  'align' => 'L', // text alignement : R,C,L
1102  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1103  ),
1104  'content' => array(
1105  'align' => 'L', // text alignement : R,C,L
1106  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1107  ),
1108  );
1109  */
1110 
1111  $rank = 0; // do not use negative rank
1112  /*
1113  $this->cols['desc'] = array(
1114  'rank' => $rank,
1115  'width' => false, // only for desc
1116  'status' => true,
1117  'title' => array(
1118  'textkey' => 'Designation', // use lang key is usefull in somme case with module
1119  'align' => 'L',
1120  // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1121  // 'label' => ' ', // the final label
1122  'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1123  ),
1124  'content' => array(
1125  'align' => 'L',
1126  'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1127  ),
1128  );
1129 
1130  // PHOTO
1131  $rank = $rank + 10;
1132  $this->cols['photo'] = array(
1133  'rank' => $rank,
1134  'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1135  'status' => false,
1136  'title' => array(
1137  'textkey' => 'Photo',
1138  'label' => ' '
1139  ),
1140  'content' => array(
1141  'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1142  ),
1143  'border-left' => false, // remove left line separator
1144  );
1145 
1146  if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
1147  {
1148  $this->cols['photo']['status'] = true;
1149  }
1150 
1151 
1152  $rank = $rank + 10;
1153  $this->cols['vat'] = array(
1154  'rank' => $rank,
1155  'status' => false,
1156  'width' => 16, // in mm
1157  'title' => array(
1158  'textkey' => 'VAT'
1159  ),
1160  'border-left' => true, // add left line separator
1161  );
1162 
1163  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1164  {
1165  $this->cols['vat']['status'] = true;
1166  }
1167 
1168  $rank = $rank + 10;
1169  $this->cols['subprice'] = array(
1170  'rank' => $rank,
1171  'width' => 19, // in mm
1172  'status' => true,
1173  'title' => array(
1174  'textkey' => 'PriceUHT'
1175  ),
1176  'border-left' => true, // add left line separator
1177  );
1178 
1179  $rank = $rank + 10;
1180  $this->cols['qty'] = array(
1181  'rank' => $rank,
1182  'width' => 16, // in mm
1183  'status' => true,
1184  'title' => array(
1185  'textkey' => 'Qty'
1186  ),
1187  'border-left' => true, // add left line separator
1188  );
1189 
1190  $rank = $rank + 10;
1191  $this->cols['progress'] = array(
1192  'rank' => $rank,
1193  'width' => 19, // in mm
1194  'status' => false,
1195  'title' => array(
1196  'textkey' => 'Progress'
1197  ),
1198  'border-left' => true, // add left line separator
1199  );
1200 
1201  if ($this->situationinvoice)
1202  {
1203  $this->cols['progress']['status'] = true;
1204  }
1205 
1206  $rank = $rank + 10;
1207  $this->cols['unit'] = array(
1208  'rank' => $rank,
1209  'width' => 11, // in mm
1210  'status' => false,
1211  'title' => array(
1212  'textkey' => 'Unit'
1213  ),
1214  'border-left' => true, // add left line separator
1215  );
1216  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1217  $this->cols['unit']['status'] = true;
1218  }
1219 
1220  $rank = $rank + 10;
1221  $this->cols['discount'] = array(
1222  'rank' => $rank,
1223  'width' => 13, // in mm
1224  'status' => false,
1225  'title' => array(
1226  'textkey' => 'ReductionShort'
1227  ),
1228  'border-left' => true, // add left line separator
1229  );
1230  if ($this->atleastonediscount) {
1231  $this->cols['discount']['status'] = true;
1232  }
1233 
1234  $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1235  $this->cols['totalexcltax'] = array(
1236  'rank' => $rank,
1237  'width' => 26, // in mm
1238  'status' => true,
1239  'title' => array(
1240  'textkey' => 'TotalHT'
1241  ),
1242  'border-left' => true, // add left line separator
1243  );
1244 
1245  // Add extrafields cols
1246  if (!empty($object->lines)) {
1247  $line = reset($object->lines);
1248  $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1249  }
1250  */
1251 
1252  $parameters = array(
1253  'object' => $object,
1254  'outputlangs' => $outputlangs,
1255  'hidedetails' => $hidedetails,
1256  'hidedesc' => $hidedesc,
1257  'hideref' => $hideref
1258  );
1259 
1260  $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1261  if ($reshook < 0)
1262  {
1263  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1264  } elseif (empty($reshook))
1265  {
1266  $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1267  } else {
1268  $this->cols = $hookmanager->resArray;
1269  }
1270  }
1271 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
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.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
</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
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '', $outputlangsbis=null)
Show table for lines.
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...
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:222
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
$conf db
API class for accounts.
Definition: inc.php:54
getColumnStatus($colKey)
get column status from column key
Class to manage hooks.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
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
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Class to manage PDF template standard_recruitmentjobposition.
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition: pdf.lib.php:2221
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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...
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).
Parent class for documents models.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
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...