dolibarr 24.0.3
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-2025 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 // TODO remise_percent is an obsolete field for object parent
822 /*if ($object->remise_percent) {
823 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
824 }
825 if ($object->remise_percent) {
826 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
827 }
828 if ($object->remise_percent) {
829 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
830 }*/
831
832 $vatrate = (string) $object->lines[$i]->tva_tx;
833
834 // Retrieve type from database for backward compatibility with old records
835 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
836 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
837 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
838 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
839 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
840 }
841
842 // retrieve global local tax
843 if ($localtax1_type && $localtax1ligne != 0) {
844 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
845 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
846 } else {
847 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
848 }
849 }
850 if ($localtax2_type && $localtax2ligne != 0) {
851 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
852 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
853 } else {
854 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
855 }
856 }
857
858 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
859 $vatrate .= '*';
860 }
861
862 // Fill $this->tva and $this->tva_array
863 if (!isset($this->tva[$vatrate])) {
864 $this->tva[$vatrate] = 0;
865 }
866 $this->tva[$vatrate] += $tvaligne;
867 $vatcode = $object->lines[$i]->vat_src_code;
868 if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
869 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
870 }
871 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
872
873
874 if (!$hidenextline) {
875 $afterPosData = $this->getMaxAfterColsLinePositionsData();
876 $pdf->setPage($afterPosData['page']);
877 $nexY = $afterPosData['y'];
878
879 // Add line
880 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData['y'] < $this->page_hauteur - $heightforfooter - 5) {
881 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
882 //$pdf->SetDrawColor(190,190,200);
883 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
884 $pdf->SetLineStyle(array('dash' => 0));
885 }
886 }
887
888 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
889 $hidenextline = 1;
890 }
891
892 $nexY += 0; // Add space between lines
893 }
894
895
896 // Add last page for document footer if there are not enough size left
897 $afterPosData = $this->getMaxAfterColsLinePositionsData();
898 if (isset($afterPosData['y']) && $afterPosData['y'] > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
899 $pdf->AddPage();
900 if (!empty($tplidx)) {
901 $pdf->useTemplate($tplidx);
902 }
903 $pagenb++;
904 $pdf->setPage($pagenb);
905 }
906
907 // Draw table frames and columns borders
908 $drawTabNumbPage = $pdf->getNumPages();
909 for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) {
910 $pdf->setPage($i);
911 // reset page orientation each loop to override it if it was changed
912 $pdf->setPageOrientation('', false, 0); // The only function to edit the bottom margin of current page to set it.
913
914 $drawTabHideTop = $hidetop;
915 $drawTabTop = $tab_top_newpage;
916 $drawTabBottom = $this->page_hauteur - $heightforfooter;
917 $hideBottom = 0; // TODO understand why it change to 1 or 0 during process
918
919 if ($i == $pageposbeforeprintlines) {
920 // first page need to start after notes
921 $drawTabTop = $tab_top;
922 } elseif (!$drawTabHideTop) {
923 if (getDolGlobalInt('MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
924 $drawTabTop -= $this->tabTitleHeight;
925 } else {
926 $drawTabHideTop = 1;
927 }
928 }
929
930 // last page need to include document footer
931 if ($i == $pdf->getNumPages()) {
932 // remove document footer height to tab bottom position
933 $drawTabBottom -= $heightforsignature + $heightforfreetext + $heightforinfotot;
934 }
935
936 $drawTabHeight = $drawTabBottom - $drawTabTop;
937 $this->_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom, $object->multicurrency_code, $outputlangsbis);
938
939 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0; // Display free text only in last page
940 $this->_pagefoot($pdf, $object, $outputlangs, $hideFreeText);
941
942 $pdf->setPage($i); // in case of _pagefoot or _tableau change it
943
944 // reset page orientation each loop to override it if it was changed by _pagefoot or _tableau change it
945 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
946
947 // Don't print head on first page ($pageposbeforeprintlines) because already added previously
948 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
949 $this->_pagehead($pdf, $object, 0, $outputlangs);
950 }
951 if (!empty($tplidx)) {
952 $pdf->useTemplate($tplidx);
953 }
954 }
955
956 // reset text color before print footers
957 $pdf->SetTextColor(0, 0, 0);
958
959 $pdf->setPage($pdf->getNumPages());
960
961 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
962
963 // Display infos area
964 $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
965
966 // Display total zone
967 $posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
968
969 // Customer signature area
970 if (!getDolGlobalString('PROPAL_DISABLE_SIGNATURE')) {
971 $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
972
973 // Rewrite keywords to add a tag with the numero of page that contains the signature section
974 $keywords = $outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name);
975 $pdf->SetKeyWords($keywords." PAGESIGN=".$pdf->getPage());
976 }
977
978 // Add number of pages in footer
979 if (method_exists($pdf, 'AliasNbPages')) {
980 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
981 }
982
983 // Add terms to sale
984 $termsofsalefilename = getDolGlobalString('MAIN_INFO_PROPAL_TERMSOFSALE');
985 if (getDolGlobalInt('MAIN_PDF_ADD_TERMSOFSALE_PROPAL') && $termsofsalefilename) {
986 $termsofsale = $conf->propal->dir_output.'/'.$termsofsalefilename;
987 if (!empty($conf->propal->multidir_output[$object->entity ?? $conf->entity])) {
988 $termsofsale = $conf->propal->multidir_output[$object->entity ?? $conf->entity].'/'.$termsofsalefilename;
989 }
990 if (file_exists($termsofsale) && is_readable($termsofsale)) {
991 $pagecount = $pdf->setSourceFile($termsofsale);
992 for ($i = 1; $i <= $pagecount; $i++) {
993 $tplIdx = $pdf->importPage($i);
994 if ($tplIdx !== false) {
995 $s = $pdf->getTemplatesize($tplIdx);
996 $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
997 $pdf->useTemplate($tplIdx);
998 } else {
999 setEventMessages(null, array($termsofsale.' cannot be added, probably protected PDF'), 'warnings');
1000 }
1001 }
1002 }
1003 }
1004
1005 //If propal merge product PDF is active
1006 if (getDolGlobalString('PRODUIT_PDF_MERGE_PROPAL')) {
1007 require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
1008
1009 $already_merged = array();
1010 foreach ($object->lines as $line) {
1011 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
1012 // Find the desired PDF
1013 $filetomerge = new Propalmergepdfproduct($this->db);
1014
1015 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1016 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
1017 } else {
1018 $filetomerge->fetch_by_product($line->fk_product);
1019 }
1020
1021 $already_merged[] = $line->fk_product;
1022
1023 $product = new Product($this->db);
1024 $product->fetch($line->fk_product);
1025
1026 if ($product->entity != $conf->entity) {
1027 $entity_product_file = $product->entity;
1028 } else {
1029 $entity_product_file = $conf->entity;
1030 }
1031
1032 // If PDF is selected and file is not empty
1033 if (count($filetomerge->lines) > 0) {
1034 foreach ($filetomerge->lines as $linefile) {
1035 if (!empty($linefile->id) && !empty($linefile->file_name)) {
1036 $filetomerge_dir = null;
1037 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
1038 if (isModEnabled("product")) {
1039 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
1040 } elseif (isModEnabled("service")) {
1041 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
1042 }
1043 } else {
1044 if (isModEnabled("product")) {
1045 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
1046 } elseif (isModEnabled("service")) {
1047 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file ?? $conf->entity].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
1048 }
1049 }
1050
1051 dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, $filetomerge_dir === null ? LOG_ERR : LOG_DEBUG);
1052 if ($filetomerge_dir === null) {
1053 // Skip loop
1054 continue;
1055 }
1056
1057 $infile = $filetomerge_dir.'/'.$linefile->file_name;
1058 if (file_exists($infile) && is_readable($infile)) {
1059 $pagecount = $pdf->setSourceFile($infile);
1060 for ($i = 1; $i <= $pagecount; $i++) {
1061 $tplIdx = $pdf->importPage($i);
1062 if ($tplIdx !== false) {
1063 $s = $pdf->getTemplatesize($tplIdx);
1064 $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
1065 $pdf->useTemplate($tplIdx);
1066 } else {
1067 setEventMessages(null, array($infile.' cannot be added, probably protected PDF'), 'warnings');
1068 }
1069 }
1070 }
1071 }
1072 }
1073 }
1074 }
1075 }
1076 }
1077
1078 $pdf->Close();
1079
1080 $pdf->Output($file, 'F');
1081
1082 //Add pdfgeneration hook
1083 $hookmanager->initHooks(array('pdfgeneration'));
1084 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
1085 global $action;
1086 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1087 $this->warnings = $hookmanager->warnings;
1088 if ($reshook < 0) {
1089 $this->error = $hookmanager->error;
1090 $this->errors = $hookmanager->errors;
1091 dolChmod($file);
1092 return -1;
1093 }
1094
1095 dolChmod($file);
1096
1097 $this->result = array('fullpath' => $file);
1098
1099 return 1; // No error
1100 } else {
1101 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
1102 return 0;
1103 }
1104 } else {
1105 $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
1106 return 0;
1107 }
1108 }
1109
1119 public function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
1120 {
1121 global $mysoc;
1122
1123 $default_font_size = pdf_getPDFFontSize($outputlangs);
1124
1125 $pdf->SetFont('', '', $default_font_size - 1);
1126
1127 $diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3);
1128
1129 // If France, show VAT mention if not applicable
1130 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
1131 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1132 $pdf->SetXY($this->marge_gauche, $posy);
1133 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', false);
1134
1135 $posy = $pdf->GetY() + 4;
1136 }
1137
1138 $posxval = 52;
1139 if (getDolGlobalString('MAIN_PDF_DELIVERY_DATE_TEXT')) {
1140 $displaydate = "daytext";
1141 } else {
1142 $displaydate = "day";
1143 }
1144
1145 // Show shipping date
1146 if (!empty($object->delivery_date)) {
1147 $outputlangs->load("sendings");
1148 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1149 $pdf->SetXY($this->marge_gauche, $posy);
1150 $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
1151 $pdf->MultiCell(80, 4, $titre, 0, 'L');
1152 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1153 $pdf->SetXY($posxval, $posy);
1154 $dlp = dol_print_date($object->delivery_date, $displaydate, false, $outputlangs, true);
1155 $pdf->MultiCell(80, 4, $dlp, 0, 'L');
1156
1157 $posy = $pdf->GetY() + 1;
1158 } elseif ($object->availability_code || $object->availability) { // Show availability conditions
1159 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1160 $pdf->SetXY($this->marge_gauche, $posy);
1161 $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
1162 $pdf->MultiCell(80, 4, $titre, 0, 'L');
1163 $pdf->SetTextColor(0, 0, 0);
1164 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1165 $pdf->SetXY($posxval, $posy);
1166 $lib_availability = ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
1167 $lib_availability = str_replace('\n', "\n", $lib_availability);
1168 $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
1169
1170 $posy = $pdf->GetY() + 1;
1171 }
1172
1173 // Show delivery mode
1174 if (!getDolGlobalString('PROPOSAL_PDF_HIDE_DELIVERYMODE') && $object->shipping_method_id > 0) {
1175 $outputlangs->load("sendings");
1176
1177 $shipping_method_id = $object->shipping_method_id;
1178 if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1179 $shipping_method_id = $this->emetteur->shipping_method_id;
1180 }
1181 $shipping_method_code = dol_getIdFromCode($this->db, (string) $shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
1182 $shipping_method_label = dol_getIdFromCode($this->db, (string) $shipping_method_id, 'c_shipment_mode', 'rowid', 'libelle');
1183
1184 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1185 $pdf->SetXY($this->marge_gauche, $posy);
1186 $titre = $outputlangs->transnoentities("SendingMethod").':';
1187 $pdf->MultiCell(43, 4, $titre, 0, 'L');
1188
1189 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1190 $pdf->SetXY($posxval, $posy);
1191 $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;
1192 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1193 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1194
1195 $posy = $pdf->GetY() + 1;
1196 }
1197
1198 // Show payments conditions
1199 if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTTERM') && $object->cond_reglement_code) {
1200 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1201 $pdf->SetXY($this->marge_gauche, $posy);
1202 $titre = $outputlangs->transnoentities("PaymentConditions").':';
1203 $pdf->MultiCell(43, 4, $titre, 0, 'L');
1204
1205 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1206 $pdf->SetXY($posxval, $posy);
1207 $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);
1208 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1209 if ($object->deposit_percent > 0) {
1210 $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
1211 }
1212 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1213
1214 $posy = $pdf->GetY() + 3;
1215 }
1216
1217 if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTMODE')) {
1218 // Show payment mode
1219 if ($object->mode_reglement_code
1220 && $object->mode_reglement_code != 'CHQ'
1221 && $object->mode_reglement_code != 'VIR') {
1222 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1223 $pdf->SetXY($this->marge_gauche, $posy);
1224 $titre = $outputlangs->transnoentities("PaymentMode").':';
1225 $pdf->MultiCell(80, 5, $titre, 0, 'L');
1226 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1227 $pdf->SetXY($posxval, $posy);
1228 $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);
1229 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1230
1231 $posy = $pdf->GetY() + 2;
1232 }
1233
1234 // Show payment mode CHQ
1235 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
1236 // Si mode reglement non force ou si force a CHQ
1237 if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
1238 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
1239 $account = new Account($this->db);
1240 $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
1241
1242 $pdf->SetXY($this->marge_gauche, $posy);
1243 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', false);
1245 $posy = $pdf->GetY() + 1;
1246
1247 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1248 $pdf->SetXY($this->marge_gauche, $posy);
1249 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1250 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', false);
1251 $posy = $pdf->GetY() + 2;
1252 }
1253 }
1254 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
1255 $pdf->SetXY($this->marge_gauche, $posy);
1256 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1257 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', false);
1258 $posy = $pdf->GetY() + 1;
1259
1260 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1261 $pdf->SetXY($this->marge_gauche, $posy);
1262 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1263 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', false);
1264 $posy = $pdf->GetY() + 2;
1265 }
1266 }
1267 }
1268 }
1269
1270 // If payment mode not forced or forced to VIR, show payment with BAN
1271 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1272 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1273 $bankid = ($object->fk_account <= 0 ? getDolGlobalInt('FACTURE_RIB_NUMBER') : $object->fk_account);
1274 if ($object->fk_bank > 0) {
1275 $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1276 }
1277 $account = new Account($this->db);
1278 $account->fetch((int) $bankid);
1279
1280 $curx = $this->marge_gauche;
1281 $cury = $posy;
1282
1283 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1284
1285 $posy += 2;
1286 }
1287 }
1288 }
1289
1290 return $posy;
1291 }
1292
1293
1305 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
1306 {
1307 global $conf, $mysoc, $hookmanager;
1308
1309 $default_font_size = pdf_getPDFFontSize($outputlangs);
1310
1311 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
1312 $outputlangsbis = new Translate('', $conf);
1313 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
1314 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1315 $default_font_size--;
1316 }
1317
1318 $tab2_top = $posy;
1319 $tab2_hl = 4;
1320 $pdf->SetFont('', '', $default_font_size - 1);
1321
1322 // Total table
1323 $col1x = 120;
1324 $col2x = 170;
1325 if ($this->page_largeur < 210) { // To work with US executive format
1326 $col2x -= 20;
1327 }
1328 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1329
1330 $useborder = 0;
1331 $index = 0;
1332
1333 // Get Total HT
1334 $total_ht = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1335
1336 // Total discount
1337 $total_discount_on_lines = 0;
1338 $multicurrency_total_discount_on_lines = 0;
1339 foreach ($object->lines as $i => $line) {
1340 $resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
1341 $multicurrency_resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2, 1);
1342
1343 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1344 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1345 // If line was a negative line, we do not count the discount as a discount
1346 if ($line->total_ht < 0) {
1347 $total_discount_on_lines += -$line->total_ht;
1348 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1349 }
1350 }
1351
1352 if ($total_discount_on_lines > 0) {
1353 if ($this->showAmountBeforeDiscount) {
1354 // Show total NET before discount
1355 $pdf->SetFillColor(255, 255, 255);
1356 $pdf->SetXY($col1x, $tab2_top);
1357 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount") . (is_object($outputlangsbis) ? ' / ' . $outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', true);
1358 $pdf->SetXY($col2x, $tab2_top);
1359
1360 $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));
1361 $pdf->MultiCell($largcol2, $tab2_hl, price($total_before_discount_to_show, 0, $outputlangs), 0, 'R', true);
1362
1363 $index++;
1364 }
1365
1366 if ($this->showDiscountAmount) {
1367 $pdf->SetFillColor(255, 255, 255);
1368 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1369 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount") . (is_object($outputlangsbis) ? ' / ' . $outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', true);
1370 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1371
1372 $total_discount_to_show = ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1373 $pdf->MultiCell($largcol2, $tab2_hl, price($total_discount_to_show, 0, $outputlangs), 0, 'R', true);
1374
1375 $index++;
1376 }
1377 }
1378
1379 // Total HT
1380 $pdf->SetFillColor(255, 255, 255);
1381 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1382 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', true);
1383
1384 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1385 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1386 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', true);
1387
1388 // Show VAT by rates and total
1389 $pdf->SetFillColor(248, 248, 248);
1390
1391 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1392 $total_ttc_origin = $object->total_ttc;
1393
1394 $this->atleastoneratenotnull = 0;
1395 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
1396 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
1397 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1398 // Nothing to do
1399 } else {
1400 //Local tax 1 before VAT
1401 //if (getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == 'localtax1on')
1402 //{
1403 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1404 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1405 continue;
1406 }
1407
1408 foreach ($localtax_rate as $tvakey => $tvaval) {
1409 if ($tvakey != 0) { // On affiche pas taux 0
1410 //$this->atleastoneratenotnull++;
1411
1412 $index++;
1413 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1414
1415 $tvacompl = '';
1416 if (preg_match('/\*/', $tvakey)) {
1417 $tvakey = str_replace('*', '', $tvakey);
1418 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1419 }
1420 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1421 $totalvat .= ' ';
1422 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1423 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1424
1425 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1426
1427 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1428 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1429 }
1430 }
1431 }
1432 //}
1433 //Local tax 2 before VAT
1434 //if (getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == 'localtax2on')
1435 //{
1436 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1437 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1438 continue;
1439 }
1440
1441 foreach ($localtax_rate as $tvakey => $tvaval) {
1442 if ($tvakey != 0) { // On affiche pas taux 0
1443 //$this->atleastoneratenotnull++;
1444
1445 $index++;
1446 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1447
1448 $tvacompl = '';
1449 if (preg_match('/\*/', $tvakey)) {
1450 $tvakey = str_replace('*', '', $tvakey);
1451 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1452 }
1453 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1454 $totalvat .= ' ';
1455 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1456 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1457
1458 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1459
1460 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1461 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1462 }
1463 }
1464 }
1465 //}
1466
1467 // VAT
1468 foreach ($this->tva as $tvakey => $tvaval) {
1469 if ($tvakey != 0) { // On affiche pas taux 0
1470 $this->atleastoneratenotnull++;
1471
1472 $index++;
1473 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1474
1475 $tvacompl = '';
1476 if (preg_match('/\*/', $tvakey)) {
1477 $tvakey = str_replace('*', '', $tvakey);
1478 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1479 }
1480 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1481 $totalvat .= ' ';
1482 $totalvat .= vatrate($tvakey, true).$tvacompl;
1483 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1484
1485 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1486 $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', true);
1487 }
1488 }
1489
1490 //Local tax 1 after VAT
1491 //if (getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == 'localtax1on')
1492 //{
1493 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1494 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1495 continue;
1496 }
1497
1498 foreach ($localtax_rate as $tvakey => $tvaval) {
1499 if ($tvakey != 0) { // On affiche pas taux 0
1500 //$this->atleastoneratenotnull++;
1501
1502 $index++;
1503 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1504
1505 $tvacompl = '';
1506 if (preg_match('/\*/', $tvakey)) {
1507 $tvakey = str_replace('*', '', $tvakey);
1508 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1509 }
1510 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1511 $totalvat .= ' ';
1512
1513 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1514 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1515
1516 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1517
1518 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1519 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1520 }
1521 }
1522 }
1523 //}
1524 //Local tax 2 after VAT
1525 //if (getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') && getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == 'localtax2on')
1526 //{
1527 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1528 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1529 continue;
1530 }
1531
1532 foreach ($localtax_rate as $tvakey => $tvaval) {
1533 // retrieve global local tax
1534 if ($tvakey != 0) { // On affiche pas taux 0
1535 //$this->atleastoneratenotnull++;
1536
1537 $index++;
1538 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1539
1540 $tvacompl = '';
1541 if (preg_match('/\*/', $tvakey)) {
1542 $tvakey = str_replace('*', '', $tvakey);
1543 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1544 }
1545 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1546 $totalvat .= ' ';
1547
1548 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1549 $totalvat .= $tvacompl;
1550 } else {
1551 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1552 }
1553
1554 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1555
1556 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1557
1558 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1559 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1560 }
1561 }
1562 }
1563 //}
1564
1565 // Total TTC
1566 $index++;
1567 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1568 $pdf->SetTextColor(0, 0, 60);
1569 $pdf->SetFillColor(224, 224, 224);
1570 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : ''), $useborder, 'L', true);
1571
1572 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1573 if (!isModEnabled("multicurrency") || $object->multicurrency_tx == 1 || getDolGlobalInt('MULTICURRENCY_SHOW_ALSO_MAIN_CURRENCY_ON_PDF') == 0) {
1574 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', true);
1575 } else {
1576 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', true);
1577
1578 //$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');
1579 $index++;
1580 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1581 $pdf->SetTextColor(0, 0, 60);
1582 $pdf->SetFillColor(224, 224, 224);
1583 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : '').' ('.$outputlangs->getCurrencySymbol($mysoc->currency_code).')', $useborder, 'L', true);
1584
1585 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1586 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc_origin, 0, $outputlangs, 1, -1, -1, $mysoc->currency_code), $useborder, 'L', true);
1587 }
1588 }
1589 }
1590
1591 $pdf->SetTextColor(0, 0, 0);
1592
1593 $resteapayer = 0;
1594 /*
1595 $resteapayer = $object->total_ttc - $deja_regle;
1596 if (!empty($object->paye)) $resteapayer=0;
1597 */
1598
1599 if ($deja_regle > 0) {
1600 // Already paid + Deposits
1601 $index++;
1602
1603 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1604 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', false);
1605
1606 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1607 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', false);
1608
1609 /*
1610 if ($object->close_code == 'discount_vat') {
1611 $index++;
1612 $pdf->SetFillColor(255,255,255);
1613
1614 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1615 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1616
1617 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1618 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1);
1619
1620 $resteapayer=0;
1621 }
1622 */
1623
1624 $index++;
1625 $pdf->SetTextColor(0, 0, 60);
1626 $pdf->SetFillColor(224, 224, 224);
1627 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1628 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', true);
1629
1630 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1631 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', true);
1632
1633 $pdf->SetFont('', '', $default_font_size - 1);
1634 $pdf->SetTextColor(0, 0, 0);
1635 }
1636
1637 $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy);
1638
1639 $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks
1640 if ($reshook < 0) {
1641 $this->error = $hookmanager->error;
1642 $this->errors = $hookmanager->errors;
1643 }
1644
1645 $index++;
1646 return ($tab2_top + ($tab2_hl * $index));
1647 }
1648
1649 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1664 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1665 {
1666 global $conf;
1667
1668 // Force to disable hidetop and hidebottom
1669 $hidebottom = 0;
1670 if ($hidetop) {
1671 $hidetop = -1;
1672 }
1673
1674 $currency = !empty($currency) ? $currency : $conf->currency;
1675 $default_font_size = pdf_getPDFFontSize($outputlangs);
1676
1677 // Amount in (at tab_top - 1)
1678 $pdf->SetTextColor(0, 0, 0);
1679 $pdf->SetFont('', '', $default_font_size - 2);
1680
1681 if (empty($hidetop)) {
1682 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1683 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1684 $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1685 }
1686
1687 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1688 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1689
1690 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1691 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1692 $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')));
1693 }
1694 }
1695
1696 $pdf->SetDrawColor(128, 128, 128);
1697 $pdf->SetFont('', '', $default_font_size - 1);
1698
1699 // Output Rect
1700 $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
1701
1702 if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) {
1703 $arrayColorTextTitle = explode(',', getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR'));
1704 $pdf->SetTextColor((float) $arrayColorTextTitle[0], (float) $arrayColorTextTitle[1], (float) $arrayColorTextTitle[2]);
1705 }
1706
1707 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1708
1709 if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) {
1710 $pdf->SetTextColor(0, 0, 0);
1711 }
1712
1713 if (empty($hidetop)) {
1714 $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
1715 }
1716 }
1717
1718 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1729 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
1730 {
1731 global $conf, $langs;
1732
1733 $ltrdirection = 'L';
1734 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1735 $ltrdirection = 'R';
1736 }
1737
1738 // Load traductions files required by page
1739 $outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
1740
1741 $default_font_size = pdf_getPDFFontSize($outputlangs);
1742
1743 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1744
1745 $pdf->SetTextColor(0, 0, 60);
1746 $pdf->SetFont('', 'B', $default_font_size + 3);
1747
1748 $w = 100;
1749
1750 $posy = $this->marge_haute;
1751 $posx = $this->page_largeur - $this->marge_droite - $w;
1752
1753 $pdf->SetXY($this->marge_gauche, $posy);
1754
1755 // Logo
1756 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1757 if ($this->emetteur->logo) {
1758 $logodir = $conf->mycompany->dir_output;
1759 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
1760 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
1761 }
1762 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1763 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1764 } else {
1765 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1766 }
1767 if (is_readable($logo)) {
1768 $height = pdf_getHeightForLogo($logo);
1769 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1770 } else {
1771 $pdf->SetTextColor(200, 0, 0);
1772 $pdf->SetFont('', 'B', $default_font_size - 2);
1773 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1774 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1775 }
1776 } else {
1777 $text = $this->emetteur->name;
1778 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1779 }
1780 }
1781
1782 $pdf->SetFont('', 'B', $default_font_size + 3);
1783 $pdf->SetXY($posx, $posy);
1784 $pdf->SetTextColor(0, 0, 60);
1785 $title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
1786 $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1787 if ($object->status == $object::STATUS_DRAFT) {
1788 $pdf->SetTextColor(128, 0, 0);
1789 $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1790 }
1791
1792 $pdf->MultiCell($w, 4, $title, '', 'R');
1793
1794 $pdf->SetFont('', 'B', $default_font_size);
1795
1796 /*
1797 $posy += 5;
1798 $pdf->SetXY($posx, $posy);
1799 $pdf->SetTextColor(0, 0, 60);
1800 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1801 if ($object->status == $object::STATUS_DRAFT) {
1802 $pdf->SetTextColor(128, 0, 0);
1803 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1804 }
1805 $pdf->MultiCell($w, 4, $textref, '', 'R');
1806 */
1807
1808 $posy += 3;
1809 $pdf->SetFont('', '', $default_font_size - 2);
1810
1811 $ref_customer = $object->ref_customer ?: $object->ref_client;
1812 if ($ref_customer) {
1813 $posy += 4;
1814 $pdf->SetXY($posx, $posy);
1815 $pdf->SetTextColor(0, 0, 60);
1816 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65), '', 'R');
1817 }
1818
1819 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
1820 $object->fetchProject();
1821 if (!empty($object->project->title)) {
1822 $posy += 3;
1823 $pdf->SetXY($posx, $posy);
1824 $pdf->SetTextColor(0, 0, 60);
1825 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ". dol_trunc($object->project->title, 50), '', 'R');
1826 $posy = $pdf->getY();
1827 }
1828 }
1829
1830 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
1831 $object->fetchProject();
1832 if (!empty($object->project->ref)) {
1833 $outputlangs->load("projects");
1834 $posy += 3;
1835 $pdf->SetXY($posx, $posy);
1836 $pdf->SetTextColor(0, 0, 60);
1837 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ". $object->project->ref, '', 'R');
1838 }
1839 }
1840
1841 if (getDolGlobalString('MAIN_PDF_DATE_TEXT')) {
1842 $displaydate = "daytext";
1843 } else {
1844 $displaydate = "day";
1845 }
1846
1847 //$posy += 4;
1848 $posy = $pdf->getY();
1849 $pdf->SetXY($posx, $posy);
1850 $pdf->SetTextColor(0, 0, 60);
1851 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, $displaydate, false, $outputlangs, true), '', 'R');
1852
1853 $posy += 4;
1854 $pdf->SetXY($posx, $posy);
1855 $pdf->SetTextColor(0, 0, 60);
1856
1857 $title = $outputlangs->transnoentities("DateEndPropal");
1858 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1859 $title .= ' - '.$outputlangsbis->transnoentities("DateEndPropal");
1860 }
1861 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->fin_validite, $displaydate, false, $outputlangs, true), '', 'R');
1862
1863 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
1864 $posy += 4;
1865 $pdf->SetXY($posx, $posy);
1866 $pdf->SetTextColor(0, 0, 60);
1867 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_client), '', 'R');
1868 }
1869
1870 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && $object->thirdparty->code_compta_client) {
1871 $posy += 4;
1872 $pdf->SetXY($posx, $posy);
1873 $pdf->SetTextColor(0, 0, 60);
1874 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_compta_client), '', 'R');
1875 }
1876
1877 // Get contact
1878 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
1879 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1880 if (count($arrayidcontact) > 0) {
1881 $usertmp = new User($this->db);
1882 $usertmp->fetch($arrayidcontact[0]);
1883 $posy += 4;
1884 $pdf->SetXY($posx, $posy);
1885 $pdf->SetTextColor(0, 0, 60);
1886 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1887 }
1888 }
1889
1890 $posy += 2;
1891 $shipp_shift = 0;
1892 $top_shift = 0;
1893 // Show list of linked objects
1894 $current_y = $pdf->getY();
1895 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); // May modify $object->note_public
1896 if ($current_y < $pdf->getY()) {
1897 $top_shift = $pdf->getY() - $current_y;
1898 }
1899
1900 if ($showaddress) {
1901 // Sender properties
1902 $carac_emetteur = '';
1903 // Add internal contact of object if defined
1904 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1905 if (count($arrayidcontact) > 0) {
1906 $object->fetch_user($arrayidcontact[0]);
1907 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1908 $carac_emetteur .= $labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1909 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1910 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1911 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1912 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1913 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1914 $carac_emetteur .= "\n";
1915 }
1916
1917 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1918
1919 // Show sender
1920 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 30 : 32;
1921 $posy += $top_shift + $this->marge_haute;
1922 $posx = $this->marge_gauche;
1923 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1924 $posx = $this->page_largeur - $this->marge_droite - 80;
1925 }
1926
1927 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1928 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1929
1930
1931 // Show sender frame
1932 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1933 $pdf->SetTextColor(0, 0, 0);
1934 $pdf->SetFont('', '', $default_font_size - 2);
1935 $pdf->SetXY($posx, $posy - 5);
1936 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1937 $pdf->SetXY($posx, $posy);
1938 $pdf->SetFillColor(230, 230, 230);
1939 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1940 $pdf->SetTextColor(0, 0, 60);
1941 }
1942
1943 // Show sender name
1944 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1945 $pdf->SetXY($posx + 2, $posy + 3);
1946 $pdf->SetFont('', 'B', $default_font_size);
1947 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1948 $posy = $pdf->getY();
1949 }
1950
1951 // Show sender information
1952 $pdf->SetXY($posx + 2, $posy);
1953 $pdf->SetFont('', '', $default_font_size - 1);
1954 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1955
1956
1957 // If CUSTOMER contact defined, we use it
1958 $usecontact = false;
1959 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1960 if (count($arrayidcontact) > 0) {
1961 $usecontact = true;
1962 $result = $object->fetch_contact($arrayidcontact[0]);
1963 }
1964
1965 // Recipient name
1966 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1967 $thirdparty = $object->contact;
1968 } else {
1969 $thirdparty = $object->thirdparty;
1970 }
1971
1972 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1973
1974 $mode = 'target';
1975 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), $mode, $object);
1976
1977 // Show recipient
1978 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1979 if ($this->page_largeur < 210) {
1980 $widthrecbox = 84; // To work with US executive format
1981 }
1982 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 30 + $this->marge_haute : 32 + $this->marge_haute;
1983 $posy += $top_shift;
1984 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1985 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1986 $posx = $this->marge_gauche;
1987 }
1988
1989 // Show recipient frame
1990 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1991 $pdf->SetTextColor(0, 0, 0);
1992 $pdf->SetFont('', '', $default_font_size - 2);
1993 $pdf->SetXY($posx + 2, $posy - 5);
1994 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1995 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1996 }
1997
1998 // Show recipient name
1999 $pdf->SetXY($posx + 2, $posy + 3);
2000 $pdf->SetFont('', 'B', $default_font_size);
2001 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2002 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
2003
2004 $posy = $pdf->getY();
2005
2006 // Show recipient information
2007 $pdf->SetFont('', '', $default_font_size - 1);
2008 $pdf->SetXY($posx + 2, $posy);
2009 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2010 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
2011 // Show shipping/delivery addressAdd commentMore actions
2012 if (getDolGlobalInt('PROPOSAL_SHOW_SHIPPING_ADDRESS')) {
2013 $idaddressshipping = $object->getIdContact('external', 'SHIPPING');
2014
2015 if (!empty($idaddressshipping)) {
2016 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2017 $companystatic = new Societe($this->db);
2018 $companystatic->fetch($object->contact->fk_soc);
2019 $carac_client_name_shipping = pdfBuildThirdpartyName($object->contact, $outputlangs);
2020 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, 1, 'target', $object);
2021 } else {
2022 $carac_client_name_shipping = pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
2023 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
2024 }
2025 if (!empty($carac_client_shipping)) {
2026 $posy += $hautcadre;
2027
2028 $hautcadre -= 5; // Height for the shipping address does not need to be as high as main box
2029
2030 // Show shipping frame
2031 $pdf->SetXY($posx + 2, $posy - 5);
2032 $pdf->SetFont('', '', $default_font_size - 2);
2033 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities('ShippingTo'), 0, 'L', false);
2034 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
2035
2036 // Show shipping name
2037 $pdf->SetXY($posx + 2, $posy + 3);
2038 $pdf->SetFont('', 'B', $default_font_size);
2039 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L');
2040
2041 $posy = $pdf->getY();
2042
2043 // Show shipping information
2044 $pdf->SetXY($posx + 2, $posy);
2045 $pdf->SetFont('', '', $default_font_size - 1);
2046 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L');
2047
2048 $shipp_shift += $hautcadre + 10;
2049 }
2050 }
2051 }
2052 $pdf->SetTextColor(0, 0, 0);
2053
2054 return array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift);
2055 }
2056
2057 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
2067 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2068 {
2069 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2070 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);
2071 }
2072
2082 protected function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
2083 {
2084 $default_font_size = pdf_getPDFFontSize($outputlangs);
2085 $tab_top = $posy + 4;
2086 $tab_hl = 4;
2087
2088 $posx = 120;
2089 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
2090
2091 // Total HT
2092 $pdf->SetFillColor(255, 255, 255);
2093 $pdf->SetXY($posx, $tab_top);
2094 $pdf->SetFont('', '', $default_font_size - 2);
2095 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', true);
2096
2097 $pdf->SetXY($posx, $tab_top + $tab_hl + 3);
2098 //$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
2099 $pdf->RoundedRect($posx, $tab_top + $tab_hl + 3, $largcol, $tab_hl * 3, $this->corner_radius, '1234', 'D');
2100
2101
2102 if (getDolGlobalString('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING')) {
2103 // Can be retrieve with getSignatureAppearanceArray()
2104 // Can be also detected by putting the mouse over the area when using evince pdf reader
2105 $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl + 3, $largcol, $tab_hl * 3);
2106 }
2107
2108 return ($tab_hl * 7);
2109 }
2110
2111
2122 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2123 {
2124 global $hookmanager;
2125
2126 // Default field style for content
2127 $this->defaultContentsFieldsStyle = array(
2128 'align' => 'R', // R,C,L
2129 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2130 );
2131
2132 // Default field style for content
2133 $this->defaultTitlesFieldsStyle = array(
2134 'align' => 'C', // R,C,L
2135 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2136 );
2137
2138 /*
2139 * For example
2140 $this->cols['theColKey'] = array(
2141 'rank' => $rank, // int : use for ordering columns
2142 'width' => 20, // the column width in mm
2143 'title' => array(
2144 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2145 'label' => ' ', // the final label : used fore final generated text
2146 'align' => 'L', // text alignment : R,C,L
2147 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2148 ),
2149 'content' => array(
2150 'align' => 'L', // text alignment : R,C,L
2151 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2152 ),
2153 );
2154 */
2155
2156 $rank = 0; // do not use negative rank
2157 $this->cols['position'] = array(
2158 'rank' => $rank,
2159 'width' => 10.0,
2160 'status' => getDolGlobalInt('PDF_CYAN_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
2161 'title' => array(
2162 'textkey' => '#', // use lang key is useful in some case with module
2163 'align' => 'C',
2164 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2165 // 'label' => ' ', // the final label
2166 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2167 ),
2168 'content' => array(
2169 'align' => 'C',
2170 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2171 ),
2172 );
2173
2174 $rank = 5; // do not use negative rank
2175 $this->cols['desc'] = array(
2176 'rank' => $rank,
2177 'width' => false, // only for desc
2178 'status' => true,
2179 'title' => array(
2180 'textkey' => 'Designation', // use lang key is useful in some case with module
2181 'align' => 'L',
2182 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2183 // 'label' => ' ', // the final label
2184 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2185 ),
2186 'content' => array(
2187 'align' => 'L',
2188 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2189 ),
2190 );
2191
2192 // Image of product
2193 $rank += 10;
2194 $this->cols['photo'] = array(
2195 'rank' => $rank,
2196 'width' => (float) getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
2197 'status' => false,
2198 'title' => array(
2199 'textkey' => 'Photo',
2200 'label' => ' '
2201 ),
2202 'content' => array(
2203 'padding' => array(0.0, 0.0, 0.0, 0.0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2204 ),
2205 'border-left' => false, // remove left line separator
2206 );
2207
2208 if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE') && !empty($this->atleastonephoto)) {
2209 $this->cols['photo']['status'] = true;
2210 $this->cols['photo']['border-left'] = true;
2211 }
2212
2213
2214 $rank += 10;
2215 $this->cols['vat'] = array(
2216 'rank' => $rank,
2217 'status' => false,
2218 'width' => 16.0, // in mm
2219 'title' => array(
2220 'textkey' => 'VAT'
2221 ),
2222 'border-left' => true, // add left line separator
2223 );
2224
2225 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
2226 $this->cols['vat']['status'] = true;
2227 }
2228
2229 $rank += 10;
2230 $this->cols['subprice'] = array(
2231 'rank' => $rank,
2232 'width' => 19.0, // in mm
2233 'status' => true,
2234 'title' => array(
2235 'textkey' => 'PriceUHT'
2236 ),
2237 'border-left' => true, // add left line separator
2238 );
2239
2240 // Adapt dynamically the width of subprice, if text is too long.
2241 $tmpwidth = 0;
2242 $nblines = count($object->lines);
2243 for ($i = 0; $i < $nblines; $i++) {
2244 $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
2245 $tmpwidth = max($tmpwidth, $tmpwidth2);
2246 }
2247 if ($tmpwidth > 10) {
2248 $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
2249 }
2250
2251 $rank += 10;
2252 $this->cols['qty'] = array(
2253 'rank' => $rank,
2254 'width' => 16.0, // in mm
2255 'status' => true,
2256 'title' => array(
2257 'textkey' => 'Qty'
2258 ),
2259 'border-left' => true, // add left line separator
2260 );
2261
2262 $rank += 10;
2263 $this->cols['unit'] = array(
2264 'rank' => $rank,
2265 'width' => 11.0, // in mm
2266 'status' => false,
2267 'title' => array(
2268 'textkey' => 'Unit'
2269 ),
2270 'border-left' => true, // add left line separator
2271 );
2272 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
2273 $this->cols['unit']['status'] = true;
2274 }
2275
2276 $rank += 10;
2277 $this->cols['discount'] = array(
2278 'rank' => $rank,
2279 'width' => 13.0, // in mm
2280 'status' => false,
2281 'title' => array(
2282 'textkey' => 'ReductionShort'
2283 ),
2284 'border-left' => true, // add left line separator
2285 );
2286 if ($this->atleastonediscount) {
2287 $this->cols['discount']['status'] = true;
2288 }
2289
2290 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
2291 $this->cols['totalexcltax'] = array(
2292 'rank' => $rank,
2293 'width' => 26.0, // in mm
2294 'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX'),
2295 'title' => array(
2296 'textkey' => 'TotalHTShort'
2297 ),
2298 'border-left' => true, // add left line separator
2299 );
2300
2301 $rank += 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
2302 $this->cols['totalincltax'] = array(
2303 'rank' => $rank,
2304 'width' => 26.0, // in mm
2305 'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'),
2306 'title' => array(
2307 'textkey' => 'TotalTTCShort'
2308 ),
2309 'border-left' => true, // add left line separator
2310 );
2311
2312 // Add extrafields cols
2313 if (!empty($object->lines)) {
2314 $line = reset($object->lines);
2315 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
2316 }
2317
2318 $parameters = array(
2319 'object' => $object,
2320 'outputlangs' => $outputlangs,
2321 'hidedetails' => $hidedetails,
2322 'hidedesc' => $hidedesc,
2323 'hideref' => $hideref
2324 );
2325
2326 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
2327 if ($reshook < 0) {
2328 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2329 } elseif (empty($reshook)) {
2330 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
2331 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
2332 } else {
2333 $this->cols = $hookmanager->resArray;
2334 }
2335 }
2336}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
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(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:3194
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition pdf.lib.php:2893
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:3226
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1810
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:294
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
Definition pdf.lib.php:1241
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:317
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition pdf.lib.php:2943
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2482
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:2420
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:749
pdfGetHeightForHtmlContent($pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
Definition pdf.lib.php:342
pdf_pagefoot($pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1423
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:273
pdf_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:3324
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:438
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
Definition pdf.lib.php:2727
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2770
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2567
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:1137
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:393
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140