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