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