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