dolibarr 24.0.0-beta
pdf.lib.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
5 * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
6 * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2010-2017 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
9 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
10 * Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
11 * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
12 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
13 * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
14 * Copyright (C) 2019 Lenin Rivas <lenin.rivas@servcom-it.com>
15 * Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
16 * Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
17 * Copyright (C) 2023-2026 Frédéric France <frederic.france@free.fr>
18 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <https://www.gnu.org/licenses/>.
32 * or see https://www.gnu.org/
33 */
34
41include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
42
43
50{
51 global $langs, $conf;
52
53 $h = 0;
54 $head = array();
55
56 $head[$h][0] = DOL_URL_ROOT.'/admin/pdf.php';
57 $head[$h][1] = $langs->trans("GlobalParameters");
58 $head[$h][2] = 'general';
59 $h++;
60
61 // Show more tabs from modules
62 // Entries must be declared in modules descriptor with line
63 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
64 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
65 complete_head_from_modules($conf, $langs, null, $head, $h, 'pdf_admin');
66
67 if (isModEnabled("propal") || isModEnabled('invoice') || isModEnabled('reception')) {
68 $head[$h][0] = DOL_URL_ROOT.'/admin/pdf_other.php';
69 $head[$h][1] = $langs->trans("SpecificParameters");
70 $head[$h][2] = 'other';
71 $h++;
72 }
73
74 complete_head_from_modules($conf, $langs, null, $head, $h, 'pdf_admin', 'remove');
75
76 return $head;
77}
78
79
87function pdf_getFormat($outputlangs = null, $mode = 'setup')
88{
89 global $conf, $db, $langs;
90
91 dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".getDolGlobalString('MAIN_PDF_FORMAT')." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null'));
92
93 // Default value if setup was not done and/or entry into c_paper_format not defined
94 $width = 210;
95 $height = 297;
96 $unit = 'mm';
97
98 if ($mode == 'auto' || !getDolGlobalString('MAIN_PDF_FORMAT') || getDolGlobalString('MAIN_PDF_FORMAT') == 'auto') {
99 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
100 $pdfformat = dol_getDefaultFormat($outputlangs);
101 } else {
102 $pdfformat = getDolGlobalString('MAIN_PDF_FORMAT');
103 }
104
105 $sql = "SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
106 $sql .= " WHERE code = '".$db->escape($pdfformat)."'";
107 $resql = $db->query($sql);
108 if ($resql) {
109 $obj = $db->fetch_object($resql);
110 if ($obj) {
111 $width = (int) $obj->width;
112 $height = (int) $obj->height;
113 $unit = $obj->unit;
114 }
115 }
116
117 //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit;
118 return array('width' => $width, 'height' => $height, 'unit' => $unit);
119}
120
129function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
130{
131 global $conf;
132
133 // Define constant for TCPDF
134 if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
135 define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file
136 define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
137 define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
138 dol_mkdir(K_PATH_CACHE);
139 define('K_BLANK_IMAGE', '_blank.png');
140 define('PDF_PAGE_FORMAT', 'A4');
141 define('PDF_PAGE_ORIENTATION', 'P');
142 define('PDF_CREATOR', 'TCPDF');
143 define('PDF_AUTHOR', 'TCPDF');
144 define('PDF_HEADER_TITLE', 'TCPDF Example');
145 define('PDF_HEADER_STRING', "by Dolibarr ERP CRM");
146 define('PDF_UNIT', 'mm');
147 define('PDF_MARGIN_HEADER', 5);
148 define('PDF_MARGIN_FOOTER', 10);
149 define('PDF_MARGIN_TOP', 27);
150 define('PDF_MARGIN_BOTTOM', 25);
151 define('PDF_MARGIN_LEFT', 15);
152 define('PDF_MARGIN_RIGHT', 15);
153 define('PDF_FONT_NAME_MAIN', 'helvetica');
154 define('PDF_FONT_SIZE_MAIN', 10);
155 define('PDF_FONT_NAME_DATA', 'helvetica');
156 define('PDF_FONT_SIZE_DATA', 8);
157 define('PDF_FONT_MONOSPACED', 'courier');
158 define('PDF_IMAGE_SCALE_RATIO', 1.25);
159 define('HEAD_MAGNIFICATION', 1.1);
160 define('K_CELL_HEIGHT_RATIO', 1.25);
161 define('K_TITLE_MAGNIFICATION', 1.3);
162 define('K_SMALL_RATIO', 2 / 3);
163 define('K_THAI_TOPCHARS', true);
164 define('K_TCPDF_CALLS_IN_HTML', true);
165 // Default: throw exceptions on TCPDF/TCPDI errors instead of die().
166 // A die() in a PDF library produces white pages on web requests and kills
167 // batch jobs on the first bad PDF. Exceptions can be caught and surfaced as
168 // normal Dolibarr errors. Users can opt out by setting
169 // TCPDF_THROW_ERRORS_INSTEAD_OF_DIE = 0 to restore the legacy die() behavior.
170 if (getDolGlobalString('TCPDF_THROW_ERRORS_INSTEAD_OF_DIE', '1')) {
171 define('K_TCPDF_THROW_EXCEPTION_ERROR', true);
172 } else {
173 define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
174 }
175 }
176
177 // Load TCPDF
178 require_once TCPDF_PATH.'tcpdf.php';
179
180 // We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features).
181 if (!getDolGlobalString('MAIN_DISABLE_TCPDI')) {
182 require_once TCPDI_PATH.'tcpdi.php';
183 }
184
185 //$arrayformat=pdf_getFormat();
186 //$format=array($arrayformat['width'],$arrayformat['height']);
187 //$metric=$arrayformat['unit'];
188
189 //$pdfa = false; // PDF default version
190 $pdfa = getDolGlobalInt('PDF_USE_A', 0); // PDF/A-1 ou PDF/A-3
191
192 if (!getDolGlobalString('MAIN_DISABLE_TCPDI') && class_exists('TCPDI')) {
193 $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa);
194 } else {
195 $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa);
196 }
197
198 // Protection and encryption of pdf
199 if (getDolGlobalString('PDF_SECURITY_ENCRYPTION')) {
200 /* Permission supported by TCPDF
201 - print : Print the document;
202 - modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
203 - copy : Copy or otherwise extract text and graphics from the document;
204 - annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
205 - fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
206 - extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
207 - assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
208 - print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
209 - owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
210 */
211
212 // For TCPDF, we specify permission we want to block
213 $pdfrights = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_RIGHTS') ? json_decode(getDolGlobalString('PDF_SECURITY_ENCRYPTION_RIGHTS'), true) : array('modify', 'copy')); // Json format in llx_const
214
215 // Password for the end user
216 $pdfuserpass = getDolGlobalString('PDF_SECURITY_ENCRYPTION_USERPASS');
217
218 // Password of the owner, created randomly if not defined
219 $pdfownerpass = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_OWNERPASS') ? getDolGlobalString('PDF_SECURITY_ENCRYPTION_OWNERPASS') : null);
220
221 // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit
222 $encstrength = getDolGlobalInt('PDF_SECURITY_ENCRYPTION_STRENGTH', 0);
223
224 // Array of recipients containing public-key certificates ('c') and permissions ('p').
225 // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print')))
226 $pubkeys = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_PUBKEYS') ? json_decode(getDolGlobalString('PDF_SECURITY_ENCRYPTION_PUBKEYS'), true) : null); // Json format in llx_const
227
228 $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys);
229 }
230
231 return $pdf;
232}
233
240function pdf_getEncryption($pathoffile)
241{
242 require_once TCPDF_PATH.'tcpdf_parser.php';
243
244 $isencrypted = false;
245
246 $content = file_get_contents($pathoffile);
247
248 //ob_start();
249 @($parser = new TCPDF_PARSER(ltrim($content)));
250 $tmp = $parser->getParsedData();
251 $xref = $tmp[0];
252 $data = $tmp[1] ?? null;
253 unset($parser);
254 //ob_end_clean();
255
256 if (isset($xref['trailer']['encrypt'])) {
257 $isencrypted = true; // Secured pdf file are currently not supported
258 }
259
260 if (empty($data)) {
261 $isencrypted = true; // Object list not found. Possible secured file
262 }
263
264 return $isencrypted;
265}
266
273function pdf_getPDFFont($outputlangs)
274{
275 if (getDolGlobalString('MAIN_PDF_FORCE_FONT')) {
276 return getDolGlobalString('MAIN_PDF_FORCE_FONT');
277 }
278
279 $font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF
280 if (class_exists('TCPDF')) { // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
281 if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') {
282 $font = $outputlangs->trans('FONTFORPDF');
283 }
284 }
285 return $font;
286}
287
294function pdf_getPDFFontSize($outputlangs)
295{
296 $size = 10; // By default, for FPDI or ISO language on TCPDF
297 if (class_exists('TCPDF')) { // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower)
298 if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') {
299 $size = (int) $outputlangs->trans('FONTSIZEFORPDF');
300 }
301 }
302 if (getDolGlobalString('MAIN_PDF_FORCE_FONT_SIZE')) {
303 $size = getDolGlobalString('MAIN_PDF_FORCE_FONT_SIZE');
304 }
305
306 return $size;
307}
308
309
317function pdf_getHeightForLogo($logo, $url = false)
318{
319 $height = getDolGlobalFloat('MAIN_DOCUMENTS_LOGO_HEIGHT', 20);
320 $maxwidth = 130;
321 include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
322 $tmp = dol_getImageSize($logo, $url);
323 if ($tmp['height']) {
324 $width = round($height * $tmp['width'] / $tmp['height']);
325 if ($width > $maxwidth) {
326 $height = $height * $maxwidth / $width;
327 }
328 }
329
330 return $height;
331}
332
342function pdfGetHeightForHtmlContent($pdf, $htmlcontent)
343{
344 // store current object
345 $pdf->startTransaction();
346 // To avoid pagebreak effect or strange behavior of writeHTMLCell when we are out of page, we imagine we are at the begin of page to test the height of the text
347 // Another solution would be to do the test on another PDF instance with samefont, width...
348 $pdf->setY(0);
349 // store starting values
350 $start_y = $pdf->GetY();
351 //var_dump($start_y);
352 $start_page = $pdf->getPage();
353 // call printing functions with content
354 $pdf->writeHTMLCell(0, 0, 0, $start_y, $htmlcontent, 0, 1, false, true, 'J', true);
355 // get the new Y
356 $end_y = $pdf->GetY();
357 $end_page = $pdf->getPage();
358 // calculate height
359 $height = 0;
360 if ($end_page == $start_page) {
361 $height = $end_y - $start_y;
362 } else {
363 for ($page = $start_page; $page <= $end_page; ++$page) {
364 $pdf->setPage($page);
365 $tmpm = $pdf->getMargins();
366 $tMargin = $tmpm['top'];
367 if ($page == $start_page) {
368 // first page
369 $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin();
370 } elseif ($page == $end_page) {
371 // last page
372 $height = $end_y - $tMargin;
373 } else {
374 $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin();
375 }
376 }
377 }
378 // restore previous object state
379 $pdf->rollbackTransaction(true);
380
381 return $height;
382}
383
384
393function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias = 0)
394{
395 // Recipient name
396 $socname = '';
397
398 if ($thirdparty instanceof Societe) {
399 $socname = $thirdparty->name;
400 if (($includealias || getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
401 if (getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME') == 2) {
402 $socname = $thirdparty->name_alias." - ".$thirdparty->name;
403 } else {
404 $socname = $thirdparty->name." - ".$thirdparty->name_alias;
405 }
406 }
407 } elseif ($thirdparty instanceof Contact) {
408 if ($thirdparty->socid > 0) {
409 $thirdparty->fetch_thirdparty();
410 $socname = $thirdparty->thirdparty->name;
411 if (($includealias || getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->thirdparty->name_alias)) {
412 if (getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME') == 2) {
413 $socname = $thirdparty->thirdparty->name_alias." - ".$thirdparty->thirdparty->name;
414 } else {
415 $socname = $thirdparty->thirdparty->name." - ".$thirdparty->thirdparty->name_alias;
416 }
417 }
418 }
419 } else {
420 throw new InvalidArgumentException('Parameter 1 $thirdparty is not a Societe nor Contact');
421 }
422
423 return $outputlangs->convToOutputCharset((string) $socname);
424}
425
438function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $targetcontact = '', $usecontact = 0, $mode = 'source', $object = null)
439{
440 global $hookmanager;
441
442 if ($mode == 'source' && !is_object($sourcecompany)) {
443 return -1;
444 }
445 if ($mode == 'target' && !is_object($targetcompany)) {
446 return -1;
447 }
448
449 if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
450 $sourcecompany->state = getState($sourcecompany->state_id);
451 }
452 if (!empty($targetcompany->state_id) && empty($targetcompany->state)) {
453 $targetcompany->state = getState($targetcompany->state_id);
454 }
455
456 $reshook = 0;
457 $stringaddress = '';
458 if (is_object($hookmanager)) {
459 $parameters = array('sourcecompany' => &$sourcecompany, 'targetcompany' => &$targetcompany, 'targetcontact' => &$targetcontact, 'outputlangs' => $outputlangs, 'mode' => $mode, 'usecontact' => $usecontact);
460 $action = '';
461 // @phan-suppress-next-line PhanTypeMismatchArgumentNullable
462 $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
463 $stringaddress .= $hookmanager->resPrint;
464 }
465 if (empty($reshook)) {
466 if ($mode == 'source') {
467 $withCountry = 0;
468 if (isset($targetcompany->country_code) && !empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
469 $withCountry = 1;
470 }
471
472 $fulladdress = dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs);
473 if ($fulladdress) {
474 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($fulladdress)."\n";
475 }
476
477 if (!getDolGlobalString('MAIN_PDF_DISABLESOURCEDETAILS')) {
478 // Phone
479 if ($sourcecompany->phone) {
480 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
481 }
482 // Phone mobile
483 if ($sourcecompany->phone_mobile && getDolGlobalString('MAIN_PDF_SHOW_SOURCE_PHONE_MOBILE')) {
484 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone_mobile);
485 }
486 // Fax
487 if ($sourcecompany->fax) {
488 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
489 }
490 // EMail
491 if ($sourcecompany->email) {
492 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
493 }
494 // Web
495 if ($sourcecompany->url) {
496 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
497 }
498 }
499 // Intra VAT
500 if (getDolGlobalString('MAIN_TVAINTRA_IN_SOURCE_ADDRESS')) {
501 if ($sourcecompany->tva_intra) {
502 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
503 }
504 }
505 // Professional Ids
506 $reg = array();
507 if (getDolGlobalString('MAIN_PROFID1_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof1)) {
508 $tmp = $outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code);
509 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
510 $tmp = $reg[1];
511 }
512 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
513 }
514 if (getDolGlobalString('MAIN_PROFID2_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof2)) {
515 $tmp = $outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code);
516 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
517 $tmp = $reg[1];
518 }
519 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
520 }
521 if (getDolGlobalString('MAIN_PROFID3_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof3)) {
522 $tmp = $outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code);
523 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
524 $tmp = $reg[1];
525 }
526 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
527 }
528 if (getDolGlobalString('MAIN_PROFID4_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof4)) {
529 $tmp = $outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code);
530 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
531 $tmp = $reg[1];
532 }
533 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
534 }
535 if (getDolGlobalString('MAIN_PROFID5_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof5)) {
536 $tmp = $outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code);
537 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
538 $tmp = $reg[1];
539 }
540 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
541 }
542 if (getDolGlobalString('MAIN_PROFID6_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof6)) {
543 $tmp = $outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code);
544 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
545 $tmp = $reg[1];
546 }
547 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
548 }
549 if (getDolGlobalString('PDF_ADD_MORE_AFTER_SOURCE_ADDRESS')) {
550 $stringaddress .= ($stringaddress ? "\n" : '') . getDolGlobalString('PDF_ADD_MORE_AFTER_SOURCE_ADDRESS');
551 }
552 }
553
554 if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) {
555 if ($usecontact && (is_object($targetcontact))) {
556 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
557
558 if (!empty($targetcontact->address)) {
559 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
560 } elseif (is_object($targetcompany)) {
561 $companytouseforaddress = $targetcompany;
562
563 // Contact on a thirdparty that is a different thirdparty than the thirdparty of object
564 if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
565 $targetcontact->fetch_thirdparty();
566 $companytouseforaddress = $targetcontact->thirdparty;
567 }
568
569 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress))."\n";
570 }
571 // Country
572 if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
573 $stringaddress .= (($stringaddress && !getDolGlobalString('MAIN_PDF_REMOVE_BREAK_BEFORE_COUNTRY')) ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));
574 } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
575 $stringaddress .= (($stringaddress && !getDolGlobalString('MAIN_PDF_REMOVE_BREAK_BEFORE_COUNTRY')) ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
576 }
577
578 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || preg_match('/targetwithdetails/', $mode)) {
579 // Phone
580 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
581 if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
582 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
583 }
584 if (!empty($targetcontact->phone_pro)) {
585 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
586 }
587 if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
588 $stringaddress .= " / ";
589 }
590 if (!empty($targetcontact->phone_mobile)) {
591 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
592 }
593 }
594 // Fax
595 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
596 if ($targetcontact->fax) {
597 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
598 }
599 }
600 // EMail
601 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
602 if ($targetcontact->email) {
603 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
604 }
605 }
606 // Web
607 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
608 if ($targetcontact->url) {
609 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset((string) $targetcontact->url);
610 }
611 }
612 }
613 } else {
614 if (is_object($targetcompany)) {
615 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
616 // Country
617 if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
618 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
619 } else {
620 $stringaddress .= ($stringaddress ? "\n" : '');
621 }
622
623 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || preg_match('/targetwithdetails/', $mode)) {
624 // Phone
625 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
626 if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) {
627 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
628 }
629 if (!empty($targetcompany->phone)) {
630 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
631 }
632 if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) {
633 $stringaddress .= " / ";
634 }
635 if (!empty($targetcompany->phone_mobile)) {
636 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
637 }
638 }
639 // Fax
640 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
641 if ($targetcompany->fax) {
642 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
643 }
644 }
645 // EMail
646 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
647 if ($targetcompany->email) {
648 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
649 }
650 }
651 // Web
652 if (getDolGlobalString('MAIN_PDF_ADDALSOTARGETDETAILS') || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
653 if ($targetcompany->url) {
654 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
655 }
656 }
657 }
658 }
659 }
660
661 // Intra VAT
662 if (!getDolGlobalString('MAIN_TVAINTRA_NOT_IN_ADDRESS')) {
663 if ($usecontact && is_object($targetcontact) && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
664 $targetcontact->fetch_thirdparty();
665 if (!empty($targetcontact->thirdparty->id) && $targetcontact->thirdparty->tva_intra) {
666 $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("VATIntraShort") . ': ' . $outputlangs->convToOutputCharset($targetcontact->thirdparty->tva_intra);
667 }
668 } elseif (!empty($targetcompany->tva_intra)) {
669 $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
670 }
671 }
672
673 // Legal form
674 if (getDolGlobalString('MAIN_LEGALFORM_IN_ADDRESS') && !empty($targetcompany->forme_juridique_code)) {
675 $tmp = getFormeJuridiqueLabel((string) $targetcompany->forme_juridique_code);
676 $stringaddress .= ($stringaddress ? "\n" : '').$tmp;
677 }
678
679 // Professional Ids
680 if (getDolGlobalString('MAIN_PROFID1_IN_ADDRESS') && !empty($targetcompany->idprof1)) {
681 $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code);
682 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
683 $tmp = $reg[1];
684 }
685 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
686 }
687 if (getDolGlobalString('MAIN_PROFID2_IN_ADDRESS') && !empty($targetcompany->idprof2)) {
688 $tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code);
689 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
690 $tmp = $reg[1];
691 }
692 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
693 }
694 if (getDolGlobalString('MAIN_PROFID3_IN_ADDRESS') && !empty($targetcompany->idprof3)) {
695 $tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code);
696 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
697 $tmp = $reg[1];
698 }
699 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
700 }
701 if (getDolGlobalString('MAIN_PROFID4_IN_ADDRESS') && !empty($targetcompany->idprof4)) {
702 $tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code);
703 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
704 $tmp = $reg[1];
705 }
706 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
707 }
708 if (getDolGlobalString('MAIN_PROFID5_IN_ADDRESS') && !empty($targetcompany->idprof5)) {
709 $tmp = $outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code);
710 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
711 $tmp = $reg[1];
712 }
713 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
714 }
715 if (getDolGlobalString('MAIN_PROFID6_IN_ADDRESS') && !empty($targetcompany->idprof6)) {
716 $tmp = $outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code);
717 if (preg_match('/\‍((.+)\‍)/', $tmp, $reg)) {
718 $tmp = $reg[1];
719 }
720 $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
721 }
722
723 // Public note
724 if (getDolGlobalString('MAIN_PUBLIC_NOTE_IN_ADDRESS')) {
725 if ($mode == 'source' && !empty($sourcecompany->note_public)) {
726 $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($sourcecompany->note_public);
727 }
728 if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) {
729 $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($targetcompany->note_public);
730 }
731 }
732 }
733 }
734
735 return $stringaddress;
736}
737
738
747function pdf_pagehead($pdf, $outputlangs, $page_height)
748{
749 global $conf;
750
751 // Add a background image on document only if good setup of const
752 if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF') && (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF') != '-1')) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image
753 $filepath = $conf->mycompany->dir_output.'/logos/' . getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF');
754 if (file_exists($filepath)) {
755 $pdf->setAutoPageBreak(false, 0); // Disable auto pagebreak before adding image
756 if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) {
757 $pdf->SetAlpha(getDolGlobalFloat('MAIN_USE_BACKGROUND_ON_PDF_ALPHA'));
758 } // Option for change opacity of background
759 $pdf->Image($filepath, getDolGlobalFloat('MAIN_USE_BACKGROUND_ON_PDF_X'), getDolGlobalFloat('MAIN_USE_BACKGROUND_ON_PDF_Y'), 0, $page_height);
760 if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) {
761 $pdf->SetAlpha(1);
762 }
763 $pdf->SetPageMark(); // This option avoid to have the images missing on some pages
764 $pdf->setAutoPageBreak(true, 0); // Restore pagebreak
765 }
766 }
767 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND') != '-1') {
768 $pdf->SetPageMark(); // This option avoid to have the images missing on some pages
769 }
770}
771
772
785function pdfWriteAdditionnalTitle($pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy)
786{
787 // Transaction/Signature ID + Duplicate or Temporary info
788 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
789
790 pdfWriteBlockedLogSignature($pdf, $outputlangs, $page_height, $object, $w, $posx, $posy);
791}
792
793
810function pdfWriteVATArray($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis, $object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl)
811{
812 global $mysoc;
813
814 $tmpatleastoneratenotnull = 0;
815
816 // Local tax 1 before VAT
817 foreach ($docgenerator->localtax1 as $localtax_type => $localtax_rate) {
818 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
819 continue;
820 }
821
822 foreach ($localtax_rate as $tvakey => $tvaval) {
823 if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX1_LINE_IF_ZERO')) {
824 //$tmpatleastoneratenotnull++;
825
826 $index++;
827 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
828
829 $tvacompl = '';
830 if (preg_match('/\*/', (string) $tvakey)) {
831 $tvakey = str_replace('*', '', (string) $tvakey);
832 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
833 }
834
835 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
836 $totalvat .= ' ';
837
838 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
839 $totalvat .= $tvacompl;
840 } else {
841 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
842 }
843
844 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
845
846 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
847
848 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
849 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
850 }
851 }
852 }
853
854 // Local tax 2 before VAT
855 foreach ($docgenerator->localtax2 as $localtax_type => $localtax_rate) {
856 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
857 continue;
858 }
859
860 foreach ($localtax_rate as $tvakey => $tvaval) {
861 if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX2_LINE_IF_ZERO')) {
862 //$tmpatleastoneratenotnull++;
863
864 $index++;
865 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
866
867 $tvacompl = '';
868 if (preg_match('/\*/', (string) $tvakey)) {
869 $tvakey = str_replace('*', '', (string) $tvakey);
870 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
871 }
872 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
873 $totalvat .= ' ';
874
875 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
876 $totalvat .= $tvacompl;
877 } else {
878 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
879 }
880
881 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
882
883 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
884
885 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
886 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
887 }
888 }
889 }
890
891 // Situations totals might be wrong on huge amounts with old mode 1
892 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
893 $sum_pdf_tva = 0;
894 foreach ($docgenerator->tva as $tvakey => $tvaval) {
895 $sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object
896 }
897
898 if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
899 if (!empty($sum_pdf_tva)) {
900 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
901 } else {
902 $coef_fix_tva = 1;
903 }
904
905
906 foreach ($docgenerator->tva as $tvakey => $tvaval) {
907 $docgenerator->tva[$tvakey] = $tvaval * $coef_fix_tva;
908 }
909 foreach ($docgenerator->tva_array as $tvakey => $tvaval) {
910 $docgenerator->tva_array[$tvakey]['amount'] = $tvaval['amount'] * $coef_fix_tva;
911 }
912 }
913 }
914
915 if (!getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) { // by default, we show detail of vat here
916 // VAT
917 foreach ($docgenerator->tva_array as $tvakey => $tvaval) {
918 if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_VAT_LINE_IF_ZERO')) {
919 $tmpatleastoneratenotnull++;
920
921 $index++;
922 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
923
924 $tvacompl = '';
925 if (preg_match('/\*/', $tvakey)) {
926 $tvakey = str_replace('*', '', $tvakey);
927 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
928 }
929 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
930 $totalvat .= ' ';
931 if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
932 $totalvat .= vatrate((string) $tvaval['vatrate'], true).$tvacompl;
933 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
934 $totalvat .= $tvaval['vatcode'].$tvacompl;
935 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
936 $totalvat .= $tvacompl;
937 } else {
938 $totalvat .= vatrate((string) $tvaval['vatrate'], true).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
939 }
940
941 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
942
943 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
944
945 $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', true);
946 }
947 }
948 }
949
950 // Local tax 1 after VAT
951 foreach ($docgenerator->localtax1 as $localtax_type => $localtax_rate) {
952 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
953 continue;
954 }
955
956 foreach ($localtax_rate as $tvakey => $tvaval) {
957 if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX1_LINE_IF_ZERO')) {
958 //$tmpatleastoneratenotnull++;
959
960 $index++;
961 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
962
963 $tvacompl = '';
964 if (preg_match('/\*/', (string) $tvakey)) {
965 $tvakey = str_replace('*', '', (string) $tvakey);
966 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
967 }
968 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
969 $totalvat .= ' ';
970
971 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
972 $totalvat .= $tvacompl;
973 } else {
974 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
975 }
976
977 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
978
979 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
980
981 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
982 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
983 }
984 }
985 }
986
987 // Local tax 2 after VAT
988 foreach ($docgenerator->localtax2 as $localtax_type => $localtax_rate) {
989 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
990 continue;
991 }
992
993 foreach ($localtax_rate as $tvakey => $tvaval) {
994 // retrieve global local tax
995 if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX2_LINE_IF_ZERO')) {
996 //$tmpatleastoneratenotnull++;
997
998 $index++;
999 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1000
1001 $tvacompl = '';
1002 if (preg_match('/\*/', (string) $tvakey)) {
1003 $tvakey = str_replace('*', '', (string) $tvakey);
1004 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1005 }
1006 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1007 $totalvat .= ' ';
1008
1009 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1010 $totalvat .= $tvacompl;
1011 } else {
1012 $totalvat .= vatrate((string) abs((float) $tvakey), true).$tvacompl;
1013 }
1014
1015 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', true);
1016
1017 $total_localtax = ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1018
1019 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1020 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', true);
1021 }
1022 }
1023 }
1024
1025 $docgenerator->atleastoneratenotnull = $tmpatleastoneratenotnull;
1026}
1027
1028
1050function pdfWriteAlreadyPaid($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis, $object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl, $deja_regle, $creditnoteamount, $depositsamount, $resteapayer, $resteapayer_origin)
1051{
1052 global $mysoc;
1053
1054 $useborder = 0;
1055
1056 if ((($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS'))
1057 || isALNERunningVersion()) {
1058 // Already paid + Deposits
1059 $index++;
1060 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1061 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("Paid") : ''), 0, 'L', false);
1062 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1063 //if (!isModEnabled("multicurrency") || $object->multicurrency_tx == 1 || getDolGlobalInt('MULTICURRENCY_SHOW_ALSO_MAIN_CURRENCY_ON_PDF') == 0) {
1064 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', false);
1065 //} else {
1066 // $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', false);
1067 //
1068 // $index++;
1069 // $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1070 // $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("Paid") : '').' ('.$outputlangs->getCurrencySymbol($mysoc->currency_code).')', $useborder, 'L', true);
1071
1072 // $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1073 // $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle_origin + $depositsamount_origin, 0, $outputlangs, 1, -1, -1, $mysoc->currency_code), $useborder, 'L', true);
1074 //}
1075
1076 // Credit note
1077 if ($creditnoteamount) {
1078 $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
1079 $labeltouse .= (is_object($outputlangsbis) ? (' / '.(($outputlangsbis->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities("CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities("CreditNotes"))) : '');
1080 $index++;
1081 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1082 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', false);
1083 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1084 $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', false);
1085 }
1086
1087 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1088 $index++;
1089 $pdf->SetFillColor(255, 255, 255);
1090
1091 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("EscompteOfferedShort") : ''), $useborder, 'L', true);
1093 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1094 $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'), 0, $outputlangs), $useborder, 'R', true);
1095
1096 $resteapayer = 0;
1097 $resteapayer_origin = 0;
1098 }
1099
1100 $index++;
1101 $pdf->SetTextColor(0, 0, 60);
1102 $pdf->SetFillColor(224, 224, 224);
1103 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1104 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', true);
1105 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1106 if (!isModEnabled("multicurrency") || $object->multicurrency_tx == 1 || getDolGlobalInt('MULTICURRENCY_SHOW_ALSO_MAIN_CURRENCY_ON_PDF') == 0) {
1107 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', true);
1108 } else {
1109 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', true);
1110
1111 //$pdf->MultiCell($largcol2, $tab2_hl, '('.price($resteapayer_origin, 0, $outputlangs, 1, -1, 'MT', $mysoc->currency_code).') '.price($resteapayer, 0, $outputlangs), 0, 'R', true);
1112 $index++;
1113 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1114 $pdf->SetTextColor(0, 0, 60);
1115 $pdf->SetFillColor(224, 224, 224);
1116 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : '').' ('.$outputlangs->getCurrencySymbol($mysoc->currency_code).')', $useborder, 'L', true);
1117
1118 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1119 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer_origin, 0, $outputlangs, 1, -1, -1, $mysoc->currency_code), $useborder, 'L', true);
1120 }
1121 }
1122}
1123
1124
1135function pdf_getSubstitutionArray($outputlangs, $exclude = null, $object = null, $onlykey = 0, $include = null)
1136{
1137 $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykey, $exclude, $object, $include);
1138 $substitutionarray['__FROM_NAME__'] = '__FROM_NAME__';
1139 $substitutionarray['__FROM_EMAIL__'] = '__FROM_EMAIL__';
1140 return $substitutionarray;
1141}
1142
1143
1155function pdf_watermark($pdf, $outputlangs, $h, $w, $unit, $text)
1156{
1157 // Print Draft Watermark
1158 if ($unit == 'pt') {
1159 $k = 1;
1160 } elseif ($unit == 'mm') {
1161 $k = 72 / 25.4;
1162 } elseif ($unit == 'cm') {
1163 $k = 72 / 2.54;
1164 } elseif ($unit == 'in') {
1165 $k = 72;
1166 } else {
1167 $k = 1;
1168 dol_print_error(null, 'Unexpected unit "'.$unit.'" for pdf_watermark');
1169 }
1170
1171 // Make substitution
1172 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null);
1173 complete_substitutions_array($substitutionarray, $outputlangs, null);
1174 $text = make_substitutions($text, $substitutionarray, $outputlangs);
1175 $text = $outputlangs->convToOutputCharset($text);
1176
1177 $savx = $pdf->getX();
1178 $savy = $pdf->getY();
1179
1180 $watermark_angle = atan($h / $w) / 2;
1181 $watermark_x_pos = 0;
1182 $watermark_y_pos = $h / 3;
1183 $watermark_x = $w / 2;
1184 $watermark_y = $h / 3;
1185 $pdf->SetFont('', 'B', 40);
1186 $pdf->SetTextColor(255, 0, 0);
1187
1188 // rotate
1189 $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k));
1190 // print watermark
1191 $pdf->SetAlpha(0.5);
1192 $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
1193
1194 // set alpha to semi-transparency
1195 $pdf->SetAlpha(0.3);
1196 $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", false);
1197
1198 // antirotate
1199 $pdf->_out('Q');
1200
1201 $pdf->SetXY($savx, $savy);
1202
1203 // Restore alpha
1204 $pdf->SetAlpha(1);
1205}
1206
1207
1219function pdfCertifMention($pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
1220{
1221 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
1222
1223 return pdfCertifMentionblockedLog($pdf, $outputlangs, $seller, $default_font_size, $posy, $pdftemplate);
1224}
1225
1226
1239function pdf_bank($pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
1240{
1241 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
1242
1243 $diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3);
1244 $diffsizecontent = getDolGlobalInt('PDF_DIFFSIZE_CONTENT', 4);
1245 $pdf->SetXY($curx, $cury);
1246
1247 if (empty($onlynumber)) {
1248 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1249 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', false);
1250 $cury += 4;
1251 }
1252
1253 $outputlangs->load("banks");
1254
1255 // Use correct name of bank id according to country
1256 $bickey = "BICNumber";
1257 if ($account->getCountryCode() == 'IN') {
1258 $bickey = "SWIFT";
1259 }
1260
1261 // Get format of bank account according to its country
1262 $usedetailedbban = $account->useDetailedBBAN();
1263
1264 //$onlynumber=0; $usedetailedbban=1; // For tests
1265 if ($usedetailedbban) {
1266 $savcurx = $curx;
1267
1268 if (empty($onlynumber)) {
1269 $pdf->SetFont('', '', $default_font_size - $diffsizecontent);
1270 $pdf->SetXY($curx, $cury);
1271 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', false);
1272 $cury += 3;
1273 }
1274
1275 if (!getDolGlobalString('PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN')) { // Note that some countries still need bank number, BIC/IBAN not enough for them
1276 // Note:
1277 // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56)
1278 // desk = code guichet (FR), used only when $usedetailedbban = 1
1279 // number = account number
1280 // key = check control key used only when $usedetailedbban = 1
1281 if (empty($onlynumber)) {
1282 $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
1283 }
1284
1285 $bank_number_length = 0;
1286 foreach ($account->getFieldsToShow() as $val) {
1287 $pdf->SetXY($curx, $cury + 4);
1288 $pdf->SetFont('', '', $default_font_size - 3);
1289
1290 if ($val == 'BankCode') {
1291 // Bank code
1292 $tmplength = 18;
1293 $content = $account->code_banque;
1294 } elseif ($val == 'DeskCode') {
1295 // Desk
1296 $tmplength = 18;
1297 $content = $account->code_guichet;
1298 } elseif ($val == 'BankAccountNumber') {
1299 // Number
1300 $tmplength = 24;
1301 $content = $account->number;
1302 } elseif ($val == 'BankAccountNumberKey') {
1303 // Key
1304 $tmplength = 15;
1305 $content = $account->cle_rib;
1306 } elseif ($val == 'IBAN' || $val == 'BIC') {
1307 // Key
1308 $tmplength = 0;
1309 $content = '';
1310 } else {
1311 dol_print_error($account->db, 'Unexpected value for getFieldsToShow: '.$val);
1312 break;
1313 }
1314
1315 if ($content == '') {
1316 continue;
1317 }
1318
1319 $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0, 'C', false);
1320 $pdf->SetXY($curx, $cury + 1);
1321 $curx += $tmplength;
1322 $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
1323 $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0, 'C', false);
1324 if (empty($onlynumber)) {
1325 $pdf->line($curx, $cury + 1, $curx, $cury + 7);
1326 }
1327
1328 // Only set this variable when table was printed
1329 $bank_number_length = 8;
1330 }
1331
1332 $curx = $savcurx;
1333 $cury += $bank_number_length;
1334 }
1335 } elseif (!empty($account->number)) {
1336 $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
1337 $pdf->SetXY($curx, $cury);
1338 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', false);
1339 $cury += 3;
1340
1341 $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
1342 $pdf->SetXY($curx, $cury);
1343 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', false);
1344 $cury += 3;
1345
1346 if ($diffsizecontent <= 2) {
1347 $cury += 1;
1348 }
1349 }
1350
1351 $pdf->SetFont('', '', $default_font_size - $diffsizecontent);
1352
1353 if (empty($onlynumber) && !empty($account->address)) {
1354 $pdf->SetXY($curx, $cury);
1355 $val = $outputlangs->transnoentities("Residence").': '.$outputlangs->convToOutputCharset($account->address);
1356 $pdf->MultiCell(100, 3, $val, 0, 'L', false);
1357 //$nboflines=dol_nboflines_bis($val,120);
1358 //$cury+=($nboflines*3)+2;
1359 $tmpy = $pdf->getStringHeight(100, $val);
1360 $cury += $tmpy;
1361 }
1362
1363 if (!empty($account->owner_name)) {
1364 $pdf->SetXY($curx, $cury);
1365 $val = $outputlangs->transnoentities("BankAccountOwner").': '.$outputlangs->convToOutputCharset($account->owner_name);
1366 $pdf->MultiCell(100, 3, $val, 0, 'L', false);
1367 $tmpy = $pdf->getStringHeight(100, $val);
1368 $cury += $tmpy;
1369 } elseif (!$usedetailedbban) {
1370 $cury += 1;
1371 }
1372
1373 // Use correct name of bank id according to country
1374 $ibankey = FormBank::getIBANLabel($account);
1375
1376 if (!empty($account->iban)) {
1377 //Remove whitespaces to ensure we are dealing with the format we expect
1378 $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban));
1379 $ibanDisplay = "";
1380
1381 $nbIbanDisplay_temp = dol_strlen($ibanDisplay_temp);
1382 for ($i = 0; $i < $nbIbanDisplay_temp; $i++) {
1383 $ibanDisplay .= $ibanDisplay_temp[$i];
1384 if ($i % 4 == 3 && $i > 0) {
1385 $ibanDisplay .= " ";
1386 }
1387 }
1388
1389 $pdf->SetFont('', 'B', $default_font_size - 3);
1390 $pdf->SetXY($curx, $cury);
1391 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': '.$ibanDisplay, 0, 'L', false);
1392 $cury += 3;
1393 }
1394
1395 if (!empty($account->bic)) {
1396 $pdf->SetFont('', 'B', $default_font_size - 3);
1397 $pdf->SetXY($curx, $cury);
1398 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', false);
1399 }
1400
1401 return $pdf->getY();
1402}
1403
1421function pdf_pagefoot($pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark = '')
1422{
1423 global $conf, $hookmanager;
1424
1425 $outputlangs->load("dict");
1426 $line = '';
1427 $reg = array();
1428 $marginwithfooter = 0; // Return value
1429
1430 $dims = $pdf->getPageDimensions();
1431
1432 // Line of free text
1433 if (empty($hidefreetext) && getDolGlobalString($paramfreetext)) {
1434 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
1435 // More substitution keys
1436 if (is_object($fromcompany)) {
1437 $substitutionarray['__FROM_NAME__'] = $fromcompany->name;
1438 $substitutionarray['__FROM_EMAIL__'] = $fromcompany->email;
1439 }
1440 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1441 $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray, $outputlangs);
1442
1443 // Make a change into HTML code to allow to include images from medias directory.
1444 // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
1445 // become
1446 // <img alt="" src="'.DOL_DATA_ROOT.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
1447 $newfreetext = preg_replace('/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/', '\1file:/'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext);
1448
1449 $line .= $outputlangs->convToOutputCharset($newfreetext);
1450 }
1451
1452 // First line of company infos
1453 $line1 = "";
1454 $line2 = "";
1455 $line3 = "";
1456 $line4 = "";
1457
1458 if (is_object($fromcompany) && in_array($showdetails, array(1, 3))) {
1459 // Company name
1460 if ($fromcompany->name) {
1461 $line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
1462 }
1463 // Address
1464 if ($fromcompany->address) {
1465 $line1 .= ($line1 ? " - " : "").str_replace("\n", ", ", $fromcompany->address);
1466 }
1467 // Zip code
1468 if ($fromcompany->zip) {
1469 $line1 .= ($line1 ? " - " : "").$fromcompany->zip;
1470 }
1471 // Town
1472 if ($fromcompany->town) {
1473 $line1 .= ($line1 ? " " : "").$fromcompany->town;
1474 }
1475 // Country
1476 if ($fromcompany->country) {
1477 $line1 .= ($line1 ? ", " : "").$fromcompany->country;
1478 }
1479 // Phone
1480 if ($fromcompany->phone) {
1481 $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone;
1482 }
1483 // Fax
1484 if ($fromcompany->fax) {
1485 $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax;
1486 }
1487
1488 // URL
1489 if ($fromcompany->url) {
1490 $line2 .= ($line2 ? " - " : "").$fromcompany->url;
1491 }
1492 // Email
1493 if ($fromcompany->email) {
1494 $line2 .= ($line2 ? " - " : "").$fromcompany->email;
1495 }
1496 }
1497 if ($showdetails == 2 || $showdetails == 3 || (!empty($fromcompany->country_code) && $fromcompany->country_code == 'DE')) {
1498 // Managers
1499 if ($fromcompany->managers) {
1500 $line2 .= ($line2 ? " - " : "").$fromcompany->managers;
1501 }
1502 }
1503
1504 // Line 3 of company infos
1505 // Juridical status
1506 if (!empty($fromcompany->forme_juridique_code)) {
1507 $line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel((string) $fromcompany->forme_juridique_code));
1508 }
1509 // Capital
1510 if (!empty($fromcompany->capital)) {
1511 $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string or a float
1512 if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
1513 $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, getDolCurrency()));
1514 } elseif (!empty($fromcompany->capital)) {
1515 $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", (string) $fromcompany->capital);
1516 }
1517 }
1518 // Prof Id 1
1519 if (!empty($fromcompany->idprof1) && ($fromcompany->country_code != 'FR' || (empty($fromcompany->idprof2) || strpos($fromcompany->idprof2, $fromcompany->idprof1) !== 0))) {
1520 $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code);
1521 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1522 $field = $reg[1];
1523 }
1524 $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
1525 }
1526 // Prof Id 2
1527 if (!empty($fromcompany->idprof2)) {
1528 $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code);
1529 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1530 $field = $reg[1];
1531 }
1532 $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
1533 }
1534
1535 // Line 4 of company infos
1536 // Prof Id 3
1537 if (!empty($fromcompany->idprof3)) {
1538 $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code);
1539 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1540 $field = $reg[1];
1541 }
1542 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
1543 }
1544 // Prof Id 4
1545 if (!empty($fromcompany->idprof4)) {
1546 $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code);
1547 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1548 $field = $reg[1];
1549 }
1550 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
1551 }
1552 // Prof Id 5
1553 if (!empty($fromcompany->idprof5)) {
1554 $field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code);
1555 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1556 $field = $reg[1];
1557 }
1558 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
1559 }
1560 // Prof Id 6
1561 if (!empty($fromcompany->idprof6)) {
1562 $field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code);
1563 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1564 $field = $reg[1];
1565 }
1566 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
1567 }
1568 // Prof Id 7
1569 if (!empty($fromcompany->idprof7)) {
1570 $field = $outputlangs->transcountrynoentities("ProfId7", $fromcompany->country_code);
1571 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1572 $field = $reg[1];
1573 }
1574 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof7);
1575 }
1576 // Prof Id 8
1577 if (!empty($fromcompany->idprof8)) {
1578 $field = $outputlangs->transcountrynoentities("ProfId8", $fromcompany->country_code);
1579 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1580 $field = $reg[1];
1581 }
1582 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof8);
1583 }
1584 // Prof Id 9
1585 if (!empty($fromcompany->idprof9)) {
1586 $field = $outputlangs->transcountrynoentities("ProfId9", $fromcompany->country_code);
1587 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1588 $field = $reg[1];
1589 }
1590 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof9);
1591 }
1592 // Prof Id 10
1593 if (!empty($fromcompany->idprof10)) {
1594 $field = $outputlangs->transcountrynoentities("ProfId10", $fromcompany->country_code);
1595 if (preg_match('/\‍((.*)\‍)/i', $field, $reg)) {
1596 $field = $reg[1];
1597 }
1598 $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof10);
1599 }
1600 // IntraCommunautary VAT
1601 if (!empty($fromcompany->tva_intra) && $fromcompany->tva_intra != '') {
1602 $line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
1603 }
1604
1605 $pdf->SetFont('', '', 7);
1606 $pdf->SetDrawColor(224, 224, 224);
1607 // Option for footer text color
1608 if (getDolGlobalString('PDF_FOOTER_TEXT_COLOR')) {
1609 $tmparray = sscanf(getDolGlobalString('PDF_FOOTER_TEXT_COLOR'), '%d, %d, %d');
1610 $r = $tmparray[0];
1611 $g = $tmparray[1];
1612 $b = $tmparray[2];
1613 $pdf->SetTextColor($r, $g, $b);
1614 }
1615
1616 // The start of the bottom of this page footer is positioned according to # of lines
1617 $freetextheight = 0;
1618 $align = '';
1619 if ($line) { // Free text
1620 //$line="sample text<br>\nfd<strong>sf</strong>sdf<br>\nghfghg<br>";
1621 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
1622 $width = 20000;
1623 $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
1624 if (getDolGlobalString('MAIN_USE_AUTOWRAP_ON_FREETEXT')) {
1625 $width = 200;
1626 $align = 'C';
1627 }
1628 $freetextheight = $pdf->getStringHeight($width, $line);
1629 } else {
1630 $freetextheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content)
1631 //print '<br>'.$freetextheight;
1632 }
1633 }
1634
1635 $posy = 0;
1636 // For customized footer
1637 if (is_object($hookmanager)) {
1638 $parameters = array('line1' => $line1, 'line2' => $line2, 'line3' => $line3, 'line4' => $line4, 'outputlangs' => $outputlangs);
1639 $action = '';
1640 $hookmanager->executeHooks('pdf_pagefoot', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1641 if (!empty($hookmanager->resPrint) && $hidefreetext == 0) {
1642 $mycustomfooter = $hookmanager->resPrint;
1643 $mycustomfooterheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0));
1644
1645 $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight;
1646 $posy = (float) $marginwithfooter;
1647
1648 // Option for footer background color (without freetext zone)
1649 if (getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) {
1650 $tmparray = sscanf(getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR'), '%d, %d, %d');
1651 $r = $tmparray[0];
1652 $g = $tmparray[1];
1653 $b = $tmparray[2];
1654 $pdf->setAutoPageBreak(false, 0); // Disable auto pagebreak
1655 $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', array(), $fill_color = array($r, $g, $b));
1656 $pdf->setAutoPageBreak(true, 0); // Restore pagebreak
1657 }
1658
1659 if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) {
1660 $pdf->setAutoPageBreak(false, 0);
1661 } // Option for disable auto pagebreak
1662 if ($line) { // Free text
1663 $pdf->SetXY($dims['lm'], -$posy);
1664 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default
1665 $pdf->MultiCell(0, 3, $line, 0, $align, false);
1666 } else {
1667 $pdf->writeHTMLCell($dims['wk'] - $dims['lm'] - $dims['rm'], $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0));
1668 }
1669 $posy -= $freetextheight;
1670 }
1671 if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) {
1672 $pdf->setAutoPageBreak(true, 0);
1673 } // Restore pagebreak
1674
1675 $pdf->SetY(-$posy);
1676
1677 // Hide footer line if footer background color is set
1678 if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) {
1679 $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy);
1680 }
1681
1682 // Option for set top margin height of footer after freetext
1683 if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) {
1684 $posy -= (float) getDolGlobalString('PDF_FOOTER_TOP_MARGIN');
1685 } else {
1686 $posy--;
1687 }
1688
1689 if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) {
1690 $pdf->setAutoPageBreak(false, 0);
1691 } // Option for disable auto pagebreak
1692 $pdf->writeHTMLCell($dims['wk'] - $dims['lm'] - $dims['rm'], $mycustomfooterheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0));
1693 if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) {
1694 $pdf->setAutoPageBreak(true, 0);
1695 } // Restore pagebreak
1696
1697 $posy -= $mycustomfooterheight - 3;
1698 } else {
1699 // Else default footer
1700 $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
1701 $posy = (float) $marginwithfooter;
1702
1703 // Option for footer background color (without freetext zone)
1704 if (getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) {
1705 $tmparray = sscanf(getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR'), '%d, %d, %d');
1706 $r = $tmparray[0];
1707 $g = $tmparray[1];
1708 $b = $tmparray[2];
1709 $pdf->setAutoPageBreak(false, 0); // Disable auto pagebreak
1710 $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', array(), $fill_color = array($r, $g, $b));
1711 $pdf->setAutoPageBreak(true, 0); // Restore pagebreak
1712 }
1713
1714 if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) {
1715 $pdf->setAutoPageBreak(false, 0);
1716 } // Option for disable auto pagebreak
1717 if ($line) { // Free text
1718 $pdf->SetXY($dims['lm'], -$posy);
1719 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default
1720 $pdf->MultiCell(0, 3, $line, 0, $align, false);
1721 } else {
1722 $pdf->writeHTMLCell($dims['wk'] - $dims['lm'] - $dims['rm'], $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0));
1723 }
1724 $posy -= $freetextheight;
1725 }
1726 if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) {
1727 $pdf->setAutoPageBreak(true, 0);
1728 } // Restore pagebreak
1729
1730 $pdf->SetY(-$posy);
1731
1732 // Option for hide all footer (page number will no hidden)
1733 if (!getDolGlobalInt('PDF_FOOTER_HIDDEN')) {
1734 // Hide footer line if footer background color is set
1735 if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) {
1736 $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy);
1737 }
1738
1739 // Option for set top margin height of footer after freetext
1740 if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) {
1741 $posy -= (float) getDolGlobalString('PDF_FOOTER_TOP_MARGIN');
1742 } else {
1743 $posy--;
1744 }
1745
1746 if (!empty($line1)) {
1747 $pdf->SetFont('', 'B', 7);
1748 $pdf->SetXY($dims['lm'], -$posy);
1749 $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', false);
1750 $posy -= 3;
1751 $pdf->SetFont('', '', 7);
1752 }
1753
1754 if (!empty($line2)) {
1755 $pdf->SetFont('', 'B', 7);
1756 $pdf->SetXY($dims['lm'], -$posy);
1757 $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', false);
1758 $posy -= 3;
1759 $pdf->SetFont('', '', 7);
1760 }
1761
1762 if (!empty($line3)) {
1763 $pdf->SetXY($dims['lm'], -$posy);
1764 $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', false);
1765 }
1766
1767 if (!empty($line4)) {
1768 $posy -= 3;
1769 $pdf->SetXY($dims['lm'], -$posy);
1770 $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', false);
1771 }
1772 }
1773 }
1774 }
1775
1776 // Show page nb and apply correction for some font.
1777 $pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0));
1778
1779 $pagination = $pdf->PageNo().' / '.$pdf->getAliasNbPages();
1780 $fontRenderCorrection = 0;
1781 if (in_array(pdf_getPDFFont($outputlangs), array('freemono', 'DejaVuSans'))) {
1782 $fontRenderCorrection = 10;
1783 }
1784 $pdf->MultiCell(18 + $fontRenderCorrection, 2, $pagination, 0, 'R', false);
1785
1786 // Show Draft Watermark
1787 if (!empty($watermark)) {
1788 pdf_watermark($pdf, $outputlangs, $page_hauteur, $page_largeur, 'mm', $watermark);
1789 }
1790
1791 return $marginwithfooter;
1792}
1793
1808function pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
1809{
1810 $linkedobjects = pdf_getLinkedObjects($object, $outputlangs); // May update $object->note_public
1811
1812 if (!empty($linkedobjects)) {
1813 foreach ($linkedobjects as $linkedobject) {
1814 $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"];
1815 if (!empty($linkedobject["date_value"])) {
1816 $reftoshow .= ' / '.$linkedobject["date_value"];
1817 }
1818
1819 $posy += 3;
1820 $pdf->SetXY($posx, $posy);
1821 $pdf->SetFont('', '', (float) $default_font_size - 2);
1822 $pdf->MultiCell($w, $h, $reftoshow, '', $align);
1823 }
1824 }
1825
1826 return $pdf->getY();
1827}
1828
1846function pdf_writelinedesc($pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0, $align = 'J')
1847{
1848 global $hookmanager;
1849
1850 $reshook = 0;
1851 $result = '';
1852 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
1853 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
1854 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
1855 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1856 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1857 }
1858 $parameters = array('pdf' => $pdf, 'i' => $i, 'outputlangs' => $outputlangs, 'w' => $w, 'h' => $h, 'posx' => $posx, 'posy' => $posy, 'hideref' => $hideref, 'hidedesc' => $hidedesc, 'issupplierline' => $issupplierline, 'special_code' => $special_code);
1859 $action = '';
1860 // WARNING: A hook must not close/open the PDF transaction. Doing this generates a lot of trouble.
1861 // Test to know if content added by the hooks is already done by the main caller of pdf_writelinedesc
1862 $reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1863
1864 if (!empty($hookmanager->resPrint)) {
1865 $result .= $hookmanager->resPrint;
1866 }
1867 }
1868 if (empty($reshook)) {
1869 $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
1870 $labelproductservice = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)/', '\1file:/'.DOL_DATA_ROOT.'/medias/\2\3', $labelproductservice, -1, $nbrep);
1871
1872 //var_dump($labelproductservice);exit;
1873
1874 // Fix bug of some HTML editors that replace links <img src="http://localhostgit/viewimage.php?modulepart=medias&file=image/efd.png" into <img src="http://localhostgit/viewimage.php?modulepart=medias&amp;file=image/efd.png"
1875 // We make the reverse, so PDF generation has the real URL.
1876 $nbrep = 0;
1877 $labelproductservice = preg_replace('/(<img[^>]*src=")([^"]*)(&amp;)([^"]*")/', '\1\2&\4', $labelproductservice, -1, $nbrep);
1878
1879 if (getDolGlobalString('MARGIN_TOP_ZERO_UL')) {
1880 $pdf->setListIndentWidth(5);
1881 $TMarginList = ['ul' => [['h' => 0.1, ],['h' => 0.1, ]], 'li' => [['h' => 0.1, ],],];
1882 $pdf->setHtmlVSpace($TMarginList);
1883 }
1884
1885 // Description
1886 $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, $align, true);
1887 $result .= $labelproductservice;
1888 }
1889 return $result;
1890}
1891
1903function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1904{
1905 global $db, $conf, $langs;
1906
1907 $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
1908 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : ''));
1909 $product_barcode = (!empty($object->lines[$i]->product_barcode) ? $object->lines[$i]->product_barcode : "");
1910 $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : ''));
1911 $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
1912 $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
1913 $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
1914
1915 $multilangsactive = getDolGlobalInt('MAIN_MULTILANGS');
1916
1917 if ($issupplierline) {
1918 include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
1919 $prodser = new ProductFournisseur($db);
1920 } else {
1921 include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
1922 $prodser = new Product($db);
1923
1924 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
1925 include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
1926 }
1927 }
1928
1929 //id
1930 $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
1931 if ($idprod) {
1932 $prodser->fetch($idprod);
1933 //load multilangs
1934 if ($multilangsactive) {
1935 $prodser->getMultiLangs();
1936 $object->lines[$i]->multilangs = $prodser->multilangs;
1937 }
1938 }
1939 //label
1940 if (!empty($object->lines[$i]->label)) {
1941 $label = $object->lines[$i]->label;
1942 } else {
1943 if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']) && $multilangsactive) {
1944 $label = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['label'];
1945 } else {
1946 if (!empty($object->lines[$i]->product_label)) {
1947 $label = $object->lines[$i]->product_label;
1948 } else {
1949 $label = '';
1950 }
1951 }
1952 }
1953 //description
1954 if (!empty($object->lines[$i]->desc)) {
1955 $desc = $object->lines[$i]->desc;
1956 } else {
1957 if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']) && $multilangsactive) {
1958 $desc = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['description'];
1959 } else {
1960 if (!empty($object->lines[$i]->description)) {
1961 $desc = $object->lines[$i]->description;
1962 } else {
1963 $desc = '';
1964 }
1965 }
1966 }
1967 //ref supplier
1968 $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
1969 //note
1970 $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
1971 //dbatch
1972 $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
1973
1974 if ($idprod) {
1975 // If a predefined product and multilang and on other lang, we renamed label with label translated
1976 if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) {
1977 $translatealsoifmodified = getDolGlobalString('MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED'); // By default if value was modified manually, we keep it (no translation because we don't have it)
1978
1979 // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
1980 // ($textwasnotmodified is replaced with $textwasmodifiedorcompleted and we add completion).
1981
1982 // Set label
1983 // If we want another language, and if label is same than default language (we did not force it to a specific value), we can use translation.
1984 //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit;
1985 $textwasnotmodified = ($label == $prodser->label);
1986 if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1987 $label = $prodser->multilangs[$outputlangs->defaultlang]["label"];
1988 }
1989
1990 // Set desc
1991 // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no
1992 $textwasnotmodified = false;
1993 if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) {
1994 $textwasnotmodified = (strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML5), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML5)) !== false);
1995 } else {
1996 $textwasnotmodified = ($desc == $prodser->description);
1997 }
1998 if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"])) {
1999 if ($textwasnotmodified) {
2000 $desc = str_replace($prodser->description, $prodser->multilangs[$outputlangs->defaultlang]["description"], $desc);
2001 } elseif ($translatealsoifmodified) {
2002 $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
2003 }
2004 }
2005
2006 // Set note
2007 $textwasnotmodified = ($note == $prodser->note_public);
2008 if (!empty($prodser->multilangs[$outputlangs->defaultlang]["other"]) && ($textwasnotmodified || $translatealsoifmodified)) {
2009 $note = $prodser->multilangs[$outputlangs->defaultlang]["other"];
2010 }
2011 }
2012 } elseif (($object->element == 'facture' || $object->element == 'facturefourn') && preg_match('/^\‍(DEPOSIT\‍).+/', $desc)) { // We must not replace '(DEPOSIT)' when it is alone, it will be translated and detailed later
2013 $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc);
2014 }
2015
2016 $libelleproduitservice = ''; // Default value
2017 if (!getDolGlobalString('PDF_HIDE_PRODUCT_LABEL_IN_SUPPLIER_LINES')) {
2018 // Description short of product line
2019 $libelleproduitservice = $label;
2020 if (!empty($libelleproduitservice) && getDolGlobalString('PDF_BOLD_PRODUCT_LABEL')) {
2021 // Adding <b> may convert the original string into a HTML string. So we have to first
2022 // convert \n into <br> we text is not already HTML.
2023 if (!dol_textishtml($libelleproduitservice)) {
2024 $libelleproduitservice = str_replace("\n", '<br>', $libelleproduitservice);
2025 }
2026 $libelleproduitservice = '<b>'.$libelleproduitservice.'</b>';
2027 }
2028 }
2029
2030
2031 // Add ref of subproducts
2032 if (getDolGlobalString('SHOW_SUBPRODUCT_REF_IN_PDF')) {
2033 $prodser->get_sousproduits_arbo();
2034 if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
2035 $outputlangs->load('mrp');
2036 $tmparrayofsubproducts = reset($prodser->sousprods);
2037
2038 $qtyText = null;
2039 if (isset($object->lines[$i]->qty) && !empty($object->lines[$i]->qty)) {
2040 $qtyText = $object->lines[$i]->qty;
2041 } elseif (isset($object->lines[$i]->qty_shipped) && !empty($object->lines[$i]->qty_shipped)) {
2042 $qtyText = $object->lines[$i]->qty;
2043 }
2044
2045 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) {
2046 foreach ($tmparrayofsubproducts as $subprodval) {
2047 $libelleproduitservice = dol_concatdesc(
2048 dol_concatdesc($libelleproduitservice, " * ".$subprodval[3]),
2049 (!empty($qtyText) ?
2050 $outputlangs->trans('Qty').':'.$qtyText.' x '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1].'= '.$outputlangs->trans('QtyTot').':'.$subprodval[1] * $qtyText :
2051 $outputlangs->trans('Qty').' '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1])
2052 );
2053 }
2054 } else {
2055 foreach ($tmparrayofsubproducts as $subprodval) {
2056 $libelleproduitservice = dol_concatdesc(
2057 dol_concatdesc($libelleproduitservice, " * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3]),
2058 (!empty($qtyText) ?
2059 $outputlangs->trans('Qty').':'.$qtyText.' x '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1].'= '.$outputlangs->trans('QtyTot').':'.$subprodval[1] * $qtyText :
2060 $outputlangs->trans('Qty').' '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1])
2061 );
2062 }
2063 }
2064 }
2065 }
2066
2067 if (isModEnabled('barcode') && getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_PRODUCT_BARCODE') && !empty($product_barcode)) {
2068 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $outputlangs->trans("BarCode")." ".$product_barcode);
2069 }
2070
2071 // Description long of product line
2072 if (!empty($desc) && ($desc != $label)) {
2073 if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
2074 $discount = new DiscountAbsolute($db);
2075 $discount->fetch($object->lines[$i]->fk_remise_except);
2076 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
2077 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref);
2078 } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
2079 $discount = new DiscountAbsolute($db);
2080 $discount->fetch($object->lines[$i]->fk_remise_except);
2081 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
2082 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref);
2083 // Add date of deposit
2084 if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) {
2085 $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
2086 }
2087 } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) {
2088 $discount = new DiscountAbsolute($db);
2089 $discount->fetch($object->lines[$i]->fk_remise_except);
2090 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source);
2091 } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) {
2092 $discount = new DiscountAbsolute($db);
2093 $discount->fetch($object->lines[$i]->fk_remise_except);
2094 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
2095 } else {
2096 if ($idprod) {
2097 // Check if description must be output
2098 if (!empty($object->element)) {
2099 $tmpkey = 'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper($object->element);
2100 if (getDolGlobalString($tmpkey)) {
2101 $hidedesc = 1;
2102 }
2103 }
2104 if (empty($hidedesc)) {
2105 if (getDolGlobalString('MAIN_DOCUMENTS_DESCRIPTION_FIRST')) {
2106 $libelleproduitservice = dol_concatdesc($desc, $libelleproduitservice);
2107 } else {
2108 if (getDolGlobalString('HIDE_LABEL_VARIANT_PDF') && $prodser->isVariant()) {
2109 $libelleproduitservice = $desc;
2110 } else {
2111 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc);
2112 }
2113 }
2114 }
2115 } else {
2116 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc);
2117 }
2118 }
2119 }
2120
2121 // We add ref of product (and supplier ref if defined)
2122 $prefix_prodserv = "";
2123 $ref_prodserv = "";
2124 if (getDolGlobalString('PRODUCT_ADD_TYPE_IN_DOCUMENTS')) { // In standard mode, we do not show this
2125 if ($prodser->isService()) {
2126 $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
2127 } else {
2128 $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
2129 }
2130 }
2131
2132 if (empty($hideref)) {
2133 if ($issupplierline) {
2134 if (!getDolGlobalString('PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES')) { // Common case
2135 $ref_prodserv = $prodser->ref; // Show local ref
2136 if ($ref_supplier) {
2137 $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : '');
2138 }
2139 } elseif (getDolGlobalInt('PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES') == 1) {
2140 $ref_prodserv = $ref_supplier;
2141 } elseif (getDolGlobalInt('PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES') == 2) {
2142 $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
2143 }
2144 } else {
2145 $ref_prodserv = $prodser->ref; // Show local ref only
2146
2147 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
2148 $productCustomerPriceStatic = new ProductCustomerPrice($db);
2149 $filter = array('fk_product' => (string) $idprod, 'fk_soc' => (string) $object->socid);
2150
2151 $nbCustomerPrices = $productCustomerPriceStatic->fetchAll('', '', 1, 0, $filter);
2152
2153 if ($nbCustomerPrices > 0) {
2154 $productCustomerPrice = null;
2155 if (count($productCustomerPriceStatic->lines) > 0) {
2156 $date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
2157 foreach ($productCustomerPriceStatic->lines as $k => $custprice_line) {
2158 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
2159 $productCustomerPrice = $custprice_line;
2160 break;
2161 }
2162 }
2163 }
2164
2165 if (isset($productCustomerPrice) && !empty($productCustomerPrice->ref_customer)) {
2166 $idcustprice = getDolGlobalInt('PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE');
2167 switch ($idcustprice) {
2168 case 1:
2169 $ref_prodserv = $productCustomerPrice->ref_customer;
2170 break;
2171
2172 case 2:
2173 $ref_prodserv = $productCustomerPrice->ref_customer . ' (' . $outputlangs->transnoentitiesnoconv('InternalRef') . ' ' . $ref_prodserv . ')';
2174 break;
2175
2176 default:
2177 $ref_prodserv = $ref_prodserv . ' (' . $outputlangs->transnoentitiesnoconv('RefCustomer') . ' ' . $productCustomerPrice->ref_customer . ')';
2178 }
2179 }
2180 }
2181 }
2182 }
2183
2184 if (!empty($libelleproduitservice) && !empty($ref_prodserv)) {
2185 $ref_prodserv .= " - ";
2186 }
2187 }
2188
2189 if (!empty($ref_prodserv) && getDolGlobalString('PDF_BOLD_PRODUCT_REF_AND_PERIOD')) {
2190 if (!dol_textishtml($libelleproduitservice)) {
2191 $libelleproduitservice = str_replace("\n", '<br>', $libelleproduitservice);
2192 }
2193 $ref_prodserv = '<b>'.$ref_prodserv.'</b>';
2194 // $prefix_prodserv and $ref_prodser are not HTML var
2195 }
2196 $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
2197
2198 // Add an additional description for the category products
2199 if (getDolGlobalString('CATEGORY_ADD_DESC_INTO_DOC') && $idprod && isModEnabled('category')) {
2200 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
2201 $categstatic = new Categorie($db);
2202 // recovering the list of all the categories linked to product
2203 $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
2204 foreach ($tblcateg as $cate) {
2205 // Adding the descriptions if they are filled
2206 $desccateg = $cate->description;
2207 if ($desccateg) {
2208 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desccateg);
2209 }
2210 }
2211 }
2212
2213 if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) {
2214 $format = 'day';
2215 $period = '';
2216 // Show duration if exists
2217 if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
2218 $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
2219 }
2220 if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) {
2221 $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')';
2222 }
2223 if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) {
2224 $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
2225 }
2226 //print '>'.$outputlangs->charset_output.','.$period;
2227 if (getDolGlobalString('PDF_BOLD_PRODUCT_REF_AND_PERIOD')) {
2228 if (!dol_textishtml($libelleproduitservice)) {
2229 $libelleproduitservice = str_replace("\n", '<br>', $libelleproduitservice);
2230 }
2231 $libelleproduitservice .= '<br><b style="color:#333666;" ><em>'.$period.'</em></b>';
2232 } else {
2233 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period);
2234 }
2235 //print $libelleproduitservice;
2236 }
2237
2238 // Show information for lot
2239 if (!empty($dbatch)) {
2240 // $object is a shipment.
2241 //var_dump($object->lines[$i]->details_entrepot); // array from llx_expeditiondet (we can have several lines for one fk_origin_line)
2242 //var_dump($object->lines[$i]->detail_batch); // array from llx_expeditiondet_batch (each line with a lot is linked to llx_expeditiondet)
2243
2244 include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
2245 include_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
2246 $tmpwarehouse = new Entrepot($db);
2247 $tmpproductbatch = new Productbatch($db);
2248
2249 $format = 'day';
2250 foreach ($dbatch as $detail) {
2251 $dte = array();
2252 if ($detail->eatby) {
2253 $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs));
2254 }
2255 if ($detail->sellby) {
2256 $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs));
2257 }
2258 if ($detail->batch) {
2259 $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch);
2260 }
2261 if ($detail->qty) {
2262 $dte[] = $outputlangs->transnoentitiesnoconv('printQty', (string) $detail->qty);
2263 }
2264
2265 // Add also info of planned warehouse for lot
2266 if ($object->element == 'shipping' && $detail->fk_origin_stock > 0 && getDolGlobalInt('PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT')) {
2267 $resproductbatch = $tmpproductbatch->fetch($detail->fk_origin_stock);
2268 if ($resproductbatch > 0) {
2269 $reswarehouse = $tmpwarehouse->fetch($tmpproductbatch->warehouseid);
2270 if ($reswarehouse > 0) {
2271 $dte[] = $tmpwarehouse->ref;
2272 }
2273 }
2274 }
2275
2276 $libelleproduitservice .= "__N__ ".implode(" - ", $dte);
2277 }
2278 } else {
2279 if (getDolGlobalInt('PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT')) {
2280 // TODO Show warehouse for shipment line without batch
2281 }
2282 }
2283
2284 // Now we convert \n into br
2285 if (dol_textishtml($libelleproduitservice)) {
2286 $libelleproduitservice = preg_replace('/__N__/', '<br>', $libelleproduitservice);
2287 } else {
2288 $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice);
2289 }
2290 $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1);
2291
2292 return $libelleproduitservice;
2293}
2294
2304function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0)
2305{
2306 global $hookmanager;
2307
2308 $reshook = 0;
2309 $result = '';
2310 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2311 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2312 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2313 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2314 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2315 }
2316 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2317 $action = '';
2318 $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2319 $result .= $hookmanager->resPrint;
2320 }
2321 if (empty($reshook)) {
2322 $result .= dol_htmlentitiesbr($object->lines[$i]->num);
2323 }
2324 return $result;
2325}
2326
2327
2337function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0)
2338{
2339 global $hookmanager;
2340
2341 $reshook = 0;
2342 $result = '';
2343 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2344 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2345 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2346 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2347 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2348 }
2349 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2350 $action = '';
2351 $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2352 $result .= $hookmanager->resPrint;
2353 }
2354 if (empty($reshook)) {
2355 $result .= dol_htmlentitiesbr($object->lines[$i]->product_ref);
2356 }
2357 return $result;
2358}
2359
2360
2370function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0)
2371{
2372 global $hookmanager;
2373
2374 $reshook = 0;
2375 $result = '';
2376 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2377 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2378 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2379 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2380 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2381 }
2382 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2383 $action = '';
2384 $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2385 $result .= $hookmanager->resPrint;
2386 }
2387 if (empty($reshook)) {
2388 $result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier);
2389 }
2390 return $result;
2391}
2392
2402function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
2403{
2404 global $conf, $hookmanager, $mysoc;
2405
2406 $result = '';
2407 $reshook = 0;
2408 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2409 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2410 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2411 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2412 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2413 }
2414 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2415 $action = '';
2416 $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2417
2418 if (!empty($hookmanager->resPrint)) {
2419 $result .= $hookmanager->resPrint;
2420 }
2421 }
2422 if (empty($reshook)) {
2423 if (empty($hidedetails) || $hidedetails > 1) {
2424 $tmpresult = '';
2425
2426 $tmpresult .= vatrate($object->lines[$i]->tva_tx, false, $object->lines[$i]->info_bits, -1);
2427 if (!getDolGlobalString('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) {
2428 if (price2num($object->lines[$i]->localtax1_tx)) {
2429 if (preg_replace('/[\s0%]/', '', $tmpresult)) {
2430 $tmpresult .= '/';
2431 } else {
2432 $tmpresult = '';
2433 }
2434 $tmpresult .= vatrate((string) abs($object->lines[$i]->localtax1_tx), false);
2435 }
2436 }
2437 if (!getDolGlobalString('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) {
2438 if (price2num($object->lines[$i]->localtax2_tx)) {
2439 if (preg_replace('/[\s0%]/', '', $tmpresult)) {
2440 $tmpresult .= '/';
2441 } else {
2442 $tmpresult = '';
2443 }
2444 $tmpresult .= vatrate((string) abs($object->lines[$i]->localtax2_tx), false);
2445 }
2446 }
2447 $tmpresult .= '%';
2448
2449 $result .= $tmpresult;
2450 }
2451 }
2452 return $result;
2453}
2454
2464function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0)
2465{
2466 global $hookmanager;
2467
2468 $sign = 1;
2469 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
2470 $sign = -1;
2471 }
2472
2473 $result = '';
2474 $reshook = 0;
2475 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2476 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2477 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2478 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2479 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2480 }
2481 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2482 $action = '';
2483 $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2484
2485 if (!empty($hookmanager->resPrint)) {
2486 $result .= $hookmanager->resPrint;
2487 }
2488 }
2489 if (empty($reshook)) {
2490 if (empty($hidedetails) || $hidedetails > 1) {
2491 $subprice = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
2492 $result .= price($sign * $subprice, 0, $outputlangs);
2493 }
2494 }
2495 return $result;
2496}
2497
2507function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0)
2508{
2509 global $hookmanager;
2510
2511 $sign = 1;
2512 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
2513 $sign = -1;
2514 }
2515
2516 $result = '';
2517 $reshook = 0;
2518 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2519 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2520 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2521 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2522 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2523 }
2524 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2525 $action = '';
2526 $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2527
2528 if (!empty($hookmanager->resPrint)) {
2529 $result .= $hookmanager->resPrint;
2530 }
2531 }
2532 if (empty($reshook)) {
2533 if (empty($hidedetails) || $hidedetails > 1) {
2534 $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
2535 }
2536 }
2537 return $result;
2538}
2539
2549function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0)
2550{
2551 global $hookmanager;
2552
2553 $result = '';
2554 $reshook = 0;
2555 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2556 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2557 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2558 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2559 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2560 }
2561 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2562 $action = '';
2563 $reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2564
2565 if (!empty($hookmanager->resPrint)) {
2566 $result = $hookmanager->resPrint;
2567 }
2568 }
2569 if (empty($reshook)) {
2570 if ($object->lines[$i]->special_code == 3) {
2571 return '';
2572 }
2573 if (empty($hidedetails) || $hidedetails > 1) {
2574 $result .= $object->lines[$i]->qty;
2575 }
2576 }
2577 return $result;
2578}
2579
2589function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0)
2590{
2591 global $hookmanager;
2592
2593 $reshook = 0;
2594 $result = '';
2595 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2596 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2597 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2598 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2599 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2600 }
2601 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2602 $action = '';
2603 $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2604
2605 if (!empty($hookmanager->resPrint)) {
2606 $result .= $hookmanager->resPrint;
2607 }
2608 }
2609 if (empty($reshook)) {
2610 if ($object->lines[$i]->special_code == 3) {
2611 return '';
2612 }
2613 if (empty($hidedetails) || $hidedetails > 1) {
2614 $result .= $object->lines[$i]->qty_asked;
2615 }
2616 }
2617 return $result;
2618}
2619
2629function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0)
2630{
2631 global $hookmanager;
2632
2633 $reshook = 0;
2634 $result = '';
2635 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2636 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2637 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2638 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2639 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2640 }
2641 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2642 $action = '';
2643 $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2644
2645 if (!empty($hookmanager->resPrint)) {
2646 $result .= $hookmanager->resPrint;
2647 }
2648 }
2649 if (empty($reshook)) {
2650 if ($object->lines[$i]->special_code == 3) {
2651 return '';
2652 }
2653 if (empty($hidedetails) || $hidedetails > 1) {
2654 $result .= $object->lines[$i]->qty_shipped;
2655 }
2656 }
2657 return $result;
2658}
2659
2669function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0)
2670{
2671 global $hookmanager;
2672
2673 $reshook = 0;
2674 $result = '';
2675 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2676 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2677 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2678 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) { // @phan-suppress-current-line PhanUndeclaredProperty
2679 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2680 }
2681 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2682 $action = '';
2683 $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2684
2685 if (!empty($hookmanager->resPrint)) {
2686 $result .= $hookmanager->resPrint;
2687 }
2688 }
2689 if (empty($reshook)) {
2690 if ($object->lines[$i]->special_code == 3) {
2691 return '';
2692 }
2693 if (empty($hidedetails) || $hidedetails > 1) {
2694 $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
2695 }
2696 }
2697 return $result;
2698}
2699
2709function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0)
2710{
2711 global $hookmanager;
2712
2713 $reshook = 0;
2714 $result = '';
2715 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2716 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2717 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2718 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2719 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2720 }
2721 $parameters = array(
2722 'i' => $i,
2723 'outputlangs' => $outputlangs,
2724 'hidedetails' => $hidedetails,
2725 'special_code' => $special_code
2726 );
2727 $action = '';
2728 $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2729
2730 if (!empty($hookmanager->resPrint)) {
2731 $result .= $hookmanager->resPrint;
2732 }
2733 }
2734 if (empty($reshook)) {
2735 if (empty($hidedetails) || $hidedetails > 1) {
2736 $result .= $object->lines[$i]->getLabelOfUnit('short', $outputlangs, 1);
2737 }
2738 }
2739 return $result;
2740}
2741
2742
2752function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0)
2753{
2754 global $hookmanager;
2755
2756 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2757
2758 $reshook = 0;
2759 $result = '';
2760 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2761 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2762 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2763 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2764 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2765 }
2766 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2767 $action = '';
2768 $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2769
2770 if (!empty($hookmanager->resPrint)) {
2771 $result .= $hookmanager->resPrint;
2772 }
2773 }
2774 if (empty($reshook)) {
2775 if ($object->lines[$i]->special_code == 3) {
2776 return '';
2777 }
2778 if (empty($hidedetails) || $hidedetails > 1) {
2779 $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs);
2780 }
2781 }
2782 return $result;
2783}
2784
2795function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null)
2796{
2797 if (empty($hookmanager)) {
2798 global $hookmanager;
2799 }
2800
2801 $reshook = 0;
2802 $result = '';
2803 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2804 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2805 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2806 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2807 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2808 }
2809 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2810 $action = '';
2811 $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2812
2813 if (!empty($hookmanager->resPrint)) {
2814 return $hookmanager->resPrint;
2815 }
2816 }
2817 if (empty($reshook)) {
2818 if ($object->lines[$i]->special_code == 3) {
2819 return '';
2820 }
2821 if (empty($hidedetails) || $hidedetails > 1) {
2822 // 2 = situation_percent is non-cumulative (delta of current situation)
2823 // 1 = (old mode): situation_percent is cumulative (state at situation)
2824 $isCumulative = getDolGlobalInt('INVOICE_USE_SITUATION') === 1;
2825 $showDelta = (bool) getDolGlobalInt('SITUATION_DISPLAY_DIFF_ON_PDF');
2826
2827 if ($isCumulative xor $showDelta) {
2828 // Either:
2829 // - old mode and we want to show a total or
2830 // - new mode and we want to show a delta
2831 $result = $object->lines[$i]->situation_percent;
2832 } else {
2833 // Either:
2834 // - old mode but we want to show a delta or
2835 // - new mode but we want to show a total
2836 $prev_progress = 0;
2837 if (method_exists($object->lines[$i], 'get_prev_progress')) {
2838 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2839 }
2840 $result = $isCumulative ?
2841 // old mode: we need to compute the delta (total - sum of previous)
2842 $object->lines[$i]->situation_percent - $prev_progress :
2843 // new mode: we need to compute the total (sum of previous + delta)
2844 $prev_progress + $object->lines[$i]->situation_percent;
2845 }
2846 $result = round($result, 1).'%';
2847 }
2848 }
2849 return $result;
2850}
2851
2861function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0)
2862{
2863 global $hookmanager;
2864
2865 $sign = 1;
2866 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
2867 $sign = -1;
2868 }
2869
2870 $reshook = 0;
2871 $result = '';
2872 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2873 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2874 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2875 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2876 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2877 }
2878 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code, 'sign' => $sign);
2879 $action = '';
2880 $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2881
2882 if (!empty($hookmanager->resPrint)) {
2883 $result .= $hookmanager->resPrint;
2884 }
2885 }
2886 if (empty($reshook)) {
2887 if (!empty($object->lines[$i]) && $object->lines[$i]->special_code == 3) {
2888 $result .= $outputlangs->transnoentities("Option");
2889 } elseif (empty($hidedetails) || $hidedetails > 1) {
2890 $total_ht = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
2891 if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) {
2892 if (method_exists($object->lines[$i], 'getSituationRatio')) {
2893 $total_ht *= $object->lines[$i]->getSituationRatio();
2894 }
2895 }
2896 $result .= price($sign * $total_ht, 0, $outputlangs);
2897 }
2898 }
2899 return $result;
2900}
2901
2911function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0)
2912{
2913 global $hookmanager;
2914
2915 $sign = 1;
2916 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
2917 $sign = -1;
2918 }
2919
2920 $reshook = 0;
2921 $result = '';
2922 //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) )
2923 if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
2924 $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
2925 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2926 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2927 }
2928 $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
2929 $action = '';
2930 $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2931
2932 if (!empty($hookmanager->resPrint)) {
2933 $result .= $hookmanager->resPrint;
2934 }
2935 }
2936 if (empty($reshook)) {
2937 if ($object->lines[$i]->special_code == 3) {
2938 $result .= $outputlangs->transnoentities("Option");
2939 } elseif (empty($hidedetails) || $hidedetails > 1) {
2940 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
2941 if (isset($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) {
2942 $total_ttc *= $object->lines[$i]->getSituationRatio();
2943 }
2944 $result .= price($sign * $total_ttc, 0, $outputlangs);
2945 }
2946 }
2947 return $result;
2948}
2949
2960function canDisplayLinkedObjectInPDF($object, $elementobject)
2961{
2962 $objectSocId = getObjectSocId($object);
2963 $elementSocId = getObjectSocId($elementobject);
2964
2965 if (getDolGlobalBool("PDF_ALLOW_DISPLAY_LINKED_OBJECT_FOR_OTHER_SOC")) {
2966 return true;
2967 }
2968
2969 if (!empty($objectSocId) && !empty($elementSocId) && $objectSocId != $elementSocId) {
2970 return false;
2971 }
2972
2973 return true;
2974}
2975
2984function pdf_getLinkedObjects($object, $outputlangs)
2985{
2986 global $db, $hookmanager;
2987
2988 $linkedobjects = array();
2989
2990 $object->fetchObjectLinked();
2991
2992 foreach ($object->linkedObjects as $objecttype => $objects) {
2993 if ($objecttype == 'facture') {
2994 // For invoice, we don't want to have a reference line on document. Image we are using recurring invoice, we will have a line longer than document width.
2995 } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') {
2996 '@phan-var-force array<Propal|SupplierProposal> $objects';
2998 $outputlangs->load('propal');
2999
3000 foreach ($objects as $elementobject) {
3001 $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
3002 $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
3003 $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
3004 $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
3005 }
3006 } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order' || $objecttype == 'order_supplier') {
3007 $optiontohidelinkedorders = "PDF_HIDE_LINKED_ORDERS_ON_SAME_THIRDPARTY";
3008 if ($objecttype == 'supplier_order' || $objecttype == 'order_supplier') {
3009 $optiontohidelinkedorders = "PDF_HIDE_LINKED_PURCHASE_ORDERS_ON_SAME_THIRDPARTY";
3010 }
3011 '@phan-var-force array<Commande|CommandeFournisseur> $objects';
3012 $outputlangs->load('orders');
3013
3014 if (count($objects) > 1 && count($objects) <= getDolGlobalInt("MAXREFONDOC", 10) && !getDolGlobalString($optiontohidelinkedorders)) {
3015 if (empty($object->context['DolPublicNoteAppendedGetLinkedObjects'])) { // Check if already appended before add to avoid repeat data
3016 $outputList = '';
3017 foreach ($objects as $elementobject) {
3018 if (canDisplayLinkedObjectInPDF($object, $elementobject)) {
3019 $outputList = dol_concatdesc($outputList, $outputlangs->transnoentities($elementobject->ref) . (empty($elementobject->ref_client) ? '' : ' (' . $elementobject->ref_client . ')') . (empty($elementobject->ref_supplier) ? '' : ' (' . $elementobject->ref_supplier . ')') . ' ');
3020 $outputList = dol_concatdesc($outputList, $outputlangs->transnoentities("OrderDate") . ' : ' . dol_print_date($elementobject->date, 'day', '', $outputlangs));
3021 }
3022 }
3023
3024 if (!empty($outputList)) {
3025 $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefOrder").' :');
3026 $object->note_public = dol_concatdesc($object->note_public, $outputList);
3027 }
3028 }
3029 } elseif (count($objects) == 1 && !getDolGlobalString($optiontohidelinkedorders)) {
3030 $elementobject = array_shift($objects);
3031 if (canDisplayLinkedObjectInPDF($object, $elementobject)) {
3032 $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
3033 $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).(!empty($elementobject->ref_client) ? ' ('.$elementobject->ref_client.')' : '').(!empty($elementobject->ref_supplier) ? ' ('.$elementobject->ref_supplier.')' : '');
3034 $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
3035 $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
3036 }
3037 }
3038 } elseif ($objecttype == 'contrat') {
3039 '@phan-var-force Contrat[] $objects';
3040 $outputlangs->load('contracts');
3041 foreach ($objects as $elementobject) {
3042 if (canDisplayLinkedObjectInPDF($object, $elementobject)) {
3043 $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
3044 $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
3045 $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
3046 $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
3047 }
3048 }
3049 } elseif ($objecttype == 'fichinter') {
3050 '@phan-var-force Fichinter[] $objects';
3051 $outputlangs->load('interventions');
3052 foreach ($objects as $elementobject) {
3053 if (canDisplayLinkedObjectInPDF($object, $elementobject)) {
3054 $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef");
3055 $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
3056 $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("InterDate");
3057 $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec, 'day', '', $outputlangs);
3058 }
3059 }
3060 } elseif ($objecttype == 'shipping') {
3061 '@phan-var-force Expedition[] $objects';
3062 $outputlangs->loadLangs(array("orders", "sendings"));
3063
3064 if (count($objects) > 1) {
3065 $order = null;
3066
3067 $refListsTxt = '';
3068 if (empty($object->linkedObjects['commande']) && $object->element != 'commande') {
3069 $refListsTxt .= $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :';
3070 } else {
3071 $refListsTxt .= $outputlangs->transnoentities("RefSending").' :';
3072 }
3073 // We concat this record info into fields xxx_value. title is overwrote.
3074 foreach ($objects as $elementobject) {
3075 if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order
3076 $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
3077 if (!empty($elementobject->linkedObjectsIds['commande'])) {
3078 include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
3079 $order = new Commande($db);
3080 $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande']));
3081 if ($ret < 1) {
3082 $order = null;
3083 }
3084 }
3085 }
3086 $refListsTxt .= (!empty($refListsTxt) ? ' ' : '');
3087 if (! is_object($order)) {
3088 $refListsTxt .= $outputlangs->transnoentities($elementobject->ref);
3089 } else {
3090 $refListsTxt .= $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '');
3091 $refListsTxt .= ' / '.$outputlangs->transnoentities($elementobject->ref);
3092 }
3093 }
3094
3095 if (empty($object->context['DolPublicNoteAppendedGetLinkedObjects']) && !getDolGlobalString("PDF_HIDE_LINKED_OBJECT_IN_PUBLIC_NOTE")) { // Check if already appended before add to avoid repeat data
3096 $object->note_public = dol_concatdesc($object->note_public, $refListsTxt);
3097 }
3098 } elseif (count($objects) == 1) {
3099 $elementobject = array_shift($objects);
3100 $order = null;
3101 // We concat this record info into fields xxx_value. title is overwrote.
3102 if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order
3103 $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
3104 if (!empty($elementobject->linkedObjectsIds['commande'])) {
3105 include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
3106 $order = new Commande($db);
3107 $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande']));
3108 if ($ret < 1) {
3109 $order = null;
3110 }
3111 }
3112 }
3113
3114 if (! is_object($order)) {
3115 $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
3116 if (empty($linkedobjects[$objecttype]['ref_value'])) {
3117 $linkedobjects[$objecttype]['ref_value'] = '';
3118 } else {
3119 $linkedobjects[$objecttype]['ref_value'] .= ' / ';
3120 }
3121 $linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
3122 $linkedobjects[$objecttype]['date_value'] = dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping, 'day', '', $outputlangs);
3123 } else {
3124 $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending");
3125 if (empty($linkedobjects[$objecttype]['ref_value'])) {
3126 $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '');
3127 }
3128 $linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref);
3129 $linkedobjects[$objecttype]['date_value'] = dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping, 'day', '', $outputlangs);
3130 }
3131 }
3132 }
3133 }
3134
3135 $object->context['DolPublicNoteAppendedGetLinkedObjects'] = 1;
3136
3137 // For add external linked objects
3138 if (is_object($hookmanager)) {
3139 $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs' => $outputlangs);
3140 $action = '';
3141 $reshook = $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
3142 if (empty($reshook)) {
3143 $linkedobjects = array_replace($linkedobjects, $hookmanager->resArray); // array_replace is used to preserve keys
3144 } elseif ($reshook > 0) {
3145 // The array must be reinserted even if it is empty because clearing the array could be one of the actions performed by the hook.
3146 $linkedobjects = $hookmanager->resArray;
3147 }
3148 }
3149
3150 return $linkedobjects;
3151}
3152
3160function pdf_getSizeForImage($realpath)
3161{
3162 $maxwidth = getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20);
3163 $maxheight = getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT', 32);
3164
3165 include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
3166 $tmp = dol_getImageSize($realpath);
3167 $width = 0;
3168 $height = 0;
3169 if ($tmp['height']) {
3170 $width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight
3171 if ($width > $maxwidth) { // Pb with maxheight, so i use maxwidth
3172 $width = $maxwidth;
3173 $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']);
3174 } else { // No pb with maxheight
3175 $height = $maxheight;
3176 }
3177 }
3178 return array('width' => $width, 'height' => $height);
3179}
3180
3192function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0, $multicurrency = 0)
3193{
3194 global $hookmanager;
3195
3196 $sign = 1;
3197 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
3198 $sign = -1;
3199 }
3200 if ($object->lines[$i]->special_code == 3) {
3201 // If option
3202 return $outputlangs->transnoentities("Option");
3203 } else {
3204 if (is_object($hookmanager)) {
3205 $special_code = $object->lines[$i]->special_code;
3206 if (!empty($object->lines[$i]->fk_parent_line)) {
3207 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
3208 }
3209
3210 $parameters = array(
3211 'i' => $i,
3212 'outputlangs' => $outputlangs,
3213 'hidedetails' => $hidedetails,
3214 'special_code' => $special_code,
3215 'multicurrency' => $multicurrency
3216 );
3217
3218 $action = '';
3219
3220 if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) { // Note that $action and $object may have been modified by some hooks
3221 if (isset($hookmanager->resArray['linetotalremise'])) {
3222 return (float) $hookmanager->resArray['linetotalremise'];
3223 } else {
3224 return (float) $hookmanager->resPrint; // For backward compatibility
3225 }
3226 }
3227 }
3228
3229 if (empty($hidedetails) || $hidedetails > 1) {
3230 if (empty($multicurrency)) {
3231 return (float) price2num($sign * (($object->lines[$i]->subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->total_ht), 'MT', 1);
3232 } else {
3233 return (float) price2num($sign * (($object->lines[$i]->multicurrency_subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->multicurrency_total_ht), 'MT', 1);
3234 }
3235 }
3236 }
3237 return 0;
3238}
3239
3247function pdfExtractMetadata($file, $field = 'Keywords')
3248{
3249 if (!dol_is_file($file)) {
3250 return "ERROR: FILE NOT FOUND OR NOT VALID";
3251 }
3252
3253 // Get content of PDF file
3254 $content = file_get_contents(dol_osencode($file));
3255
3256 // Use a regex to capture the metadata
3257 if ($content) {
3258 $matches = array();
3259
3260 // Remove non printablecaracters
3261 $content = preg_replace('/[^(\x20-\x7F)]*/', '', $content);
3262 if (preg_match('/\/' . preg_quote($field, '/') . '\s*\‍((.*?)\‍)/', $content, $matches)) {
3263 return trim($matches[1]);
3264 }
3265 return "ERROR: NOT FOUND";
3266 } else {
3267 return "ERROR: FAILED TO READ PDF";
3268 }
3269}
3270
3289 TCPDF $pdf,
3290 CommonDocGenerator $generator,
3291 float $curY,
3293 int $i,
3294 Translate $outputlangs,
3295 int $hideref,
3296 int $hidedesc,
3297 array $bgColor,
3298 bool $isSubtotal = false,
3299 bool $applySubtotalLogic = true
3300) {
3301 $savePage = $pdf->getPage();
3302 $saveX = $pdf->GetX();
3303 $prevAlign = $generator->cols['desc']['content']['align'];
3304
3305 if ($isSubtotal && $applySubtotalLogic && $object->lines[$i]->qty < 0) {
3306 $outputlangs->load("subtotals");
3307 $object->lines[$i]->desc = $outputlangs->trans("SubtotalOf", $object->lines[$i]->desc);
3308 $generator->cols['desc']['content']['align'] = ($prevAlign === 'L') ? 'R' : 'L';
3309 }
3310
3311 $pdf->startTransaction();
3312 $pdf->SetXY($saveX, $curY);
3313 $generator->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
3314 $pageAfter = $pdf->getPage();
3315 $yAfter = $pdf->GetY();
3316 $pdf->rollbackTransaction(true);
3317
3318 $pdf->SetFillColor($bgColor[0], $bgColor[1], $bgColor[2]);
3319 $width = $generator->page_largeur - $generator->marge_droite - $generator->marge_gauche;
3320
3321 $pdf->SetXY($generator->marge_gauche, $curY);
3322 if ($pageAfter === $savePage) {
3323 $pdf->MultiCell($width, max(0, $yAfter - $curY), '', 0, '', true);
3324 } else {
3325 $pdf->MultiCell($width, $pdf->getPageHeight() - $pdf->getBreakMargin() - $curY, '', 0, '', true);
3326
3327 $pdf->setPage($pageAfter);
3328 $pdf->SetXY($generator->marge_gauche, $pdf->getMargins()['top']);
3329 $pdf->MultiCell($width, max(0, $yAfter - $pdf->getMargins()['top']), '', 0, '', true);
3330
3331 $pdf->setPage($savePage);
3332 }
3333
3334 $pdf->SetTextColor(colorIsLight(implode(',', $bgColor)));
3335 $pdf->SetXY($saveX, $curY);
3336 $generator->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
3337 $generator->setAfterColsLinePositionsData('desc', $pdf->GetY(), $pdf->getPage());
3338
3339 $generator->cols['desc']['content']['align'] = $prevAlign;
3340}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
pdfWriteBlockedLogSignature(&$pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy)
Add some information from the blockedlog module.
pdfCertifMentionblockedLog(&$pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
Add legal mention.
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage categories.
Class to manage customers orders.
Parent class for documents (PDF, ODT, ...) generators.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)
Used for to set afterColsLinePositions var in a pdf draw line loop.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to manage contact/addresses.
Class to manage absolute discounts.
Class to manage warehouses.
static getIBANLabel(Account $account)
Returns the name of the Iban label.
File of class to manage predefined price products or services by customer.
Class to manage predefined suppliers products.
Class to manage products or services.
Manage record for batch number management.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
getState($id, $withcode='0', $dbtouse=null, $withregion=0, $outputlangs=null, $entconv=1)
Return state translated from an id.
getFormeJuridiqueLabel($code)
Return the name translated of juridical status.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_is_file($pathoffile)
Return if path is a file.
dol_print_reduction($reduction, $langs)
Returns formatted reduction.
dol_getDefaultFormat($outputlangs=null)
Try to guess default paper format according to language into $langs.
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_now($mode='gmt')
Return date for now.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
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_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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 '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
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_textishtml($msg, $option=0)
Return if a text is a html content.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
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.
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)
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp)
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:3160
pdf_watermark($pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:1155
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition pdf.lib.php:2861
pdfCertifMention($pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
Add legal certificate mention.
Definition pdf.lib.php:1219
pdf_getlinedesc($object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
Return line description translated in outputlangs and encoded into htmlentities and with
Definition pdf.lib.php:1903
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:3192
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1808
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:294
pdfExtractMetadata($file, $field='Keywords')
Function to extract metadata from a PDF file by doing a binary parsing of the PDF file.
Definition pdf.lib.php:3247
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
Definition pdf.lib.php:1239
pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails=0)
Return line quantity shipped.
Definition pdf.lib.php:2629
pdf_getlinenum($object, $i, $outputlangs, $hidedetails=0)
Return line num.
Definition pdf.lib.php:2304
pdf_getEncryption($pathoffile)
Return if pdf file is protected/encrypted.
Definition pdf.lib.php:240
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0, $align='J')
Output line description into PDF.
Definition pdf.lib.php:1846
pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price including tax.
Definition pdf.lib.php:2507
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:317
pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails=0)
Return line ref_supplier.
Definition pdf.lib.php:2370
pdfWriteVATArray($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis, $object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl)
Add some information from the blockedlog module.
Definition pdf.lib.php:810
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition pdf.lib.php:2911
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2464
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
Definition pdf.lib.php:2795
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:2402
pdf_admin_prepare_head()
Return array head with list of tabs to view object information.
Definition pdf.lib.php:49
canDisplayLinkedObjectInPDF($object, $elementobject)
Check if a linked object can be displayed based on third-party privacy rules.
Definition pdf.lib.php:2960
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:747
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:1421
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:3288
pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails=0)
Return line keep to ship quantity.
Definition pdf.lib.php:2669
pdf_getlineref($object, $i, $outputlangs, $hidedetails=0)
Return line product ref.
Definition pdf.lib.php:2337
pdfWriteAdditionnalTitle($pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy)
Add some information from the blockedlog module.
Definition pdf.lib.php:785
pdfWriteAlreadyPaid($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis, $object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl, $deja_regle, $creditnoteamount, $depositsamount, $resteapayer, $resteapayer_origin)
Add some information from the blockedlog module.
Definition pdf.lib.php:1050
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:2709
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2752
pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails=0)
Return line quantity asked.
Definition pdf.lib.php:2589
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2549
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:1135
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