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