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