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