dolibarr 21.0.0-alpha
pdf_crabe.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-2018 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 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
15 * Copyright (C) 2024 Nick Fragoulis
16 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 * or see https://www.gnu.org/
31 */
32
39require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
40require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
44
45
50{
54 public $db;
55
59 public $name;
60
64 public $description;
65
69 public $update_main_doc_field;
70
74 public $type;
75
80 public $version = 'dolibarr';
81
85 public $situationinvoice;
86
90 public $posxprogress;
91
95 public $categoryOfOperation = -1; // unknown by default
96
97
103 public function __construct($db)
104 {
105 global $conf, $langs, $mysoc;
106
107 // Translations
108 $langs->loadLangs(array("main", "bills"));
109
110 $this->db = $db;
111 $this->name = "crabe";
112 $this->description = $langs->trans('PDFCrabeDescription');
113 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
114
115 // Dimension page
116 $this->type = 'pdf';
117 $formatarray = pdf_getFormat();
118 $this->page_largeur = $formatarray['width'];
119 $this->page_hauteur = $formatarray['height'];
120 $this->format = array($this->page_largeur, $this->page_hauteur);
121 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
122 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
123 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
124 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
125 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
126 $this->option_logo = 1; // Display logo
127 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
128 $this->option_modereg = 1; // Display payment mode
129 $this->option_condreg = 1; // Display payment terms
130 $this->option_multilang = 1; // Available in several languages
131 $this->option_escompte = 1; // Displays if there has been a discount
132 $this->option_credit_note = 1; // Support credit notes
133 $this->option_freetext = 1; // Support add of a personalised text
134 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
135 $this->watermark = '';
136
137 // Define position of columns
138 $this->posxdesc = $this->marge_gauche + 1;
139 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
140 $this->posxtva = 101;
141 $this->posxup = 118;
142 $this->posxqty = 135;
143 $this->posxunit = 151;
144 } else {
145 $this->posxtva = 106;
146 $this->posxup = 122;
147 $this->posxqty = 145;
148 $this->posxunit = 162;
149 }
150 $this->posxprogress = 151; // Only displayed for situation invoices
151 $this->posxdiscount = 162;
152 $this->posxprogress = 174;
153 $this->postotalht = 174;
154 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') || getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
155 $this->posxtva = $this->posxup;
156 }
157 $this->posxpicture = $this->posxtva - getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20); // width of images
158 if ($this->page_largeur < 210) { // To work with US executive format
159 $this->posxpicture -= 20;
160 $this->posxtva -= 20;
161 $this->posxup -= 20;
162 $this->posxqty -= 20;
163 $this->posxunit -= 20;
164 $this->posxdiscount -= 20;
165 $this->posxprogress -= 20;
166 $this->postotalht -= 20;
167 }
168
169 $this->tva = array();
170 $this->tva_array = array();
171 $this->localtax1 = array();
172 $this->localtax2 = array();
173 $this->atleastoneratenotnull = 0;
174 $this->atleastonediscount = 0;
175 $this->situationinvoice = false;
176
177 if ($mysoc === null) {
178 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
179 return;
180 }
181
182 // Get source company
183 $this->emetteur = $mysoc;
184 if (empty($this->emetteur->country_code)) {
185 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
186 }
187 }
188
189
190 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
202 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
203 {
204 // phpcs:enable
205 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
206
207 dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
208
209 if (!is_object($outputlangs)) {
210 $outputlangs = $langs;
211 }
212 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
213 if (getDolGlobalString('MAIN_USE_FPDF')) {
214 $outputlangs->charset_output = 'ISO-8859-1';
215 }
216
217 // Load translation files required by the page
218 $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "compta"));
219
220 // Show Draft Watermark
221 if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
222 $this->watermark = getDolGlobalString('FACTURE_DRAFT_WATERMARK');
223 }
224
225 global $outputlangsbis;
226 $outputlangsbis = null;
227 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
228 $outputlangsbis = new Translate('', $conf);
229 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
230 $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies", "compta"));
231 }
232
233 $nblines = count($object->lines);
234
235 // Loop on each lines to detect if there is at least one image to show
236 $realpatharray = array();
237 if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) {
238 for ($i = 0; $i < $nblines; $i++) {
239 if (empty($object->lines[$i]->fk_product)) {
240 continue;
241 }
242
243 $objphoto = new Product($this->db);
244 $objphoto->fetch($object->lines[$i]->fk_product);
245
246 $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
247 $dir = $conf->product->dir_output.'/'.$pdir;
248
249 $realpath = '';
250 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
251 $filename = $obj['photo'];
252 //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
253 $realpath = $dir.$filename;
254 break;
255 }
256
257 if ($realpath) {
258 $realpatharray[$i] = $realpath;
259 }
260 }
261 }
262 if (count($realpatharray) == 0) {
263 $this->posxpicture = $this->posxtva;
264 }
265
266 if ($conf->facture->dir_output) {
267 $object->fetch_thirdparty();
268
269 $deja_regle = $object->getSommePaiement((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
270 $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
271 $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
272
273 // Definition of $dir and $file
274 if ($object->specimen) {
275 $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
276 $file = $dir."/SPECIMEN.pdf";
277 } else {
278 $objectref = dol_sanitizeFileName($object->ref);
279 $dir = (empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity])."/".$objectref;
280 $file = $dir."/".$objectref.".pdf";
281 }
282 if (!file_exists($dir)) {
283 if (dol_mkdir($dir) < 0) {
284 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
285 return 0;
286 }
287 }
288
289 if (file_exists($dir)) {
290 // Add pdfgeneration hook
291 if (!is_object($hookmanager)) {
292 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
293 $hookmanager = new HookManager($this->db);
294 }
295 $hookmanager->initHooks(array('pdfgeneration'));
296 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
297 global $action;
298 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
299
300 // Set nblines with the new facture lines content after hook
301 $nblines = count($object->lines);
302 $nbpayments = count($object->getListOfPayments());
303
304 // Create pdf instance
305 $pdf = pdf_getInstance($this->format);
306 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
307 $pdf->SetAutoPageBreak(1, 0);
308
309 $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
310 if ($heightforinfotot > 220) {
311 $heightforinfotot = 220;
312 }
313 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
314 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
315 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
316 $heightforfooter += 6;
317 }
318
319 $heightforqrinvoice_firstpage = 0;
320 if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
321 $heightforqrinvoice_firstpage = $this->getHeightForQRInvoice(1, $object, $langs);
322 if ($heightforqrinvoice_firstpage > 0) {
323 // Shrink infotot to a base 30
324 $heightforinfotot = 30 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
325 }
326 }
327
328 if (class_exists('TCPDF')) {
329 $pdf->setPrintHeader(false);
330 $pdf->setPrintFooter(false);
331 }
332 $pdf->SetFont(pdf_getPDFFont($outputlangs));
333
334 // Set path to the background PDF File
335 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
336 $logodir = $conf->mycompany->dir_output;
337 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
338 $logodir = $conf->mycompany->multidir_output[$object->entity];
339 }
340 $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
341 $tplidx = $pdf->importPage(1);
342 }
343
344 $pdf->Open();
345 $pagenb = 0;
346 $pdf->SetDrawColor(128, 128, 128);
347
348 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
349 $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
350 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
351 $pdf->SetAuthor($mysoc->name.($user->id > 0 ? ' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) : ''));
352 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
353 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
354 $pdf->SetCompression(false);
355 }
356
357 // Set certificate
358 $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
359 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ? '' : $user->conf->CERTIFICATE_CRT_PRIVATE;
360 // If user has no certificate, we try to take the company one
361 if (!$cert) {
362 $cert = !getDolGlobalString('CERTIFICATE_CRT') ? '' : $conf->global->CERTIFICATE_CRT;
363 }
364 if (!$certprivate) {
365 $certprivate = !getDolGlobalString('CERTIFICATE_CRT_PRIVATE') ? '' : $conf->global->CERTIFICATE_CRT_PRIVATE;
366 }
367 // If a certificate is found
368 if ($cert) {
369 $info = array(
370 'Name' => $this->emetteur->name,
371 'Location' => getCountry($this->emetteur->country_code, ''),
372 'Reason' => 'INVOICE',
373 'ContactInfo' => $this->emetteur->email
374 );
375 $pdf->setSignature($cert, $certprivate, $this->emetteur->name, '', 2, $info);
376 }
377
378 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
379 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
380
381 // Set $this->atleastonediscount if you have at least one discount
382 // and determine category of operation
383 $categoryOfOperation = 0;
384 $nbProduct = 0;
385 $nbService = 0;
386 for ($i = 0; $i < $nblines; $i++) {
387 if ($object->lines[$i]->remise_percent) {
388 $this->atleastonediscount++;
389 }
390
391 // determine category of operation
392 if ($categoryOfOperation < 2) {
393 $lineProductType = $object->lines[$i]->product_type;
394 if ($lineProductType == Product::TYPE_PRODUCT) {
395 $nbProduct++;
396 } elseif ($lineProductType == Product::TYPE_SERVICE) {
397 $nbService++;
398 }
399 if ($nbProduct > 0 && $nbService > 0) {
400 // mixed products and services
401 $categoryOfOperation = 2;
402 }
403 }
404 }
405 // determine category of operation
406 if ($categoryOfOperation <= 0) {
407 // only services
408 if ($nbProduct == 0 && $nbService > 0) {
409 $categoryOfOperation = 1;
410 }
411 }
412 $this->categoryOfOperation = $categoryOfOperation;
413 if (empty($this->atleastonediscount)) { // retrieve space not used by discount
414 $delta = ($this->posxprogress - $this->posxdiscount);
415 $this->posxpicture += $delta;
416 $this->posxtva += $delta;
417 $this->posxup += $delta;
418 $this->posxqty += $delta;
419 $this->posxunit += $delta;
420 $this->posxdiscount += $delta;
421 // post of fields after are not modified, stay at same position
422 }
423
424 $progress_width = 0;
425 // Situation invoice handling
426 if ($object->situation_cycle_ref && !getDolGlobalString('MAIN_PDF_HIDE_SITUATION')) {
427 $this->situationinvoice = true;
428 $progress_width = 10;
429 $this->posxpicture -= $progress_width;
430 $this->posxtva -= $progress_width;
431 $this->posxup -= $progress_width;
432 $this->posxqty -= $progress_width;
433 $this->posxunit -= $progress_width;
434 $this->posxdiscount -= $progress_width;
435 $this->posxprogress -= $progress_width;
436 }
437
438 // New page
439 $pdf->AddPage();
440 if (!empty($tplidx)) {
441 $pdf->useTemplate($tplidx);
442 }
443 $pagenb++;
444
445 // Output header (logo, ref and address blocks). This is first call for first page.
446 $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
447 $pdf->SetFont('', '', $default_font_size - 1);
448 $pdf->MultiCell(0, 3, ''); // Set interline to 3
449 $pdf->SetTextColor(0, 0, 0);
450
451 // $pdf->GetY() here can't be used. It is bottom of the second address box but first one may be higher
452
453 // $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
454 $tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
455 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
456
457 // You can add more thing under header here, if you increase $extra_under_address_shift too.
458 $extra_under_address_shift = 0;
459 $qrcodestring = '';
460 if (getDolGlobalString('INVOICE_ADD_ZATCA_QR_CODE')) {
461 $qrcodestring = $object->buildZATCAQRString();
462 } elseif (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == '1' && (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')) {
463 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
464 $qrcodestring = $object->buildSwitzerlandQRString();
465 }
466 } elseif (getDolGlobalString('INVOICE_ADD_EPC_QR_CODE') == '1' && (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')) {
467 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
468 $qrcodestring = $object->buildEPCQrCodeString();
469 }
470 }
471
472 if ($qrcodestring) {
473 $qrcodecolor = array('25', '25', '25');
474 // set style for QR-code
475 $styleQr = array(
476 'border' => false,
477 'padding' => 0,
478 'fgcolor' => $qrcodecolor,
479 'bgcolor' => false, //array(255,255,255)
480 'module_width' => 1, // width of a single module in points
481 'module_height' => 1 // height of a single module in points
482 );
483 $pdf->write2DBarcode($qrcodestring, 'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr, 'N');
484
485 if (getDolGlobalString('INVOICE_ADD_EPC_QR_CODE') == '1' && (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')) {
486 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
487 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
488 $pdf->SetFont('', '', $default_font_size - 4);
489 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv("INVOICE_ADD_EPC_QR_CODEPay"), 0, 'L', 0);
490 }
491 }
492
493 $extra_under_address_shift += 25;
494 }
495
496 // Call hook printUnderHeaderPDFline
497 $parameters = array(
498 'object' => $object,
499 'i' => $i,
500 'pdf' => &$pdf,
501 'outputlangs' => $outputlangs,
502 'hidedetails' => $hidedetails
503 );
504 $reshook = $hookmanager->executeHooks('printUnderHeaderPDFline', $parameters, $this); // Note that $object may have been modified by hook
505 if (!empty($hookmanager->resArray['extra_under_address_shift'])) {
506 $extra_under_address_shift += $hookmanager->resArray['extra_under_address_shift'];
507 }
508
509 $tab_top += $extra_under_address_shift;
510 $tab_top_newpage += 0;
511
512 // Incoterm
513 $height_incoterms = 0;
514 if (isModEnabled('incoterm')) {
515 $desc_incoterms = $object->getIncotermsForPDF();
516 if ($desc_incoterms) {
517 $tab_top -= 2;
518
519 $pdf->SetFont('', '', $default_font_size - 1);
520 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
521 $nexY = $pdf->GetY();
522 $height_incoterms = $nexY - $tab_top;
523
524 // Rect takes a length in 3rd parameter
525 $pdf->SetDrawColor(192, 192, 192);
526 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D');
527
528 $tab_top = $nexY + 6;
529 }
530 }
531
532 // Display notes
533 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
534 if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
535 // Get first sale rep
536 if (is_object($object->thirdparty)) {
537 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
538 $salerepobj = new User($this->db);
539 $salerepobj->fetch($salereparray[0]['id']);
540 if (!empty($salerepobj->signature)) {
541 $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
542 }
543 }
544 }
545 // Extrafields in note
546 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
547 if (!empty($extranote)) {
548 $notetoshow = dol_concatdesc($notetoshow, $extranote);
549 }
550 if ($notetoshow) {
551 $tab_top -= 2;
552
553 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
554 complete_substitutions_array($substitutionarray, $outputlangs, $object);
555
556 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
557 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
558
559 $pdf->SetFont('', '', $default_font_size - 1);
560 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
561 $nexY = $pdf->GetY();
562 $height_note = $nexY - $tab_top;
563
564 // Rect takes a length in 3rd parameter
565 $pdf->SetDrawColor(192, 192, 192);
566 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius, '1234', 'D');
567
568 $tab_top = $nexY + 6;
569 }
570
571 $iniY = $tab_top + 7;
572 $curY = $tab_top + 7;
573 $nexY = $tab_top + 7;
574
575 // Loop on each lines
576 for ($i = 0; $i < $nblines; $i++) {
577 $curY = $nexY;
578 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
579 $pdf->SetTextColor(0, 0, 0);
580
581 // Define size of image if we need it
582 $imglinesize = array();
583 if (!empty($realpatharray[$i])) {
584 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
585 }
586
587 $pdf->setTopMargin($tab_top_newpage);
588 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs);
589 $pdf->setPageOrientation('', 1, $page_bottom_margin);
590 $pageposbefore = $pdf->getPage();
591
592 $showpricebeforepagebreak = 1;
593 $posYAfterImage = 0;
594 $posYAfterDescription = 0;
595
596 // We start with Photo of product line
597 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
598 $pdf->AddPage('', '', true);
599 if (!empty($tplidx)) {
600 $pdf->useTemplate($tplidx);
601 }
602 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
603 $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
604 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
605 }
606 $pdf->setPage($pageposbefore + 1);
607
608 $curY = $tab_top_newpage;
609
610 // Allows data in the first page if description is long enough to break in multiples pages
611 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
612 $showpricebeforepagebreak = 1;
613 } else {
614 $showpricebeforepagebreak = 0;
615 }
616 }
617
618 if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
619 $curX = $this->posxpicture - 1;
620 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
621 // $pdf->Image does not increase value return by getY, so we save it manually
622 $posYAfterImage = $curY + $imglinesize['height'];
623 }
624
625 // Description of product line
626 $curX = $this->posxdesc - 1;
627
628 $pdf->startTransaction();
629 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
630 $pageposafter = $pdf->getPage();
631 if ($pageposafter > $pageposbefore) { // There is a pagebreak
632 $pdf->rollbackTransaction(true);
633 $pageposafter = $pageposbefore;
634 //print $pageposafter.'-'.$pageposbefore;exit;
635 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
636 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
637 $pageposafter = $pdf->getPage();
638 $posyafter = $pdf->GetY();
639 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
640 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) { // There is no space left for total+free text
641 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
642 $pdf->AddPage('', '', true);
643 if (!empty($tplidx)) {
644 $pdf->useTemplate($tplidx);
645 }
646 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
647 $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
648 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
649 }
650 $pdf->setPage($pageposafter + 1);
651 }
652 } else {
653 // We found a page break
654
655 // Allows data in the first page if description is long enough to break in multiples pages
656 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
657 $showpricebeforepagebreak = 1;
658 } else {
659 $showpricebeforepagebreak = 0;
660 }
661 }
662 } else { // No pagebreak
663 $pdf->commitTransaction();
664 }
665 $posYAfterDescription = $pdf->GetY();
666
667 $nexY = $pdf->GetY();
668 $pageposafter = $pdf->getPage();
669 $pdf->setPage($pageposbefore);
670 $pdf->setTopMargin($this->marge_haute);
671 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
672
673 // We suppose that a too long description or photo were moved completely on next page
674 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
675 $pdf->setPage($pageposafter);
676 $curY = $tab_top_newpage;
677 }
678
679 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
680
681 // VAT Rate
682 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
683 $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
684 $pdf->SetXY($this->posxtva - 5, $curY);
685 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
686 }
687
688 // Unit price before discount
689 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
690 $pdf->SetXY($this->posxup, $curY);
691 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
692
693 // Quantity
694 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
695 $pdf->SetXY($this->posxqty, $curY);
696 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
697
698 // Unit
699 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
700 $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails);
701 $pdf->SetXY($this->posxunit, $curY);
702 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
703 }
704
705 // Discount on line
706 if ($object->lines[$i]->remise_percent) {
707 $pdf->SetXY($this->posxdiscount - 2, $curY);
708 $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
709 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
710 }
711
712 // Situation progress
713 if ($this->situationinvoice) {
714 $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
715 $pdf->SetXY($this->posxprogress, $curY);
716 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
717 }
718
719 // Total HT line
720 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
721 $pdf->SetXY($this->postotalht, $curY);
722 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
723
724
725 $sign = 1;
726 if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
727 $sign = -1;
728 }
729 // Collection of totals by value of VAT in $this->tva["taux"]=total_tva
730 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
731 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation
732 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
733 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
734 } else {
735 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
736 }
737 } else {
738 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
739 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
740 } else {
741 $tvaligne = $sign * $object->lines[$i]->total_tva;
742 }
743 }
744
745 $localtax1ligne = $object->lines[$i]->total_localtax1;
746 $localtax2ligne = $object->lines[$i]->total_localtax2;
747 $localtax1_rate = $object->lines[$i]->localtax1_tx;
748 $localtax2_rate = $object->lines[$i]->localtax2_tx;
749 $localtax1_type = $object->lines[$i]->localtax1_type;
750 $localtax2_type = $object->lines[$i]->localtax2_type;
751
752 // TODO remise_percent is an obsolete field for object parent
753 /*if ($object->remise_percent) {
754 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
755 }
756 if ($object->remise_percent) {
757 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
758 }
759 if ($object->remise_percent) {
760 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
761 }*/
762
763 $vatrate = (string) $object->lines[$i]->tva_tx;
764
765 // Retrieve type from database for backward compatibility with old records
766 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
767 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
768 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
769 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
770 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
771 }
772
773 // retrieve global local tax
774 if ($localtax1_type && $localtax1ligne != 0) {
775 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
776 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
777 } else {
778 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
779 }
780 }
781 if ($localtax2_type && $localtax2ligne != 0) {
782 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
783 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
784 } else {
785 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
786 }
787 }
788
789 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
790 $vatrate .= '*';
791 }
792
793 // Fill $this->tva and $this->tva_array
794 if (!isset($this->tva[$vatrate])) {
795 $this->tva[$vatrate] = 0;
796 }
797 $this->tva[$vatrate] += $tvaligne; // ->tva is abandoned, we use now ->tva_array that is more complete
798 $vatcode = $object->lines[$i]->vat_src_code;
799 if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
800 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
801 }
802 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
803
804 if ($posYAfterImage > $posYAfterDescription) {
805 $nexY = $posYAfterImage;
806 }
807
808 // Add line
809 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
810 $pdf->setPage($pageposafter);
811 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
812 //$pdf->SetDrawColor(190,190,200);
813 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
814 $pdf->SetLineStyle(array('dash' => 0));
815 }
816
817 $nexY += 2; // Add space between lines
818
819 // Detect if some page were added automatically and output _tableau for past pages
820 while ($pagenb < $pageposafter) {
821 $pdf->setPage($pagenb);
822 if ($pagenb == 1) {
823 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
824 } else {
825 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
826 }
827 $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pagenb, $object, $langs));
828 $pagenb++;
829 $pdf->setPage($pagenb);
830 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
831 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
832 $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
833 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
834 }
835 if (!empty($tplidx)) {
836 $pdf->useTemplate($tplidx);
837 }
838 }
839 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
840 if ($pagenb == 1) {
841 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
842 } else {
843 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
844 }
845 $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pagenb, $object, $langs));
846 // New page
847 $pdf->AddPage();
848 if (!empty($tplidx)) {
849 $pdf->useTemplate($tplidx);
850 }
851 $pagenb++;
852 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
853 $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
854 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
855 }
856 }
857 }
858
859 // Show square
860 if ($pagenb == 1) {
861 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0, $object->multicurrency_code);
862 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
863 } else {
864 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
865 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
866 }
867 dol_syslog("bottomlasttab=".$bottomlasttab." this->page_hauteur=".$this->page_hauteur." heightforinfotot=".$heightforinfotot." heightforfreetext=".$heightforfreetext." heightforfooter=".$heightforfooter);
868
869 // Display info area
870 $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
871
872 // Display total area
873 $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
874
875 // Display Payments area
876 $listofpayments = $object->getListOfPayments('', 0, 1);
877 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
878 $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter);
879 }
880
881 // Pagefoot
882 $this->_pagefoot($pdf, $object, $outputlangs, 0, $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs));
883 if (method_exists($pdf, 'AliasNbPages')) {
884 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
885 }
886
887 if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
888 $result = $this->addBottomQRInvoice($pdf, $object, $outputlangs);
889 if (!$result) {
890 $pdf->Close();
891 return 0;
892 }
893 }
894 $pdf->Close();
895
896 $pdf->Output($file, 'F');
897
898 // Add pdfgeneration hook
899 $hookmanager->initHooks(array('pdfgeneration'));
900 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
901 global $action;
902 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
903 if ($reshook < 0) {
904 $this->error = $hookmanager->error;
905 $this->errors = $hookmanager->errors;
906 }
907
908 dolChmod($file);
909
910 $this->result = array('fullpath' => $file);
911
912 return 1; // No error
913 } else {
914 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
915 return 0;
916 }
917 } else {
918 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
919 return 0;
920 }
921 }
922
923
924 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
925 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
936 protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0)
937 {
938 // phpcs:enable
939
940 $sign = 1;
941 if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
942 $sign = -1;
943 }
944
945 $current_page = $pdf->getPage();
946 $tab3_posx = 120;
947 $tab3_top = $posy + 8;
948 $tab3_width = 80;
949 $tab3_height = 4;
950 if ($this->page_largeur < 210) { // To work with US executive format
951 $tab3_posx -= 15;
952 }
953
954 $default_font_size = pdf_getPDFFontSize($outputlangs);
955
956 $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
957
958 $y = 0;
959
960 $pdf->SetFont('', '', $default_font_size - 4);
961
962
963 // Loop on each discount available (deposits and credit notes and excess of payment included)
964 $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,";
965 $sql .= " re.description, re.fk_facture_source,";
966 $sql .= " f.type, f.datef";
967 $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
968 $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
969 $resql = $this->db->query($sql);
970 if ($resql) {
971 $num = $this->db->num_rows($resql);
972 $i = 0;
973 $invoice = new Facture($this->db);
974 while ($i < $num) {
975 $y += 3;
976 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
977 $y = 0;
978 $current_page++;
979 $pdf->AddPage('', '', true);
980 /*if (!empty($tplidx)) {
981 $pdf->useTemplate($tplidx);
982 }*/
983 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
984 $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
985 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
986 }
987 $pdf->setPage($current_page);
988 $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
989 }
990
991 $obj = $this->db->fetch_object($resql);
992
993 if ($obj->type == 2) {
994 $text = $outputlangs->transnoentities("CreditNote");
995 } elseif ($obj->type == 3) {
996 $text = $outputlangs->transnoentities("Deposit");
997 } elseif ($obj->type == 0) {
998 $text = $outputlangs->transnoentities("ExcessReceived");
999 } else {
1000 $text = $outputlangs->transnoentities("UnknownType");
1001 }
1002
1003 $invoice->fetch($obj->fk_facture_source);
1004
1005 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1006 $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
1007 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1008 $pdf->MultiCell(20, 3, price((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
1009 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1010 $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
1011 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1012 $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
1013
1014 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1015
1016 $i++;
1017 }
1018 } else {
1019 $this->error = $this->db->lasterror();
1020 return -1;
1021 }
1022
1023 // Loop on each payment
1024 // TODO Call getListOfPayments instead of hard coded sql
1025 $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1026 $sql .= " cp.code";
1027 $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
1028 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
1029 $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1030 //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
1031 $sql .= " ORDER BY p.datep";
1032
1033 $resql = $this->db->query($sql);
1034 if ($resql) {
1035 $num = $this->db->num_rows($resql);
1036 $i = 0;
1037 $y += 3;
1038 $maxY = $y;
1039 while ($i < $num) {
1040 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1041 $y = 0;
1042 $current_page++;
1043 $pdf->AddPage('', '', true);
1044 /*if (!empty($tplidx)) {
1045 $pdf->useTemplate($tplidx);
1046 }*/
1047 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
1048 $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
1049 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1050 }
1051 $pdf->setPage($current_page);
1052 $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
1053 }
1054
1055 $row = $this->db->fetch_object($resql);
1056
1057 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1058 $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
1059 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1060 $pdf->MultiCell(20, 3, price($sign * ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
1061 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1062 $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
1063
1064 $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
1065 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1066 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1067 $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
1068 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1069 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1070 $y += 3;
1071 $i++;
1072 }
1073
1074 return $tab3_top + $y + 3;
1075 } else {
1076 $this->error = $this->db->lasterror();
1077 return -1;
1078 }
1079 }
1080
1081 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1082 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1096 protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
1097 {
1098 // phpcs:enable
1099 $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
1100 if ($object->type == 2) {
1101 $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
1102 }
1103
1104 $pdf->SetFont('', '', $default_font_size - 3);
1105 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1106 $pdf->MultiCell(60, 3, $title, 0, 'L', 0);
1107
1108 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1109
1110 $pdf->SetFont('', '', $default_font_size - 4);
1111 $pdf->SetXY($tab3_posx, $tab3_top);
1112 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
1113 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1114 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
1115 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1116 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
1117 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1118 $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
1119
1120 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1121 }
1122
1123 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1124 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1135 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1136 {
1137 // phpcs:enable
1138 global $conf, $mysoc, $hookmanager;
1139
1140 $default_font_size = pdf_getPDFFontSize($outputlangs);
1141
1142 $pdf->SetFont('', '', $default_font_size - 1);
1143
1144 // If France, show VAT mention if not applicable
1145 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
1146 $pdf->SetFont('', 'B', $default_font_size - 2);
1147 $pdf->SetXY($this->marge_gauche, $posy);
1148 if ($mysoc->forme_juridique_code == 92) {
1149 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0);
1150 } else {
1151 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
1152 }
1153
1154 $posy = $pdf->GetY() + 4;
1155 }
1156
1157 $posxval = 52;
1158 $posxend = 110; // End of x for text on left side
1159 if ($this->page_largeur < 210) { // To work with US executive format
1160 $posxend -= 10;
1161 }
1162
1163 // Show payments conditions
1164 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1165 $pdf->SetFont('', 'B', $default_font_size - 2);
1166 $pdf->SetXY($this->marge_gauche, $posy);
1167 $titre = $outputlangs->transnoentities("PaymentConditions").':';
1168 $pdf->MultiCell(43, 4, $titre, 0, 'L');
1169
1170 $pdf->SetFont('', '', $default_font_size - 2);
1171 $pdf->SetXY($posxval, $posy);
1172 $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);
1173 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1174 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1175
1176 $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
1177 }
1178
1179 // Show category of operations
1180 if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1181 $pdf->SetFont('', 'B', $default_font_size - 2);
1182 $pdf->SetXY($this->marge_gauche, $posy);
1183 $categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : ';
1184 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L');
1185
1186 $pdf->SetFont('', '', $default_font_size - 2);
1187 $pdf->SetXY($posxval, $posy);
1188 $categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
1189 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L');
1190
1191 $posy = $pdf->GetY() + 3; // for 2 lines
1192 }
1193
1194 if ($object->type != 2) {
1195 // Check a payment mode is defined
1196 if (empty($object->mode_reglement_code)
1197 && !getDolGlobalInt('FACTURE_CHQ_NUMBER')
1198 && !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1199 $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
1200 } elseif (($object->mode_reglement_code == 'CHQ' && !getDolGlobalInt('FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
1201 || ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1202 // Avoid having any valid PDF with setup that is not complete
1203 $outputlangs->load("errors");
1204
1205 $pdf->SetXY($this->marge_gauche, $posy);
1206 $pdf->SetTextColor(200, 0, 0);
1207 $pdf->SetFont('', 'B', $default_font_size - 2);
1208 $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1209 $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
1210 $pdf->SetTextColor(0, 0, 0);
1211
1212 $posy = $pdf->GetY() + 1;
1213 }
1214
1215 // Show payment mode
1216 if (!empty($object->mode_reglement_code)
1217 && $object->mode_reglement_code != 'CHQ'
1218 && $object->mode_reglement_code != 'VIR') {
1219 $pdf->SetFont('', 'B', $default_font_size - 2);
1220 $pdf->SetXY($this->marge_gauche, $posy);
1221 $titre = $outputlangs->transnoentities("PaymentMode").':';
1222 $pdf->MultiCell(80, 5, $titre, 0, 'L');
1223
1224 $pdf->SetFont('', '', $default_font_size - 2);
1225 $pdf->SetXY($posxval, $posy);
1226 $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);
1227 //#21654: add account number used for the debit
1228 if ($object->mode_reglement_code == "PRE") {
1229 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
1230 $bac = new CompanyBankAccount($this->db);
1231 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1232 $bac->fetch(0, '', $object->thirdparty->id);
1233 $iban = $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
1234 $lib_mode_reg .= ' '.$outputlangs->trans("PaymentTypePREdetails", dol_trunc($iban, 6, 'right', 'UTF-8', 1));
1235 }
1236 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1237
1238 $posy = $pdf->GetY();
1239 }
1240
1241 // Show if Option VAT debit option is on also if transmitter is french
1242 // Decret n°2099-1299 2022-10-07
1243 // French mention : "Option pour le paiement de la taxe d'après les débits"
1244 if ($this->emetteur->country_code == 'FR') {
1245 if (getDolGlobalInt('TAX_MODE') == 1) {
1246 $pdf->SetXY($this->marge_gauche, $posy);
1247 $pdf->writeHTMLCell(80, 5, '', '', $outputlangs->transnoentities("MentionVATDebitOptionIsOn"), 0, 1);
1248
1249 $posy = $pdf->GetY() + 1;
1250 }
1251 }
1252
1253 // Show online payment link
1254 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') {
1255 $useonlinepayment = 0;
1256 if (getDolGlobalString('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) {
1257 // Show online payment link
1258 // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
1259 include_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
1260 $validpaymentmethod = getValidOnlinePaymentMethods('');
1261 $useonlinepayment = count($validpaymentmethod);
1262 }
1263
1264 if ($object->status != Facture::STATUS_DRAFT && $useonlinepayment) {
1265 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
1266 global $langs;
1267
1268 $langs->loadLangs(array('payment', 'paybox', 'stripe'));
1269 $servicename = $langs->transnoentities('Online');
1270 $paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0);
1271 $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';
1272
1273 $pdf->SetXY($this->marge_gauche, $posy);
1274 $pdf->writeHTMLCell(80, 5, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
1275
1276 $posy = $pdf->GetY() + 1;
1277 }
1278 }
1279
1280 // Show payment mode CHQ
1281 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
1282 // If payment mode unregulated or payment mode forced to CHQ
1283 if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
1284 $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1285
1286 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
1287 $account = new Account($this->db);
1288 $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
1289
1290 $pdf->SetXY($this->marge_gauche, $posy);
1291 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1292 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', 0);
1293 $posy = $pdf->GetY() + 1;
1294
1295 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1296 $pdf->SetXY($this->marge_gauche, $posy);
1297 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1298 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1299 $posy = $pdf->GetY() + 2;
1300 }
1301 }
1302 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1303 $pdf->SetXY($this->marge_gauche, $posy);
1304 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1305 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1306 $posy = $pdf->GetY() + 1;
1307
1308 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1309 $pdf->SetXY($this->marge_gauche, $posy);
1310 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1311 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1312 $posy = $pdf->GetY() + 2;
1313 }
1314 }
1315 }
1316 }
1317
1318 // If payment mode not forced or forced to VIR, show payment with BAN
1319 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1320 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1321 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1322 if ($object->fk_bank > 0) {
1323 $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1324 }
1325 $account = new Account($this->db);
1326 $account->fetch($bankid);
1327
1328 $curx = $this->marge_gauche;
1329 $cury = $posy;
1330
1331 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1332
1333 $posy += 2;
1334
1335 if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION')) {
1336 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
1337 $invoicePaymentKey = dolBECalculateStructuredCommunication($object->ref, $object->type);
1338
1339 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('StructuredCommunication').": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0, 'L', 0);
1340 }
1341 }
1342 }
1343 }
1344
1345 return $posy;
1346 }
1347
1348
1349 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1350 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1362 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1363 {
1364 // phpcs:enable
1365 global $conf, $mysoc, $hookmanager;
1366
1367 $sign = 1;
1368 if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
1369 $sign = -1;
1370 }
1371
1372 $default_font_size = pdf_getPDFFontSize($outputlangs);
1373
1374 $outputlangsbis = null;
1375 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
1376 $outputlangsbis = new Translate('', $conf);
1377 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
1378 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1379 $default_font_size--;
1380 }
1381
1382 $tab2_top = $posy;
1383 $tab2_hl = 4;
1384 $pdf->SetFont('', '', $default_font_size - 1);
1385
1386 // Total table
1387 $col1x = 120;
1388 $col2x = 170;
1389 if ($this->page_largeur < 210) { // To work with US executive format
1390 $col1x -= 15;
1391 $col2x -= 10;
1392 }
1393 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1394
1395 $useborder = 0;
1396 $index = 0;
1397
1398 // Get Total HT
1399 $total_ht = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1400
1401 // Total remise
1402 $total_line_remise = 0;
1403 foreach ($object->lines as $i => $line) {
1404 $resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
1405 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1406 // Gestion remise sous forme de ligne négative
1407 if ($line->total_ht < 0) {
1408 $total_line_remise += -$line->total_ht;
1409 }
1410 }
1411 if ($total_line_remise > 0) {
1412 $pdf->SetFillColor(255, 255, 255);
1413 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1414 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
1415 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1416 $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
1417
1418 $index++;
1419
1420 // Show total NET before discount
1421 $pdf->SetFillColor(255, 255, 255);
1422 $pdf->SetXY($col1x, $tab2_top);
1423 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
1424 $pdf->SetXY($col2x, $tab2_top);
1425 $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
1426
1427 $index++;
1428 }
1429
1430 // Total HT
1431 $pdf->SetFillColor(255, 255, 255);
1432 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1433 $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);
1434
1435 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1436 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1437 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
1438
1439 // Show VAT by rates and total
1440 $pdf->SetFillColor(248, 248, 248);
1441
1442 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1443
1444 $this->atleastoneratenotnull = 0;
1445 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
1446 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
1447 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1448 // Nothing to do
1449 } else {
1450 //Local tax 1 before VAT
1451 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1452 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1453 continue;
1454 }
1455
1456 foreach ($localtax_rate as $tvakey => $tvaval) {
1457 if ($tvakey != 0) { // On affiche pas taux 0
1458 //$this->atleastoneratenotnull++;
1459
1460 $index++;
1461 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1462
1463 $tvacompl = '';
1464 if (preg_match('/\*/', (string) $tvakey)) {
1465 $tvakey = str_replace('*', '', (string) $tvakey);
1466 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1467 }
1468
1469 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1470 $totalvat .= ' ';
1471
1472 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1473 $totalvat .= $tvacompl;
1474 } else {
1475 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1476 }
1477
1478 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1479
1480 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1481
1482 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1483 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1484 }
1485 }
1486 }
1487
1488 //Local tax 2 before VAT
1489 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1490 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1491 continue;
1492 }
1493
1494 foreach ($localtax_rate as $tvakey => $tvaval) {
1495 if ($tvakey != 0) { // On affiche pas taux 0
1496 //$this->atleastoneratenotnull++;
1497
1498 $index++;
1499 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1500
1501 $tvacompl = '';
1502 if (preg_match('/\*/', (string) $tvakey)) {
1503 $tvakey = str_replace('*', '', (string) $tvakey);
1504 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1505 }
1506 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1507 $totalvat .= ' ';
1508
1509 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1510 $totalvat .= $tvacompl;
1511 } else {
1512 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1513 }
1514
1515 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1516
1517 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1518
1519 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1520 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1521 }
1522 }
1523 }
1524
1525 // VAT
1526 foreach ($this->tva_array as $tvakey => $tvaval) {
1527 if ($tvakey != 0) { // On affiche pas taux 0
1528 $this->atleastoneratenotnull++;
1529
1530 $index++;
1531 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1532
1533 $tvacompl = '';
1534 if (preg_match('/\*/', $tvakey)) {
1535 $tvakey = str_replace('*', '', $tvakey);
1536 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1537 }
1538 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1539 $totalvat .= ' ';
1540 if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
1541 $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
1542 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
1543 $totalvat .= $tvaval['vatcode'].$tvacompl;
1544 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1545 $totalvat .= $tvacompl;
1546 } else {
1547 $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
1548 }
1549 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1550
1551 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1552 $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
1553 }
1554 }
1555
1556 //Local tax 1 after VAT
1557 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1558 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1559 continue;
1560 }
1561
1562 foreach ($localtax_rate as $tvakey => $tvaval) {
1563 if ($tvakey != 0) { // On affiche pas taux 0
1564 //$this->atleastoneratenotnull++;
1565
1566 $index++;
1567 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1568
1569 $tvacompl = '';
1570 if (preg_match('/\*/', (string) $tvakey)) {
1571 $tvakey = str_replace('*', '', (string) $tvakey);
1572 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1573 }
1574 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1575
1576 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1577 $totalvat .= $tvacompl;
1578 } else {
1579 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1580 }
1581
1582 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1583
1584 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1585
1586 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1587 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1588 }
1589 }
1590 }
1591
1592 //Local tax 2 after VAT
1593 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1594 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1595 continue;
1596 }
1597
1598 foreach ($localtax_rate as $tvakey => $tvaval) {
1599 //$this->atleastoneratenotnull++;
1600
1601 $index++;
1602 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1603
1604 $tvacompl = '';
1605 if (preg_match('/\*/', (string) $tvakey)) {
1606 $tvakey = str_replace('*', '', (string) $tvakey);
1607 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1608 }
1609 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1610
1611 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1612 $totalvat .= $tvacompl;
1613 } else {
1614 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1615 }
1616
1617 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1618
1619 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1620
1621 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1622 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1623 }
1624 }
1625
1626 // Revenue stamp
1627 if (price2num($object->revenuestamp, 'MT') != 0) {
1628 $index++;
1629 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1630 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1631
1632 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1633 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
1634 }
1635
1636 // Total TTC
1637 $index++;
1638 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1639 $pdf->SetTextColor(0, 0, 60);
1640 $pdf->SetFillColor(224, 224, 224);
1641 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1642
1643 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1644 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1645
1646 // Retained warranty
1647 if ($object->displayRetainedWarranty()) {
1648 $pdf->SetTextColor(40, 40, 40);
1649 $pdf->SetFillColor(255, 255, 255);
1650
1651 $retainedWarranty = $object->getRetainedWarrantyAmount();
1652 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1653
1654 // Billed - retained warranty
1655 $index++;
1656 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1657 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
1658
1659 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1660 $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
1661
1662 // retained warranty
1663 $index++;
1664 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1665
1666 $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
1667 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
1668
1669 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
1670 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1671 $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
1672 }
1673 }
1674 }
1675
1676 $pdf->SetTextColor(0, 0, 0);
1677 $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
1678 $depositsamount = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1679 //print "x".$creditnoteamount."-".$depositsamount;exit;
1680 $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1681 if (!empty($object->paye)) {
1682 $resteapayer = 0;
1683 }
1684
1685 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
1686 // Already paid + Deposits
1687 $index++;
1688 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1689 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1690 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1691 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
1692
1693 // Credit note
1694 if ($creditnoteamount) {
1695 $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
1696 $index++;
1697 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1698 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
1699 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1700 $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
1701 }
1702
1703 // Escompte
1704 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1705 $index++;
1706 $pdf->SetFillColor(255, 255, 255);
1707
1708 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1709 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1710 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1711 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
1712
1713 $resteapayer = 0;
1714 }
1715
1716 $index++;
1717 $pdf->SetTextColor(0, 0, 60);
1718 $pdf->SetFillColor(224, 224, 224);
1719 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1720 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1721 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1722 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1723
1724 $pdf->SetFont('', '', $default_font_size - 1);
1725 $pdf->SetTextColor(0, 0, 0);
1726 }
1727
1728 $index++;
1729
1730 if (getDolGlobalString("BILL_TEXT_TOTAL_FOOTER")) {
1731 $index++;
1732 $index++;
1733 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1734 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0, 'L', 0);
1735 }
1736
1737 return ($tab2_top + ($tab2_hl * $index));
1738 }
1739
1740 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1754 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1755 {
1756 global $conf;
1757
1758 // Force to disable hidetop and hidebottom
1759 $hidebottom = 0;
1760 if ($hidetop) {
1761 $hidetop = -1;
1762 }
1763
1764 $currency = !empty($currency) ? $currency : $conf->currency;
1765 $default_font_size = pdf_getPDFFontSize($outputlangs);
1766
1767 // Amount in (at tab_top - 1)
1768 $pdf->SetTextColor(0, 0, 0);
1769 $pdf->SetFont('', '', $default_font_size - 2);
1770
1771 if (empty($hidetop)) {
1772 // Show category of operations
1773 if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1774 $categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
1775 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1776 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1777 }
1778
1779 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1780 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1781 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1782
1783 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1784 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1785 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1786 }
1787 }
1788
1789 $pdf->SetDrawColor(128, 128, 128);
1790 $pdf->SetFont('', '', $default_font_size - 1);
1791
1792 // Output Rect
1793 $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
1794
1795 if (empty($hidetop)) {
1796 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
1797
1798 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1799 $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1800 }
1801
1802 if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) {
1803 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1804 if (empty($hidetop)) {
1805 //$pdf->SetXY($this->posxpicture-1, $tab_top+1);
1806 //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
1807 }
1808 }
1809
1810 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
1811 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1812 if (empty($hidetop)) {
1813 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1814 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1815 }
1816 }
1817
1818 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1819 if (empty($hidetop)) {
1820 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1821 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1822 }
1823
1824 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1825 if (empty($hidetop)) {
1826 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1827 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1828 }
1829
1830 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1831 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1832 if (empty($hidetop)) {
1833 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1834 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
1835 }
1836 }
1837
1838 if ($this->atleastonediscount) {
1839 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1840 if (empty($hidetop)) {
1841 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1842 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1843 }
1844 }
1845
1846 if ($this->situationinvoice) {
1847 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1848 if (empty($hidetop)) {
1849 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1850 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
1851 }
1852 }
1853
1854 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1855 if (empty($hidetop)) {
1856 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1857 $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
1858 }
1859 }
1860
1861 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1872 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
1873 {
1874 // phpcs:enable
1875 global $conf, $langs;
1876
1877 $ltrdirection = 'L';
1878 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1879 $ltrdirection = 'R';
1880 }
1881
1882 // Load traductions files required by page
1883 $outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
1884
1885 $default_font_size = pdf_getPDFFontSize($outputlangs);
1886
1887 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1888
1889 $pdf->SetTextColor(0, 0, 60);
1890 $pdf->SetFont('', 'B', $default_font_size + 3);
1891
1892 $w = 110;
1893
1894 $posy = $this->marge_haute;
1895 $posx = $this->page_largeur - $this->marge_droite - $w;
1896
1897 $pdf->SetXY($this->marge_gauche, $posy);
1898
1899 // Logo
1900 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1901 if ($this->emetteur->logo) {
1902 $logodir = $conf->mycompany->dir_output;
1903 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1904 $logodir = $conf->mycompany->multidir_output[$object->entity];
1905 }
1906 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1907 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1908 } else {
1909 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1910 }
1911 if (is_readable($logo)) {
1912 $height = pdf_getHeightForLogo($logo);
1913 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1914 } else {
1915 $pdf->SetTextColor(200, 0, 0);
1916 $pdf->SetFont('', 'B', $default_font_size - 2);
1917 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1918 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1919 }
1920 } else {
1921 $text = $this->emetteur->name;
1922 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1923 }
1924 }
1925
1926 $pdf->SetFont('', 'B', $default_font_size + 3);
1927 $pdf->SetXY($posx, $posy);
1928 $pdf->SetTextColor(0, 0, 60);
1929 $title = $outputlangs->transnoentities("PdfInvoiceTitle");
1930 if ($object->type == 1) {
1931 $title = $outputlangs->transnoentities("InvoiceReplacement");
1932 }
1933 if ($object->type == 2) {
1934 $title = $outputlangs->transnoentities("InvoiceAvoir");
1935 }
1936 if ($object->type == 3) {
1937 $title = $outputlangs->transnoentities("InvoiceDeposit");
1938 }
1939 if ($object->type == 4) {
1940 $title = $outputlangs->transnoentities("InvoiceProForma");
1941 }
1942 if ($this->situationinvoice) {
1943 $langs->loadLangs(array("other"));
1944 $title = $outputlangs->transnoentities("PDFInvoiceSituation") . " " . $outputlangs->transnoentities("NumberingShort") . $object->situation_counter . " -";
1945 }
1946 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1947 $title .= ' - ';
1948 if ($object->type == 0) {
1949 if ($this->situationinvoice) {
1950 $title .= $outputlangsbis->transnoentities("PDFInvoiceSituation");
1951 }
1952 $title .= $outputlangsbis->transnoentities("PdfInvoiceTitle");
1953 } elseif ($object->type == 1) {
1954 $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
1955 } elseif ($object->type == 2) {
1956 $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
1957 } elseif ($object->type == 3) {
1958 $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
1959 } elseif ($object->type == 4) {
1960 $title .= $outputlangsbis->transnoentities("InvoiceProForma");
1961 }
1962 }
1963 $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1964 if ($object->status == $object::STATUS_DRAFT) {
1965 $pdf->SetTextColor(128, 0, 0);
1966 $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1967 }
1968
1969 $pdf->MultiCell($w, 3, $title, '', 'R');
1970
1971 $pdf->SetFont('', 'B', $default_font_size);
1972
1973 /*
1974 $posy += 5;
1975 $pdf->SetXY($posx, $posy);
1976 $pdf->SetTextColor(0, 0, 60);
1977 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1978 if ($object->status == $object::STATUS_DRAFT) {
1979 $pdf->SetTextColor(128, 0, 0);
1980 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1981 }
1982 $pdf->MultiCell($w, 4, $textref, '', 'R');*/
1983
1984 $posy += 3;
1985 $pdf->SetFont('', '', $default_font_size - 2);
1986
1987 if ($object->ref_customer) {
1988 $posy += 4;
1989 $pdf->SetXY($posx, $posy);
1990 $pdf->SetTextColor(0, 0, 60);
1991 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_customer), '', 'R');
1992 }
1993
1994 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
1995 $object->fetchProject();
1996 if (!empty($object->project->ref)) {
1997 $posy += 3;
1998 $pdf->SetXY($posx, $posy);
1999 $pdf->SetTextColor(0, 0, 60);
2000 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
2001 }
2002 }
2003
2004 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
2005 $object->fetchProject();
2006 if (!empty($object->project->ref)) {
2007 $outputlangs->load("projects");
2008 $posy += 3;
2009 $pdf->SetXY($posx, $posy);
2010 $pdf->SetTextColor(0, 0, 60);
2011 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
2012 }
2013 }
2014
2015 $objectidnext = $object->getIdReplacingInvoice('validated');
2016 if ($object->type == 0 && $objectidnext) {
2017 $objectreplacing = new Facture($this->db);
2018 $objectreplacing->fetch($objectidnext);
2019
2020 $posy += 3;
2021 $pdf->SetXY($posx, $posy);
2022 $pdf->SetTextColor(0, 0, 60);
2023 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
2024 }
2025 if ($object->type == 1) {
2026 $objectreplaced = new Facture($this->db);
2027 $objectreplaced->fetch($object->fk_facture_source);
2028
2029 $posy += 4;
2030 $pdf->SetXY($posx, $posy);
2031 $pdf->SetTextColor(0, 0, 60);
2032 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
2033 }
2034 if ($object->type == 2 && !empty($object->fk_facture_source)) {
2035 $objectreplaced = new Facture($this->db);
2036 $objectreplaced->fetch($object->fk_facture_source);
2037
2038 $posy += 3;
2039 $pdf->SetXY($posx, $posy);
2040 $pdf->SetTextColor(0, 0, 60);
2041 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
2042 }
2043
2044 $posy += 4;
2045 $pdf->SetXY($posx, $posy);
2046 $pdf->SetTextColor(0, 0, 60);
2047 $title = $outputlangs->transnoentities("DateInvoice");
2048 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2049 $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
2050 }
2051 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
2052
2053 if (getDolGlobalString('INVOICE_POINTOFTAX_DATE')) {
2054 $posy += 4;
2055 $pdf->SetXY($posx, $posy);
2056 $pdf->SetTextColor(0, 0, 60);
2057 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R');
2058 }
2059
2060 if ($object->type != 2) {
2061 $posy += 3;
2062 $pdf->SetXY($posx, $posy);
2063 $pdf->SetTextColor(0, 0, 60);
2064 $title = $outputlangs->transnoentities("DateDue");
2065 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2066 $title .= ' - '.$outputlangsbis->transnoentities("DateDue");
2067 }
2068 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
2069 }
2070
2071 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
2072 $posy += 3;
2073 $pdf->SetXY($posx, $posy);
2074 $pdf->SetTextColor(0, 0, 60);
2075 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
2076 }
2077
2078 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && $object->thirdparty->code_compta_client) {
2079 $posy += 3;
2080 $pdf->SetXY($posx, $posy);
2081 $pdf->SetTextColor(0, 0, 60);
2082 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_compta_client), '', 'R');
2083 }
2084
2085 // Get contact
2086 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
2087 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
2088 if (count($arrayidcontact) > 0) {
2089 $usertmp = new User($this->db);
2090 $usertmp->fetch($arrayidcontact[0]);
2091 $posy += 4;
2092 $pdf->SetXY($posx, $posy);
2093 $pdf->SetTextColor(0, 0, 60);
2094 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
2095 }
2096 }
2097
2098 $posy += 1;
2099
2100 $top_shift = 0;
2101 // Show list of linked objects
2102 $current_y = $pdf->getY();
2103 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
2104 if ($current_y < $pdf->getY()) {
2105 $top_shift = $pdf->getY() - $current_y;
2106 }
2107
2108 if ($showaddress) {
2109 // Sender properties
2110 $carac_emetteur = '';
2111 // Add internal contact of object if defined
2112 $arrayidcontact = $object->getIdContact('internal', 'BILLING');
2113 if (count($arrayidcontact) > 0) {
2114 $object->fetch_user($arrayidcontact[0]);
2115 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
2116 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
2117 $carac_emetteur .= "\n";
2118 }
2119
2120 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
2121
2122 // Show sender
2123 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
2124 $posy += $top_shift;
2125 $posx = $this->marge_gauche;
2126 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
2127 $posx = $this->page_largeur - $this->marge_droite - 80;
2128 }
2129
2130 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
2131 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
2132
2133
2134 // Show sender frame
2135 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
2136 $pdf->SetTextColor(0, 0, 0);
2137 $pdf->SetFont('', '', $default_font_size - 2);
2138 $pdf->SetXY($posx, $posy - 5);
2139 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
2140 $pdf->SetXY($posx, $posy);
2141 $pdf->SetFillColor(230, 230, 230);
2142 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
2143 $pdf->SetTextColor(0, 0, 60);
2144 }
2145
2146 // Show sender name
2147 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
2148 $pdf->SetXY($posx + 2, $posy + 3);
2149 $pdf->SetFont('', 'B', $default_font_size);
2150 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2151 $posy = $pdf->getY();
2152 }
2153
2154 // Show sender information
2155 $pdf->SetXY($posx + 2, $posy);
2156 $pdf->SetFont('', '', $default_font_size - 1);
2157 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2158
2159
2160 // If BILLING contact defined on invoice, we use it
2161 $usecontact = false;
2162 $arrayidcontact = $object->getIdContact('external', 'BILLING');
2163 if (count($arrayidcontact) > 0) {
2164 $usecontact = true;
2165 $result = $object->fetch_contact($arrayidcontact[0]);
2166 }
2167
2168 // Recipient name
2169 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2170 $thirdparty = $object->contact;
2171 } else {
2172 $thirdparty = $object->thirdparty;
2173 }
2174
2175 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
2176
2177 $mode = 'target';
2178 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), $mode, $object);
2179
2180 // Show recipient
2181 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
2182 if ($this->page_largeur < 210) {
2183 $widthrecbox = 84; // To work with US executive format
2184 }
2185 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
2186 $posy += $top_shift;
2187 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2188 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
2189 $posx = $this->marge_gauche;
2190 }
2191
2192 // Show recipient frame
2193 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
2194 $pdf->SetTextColor(0, 0, 0);
2195 $pdf->SetFont('', '', $default_font_size - 2);
2196 $pdf->SetXY($posx + 2, $posy - 5);
2197 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
2198 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
2199 }
2200
2201 // Show recipient name
2202 $pdf->SetXY($posx + 2, $posy + 3);
2203 $pdf->SetFont('', 'B', $default_font_size);
2204 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2205 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2206
2207 $posy = $pdf->getY();
2208
2209 // Show recipient information
2210 $pdf->SetFont('', '', $default_font_size - 1);
2211 $pdf->SetXY($posx + 2, $posy);
2212 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2213 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2214
2215 // Show shipping address
2216 if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) {
2217 $idaddressshipping = $object->getIdContact('external', 'SHIPPING');
2218
2219 if (!empty($idaddressshipping)) {
2220 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2221 $companystatic = new Societe($this->db);
2222 $companystatic->fetch($object->contact->fk_soc);
2223 $carac_client_name_shipping = pdfBuildThirdpartyName($object->contact, $outputlangs);
2224 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, ($usecontact ? 1 : 0), 'target', $object);
2225 } else {
2226 $carac_client_name_shipping = pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
2227 $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
2228 }
2229 if (!empty($carac_client_shipping)) {
2230 $posy += $hautcadre;
2231
2232 $hautcadre -= 10; // Height for the shipping address does not need to be as high as main box
2233
2234 // Show shipping frame
2235 $pdf->SetXY($posx + 2, $posy - 5);
2236 $pdf->SetFont('', '', $default_font_size - 2);
2237 $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0);
2238 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
2239
2240 // Show shipping name
2241 $pdf->SetXY($posx + 2, $posy + 3);
2242 $pdf->SetFont('', 'B', $default_font_size);
2243 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L');
2244
2245 $posy = $pdf->getY();
2246
2247 // Show shipping information
2248 $pdf->SetXY($posx + 2, $posy);
2249 $pdf->SetFont('', '', $default_font_size - 1);
2250 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L');
2251
2252 $top_shift += $hautcadre + 10;
2253 }
2254 }
2255 }
2256
2257 $pdf->SetTextColor(0, 0, 0);
2258
2259 return $top_shift;
2260 }
2261
2262 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
2273 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0)
2274 {
2275 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2276
2277 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);
2278 }
2279}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage bank accounts.
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
Class to manage bank accounts description of third parties.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
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 generate the customer invoice PDF with template Crabe.
__construct($db)
Constructor.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
_tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter=0)
Show payments table.
_tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
Show miscellaneous information (payment mode, payment term, ...)
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0, $heightforqrinvoice=0)
Show footer of page.
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
Function _tableau_versements_header.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
Show total to pay.
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...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
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.
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...
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_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0, $align='J')
Output line description into PDF.
Definition pdf.lib.php:1442
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_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