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