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