dolibarr 21.0.0-alpha
pdf_sponge.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5 * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
11 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
13 * Copyright (C) 2022-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
14 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
15 * Copyright (C) 2024 Nick Fragoulis
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 * or see https://www.gnu.org/
30 */
31
38require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
39require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
43
44
49{
53 public $db;
54
58 public $name;
59
63 public $description;
64
68 public $update_main_doc_field;
69
73 public $type;
74
79 public $version = 'dolibarr';
80
84 public $heightforinfotot;
85
89 public $heightforfreetext;
90
94 public $heightforfooter;
95
99 public $tab_top;
100
104 public $tab_top_newpage;
105
109 public $situationinvoice;
110
111
115 public $cols;
116
120 public $categoryOfOperation = -1; // unknown by default
121
122
128 public function __construct($db)
129 {
130 global $langs, $mysoc;
131
132 // Translations
133 $langs->loadLangs(array("main", "bills"));
134
135 $this->db = $db;
136 $this->name = "sponge";
137 $this->description = $langs->trans('PDFSpongeDescription');
138 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
139
140 // Dimension page
141 $this->type = 'pdf';
142 $formatarray = pdf_getFormat();
143 $this->page_largeur = $formatarray['width'];
144 $this->page_hauteur = $formatarray['height'];
145 $this->format = array($this->page_largeur, $this->page_hauteur);
146 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
147 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
148 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
149 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
150 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
151 $this->option_logo = 1; // Display logo
152 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
153 $this->option_modereg = 1; // Display payment mode
154 $this->option_condreg = 1; // Display payment terms
155 $this->option_multilang = 1; // Available in several languages
156 $this->option_escompte = 1; // Displays if there has been a discount
157 $this->option_credit_note = 1; // Support credit notes
158 $this->option_freetext = 1; // Support add of a personalised text
159 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
160 $this->watermark = '';
161
162 if ($mysoc === null) {
163 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
164 return;
165 }
166
167 // Get source company
168 $this->emetteur = $mysoc;
169 if (empty($this->emetteur->country_code)) {
170 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
171 }
172
173 // Define position of columns
174 $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff
175
176
177 $this->tabTitleHeight = 5; // default height
178
179 // Use new system for position of columns, view $this->defineColumnField()
180
181 $this->tva = array();
182 $this->tva_array = array();
183 $this->localtax1 = array();
184 $this->localtax2 = array();
185 $this->atleastoneratenotnull = 0;
186 $this->atleastonediscount = 0;
187 $this->situationinvoice = false;
188 }
189
190
191 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
203 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
204 {
205 // phpcs:enable
206 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
207
208 dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
209
210 if (!is_object($outputlangs)) {
211 $outputlangs = $langs;
212 }
213 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
214 if (getDolGlobalString('MAIN_USE_FPDF')) {
215 $outputlangs->charset_output = 'ISO-8859-1';
216 }
217
218 // Load translation files required by the page
219 $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "compta"));
220
221 global $outputlangsbis;
222 $outputlangsbis = null;
223 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
224 $outputlangsbis = new Translate('', $conf);
225 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
226 $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies", "compta"));
227 }
228
229 // Show Draft Watermark
230 if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
231 $this->watermark = getDolGlobalString('FACTURE_DRAFT_WATERMARK');
232 }
233
234 $nblines = count($object->lines);
235
236 $hidetop = 0;
237 if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
238 $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
239 }
240
241 // Loop on each lines to detect if there is at least one image to show
242 $realpatharray = array();
243 $this->atleastonephoto = false;
244 if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) {
245 $objphoto = new Product($this->db);
246
247 for ($i = 0; $i < $nblines; $i++) {
248 if (empty($object->lines[$i]->fk_product)) {
249 continue;
250 }
251
252 $objphoto->fetch($object->lines[$i]->fk_product);
253 //var_dump($objphoto->ref);exit;
254 $pdir = array();
255 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
256 $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
257 $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
258 } else {
259 $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
260 $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
261 }
262
263 $arephoto = false;
264 foreach ($pdir as $midir) {
265 if (!$arephoto) {
266 if ($conf->entity != $objphoto->entity) {
267 $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
268 } else {
269 $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
270 }
271
272 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
273 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
274 if ($obj['photo_vignette']) {
275 $filename = $obj['photo_vignette'];
276 } else {
277 $filename = $obj['photo'];
278 }
279 } else {
280 $filename = $obj['photo'];
281 }
282
283 $realpath = $dir.$filename;
284 $arephoto = true;
285 $this->atleastonephoto = true;
286 }
287 }
288 }
289
290 if ($realpath && $arephoto) {
291 $realpatharray[$i] = $realpath;
292 }
293 }
294 }
295
296 //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
297
298 if ($conf->facture->multidir_output[$conf->entity]) {
299 $object->fetch_thirdparty();
300
301 $deja_regle = $object->getSommePaiement((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
302 $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
303 $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
304
305 // Definition of $dir and $file
306 if ($object->specimen) {
307 $dir = $conf->facture->multidir_output[$conf->entity];
308 $file = $dir."/SPECIMEN.pdf";
309 } else {
310 $objectref = dol_sanitizeFileName($object->ref);
311 $dir = $conf->facture->multidir_output[$object->entity]."/".$objectref;
312 $file = $dir."/".$objectref.".pdf";
313 }
314 if (!file_exists($dir)) {
315 if (dol_mkdir($dir) < 0) {
316 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
317 return 0;
318 }
319 }
320
321 if (file_exists($dir)) {
322 // Add pdfgeneration hook
323 if (!is_object($hookmanager)) {
324 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
325 $hookmanager = new HookManager($this->db);
326 }
327 $hookmanager->initHooks(array('pdfgeneration'));
328 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
329 global $action;
330 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
331
332 // Set nblines with the new facture lines content after hook
333 $nblines = count($object->lines);
334 $nbpayments = count($object->getListOfPayments());
335
336 // Create pdf instance
337 $pdf = pdf_getInstance($this->format);
338 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
339 $pdf->SetAutoPageBreak(1, 0);
340
341 $this->heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
342 $this->heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
343 $this->heightforfooter = $this->marge_basse + (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
344
345 $heightforqrinvoice = $heightforqrinvoice_firstpage = 0;
346 if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
347 if ($this->getHeightForQRInvoice(1, $object, $langs) > 0) {
348 // Shrink infotot to a base 30
349 $this->heightforinfotot = 30 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
350 }
351 }
352
353 if (class_exists('TCPDF')) {
354 $pdf->setPrintHeader(false);
355 $pdf->setPrintFooter(false);
356 }
357 $pdf->SetFont(pdf_getPDFFont($outputlangs));
358
359 // Set path to the background PDF File
360 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
361 $logodir = $conf->mycompany->dir_output;
362 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
363 $logodir = $conf->mycompany->multidir_output[$object->entity];
364 }
365 $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
366 $tplidx = $pdf->importPage(1);
367 }
368
369 $pdf->Open();
370 $pagenb = 0;
371 $pdf->SetDrawColor(128, 128, 128);
372
373 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
374 $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
375 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
376 $pdf->SetAuthor($mysoc->name.($user->id > 0 ? ' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) : ''));
377 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
378 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
379 $pdf->SetCompression(false);
380 }
381
382 // Set certificate
383 $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
384 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ? '' : $user->conf->CERTIFICATE_CRT_PRIVATE;
385 // If user has no certificate, we try to take the company one
386 if (!$cert) {
387 $cert = getDolGlobalString('CERTIFICATE_CRT');
388 }
389 if (!$certprivate) {
390 $certprivate = getDolGlobalString('CERTIFICATE_CRT_PRIVATE');
391 }
392 // If a certificate is found
393 if ($cert) {
394 $info = array(
395 'Name' => $this->emetteur->name,
396 'Location' => getCountry($this->emetteur->country_code, ''),
397 'Reason' => 'INVOICE',
398 'ContactInfo' => $this->emetteur->email
399 );
400 $pdf->setSignature($cert, $certprivate, $this->emetteur->name, '', 2, $info);
401 }
402
403 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
404 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
405
406 // Set $this->atleastonediscount if you have at least one discount
407 // and determine category of operation
408 $categoryOfOperation = 0;
409 $nbProduct = 0;
410 $nbService = 0;
411 for ($i = 0; $i < $nblines; $i++) {
412 if ($object->lines[$i]->remise_percent) {
413 $this->atleastonediscount++;
414 }
415
416 // determine category of operation
417 if ($categoryOfOperation < 2) {
418 $lineProductType = $object->lines[$i]->product_type;
419 if ($lineProductType == Product::TYPE_PRODUCT) {
420 $nbProduct++;
421 } elseif ($lineProductType == Product::TYPE_SERVICE) {
422 $nbService++;
423 }
424 if ($nbProduct > 0 && $nbService > 0) {
425 // mixed products and services
426 $categoryOfOperation = 2;
427 }
428 }
429 }
430 // determine category of operation
431 if ($categoryOfOperation <= 0) {
432 // only services
433 if ($nbProduct == 0 && $nbService > 0) {
434 $categoryOfOperation = 1;
435 }
436 }
437 $this->categoryOfOperation = $categoryOfOperation;
438
439 // Situation invoice handling
440 if ($object->situation_cycle_ref) {
441 $this->situationinvoice = true;
442 }
443
444 // New page
445 $pdf->AddPage();
446 if (!empty($tplidx)) {
447 $pdf->useTemplate($tplidx);
448 }
449 $pagenb++;
450
451 // Output header (logo, ref and address blocks). This is first call for first page.
452 $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
453 $top_shift = $pagehead['top_shift'];
454 $shipp_shift = $pagehead['shipp_shift'];
455 $pdf->SetFont('', '', $default_font_size - 1);
456 $pdf->MultiCell(0, 3, ''); // Set interline to 3
457 $pdf->SetTextColor(0, 0, 0);
458
459 // $pdf->GetY() here can't be used. It is bottom of the second address box but first one may be higher
460
461 // $this->tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
462 $this->tab_top = 90 + $top_shift + $shipp_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
463 $this->tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
464
465 // You can add more thing under header here, if you increase $extra_under_address_shift too.
466 $extra_under_address_shift = 0;
467 $qrcodestring = '';
468 if (getDolGlobalString('INVOICE_ADD_ZATCA_QR_CODE')) {
469 $qrcodestring = $object->buildZATCAQRString();
470 } elseif (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == '1' && (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')) {
471 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
472 $qrcodestring = $object->buildSwitzerlandQRString();
473 }
474 } elseif (getDolGlobalString('INVOICE_ADD_EPC_QR_CODE') == '1' && (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')) {
475 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
476 $qrcodestring = $object->buildEPCQrCodeString();
477 }
478 }
479
480 if ($qrcodestring) {
481 $qrcodecolor = array('25', '25', '25');
482 // set style for QR-code
483 $styleQr = array(
484 'border' => false,
485 'padding' => 0,
486 'fgcolor' => $qrcodecolor,
487 'bgcolor' => false, //array(255,255,255)
488 'module_width' => 1, // width of a single module in points
489 'module_height' => 1 // height of a single module in points
490 );
491 $pdf->write2DBarcode($qrcodestring, 'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr, 'N');
492
493 if (getDolGlobalString('INVOICE_ADD_EPC_QR_CODE') == '1' && (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')) {
494 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
495 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
496 $pdf->SetFont('', '', $default_font_size - 4);
497 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv("INVOICE_ADD_EPC_QR_CODEPay"), 0, 'L', 0);
498 }
499 }
500
501 $extra_under_address_shift += 25;
502 }
503
504 // Call hook printUnderHeaderPDFline
505 $parameters = array(
506 'object' => $object,
507 'i' => $i,
508 'pdf' => &$pdf,
509 'outputlangs' => $outputlangs,
510 'hidedetails' => $hidedetails
511 );
512 $reshook = $hookmanager->executeHooks('printUnderHeaderPDFline', $parameters, $this); // Note that $object may have been modified by hook
513 if (!empty($hookmanager->resArray['extra_under_address_shift'])) {
514 $extra_under_address_shift += $hookmanager->resArray['extra_under_address_shift'];
515 }
516
517 $this->tab_top += $extra_under_address_shift;
518 $this->tab_top_newpage += 0;
519
520
521 // Define height of table for lines (for first page)
522 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->getHeightForQRInvoice(1, $object, $langs);
523
524 $nexY = $this->tab_top - 1;
525
526 // Incoterm
527 $height_incoterms = 0;
528 if (isModEnabled('incoterm')) {
529 $desc_incoterms = $object->getIncotermsForPDF();
530 if ($desc_incoterms) {
531 $this->tab_top -= 2;
532
533 $pdf->SetFont('', '', $default_font_size - 1);
534 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
535 $nexY = max($pdf->GetY(), $nexY);
536 $height_incoterms = $nexY - $this->tab_top;
537
538 // Rect takes a length in 3rd parameter
539 $pdf->SetDrawColor(192, 192, 192);
540 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D');
541
542 $this->tab_top = $nexY + 6;
543 $height_incoterms += 4;
544 }
545 }
546
547 // Displays notes. Here we are still on code executed only for the first page.
548 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
549 if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
550 // Get first sale rep
551 if (is_object($object->thirdparty)) {
552 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
553 $salerepobj = new User($this->db);
554 $salerepobj->fetch($salereparray[0]['id']);
555 if (!empty($salerepobj->signature)) {
556 $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
557 }
558 }
559 }
560
561 // Extrafields in note
562 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
563 if (!empty($extranote)) {
564 $notetoshow = dol_concatdesc($notetoshow, $extranote);
565 }
566
567 $pagenb = $pdf->getPage();
568 if ($notetoshow) {
569 $this->tab_top -= 2;
570
571 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
572 $pageposbeforenote = $pagenb;
573
574 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
575 complete_substitutions_array($substitutionarray, $outputlangs, $object);
576 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
577 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
578
579 $pdf->startTransaction();
580
581 $pdf->SetFont('', '', $default_font_size - 1);
582 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
583 // Description
584 $pageposafternote = $pdf->getPage();
585 $posyafter = $pdf->GetY();
586
587 if ($pageposafternote > $pageposbeforenote) {
588 $pdf->rollbackTransaction(true);
589
590 // prepare pages to receive notes
591 while ($pagenb < $pageposafternote) {
592 $pdf->AddPage();
593 $pagenb++;
594 if (!empty($tplidx)) {
595 $pdf->useTemplate($tplidx);
596 }
597 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
598 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
599 }
600 $pdf->setTopMargin($this->tab_top_newpage);
601 // The only function to edit the bottom margin of current page to set it.
602 $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
603 }
604
605 // back to start
606 $pdf->setPage($pageposbeforenote);
607 $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
608 $pdf->SetFont('', '', $default_font_size - 1);
609 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
610 $pageposafternote = $pdf->getPage();
611
612 $posyafter = $pdf->GetY();
613
614 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) { // There is no space left for total+free text
615 $pdf->AddPage('', '', true);
616 $pagenb++;
617 $pageposafternote++;
618 $pdf->setPage($pageposafternote);
619 $pdf->setTopMargin($this->tab_top_newpage);
620 // The only function to edit the bottom margin of current page to set it.
621 $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
622 //$posyafter = $this->tab_top_newpage;
623 }
624
625
626 // apply note frame to previous pages
627 $i = $pageposbeforenote;
628 while ($i < $pageposafternote) {
629 $pdf->setPage($i);
630
631
632 $pdf->SetDrawColor(128, 128, 128);
633 // Draw note frame
634 if ($i > $pageposbeforenote) {
635 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
636 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
637 } else {
638 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
639 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
640 }
641
642 // Add footer
643 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
644 $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($i, $object, $outputlangs));
645
646 $i++;
647 }
648
649 // apply note frame to last page
650 $pdf->setPage($pageposafternote);
651 if (!empty($tplidx)) {
652 $pdf->useTemplate($tplidx);
653 }
654 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
655 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
656 }
657 $height_note = $posyafter - $this->tab_top_newpage;
658 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
659 } else {
660 // No pagebreak
661 $pdf->commitTransaction();
662 $posyafter = $pdf->GetY();
663 $height_note = $posyafter - $this->tab_top;
664 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
665
666
667 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
668 // not enough space, need to add page
669 $pdf->AddPage('', '', true);
670 $pagenb++;
671 $pageposafternote++;
672 $pdf->setPage($pageposafternote);
673 if (!empty($tplidx)) {
674 $pdf->useTemplate($tplidx);
675 }
676 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
677 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
678 }
679
680 $posyafter = $this->tab_top_newpage;
681 }
682 }
683
684 $tab_height -= $height_note;
685 $this->tab_top = $posyafter + 6;
686 } else {
687 $height_note = 0;
688 }
689
690 // Use new auto column system
691 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
692
693 // Table simulation to know the height of the title line (this set this->tableTitleHeight)
694 $pdf->startTransaction();
695 $this->pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
696 $pdf->rollbackTransaction(true);
697
698 $nexY = $this->tab_top + $this->tabTitleHeight;
699
700 // Loop on each lines
701 $pageposbeforeprintlines = $pdf->getPage();
702 $pagenb = $pageposbeforeprintlines;
703 for ($i = 0; $i < $nblines; $i++) {
704 $curY = $nexY;
705 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
706 $pdf->SetTextColor(0, 0, 0);
707
708 // Define size of image if we need it
709 $imglinesize = array();
710 if (!empty($realpatharray[$i])) {
711 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
712 }
713
714 $pdf->setTopMargin($this->tab_top_newpage);
715 $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs);
716 $pdf->setPageOrientation('', 1, $page_bottom_margin);
717 $pageposbefore = $pdf->getPage();
718
719 $showpricebeforepagebreak = 1;
720 $posYAfterImage = 0;
721 $posYAfterDescription = 0;
722
723 if ($this->getColumnStatus('photo')) {
724 // We start with Photo of product line
725 if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - $page_bottom_margin)) { // If photo too high, we moved completely on new page
726 $pdf->AddPage('', '', true);
727 if (!empty($tplidx)) {
728 $pdf->useTemplate($tplidx);
729 }
730 $pdf->setPage($pageposbefore + 1);
731
732 $curY = $this->tab_top_newpage;
733
734 // Allows data in the first page if description is long enough to break in multiples pages
735 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
736 $showpricebeforepagebreak = 1;
737 } else {
738 $showpricebeforepagebreak = 0;
739 }
740 }
741
742 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
743 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
744 // $pdf->Image does not increase value return by getY, so we save it manually
745 $posYAfterImage = $curY + $imglinesize['height'];
746 }
747 }
748
749 // Description of product line
750 if ($this->getColumnStatus('desc')) {
751 $pdf->startTransaction();
752
753 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
754 $pageposafter = $pdf->getPage();
755
756 if ($pageposafter > $pageposbefore) { // There is a pagebreak
757 $pdf->rollbackTransaction(true);
758 $pageposafter = $pageposbefore;
759 $pdf->setPageOrientation('', 1, $this->heightforfooter); // The only function to edit the bottom margin of current page to set it.
760
761 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
762
763 $pageposafter = $pdf->getPage();
764 $posyafter = $pdf->GetY();
765 //var_dump($posyafter); var_dump(($this->page_hauteur - ($this->heightforfooter+$this->heightforfreetext+$this->heightforinfotot))); exit;
766 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) { // There is no space left for total+free text
767 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
768 $pdf->AddPage('', '', true);
769 if (!empty($tplidx)) {
770 $pdf->useTemplate($tplidx);
771 }
772 $pdf->setPage($pageposafter + 1);
773 }
774 } else {
775 // We found a page break
776 // Allows data in the first page if description is long enough to break in multiples pages
777 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
778 $showpricebeforepagebreak = 1;
779 } else {
780 $showpricebeforepagebreak = 0;
781 }
782 }
783 } else { // No pagebreak
784 $pdf->commitTransaction();
785 }
786 $posYAfterDescription = $pdf->GetY();
787 }
788
789 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
790
791 $pageposafter = $pdf->getPage();
792 $pdf->setPage($pageposbefore);
793 $pdf->setTopMargin($this->marge_haute);
794 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
795
796 // We suppose that a too long description or photo were moved completely on next page
797 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
798 $pdf->setPage($pageposafter);
799 $curY = $this->tab_top_newpage;
800 }
801
802 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
803
804 // # of line
805 if ($this->getColumnStatus('position')) {
806 $this->printStdColumnContent($pdf, $curY, 'position', (string) ($i + 1));
807 }
808
809 // VAT Rate
810 if ($this->getColumnStatus('vat')) {
811 $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
812 $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
813 $nexY = max($pdf->GetY(), $nexY);
814 }
815
816 // Unit price before discount
817 if ($this->getColumnStatus('subprice')) {
818 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
819 $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
820 $nexY = max($pdf->GetY(), $nexY);
821 }
822
823 // Quantity
824 // Enough for 6 chars
825 if ($this->getColumnStatus('qty')) {
826 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
827 $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
828 $nexY = max($pdf->GetY(), $nexY);
829 }
830
831 // Situation progress
832 if ($this->getColumnStatus('progress')) {
833 $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
834 $this->printStdColumnContent($pdf, $curY, 'progress', $progress);
835 $nexY = max($pdf->GetY(), $nexY);
836 }
837
838 // Unit
839 if ($this->getColumnStatus('unit')) {
840 $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails);
841 $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
842 $nexY = max($pdf->GetY(), $nexY);
843 }
844
845 // Discount on line
846 if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
847 $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
848 $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
849 $nexY = max($pdf->GetY(), $nexY);
850 }
851
852 // Total excl tax line (HT)
853 if ($this->getColumnStatus('totalexcltax')) {
854 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
855 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
856 $nexY = max($pdf->GetY(), $nexY);
857 }
858
859 // Total with tax line (TTC)
860 if ($this->getColumnStatus('totalincltax')) {
861 $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
862 $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
863 $nexY = max($pdf->GetY(), $nexY);
864 }
865
866 // Extrafields
867 if (!empty($object->lines[$i]->array_options)) {
868 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
869 if ($this->getColumnStatus($extrafieldColKey)) {
870 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
871 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
872 $nexY = max($pdf->GetY(), $nexY);
873 }
874 }
875 }
876
877
878 $parameters = array(
879 'object' => $object,
880 'i' => $i,
881 'pdf' => & $pdf,
882 'curY' => & $curY,
883 'nexY' => & $nexY,
884 'outputlangs' => $outputlangs,
885 'hidedetails' => $hidedetails
886 );
887 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
888
889
890 $sign = 1;
891 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
892 $sign = -1;
893 }
894 // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
895 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
896 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation
897 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
898 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
899 } else {
900 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
901 }
902 } else {
903 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
904 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
905 } else {
906 $tvaligne = $sign * $object->lines[$i]->total_tva;
907 }
908 }
909
910 $localtax1ligne = $object->lines[$i]->total_localtax1;
911 $localtax2ligne = $object->lines[$i]->total_localtax2;
912 $localtax1_rate = $object->lines[$i]->localtax1_tx;
913 $localtax2_rate = $object->lines[$i]->localtax2_tx;
914 $localtax1_type = $object->lines[$i]->localtax1_type;
915 $localtax2_type = $object->lines[$i]->localtax2_type;
916
917 // TODO remise_percent is an obsolete field for object parent
918 /*if ($object->remise_percent) {
919 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
920 }
921 if ($object->remise_percent) {
922 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
923 }
924 if ($object->remise_percent) {
925 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
926 }*/
927
928 $vatrate = (string) $object->lines[$i]->tva_tx;
929
930 // Retrieve type from database for backward compatibility with old records
931 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
932 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
933 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
934 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
935 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
936 }
937
938 // retrieve global local tax
939 if ($localtax1_type && $localtax1ligne != 0) {
940 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
941 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
942 } else {
943 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
944 }
945 }
946 if ($localtax2_type && $localtax2ligne != 0) {
947 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
948 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
949 } else {
950 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
951 }
952 }
953
954 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
955 $vatrate .= '*';
956 }
957
958 // Fill $this->tva and $this->tva_array
959 if (!isset($this->tva[$vatrate])) {
960 $this->tva[$vatrate] = 0;
961 }
962 $this->tva[$vatrate] += $tvaligne; // ->tva is abandoned, we use now ->tva_array that is more complete
963 $vatcode = $object->lines[$i]->vat_src_code;
964 if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
965 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
966 }
967 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
968
969 $nexY = max($nexY, $posYAfterImage);
970
971 // Add line
972 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
973 $pdf->setPage($pageposafter);
974 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
975 //$pdf->SetDrawColor(190,190,200);
976 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
977 $pdf->SetLineStyle(array('dash' => 0));
978 }
979
980 // Detect if some page were added automatically and output _tableau for past pages
981 while ($pagenb < $pageposafter) {
982 $pdf->setPage($pagenb);
983 $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs);
984 if ($pagenb == $pageposbeforeprintlines) {
985 $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
986 } else {
987 $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
988 }
989 $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs));
990 $pagenb++;
991 $pdf->setPage($pagenb);
992 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
993 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
994 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
995 }
996 if (!empty($tplidx)) {
997 $pdf->useTemplate($tplidx);
998 }
999 }
1000
1001 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
1002 $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs);
1003 if ($pagenb == $pageposafter) {
1004 $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
1005 } else {
1006 $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
1007 }
1008 $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs));
1009 // New page
1010 $pdf->AddPage();
1011 if (!empty($tplidx)) {
1012 $pdf->useTemplate($tplidx);
1013 }
1014 $pagenb++;
1015 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
1016 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1017 }
1018 }
1019 }
1020
1021 // Show square
1022 $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs);
1023 if ($pagenb == $pageposbeforeprintlines) {
1024 $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
1025 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1026 } else {
1027 $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
1028 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1029 }
1030
1031 // Display infos area
1032 $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
1033
1034 // Display total zone
1035 $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1036
1037 // Display payment area
1038 $listofpayments = $object->getListOfPayments('', 0, 1);
1039 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
1040 $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
1041 }
1042
1043 // Pagefoot
1044 $this->_pagefoot($pdf, $object, $outputlangs, 0, $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs));
1045 if (method_exists($pdf, 'AliasNbPages')) {
1046 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
1047 }
1048
1049 if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
1050 $this->addBottomQRInvoice($pdf, $object, $outputlangs);
1051 }
1052 $pdf->Close();
1053
1054 $pdf->Output($file, 'F');
1055
1056 // Add pdfgeneration hook
1057 $hookmanager->initHooks(array('pdfgeneration'));
1058 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
1059 global $action;
1060 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1061 if ($reshook < 0) {
1062 $this->error = $hookmanager->error;
1063 $this->errors = $hookmanager->errors;
1064 }
1065
1066 dolChmod($file);
1067
1068 $this->result = array('fullpath' => $file);
1069
1070 return 1; // No error
1071 } else {
1072 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
1073 return 0;
1074 }
1075 } else {
1076 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
1077 return 0;
1078 }
1079 }
1080
1081
1091 public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
1092 {
1093 $sign = 1;
1094 if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
1095 $sign = -1;
1096 }
1097
1098 $tab3_posx = 120;
1099 $tab3_top = $posy + 8;
1100 $tab3_width = 80;
1101 $tab3_height = 4;
1102 if ($this->page_largeur < 210) { // To work with US executive format
1103 $tab3_posx -= 15;
1104 }
1105
1106 $default_font_size = pdf_getPDFFontSize($outputlangs);
1107
1108 $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
1109 if ($object->type == 2) {
1110 $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
1111 }
1112
1113 $pdf->SetFont('', '', $default_font_size - 3);
1114 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1115 $pdf->MultiCell(60, 3, $title, 0, 'L', 0);
1116
1117 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1118
1119 $pdf->SetFont('', '', $default_font_size - 4);
1120 $pdf->SetXY($tab3_posx, $tab3_top);
1121 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
1122 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1123 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
1124 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1125 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
1126 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1127 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
1128
1129 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1130
1131 $y = 0;
1132
1133 $pdf->SetFont('', '', $default_font_size - 4);
1134
1135
1136 // Loop on each discount available (deposits and credit notes and excess of payment included)
1137 $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
1138 $sql .= " re.description, re.fk_facture_source,";
1139 $sql .= " f.type, f.datef";
1140 $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
1141 $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
1142 $resql = $this->db->query($sql);
1143 if ($resql) {
1144 $num = $this->db->num_rows($resql);
1145 $i = 0;
1146 $invoice = new Facture($this->db);
1147 while ($i < $num) {
1148 $y += 3;
1149 $obj = $this->db->fetch_object($resql);
1150
1151 if ($obj->type == 2) {
1152 $text = $outputlangs->transnoentities("CreditNote");
1153 } elseif ($obj->type == 3) {
1154 $text = $outputlangs->transnoentities("Deposit");
1155 } elseif ($obj->type == 0) {
1156 $text = $outputlangs->transnoentities("ExcessReceived");
1157 } else {
1158 $text = $outputlangs->transnoentities("UnknownType");
1159 }
1160
1161 $invoice->fetch($obj->fk_facture_source);
1162
1163 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1164 $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
1165 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1166 $pdf->MultiCell(20, 3, price((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
1167 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1168 $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
1169 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1170 $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
1171
1172 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1173
1174 $i++;
1175 }
1176 } else {
1177 $this->error = $this->db->lasterror();
1178 return -1;
1179 }
1180
1181 // Loop on each payment
1182 // TODO Call getListOfPayments instead of hard coded sql
1183 $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1184 $sql .= " cp.code";
1185 $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
1186 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
1187 $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1188 //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
1189 $sql .= " ORDER BY p.datep";
1190
1191 $resql = $this->db->query($sql);
1192 if ($resql) {
1193 $num = $this->db->num_rows($resql);
1194 $i = 0;
1195 $y += 3;
1196 $maxY = $y;
1197 while ($i < $num) {
1198 $row = $this->db->fetch_object($resql);
1199 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1200 $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
1201 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1202 $pdf->MultiCell(20, 3, price($sign * ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
1203 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1204 $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
1205
1206 $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
1207 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1208 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1209 $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
1210 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1211 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1212 $y += 3;
1213 $i++;
1214 }
1215
1216 return $tab3_top + $y + 3;
1217 } else {
1218 $this->error = $this->db->lasterror();
1219 return -1;
1220 }
1221 }
1222
1223
1234 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1235 {
1236 global $conf, $mysoc, $hookmanager;
1237
1238 $default_font_size = pdf_getPDFFontSize($outputlangs);
1239
1240 $pdf->SetFont('', '', $default_font_size - 1);
1241
1242 // If France, show VAT mention if not applicable
1243 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
1244 $pdf->SetFont('', '', $default_font_size - 2);
1245 $pdf->SetXY($this->marge_gauche, $posy);
1246 if ($mysoc->forme_juridique_code == 92) {
1247 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0);
1248 } else {
1249 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
1250 }
1251
1252 $posy = $pdf->GetY() + 4;
1253 }
1254
1255 $posxval = 52; // Position of values of properties shown on left side
1256 $posxend = 110; // End of x for text on left side
1257 if ($this->page_largeur < 210) { // To work with US executive format
1258 $posxend -= 10;
1259 }
1260
1261 // Show payments conditions
1262 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1263 $pdf->SetFont('', '', $default_font_size - 2);
1264 $pdf->SetXY($this->marge_gauche, $posy);
1265 $titre = $outputlangs->transnoentities("PaymentConditions").':';
1266 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0, 'L');
1267
1268 $pdf->SetFont('', '', $default_font_size - 2);
1269 $pdf->SetXY($posxval, $posy);
1270 $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
1271 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1272 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0, 'L');
1273
1274 $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
1275 }
1276
1277 // Show category of operations
1278 if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1279 $pdf->SetFont('', '', $default_font_size - 2);
1280 $pdf->SetXY($this->marge_gauche, $posy);
1281 $categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : ';
1282 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L');
1283
1284 $pdf->SetFont('', '', $default_font_size - 2);
1285 $pdf->SetXY($posxval, $posy);
1286 $categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
1287 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L');
1288
1289 $posy = $pdf->GetY() + 3; // for 2 lines
1290 }
1291
1292 if ($object->type != 2) {
1293 // Check a payment mode is defined
1294 if (empty($object->mode_reglement_code)
1295 && !getDolGlobalInt('FACTURE_CHQ_NUMBER')
1296 && !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1297 $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
1298 } elseif (($object->mode_reglement_code == 'CHQ' && !getDolGlobalInt('FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
1299 || ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1300 // Avoid having any valid PDF with setup that is not complete
1301 $outputlangs->load("errors");
1302
1303 $pdf->SetXY($this->marge_gauche, $posy);
1304 $pdf->SetTextColor(200, 0, 0);
1305 $pdf->SetFont('', '', $default_font_size - 2);
1306 $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1307 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0, 'L', 0);
1308 $pdf->SetTextColor(0, 0, 0);
1309
1310 $posy = $pdf->GetY() + 1;
1311 }
1312
1313 // Show payment mode
1314 if (!empty($object->mode_reglement_code)
1315 && $object->mode_reglement_code != 'CHQ'
1316 && $object->mode_reglement_code != 'VIR') {
1317 $pdf->SetFont('', '', $default_font_size - 2);
1318 $pdf->SetXY($this->marge_gauche, $posy);
1319 $titre = $outputlangs->transnoentities("PaymentMode").':';
1320 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0, 'L');
1321
1322 $pdf->SetFont('', '', $default_font_size - 2);
1323 $pdf->SetXY($posxval, $posy);
1324 $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
1325
1326 //#21654: add account number used for the debit
1327 if ($object->mode_reglement_code == "PRE") {
1328 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
1329 $bac = new CompanyBankAccount($this->db);
1330 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1331 $bac->fetch(0, '', $object->thirdparty->id);
1332 $iban = $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
1333 $lib_mode_reg .= ' '.$outputlangs->trans("PaymentTypePREdetails", dol_trunc($iban, 6, 'right', 'UTF-8', 1));
1334 }
1335
1336 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0, 'L');
1337
1338 $posy = $pdf->GetY();
1339 }
1340
1341 // Show if Option VAT debit option is on also if transmitter is french
1342 // Decret n°2099-1299 2022-10-07
1343 // French mention : "Option pour le paiement de la taxe d'après les débits"
1344 if ($this->emetteur->country_code == 'FR') {
1345 if (getDolGlobalInt('TAX_MODE') == 1) {
1346 $pdf->SetXY($this->marge_gauche, $posy);
1347 $pdf->writeHTMLCell(80, 5, '', '', $outputlangs->transnoentities("MentionVATDebitOptionIsOn"), 0, 1);
1348
1349 $posy = $pdf->GetY() + 1;
1350 }
1351 }
1352
1353 // Show online payment link
1354 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') {
1355 $useonlinepayment = 0;
1356 if (getDolGlobalString('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) {
1357 // Show online payment link
1358 // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
1359 include_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
1360 $validpaymentmethod = getValidOnlinePaymentMethods('');
1361 $useonlinepayment = count($validpaymentmethod);
1362 }
1363
1364
1365 if ($object->status != Facture::STATUS_DRAFT && $useonlinepayment) {
1366 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
1367 global $langs;
1368
1369 $langs->loadLangs(array('payment', 'paybox', 'stripe'));
1370 $servicename = $langs->transnoentities('Online');
1371 $paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0);
1372 $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';
1373
1374 $pdf->SetXY($this->marge_gauche, $posy);
1375 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
1376
1377 $posy = $pdf->GetY() + 1;
1378 }
1379 }
1380
1381 // Show payment mode CHQ
1382 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
1383 // If payment mode unregulated or payment mode forced to CHQ
1384 if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
1385 $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1386
1387 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
1388 $account = new Account($this->db);
1389 $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
1390
1391 $pdf->SetXY($this->marge_gauche, $posy);
1392 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1393 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', 0);
1394 $posy = $pdf->GetY() + 1;
1395
1396 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1397 $pdf->SetXY($this->marge_gauche, $posy);
1398 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1399 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1400 $posy = $pdf->GetY() + 2;
1401 }
1402 }
1403 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1404 $pdf->SetXY($this->marge_gauche, $posy);
1405 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1406 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1407 $posy = $pdf->GetY() + 1;
1408
1409 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1410 $pdf->SetXY($this->marge_gauche, $posy);
1411 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1412 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1413 $posy = $pdf->GetY() + 2;
1414 }
1415 }
1416 }
1417 }
1418
1419 // If payment mode not forced or forced to VIR, show payment with BAN
1420 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1421 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1422 $bankid = ($object->fk_account <= 0 ? getDolGlobalInt('FACTURE_RIB_NUMBER') : $object->fk_account);
1423 if ($object->fk_bank > 0) {
1424 $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1425 }
1426 $account = new Account($this->db);
1427 $account->fetch($bankid);
1428
1429 $curx = $this->marge_gauche;
1430 $cury = $posy;
1431
1432 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1433
1434 $posy += 2;
1435
1436 // SHOW EPC QR CODE
1437 if (getDolGlobalString('INVOICE_ADD_EPC_QR_CODE') == 'bottom') {
1438 $qrPosX = 120;
1439 $qrPosY = $posy;
1440 $qrCodeColor = array('25', '25', '25');
1441 $styleQr = array(
1442 'border' => false,
1443 'padding' => 0,
1444 'fgcolor' => $qrCodeColor,
1445 'bgcolor' => false, //array(255,255,255)
1446 'module_width' => 1, // width of a single module in points
1447 'module_height' => 1 // height of a single module in points
1448 );
1449
1450 $EPCQrCodeString = $object->buildEPCQrCodeString();
1451 $pdf->write2DBarcode($EPCQrCodeString, 'QRCODE,M', $qrPosX, $qrPosY, 25, 25, $styleQr, 'N');
1452
1453 $pdf->SetXY($qrPosX + 30, $posy + 5);
1454 $pdf->SetFont('', '', $default_font_size - 5);
1455 $pdf->MultiCell(30, 3, $outputlangs->transnoentitiesnoconv("INVOICE_ADD_EPC_QR_CODEPay"), 0, 'L', 0);
1456 $posy = $pdf->GetY() + 2;
1457 }
1458
1459 // Show structured communication
1460 if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION')) {
1461 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
1462 $invoicePaymentKey = dolBECalculateStructuredCommunication($object->ref, $object->type);
1463
1464 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('StructuredCommunication').": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0, 'L', 0);
1465 }
1466 }
1467 }
1468 }
1469
1470 return $posy;
1471 }
1472
1473
1485 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1486 {
1487 global $conf, $mysoc, $hookmanager;
1488
1489 $sign = 1;
1490 if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
1491 $sign = -1;
1492 }
1493
1494 $default_font_size = pdf_getPDFFontSize($outputlangs);
1495
1496 $tab2_top = $posy;
1497 $tab2_hl = 4;
1498 if (is_object($outputlangsbis)) { // When we show 2 languages we need more room for text, so we use a smaller font.
1499 $pdf->SetFont('', '', $default_font_size - 2);
1500 } else {
1501 $pdf->SetFont('', '', $default_font_size - 1);
1502 }
1503
1504 // Total table
1505 $col1x = 120;
1506 $col2x = 170;
1507 if ($this->page_largeur < 210) { // To work with US executive format
1508 $col1x -= 15;
1509 $col2x -= 10;
1510 }
1511 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1512
1513 $useborder = 0;
1514 $index = 0;
1515
1516 // Add trigger to allow to edit $object
1517 $parameters = array(
1518 'object' => &$object,
1519 'outputlangs' => $outputlangs,
1520 );
1521 $hookmanager->executeHooks('beforePercentCalculation', $parameters, $this); // Note that $object may have been modified by hook
1522
1523 // overall percentage of advancement
1524 $percent = 0;
1525 $i = 0;
1526 foreach ($object->lines as $line) {
1527 if ($line->product_type != 9) {
1528 $percent += $line->situation_percent;
1529 $i++;
1530 }
1531 }
1532
1533 if (!empty($i)) {
1534 $avancementGlobal = $percent / $i;
1535 } else {
1536 $avancementGlobal = 0;
1537 }
1538
1539 $object->fetchPreviousNextSituationInvoice();
1540 $TPreviousIncoice = $object->tab_previous_situation_invoice;
1541
1542 $total_a_payer = 0;
1543 $total_a_payer_ttc = 0;
1544 foreach ($TPreviousIncoice as &$fac) {
1545 $total_a_payer += $fac->total_ht;
1546 $total_a_payer_ttc += $fac->total_ttc;
1547 }
1548 $total_a_payer += $object->total_ht;
1549 $total_a_payer_ttc += $object->total_ttc;
1550
1551 if (!empty($avancementGlobal)) {
1552 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1553 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1554 } else {
1555 $total_a_payer = 0;
1556 $total_a_payer_ttc = 0;
1557 }
1558
1559 $i = 1;
1560 if (!empty($TPreviousIncoice)) {
1561 $pdf->setY($tab2_top);
1562 $posy = $pdf->GetY();
1563
1564 foreach ($TPreviousIncoice as &$fac) {
1565 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1566 $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs));
1567 $pdf->addPage();
1568 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
1569 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1570 $pdf->setY($this->tab_top_newpage);
1571 } else {
1572 $pdf->setY($this->marge_haute);
1573 }
1574 $posy = $pdf->GetY();
1575 }
1576
1577 // Cumulate preceding VAT
1578 $index++;
1579 $pdf->SetFillColor(255, 255, 255);
1580 $pdf->SetXY($col1x, $posy);
1581 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1582
1583 $pdf->SetXY($col2x, $posy);
1584
1585 $facSign = '';
1586 if ($i > 1) {
1587 $facSign = $fac->total_ht >= 0 ? '+' : '';
1588 }
1589
1590 $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
1591
1592 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
1593
1594 $i++;
1595 $posy += $tab2_hl;
1596
1597 $pdf->setY($posy);
1598 }
1599
1600 // Display current total
1601 $pdf->SetFillColor(255, 255, 255);
1602 $pdf->SetXY($col1x, $posy);
1603 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1604
1605 $pdf->SetXY($col2x, $posy);
1606 $facSign = '';
1607 if ($i > 1) {
1608 $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
1609 }
1610
1611 if ($fac->type === Facture::TYPE_CREDIT_NOTE) {
1612 $facSign = '-'; // les avoirs
1613 }
1614
1615
1616 $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
1617 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
1618
1619 $posy += $tab2_hl;
1620
1621 // Display all total
1622 $pdf->SetFont('', '', $default_font_size - 1);
1623 $pdf->SetFillColor(255, 255, 255);
1624 $pdf->SetXY($col1x, $posy);
1625 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
1626
1627 $pdf->SetXY($col2x, $posy);
1628 $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
1629 $pdf->SetFont('', '', $default_font_size - 2);
1630
1631 $posy += $tab2_hl;
1632
1633 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1634 $pdf->addPage();
1635 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
1636 $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1637 $pdf->setY($this->tab_top_newpage);
1638 } else {
1639 $pdf->setY($this->marge_haute);
1640 }
1641
1642 $posy = $pdf->GetY();
1643 }
1644
1645 $tab2_top = $posy;
1646 $index = 0;
1647
1648 $tab2_top += 3;
1649 }
1650
1651
1652 // Get Total HT
1653 $total_ht = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1654
1655 // Total remise
1656 $total_line_remise = 0;
1657 foreach ($object->lines as $i => $line) {
1658 $resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
1659 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1660 // Gestion remise sous forme de ligne négative
1661 if ($line->total_ht < 0) {
1662 $total_line_remise += -$line->total_ht;
1663 }
1664 }
1665 if ($total_line_remise > 0) {
1666 $pdf->SetFillColor(255, 255, 255);
1667 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1668 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
1669 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1670 $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
1671
1672 $index++;
1673
1674 // Show total NET before discount
1675 $pdf->SetFillColor(255, 255, 255);
1676 $pdf->SetXY($col1x, $tab2_top);
1677 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
1678 $pdf->SetXY($col2x, $tab2_top);
1679 $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
1680
1681 $index++;
1682 }
1683
1684 // Total HT
1685 $pdf->SetFillColor(255, 255, 255);
1686 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1687 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ? "TotalHT" : "Total") : ''), 0, 'L', 1);
1688
1689 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1690 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1691 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
1692
1693 // Show VAT by rates and total
1694 $pdf->SetFillColor(248, 248, 248);
1695
1696 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1697
1698 $this->atleastoneratenotnull = 0;
1699 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
1700 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
1701 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1702 // Nothing to do
1703 } else {
1704 //Local tax 1 before VAT
1705 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1706 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1707 continue;
1708 }
1709
1710 foreach ($localtax_rate as $tvakey => $tvaval) {
1711 if ($tvakey != 0) { // On affiche pas taux 0
1712 //$this->atleastoneratenotnull++;
1713
1714 $index++;
1715 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1716
1717 $tvacompl = '';
1718 if (preg_match('/\*/', (string) $tvakey)) {
1719 $tvakey = str_replace('*', '', (string) $tvakey);
1720 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1721 }
1722
1723 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1724 $totalvat .= ' ';
1725
1726 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1727 $totalvat .= $tvacompl;
1728 } else {
1729 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1730 }
1731
1732 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1733
1734 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1735
1736 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1737 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1738 }
1739 }
1740 }
1741
1742 //Local tax 2 before VAT
1743 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1744 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1745 continue;
1746 }
1747
1748 foreach ($localtax_rate as $tvakey => $tvaval) {
1749 if ($tvakey != 0) { // On affiche pas taux 0
1750 //$this->atleastoneratenotnull++;
1751
1752 $index++;
1753 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1754
1755 $tvacompl = '';
1756 if (preg_match('/\*/', (string) $tvakey)) {
1757 $tvakey = str_replace('*', '', (string) $tvakey);
1758 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1759 }
1760 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1761 $totalvat .= ' ';
1762
1763 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1764 $totalvat .= $tvacompl;
1765 } else {
1766 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1767 }
1768
1769 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1770
1771 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1772
1773 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1774 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1775 }
1776 }
1777 }
1778
1779 // Situations totals might be wrong on huge amounts with old mode 1
1780 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
1781 $sum_pdf_tva = 0;
1782 foreach ($this->tva as $tvakey => $tvaval) {
1783 $sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object
1784 }
1785
1786 if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
1787 if (!empty($sum_pdf_tva)) {
1788 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1789 } else {
1790 $coef_fix_tva = 1;
1791 }
1792
1793
1794 foreach ($this->tva as $tvakey => $tvaval) {
1795 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1796 }
1797 foreach ($this->tva_array as $tvakey => $tvaval) {
1798 $this->tva_array[$tvakey]['amount'] = $tvaval['amount'] * $coef_fix_tva;
1799 }
1800 }
1801 }
1802
1803 // VAT
1804 foreach ($this->tva_array as $tvakey => $tvaval) {
1805 if ($tvakey != 0) { // On affiche pas taux 0
1806 $this->atleastoneratenotnull++;
1807
1808 $index++;
1809 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1810
1811 $tvacompl = '';
1812 if (preg_match('/\*/', $tvakey)) {
1813 $tvakey = str_replace('*', '', $tvakey);
1814 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1815 }
1816 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1817 $totalvat .= ' ';
1818 if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
1819 $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
1820 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
1821 $totalvat .= $tvaval['vatcode'].$tvacompl;
1822 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1823 $totalvat .= $tvacompl;
1824 } else {
1825 $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
1826 }
1827 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1828
1829 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1830 $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
1831 }
1832 }
1833
1834 //Local tax 1 after VAT
1835 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1836 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1837 continue;
1838 }
1839
1840 foreach ($localtax_rate as $tvakey => $tvaval) {
1841 if ($tvakey != 0) { // On affiche pas taux 0
1842 //$this->atleastoneratenotnull++;
1843
1844 $index++;
1845 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1846
1847 $tvacompl = '';
1848 if (preg_match('/\*/', (string) $tvakey)) {
1849 $tvakey = str_replace('*', '', (string) $tvakey);
1850 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1851 }
1852 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1853 $totalvat .= ' ';
1854
1855 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1856 $totalvat .= $tvacompl;
1857 } else {
1858 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1859 }
1860
1861 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1862
1863 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1864
1865 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1866 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1867 }
1868 }
1869 }
1870
1871 //Local tax 2 after VAT
1872 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1873 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1874 continue;
1875 }
1876
1877 foreach ($localtax_rate as $tvakey => $tvaval) {
1878 // retrieve global local tax
1879 if ($tvakey != 0) { // On affiche pas taux 0
1880 //$this->atleastoneratenotnull++;
1881
1882 $index++;
1883 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1884
1885 $tvacompl = '';
1886 if (preg_match('/\*/', (string) $tvakey)) {
1887 $tvakey = str_replace('*', '', (string) $tvakey);
1888 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1889 }
1890 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1891 $totalvat .= ' ';
1892
1893 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1894 $totalvat .= $tvacompl;
1895 } else {
1896 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1897 }
1898
1899 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1900
1901 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1902
1903 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1904 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1905 }
1906 }
1907 }
1908
1909 // Revenue stamp
1910 if (price2num($object->revenuestamp, 'MT') != 0) {
1911 $index++;
1912 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1913 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RevenueStamp", $mysoc->country_code) : ''), $useborder, 'L', 1);
1914
1915 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1916 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
1917 }
1918
1919 // Total TTC
1920 $index++;
1921 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1922 $pdf->SetTextColor(0, 0, 60);
1923 $pdf->SetFillColor(224, 224, 224);
1924 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : ''), $useborder, 'L', 1);
1925
1926 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1927 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1928
1929
1930 // Retained warranty
1931 if ($object->displayRetainedWarranty()) {
1932 $pdf->SetTextColor(40, 40, 40);
1933 $pdf->SetFillColor(255, 255, 255);
1934
1935 $retainedWarranty = $object->getRetainedWarrantyAmount();
1936 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1937
1938 // Billed - retained warranty
1939 $index++;
1940 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1941 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
1942
1943 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1944 $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
1945
1946 // retained warranty
1947 $index++;
1948 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1949
1950 $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RetainedWarranty") : '').' ('.$object->retained_warranty.'%)';
1951 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
1952
1953 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
1954 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1955 $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
1956 }
1957 }
1958 }
1959
1960 $pdf->SetTextColor(0, 0, 0);
1961
1962 $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
1963 $depositsamount = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1964
1965 $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1966 if (!empty($object->paye)) {
1967 $resteapayer = 0;
1968 }
1969
1970 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
1971 // Already paid + Deposits
1972 $index++;
1973 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1974 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("Paid") : ''), 0, 'L', 0);
1975 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1976 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
1977
1978 // Credit note
1979 if ($creditnoteamount) {
1980 $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
1981 $labeltouse .= (is_object($outputlangsbis) ? (' / '.(($outputlangsbis->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities("CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities("CreditNotes"))) : '');
1982 $index++;
1983 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1984 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
1985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1986 $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
1987 }
1988
1989 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1990 $index++;
1991 $pdf->SetFillColor(255, 255, 255);
1992
1993 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1994 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("EscompteOfferedShort") : ''), $useborder, 'L', 1);
1995 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1996 $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'), 0, $outputlangs), $useborder, 'R', 1);
1997
1998 $resteapayer = 0;
1999 }
2000
2001 $index++;
2002 $pdf->SetTextColor(0, 0, 60);
2003 $pdf->SetFillColor(224, 224, 224);
2004 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
2005 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
2006 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
2007 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
2008
2009 $pdf->SetFont('', '', $default_font_size - 1);
2010 $pdf->SetTextColor(0, 0, 0);
2011 }
2012
2013 $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy);
2014
2015 $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks
2016 if ($reshook < 0) {
2017 $this->error = $hookmanager->error;
2018 $this->errors = $hookmanager->errors;
2019 }
2020
2021 $index++;
2022 return ($tab2_top + ($tab2_hl * $index));
2023 }
2024
2025 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2033 public static function liste_modeles($db, $maxfilenamelength = 0)
2034 {
2035 // phpcs:enable
2036 return parent::liste_modeles($db, $maxfilenamelength); // TODO: Change the autogenerated stub
2037 }
2038
2039 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
2054 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
2055 {
2056 global $conf;
2057
2058 // Force to disable hidetop and hidebottom
2059 $hidebottom = 0;
2060 if ($hidetop) {
2061 $hidetop = -1;
2062 }
2063
2064 $currency = !empty($currency) ? $currency : $conf->currency;
2065 $default_font_size = pdf_getPDFFontSize($outputlangs);
2066
2067 // Amount in (at tab_top - 1)
2068 $pdf->SetTextColor(0, 0, 0);
2069 $pdf->SetFont('', '', $default_font_size - 2);
2070
2071 if (empty($hidetop)) {
2072 // Show category of operations
2073 if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
2074 $categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
2075 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
2076 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
2077 }
2078
2079 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
2080 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2081 $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
2082 }
2083
2084 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
2085 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2086
2087 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
2088 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
2089 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2090 }
2091 }
2092
2093 $pdf->SetDrawColor(128, 128, 128);
2094 $pdf->SetFont('', '', $default_font_size - 1);
2095
2096 // Output Rect
2097 $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter
2098
2099
2100 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
2101
2102 if (empty($hidetop)) {
2103 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
2104 }
2105 }
2106
2107 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
2118 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
2119 {
2120 // phpcs:enable
2121 global $conf, $langs;
2122
2123 $ltrdirection = 'L';
2124 if ($outputlangs->trans("DIRECTION") == 'rtl') {
2125 $ltrdirection = 'R';
2126 }
2127
2128 // Load traductions files required by page
2129 $outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
2130
2131 $default_font_size = pdf_getPDFFontSize($outputlangs);
2132
2133 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
2134
2135 $pdf->SetTextColor(0, 0, 60);
2136 $pdf->SetFont('', 'B', $default_font_size + 3);
2137
2138 $w = 110;
2139
2140 $posy = $this->marge_haute;
2141 $posx = $this->page_largeur - $this->marge_droite - $w;
2142
2143 $pdf->SetXY($this->marge_gauche, $posy);
2144
2145 // Logo
2146 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
2147 if ($this->emetteur->logo) {
2148 $logodir = $conf->mycompany->dir_output;
2149 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
2150 $logodir = $conf->mycompany->multidir_output[$object->entity];
2151 }
2152 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
2153 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
2154 } else {
2155 $logo = $logodir.'/logos/'.$this->emetteur->logo;
2156 }
2157 if (is_readable($logo)) {
2158 $height = pdf_getHeightForLogo($logo);
2159 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
2160 } else {
2161 $pdf->SetTextColor(200, 0, 0);
2162 $pdf->SetFont('', 'B', $default_font_size - 2);
2163 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
2164 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
2165 }
2166 } else {
2167 $text = $this->emetteur->name;
2168 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2169 }
2170 }
2171
2172 $pdf->SetFont('', 'B', $default_font_size + 3);
2173 $pdf->SetXY($posx, $posy);
2174 $pdf->SetTextColor(0, 0, 60);
2175 $title = $outputlangs->transnoentities("PdfInvoiceTitle");
2176 if ($object->type == 1) {
2177 $title = $outputlangs->transnoentities("InvoiceReplacement");
2178 }
2179 if ($object->type == 2) {
2180 $title = $outputlangs->transnoentities("InvoiceAvoir");
2181 }
2182 if ($object->type == 3) {
2183 $title = $outputlangs->transnoentities("InvoiceDeposit");
2184 }
2185 if ($object->type == 4) {
2186 $title = $outputlangs->transnoentities("InvoiceProForma");
2187 }
2188 if ($this->situationinvoice) {
2189 $langs->loadLangs(array("other"));
2190 $title = $outputlangs->transnoentities("PDFInvoiceSituation") . " " . $outputlangs->transnoentities("NumberingShort") . $object->situation_counter . " -";
2191 }
2192 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2193 $title .= ' - ';
2194 if ($object->type == 0) {
2195 if ($this->situationinvoice) {
2196 $title .= $outputlangsbis->transnoentities("PDFInvoiceSituation");
2197 }
2198 $title .= $outputlangsbis->transnoentities("PdfInvoiceTitle");
2199 } elseif ($object->type == 1) {
2200 $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
2201 } elseif ($object->type == 2) {
2202 $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
2203 } elseif ($object->type == 3) {
2204 $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
2205 } elseif ($object->type == 4) {
2206 $title .= $outputlangsbis->transnoentities("InvoiceProForma");
2207 }
2208 }
2209 $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
2210 if ($object->status == $object::STATUS_DRAFT) {
2211 $pdf->SetTextColor(128, 0, 0);
2212 $title .= ' - '.$outputlangs->transnoentities("NotValidated");
2213 }
2214
2215 $pdf->MultiCell($w, 3, $title, '', 'R');
2216
2217 $pdf->SetFont('', 'B', $default_font_size);
2218
2219 /*
2220 $posy += 5;
2221 $pdf->SetXY($posx, $posy);
2222 $pdf->SetTextColor(0, 0, 60);
2223 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
2224 if ($object->status == $object::STATUS_DRAFT) {
2225 $pdf->SetTextColor(128, 0, 0);
2226 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
2227 }
2228 $pdf->MultiCell($w, 4, $textref, '', 'R');*/
2229
2230 $posy += 3;
2231 $pdf->SetFont('', '', $default_font_size - 2);
2232
2233 if ($object->ref_customer) {
2234 $posy += 4;
2235 $pdf->SetXY($posx, $posy);
2236 $pdf->SetTextColor(0, 0, 60);
2237 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_customer), 65), '', 'R');
2238 }
2239
2240 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
2241 $object->fetchProject();
2242 if (!empty($object->project->ref)) {
2243 $posy += 3;
2244 $pdf->SetXY($posx, $posy);
2245 $pdf->SetTextColor(0, 0, 60);
2246 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
2247 }
2248 }
2249
2250 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
2251 $object->fetchProject();
2252 if (!empty($object->project->ref)) {
2253 $outputlangs->load("projects");
2254 $posy += 3;
2255 $pdf->SetXY($posx, $posy);
2256 $pdf->SetTextColor(0, 0, 60);
2257 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
2258 }
2259 }
2260
2261 $objectidnext = $object->getIdReplacingInvoice('validated');
2262 if ($object->type == 0 && $objectidnext) {
2263 $objectreplacing = new Facture($this->db);
2264 $objectreplacing->fetch($objectidnext);
2265
2266 $posy += 3;
2267 $pdf->SetXY($posx, $posy);
2268 $pdf->SetTextColor(0, 0, 60);
2269 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
2270 }
2271 if ($object->type == 1) {
2272 $objectreplaced = new Facture($this->db);
2273 $objectreplaced->fetch($object->fk_facture_source);
2274
2275 $posy += 4;
2276 $pdf->SetXY($posx, $posy);
2277 $pdf->SetTextColor(0, 0, 60);
2278 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
2279 }
2280 if ($object->type == 2 && !empty($object->fk_facture_source)) {
2281 $objectreplaced = new Facture($this->db);
2282 $objectreplaced->fetch($object->fk_facture_source);
2283
2284 $posy += 3;
2285 $pdf->SetXY($posx, $posy);
2286 $pdf->SetTextColor(0, 0, 60);
2287 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
2288 }
2289
2290 $posy += 4;
2291 $pdf->SetXY($posx, $posy);
2292 $pdf->SetTextColor(0, 0, 60);
2293
2294 $title = $outputlangs->transnoentities("DateInvoice");
2295 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2296 $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
2297 }
2298 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
2299
2300 if (getDolGlobalString('INVOICE_POINTOFTAX_DATE')) {
2301 $posy += 4;
2302 $pdf->SetXY($posx, $posy);
2303 $pdf->SetTextColor(0, 0, 60);
2304 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R');
2305 }
2306
2307 if ($object->type != 2) {
2308 $posy += 3;
2309 $pdf->SetXY($posx, $posy);
2310 $pdf->SetTextColor(0, 0, 60);
2311 $title = $outputlangs->transnoentities("DateDue");
2312 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2313 $title .= ' - '.$outputlangsbis->transnoentities("DateDue");
2314 }
2315 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
2316 }
2317
2318 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
2319 $posy += 3;
2320 $pdf->SetXY($posx, $posy);
2321 $pdf->SetTextColor(0, 0, 60);
2322 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
2323 }
2324
2325 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && $object->thirdparty->code_compta_client) {
2326 $posy += 3;
2327 $pdf->SetXY($posx, $posy);
2328 $pdf->SetTextColor(0, 0, 60);
2329 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_compta_client), '', 'R');
2330 }
2331
2332 // Get contact
2333 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
2334 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
2335 if (count($arrayidcontact) > 0) {
2336 $usertmp = new User($this->db);
2337 $usertmp->fetch($arrayidcontact[0]);
2338 $posy += 4;
2339 $pdf->SetXY($posx, $posy);
2340 $pdf->SetTextColor(0, 0, 60);
2341 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
2342 }
2343 }
2344
2345 $posy += 1;
2346
2347 $top_shift = 0;
2348 $shipp_shift = 0;
2349 // Show list of linked objects
2350 $current_y = $pdf->getY();
2351 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
2352 if ($current_y < $pdf->getY()) {
2353 $top_shift = $pdf->getY() - $current_y;
2354 }
2355
2356 if ($showaddress) {
2357 // Sender properties
2358 $carac_emetteur = '';
2359 // Add internal contact of object if defined
2360 $arrayidcontact = $object->getIdContact('internal', 'BILLING');
2361 if (count($arrayidcontact) > 0) {
2362 $object->fetch_user($arrayidcontact[0]);
2363 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
2364 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
2365 $carac_emetteur .= "\n";
2366 }
2367
2368 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
2369
2370 // Show sender
2371 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
2372 $posy += $top_shift;
2373 $posx = $this->marge_gauche;
2374 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
2375 $posx = $this->page_largeur - $this->marge_droite - 80;
2376 }
2377
2378 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
2379 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
2380
2381 // Show sender frame
2382 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
2383 $pdf->SetTextColor(0, 0, 0);
2384 $pdf->SetFont('', '', $default_font_size - 2);
2385 $pdf->SetXY($posx, $posy - 5);
2386 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
2387 $pdf->SetXY($posx, $posy);
2388 $pdf->SetFillColor(230, 230, 230);
2389 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
2390 $pdf->SetTextColor(0, 0, 60);
2391 }
2392
2393 // Show sender name
2394 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
2395 $pdf->SetXY($posx + 2, $posy + 3);
2396 $pdf->SetFont('', 'B', $default_font_size);
2397 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2398 $posy = $pdf->getY();
2399 }
2400
2401 // Show sender information
2402 $pdf->SetXY($posx + 2, $posy);
2403 $pdf->SetFont('', '', $default_font_size - 1);
2404 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2405
2406 // If BILLING contact defined on invoice, we use it
2407 $usecontact = false;
2408 $arrayidcontact = $object->getIdContact('external', 'BILLING');
2409 if (count($arrayidcontact) > 0) {
2410 $usecontact = true;
2411 $result = $object->fetch_contact($arrayidcontact[0]);
2412 }
2413
2414 // Recipient name
2415 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2416 $thirdparty = $object->contact;
2417 } else {
2418 $thirdparty = $object->thirdparty;
2419 }
2420
2421 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
2422
2423 $mode = 'target';
2424 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), $mode, $object);
2425
2426 // Show recipient
2427 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
2428 if ($this->page_largeur < 210) {
2429 $widthrecbox = 84; // To work with US executive format
2430 }
2431 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
2432 $posy += $top_shift;
2433 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2434 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
2435 $posx = $this->marge_gauche;
2436 }
2437
2438 // Show recipient frame
2439 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
2440 $pdf->SetTextColor(0, 0, 0);
2441 $pdf->SetFont('', '', $default_font_size - 2);
2442 $pdf->SetXY($posx + 2, $posy - 5);
2443 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
2444 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
2445 }
2446
2447 // Show recipient name
2448 $pdf->SetXY($posx + 2, $posy + 3);
2449 $pdf->SetFont('', 'B', $default_font_size);
2450 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2451 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2452
2453 $posy = $pdf->getY();
2454
2455 // Show recipient information
2456 $pdf->SetFont('', '', $default_font_size - 1);
2457 $pdf->SetXY($posx + 2, $posy);
2458 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2459 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2460
2461 // Show shipping address
2462 if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) {
2463 $idaddressshipping = $object->getIdContact('external', 'SHIPPING');
2464
2465 if (!empty($idaddressshipping)) {
2466 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2467 $companystatic = new Societe($this->db);
2468 $companystatic->fetch($object->contact->fk_soc);
2469 $carac_client_name_shipping = pdfBuildThirdpartyName($object->contact, $outputlangs);
2470 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, ($usecontact ? 1 : 0), 'target', $object);
2471 } else {
2472 $carac_client_name_shipping = pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
2473 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
2474 }
2475 if (!empty($carac_client_shipping)) {
2476 $posy += $hautcadre;
2477
2478 $hautcadre -= 10; // Height for the shipping address does not need to be as high as main box
2479
2480 // Show shipping frame
2481 $pdf->SetXY($posx + 2, $posy - 5);
2482 $pdf->SetFont('', '', $default_font_size - 2);
2483 $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0);
2484 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
2485
2486 // Show shipping name
2487 $pdf->SetXY($posx + 2, $posy + 3);
2488 $pdf->SetFont('', 'B', $default_font_size);
2489 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L');
2490
2491 $posy = $pdf->getY();
2492
2493 // Show shipping information
2494 $pdf->SetXY($posx + 2, $posy);
2495 $pdf->SetFont('', '', $default_font_size - 1);
2496 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L');
2497
2498 $shipp_shift += $hautcadre + 10;
2499 }
2500 }
2501 }
2502
2503 $pdf->SetTextColor(0, 0, 0);
2504
2505 $pagehead = array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift);
2506
2507 return $pagehead;
2508 }
2509
2510 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
2521 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0)
2522 {
2523 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2524 return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
2525 }
2526
2537 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2538 {
2539 global $hookmanager;
2540
2541 // Default field style for content
2542 $this->defaultContentsFieldsStyle = array(
2543 'align' => 'R', // R,C,L
2544 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2545 );
2546
2547 // Default field style for content
2548 $this->defaultTitlesFieldsStyle = array(
2549 'align' => 'C', // R,C,L
2550 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2551 );
2552
2553 /*
2554 * For example
2555 $this->cols['theColKey'] = array(
2556 'rank' => $rank, // int : use for ordering columns
2557 'width' => 20, // the column width in mm
2558 'title' => array(
2559 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2560 'label' => ' ', // the final label : used fore final generated text
2561 'align' => 'L', // text alignment : R,C,L
2562 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2563 ),
2564 'content' => array(
2565 'align' => 'L', // text alignment : R,C,L
2566 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2567 ),
2568 );
2569 */
2570
2571 $rank = 0; // do not use negative rank
2572 $this->cols['position'] = array(
2573 'rank' => $rank,
2574 'width' => 10,
2575 'status' => getDolGlobalInt('PDF_SPONGE_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
2576 'title' => array(
2577 'textkey' => '#', // use lang key is useful in somme case with module
2578 'align' => 'C',
2579 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2580 // 'label' => ' ', // the final label
2581 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2582 ),
2583 'content' => array(
2584 'align' => 'C',
2585 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2586 ),
2587 );
2588
2589 $rank = 5; // do not use negative rank
2590 $this->cols['desc'] = array(
2591 'rank' => $rank,
2592 'width' => false, // only for desc
2593 'status' => true,
2594 'title' => array(
2595 'textkey' => 'Designation', // use lang key is useful in somme case with module
2596 'align' => 'L',
2597 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
2598 // 'label' => ' ', // the final label
2599 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2600 ),
2601 'content' => array(
2602 'align' => 'L',
2603 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2604 ),
2605 );
2606
2607 // Image of product
2608 $rank += 10;
2609 $this->cols['photo'] = array(
2610 'rank' => $rank,
2611 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
2612 'status' => false,
2613 'title' => array(
2614 'textkey' => 'Photo',
2615 'label' => ' '
2616 ),
2617 'content' => array(
2618 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
2619 ),
2620 'border-left' => false, // remove left line separator
2621 );
2622
2623 if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) {
2624 $this->cols['photo']['status'] = true;
2625 }
2626
2627
2628 $rank += 10;
2629 $this->cols['vat'] = array(
2630 'rank' => $rank,
2631 'status' => false,
2632 'width' => 16, // in mm
2633 'title' => array(
2634 'textkey' => 'VAT'
2635 ),
2636 'border-left' => true, // add left line separator
2637 );
2638
2639 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
2640 $this->cols['vat']['status'] = true;
2641 }
2642
2643 $rank += 10;
2644 $this->cols['subprice'] = array(
2645 'rank' => $rank,
2646 'width' => 19, // in mm
2647 'status' => true,
2648 'title' => array(
2649 'textkey' => 'PriceUHT'
2650 ),
2651 'border-left' => true, // add left line separator
2652 );
2653
2654 // Adapt dynamically the width of subprice, if text is too long.
2655 $tmpwidth = 0;
2656 $nblines = count($object->lines);
2657 for ($i = 0; $i < $nblines; $i++) {
2658 $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
2659 $tmpwidth = max($tmpwidth, $tmpwidth2);
2660 }
2661 if ($tmpwidth > 10) {
2662 $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
2663 }
2664
2665 $rank += 10;
2666 $this->cols['qty'] = array(
2667 'rank' => $rank,
2668 'width' => 16, // in mm
2669 'status' => true,
2670 'title' => array(
2671 'textkey' => 'Qty'
2672 ),
2673 'border-left' => true, // add left line separator
2674 );
2675
2676 $rank += 10;
2677 $this->cols['progress'] = array(
2678 'rank' => $rank,
2679 'width' => 19, // in mm
2680 'status' => false,
2681 'title' => array(
2682 'textkey' => 'ProgressShort'
2683 ),
2684 'border-left' => true, // add left line separator
2685 );
2686
2687 if ($this->situationinvoice) {
2688 $this->cols['progress']['status'] = true;
2689 }
2690
2691 $rank += 10;
2692 $this->cols['unit'] = array(
2693 'rank' => $rank,
2694 'width' => 11, // in mm
2695 'status' => false,
2696 'title' => array(
2697 'textkey' => 'Unit'
2698 ),
2699 'border-left' => true, // add left line separator
2700 );
2701 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
2702 $this->cols['unit']['status'] = true;
2703 }
2704
2705 $rank += 10;
2706 $this->cols['discount'] = array(
2707 'rank' => $rank,
2708 'width' => 13, // in mm
2709 'status' => false,
2710 'title' => array(
2711 'textkey' => 'ReductionShort'
2712 ),
2713 'border-left' => true, // add left line separator
2714 );
2715 if ($this->atleastonediscount) {
2716 $this->cols['discount']['status'] = true;
2717 }
2718
2719 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
2720 $this->cols['totalexcltax'] = array(
2721 'rank' => $rank,
2722 'width' => 26, // in mm
2723 'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX'),
2724 'title' => array(
2725 'textkey' => 'TotalHTShort'
2726 ),
2727 'border-left' => true, // add left line separator
2728 );
2729
2730 $rank += 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
2731 $this->cols['totalincltax'] = array(
2732 'rank' => $rank,
2733 'width' => 26, // in mm
2734 'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'),
2735 'title' => array(
2736 'textkey' => 'TotalTTCShort'
2737 ),
2738 'border-left' => true, // add left line separator
2739 );
2740
2741 // Add extrafields cols
2742 if (!empty($object->lines)) {
2743 $line = reset($object->lines);
2744 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
2745 }
2746
2747 $parameters = array(
2748 'object' => $object,
2749 'outputlangs' => $outputlangs,
2750 'hidedetails' => $hidedetails,
2751 'hidedesc' => $hidedesc,
2752 'hideref' => $hideref
2753 );
2754
2755 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
2756 if ($reshook < 0) {
2757 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2758 } elseif (empty($reshook)) {
2759 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
2760 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
2761 } else {
2762 $this->cols = $hookmanager->resArray;
2763 }
2764 }
2765}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage bank accounts.
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Class to manage bank accounts description of third parties.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage hooks.
Parent class of invoice document generators.
addBottomQRInvoice(TCPDF $pdf, Facture $object, Translate $langs)
Add SwissQR invoice at bottom of page 1.
getHeightForQRInvoice(int $pagenbr, Facture $object, Translate $langs)
Get the height for bottom-page QR invoice in mm, depending on the page number.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
Class to manage PDF invoice template sponge.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct($db)
Constructor.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
Show total to pay.
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0, $heightforqrinvoice=0)
Show footer of page.
drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
Show miscellaneous information (payment mode, payment term, ...)
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dolBECalculateStructuredCommunication($invoice_number, $invoice_type)
Calculate Structured Communication / BE Bank payment reference number.
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:2648
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition pdf.lib.php:2382
pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails=0)
Return line total amount discount.
Definition pdf.lib.php:2679
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:288
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:313
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition pdf.lib.php:2438
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1027
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2000
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
Definition pdf.lib.php:2331
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:1938
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:729
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1405
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
Definition pdf.lib.php:850
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:265
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:434
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
Definition pdf.lib.php:2245
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2288
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2085
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:765
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:386
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140