dolibarr 25.0.0-alpha
pdf_cyan.modules.php
Go to the documentation of this file.
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-2015 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7 * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
10 * Copyright (C) 2021-2024 Anthony Berton <anthony.berton@bb2a.fr>
11 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Nick Fragoulis
14 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 * or see https://www.gnu.org/
29 */
30
36require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
37require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
41
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 $cols;
82
88 public function __construct($db)
89 {
90 global $langs, $mysoc;
91
92 // Translations
93 $langs->loadLangs(array("main", "bills"));
94
95 $this->db = $db;
96 $this->name = "cyan";
97 $this->description = $langs->trans('DocModelCyanDescription');
98 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
99
100 // Dimension page
101 $this->type = 'pdf';
102 $formatarray = pdf_getFormat();
103 $this->page_largeur = $formatarray['width'];
104 $this->page_hauteur = $formatarray['height'];
105 $this->format = array($this->page_largeur, $this->page_hauteur);
106 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
107 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
108 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
109 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
110 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
111 $this->option_logo = 1; // Display logo
112 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
113 $this->option_modereg = 1; // Display payment mode
114 $this->option_condreg = 1; // Display payment terms
115 $this->option_multilang = 1; // Available in several languages
116 $this->option_escompte = 0; // Displays if there has been a discount
117 $this->option_credit_note = 0; // Support credit notes
118 $this->option_freetext = 1; // Support add of a personalised text
119 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
120 $this->watermark = '';
121
122 // Define position of columns
123 $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff
124
125
126 $this->tabTitleHeight = 5; // default height
127
128 // Use new system for position of columns, view $this->defineColumnField()
129
130 $this->tva = array();
131 $this->tva_array = array();
132 $this->localtax1 = array();
133 $this->localtax2 = array();
134 $this->atleastoneratenotnull = 0;
135 $this->atleastonediscount = 0;
136
137 $this->showAmountBeforeDiscount = getDolGlobalInt('MAIN_HIDE_AMOUNT_BEFORE_DISCOUNT') || getDolGlobalInt('MAIN_HIDE_AMOUNT_BEFORE_DISCOUNT_PROPALE') ? 0 : 1;
138 $this->showDiscountAmount = getDolGlobalInt('MAIN_HIDE_AMOUNT_DISCOUNT') || getDolGlobalInt('MAIN_HIDE_AMOUNT_BEFORE_DISCOUNT_PROPALE') ? 0 : 1;
139
140
141 if ($mysoc === null) {
142 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
143 return;
144 }
145
146 // Get source company
147 $this->emetteur = $mysoc;
148 if (empty($this->emetteur->country_code)) {
149 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
150 }
151 }
152
153 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
165 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
166 {
167 // phpcs:enable
168 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
169
170 dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
171
172 if (!is_object($outputlangs)) {
173 $outputlangs = $langs;
174 }
175 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
176 if (getDolGlobalString('MAIN_USE_FPDF')) {
177 $outputlangs->charset_output = 'ISO-8859-1';
178 }
179
180 // Load translation files required by page
181 $langfiles = array("main", "dict", "companies", "bills", "products", "propal", "compta");
182 $outputlangs->loadLangs($langfiles);
183
184 // Show Draft Watermark
185 if ($object->status == $object::STATUS_DRAFT && getDolGlobalString('PROPALE_DRAFT_WATERMARK')) {
186 $this->watermark = getDolGlobalString('PROPALE_DRAFT_WATERMARK');
187 }
188
189 global $outputlangsbis;
190 $outputlangsbis = null;
191 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
192 $outputlangsbis = new Translate('', $conf);
193 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
194 $outputlangsbis->loadLangs($langfiles);
195 }
196
197 $nblines = count($object->lines);
198
199 $hidetop = getDolGlobalInt('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
200
201 // Loop on each lines to detect if there is at least one image to show
202 $realpatharray = array();
203 $this->atleastonephoto = false;
204 if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) {
205 $objphoto = new Product($this->db);
206
207 for ($i = 0; $i < $nblines; $i++) {
208 if (empty($object->lines[$i]->fk_product)) {
209 continue;
210 }
211
212 $objphoto->fetch($object->lines[$i]->fk_product);
213 //var_dump($objphoto->ref);exit;
214 $pdir = array();
215 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
216 $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
217 $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
218 } else {
219 $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
220 $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
221 }
222
223 $realpath = '';
224 $arephoto = false;
225 foreach ($pdir as $midir) {
226 if (!$arephoto) {
227 $entity = $objphoto->entity;
228 if ($entity !== null && $conf->entity != $entity) {
229 $dir = $conf->product->multidir_output[$entity].'/'.$midir; //Check repertories of current entities
230 } else {
231 $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
232 }
233
234 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
235 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
236 if ($obj['photo_vignette']) {
237 $filename = $obj['photo_vignette'];
238 } else {
239 $filename = $obj['photo'];
240 }
241 } else {
242 $filename = $obj['photo'];
243 }
244
245 $realpath = $dir.$filename;
246 $arephoto = true;
247 $this->atleastonephoto = true;
248 }
249 }
250 }
251
252 if ($realpath && $arephoto) {
253 $realpatharray[$i] = $realpath;
254 }
255 }
256 }
257
258 if (count($realpatharray) == 0) {
259 $this->posxpicture = $this->posxtva;
260 }
261
262 if ($conf->propal->multidir_output[$conf->entity]) {
263 $object->fetch_thirdparty();
264
265 $deja_regle = 0;
266
267 // Definition of $dir and $file
268 if ($object->specimen) {
269 $dir = $conf->propal->multidir_output[$conf->entity];
270 $file = $dir."/SPECIMEN.pdf";
271 } else {
272 $objectref = dol_sanitizeFileName($object->ref);
273 $dir = $conf->propal->multidir_output[$object->entity ?? $conf->entity]."/".$objectref;
274 $file = $dir."/".$objectref.".pdf";
275 }
276
277 if (!file_exists($dir)) {
278 if (dol_mkdir($dir) < 0) {
279 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
280 return 0;
281 }
282 }
283
284 if (file_exists($dir)) {
285 // Add pdfgeneration hook
286 if (!is_object($hookmanager)) {
287 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
288 $hookmanager = new HookManager($this->db);
289 }
290 $hookmanager->initHooks(array('pdfgeneration'));
291 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
292 global $action;
293 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
294
295 // Set nblines with the new content of lines after hook
296 $nblines = count($object->lines);
297 //$nbpayments = count($object->getListOfPayments());
298
299 // Create pdf instance
300 $pdf = pdf_getInstance($this->format);
301 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
302 $pdf->setAutoPageBreak(true, 0);
303
304 if (class_exists('TCPDF')) {
305 $pdf->setPrintHeader(false);
306 $pdf->setPrintFooter(false);
307 }
308 $pdf->SetFont(pdf_getPDFFont($outputlangs));
309 // Set path to the background PDF File
310 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
311 $logodir = $conf->mycompany->dir_output;
312 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
313 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
314 }
315 $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
316 $tplidx = $pdf->importPage(1);
317 }
318
319 $pdf->Open();
320 $pagenb = 0;
321 $pdf->SetDrawColor(128, 128, 128);
322
323 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
324 $pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
325 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
326 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
327 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
328 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
329 $pdf->SetCompression(false);
330 }
331
332 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
333 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
334
335 // Set $this->atleastonediscount if you have at least one discount
336 for ($i = 0; $i < $nblines; $i++) {
337 if ($object->lines[$i]->remise_percent) {
338 $this->atleastonediscount++;
339 }
340 }
341
342
343 // New page
344 $pdf->AddPage();
345 if (!empty($tplidx)) {
346 $pdf->useTemplate($tplidx);
347 }
348 $pagenb++;
349
350 $heightforinfotot = 40; // Height reserved to output the info and total part
351 $heightforsignature = !getDolGlobalString('PROPAL_DISABLE_SIGNATURE') ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
352 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
353 $heightforfooter = $this->marge_basse + (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
354 //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
355
356 $save_note_public = $object->note_public; // Because $object->note_public may be modified by _pagehead() that calls pdf_writeLinkedObjects() that calls ... that modify $object->note_private
357
358 $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
359 $top_shift = $pagehead['top_shift'];
360 $shipp_shift = $pagehead['shipp_shift'];
361 $pdf->SetFont('', '', $default_font_size - 1);
362 $pdf->MultiCell(0, 3, ''); // Set interline to 3
363 $pdf->SetTextColor(0, 0, 0);
364
365
366 $tab_top = 80 + $this->marge_haute + $top_shift + $shipp_shift;
367 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 32 + $this->marge_haute + $top_shift : $this->marge_haute);
368 if (!$hidetop && getDolGlobalInt('MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
369 // TODO : make this hidden conf the default behavior for each PDF when each PDF managed this new Display
370 $tab_top_newpage += $this->tabTitleHeight;
371 }
372
373 $nexY = $tab_top;
374
375 // Incoterm
376 $height_incoterms = 0;
377 if (isModEnabled('incoterm')) {
378 $desc_incoterms = $object->getIncotermsForPDF();
379 if ($desc_incoterms) {
380 $tab_top -= 2;
381
382 $pdf->SetFont('', '', $default_font_size - 1);
383 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
384 $nexY = max($pdf->GetY(), $nexY);
385 $height_incoterms = $nexY - $tab_top;
386
387 // Rect takes a length in 3rd parameter
388 $pdf->SetDrawColor(192, 192, 192);
389 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D');
390
391 $tab_top = $nexY + 6;
392 $height_incoterms += 4;
393 }
394 }
395
396 // Displays notes
397 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
398 if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
399 // Get first sale rep
400 if (is_object($object->thirdparty)) {
401 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
402 $salerepobj = new User($this->db);
403 $salerepobj->fetch($salereparray[0]['id']);
404 if (!empty($salerepobj->signature)) {
405 $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
406 }
407 }
408 }
409
410 $object->note_public = $save_note_public; // Now that we have output the note_public, we can restore it to initial value.
411
412 // Extrafields in note
413 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
414 if (!empty($extranote)) {
415 $notetoshow = dol_concatdesc((string) $notetoshow, $extranote);
416 }
417
418 if (getDolGlobalString('MAIN_ADD_CREATOR_IN_NOTE') && $object->user_author_id > 0) {
419 $tmpuser = new User($this->db);
420 $tmpuser->fetch($object->user_author_id);
421
422 $creator_info = $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
423 if ($tmpuser->email) {
424 $creator_info .= ', '.$langs->trans("EMail").': '.$tmpuser->email;
425 }
426 if ($tmpuser->office_phone) {
427 $creator_info .= ', '.$langs->trans("Phone").': '.$tmpuser->office_phone;
428 }
429
430 $notetoshow = dol_concatdesc((string) $notetoshow, $creator_info);
431 }
432
433 $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
434
435 $pagenb = $pdf->getPage();
436 if ($notetoshow) {
437 $tab_top -= 2;
438
439 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
440 $pageposbeforenote = $pagenb;
441
442 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
443 complete_substitutions_array($substitutionarray, $outputlangs, $object);
444 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
445 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
446
447 $pdf->startTransaction();
448
449 $pdf->SetFont('', '', $default_font_size - 1);
450 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
451 // Description
452 $pageposafternote = $pdf->getPage();
453 $posyafter = $pdf->GetY();
454
455 if ($pageposafternote > $pageposbeforenote) {
456 $pdf->rollbackTransaction(true);
457
458 // prepare pages to receive notes
459 while ($pagenb < $pageposafternote) {
460 $pdf->AddPage();
461 $pagenb++;
462 if (!empty($tplidx)) {
463 $pdf->useTemplate($tplidx);
464 }
465 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
466 $this->_pagehead($pdf, $object, 0, $outputlangs);
467 }
468 // $this->_pagefoot($pdf,$object,$outputlangs,1);
469 $pdf->setTopMargin($tab_top_newpage);
470 // The only function to edit the bottom margin of current page to set it.
471 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
472 }
473
474 // back to start
475 $pdf->setPage($pageposbeforenote);
476 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
477 $pdf->SetFont('', '', $default_font_size - 1);
478 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
479 $pageposafternote = $pdf->getPage();
480
481 $posyafter = $pdf->GetY();
482
483 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
484 $pdf->AddPage('', '', true);
485 $pagenb++;
486 $pageposafternote++;
487 $pdf->setPage($pageposafternote);
488 $pdf->setTopMargin($tab_top_newpage);
489 // The only function to edit the bottom margin of current page to set it.
490 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
491 //$posyafter = $tab_top_newpage;
492 }
493
494
495 // apply note frame to previous pages
496 $i = $pageposbeforenote;
497 while ($i < $pageposafternote) {
498 $pdf->setPage($i);
499
500
501 $pdf->SetDrawColor(128, 128, 128);
502 // Draw note frame
503 if ($i > $pageposbeforenote) {
504 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
505 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
506 } else {
507 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
508 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
509 }
510
511 // Add footer
512 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
513 $this->_pagefoot($pdf, $object, $outputlangs, 1);
514
515 $i++;
516 }
517
518 // apply note frame to last page
519 $pdf->setPage($pageposafternote);
520 if (!empty($tplidx)) {
521 $pdf->useTemplate($tplidx);
522 }
523 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
524 $this->_pagehead($pdf, $object, 0, $outputlangs);
525 }
526 $height_note = $posyafter - $tab_top_newpage;
527 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
528 } else {
529 // No pagebreak
530 $pdf->commitTransaction();
531 $posyafter = $pdf->GetY();
532 $height_note = $posyafter - $tab_top;
533 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
534
535
536 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
537 // not enough space, need to add page
538 $pdf->AddPage('', '', true);
539 $pagenb++;
540 $pageposafternote++;
541 $pdf->setPage($pageposafternote);
542 if (!empty($tplidx)) {
543 $pdf->useTemplate($tplidx);
544 }
545 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
546 $this->_pagehead($pdf, $object, 0, $outputlangs);
547 }
548
549 $posyafter = $tab_top_newpage;
550 }
551 }
552 $tab_height -= $height_note;
553 $tab_top = $posyafter + 6;
554 } else {
555 $height_note = 0;
556 }
557
558 // Use new auto column system
559 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
560
561 // Table simulation to know the height of the title line
562 $pdf->startTransaction();
563 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
564 $pdf->rollbackTransaction(true);
565
566 $nexY = $tab_top + $this->tabTitleHeight;
567
568 // Loop on each lines
569 $pageposbeforeprintlines = $pdf->getPage();
570 $pagenb = $pageposbeforeprintlines;
571
572 $pdf_sub_options = array();
573 $pdf_sub_options['titleshowuponpdf'] = 1;
574 $pdf_sub_options['titleshowtotalexludingvatonpdf'] = 1;
575 $pdf_sub_options_before_title = array(); // Options in use before each title line, by level
576
577 $hidenextline = 0;
578
579 for ($i = 0; $i < $nblines; $i++) {
580 $linePosition = $i + 1;
581 $curY = $nexY;
582
583 $sub_options = $object->lines[$i]->extraparams["subtotal"] ?? array();
584
585
586 if ($object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
587 $level = $object->lines[$i]->qty;
588 // Keep the options in use before a title line, to restore them after the subtotal line that closes its block
589 if ($level > 0 && !isset($pdf_sub_options_before_title[(int) $level])) {
590 $pdf_sub_options_before_title[(int) $level] = $pdf_sub_options;
591 }
592 if ($sub_options) {
593 $hidenextline = 0;
594 if (isset($sub_options['titleshowuponpdf'])) {
595 $pdf_sub_options['titleshowuponpdf'] = isset($pdf_sub_options['titleshowuponpdf']) && $pdf_sub_options['titleshowuponpdf'] < $level ? $pdf_sub_options['titleshowuponpdf'] : $level;
596 } elseif (isset($pdf_sub_options['titleshowuponpdf']) && abs($level) <= $pdf_sub_options['titleshowuponpdf']) {
597 unset($pdf_sub_options['titleshowuponpdf']);
598 }
599 if (isset($sub_options['titleshowtotalexludingvatonpdf'])) {
600 $pdf_sub_options['titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options['titleshowtotalexludingvatonpdf']) && $pdf_sub_options['titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options['titleshowtotalexludingvatonpdf'] : $level;
601 } elseif (isset($pdf_sub_options['titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options['titleshowtotalexludingvatonpdf']) {
602 unset($pdf_sub_options['titleshowtotalexludingvatonpdf']);
603 }
604 } else {
605 if (isset($pdf_sub_options['titleshowuponpdf']) && abs($level) <= $pdf_sub_options['titleshowuponpdf']) {
606 unset($pdf_sub_options['titleshowuponpdf']);
607 }
608 if (isset($pdf_sub_options['titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options['titleshowtotalexludingvatonpdf']) {
609 unset($pdf_sub_options['titleshowtotalexludingvatonpdf']);
610 }
611 }
612 // A subtotal line closes the block of the title line of same level: the next lines get back the options in use before this title line
613 if ($level < 0 && isset($pdf_sub_options_before_title[(int) abs($level)])) {
614 $pdf_sub_options = $pdf_sub_options_before_title[(int) abs($level)];
615 foreach (array_keys($pdf_sub_options_before_title) as $tmplevel) {
616 if ($tmplevel >= abs($level)) {
617 unset($pdf_sub_options_before_title[$tmplevel]);
618 }
619 }
620 }
621 }
622
623 if ($object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && isset($sub_options['subtotalshowtotalexludingvatonpdf']) && getDolGlobalString('SUBTOTAL_HIDE_LINES_UNDER_TITLE')) { // TODO Use $sub_options['titlehidelinesundertitle'] instead of SUBTOTAL_HIDE_LINES_UNDER_TITLE
624 $hidenextline = 0;
625 $pdf_sub_options = array();
626 $pdf_sub_options['titleshowuponpdf'] = 1;
627 $pdf_sub_options['titleshowtotalexludingvatonpdf'] = 1;
628 }
629
630 if ($hidenextline) {
631 $linePosition--;
632 } else {
633 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options['titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
634 $object->lines[$i]->pagebreak = true;
635 }
636
637 // in First Check line page break and add page if needed
638 if (isset($object->lines[$i]->pagebreak) && $object->lines[$i]->pagebreak) {
639 // New page
640 $pdf->AddPage();
641 if (!empty($tplidx)) {
642 $pdf->useTemplate($tplidx);
643 }
644
645 $pdf->setPage($pdf->getNumPages());
646 $nexY = $curY = $tab_top_newpage;
647 }
648
649 $this->resetAfterColsLinePositionsData($nexY, $pdf->getPage());
650
651 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
652 $pdf->SetTextColor(0, 0, 0);
653
654 // Define size of image if we need it
655 $imglinesize = array();
656 if (!empty($realpatharray[$i])) {
657 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
658 }
659
660 $pdf->setTopMargin($tab_top_newpage);
661 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
662 $pageposbefore = $pdf->getPage();
663 $curYBefore = $curY;
664
665 // Allows data in the first page if description is long enough to break in multiples pages
666 $showpricebeforepagebreak = getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE');
667
668 $posYAfterImage = 0;
669
670 if ($this->getColumnStatus('photo')) {
671 // We start with Photo of product line
672 $imageTopMargin = 1;
673 if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imageTopMargin + $imglinesize['height']) > ($this->page_hauteur - $heightforfooter)) { // If photo too high, we moved completely on new page
674 $pdf->AddPage('', '', true);
675 if (!empty($tplidx)) {
676 $pdf->useTemplate($tplidx);
677 }
678 $pdf->setPage($pageposbefore + 1);
679 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
680 $curY = $tab_top_newpage;
681 $showpricebeforepagebreak = 0;
682 }
683
684 $pdf->setPageOrientation('', false, $heightforfooter + $heightforfreetext); // The only function to edit the bottom margin of current page to set it.
685 // @phan-suppress-next-line PhanTypeMismatchProperty
686 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
687 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + $imageTopMargin, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
688 // $pdf->Image does not increase value return by getY, so we save it manually
689 $posYAfterImage = $curY + $imglinesize['height'];
690
691 $this->setAfterColsLinePositionsData('photo', $posYAfterImage, $pdf->getPage());
692 }
693 }
694
695 // restore Page orientation for text
696 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
697
698 if ($this->getColumnStatus('desc')) {
699 if ($object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
700 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
701 $this->setAfterColsLinePositionsData('desc', $pdf->GetY(), $pdf->getPage());
702 } else {
703 $bg_color = colorStringToArray(getDolGlobalString("SUBTOTAL_BACK_COLOR_LEVEL_".abs($object->lines[$i]->qty), 'ffffff'));
704 pdf_render_subtotals($pdf, $this, $curY, $object, $i, $outputlangs, $hideref, $hidedesc, $bg_color, true, true);
705 }
706 }
707
708 $afterPosData = $this->getMaxAfterColsLinePositionsData();
709 $pdf->setPage($pageposbefore);
710 $pdf->setTopMargin($this->marge_haute);
711 $curY = $curYBefore;
712 $pdf->setPageOrientation('', false, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
713
714
715 // We suppose that a too long description or photo were moved completely on next page
716 if ($afterPosData['page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
717 $pdf->setPage($afterPosData['page']);
718 $curY = $tab_top_newpage;
719 }
720
721 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
722
723
724 // # of line
725 if ($this->getColumnStatus('position')) {
726 $this->printStdColumnContent($pdf, $curY, 'position', strval($linePosition));
727 }
728
729 // VAT Rate
730 if ($this->getColumnStatus('vat') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
731 $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
732 $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
733 }
734
735 // Unit price before discount
736 if ($this->getColumnStatus('subprice') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options['titleshowuponpdf'])) {
737 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
738 $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
739 }
740
741 // Quantity
742 // Enough for 6 chars
743 if ($this->getColumnStatus('qty') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
744 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
745 $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
746 }
747
748
749 // Unit
750 if ($this->getColumnStatus('unit') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
751 $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails);
752 $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
753 }
754
755 // Discount on line
756 if ($this->getColumnStatus('discount') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && $object->lines[$i]->remise_percent) {
757 $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
758 $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
759 }
760
761 // Total excl tax line (HT)
762 if ($this->getColumnStatus('totalexcltax')) {
763 if ($object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options['titleshowtotalexludingvatonpdf'])) {
764 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
765 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
766 } elseif ($object->lines[$i]->qty < 0 && isset($sub_options['subtotalshowtotalexludingvatonpdf'])) {
767 if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
768 $total_excl_tax = $object->getSubtotalLineMulticurrencyAmount($object->lines[$i]);
769 } else {
770 $total_excl_tax = $object->getSubtotalLineAmount($object->lines[$i]);
771 }
772 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
773 }
774 }
775
776 // Total with tax line (TTC)
777 if ($this->getColumnStatus('totalincltax') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
778 $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
779 $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
780 }
781
782 // Extrafields
783 if (!empty($object->lines[$i]->array_options)) {
784 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
785 if ($this->getColumnStatus($extrafieldColKey)) {
786 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
787 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
788
789 $this->setAfterColsLinePositionsData('options_'.$extrafieldColKey, $pdf->GetY(), $pdf->getPage());
790 }
791 }
792 }
793
794 $afterPosData = $this->getMaxAfterColsLinePositionsData();
795 $parameters = array(
796 'object' => $object,
797 'i' => $i,
798 'pdf' => & $pdf,
799 'curY' => & $curY,
800 'nexY' => & $afterPosData['y'], // for backward module hook compatibility Y will be accessible by $object->getMaxAfterColsLinePositionsData()
801 'outputlangs' => $outputlangs,
802 'hidedetails' => $hidedetails
803 );
804 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
805 }
806
807 // Collection of totals by value of vat in $this->tva["rate"] = total_tva
808 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
809 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
810 } else {
811 $tvaligne = $object->lines[$i]->total_tva;
812 }
813
814 $localtax1ligne = $object->lines[$i]->total_localtax1;
815 $localtax2ligne = $object->lines[$i]->total_localtax2;
816 $localtax1_rate = $object->lines[$i]->localtax1_tx;
817 $localtax2_rate = $object->lines[$i]->localtax2_tx;
818 $localtax1_type = $object->lines[$i]->localtax1_type;
819 $localtax2_type = $object->lines[$i]->localtax2_type;
820
821 $vatrate = (string) $object->lines[$i]->tva_tx;
822
823 // Retrieve type from database for backward compatibility with old records
824 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
825 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
826 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
827 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
828 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
829 }
830
831 // retrieve global local tax
832 if ($localtax1_type && $localtax1ligne != 0) {
833 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
834 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
835 } else {
836 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
837 }
838 }
839 if ($localtax2_type && $localtax2ligne != 0) {
840 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
841 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
842 } else {
843 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
844 }
845 }
846
847 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
848 $vatrate .= '*';
849 }
850
851 // Fill $this->tva and $this->tva_array
852 if (!isset($this->tva[$vatrate])) {
853 $this->tva[$vatrate] = 0;
854 }
855 $this->tva[$vatrate] += $tvaligne;
856 $vatcode = $object->lines[$i]->vat_src_code;
857 if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
858 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
859 }
860 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
861
862
863 if (!$hidenextline) {
864 $afterPosData = $this->getMaxAfterColsLinePositionsData();
865 $pdf->setPage($afterPosData['page']);
866 $nexY = $afterPosData['y'];
867
868 // Add line
869 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData['y'] < $this->page_hauteur - $heightforfooter - 5) {
870 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
871 //$pdf->SetDrawColor(190,190,200);
872 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
873 $pdf->SetLineStyle(array('dash' => 0));
874 }
875 }
876
877 if ($object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && (isset($sub_options['titleshowuponpdf']) || isset($sub_options['titleshowtotalexludingvatonpdf'])) && getDolGlobalString('SUBTOTAL_HIDE_LINES_UNDER_TITLE')) { // TODO Use $sub_options['titlehidelinesundertitle'] instead of SUBTOTAL_HIDE_LINES_UNDER_TITLE
878 $hidenextline = 1;
879 }
880
881 $nexY += 0; // Add space between lines
882 }
883
884
885 // Add last page for document footer if there are not enough size left
886 $afterPosData = $this->getMaxAfterColsLinePositionsData();
887 if (isset($afterPosData['y']) && $afterPosData['y'] > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
888 $pdf->AddPage();
889 if (!empty($tplidx)) {
890 $pdf->useTemplate($tplidx);
891 }
892 $pagenb++;
893 $pdf->setPage($pagenb);
894 }
895
896 // Draw table frames and columns borders
897 $drawTabNumbPage = $pdf->getNumPages();
898 for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) {
899 $pdf->setPage($i);
900 // reset page orientation each loop to override it if it was changed
901 $pdf->setPageOrientation('', false, 0); // The only function to edit the bottom margin of current page to set it.
902
903 $drawTabHideTop = $hidetop;
904 $drawTabTop = $tab_top_newpage;
905 $drawTabBottom = $this->page_hauteur - $heightforfooter;
906 $hideBottom = 0; // TODO understand why it change to 1 or 0 during process
907
908 if ($i == $pageposbeforeprintlines) {
909 // first page need to start after notes
910 $drawTabTop = $tab_top;
911 } elseif (!$drawTabHideTop) {
912 if (getDolGlobalInt('MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
913 $drawTabTop -= $this->tabTitleHeight;
914 } else {
915 $drawTabHideTop = 1;
916 }
917 }
918
919 // last page need to include document footer
920 if ($i == $pdf->getNumPages()) {
921 // remove document footer height to tab bottom position
922 $drawTabBottom -= $heightforsignature + $heightforfreetext + $heightforinfotot;
923 }
924
925 $drawTabHeight = $drawTabBottom - $drawTabTop;
926 $this->_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom, $object->multicurrency_code, $outputlangsbis);
927
928 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0; // Display free text only in last page
929 $this->_pagefoot($pdf, $object, $outputlangs, $hideFreeText);
930
931 $pdf->setPage($i); // in case of _pagefoot or _tableau change it
932
933 // reset page orientation each loop to override it if it was changed by _pagefoot or _tableau change it
934 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
935
936 // Don't print head on first page ($pageposbeforeprintlines) because already added previously
937 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
938 $this->_pagehead($pdf, $object, 0, $outputlangs);
939 }
940 if (!empty($tplidx)) {
941 $pdf->useTemplate($tplidx);
942 }
943 }
944
945 // reset text color before print footers
946 $pdf->SetTextColor(0, 0, 0);
947
948 $pdf->setPage($pdf->getNumPages());
949
950 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
951
952 // Display infos area
953 $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
954
955 // Display total zone
956 $posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
957
958 // Customer signature area
959 if (!getDolGlobalString('PROPAL_DISABLE_SIGNATURE')) {
960 $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
961
962 // Rewrite keywords to add a tag with the numero of page that contains the signature section
963 $keywords = $outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name);
964 $pdf->SetKeyWords($keywords." PAGESIGN=".$pdf->getPage());
965 }
966
967 // Add number of pages in footer
968 if (method_exists($pdf, 'AliasNbPages')) {
969 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
970 }
971
972 // Add terms to sale
973 $termsofsalefilename = getDolGlobalString('MAIN_INFO_PROPAL_TERMSOFSALE');
974 if ($this->mustAddTermsOfSale($object, 'PROPAL') && $termsofsalefilename) {
975 $termsofsale = $conf->propal->dir_output.'/'.$termsofsalefilename;
976 if (!empty($conf->propal->multidir_output[$object->entity ?? $conf->entity])) {
977 $termsofsale = $conf->propal->multidir_output[$object->entity ?? $conf->entity].'/'.$termsofsalefilename;
978 }
979 if (file_exists($termsofsale) && is_readable($termsofsale)) {
980 $pagecount = $pdf->setSourceFile($termsofsale);
981 for ($i = 1; $i <= $pagecount; $i++) {
982 $tplIdx = $pdf->importPage($i);
983 if ($tplIdx !== false) {
984 $s = $pdf->getTemplatesize($tplIdx);
985 $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
986 $pdf->useTemplate($tplIdx);
987 } else {
988 setEventMessages(null, array($termsofsale.' cannot be added, probably protected PDF'), 'warnings');
989 }
990 }
991 }
992 }
993
994 //If propal merge product PDF is active
995 if (getDolGlobalString('PRODUIT_PDF_MERGE_PROPAL')) {
996 require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
997
998 $already_merged = array();
999 foreach ($object->lines as $line) {
1000 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
1001 // Find the desired PDF
1002 $filetomerge = new Propalmergepdfproduct($this->db);
1003
1004 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1005 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
1006 } else {
1007 $filetomerge->fetch_by_product($line->fk_product);
1008 }
1009
1010 $already_merged[] = $line->fk_product;
1011
1012 $product = new Product($this->db);
1013 $product->fetch($line->fk_product);
1014
1015 if ($product->entity != $conf->entity) {
1016 $entity_product_file = $product->entity;
1017 } else {
1018 $entity_product_file = $conf->entity;
1019 }
1020
1021 // If PDF is selected and file is not empty
1022 if (count($filetomerge->lines) > 0) {
1023 foreach ($filetomerge->lines as $linefile) {
1024 if (!empty($linefile->id) && !empty($linefile->file_name)) {
1025 $filetomerge_dir = null;
1026 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
1027 if (isModEnabled("product")) {
1028 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
1029 } elseif (isModEnabled("service")) {
1030 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
1031 }
1032 } else {
1033 if (isModEnabled("product")) {
1034 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
1035 } elseif (isModEnabled("service")) {
1036 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
1037 }
1038 }
1039
1040 dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, $filetomerge_dir === null ? LOG_ERR : LOG_DEBUG);
1041 if ($filetomerge_dir === null) {
1042 // Skip loop
1043 continue;
1044 }
1045
1046 $infile = $filetomerge_dir.'/'.$linefile->file_name;
1047 if (file_exists($infile) && is_readable($infile)) {
1048 $pagecount = $pdf->setSourceFile($infile);
1049 for ($i = 1; $i <= $pagecount; $i++) {
1050 $tplIdx = $pdf->importPage($i);
1051 if ($tplIdx !== false) {
1052 $s = $pdf->getTemplatesize($tplIdx);
1053 $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
1054 $pdf->useTemplate($tplIdx);
1055 } else {
1056 setEventMessages(null, array($infile.' cannot be added, probably protected PDF'), 'warnings');
1057 }
1058 }
1059 }
1060 }
1061 }
1062 }
1063 }
1064 }
1065 }
1066
1067 $pdf->Close();
1068
1069 $pdf->Output($file, 'F');
1070
1071 //Add pdfgeneration hook
1072 $hookmanager->initHooks(array('pdfgeneration'));
1073 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
1074 global $action;
1075 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1076 $this->warnings = $hookmanager->warnings;
1077 if ($reshook < 0) {
1078 $this->error = $hookmanager->error;
1079 $this->errors = $hookmanager->errors;
1080 dolChmod($file);
1081 return -1;
1082 }
1083
1084 dolChmod($file);
1085
1086 $this->result = array('fullpath' => $file);
1087
1088 return 1; // No error
1089 } else {
1090 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
1091 return 0;
1092 }
1093 } else {
1094 $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
1095 return 0;
1096 }
1097 }
1098
1108 public function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
1109 {
1110 global $mysoc;
1111
1112 $default_font_size = pdf_getPDFFontSize($outputlangs);
1113
1114 $pdf->SetFont('', '', $default_font_size - 1);
1115
1116 $diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3);
1117
1118 // If France, show VAT mention if not applicable
1119 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
1120 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1121 $pdf->SetXY($this->marge_gauche, $posy);
1122 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', false);
1123
1124 $posy = $pdf->GetY() + 4;
1125 }
1126
1127 $posxval = 52;
1128 if (getDolGlobalString('MAIN_PDF_DELIVERY_DATE_TEXT')) {
1129 $displaydate = "daytext";
1130 } else {
1131 $displaydate = "day";
1132 }
1133
1134 // Show shipping date
1135 if (!empty($object->delivery_date)) {
1136 $outputlangs->load("sendings");
1137 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1138 $pdf->SetXY($this->marge_gauche, $posy);
1139 $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
1140 $pdf->MultiCell(80, 4, $titre, 0, 'L');
1141 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1142 $pdf->SetXY($posxval, $posy);
1143 $dlp = dol_print_date($object->delivery_date, $displaydate, false, $outputlangs, true);
1144 $pdf->MultiCell(80, 4, $dlp, 0, 'L');
1145
1146 $posy = $pdf->GetY() + 1;
1147 } elseif ($object->availability_code || $object->availability) { // Show availability conditions
1148 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1149 $pdf->SetXY($this->marge_gauche, $posy);
1150 $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
1151 $pdf->MultiCell(80, 4, $titre, 0, 'L');
1152 $pdf->SetTextColor(0, 0, 0);
1153 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1154 $pdf->SetXY($posxval, $posy);
1155 $lib_availability = ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
1156 $lib_availability = str_replace('\n', "\n", $lib_availability);
1157 $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
1158
1159 $posy = $pdf->GetY() + 1;
1160 }
1161
1162 // Show delivery mode
1163 if (!getDolGlobalString('PROPOSAL_PDF_HIDE_DELIVERYMODE') && $object->shipping_method_id > 0) {
1164 $outputlangs->load("sendings");
1165
1166 $shipping_method_id = $object->shipping_method_id;
1167 if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1168 $shipping_method_id = $this->emetteur->shipping_method_id;
1169 }
1170 $shipping_method_code = dol_getIdFromCode($this->db, (string) $shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
1171 $shipping_method_label = dol_getIdFromCode($this->db, (string) $shipping_method_id, 'c_shipment_mode', 'rowid', 'libelle');
1172
1173 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1174 $pdf->SetXY($this->marge_gauche, $posy);
1175 $titre = $outputlangs->transnoentities("SendingMethod").':';
1176 $pdf->MultiCell(43, 4, $titre, 0, 'L');
1177
1178 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1179 $pdf->SetXY($posxval, $posy);
1180 $lib_condition_paiement = ($outputlangs->transnoentities("SendingMethod".strtoupper($shipping_method_code)) != "SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans("SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label;
1181 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1182 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1183
1184 $posy = $pdf->GetY() + 1;
1185 }
1186
1187 // Show payments conditions
1188 if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTTERM') && $object->cond_reglement_code) {
1189 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1190 $pdf->SetXY($this->marge_gauche, $posy);
1191 $titre = $outputlangs->transnoentities("PaymentConditions").':';
1192 $pdf->MultiCell(43, 4, $titre, 0, 'L');
1193
1194 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1195 $pdf->SetXY($posxval, $posy);
1196 $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
1197 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1198 if ($object->deposit_percent > 0) {
1199 $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
1200 }
1201 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1202
1203 $posy = $pdf->GetY() + 3;
1204 }
1205
1206 if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTMODE')) {
1207 // Show payment mode
1208 if ($object->mode_reglement_code
1209 && $object->mode_reglement_code != 'CHQ'
1210 && $object->mode_reglement_code != 'VIR') {
1211 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1212 $pdf->SetXY($this->marge_gauche, $posy);
1213 $titre = $outputlangs->transnoentities("PaymentMode").':';
1214 $pdf->MultiCell(80, 5, $titre, 0, 'L');
1215 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1216 $pdf->SetXY($posxval, $posy);
1217 $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
1218 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1219
1220 $posy = $pdf->GetY() + 2;
1221 }
1222
1223 // Show payment mode CHQ
1224 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
1225 // Si mode reglement non force ou si force a CHQ
1226 if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
1227 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
1228 $account = new Account($this->db);
1229 $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
1230
1231 $pdf->SetXY($this->marge_gauche, $posy);
1232 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1233 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', false);
1234 $posy = $pdf->GetY() + 1;
1235
1236 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1237 $pdf->SetXY($this->marge_gauche, $posy);
1238 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1239 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', false);
1240 $posy = $pdf->GetY() + 2;
1241 }
1242 }
1243 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
1244 $pdf->SetXY($this->marge_gauche, $posy);
1245 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1246 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', false);
1247 $posy = $pdf->GetY() + 1;
1248
1249 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1250 $pdf->SetXY($this->marge_gauche, $posy);
1251 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1252 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', false);
1253 $posy = $pdf->GetY() + 2;
1254 }
1255 }
1256 }
1257 }
1258
1259 // If payment mode not forced or forced to VIR, show payment with BAN
1260 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1261 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1262 $bankid = ($object->fk_account <= 0 ? getDolGlobalInt('FACTURE_RIB_NUMBER') : $object->fk_account);
1263 if ($object->fk_bank > 0) {
1264 $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1265 }
1266 $account = new Account($this->db);
1267 $account->fetch((int) $bankid);
1268
1269 $curx = $this->marge_gauche;
1270 $cury = $posy;
1271
1272 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1273
1274 $posy += 2;
1275 }
1276 }
1277 }
1278
1279 return $posy;
1280 }
1281
1282
1294 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
1295 {
1296 global $conf, $mysoc, $hookmanager;
1297
1298 $default_font_size = pdf_getPDFFontSize($outputlangs);
1299
1300 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
1301 $outputlangsbis = new Translate('', $conf);
1302 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
1303 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1304 $default_font_size--;
1305 }
1306
1307 $tab2_top = $posy;
1308 $tab2_hl = 4;
1309 $pdf->SetFont('', '', $default_font_size - 1);
1310
1311 // Total table
1312 $col1x = 120;
1313 $col2x = 170;
1314 if ($this->page_largeur < 210) { // To work with US executive format
1315 $col2x -= 20;
1316 }
1317 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1318
1319 $useborder = 0;
1320 $index = 0;
1321
1322 // Get Total HT
1323 $total_ht = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1324
1325 // Total discount
1326 $total_discount_on_lines = 0;
1327 $multicurrency_total_discount_on_lines = 0;
1328 foreach ($object->lines as $i => $line) {
1329 $resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
1330 $multicurrency_resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2, 1);
1331
1332 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1333 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1334 // If line was a negative line, we do not count the discount as a discount
1335 if ($line->total_ht < 0) {
1336 $total_discount_on_lines += -$line->total_ht;
1337 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1338 }
1339 }
1340
1341 if ($total_discount_on_lines > 0) {
1342 if ($this->showAmountBeforeDiscount) {
1343 // Show total NET before discount
1344 $pdf->SetFillColor(255, 255, 255);
1345 $pdf->SetXY($col1x, $tab2_top);
1346 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount") . (is_object($outputlangsbis) ? ' / ' . $outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', true);
1347 $pdf->SetXY($col2x, $tab2_top);
1348
1349 $total_before_discount_to_show = ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? ($object->multicurrency_total_ht + $multicurrency_total_discount_on_lines) : ($object->total_ht + $total_discount_on_lines));
1350 $pdf->MultiCell($largcol2, $tab2_hl, price($total_before_discount_to_show, 0, $outputlangs), 0, 'R', true);
1351
1352 $index++;
1353 }
1354
1355 if ($this->showDiscountAmount) {
1356 $pdf->SetFillColor(255, 255, 255);
1357 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1358 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount") . (is_object($outputlangsbis) ? ' / ' . $outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', true);
1359 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1360
1361 $total_discount_to_show = ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1362 $pdf->MultiCell($largcol2, $tab2_hl, price($total_discount_to_show, 0, $outputlangs), 0, 'R', true);
1363
1364 $index++;
1365 }
1366 }
1367
1368 // Total HT
1369 $pdf->SetFillColor(255, 255, 255);
1370 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1371 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', true);
1372
1373 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1374 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1375 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', true);
1376
1377 // Show VAT by rates and total
1378 $pdf->SetFillColor(248, 248, 248);
1379
1380 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1381 $total_ttc_origin = $object->total_ttc;
1382
1383 $this->atleastoneratenotnull = 0;
1384 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
1385 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
1386 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1387 // Nothing to do
1388 } else {
1389 //Local tax 1 before VAT
1390 //if (getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == 'localtax1on')
1391 //{
1392 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1393 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1394 continue;
1395 }
1396
1397 foreach ($localtax_rate as $tvakey => $tvaval) {
1398 if ($tvakey != 0) { // On affiche pas taux 0
1399 //$this->atleastoneratenotnull++;
1400
1401 $index++;
1402 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1403
1404 $tvacompl = '';
1405 if (preg_match('/\*/', $tvakey)) {
1406 $tvakey = str_replace('*', '', $tvakey);
1407 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1408 }
1409 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1410 $totalvat .= ' ';
1411 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1412 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1413
1414 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1415
1416 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1417 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1418 }
1419 }
1420 }
1421 //}
1422 //Local tax 2 before VAT
1423 //if (getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == 'localtax2on')
1424 //{
1425 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1426 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1427 continue;
1428 }
1429
1430 foreach ($localtax_rate as $tvakey => $tvaval) {
1431 if ($tvakey != 0) { // On affiche pas taux 0
1432 //$this->atleastoneratenotnull++;
1433
1434 $index++;
1435 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1436
1437 $tvacompl = '';
1438 if (preg_match('/\*/', $tvakey)) {
1439 $tvakey = str_replace('*', '', $tvakey);
1440 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1441 }
1442 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1443 $totalvat .= ' ';
1444 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1445 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1446
1447 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1448
1449 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1450 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1451 }
1452 }
1453 }
1454 //}
1455
1456 // VAT
1457 foreach ($this->tva as $tvakey => $tvaval) {
1458 if ($tvakey != 0) { // On affiche pas taux 0
1459 $this->atleastoneratenotnull++;
1460
1461 $index++;
1462 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1463
1464 $tvacompl = '';
1465 if (preg_match('/\*/', $tvakey)) {
1466 $tvakey = str_replace('*', '', $tvakey);
1467 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1468 }
1469 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1470 $totalvat .= ' ';
1471 $totalvat .= vatrate($tvakey, true).$tvacompl;
1472 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1473
1474 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1475 $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', true);
1476 }
1477 }
1478
1479 //Local tax 1 after VAT
1480 //if (getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == 'localtax1on')
1481 //{
1482 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1483 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1484 continue;
1485 }
1486
1487 foreach ($localtax_rate as $tvakey => $tvaval) {
1488 if ($tvakey != 0) { // On affiche pas taux 0
1489 //$this->atleastoneratenotnull++;
1490
1491 $index++;
1492 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1493
1494 $tvacompl = '';
1495 if (preg_match('/\*/', $tvakey)) {
1496 $tvakey = str_replace('*', '', $tvakey);
1497 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1498 }
1499 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1500 $totalvat .= ' ';
1501
1502 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1503 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1504
1505 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1506
1507 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1508 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1509 }
1510 }
1511 }
1512 //}
1513 //Local tax 2 after VAT
1514 //if (getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == 'localtax2on')
1515 //{
1516 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1517 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1518 continue;
1519 }
1520
1521 foreach ($localtax_rate as $tvakey => $tvaval) {
1522 // retrieve global local tax
1523 if ($tvakey != 0) { // On affiche pas taux 0
1524 //$this->atleastoneratenotnull++;
1525
1526 $index++;
1527 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1528
1529 $tvacompl = '';
1530 if (preg_match('/\*/', $tvakey)) {
1531 $tvakey = str_replace('*', '', $tvakey);
1532 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1533 }
1534 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1535 $totalvat .= ' ';
1536
1537 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1538 $totalvat .= $tvacompl;
1539 } else {
1540 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1541 }
1542
1543 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1544
1545 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1546
1547 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1548 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1549 }
1550 }
1551 }
1552 //}
1553
1554 // Total TTC
1555 $index++;
1556 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1557 $pdf->SetTextColor(0, 0, 60);
1558 $pdf->SetFillColor(224, 224, 224);
1559 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : ''), $useborder, 'L', true);
1560
1561 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1562 if (!isModEnabled("multicurrency") || $object->multicurrency_tx == 1 || getDolGlobalInt('MULTICURRENCY_SHOW_ALSO_MAIN_CURRENCY_ON_PDF') == 0) {
1563 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', true);
1564 } else {
1565 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', true);
1566
1567 //$pdf->writeHTMLCell($largcol2, $tab2_hl, null, null, '<font size="-2">('.price($sign * $object->total_ttc, 0, $outputlangs, 1, -1, 'MT', $mysoc->currency_code).')</font> &nbsp; '.price($sign * $total_ttc, 0, $outputlangs), $useborder, 1, true, true, 'R');
1568 $index++;
1569 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1570 $pdf->SetTextColor(0, 0, 60);
1571 $pdf->SetFillColor(224, 224, 224);
1572 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : '').' ('.$outputlangs->getCurrencySymbol($mysoc->currency_code).')', $useborder, 'L', true);
1573
1574 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1575 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc_origin, 0, $outputlangs, 1, -1, -1, $mysoc->currency_code), $useborder, 'L', true);
1576 }
1577 }
1578 }
1579
1580 $pdf->SetTextColor(0, 0, 0);
1581
1582 $resteapayer = 0;
1583 /*
1584 $resteapayer = $object->total_ttc - $deja_regle;
1585 if (!empty($object->paye)) $resteapayer=0;
1586 */
1587
1588 if ($deja_regle > 0) {
1589 // Already paid + Deposits
1590 $index++;
1591
1592 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1593 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', false);
1594
1595 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1596 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', false);
1597
1598 /*
1599 if ($object->close_code == 'discount_vat') {
1600 $index++;
1601 $pdf->SetFillColor(255,255,255);
1602
1603 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1604 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1605
1606 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1607 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1);
1608
1609 $resteapayer=0;
1610 }
1611 */
1612
1613 $index++;
1614 $pdf->SetTextColor(0, 0, 60);
1615 $pdf->SetFillColor(224, 224, 224);
1616 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1617 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', true);
1618
1619 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1620 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', true);
1621
1622 $pdf->SetFont('', '', $default_font_size - 1);
1623 $pdf->SetTextColor(0, 0, 0);
1624 }
1625
1626 $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy);
1627
1628 $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks
1629 if ($reshook < 0) {
1630 $this->error = $hookmanager->error;
1631 $this->errors = $hookmanager->errors;
1632 }
1633
1634 $index++;
1635 return ($tab2_top + ($tab2_hl * $index));
1636 }
1637
1638 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1653 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1654 {
1655 global $conf;
1656
1657 // Force to disable hidetop and hidebottom
1658 $hidebottom = 0;
1659 if ($hidetop) {
1660 $hidetop = -1;
1661 }
1662
1663 $currency = !empty($currency) ? $currency : $conf->currency;
1664 $default_font_size = pdf_getPDFFontSize($outputlangs);
1665
1666 // Amount in (at tab_top - 1)
1667 $pdf->SetTextColor(0, 0, 0);
1668 $pdf->SetFont('', '', $default_font_size - 2);
1669
1670 if (empty($hidetop)) {
1671 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1672 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1673 $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1674 }
1675
1676 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1677 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1678
1679 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1680 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1681 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1682 }
1683 }
1684
1685 $pdf->SetDrawColor(128, 128, 128);
1686 $pdf->SetFont('', '', $default_font_size - 1);
1687
1688 // Output Rect
1689 $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter
1690
1691 if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) {
1692 $arrayColorTextTitle = explode(',', getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR'));
1693 $pdf->SetTextColor((float) $arrayColorTextTitle[0], (float) $arrayColorTextTitle[1], (float) $arrayColorTextTitle[2]);
1694 }
1695
1696 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1697
1698 if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) {
1699 $pdf->SetTextColor(0, 0, 0);
1700 }
1701
1702 if (empty($hidetop)) {
1703 $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
1704 }
1705 }
1706
1707 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1718 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
1719 {
1720 global $conf, $langs;
1721
1722 $ltrdirection = 'L';
1723 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1724 $ltrdirection = 'R';
1725 }
1726
1727 // Load traductions files required by page
1728 $outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
1729
1730 $default_font_size = pdf_getPDFFontSize($outputlangs);
1731
1732 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1733
1734 $pdf->SetTextColor(0, 0, 60);
1735 $pdf->SetFont('', 'B', $default_font_size + 3);
1736
1737 $w = 100;
1738
1739 $posy = $this->marge_haute;
1740 $posx = $this->page_largeur - $this->marge_droite - $w;
1741
1742 $pdf->SetXY($this->marge_gauche, $posy);
1743
1744 // Logo
1745 $logodir = $conf->mycompany->dir_output;
1746 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
1747 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
1748 }
1749 pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection);
1750
1751 $pdf->SetFont('', 'B', $default_font_size + 3);
1752 $pdf->SetXY($posx, $posy);
1753 $pdf->SetTextColor(0, 0, 60);
1754 $title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
1755 $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1756 if ($object->status == $object::STATUS_DRAFT) {
1757 $pdf->SetTextColor(128, 0, 0);
1758 $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1759 }
1760
1761 $pdf->MultiCell($w, 4, $title, '', 'R');
1762
1763 $pdf->SetFont('', 'B', $default_font_size);
1764
1765 /*
1766 $posy += 5;
1767 $pdf->SetXY($posx, $posy);
1768 $pdf->SetTextColor(0, 0, 60);
1769 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1770 if ($object->status == $object::STATUS_DRAFT) {
1771 $pdf->SetTextColor(128, 0, 0);
1772 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1773 }
1774 $pdf->MultiCell($w, 4, $textref, '', 'R');
1775 */
1776
1777 $posy += 3;
1778 $pdf->SetFont('', '', $default_font_size - 2);
1779
1780 $ref_customer = $object->ref_customer ?: $object->ref_client;
1781 if ($ref_customer) {
1782 $posy += 4;
1783 $pdf->SetXY($posx, $posy);
1784 $pdf->SetTextColor(0, 0, 60);
1785 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".pdf_truncate_text($pdf, $outputlangs->convToOutputCharset($ref_customer), 65), '', 'R');
1786 }
1787
1788 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
1789 $object->fetchProject();
1790 if (!empty($object->project->title)) {
1791 $posy += 3;
1792 $pdf->SetXY($posx, $posy);
1793 $pdf->SetTextColor(0, 0, 60);
1794 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ". pdf_truncate_text($pdf, $object->project->title, 50), '', 'R');
1795 $posy = $pdf->getY();
1796 }
1797 }
1798
1799 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
1800 $object->fetchProject();
1801 if (!empty($object->project->ref)) {
1802 $outputlangs->load("projects");
1803 $posy += 3;
1804 $pdf->SetXY($posx, $posy);
1805 $pdf->SetTextColor(0, 0, 60);
1806 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ". $object->project->ref, '', 'R');
1807 }
1808 }
1809
1810 if (getDolGlobalString('MAIN_PDF_DATE_TEXT')) {
1811 $displaydate = "daytext";
1812 } else {
1813 $displaydate = "day";
1814 }
1815
1816 //$posy += 4;
1817 $posy = $pdf->getY();
1818 $pdf->SetXY($posx, $posy);
1819 $pdf->SetTextColor(0, 0, 60);
1820 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, $displaydate, false, $outputlangs, true), '', 'R');
1821
1822 $posy += 4;
1823 $pdf->SetXY($posx, $posy);
1824 $pdf->SetTextColor(0, 0, 60);
1825
1826 $title = $outputlangs->transnoentities("DateEndPropal");
1827 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1828 $title .= ' - '.$outputlangsbis->transnoentities("DateEndPropal");
1829 }
1830 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->fin_validite, $displaydate, false, $outputlangs, true), '', 'R');
1831
1832 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
1833 $posy += 4;
1834 $pdf->SetXY($posx, $posy);
1835 $pdf->SetTextColor(0, 0, 60);
1836 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_client), '', 'R');
1837 }
1838
1839 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && $object->thirdparty->code_compta_client) {
1840 $posy += 4;
1841 $pdf->SetXY($posx, $posy);
1842 $pdf->SetTextColor(0, 0, 60);
1843 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_compta_client), '', 'R');
1844 }
1845
1846 // Get contact
1847 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
1848 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1849 if (count($arrayidcontact) > 0) {
1850 $usertmp = new User($this->db);
1851 $usertmp->fetch($arrayidcontact[0]);
1852 $posy += 4;
1853 $pdf->SetXY($posx, $posy);
1854 $pdf->SetTextColor(0, 0, 60);
1855 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1856 }
1857 }
1858
1859 $posy += 2;
1860 $shipp_shift = 0;
1861 $top_shift = 0;
1862 // Show list of linked objects
1863 $current_y = $pdf->getY();
1864 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); // May modify $object->note_public
1865 if ($current_y < $pdf->getY()) {
1866 $top_shift = $pdf->getY() - $current_y;
1867 }
1868
1869 if ($showaddress) {
1870 // Sender properties
1871 $carac_emetteur = '';
1872 // Add internal contact of object if defined
1873 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1874 if (count($arrayidcontact) > 0) {
1875 $object->fetch_user($arrayidcontact[0]);
1876 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1877 $carac_emetteur .= $labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1878 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1879 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1880 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1881 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1882 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1883 $carac_emetteur .= "\n";
1884 }
1885
1886 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1887
1888 // Show sender
1889 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 30 : 32;
1890 $posy += $top_shift + $this->marge_haute;
1891 $posx = $this->marge_gauche;
1892 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1893 $posx = $this->page_largeur - $this->marge_droite - 80;
1894 }
1895
1896 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1897 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1898
1899
1900 // Show sender frame
1901 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1902 $pdf->SetTextColor(0, 0, 0);
1903 $pdf->SetFont('', '', $default_font_size - 2);
1904 $pdf->SetXY($posx, $posy - 5);
1905 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1906 $pdf->SetXY($posx, $posy);
1907 $pdf->SetFillColor(230, 230, 230);
1908 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1909 $pdf->SetTextColor(0, 0, 60);
1910 }
1911
1912 // Show sender name
1913 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1914 $pdf->SetXY($posx + 2, $posy + 3);
1915 $pdf->SetFont('', 'B', $default_font_size);
1916 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1917 $posy = $pdf->getY();
1918 }
1919
1920 // Show sender information
1921 $pdf->SetXY($posx + 2, $posy);
1922 $pdf->SetFont('', '', $default_font_size - 1);
1923 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1924
1925
1926 // If CUSTOMER contact defined, we use it
1927 $usecontact = false;
1928 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1929 if (count($arrayidcontact) > 0) {
1930 $usecontact = true;
1931 $result = $object->fetch_contact($arrayidcontact[0]);
1932 }
1933
1934 // Recipient name
1935 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1936 $thirdparty = $object->contact;
1937 } else {
1938 $thirdparty = $object->thirdparty;
1939 }
1940
1941 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1942
1943 $mode = 'target';
1944 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), $mode, $object);
1945
1946 // Show recipient
1947 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1948 if ($this->page_largeur < 210) {
1949 $widthrecbox = 84; // To work with US executive format
1950 }
1951 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 30 + $this->marge_haute : 32 + $this->marge_haute;
1952 $posy += $top_shift;
1953 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1954 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1955 $posx = $this->marge_gauche;
1956 }
1957
1958 // Show recipient frame
1959 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1960 $pdf->SetTextColor(0, 0, 0);
1961 $pdf->SetFont('', '', $default_font_size - 2);
1962 $pdf->SetXY($posx + 2, $posy - 5);
1963 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1964 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1965 }
1966
1967 // Show recipient name
1968 $pdf->SetXY($posx + 2, $posy + 3);
1969 $pdf->SetFont('', 'B', $default_font_size);
1970 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1971 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1972
1973 $posy = $pdf->getY();
1974
1975 // Show recipient information
1976 $pdf->SetFont('', '', $default_font_size - 1);
1977 $pdf->SetXY($posx + 2, $posy);
1978 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1979 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1980 // Show shipping/delivery addressAdd commentMore actions
1981 if (getDolGlobalInt('PROPOSAL_SHOW_SHIPPING_ADDRESS')) {
1982 $idaddressshipping = $object->getIdContact('external', 'SHIPPING');
1983
1984 if (!empty($idaddressshipping)) {
1985 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
1986 $companystatic = new Societe($this->db);
1987 $companystatic->fetch($object->contact->fk_soc);
1988 $carac_client_name_shipping = pdfBuildThirdpartyName($object->contact, $outputlangs);
1989 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, 1, 'targetshipping', $object);
1990 } else {
1991 $carac_client_name_shipping = pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
1992 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'targetshipping', $object);
1993 }
1994 if (!empty($carac_client_shipping)) {
1995 $posy += $hautcadre;
1996
1997 $hautcadre -= 5; // Height for the shipping address does not need to be as high as main box
1998
1999 // Show shipping frame
2000 $pdf->SetXY($posx + 2, $posy - 5);
2001 $pdf->SetFont('', '', $default_font_size - 2);
2002 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities('ShippingTo'), 0, 'L', false);
2003 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
2004
2005 // Show shipping name
2006 $pdf->SetXY($posx + 2, $posy + 3);
2007 $pdf->SetFont('', 'B', $default_font_size);
2008 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L');
2009
2010 $posy = $pdf->getY();
2011
2012 // Show shipping information
2013 $pdf->SetXY($posx + 2, $posy);
2014 $pdf->SetFont('', '', $default_font_size - 1);
2015 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L');
2016
2017 $shipp_shift += $hautcadre + 10;
2018 }
2019 }
2020 }
2021 $pdf->SetTextColor(0, 0, 0);
2022
2023 return array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift);
2024 }
2025
2026 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
2036 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2037 {
2038 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2039 return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
2040 }
2041
2051 protected function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
2052 {
2053 $default_font_size = pdf_getPDFFontSize($outputlangs);
2054 $tab_top = $posy + 4;
2055 $tab_hl = 4;
2056
2057 $posx = 120;
2058 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
2059
2060 // Total HT
2061 $pdf->SetFillColor(255, 255, 255);
2062 $pdf->SetXY($posx, $tab_top);
2063 $pdf->SetFont('', '', $default_font_size - 2);
2064 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', true);
2065
2066 $pdf->SetXY($posx, $tab_top + $tab_hl + 3);
2067 //$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
2068 $pdf->RoundedRect($posx, $tab_top + $tab_hl + 3, $largcol, $tab_hl * 3, $this->corner_radius, '1234', 'D');
2069
2070
2071 if (getDolGlobalString('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING')) {
2072 // Can be retrieve with getSignatureAppearanceArray()
2073 // Can be also detected by putting the mouse over the area when using evince pdf reader
2074 $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl + 3, $largcol, $tab_hl * 3);
2075 }
2076
2077 return ($tab_hl * 7);
2078 }
2079
2080
2091 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2092 {
2093 global $hookmanager;
2094
2095 // Default field style for content
2096 $this->defaultContentsFieldsStyle = array(
2097 'align' => 'R', // R,C,L
2098 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2099 );
2100
2101 // Default field style for content
2102 $this->defaultTitlesFieldsStyle = array(
2103 'align' => 'C', // R,C,L
2104 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2105 );
2106
2107 /*
2108 * For example
2109 $this->cols['theColKey'] = array(
2110 'rank' => $rank, // int : use for ordering columns
2111 'width' => 20, // the column width in mm
2112 'title' => array(
2113 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2114 'label' => ' ', // the final label : used fore final generated text
2115 'align' => 'L', // text alignment : R,C,L
2116 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2117 ),
2118 'content' => array(
2119 'align' => 'L', // text alignment : R,C,L
2120 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2121 ),
2122 );
2123 */
2124
2125 $rank = 0; // do not use negative rank
2126 $this->cols['position'] = array(
2127 'rank' => $rank,
2128 'width' => 10.0,
2129 'status' => getDolGlobalInt('PDF_CYAN_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
2130 'title' => array(
2131 'textkey' => '#', // use lang key is useful in some case with module
2132 'align' => 'C',
2133 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2134 // 'label' => ' ', // the final label
2135 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2136 ),
2137 'content' => array(
2138 'align' => 'C',
2139 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2140 ),
2141 );
2142
2143 $rank = 5; // do not use negative rank
2144 $this->cols['desc'] = array(
2145 'rank' => $rank,
2146 'width' => false, // only for desc
2147 'status' => true,
2148 'title' => array(
2149 'textkey' => 'Designation', // use lang key is useful in some case with module
2150 'align' => 'L',
2151 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2152 // 'label' => ' ', // the final label
2153 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2154 ),
2155 'content' => array(
2156 'align' => 'L',
2157 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2158 ),
2159 );
2160
2161 // Image of product
2162 $rank += 10;
2163 $this->cols['photo'] = array(
2164 'rank' => $rank,
2165 'width' => (float) getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
2166 'status' => false,
2167 'title' => array(
2168 'textkey' => 'Photo',
2169 'label' => ' '
2170 ),
2171 'content' => array(
2172 'padding' => array(0.0, 0.0, 0.0, 0.0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2173 ),
2174 'border-left' => false, // remove left line separator
2175 );
2176
2177 if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE') && !empty($this->atleastonephoto)) {
2178 $this->cols['photo']['status'] = true;
2179 $this->cols['photo']['border-left'] = true;
2180 }
2181
2182
2183 $rank += 10;
2184 $this->cols['vat'] = array(
2185 'rank' => $rank,
2186 'status' => false,
2187 'width' => 16.0, // in mm
2188 'title' => array(
2189 'textkey' => 'VAT'
2190 ),
2191 'border-left' => true, // add left line separator
2192 );
2193
2194 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
2195 $this->cols['vat']['status'] = true;
2196 }
2197
2198 $rank += 10;
2199 $this->cols['subprice'] = array(
2200 'rank' => $rank,
2201 'width' => 19.0, // in mm
2202 'status' => true,
2203 'title' => array(
2204 'textkey' => 'PriceUHT'
2205 ),
2206 'border-left' => true, // add left line separator
2207 );
2208
2209 // Adapt dynamically the width of subprice, if text is too long.
2210 $tmpwidth = 0;
2211 $nblines = count($object->lines);
2212 for ($i = 0; $i < $nblines; $i++) {
2213 $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
2214 $tmpwidth = max($tmpwidth, $tmpwidth2);
2215 }
2216 if ($tmpwidth > 10) {
2217 $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
2218 }
2219
2220 $rank += 10;
2221 $this->cols['qty'] = array(
2222 'rank' => $rank,
2223 'width' => 16.0, // in mm
2224 'status' => true,
2225 'title' => array(
2226 'textkey' => 'Qty'
2227 ),
2228 'border-left' => true, // add left line separator
2229 );
2230
2231 $rank += 10;
2232 $this->cols['unit'] = array(
2233 'rank' => $rank,
2234 'width' => 11.0, // in mm
2235 'status' => false,
2236 'title' => array(
2237 'textkey' => 'Unit'
2238 ),
2239 'border-left' => true, // add left line separator
2240 );
2241 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
2242 $this->cols['unit']['status'] = true;
2243 }
2244
2245 $rank += 10;
2246 $this->cols['discount'] = array(
2247 'rank' => $rank,
2248 'width' => 13.0, // in mm
2249 'status' => false,
2250 'title' => array(
2251 'textkey' => 'ReductionShort'
2252 ),
2253 'border-left' => true, // add left line separator
2254 );
2255 if ($this->atleastonediscount) {
2256 $this->cols['discount']['status'] = true;
2257 }
2258
2259 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
2260 $this->cols['totalexcltax'] = array(
2261 'rank' => $rank,
2262 'width' => 26.0, // in mm
2263 'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX'),
2264 'title' => array(
2265 'textkey' => 'TotalHTShort'
2266 ),
2267 'border-left' => true, // add left line separator
2268 );
2269
2270 $rank += 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
2271 $this->cols['totalincltax'] = array(
2272 'rank' => $rank,
2273 'width' => 26.0, // in mm
2274 'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'),
2275 'title' => array(
2276 'textkey' => 'TotalTTCShort'
2277 ),
2278 'border-left' => true, // add left line separator
2279 );
2280
2281 // Add extrafields cols
2282 if (!empty($object->lines)) {
2283 $line = reset($object->lines);
2284 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
2285 }
2286
2287 $parameters = array(
2288 'object' => $object,
2289 'outputlangs' => $outputlangs,
2290 'hidedetails' => $hidedetails,
2291 'hidedesc' => $hidedesc,
2292 'hideref' => $hideref
2293 );
2294
2295 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
2296 if ($reshook < 0) {
2297 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2298 } elseif (empty($reshook)) {
2299 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
2300 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
2301 } else {
2302 $this->cols = $hookmanager->resArray;
2303 }
2304 }
2305}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bank accounts.
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getMaxAfterColsLinePositionsData()
Get position in PDF after col display.
mustAddTermsOfSale($object, $type)
Return if the terms of sale file must be concatenated to the generated document.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)
Used for to set afterColsLinePositions var in a pdf draw line loop.
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
resetAfterColsLinePositionsData(float $y, int $pageNumb)
Used for reset afterColsLinePositions var in start of a new pdf draw line loop.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Class to manage hooks.
Class mere des modeles de propale.
Class to manage products or services.
Put here description of your class.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
Class to generate PDF proposal Cyan.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
__construct($db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_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.
drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
drawInfoTable(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
global $mysoc
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
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_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:3263
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition pdf.lib.php:2964
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails=0, $multicurrency=0)
Return line total amount discount.
Definition pdf.lib.php:3295
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation The hook 'pdf_writeLinkedObjects' can replace this block (retu...
Definition pdf.lib.php:1870
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:296
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation The hook 'pdf_bank' can replace this block (return > 0).
Definition pdf.lib.php:1286
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition pdf.lib.php:3014
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2553
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:2491
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:792
pdfGetHeightForHtmlContent($pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
Definition pdf.lib.php:385
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:1479
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:275
pdf_render_subtotals(TCPDF $pdf, CommonDocGenerator $generator, float $curY, CommonObject $object, int $i, Translate $outputlangs, int $hideref, int $hidedesc, array $bgColor, bool $isSubtotal=false, bool $applySubtotalLogic=true)
Render subtotals line with a colored background and adapted text color .
Definition pdf.lib.php:3395
pdf_truncate_text($pdf, $text, $max_width, $ellipsis_pos=1, $ellipsis="\u{2026}")
Truncates text to fit a specified width in TCPDF, with configurable ellipsis position.
Definition pdf.lib.php:3483
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:481
pdf_writeLogoOrCompanyName($pdf, $outputlangs, $emetteur, $logodir, $posx, $posy, $w, $default_font_size, $align)
Output company logo on top-left of a PDF page header, or the company name as fallback text if no logo...
Definition pdf.lib.php:351
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
Definition pdf.lib.php:2798
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2841
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2638
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:1180
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:436
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:165