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