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