dolibarr 24.0.2
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 // TODO remise_percent is an obsolete field for object parent
568 /*if ($object->remise_percent) {
569 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
570 }
571 if ($object->remise_percent) {
572 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
573 }
574 if ($object->remise_percent) {
575 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
576 }*/
577
578 $vatrate = (string) $object->lines[$i]->tva_tx;
579
580 // Retrieve type from database for backward compatibility with old records
581 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
582 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
583 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
584 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
585 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
586 }
587
588 // retrieve global local tax
589 if ($localtax1_type && $localtax1ligne != 0) {
590 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
591 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
592 } else {
593 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
594 }
595 }
596 if ($localtax2_type && $localtax2ligne != 0) {
597 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
598 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
599 } else {
600 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
601 }
602 }
603
604 if (((int) $object->lines[$i]->info_bits & 0x01) == 0x01) {
605 $vatrate .= '*';
606 }
607 if (!isset($this->tva[$vatrate])) {
608 $this->tva[$vatrate] = 0;
609 }
610 $this->tva[$vatrate] += $tvaligne;
611
612 $nexY = max($nexY, $posYAfterImage);
613
614 // Add line
615 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
616 $pdf->setPage($pageposafter);
617 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
618 //$pdf->SetDrawColor(190,190,200);
619 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
620 $pdf->SetLineStyle(array('dash' => 0));
621 }
622
623 // Detect if some page were added automatically and output _tableau for past pages
624 while ($pagenb < $pageposafter) {
625 $pdf->setPage($pagenb);
626 if ($pagenb == $pageposbeforeprintlines) {
627 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
628 } else {
629 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
630 }
631 $this->_pagefoot($pdf, $object, $outputlangs, 1);
632 $pagenb++;
633 $pdf->setPage($pagenb);
634 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
635 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
636 $this->_pagehead($pdf, $object, 0, $outputlangs);
637 }
638 }
639
640 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
641 if ($pagenb == $pageposafter) {
642 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
643 } else {
644 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
645 }
646 $this->_pagefoot($pdf, $object, $outputlangs, 1);
647 // New page
648 $pdf->AddPage();
649 if (!empty($tplidx)) {
650 $pdf->useTemplate($tplidx);
651 }
652 $pagenb++;
653 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
654 $this->_pagehead($pdf, $object, 0, $outputlangs);
655 }
656 }
657 }
658
659 // Show square
660 if ($pagenb == $pageposbeforeprintlines) {
661 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
662 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
663 } else {
664 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
665 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 }
667
668 // Display infos area
669 //$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
670
671 // Display total zone
672 //$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
673
674 // Display payment area
675 /*
676 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
677 {
678 $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
679 }
680 */
681
682 // Pagefoot
683 $this->_pagefoot($pdf, $object, $outputlangs);
684 if (method_exists($pdf, 'AliasNbPages')) {
685 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
686 }
687
688 $pdf->Close();
689
690 $pdf->Output($file, 'F');
691
692 // Add pdfgeneration hook
693 $hookmanager->initHooks(array('pdfgeneration'));
694 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
695 global $action;
696 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
697 $this->warnings = $hookmanager->warnings;
698 if ($reshook < 0) {
699 $this->error = $hookmanager->error;
700 $this->errors = $hookmanager->errors;
701 dolChmod($file);
702 return -1;
703 }
704
705 dolChmod($file);
706
707 $this->result = array('fullpath' => $file);
708
709 return 1; // No error
710 } else {
711 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
712 return 0;
713 }
714 } else {
715 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "ASSET_OUTPUTDIR");
716 return 0;
717 }
718 }
719
720 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
728 public static function liste_modeles($db, $maxfilenamelength = 0)
729 {
730 // phpcs:enable
731 return parent::liste_modeles($db, $maxfilenamelength); // TODO: Change the autogenerated stub
732 }
733
734 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
749 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
750 {
751 global $conf;
752
753 // Force to disable hidetop and hidebottom
754 $hidebottom = 0;
755 if ($hidetop) {
756 $hidetop = -1;
757 }
758
759 $currency = !empty($currency) ? $currency : getDolCurrency();
760 $default_font_size = pdf_getPDFFontSize($outputlangs);
761
762 // Amount in (at tab_top - 1)
763 $pdf->SetTextColor(0, 0, 0);
764 $pdf->SetFont('', '', $default_font_size - 2);
765
766 if (empty($hidetop)) {
767 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
768 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
769 $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
770 }
771
772 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
773 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
774
775 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
776 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
777 $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')));
778 }
779 }
780
781 $pdf->SetDrawColor(128, 128, 128);
782 $pdf->SetFont('', '', $default_font_size - 1);
783
784 // Output Rect
785 $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
786
787
788 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
789
790 if (empty($hidetop)) {
791 $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
792 }
793 }
794
795 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
806 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
807 {
808 global $conf, $langs;
809
810 // Load traductions files required by page
811 $outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
812
813 $default_font_size = pdf_getPDFFontSize($outputlangs);
814
815 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
816
817 // Show Draft Watermark
818 if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
819 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
820 }
821
822 $pdf->SetTextColor(0, 0, 60);
823 $pdf->SetFont('', 'B', $default_font_size + 3);
824
825 $w = 110;
826
827 $posy = $this->marge_haute;
828 $posx = $this->page_largeur - $this->marge_droite - $w;
829
830 $pdf->SetXY($this->marge_gauche, $posy);
831
832 // Logo
833 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
834 if ($this->emetteur->logo) {
835 $logodir = $conf->mycompany->dir_output;
836 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
837 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
838 }
839 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
840 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
841 } else {
842 $logo = $logodir.'/logos/'.$this->emetteur->logo;
843 }
844 if (is_readable($logo)) {
845 $height = pdf_getHeightForLogo($logo);
846 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
847 } else {
848 $pdf->SetTextColor(200, 0, 0);
849 $pdf->SetFont('', 'B', $default_font_size - 2);
850 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
851 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
852 }
853 } else {
854 $text = (string) $this->emetteur->name;
855 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
856 }
857 }
858
859 $pdf->SetFont('', 'B', $default_font_size + 3);
860 $pdf->SetXY($posx, $posy);
861 $pdf->SetTextColor(0, 0, 60);
862 $title = $outputlangs->transnoentities("PdfTitle");
863 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
864 $title .= ' - ';
865 $title .= $outputlangsbis->transnoentities("PdfTitle");
866 }
867 $pdf->MultiCell($w, 3, $title, '', 'R');
868
869 $pdf->SetFont('', 'B', $default_font_size);
870
871 $posy += 5;
872 $pdf->SetXY($posx, $posy);
873 $pdf->SetTextColor(0, 0, 60);
874 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
875 if ($object->status == $object::STATUS_DRAFT) {
876 $pdf->SetTextColor(128, 0, 0);
877 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
878 }
879 $pdf->MultiCell($w, 4, $textref, '', 'R');
880
881 $posy += 1;
882 $pdf->SetFont('', '', $default_font_size - 2);
883
884 // if ($object->ref_client) {
885 // $posy += 4;
886 // $pdf->SetXY($posx, $posy);
887 // $pdf->SetTextColor(0, 0, 60);
888 // $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
889 // }
890
891 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
892 $object->fetchProject();
893 if (!empty($object->project->ref)) {
894 $posy += 3;
895 $pdf->SetXY($posx, $posy);
896 $pdf->SetTextColor(0, 0, 60);
897 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : dol_trunc($object->project->title, 50)), '', 'R');
898 }
899 }
900
901 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
902 $object->fetchProject();
903 if (!empty($object->project->ref)) {
904 $outputlangs->load("projects");
905 $posy += 3;
906 $pdf->SetXY($posx, $posy);
907 $pdf->SetTextColor(0, 0, 60);
908 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
909 }
910 }
911
912 $posy += 4;
913 $pdf->SetXY($posx, $posy);
914 $pdf->SetTextColor(0, 0, 60);
915
916 $title = $outputlangs->transnoentities("Date");
917 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
918 $title .= ' - '.$outputlangsbis->transnoentities("Date");
919 }
920 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_acquisition, "day", false, $outputlangs), '', 'R');
921
922 if (is_object($object->thirdparty) && $object->thirdparty->code_client) {
923 $posy += 3;
924 $pdf->SetXY($posx, $posy);
925 $pdf->SetTextColor(0, 0, 60);
926 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_client), '', 'R');
927 }
928
929 // Get contact
930 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
931 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
932 if (count($arrayidcontact) > 0) {
933 $usertmp = new User($this->db);
934 $usertmp->fetch($arrayidcontact[0]);
935 $posy += 4;
936 $pdf->SetXY($posx, $posy);
937 $pdf->SetTextColor(0, 0, 60);
938 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
939 }
940 }
941
942 $posy += 1;
943
944 $top_shift = 0;
945 // Show list of linked objects
946 $current_y = $pdf->getY();
947 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
948 if ($current_y < $pdf->getY()) {
949 $top_shift = $pdf->getY() - $current_y;
950 }
951
952 if ($showaddress) {
953 // Sender properties
954 $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
955
956 // Show sender
957 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
958 $posy += $top_shift;
959 $posx = $this->marge_gauche;
960 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
961 $posx = $this->page_largeur - $this->marge_droite - 80;
962 }
963
964 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
965 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
966
967
968 // Show sender frame
969 $pdf->SetTextColor(0, 0, 0);
970 $pdf->SetFont('', '', $default_font_size - 2);
971 $pdf->SetXY($posx, $posy - 5);
972 $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
973 $pdf->SetXY($posx, $posy);
974 $pdf->SetFillColor(230, 230, 230);
975 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
976 $pdf->SetTextColor(0, 0, 60);
977
978 // Show sender name
979 $pdf->SetXY($posx + 2, $posy + 3);
980 $pdf->SetFont('', 'B', $default_font_size);
981 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset((string) $this->emetteur->name), 0, 'L');
982 $posy = $pdf->getY();
983
984 // Show sender information
985 $pdf->SetXY($posx + 2, $posy);
986 $pdf->SetFont('', '', $default_font_size - 1);
987 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
988
989 // If BILLING contact defined on invoice, we use it
990 $usecontact = false;
991 $arrayidcontact = $object->getIdContact('external', 'BILLING');
992 if (count($arrayidcontact) > 0) {
993 $usecontact = true;
994 $result = $object->fetch_contact($arrayidcontact[0]);
995 }
996
997 // Recipient name
998 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'))) {
999 $thirdparty = $object->contact;
1000 } else {
1001 $thirdparty = $object->thirdparty;
1002 }
1003
1004 if (is_object($thirdparty)) {
1005 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1006 } else {
1007 $carac_client_name = '';
1008 }
1009
1010 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), 'target', $object);
1011
1012 // Show recipient
1013 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1014 if ($this->page_largeur < 210) {
1015 $widthrecbox = 84; // To work with US executive format
1016 }
1017 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1018 $posy += $top_shift;
1019 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1020 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1021 $posx = $this->marge_gauche;
1022 }
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->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
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 $pdf->SetTextColor(0, 0, 0);
1045
1046 return $top_shift;
1047 }
1048
1049 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1059 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1060 {
1061 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1062 return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1063 }
1064
1075 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1076 {
1077 global $conf, $hookmanager;
1078
1079 // Default field style for content
1080 $this->defaultContentsFieldsStyle = array(
1081 'align' => 'R', // R,C,L
1082 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1083 );
1084
1085 // Default field style for content
1086 $this->defaultTitlesFieldsStyle = array(
1087 'align' => 'C', // R,C,L
1088 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1089 );
1090
1091 /*
1092 * For example
1093 $this->cols['theColKey'] = array(
1094 'rank' => $rank, // int : use for ordering columns
1095 'width' => 20, // the column width in mm
1096 'title' => array(
1097 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1098 'label' => ' ', // the final label : used fore final generated text
1099 'align' => 'L', // text alignment : R,C,L
1100 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1101 ),
1102 'content' => array(
1103 'align' => 'L', // text alignment : R,C,L
1104 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1105 ),
1106 );
1107 */
1108
1109 $rank = 0; // do not use negative rank
1110 $this->cols['desc'] = array(
1111 'rank' => $rank,
1112 'width' => false, // only for desc
1113 'status' => true,
1114 'title' => array(
1115 'textkey' => 'Designation', // use lang key is useful in some case with module
1116 'align' => 'L',
1117 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1118 // 'label' => ' ', // the final label
1119 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1120 ),
1121 'content' => array(
1122 'align' => 'L',
1123 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1124 ),
1125 );
1126
1127 $rank += 10;
1128 $this->cols['vat'] = array(
1129 'rank' => $rank,
1130 'status' => false,
1131 'width' => 16.0, // in mm
1132 'title' => array(
1133 'textkey' => 'VAT'
1134 ),
1135 'border-left' => true, // add left line separator
1136 );
1137
1138 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
1139 $this->cols['vat']['status'] = true;
1140 }
1141
1142 $rank += 10;
1143 $this->cols['subprice'] = array(
1144 'rank' => $rank,
1145 'width' => 19.0, // in mm
1146 'status' => true,
1147 'title' => array(
1148 'textkey' => 'PriceUHT'
1149 ),
1150 'border-left' => true, // add left line separator
1151 );
1152
1153 $rank += 10;
1154 $this->cols['qty'] = array(
1155 'rank' => $rank,
1156 'width' => 16.0, // in mm
1157 'status' => true,
1158 'title' => array(
1159 'textkey' => 'Qty'
1160 ),
1161 'border-left' => true, // add left line separator
1162 );
1163
1164 $rank += 10;
1165 $this->cols['progress'] = array(
1166 'rank' => $rank,
1167 'width' => 19.0, // in mm
1168 'status' => false,
1169 'title' => array(
1170 'textkey' => 'Progress'
1171 ),
1172 'border-left' => true, // add left line separator
1173 );
1174
1175 if ($this->situationinvoice) {
1176 $this->cols['progress']['status'] = true;
1177 }
1178
1179 $rank += 10;
1180 $this->cols['unit'] = array(
1181 'rank' => $rank,
1182 'width' => 11.0, // in mm
1183 'status' => false,
1184 'title' => array(
1185 'textkey' => 'Unit'
1186 ),
1187 'border-left' => true, // add left line separator
1188 );
1189 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1190 $this->cols['unit']['status'] = true;
1191 }
1192
1193 $rank += 10;
1194 $this->cols['discount'] = array(
1195 'rank' => $rank,
1196 'width' => 13.0, // in mm
1197 'status' => false,
1198 'title' => array(
1199 'textkey' => 'ReductionShort'
1200 ),
1201 'border-left' => true, // add left line separator
1202 );
1203 if ($this->atleastonediscount) {
1204 $this->cols['discount']['status'] = true;
1205 }
1206
1207 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1208 $this->cols['totalexcltax'] = array(
1209 'rank' => $rank,
1210 'width' => 26.0, // in mm
1211 'status' => true,
1212 'title' => array(
1213 'textkey' => 'TotalHT'
1214 ),
1215 'border-left' => true, // add left line separator
1216 );
1217
1218 // Add extrafields cols
1219 if (!empty($object->lines)) {
1220 $line = reset($object->lines);
1221 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1222 }
1223
1224 $parameters = array(
1225 'object' => $object,
1226 'outputlangs' => $outputlangs,
1227 'hidedetails' => $hidedetails,
1228 'hidedesc' => $hidedesc,
1229 'hideref' => $hideref
1230 );
1231
1232 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1233 if ($reshook < 0) {
1234 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1235 } elseif (empty($reshook)) {
1236 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1237 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1238 } else {
1239 $this->cols = $hookmanager->resArray;
1240 }
1241 }
1242}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_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 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)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
pdf_watermark($pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:1157
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:1810
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:294
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:317
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:749
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:1423
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:273
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:438
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2567
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:1137
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:393
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140