dolibarr 21.0.0-beta
pdf_zenith.modules.php
1<?php
2/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
5 * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
7 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
8 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Nick Fragoulis
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 * or see https://www.gnu.org/
25 */
26
33require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
34require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
35require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
39
40
45{
49 public $db;
50
54 public $name;
55
59 public $description;
60
64 public $update_main_doc_field;
65
69 public $type;
70
75 public $version = 'dolibarr';
76
77
83 public function __construct($db)
84 {
85 global $conf, $langs, $mysoc;
86
87 // Load translation files required by the page
88 $langs->loadLangs(array("main", "bills"));
89
90 $this->db = $db;
91 $this->name = "zenith";
92 $this->description = $langs->trans('DocModelZenithDescription');
93 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
94
95 // Page size for A4 format
96 $this->type = 'pdf';
97 $formatarray = pdf_getFormat();
98 $this->page_largeur = $formatarray['width'];
99 $this->page_hauteur = $formatarray['height'];
100 $this->format = array($this->page_largeur, $this->page_hauteur);
101 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
102 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
103 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
104 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
105 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
106 $this->option_logo = 1; // Display logo
107 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
108 $this->option_modereg = 1; // Display payment mode
109 $this->option_condreg = 1; // Display payment terms
110 $this->option_multilang = 1; //Available in several languages
111 $this->option_escompte = 0; // Displays if there has been a discount
112 $this->option_credit_note = 0; // Support credit notes
113 $this->option_freetext = 1; // Support add of a personalised text
114 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
115
116 // Define position of columns
117 $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support during PDF transition: TODO remove this at the end
118
119 $this->tabTitleHeight = 5; // default height
120
121 $this->tva = array();
122 $this->tva_array = array();
123 $this->localtax1 = array();
124 $this->localtax2 = array();
125 $this->atleastoneratenotnull = 0;
126 $this->atleastonediscount = 0;
127
128 if ($mysoc === null) {
129 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
130 return;
131 }
132
133 // Get source company
134 $this->emetteur = $mysoc;
135 if (empty($this->emetteur->country_code)) {
136 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
137 }
138 }
139
140
141 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
153 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
154 {
155 // phpcs:enable
156 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
157
158 if (!is_object($outputlangs)) {
159 $outputlangs = $langs;
160 }
161 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
162 if (getDolGlobalString('MAIN_USE_FPDF')) {
163 $outputlangs->charset_output = 'ISO-8859-1';
164 }
165
166 // Load translation files required by the page
167 $outputlangs->loadLangs(array("main", "supplier_proposal", "companies", "bills", "dict", "products"));
168
169 global $outputlangsbis;
170 $outputlangsbis = null;
171 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
172 $outputlangsbis = new Translate('', $conf);
173 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
174 $outputlangsbis->loadLangs(array("main", "supplier_proposal", "companies", "bills", "dict", "products"));
175 }
176
177 $nblines = count($object->lines);
178
179 $hidetop = 0;
180 if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
181 $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
182 }
183
184 // Loop on each lines to detect if there is at least one image to show
185 $realpatharray = array();
186 if (getDolGlobalString('MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE')) {
187 for ($i = 0; $i < $nblines; $i++) {
188 if (empty($object->lines[$i]->fk_product)) {
189 continue;
190 }
191
192 $objphoto = new Product($this->db);
193 $objphoto->fetch($object->lines[$i]->fk_product);
194
195 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
196 $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
197 $dir = $conf->product->dir_output.'/'.$pdir;
198 } else {
199 $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product');
200 $dir = $conf->product->dir_output.'/'.$pdir;
201 }
202
203 $realpath = '';
204 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
205 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
206 if ($obj['photo_vignette']) {
207 $filename = $obj['photo_vignette'];
208 } else {
209 $filename = $obj['photo'];
210 }
211 } else {
212 $filename = $obj['photo'];
213 }
214 $realpath = $dir.$filename;
215 break;
216 }
217
218 if ($realpath) {
219 $realpatharray[$i] = $realpath;
220 }
221 }
222 }
223 if (count($realpatharray) == 0) {
224 $this->posxpicture = $this->posxtva;
225 }
226
227 if ($conf->supplier_proposal->dir_output) {
228 $object->fetch_thirdparty();
229
230 $deja_regle = 0;
231 $amount_credit_notes_included = 0;
232 $amount_deposits_included = 0;
233 //$amount_credit_notes_included = $object->getSumCreditNotesUsed();
234 //$amount_deposits_included = $object->getSumDepositsUsed();
235
236 // Definition of $dir and $file
237 if ($object->specimen) {
238 $dir = $conf->supplier_proposal->dir_output;
239 $file = $dir."/SPECIMEN.pdf";
240 } else {
241 $objectref = dol_sanitizeFileName($object->ref);
242 $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
243 $dir = $conf->supplier_proposal->dir_output.'/'.$objectref;
244 $file = $dir."/".$objectref.".pdf";
245 if (getDolGlobalString('SUPPLIER_REF_IN_NAME')) {
246 $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
247 }
248 }
249
250 if (!file_exists($dir)) {
251 if (dol_mkdir($dir) < 0) {
252 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
253 return 0;
254 }
255 }
256
257 if (file_exists($dir)) {
258 // Add pdfgeneration hook
259 if (!is_object($hookmanager)) {
260 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
261 $hookmanager = new HookManager($this->db);
262 }
263 $hookmanager->initHooks(array('pdfgeneration'));
264 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
265 global $action;
266 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
267
268 $nblines = count($object->lines);
269
270 $pdf = pdf_getInstance($this->format);
271 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
272 $heightforinfotot = 50; // Height reserved to output the info and total part
273 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
274 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
275 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
276 $heightforfooter += 6;
277 }
278 $pdf->SetAutoPageBreak(1, 0);
279
280 if (class_exists('TCPDF')) {
281 $pdf->setPrintHeader(false);
282 $pdf->setPrintFooter(false);
283 }
284 $pdf->SetFont(pdf_getPDFFont($outputlangs));
285 // Set path to the background PDF File
286 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
287 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
288 $tplidx = $pdf->importPage(1);
289 }
290
291 $pdf->Open();
292 $pagenb = 0;
293 $pdf->SetDrawColor(128, 128, 128);
294
295 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
296 $pdf->SetSubject($outputlangs->transnoentities("SupplierProposal"));
297 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
298 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
299 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SupplierProposal")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
300 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
301 $pdf->SetCompression(false);
302 }
303
304 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
305 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
306
307 // Does we have at least one line with discount $this->atleastonediscount
308 foreach ($object->lines as $line) {
309 if ($line->remise_percent) {
310 $this->atleastonediscount = true;
311 break;
312 }
313 }
314
315 // New page
316 $pdf->AddPage();
317 if (!empty($tplidx)) {
318 $pdf->useTemplate($tplidx);
319 }
320 $pagenb++;
321 $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
322 $pdf->SetFont('', '', $default_font_size - 1);
323 $pdf->MultiCell(0, 3, ''); // Set interline to 3
324 $pdf->SetTextColor(0, 0, 0);
325
326 $tab_top = 90 + $top_shift;
327 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
328
329 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
330
331 // Incoterm
332 if (isModEnabled('incoterm')) {
333 $desc_incoterms = $object->getIncotermsForPDF();
334 if ($desc_incoterms) {
335 $tab_top -= 2;
336
337 $pdf->SetFont('', '', $default_font_size - 1);
338 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
339 $nexY = $pdf->GetY();
340 $height_incoterms = $nexY - $tab_top;
341
342 // Rect takes a length in 3rd parameter
343 $pdf->SetDrawColor(192, 192, 192);
344 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D');
345
346 $tab_top = $nexY + 6;
347 }
348 }
349
350 // Affiche notes
351 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
352
353 // Extrafields in note
354 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
355 if (!empty($extranote)) {
356 $notetoshow = dol_concatdesc($notetoshow, $extranote);
357 }
358
359 $pagenb = $pdf->getPage();
360 if ($notetoshow) {
361 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
362 $pageposbeforenote = $pagenb;
363
364 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
365 complete_substitutions_array($substitutionarray, $outputlangs, $object);
366 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
367 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
368
369 $tab_top -= 2;
370
371 $pdf->startTransaction();
372
373 $pdf->SetFont('', '', $default_font_size - 1);
374 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
375 // Description
376 $pageposafternote = $pdf->getPage();
377 $posyafter = $pdf->GetY();
378
379 if ($pageposafternote > $pageposbeforenote) {
380 $pdf->rollbackTransaction(true);
381
382 // prepar pages to receive notes
383 while ($pagenb < $pageposafternote) {
384 $pdf->AddPage();
385 $pagenb++;
386 if (!empty($tplidx)) {
387 $pdf->useTemplate($tplidx);
388 }
389 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
390 $this->_pagehead($pdf, $object, 0, $outputlangs);
391 }
392 // $this->_pagefoot($pdf,$object,$outputlangs,1);
393 $pdf->setTopMargin($tab_top_newpage);
394 // The only function to edit the bottom margin of current page to set it.
395 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
396 }
397
398 // back to start
399 $pdf->setPage($pageposbeforenote);
400 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
401 $pdf->SetFont('', '', $default_font_size - 1);
402 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
403 $pageposafternote = $pdf->getPage();
404
405 $posyafter = $pdf->GetY();
406
407 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
408 $pdf->AddPage('', '', true);
409 $pagenb++;
410 $pageposafternote++;
411 $pdf->setPage($pageposafternote);
412 $pdf->setTopMargin($tab_top_newpage);
413 // The only function to edit the bottom margin of current page to set it.
414 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
415 //$posyafter = $tab_top_newpage;
416 }
417
418
419 // apply note frame to previous pages
420 $i = $pageposbeforenote;
421 while ($i < $pageposafternote) {
422 $pdf->setPage($i);
423
424
425 $pdf->SetDrawColor(128, 128, 128);
426 // Draw note frame
427 if ($i > $pageposbeforenote) {
428 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
429 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
430 } else {
431 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
432 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
433 }
434
435 // Add footer
436 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
437 $this->_pagefoot($pdf, $object, $outputlangs, 1);
438
439 $i++;
440 }
441
442 // apply note frame to last page
443 $pdf->setPage($pageposafternote);
444 if (!empty($tplidx)) {
445 $pdf->useTemplate($tplidx);
446 }
447 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
448 $this->_pagehead($pdf, $object, 0, $outputlangs);
449 }
450 $height_note = $posyafter - $tab_top_newpage;
451 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
452 } else {
453 // No pagebreak
454 $pdf->commitTransaction();
455 $posyafter = $pdf->GetY();
456 $height_note = $posyafter - $tab_top;
457 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
458
459
460 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
461 // not enough space, need to add page
462 $pdf->AddPage('', '', true);
463 $pagenb++;
464 $pageposafternote++;
465 $pdf->setPage($pageposafternote);
466 if (!empty($tplidx)) {
467 $pdf->useTemplate($tplidx);
468 }
469 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
470 $this->_pagehead($pdf, $object, 0, $outputlangs);
471 }
472
473 $posyafter = $tab_top_newpage;
474 }
475 }
476
477 $tab_height -= $height_note;
478 $tab_top = $posyafter + 6;
479 } else {
480 $height_note = 0;
481 }
482
483 // Use new auto column system
484 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
485
486 $nexY = $tab_top + $this->tabTitleHeight;
487
488 // Loop on each lines
489 $pageposbeforeprintlines = $pdf->getPage();
490 $pagenb = $pageposbeforeprintlines;
491 for ($i = 0; $i < $nblines; $i++) {
492 $curY = $nexY;
493 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
494 $pdf->SetTextColor(0, 0, 0);
495
496 // Define size of image if we need it
497 $imglinesize = array();
498 if (!empty($realpatharray[$i])) {
499 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
500 }
501
502 $pdf->setTopMargin($tab_top_newpage);
503 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
504 $pageposbefore = $pdf->getPage();
505
506 $showpricebeforepagebreak = 1;
507 $posYAfterImage = 0;
508 $posYAfterDescription = 0;
509
510 // We start with Photo of product line
511 if ($this->getColumnStatus('photo')) {
512 // We start with Photo of product line
513 if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
514 $pdf->AddPage('', '', true);
515 if (!empty($tplidx)) {
516 $pdf->useTemplate($tplidx);
517 }
518 $pdf->setPage($pageposbefore + 1);
519
520 $curY = $tab_top_newpage;
521
522 // Allows data in the first page if description is long enough to break in multiples pages
523 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
524 $showpricebeforepagebreak = 1;
525 } else {
526 $showpricebeforepagebreak = 0;
527 }
528 }
529
530 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
531 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
532 // $pdf->Image does not increase value return by getY, so we save it manually
533 $posYAfterImage = $curY + $imglinesize['height'];
534 }
535 }
536 // Description of product line
537 $curX = $this->posxdesc - 1;
538 $showpricebeforepagebreak = 1;
539
540 if ($this->getColumnStatus('desc')) {
541 $pdf->startTransaction();
542 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
543
544 $pageposafter = $pdf->getPage();
545 if ($pageposafter > $pageposbefore) { // There is a pagebreak
546 $pdf->rollbackTransaction(true);
547
548 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
549
550 $pageposafter = $pdf->getPage();
551 $posyafter = $pdf->GetY();
552 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
553 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
554 $pdf->AddPage('', '', true);
555 if (!empty($tplidx)) {
556 $pdf->useTemplate($tplidx);
557 }
558 //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
559 $pdf->setPage($pageposafter + 1);
560 }
561 } else {
562 // We found a page break
563 // Allows data in the first page if description is long enough to break in multiples pages
564 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
565 $showpricebeforepagebreak = 1;
566 } else {
567 $showpricebeforepagebreak = 0;
568 }
569 }
570 } else { // No pagebreak
571 $pdf->commitTransaction();
572 }
573 $posYAfterDescription = $pdf->GetY();
574 }
575
576 $nexY = $pdf->GetY();
577 $pageposafter = $pdf->getPage();
578 $pdf->setPage($pageposbefore);
579 $pdf->setTopMargin($this->marge_haute);
580 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
581
582 // We suppose that a too long description is moved completely on next page
583 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
584 $pdf->setPage($pageposafter);
585 $curY = $tab_top_newpage;
586 }
587
588 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default
589
590 // VAT Rate
591 if ($this->getColumnStatus('vat')) {
592 $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
593 $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
594 $nexY = max($pdf->GetY(), $nexY);
595 }
596
597 // Unit price before discount
598 if ($this->getColumnStatus('subprice')) {
599 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
600 $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
601 $nexY = max($pdf->GetY(), $nexY);
602 }
603
604 // Quantity
605 // Enough for 6 chars
606 if ($this->getColumnStatus('qty')) {
607 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
608 $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
609 $nexY = max($pdf->GetY(), $nexY);
610 }
611
612
613 // Unit
614 if ($this->getColumnStatus('unit')) {
615 $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails);
616 $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
617 $nexY = max($pdf->GetY(), $nexY);
618 }
619
620 // Discount on line
621 if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
622 $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
623 $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
624 $nexY = max($pdf->GetY(), $nexY);
625 }
626
627 // Total HT line
628 if ($this->getColumnStatus('totalexcltax')) {
629 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
630 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
631 $nexY = max($pdf->GetY(), $nexY);
632 }
633
634 // Extrafields
635 if (!empty($object->lines[$i]->array_options)) {
636 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
637 if ($this->getColumnStatus($extrafieldColKey)) {
638 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
639 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
640 $nexY = max($pdf->GetY(), $nexY);
641 }
642 }
643 }
644
645 $parameters = array(
646 'object' => $object,
647 'i' => $i,
648 'pdf' => & $pdf,
649 'curY' => & $curY,
650 'nexY' => & $nexY,
651 'outputlangs' => $outputlangs,
652 'hidedetails' => $hidedetails
653 );
654 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
655
656
657 // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
658 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
659 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
660 } else {
661 $tvaligne = $object->lines[$i]->total_tva;
662 }
663
664 $localtax1ligne = $object->lines[$i]->total_localtax1;
665 $localtax2ligne = $object->lines[$i]->total_localtax2;
666 $localtax1_rate = $object->lines[$i]->localtax1_tx;
667 $localtax2_rate = $object->lines[$i]->localtax2_tx;
668 $localtax1_type = $object->lines[$i]->localtax1_type;
669 $localtax2_type = $object->lines[$i]->localtax2_type;
670
671 // TODO remise_percent is an obsolete field for object parent
672 /*if (!empty($object->remise_percent)) {
673 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
674 }
675 if (!empty($object->remise_percent)) {
676 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
677 }
678 if (!empty($object->remise_percent)) {
679 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
680 }*/
681
682 $vatrate = (string) $object->lines[$i]->tva_tx;
683
684 // Retrieve type from database for backward compatibility with old records
685 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
686 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
687 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
688 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
689 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
690 }
691
692 // retrieve global local tax
693 if ($localtax1_type && $localtax1ligne != 0) {
694 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
695 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
696 } else {
697 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
698 }
699 }
700 if ($localtax2_type && $localtax2ligne != 0) {
701 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
702 $this->localtax2[$localtax2_type][$localtax2_rate] = (float) $localtax2ligne;
703 } else {
704 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
705 }
706 }
707
708 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
709 $vatrate .= '*';
710 }
711
712 // Fill $this->tva and $this->tva_array
713 if (!isset($this->tva[$vatrate])) {
714 $this->tva[$vatrate] = 0;
715 }
716 $this->tva[$vatrate] += $tvaligne;
717 $vatcode = $object->lines[$i]->vat_src_code;
718 if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
719 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
720 }
721 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
722
723 if ($posYAfterImage > $posYAfterDescription) {
724 $nexY = $posYAfterImage;
725 }
726
727 // Add line
728 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
729 $pdf->setPage($pageposafter);
730 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
731 //$pdf->SetDrawColor(190,190,200);
732 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
733 $pdf->SetLineStyle(array('dash' => 0));
734 }
735
736 // Detect if some page were added automatically and output _tableau for past pages
737 while ($pagenb < $pageposafter) {
738 $pdf->setPage($pagenb);
739 if ($pagenb == $pageposbeforeprintlines) {
740 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
741 } else {
742 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
743 }
744 $this->_pagefoot($pdf, $object, $outputlangs, 1);
745 $pagenb++;
746 $pdf->setPage($pagenb);
747 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
748 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
749 $this->_pagehead($pdf, $object, 0, $outputlangs);
750 }
751 if (!empty($tplidx)) {
752 $pdf->useTemplate($tplidx);
753 }
754 }
755 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
756 if ($pagenb == $pageposafter) {
757 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
758 } else {
759 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
760 }
761 $this->_pagefoot($pdf, $object, $outputlangs, 1);
762 // New page
763 $pdf->AddPage();
764 if (!empty($tplidx)) {
765 $pdf->useTemplate($tplidx);
766 }
767 $pagenb++;
768 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
769 $this->_pagehead($pdf, $object, 0, $outputlangs);
770 }
771 }
772 }
773
774 // Show square
775 if ($pagenb == $pageposbeforeprintlines) {
776 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
777 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
778 } else {
779 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
780 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
781 }
782
783 // Affiche zone infos
784 $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
785
786 // Affiche zone totaux
787 $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
788
789 // Affiche zone versements
790 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
791 $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
792 }
793
794 // Pied de page
795 $this->_pagefoot($pdf, $object, $outputlangs);
796 if (method_exists($pdf, 'AliasNbPages')) {
797 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
798 }
799
800 $pdf->Close();
801
802 $pdf->Output($file, 'F');
803
804 // Add pdfgeneration hook
805 $hookmanager->initHooks(array('pdfgeneration'));
806 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
807 global $action;
808 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
809 if ($reshook < 0) {
810 $this->error = $hookmanager->error;
811 $this->errors = $hookmanager->errors;
812 }
813
814 dolChmod($file);
815
816 $this->result = array('fullpath' => $file);
817
818 return 1; // No error
819 } else {
820 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
821 return 0;
822 }
823 } else {
824 $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
825 return 0;
826 }
827 }
828
829 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
830 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
840 protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
841 {
842 // phpcs:enable
843 return 1;
844 }
845
846 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
847 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
857 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
858 {
859 // phpcs:enable
860 global $conf, $mysoc;
861 $default_font_size = pdf_getPDFFontSize($outputlangs);
862
863 $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
864
865 // If France, show VAT mention if not applicable
866 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
867 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
868 $pdf->SetXY($this->marge_gauche, $posy);
869 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
870
871 $posy = $pdf->GetY() + 4;
872 }
873
874 $posxval = 52;
875
876 // Show payments conditions
877 if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
878 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
879 $pdf->SetXY($this->marge_gauche, $posy);
880 $titre = $outputlangs->transnoentities("PaymentConditions").':';
881 $pdf->MultiCell(80, 4, $titre, 0, 'L');
882
883 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
884 $pdf->SetXY($posxval, $posy);
885 $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);
886 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
887 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
888
889 $posy = $pdf->GetY() + 3;
890 }
891
892 // Show payment mode
893 if (!empty($object->mode_reglement_code)) {
894 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
895 $pdf->SetXY($this->marge_gauche, $posy);
896 $titre = $outputlangs->transnoentities("PaymentMode").':';
897 $pdf->MultiCell(80, 5, $titre, 0, 'L');
898
899 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
900 $pdf->SetXY($posxval, $posy);
901 $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);
902 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
903
904 $posy = $pdf->GetY() + 2;
905 }
906
907
908 return $posy;
909 }
910
911 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
912 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
923 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
924 {
925 // phpcs:enable
926 global $conf, $mysoc;
927
928 $default_font_size = pdf_getPDFFontSize($outputlangs);
929
930 $tab2_top = $posy;
931 $tab2_hl = 4;
932 $pdf->SetFont('', '', $default_font_size - 1);
933
934 // Tableau total
935 $col1x = 120;
936 $col2x = 170;
937 if ($this->page_largeur < 210) { // To work with US executive format
938 $col2x -= 20;
939 }
940 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941
942 $useborder = 0;
943 $index = 0;
944
945 // Total HT
946 $pdf->SetFillColor(255, 255, 255);
947 $pdf->SetXY($col1x, $tab2_top);
948 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
949
950 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
951 $pdf->SetXY($col2x, $tab2_top);
952 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
953
954 // Show VAT by rates and total
955 $pdf->SetFillColor(248, 248, 248);
956
957 $this->atleastoneratenotnull = 0;
958 foreach ($this->tva as $tvakey => $tvaval) {
959 if ($tvakey > 0) { // On affiche pas taux 0
960 $this->atleastoneratenotnull++;
961
962 $index++;
963 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
964
965 $tvacompl = '';
966
967 if (preg_match('/\*/', $tvakey)) {
968 $tvakey = str_replace('*', '', $tvakey);
969 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
970 }
971
972 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
973 $totalvat .= vatrate($tvakey, 1).$tvacompl;
974 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
975
976 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
977 $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
978 }
979 }
980 if (!$this->atleastoneratenotnull) { // If no vat at all
981 $index++;
982 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
984
985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
986 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
987
988 // Total LocalTax1
989 if (getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == 'localtax1on' && $object->total_localtax1 > 0) {
990 $index++;
991 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
992 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
993 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
994 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
995 }
996
997 // Total LocalTax2
998 if (getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == 'localtax2on' && $object->total_localtax2 > 0) {
999 $index++;
1000 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1001 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
1002 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1003 $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
1004 }
1005 } else {
1006 //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1007 //{
1008 //Local tax 1
1009 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1010 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1011 continue;
1012 }
1013
1014 foreach ($localtax_rate as $tvakey => $tvaval) {
1015 if ($tvakey != 0) { // On affiche pas taux 0
1016 //$this->atleastoneratenotnull++;
1017
1018 $index++;
1019 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1020
1021 $tvacompl = '';
1022 if (preg_match('/\*/', $tvakey)) {
1023 $tvakey = str_replace('*', '', $tvakey);
1024 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1025 }
1026 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1027 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1028 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1029
1030 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1031 $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1032 }
1033 }
1034 }
1035
1036 //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1037 //{
1038 //Local tax 2
1039 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1040 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1041 continue;
1042 }
1043
1044 foreach ($localtax_rate as $tvakey => $tvaval) {
1045 if ($tvakey != 0) { // On affiche pas taux 0
1046 //$this->atleastoneratenotnull++;
1047
1048 $index++;
1049 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1050
1051 $tvacompl = '';
1052 if (preg_match('/\*/', $tvakey)) {
1053 $tvakey = str_replace('*', '', $tvakey);
1054 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1055 }
1056 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1057 $totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
1058 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1059
1060 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1061 $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
1062 }
1063 }
1064 }
1065 }
1066
1067 // Total TTC
1068 $index++;
1069 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1070 $pdf->SetTextColor(0, 0, 60);
1071 $pdf->SetFillColor(224, 224, 224);
1072 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1073
1074 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1075 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1076 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
1077 $pdf->SetFont('', '', $default_font_size - 1);
1078 $pdf->SetTextColor(0, 0, 0);
1079
1080 $creditnoteamount = 0;
1081 $depositsamount = 0;
1082 //$creditnoteamount=$object->getSumCreditNotesUsed();
1083 //$depositsamount=$object->getSumDepositsUsed();
1084 //print "x".$creditnoteamount."-".$depositsamount;exit;
1085 $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086 if (!empty($object->paye)) {
1087 $resteapayer = 0;
1088 }
1089
1090 if ($deja_regle > 0) {
1091 // Already paid + Deposits
1092 $index++;
1093
1094 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1095 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1096 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1097 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
1098
1099 $index++;
1100 $pdf->SetTextColor(0, 0, 60);
1101 $pdf->SetFillColor(224, 224, 224);
1102 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1104
1105 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1106 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
1107
1108 $pdf->SetFont('', '', $default_font_size - 1);
1109 $pdf->SetTextColor(0, 0, 0);
1110 }
1111
1112 $index++;
1113 return ($tab2_top + ($tab2_hl * $index));
1114 }
1115
1116 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1130 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1131 {
1132 global $conf;
1133
1134 // Force to disable hidetop and hidebottom
1135 $hidebottom = 0;
1136 if ($hidetop) {
1137 $hidetop = -1;
1138 }
1139
1140 $currency = !empty($currency) ? $currency : $conf->currency;
1141 $default_font_size = pdf_getPDFFontSize($outputlangs);
1142
1143 // Amount in (at tab_top - 1)
1144 $pdf->SetTextColor(0, 0, 0);
1145 $pdf->SetFont('', '', $default_font_size - 2);
1146
1147 if (empty($hidetop)) {
1148 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1149 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1150 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1151
1152 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1153 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1154 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1155 }
1156 }
1157
1158 $pdf->SetDrawColor(128, 128, 128);
1159 $pdf->SetFont('', '', $default_font_size - 1);
1160
1161 // Output Rect
1162 $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter
1163
1164 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1165
1166 if (empty($hidetop)) {
1167 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
1168 }
1169 }
1170
1171 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1181 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1182 {
1183 global $langs, $conf, $mysoc;
1184
1185 $ltrdirection = 'L';
1186 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1187 $ltrdirection = 'R';
1188 }
1189
1190 // Load translation files required by the page
1191 $outputlangs->loadLangs(array("main", "supplier_proposal", "companies", "bills", "sendings"));
1192
1193 $default_font_size = pdf_getPDFFontSize($outputlangs);
1194
1195 // Do not add the BACKGROUND as this is for suppliers
1196 //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1197
1198 //Affiche le filigrane brouillon - Print Draft Watermark
1199 /*if($object->statut==0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK'))
1200 {
1201 pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
1202 }*/
1203 //Print content
1204
1205 $pdf->SetTextColor(0, 0, 60);
1206 $pdf->SetFont('', 'B', $default_font_size + 3);
1207
1208 $posx = $this->page_largeur - $this->marge_droite - 100;
1209 $posy = $this->marge_haute;
1210
1211 $pdf->SetXY($this->marge_gauche, $posy);
1212
1213 // Logo
1214 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1215 if ($this->emetteur->logo) {
1216 $logodir = $conf->mycompany->dir_output;
1217 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1218 $logodir = $conf->mycompany->multidir_output[$object->entity];
1219 }
1220 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1221 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1222 } else {
1223 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1224 }
1225 if (is_readable($logo)) {
1226 $height = pdf_getHeightForLogo($logo);
1227 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1228 } else {
1229 $pdf->SetTextColor(200, 0, 0);
1230 $pdf->SetFont('', 'B', $default_font_size - 2);
1231 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1232 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1233 }
1234 } else {
1235 $text = $this->emetteur->name;
1236 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1237 }
1238 }
1239
1240 $pdf->SetFont('', 'B', $default_font_size + 3);
1241 $pdf->SetXY($posx, $posy);
1242 $pdf->SetTextColor(0, 0, 60);
1243 $title = $outputlangs->transnoentities("SupplierProposal")." ".$outputlangs->convToOutputCharset($object->ref);
1244 $pdf->MultiCell(100, 3, $title, '', 'R');
1245 $posy += 1;
1246
1247 if ($object->ref_supplier) {
1248 $posy += 4;
1249 $pdf->SetFont('', 'B', $default_font_size);
1250 $pdf->SetXY($posx, $posy);
1251 $pdf->SetTextColor(0, 0, 60);
1252 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
1253 $posy += 1;
1254 }
1255
1256 $pdf->SetFont('', '', $default_font_size - 1);
1257
1258 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
1259 $object->fetchProject();
1260 if (!empty($object->project->ref)) {
1261 $posy += 3;
1262 $pdf->SetXY($posx, $posy);
1263 $pdf->SetTextColor(0, 0, 60);
1264 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1265 }
1266 }
1267
1268 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
1269 $object->fetchProject();
1270 if (!empty($object->project->ref)) {
1271 $outputlangs->load("projects");
1272 $posy += 4;
1273 $pdf->SetXY($posx, $posy);
1274 $langs->load("projects");
1275 $pdf->SetTextColor(0, 0, 60);
1276 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1277 }
1278 }
1279
1280 if (!empty($object->date)) {
1281 $posy += 5;
1282 $pdf->SetXY($posx, $posy);
1283 $pdf->SetTextColor(0, 0, 60);
1284 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1285 } else {
1286 $posy += 5;
1287 $pdf->SetXY($posx, $posy);
1288 $pdf->SetTextColor(255, 0, 0);
1289 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Draft"), '', 'R');
1290 }
1291
1292 $pdf->SetTextColor(0, 0, 60);
1293 $usehourmin = 'day';
1294 if (getDolGlobalString('SUPPLIER_PROPOSAL_USE_HOUR_FOR_DELIVERY_DATE')) {
1295 $usehourmin = 'dayhour';
1296 }
1297 if (!empty($object->delivery_date)) {
1298 $posy += 4;
1299 $pdf->SetXY($posx - 90, $posy);
1300 $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R');
1301 }
1302
1303 if ($object->thirdparty->code_fournisseur) {
1304 $posy += 4;
1305 $pdf->SetXY($posx, $posy);
1306 $pdf->SetTextColor(0, 0, 60);
1307 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1308 }
1309
1310 // Get contact
1311 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
1312 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1313
1314 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1315 $usertmp = new User($this->db);
1316 $usertmp->fetch($arrayidcontact[0]);
1317 $posy += 4;
1318 $pdf->SetXY($posx, $posy);
1319 $pdf->SetTextColor(0, 0, 60);
1320 $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1321 }
1322 }
1323
1324 $posy += 1;
1325 $pdf->SetTextColor(0, 0, 60);
1326
1327 $top_shift = 0;
1328 // Show list of linked objects
1329 $current_y = $pdf->getY();
1330 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1331 if ($current_y < $pdf->getY()) {
1332 $top_shift = $pdf->getY() - $current_y;
1333 }
1334
1335 if ($showaddress) {
1336 // Sender properties
1337 $carac_emetteur = '';
1338 // Add internal contact of object if defined
1339 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1340 if (count($arrayidcontact) > 0) {
1341 $object->fetch_user($arrayidcontact[0]);
1342 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1343 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1344 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1345 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1346 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1347 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1348 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1349 $carac_emetteur .= "\n";
1350 }
1351
1352 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1353
1354 // Show sender
1355 $posy = 42 + $top_shift;
1356 $posx = $this->marge_gauche;
1357 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1358 $posx = $this->page_largeur - $this->marge_droite - 80;
1359 }
1360 $hautcadre = 40;
1361
1362 // Show sender frame
1363 $pdf->SetTextColor(0, 0, 0);
1364 $pdf->SetFont('', '', $default_font_size - 2);
1365 $pdf->SetXY($posx, $posy - 5);
1366 $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1367 $pdf->SetXY($posx, $posy);
1368 $pdf->SetFillColor(230, 230, 230);
1369 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F');
1370 $pdf->SetTextColor(0, 0, 60);
1371
1372 // Show sender name
1373 $pdf->SetXY($posx + 2, $posy + 3);
1374 $pdf->SetFont('', 'B', $default_font_size);
1375 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1376 $posy = $pdf->getY();
1377
1378 // Show sender information
1379 $pdf->SetXY($posx + 2, $posy);
1380 $pdf->SetFont('', '', $default_font_size - 1);
1381 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1382
1383
1384
1385 // If CUSTOMER contact defined on proposal, we use it. Note: Even if this is a supplier object, the code for external contact that follow order is 'CUSTOMER'
1386 $usecontact = false;
1387 if (!getDolGlobalInt('SUPPLIER_PROPOSAL_ADD_BILLING_CONTACT')) {
1388 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1389 } else {
1390 $arrayidcontact = array_merge($object->getIdContact('external', 'CUSTOMER'), $object->getIdContact('external', 'BILLING'));
1391 }
1392 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1393 $usecontact = true;
1394 $result = $object->fetch_contact($arrayidcontact[0]);
1395 }
1396
1397 // Recipient name
1398 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1399 $thirdparty = $object->contact;
1400 } else {
1401 $thirdparty = $object->thirdparty;
1402 }
1403
1404 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1405
1406 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), ($usecontact ? 1 : 0), 'target', $object);
1407
1408 // Show recipient
1409 $widthrecbox = 100;
1410 if ($this->page_largeur < 210) {
1411 $widthrecbox = 84; // To work with US executive format
1412 }
1413 $posy = 42 + $top_shift;
1414 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1415 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1416 $posx = $this->marge_gauche;
1417 }
1418
1419 // Show recipient frame
1420 $pdf->SetTextColor(0, 0, 0);
1421 $pdf->SetFont('', '', $default_font_size - 2);
1422 $pdf->SetXY($posx + 2, $posy - 5);
1423 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1424 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1425
1426 // Show recipient name
1427 $pdf->SetXY($posx + 2, $posy + 3);
1428 $pdf->SetFont('', 'B', $default_font_size);
1429 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1430 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1431
1432 $posy = $pdf->getY();
1433
1434 // Show recipient information
1435 $pdf->SetFont('', '', $default_font_size - 1);
1436 $pdf->SetXY($posx + 2, $posy);
1437 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1438 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1439 }
1440
1441 return $top_shift;
1442 }
1443
1444 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1454 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1455 {
1456 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1457 return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1458 }
1459
1460
1461
1472 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1473 {
1474 global $conf, $hookmanager;
1475
1476 // Default field style for content
1477 $this->defaultContentsFieldsStyle = array(
1478 'align' => 'R', // R,C,L
1479 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1480 );
1481
1482 // Default field style for content
1483 $this->defaultTitlesFieldsStyle = array(
1484 'align' => 'C', // R,C,L
1485 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1486 );
1487
1488 $rank = 0; // do not use negative rank
1489 $this->cols['desc'] = array(
1490 'rank' => $rank,
1491 'width' => false, // only for desc
1492 'status' => true,
1493 'title' => array(
1494 'textkey' => 'Designation', // use lang key is useful in somme case with module
1495 'align' => 'L',
1496 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1497 // 'label' => ' ', // the final label
1498 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1499 ),
1500 'content' => array(
1501 'align' => 'L',
1502 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1503 ),
1504 );
1505
1506 $rank += 10;
1507 $this->cols['photo'] = array(
1508 'rank' => $rank,
1509 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
1510 'status' => false,
1511 'title' => array(
1512 'textkey' => 'Photo',
1513 'label' => ' '
1514 ),
1515 'content' => array(
1516 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1517 ),
1518 'border-left' => false, // remove left line separator
1519 );
1520
1521 if (getDolGlobalString('MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE')) {
1522 $this->cols['photo']['status'] = true;
1523 }
1524
1525
1526 $rank += 10;
1527 $this->cols['vat'] = array(
1528 'rank' => $rank,
1529 'status' => false,
1530 'width' => 16, // in mm
1531 'title' => array(
1532 'textkey' => 'VAT'
1533 ),
1534 'border-left' => true, // add left line separator
1535 );
1536
1537 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
1538 $this->cols['vat']['status'] = true;
1539 }
1540
1541 $rank += 10;
1542 $this->cols['subprice'] = array(
1543 'rank' => $rank,
1544 'width' => 19, // in mm
1545 'status' => false,
1546 'title' => array(
1547 'textkey' => 'PriceUHT'
1548 ),
1549 'border-left' => true, // add left line separator
1550 );
1551
1552 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE')) {
1553 $this->cols['subprice']['status'] = true;
1554 }
1555
1556 $rank += 10;
1557 $this->cols['qty'] = array(
1558 'rank' => $rank,
1559 'width' => 16, // in mm
1560 'status' => true,
1561 'title' => array(
1562 'textkey' => 'Qty'
1563 ),
1564 'border-left' => true, // add left line separator
1565 );
1566
1567 $rank += 10;
1568 $this->cols['unit'] = array(
1569 'rank' => $rank,
1570 'width' => 11, // in mm
1571 'status' => false,
1572 'title' => array(
1573 'textkey' => 'Unit'
1574 ),
1575 'border-left' => true, // add left line separator
1576 );
1577 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1578 $this->cols['unit']['status'] = true;
1579 }
1580
1581 $rank += 10;
1582 $this->cols['discount'] = array(
1583 'rank' => $rank,
1584 'width' => 13, // in mm
1585 'status' => false,
1586 'title' => array(
1587 'textkey' => 'ReductionShort'
1588 ),
1589 'border-left' => true, // add left line separator
1590 );
1591 if ($this->atleastonediscount) {
1592 $this->cols['discount']['status'] = true;
1593 }
1594
1595 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1596 $this->cols['totalexcltax'] = array(
1597 'rank' => $rank,
1598 'width' => 26, // in mm
1599 'status' => false,
1600 'title' => array(
1601 'textkey' => 'TotalHT'
1602 ),
1603 'border-left' => true, // add left line separator
1604 );
1605
1606 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN')) {
1607 $this->cols['totalexcltax']['status'] = true;
1608 }
1609
1610 // Add extrafields cols
1611 if (!empty($object->lines)) {
1612 $line = reset($object->lines);
1613 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1614 }
1615
1616 $parameters = array(
1617 'object' => $object,
1618 'outputlangs' => $outputlangs,
1619 'hidedetails' => $hidedetails,
1620 'hidedesc' => $hidedesc,
1621 'hideref' => $hideref
1622 );
1623
1624 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1625 if ($reshook < 0) {
1626 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1627 } elseif (empty($reshook)) {
1628 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1629 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1630 } else {
1631 $this->cols = $hookmanager->resArray;
1632 }
1633 }
1634}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Class to manage hooks.
Perent class of the Proposal models.
Class to manage products or services.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate the supplier proposals with the zenith model.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct($db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:2648
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition pdf.lib.php:2382
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:288
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:313
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1027
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2000
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:1938
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1405
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:265
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:434
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
Definition pdf.lib.php:2245
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2288
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2085
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:765
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:386
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152