dolibarr 25.0.0-alpha
pdf_standard_asset.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-2026 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Nick Fragoulis
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 * or see https://www.gnu.org/
28 */
29
36require_once DOL_DOCUMENT_ROOT . '/core/modules/asset/modules_asset.php';
37require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
41
42
47{
51 public $db;
52
56 public $name;
57
61 public $description;
62
66 public $update_main_doc_field;
67
71 public $type;
72
77 public $version = 'dolibarr';
78
82 public $situationinvoice;
83
87 public $cols;
88
89
95 public function __construct($db)
96 {
97 global $conf, $langs, $mysoc;
98
99 // Translations
100 $langs->loadLangs(array("main", "bills"));
101
102 $this->db = $db;
103 $this->name = "standard";
104 $this->description = $langs->trans('DocumentModelStandardPDF');
105 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
106
107 // Dimension page
108 $this->type = 'pdf';
109 $formatarray = pdf_getFormat();
110 $this->page_largeur = $formatarray['width'];
111 $this->page_hauteur = $formatarray['height'];
112 $this->format = array($this->page_largeur, $this->page_hauteur);
113 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
114 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
115 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
116 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
117 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
118
119 // Define position of columns
120 $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff
121
122
123 $this->tabTitleHeight = 5; // default height
124
125 // Use new system for position of columns, view $this->defineColumnField()
126
127 $this->tva = array();
128 $this->localtax1 = array();
129 $this->localtax2 = array();
130 $this->atleastoneratenotnull = 0;
131 $this->atleastonediscount = 0;
132 $this->situationinvoice = false;
133
134 if ($mysoc === null) {
135 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
136 return;
137 }
138 // Get source company
139 $this->emetteur = $mysoc;
140 if (empty($this->emetteur->country_code)) {
141 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
142 }
143 }
144
145
146 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
158 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
159 {
160 // phpcs:enable
161 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
162
163 dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
164
165 if (!is_object($outputlangs)) {
166 $outputlangs = $langs;
167 }
168 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
169 if (getDolGlobalString('MAIN_USE_FPDF')) {
170 $outputlangs->charset_output = 'ISO-8859-1';
171 }
172
173 // Load translation files required by the page
174 $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
175
176 global $outputlangsbis;
177 $outputlangsbis = null;
178 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
179 $outputlangsbis = new Translate('', $conf);
180 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
181 $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
182 }
183
184 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
185
186 $hidetop = 0;
187 if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
188 $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
189 }
190
191 if ($conf->asset->dir_output.'/asset') {
192 $object->fetch_thirdparty();
193
194 // Definition of $dir and $file
195 if ($object->specimen) {
196 $dir = $conf->asset->dir_output.'/asset';
197 $file = $dir."/SPECIMEN.pdf";
198 } else {
199 $objectref = dol_sanitizeFileName($object->ref);
200 $dir = $conf->asset->dir_output.'/asset/'.$objectref;
201 $file = $dir."/".$objectref.".pdf";
202 }
203 if (!file_exists($dir)) {
204 if (dol_mkdir($dir) < 0) {
205 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
206 return 0;
207 }
208 }
209
210 if (file_exists($dir)) {
211 // Add pdfgeneration hook
212 if (!is_object($hookmanager)) {
213 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
214 $hookmanager = new HookManager($this->db);
215 }
216 $hookmanager->initHooks(array('pdfgeneration'));
217 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
218 global $action;
219 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
220
221 // Set nblines with the new facture lines content after hook
222 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
223
224 // Create pdf instance
225 $pdf = pdf_getInstance($this->format);
226 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
227 $pdf->setAutoPageBreak(true, 0);
228
229 $heightforinfotot = 50; // Height reserved to output the info and total part and payment part
230 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
231 $heightforfooter = $this->marge_basse + (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
232
233 if (class_exists('TCPDF')) {
234 $pdf->setPrintHeader(false);
235 $pdf->setPrintFooter(false);
236 }
237 $pdf->SetFont(pdf_getPDFFont($outputlangs));
238
239 // Set path to the background PDF File
240 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
241 $logodir = $conf->mycompany->dir_output;
242 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
243 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
244 }
245 $pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
246 $tplidx = $pdf->importPage(1);
247 }
248
249 $pdf->Open();
250 $pagenb = 0;
251 $pdf->SetDrawColor(128, 128, 128);
252
253 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
254 $pdf->SetSubject($outputlangs->transnoentities("PdfTitle"));
255 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
256
257 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
258 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfTitle")." ".$outputlangs->convToOutputCharset(is_object($object->thirdparty) ? (string) $object->thirdparty->name : ''));
259 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
260 $pdf->SetCompression(false);
261 }
262
263 // Set certificate
264 $cert = getDolUserString('CERTIFICATE_CRT', getDolGlobalString('CERTIFICATE_CRT'));
265 $certprivate = getDolUserString('CERTIFICATE_CRT_PRIVATE', getDolGlobalString('CERTIFICATE_CRT_PRIVATE'));
266
267 // If a certificate is found
268 if ($cert) {
269 $info = array(
270 'Name' => $this->emetteur->name,
271 'Location' => getCountry($this->emetteur->country_code, ''),
272 'Reason' => 'ASSET',
273 'ContactInfo' => $this->emetteur->email
274 );
275 $pdf->setSignature($cert, $certprivate, $this->emetteur->name, '', 2, $info);
276 }
277
278 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
279 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
280
281 // New page
282 $pdf->AddPage();
283 if (!empty($tplidx)) {
284 $pdf->useTemplate($tplidx);
285 }
286 $pagenb++;
287
288 $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
289 $pdf->SetFont('', '', $default_font_size - 1);
290 $pdf->MultiCell(0, 3, ''); // Set interline to 3
291 $pdf->SetTextColor(0, 0, 0);
292
293 $tab_top = 90 + $top_shift;
294 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
295 $tab_height = 130 - $top_shift;
296 $tab_height_newpage = 150;
297 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
298 $tab_height_newpage -= $top_shift;
299 }
300
301 $nexY = $tab_top - 1;
302
303 // Display notes
304 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
305 // Extrafields in note
306 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
307 if (!empty($extranote)) {
308 $notetoshow = dol_concatdesc($notetoshow, $extranote);
309 }
310
311 $pagenb = $pdf->getPage();
312 if ($notetoshow) {
313 $tab_top -= 2;
314
315 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
316 $pageposbeforenote = $pagenb;
317
318 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
319 complete_substitutions_array($substitutionarray, $outputlangs, $object);
320 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
321 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
322
323 $pdf->startTransaction();
324
325 $pdf->SetFont('', '', $default_font_size - 1);
326 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
327 // Description
328 $pageposafternote = $pdf->getPage();
329 $posyafter = $pdf->GetY();
330
331 if ($pageposafternote > $pageposbeforenote) {
332 $pdf->rollbackTransaction(true);
333
334 // prepare pages to receive notes
335 while ($pagenb < $pageposafternote) {
336 $pdf->AddPage();
337 $pagenb++;
338 if (!empty($tplidx)) {
339 $pdf->useTemplate($tplidx);
340 }
341 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
342 $this->_pagehead($pdf, $object, 0, $outputlangs);
343 }
344 // $this->_pagefoot($pdf,$object,$outputlangs,1);
345 $pdf->setTopMargin($tab_top_newpage);
346 // The only function to edit the bottom margin of current page to set it.
347 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
348 }
349
350 // back to start
351 $pdf->setPage($pageposbeforenote);
352 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
353 $pdf->SetFont('', '', $default_font_size - 1);
354 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
355 $pageposafternote = $pdf->getPage();
356
357 $posyafter = $pdf->GetY();
358
359 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
360 $pdf->AddPage('', '', true);
361 $pagenb++;
362 $pageposafternote++;
363 $pdf->setPage($pageposafternote);
364 $pdf->setTopMargin($tab_top_newpage);
365 // The only function to edit the bottom margin of current page to set it.
366 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
367 //$posyafter = $tab_top_newpage;
368 }
369
370
371 // apply note frame to previous pages
372 $i = $pageposbeforenote;
373 while ($i < $pageposafternote) {
374 $pdf->setPage($i);
375
376
377 $pdf->SetDrawColor(128, 128, 128);
378 // Draw note frame
379 if ($i > $pageposbeforenote) {
380 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
381 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
382 } else {
383 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
384 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
385 }
386
387 // Add footer
388 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
389 $this->_pagefoot($pdf, $object, $outputlangs, 1);
390
391 $i++;
392 }
393
394 // apply note frame to last page
395 $pdf->setPage($pageposafternote);
396 if (!empty($tplidx)) {
397 $pdf->useTemplate($tplidx);
398 }
399 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
400 $this->_pagehead($pdf, $object, 0, $outputlangs);
401 }
402 $height_note = $posyafter - $tab_top_newpage;
403 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
404 } else { // No pagebreak
405 $pdf->commitTransaction();
406 $posyafter = $pdf->GetY();
407 $height_note = $posyafter - $tab_top;
408 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
409
410
411 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
412 // not enough space, need to add page
413 $pdf->AddPage('', '', true);
414 $pagenb++;
415 $pageposafternote++;
416 $pdf->setPage($pageposafternote);
417 if (!empty($tplidx)) {
418 $pdf->useTemplate($tplidx);
419 }
420 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
421 $this->_pagehead($pdf, $object, 0, $outputlangs);
422 }
423
424 $posyafter = $tab_top_newpage;
425 }
426 }
427
428 $tab_height -= $height_note;
429 $tab_top = $posyafter + 6;
430 } else {
431 $height_note = 0;
432 }
433
434 // Use new auto column system
435 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
436
437 // Table simulation to know the height of the title line
438 $pdf->startTransaction();
439 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
440 $pdf->rollbackTransaction(true);
441
442 $nexY = $tab_top + $this->tabTitleHeight;
443
444 // Loop on each lines
445 $pageposbeforeprintlines = $pdf->getPage();
446 $pagenb = $pageposbeforeprintlines;
447 for ($i = 0; $i < $nblines; $i++) {
448 $curY = $nexY;
449 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
450 $pdf->SetTextColor(0, 0, 0);
451
452 $pdf->setTopMargin($tab_top_newpage);
453 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
454 $pageposbefore = $pdf->getPage();
455
456 $showpricebeforepagebreak = 1;
457 $posYAfterImage = 0;
458
459 // Description of product line
460 if ($this->getColumnStatus('desc')) {
461 $pdf->startTransaction();
462
463 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
464 $pageposafter = $pdf->getPage();
465
466 if ($pageposafter > $pageposbefore) { // There is a pagebreak
467 $pdf->rollbackTransaction(true);
468 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
469
470 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
471
472 $pageposafter = $pdf->getPage();
473 $posyafter = $pdf->GetY();
474 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
475 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
476 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
477 $pdf->AddPage('', '', true);
478 if (!empty($tplidx)) {
479 $pdf->useTemplate($tplidx);
480 }
481 $pdf->setPage($pageposafter + 1);
482 }
483 } else {
484 // We found a page break
485 // Allows data in the first page if description is long enough to break in multiples pages
486 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
487 $showpricebeforepagebreak = 1;
488 } else {
489 $showpricebeforepagebreak = 0;
490 }
491 }
492 } else { // No pagebreak
493 $pdf->commitTransaction();
494 }
495 }
496
497 $nexY = $pdf->GetY();
498 $pageposafter = $pdf->getPage();
499 $pdf->setPage($pageposbefore);
500 $pdf->setTopMargin($this->marge_haute);
501 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
502
503 // We suppose that a too long description were moved completely on next page
504 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
505 $pdf->setPage($pageposafter);
506 $curY = $tab_top_newpage;
507 }
508
509 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default
510
511 // Quantity
512 // Enough for 6 chars
513 if ($this->getColumnStatus('qty')) {
514 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
515 $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
516 $nexY = max($pdf->GetY(), $nexY);
517 }
518
519 // Extrafields
520 if (!empty($object->lines[$i]->array_options)) {
521 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
522 if ($this->getColumnStatus($extrafieldColKey)) {
523 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
524 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
525 $nexY = max($pdf->GetY(), $nexY);
526 }
527 }
528 }
529
530
531 $parameters = array(
532 'object' => $object,
533 'i' => $i,
534 'pdf' => & $pdf,
535 'curY' => & $curY,
536 'nexY' => & $nexY,
537 'outputlangs' => $outputlangs,
538 'hidedetails' => $hidedetails
539 );
540 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
541
542
543 $sign = 1;
544 // Collect total by value of vat rate into $this->tva["taux"]=total_tva
545 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
546 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation
547 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
548 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
549 } else {
550 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
551 }
552 } else {
553 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
554 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
555 } else {
556 $tvaligne = $sign * $object->lines[$i]->total_tva;
557 }
558 }
559
560 $localtax1ligne = $object->lines[$i]->total_localtax1;
561 $localtax2ligne = $object->lines[$i]->total_localtax2;
562 $localtax1_rate = $object->lines[$i]->localtax1_tx;
563 $localtax2_rate = $object->lines[$i]->localtax2_tx;
564 $localtax1_type = $object->lines[$i]->localtax1_type;
565 $localtax2_type = $object->lines[$i]->localtax2_type;
566
567 $vatrate = (string) $object->lines[$i]->tva_tx;
568
569 // Retrieve type from database for backward compatibility with old records
570 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
571 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
572 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
573 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
574 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
575 }
576
577 // retrieve global local tax
578 if ($localtax1_type && $localtax1ligne != 0) {
579 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
580 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
581 } else {
582 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
583 }
584 }
585 if ($localtax2_type && $localtax2ligne != 0) {
586 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
587 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
588 } else {
589 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
590 }
591 }
592
593 if (((int) $object->lines[$i]->info_bits & 0x01) == 0x01) {
594 $vatrate .= '*';
595 }
596 if (!isset($this->tva[$vatrate])) {
597 $this->tva[$vatrate] = 0;
598 }
599 $this->tva[$vatrate] += $tvaligne;
600
601 $nexY = max($nexY, $posYAfterImage);
602
603 // Add line
604 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
605 $pdf->setPage($pageposafter);
606 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
607 //$pdf->SetDrawColor(190,190,200);
608 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
609 $pdf->SetLineStyle(array('dash' => 0));
610 }
611
612 // Detect if some page were added automatically and output _tableau for past pages
613 while ($pagenb < $pageposafter) {
614 $pdf->setPage($pagenb);
615 if ($pagenb == $pageposbeforeprintlines) {
616 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
617 } else {
618 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
619 }
620 $this->_pagefoot($pdf, $object, $outputlangs, 1);
621 $pagenb++;
622 $pdf->setPage($pagenb);
623 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
624 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
625 $this->_pagehead($pdf, $object, 0, $outputlangs);
626 }
627 }
628
629 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
630 if ($pagenb == $pageposafter) {
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 // New page
637 $pdf->AddPage();
638 if (!empty($tplidx)) {
639 $pdf->useTemplate($tplidx);
640 }
641 $pagenb++;
642 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
643 $this->_pagehead($pdf, $object, 0, $outputlangs);
644 }
645 }
646 }
647
648 // Show square
649 if ($pagenb == $pageposbeforeprintlines) {
650 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
651 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652 } else {
653 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
654 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
655 }
656
657 // Display infos area
658 //$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
659
660 // Display total zone
661 //$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
662
663 // Display payment area
664 /*
665 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
666 {
667 $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
668 }
669 */
670
671 // Pagefoot
672 $this->_pagefoot($pdf, $object, $outputlangs);
673 if (method_exists($pdf, 'AliasNbPages')) {
674 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
675 }
676
677 $pdf->Close();
678
679 $pdf->Output($file, 'F');
680
681 // Add pdfgeneration hook
682 $hookmanager->initHooks(array('pdfgeneration'));
683 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
684 global $action;
685 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
686 $this->warnings = $hookmanager->warnings;
687 if ($reshook < 0) {
688 $this->error = $hookmanager->error;
689 $this->errors = $hookmanager->errors;
690 dolChmod($file);
691 return -1;
692 }
693
694 dolChmod($file);
695
696 $this->result = array('fullpath' => $file);
697
698 return 1; // No error
699 } else {
700 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
701 return 0;
702 }
703 } else {
704 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "ASSET_OUTPUTDIR");
705 return 0;
706 }
707 }
708
709 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
717 public static function liste_modeles($db, $maxfilenamelength = 0)
718 {
719 // phpcs:enable
720 return parent::liste_modeles($db, $maxfilenamelength); // TODO: Change the autogenerated stub
721 }
722
723 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
738 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
739 {
740 global $conf;
741
742 // Force to disable hidetop and hidebottom
743 $hidebottom = 0;
744 if ($hidetop) {
745 $hidetop = -1;
746 }
747
748 $currency = !empty($currency) ? $currency : getDolCurrency();
749 $default_font_size = pdf_getPDFFontSize($outputlangs);
750
751 // Amount in (at tab_top - 1)
752 $pdf->SetTextColor(0, 0, 0);
753 $pdf->SetFont('', '', $default_font_size - 2);
754
755 if (empty($hidetop)) {
756 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
757 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
758 $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
759 }
760
761 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
762 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
763
764 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
765 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
766 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
767 }
768 }
769
770 $pdf->SetDrawColor(128, 128, 128);
771 $pdf->SetFont('', '', $default_font_size - 1);
772
773 // Output Rect
774 $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter
775
776
777 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
778
779 if (empty($hidetop)) {
780 $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
781 }
782 }
783
784 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
795 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
796 {
797 global $conf, $langs;
798
799 // Load traductions files required by page
800 $outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
801
802 $default_font_size = pdf_getPDFFontSize($outputlangs);
803
804 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
805
806 // Show Draft Watermark
807 if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
808 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
809 }
810
811 $pdf->SetTextColor(0, 0, 60);
812 $pdf->SetFont('', 'B', $default_font_size + 3);
813
814 $w = 110;
815
816 $posy = $this->marge_haute;
817 $posx = $this->page_largeur - $this->marge_droite - $w;
818
819 $pdf->SetXY($this->marge_gauche, $posy);
820
821 // Logo
822 $logodir = $conf->mycompany->dir_output;
823 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
824 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
825 }
826 pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, 'L');
827
828 $pdf->SetFont('', 'B', $default_font_size + 3);
829 $pdf->SetXY($posx, $posy);
830 $pdf->SetTextColor(0, 0, 60);
831 $title = $outputlangs->transnoentities("PdfTitle");
832 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
833 $title .= ' - ';
834 $title .= $outputlangsbis->transnoentities("PdfTitle");
835 }
836 $pdf->MultiCell($w, 3, $title, '', 'R');
837
838 $pdf->SetFont('', 'B', $default_font_size);
839
840 $posy += 5;
841 $pdf->SetXY($posx, $posy);
842 $pdf->SetTextColor(0, 0, 60);
843 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
844 if ($object->status == $object::STATUS_DRAFT) {
845 $pdf->SetTextColor(128, 0, 0);
846 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
847 }
848 $pdf->MultiCell($w, 4, $textref, '', 'R');
849
850 $posy += 1;
851 $pdf->SetFont('', '', $default_font_size - 2);
852
853 // if ($object->ref_client) {
854 // $posy += 4;
855 // $pdf->SetXY($posx, $posy);
856 // $pdf->SetTextColor(0, 0, 60);
857 // $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
858 // }
859
860 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
861 $object->fetchProject();
862 if (!empty($object->project->ref)) {
863 $posy += 3;
864 $pdf->SetXY($posx, $posy);
865 $pdf->SetTextColor(0, 0, 60);
866 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : pdf_truncate_text($pdf, $object->project->title, 50)), '', 'R');
867 }
868 }
869
870 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
871 $object->fetchProject();
872 if (!empty($object->project->ref)) {
873 $outputlangs->load("projects");
874 $posy += 3;
875 $pdf->SetXY($posx, $posy);
876 $pdf->SetTextColor(0, 0, 60);
877 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
878 }
879 }
880
881 $posy += 4;
882 $pdf->SetXY($posx, $posy);
883 $pdf->SetTextColor(0, 0, 60);
884
885 $title = $outputlangs->transnoentities("Date");
886 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
887 $title .= ' - '.$outputlangsbis->transnoentities("Date");
888 }
889 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_acquisition, "day", false, $outputlangs), '', 'R');
890
891 if (is_object($object->thirdparty) && $object->thirdparty->code_client) {
892 $posy += 3;
893 $pdf->SetXY($posx, $posy);
894 $pdf->SetTextColor(0, 0, 60);
895 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_client), '', 'R');
896 }
897
898 // Get contact
899 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
900 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
901 if (count($arrayidcontact) > 0) {
902 $usertmp = new User($this->db);
903 $usertmp->fetch($arrayidcontact[0]);
904 $posy += 4;
905 $pdf->SetXY($posx, $posy);
906 $pdf->SetTextColor(0, 0, 60);
907 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
908 }
909 }
910
911 $posy += 1;
912
913 $top_shift = 0;
914 // Show list of linked objects
915 $current_y = $pdf->getY();
916 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
917 if ($current_y < $pdf->getY()) {
918 $top_shift = $pdf->getY() - $current_y;
919 }
920
921 if ($showaddress) {
922 // Sender properties
923 $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
924
925 // Show sender
926 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
927 $posy += $top_shift;
928 $posx = $this->marge_gauche;
929 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
930 $posx = $this->page_largeur - $this->marge_droite - 80;
931 }
932
933 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
934 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
935
936
937 // Show sender frame
938 $pdf->SetTextColor(0, 0, 0);
939 $pdf->SetFont('', '', $default_font_size - 2);
940 $pdf->SetXY($posx, $posy - 5);
941 $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
942 $pdf->SetXY($posx, $posy);
943 $pdf->SetFillColor(230, 230, 230);
944 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
945 $pdf->SetTextColor(0, 0, 60);
946
947 // Show sender name
948 $pdf->SetXY($posx + 2, $posy + 3);
949 $pdf->SetFont('', 'B', $default_font_size);
950 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset((string) $this->emetteur->name), 0, 'L');
951 $posy = $pdf->getY();
952
953 // Show sender information
954 $pdf->SetXY($posx + 2, $posy);
955 $pdf->SetFont('', '', $default_font_size - 1);
956 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
957
958 // If BILLING contact defined on invoice, we use it
959 $usecontact = false;
960 $arrayidcontact = $object->getIdContact('external', 'BILLING');
961 if (count($arrayidcontact) > 0) {
962 $usecontact = true;
963 $result = $object->fetch_contact($arrayidcontact[0]);
964 }
965
966 // Recipient name
967 if (is_object($object->contact) && is_object($object->thirdparty) && $object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
968 $thirdparty = $object->contact;
969 } else {
970 $thirdparty = $object->thirdparty;
971 }
972
973 if (is_object($thirdparty)) {
974 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
975 } else {
976 $carac_client_name = '';
977 }
978
979 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), 'target', $object);
980
981 // Show recipient
982 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
983 if ($this->page_largeur < 210) {
984 $widthrecbox = 84; // To work with US executive format
985 }
986 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
987 $posy += $top_shift;
988 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
989 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
990 $posx = $this->marge_gauche;
991 }
992
993 // Show recipient frame
994 $pdf->SetTextColor(0, 0, 0);
995 $pdf->SetFont('', '', $default_font_size - 2);
996 $pdf->SetXY($posx + 2, $posy - 5);
997 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
998 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
999
1000 // Show recipient name
1001 $pdf->SetXY($posx + 2, $posy + 3);
1002 $pdf->SetFont('', 'B', $default_font_size);
1003 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1004
1005 $posy = $pdf->getY();
1006
1007 // Show recipient information
1008 $pdf->SetFont('', '', $default_font_size - 1);
1009 $pdf->SetXY($posx + 2, $posy);
1010 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1011 }
1012
1013 $pdf->SetTextColor(0, 0, 0);
1014
1015 return $top_shift;
1016 }
1017
1018 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1028 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1029 {
1030 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1031 return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1032 }
1033
1044 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1045 {
1046 global $conf, $hookmanager;
1047
1048 // Default field style for content
1049 $this->defaultContentsFieldsStyle = array(
1050 'align' => 'R', // R,C,L
1051 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1052 );
1053
1054 // Default field style for content
1055 $this->defaultTitlesFieldsStyle = array(
1056 'align' => 'C', // R,C,L
1057 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1058 );
1059
1060 /*
1061 * For example
1062 $this->cols['theColKey'] = array(
1063 'rank' => $rank, // int : use for ordering columns
1064 'width' => 20, // the column width in mm
1065 'title' => array(
1066 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1067 'label' => ' ', // the final label : used fore final generated text
1068 'align' => 'L', // text alignment : R,C,L
1069 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1070 ),
1071 'content' => array(
1072 'align' => 'L', // text alignment : R,C,L
1073 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1074 ),
1075 );
1076 */
1077
1078 $rank = 0; // do not use negative rank
1079 $this->cols['desc'] = array(
1080 'rank' => $rank,
1081 'width' => false, // only for desc
1082 'status' => true,
1083 'title' => array(
1084 'textkey' => 'Designation', // use lang key is useful in some case with module
1085 'align' => 'L',
1086 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1087 // 'label' => ' ', // the final label
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',
1092 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1093 ),
1094 );
1095
1096 $rank += 10;
1097 $this->cols['vat'] = array(
1098 'rank' => $rank,
1099 'status' => false,
1100 'width' => 16.0, // in mm
1101 'title' => array(
1102 'textkey' => 'VAT'
1103 ),
1104 'border-left' => true, // add left line separator
1105 );
1106
1107 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
1108 $this->cols['vat']['status'] = true;
1109 }
1110
1111 $rank += 10;
1112 $this->cols['subprice'] = array(
1113 'rank' => $rank,
1114 'width' => 19.0, // in mm
1115 'status' => true,
1116 'title' => array(
1117 'textkey' => 'PriceUHT'
1118 ),
1119 'border-left' => true, // add left line separator
1120 );
1121
1122 $rank += 10;
1123 $this->cols['qty'] = array(
1124 'rank' => $rank,
1125 'width' => 16.0, // in mm
1126 'status' => true,
1127 'title' => array(
1128 'textkey' => 'Qty'
1129 ),
1130 'border-left' => true, // add left line separator
1131 );
1132
1133 $rank += 10;
1134 $this->cols['progress'] = array(
1135 'rank' => $rank,
1136 'width' => 19.0, // in mm
1137 'status' => false,
1138 'title' => array(
1139 'textkey' => 'Progress'
1140 ),
1141 'border-left' => true, // add left line separator
1142 );
1143
1144 if ($this->situationinvoice) {
1145 $this->cols['progress']['status'] = true;
1146 }
1147
1148 $rank += 10;
1149 $this->cols['unit'] = array(
1150 'rank' => $rank,
1151 'width' => 11.0, // in mm
1152 'status' => false,
1153 'title' => array(
1154 'textkey' => 'Unit'
1155 ),
1156 'border-left' => true, // add left line separator
1157 );
1158 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1159 $this->cols['unit']['status'] = true;
1160 }
1161
1162 $rank += 10;
1163 $this->cols['discount'] = array(
1164 'rank' => $rank,
1165 'width' => 13.0, // in mm
1166 'status' => false,
1167 'title' => array(
1168 'textkey' => 'ReductionShort'
1169 ),
1170 'border-left' => true, // add left line separator
1171 );
1172 if ($this->atleastonediscount) {
1173 $this->cols['discount']['status'] = true;
1174 }
1175
1176 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1177 $this->cols['totalexcltax'] = array(
1178 'rank' => $rank,
1179 'width' => 26.0, // in mm
1180 'status' => true,
1181 'title' => array(
1182 'textkey' => 'TotalHT'
1183 ),
1184 'border-left' => true, // add left line separator
1185 );
1186
1187 // Add extrafields cols
1188 if (!empty($object->lines)) {
1189 $line = reset($object->lines);
1190 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1191 }
1192
1193 $parameters = array(
1194 'object' => $object,
1195 'outputlangs' => $outputlangs,
1196 'hidedetails' => $hidedetails,
1197 'hidedesc' => $hidedesc,
1198 'hideref' => $hideref
1199 );
1200
1201 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1202 if ($reshook < 0) {
1203 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1204 } elseif (empty($reshook)) {
1205 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1206 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1207 } else {
1208 $this->cols = $hookmanager->resArray;
1209 }
1210 }
1211}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:280
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Class to manage hooks.
Parent class for documents models.
Class to manage translations.
Class to manage Dolibarr users.
Class to manage PDF template standard_asset.
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.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
global $mysoc
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(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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...
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
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...
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
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...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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 a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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_watermark($pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:1200
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1853
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:296
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:792
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:1466
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:275
pdf_truncate_text($pdf, $text, $max_width, $ellipsis_pos=1, $ellipsis="\u{2026}")
Truncates text to fit a specified width in TCPDF, with configurable ellipsis position.
Definition pdf.lib.php:3437
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:481
pdf_writeLogoOrCompanyName($pdf, $outputlangs, $emetteur, $logodir, $posx, $posy, $w, $default_font_size, $align)
Output company logo on top-left of a PDF page header, or the company name as fallback text if no logo...
Definition pdf.lib.php:351
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2610
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:1180
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:436
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140