dolibarr 20.0.2
pdf_eratosthene.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5 * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7 * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
10 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
12 * Copyright (C) 2024 Nick Fragoulis
13 * Copyright (C) 2024 Joachim Kueter <git-jk@bloxera.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 * or see https://www.gnu.org/
28 */
29
36require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
37require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
41
42
47{
51 public $db;
52
56 public $entity;
57
61 public $name;
62
66 public $description;
67
71 public $update_main_doc_field;
72
76 public $type;
77
82 public $version = 'dolibarr';
83
87 public $cols;
88
89
95 public function __construct(DoliDB $db)
96 {
97 global $conf, $langs, $mysoc;
98
99 // Translations
100 $langs->loadLangs(array("main", "bills", "products"));
101
102 $this->db = $db;
103 $this->name = "eratosthene";
104 $this->description = $langs->trans('PDFEratostheneDescription');
105 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
106
107 // Dimension page
108 $this->type = 'pdf';
109 $formatarray = pdf_getFormat();
110 $this->page_largeur = $formatarray['width'];
111 $this->page_hauteur = $formatarray['height'];
112 $this->format = array($this->page_largeur, $this->page_hauteur);
113 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
114 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
115 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
116 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
117
118 $this->option_logo = 1; // Display logo
119 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
120 $this->option_modereg = 1; // Display payment mode
121 $this->option_condreg = 1; // Display payment terms
122 $this->option_multilang = 1; // Available in several languages
123 $this->option_escompte = 0; // Displays if there has been a discount
124 $this->option_credit_note = 0; // Support credit notes
125 $this->option_freetext = 1; // Support add of a personalised text
126 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
127 $this->watermark = '';
128
129 // Get source company
130 $this->emetteur = $mysoc;
131 if (empty($this->emetteur->country_code)) {
132 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
133 }
134
135 // Define position of columns
136 $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff
137
138
139 $this->tabTitleHeight = 5; // default height
140
141 // Use new system for position of columns, view $this->defineColumnField()
142
143 $this->tva = array();
144 $this->tva_array = array();
145 $this->localtax1 = array();
146 $this->localtax2 = array();
147 $this->atleastoneratenotnull = 0;
148 $this->atleastonediscount = 0;
149 }
150
151 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
163 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
164 {
165 // phpcs:enable
166 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
167
168 dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
169
170 if (!is_object($outputlangs)) {
171 $outputlangs = $langs;
172 }
173 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
174 if (getDolGlobalInt('MAIN_USE_FPDF')) {
175 $outputlangs->charset_output = 'ISO-8859-1';
176 }
177
178 // Load translation files required by the page
179 $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
180
181 // Show Draft Watermark
182 if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) {
183 $this->watermark = getDolGlobalString('COMMANDE_DRAFT_WATERMARK');
184 }
185
186 global $outputlangsbis;
187 $outputlangsbis = null;
188 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
189 $outputlangsbis = new Translate('', $conf);
190 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
191 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
192 }
193
194 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
195
196 $hidetop = 0;
197 if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
198 $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
199 }
200
201 // Loop on each lines to detect if there is at least one image to show
202 $realpatharray = array();
203 $this->atleastonephoto = false;
204 if (getDolGlobalInt('MAIN_GENERATE_ORDERS_WITH_PICTURE')) {
205 $objphoto = new Product($this->db);
206
207 for ($i = 0; $i < $nblines; $i++) {
208 if (empty($object->lines[$i]->fk_product)) {
209 continue;
210 }
211
212 $pdir = array();
213
214 $objphoto->fetch($object->lines[$i]->fk_product);
215 //var_dump($objphoto->ref);exit;
216 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
217 $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
218 $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
219 } else {
220 $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
221 $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
222 }
223
224 $arephoto = false;
225 foreach ($pdir as $midir) {
226 if (!$arephoto) {
227 if ($conf->entity != $objphoto->entity) {
228 $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
229 } else {
230 $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
231 }
232
233 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
234 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
235 if ($obj['photo_vignette']) {
236 $filename = $obj['photo_vignette'];
237 } else {
238 $filename = $obj['photo'];
239 }
240 } else {
241 $filename = $obj['photo'];
242 }
243
244 $realpath = $dir.$filename;
245 $arephoto = true;
246 $this->atleastonephoto = true;
247 }
248 }
249 }
250
251 if ($realpath && $arephoto) {
252 $realpatharray[$i] = $realpath;
253 }
254 }
255 }
256
257
258
260 $object->fetch_thirdparty();
261
262 $deja_regle = 0;
263
264 // Definition of $dir and $file
265 if ($object->specimen) {
267 $file = $dir."/SPECIMEN.pdf";
268 } else {
269 $objectref = dol_sanitizeFileName($object->ref);
270 $dir = getMultidirOutput($object)."/".$objectref;
271 $file = $dir."/".$objectref.".pdf";
272 }
273
274 if (!file_exists($dir)) {
275 if (dol_mkdir($dir) < 0) {
276 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
277 return 0;
278 }
279 }
280
281 if (file_exists($dir)) {
282 // Add pdfgeneration hook
283 if (!is_object($hookmanager)) {
284 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
285 $hookmanager = new HookManager($this->db);
286 }
287 $hookmanager->initHooks(array('pdfgeneration'));
288 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
289 global $action;
290 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
291
292 // Set nblines with the new lines content after hook
293 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
294
295 // Create pdf instance
296 $pdf = pdf_getInstance($this->format);
297 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
298 $pdf->SetAutoPageBreak(1, 0);
299
300 $heightforinfotot = 40; // Height reserved to output the info and total part
301 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
302 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
303 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
304 $heightforfooter += 6;
305 }
306
307 if (class_exists('TCPDF')) {
308 $pdf->setPrintHeader(false);
309 $pdf->setPrintFooter(false);
310 }
311 $pdf->SetFont(pdf_getPDFFont($outputlangs));
312 // Set path to the background PDF File
313 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
314 $logodir = $conf->mycompany->dir_output;
315 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
316 $logodir = $conf->mycompany->multidir_output[$object->entity];
317 }
318 $pagecount = $pdf->setSourceFile($logodir.'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
319 $tplidx = $pdf->importPage(1);
320 }
321
322 $pdf->Open();
323 $pagenb = 0;
324 $pdf->SetDrawColor(128, 128, 128);
325
326 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
327 $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
328 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
329 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
330 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
331 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
332 $pdf->SetCompression(false);
333 }
334
335 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
336 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
337
338 // Set $this->atleastonediscount if you have at least one discount
339 for ($i = 0; $i < $nblines; $i++) {
340 if ($object->lines[$i]->remise_percent) {
341 $this->atleastonediscount++;
342 }
343 }
344
345
346 // New page
347 $pdf->AddPage();
348 if (!empty($tplidx)) {
349 $pdf->useTemplate($tplidx);
350 }
351 $pagenb++;
352 $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null));
353 $pdf->SetFont('', '', $default_font_size - 1);
354 $pdf->MultiCell(0, 3, ''); // Set interline to 3
355 $pdf->SetTextColor(0, 0, 0);
356
357
358 $tab_top = 90 + $top_shift;
359 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
360
361 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
362
363 $nexY = $tab_top - 1;
364
365 // Incoterm
366 $height_incoterms = 0;
367 if (isModEnabled('incoterm')) {
368 $desc_incoterms = $object->getIncotermsForPDF();
369 if ($desc_incoterms) {
370 $tab_top -= 2;
371
372 $pdf->SetFont('', '', $default_font_size - 1);
373 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
374 $nexY = max($pdf->GetY(), $nexY);
375 $height_incoterms = $nexY - $tab_top;
376
377 // Rect takes a length in 3rd parameter
378 $pdf->SetDrawColor(192, 192, 192);
379 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
380
381 $tab_top = $nexY + 6;
382 }
383 }
384
385 // Display notes
386 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
387 if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
388 // Get first sale rep
389 if (is_object($object->thirdparty)) {
390 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
391 $salerepobj = new User($this->db);
392 $salerepobj->fetch($salereparray[0]['id']);
393 if (!empty($salerepobj->signature)) {
394 $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
395 }
396 }
397 }
398 // Extrafields in note
399 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
400 if (!empty($extranote)) {
401 $notetoshow = dol_concatdesc($notetoshow, $extranote);
402 }
403
404 $pagenb = $pdf->getPage();
405 if ($notetoshow) {
406 $tab_top -= 2;
407
408 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
409 $pageposbeforenote = $pagenb;
410
411 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
412 complete_substitutions_array($substitutionarray, $outputlangs, $object);
413 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
414 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
415
416 $pdf->startTransaction();
417
418 $pdf->SetFont('', '', $default_font_size - 1);
419 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
420 // Description
421 $pageposafternote = $pdf->getPage();
422 $posyafter = $pdf->GetY();
423
424 if ($pageposafternote > $pageposbeforenote) {
425 $pdf->rollbackTransaction(true);
426
427 // prepare pages to receive notes
428 while ($pagenb < $pageposafternote) {
429 $pdf->AddPage();
430 $pagenb++;
431 if (!empty($tplidx)) {
432 $pdf->useTemplate($tplidx);
433 }
434 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
435 $this->_pagehead($pdf, $object, 0, $outputlangs);
436 }
437 // $this->_pagefoot($pdf,$object,$outputlangs,1);
438 $pdf->setTopMargin($tab_top_newpage);
439 // The only function to edit the bottom margin of current page to set it.
440 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
441 }
442
443 // back to start
444 $pdf->setPage($pageposbeforenote);
445 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
446 $pdf->SetFont('', '', $default_font_size - 1);
447 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
448 $pageposafternote = $pdf->getPage();
449
450 $posyafter = $pdf->GetY();
451
452 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
453 $pdf->AddPage('', '', true);
454 $pagenb++;
455 $pageposafternote++;
456 $pdf->setPage($pageposafternote);
457 $pdf->setTopMargin($tab_top_newpage);
458 // The only function to edit the bottom margin of current page to set it.
459 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
460 //$posyafter = $tab_top_newpage;
461 }
462
463
464 // apply note frame to previous pages
465 $i = $pageposbeforenote;
466 while ($i < $pageposafternote) {
467 $pdf->setPage($i);
468
469
470 $pdf->SetDrawColor(128, 128, 128);
471 // Draw note frame
472 if ($i > $pageposbeforenote) {
473 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
474 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
475 } else {
476 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
477 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
478 }
479
480 // Add footer
481 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
482 $this->_pagefoot($pdf, $object, $outputlangs, 1);
483
484 $i++;
485 }
486
487 // apply note frame to last page
488 $pdf->setPage($pageposafternote);
489 if (!empty($tplidx)) {
490 $pdf->useTemplate($tplidx);
491 }
492 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
493 $this->_pagehead($pdf, $object, 0, $outputlangs);
494 }
495 $height_note = $posyafter - $tab_top_newpage;
496 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
497 } else {
498 // No pagebreak
499 $pdf->commitTransaction();
500 $posyafter = $pdf->GetY();
501 $height_note = $posyafter - $tab_top;
502 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
503
504
505 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
506 // not enough space, need to add page
507 $pdf->AddPage('', '', true);
508 $pagenb++;
509 $pageposafternote++;
510 $pdf->setPage($pageposafternote);
511 if (!empty($tplidx)) {
512 $pdf->useTemplate($tplidx);
513 }
514 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
515 $this->_pagehead($pdf, $object, 0, $outputlangs);
516 }
517
518 $posyafter = $tab_top_newpage;
519 }
520 }
521
522 $tab_height = $tab_height - $height_note;
523 $tab_top = $posyafter + 6;
524 } else {
525 $height_note = 0;
526 }
527
528
529 // Use new auto column system
530 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
531
532 // Table simulation to know the height of the title line
533 $pdf->startTransaction();
534 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
535 $pdf->rollbackTransaction(true);
536
537 $nexY = $tab_top + $this->tabTitleHeight;
538
539 // Loop on each lines
540 $pageposbeforeprintlines = $pdf->getPage();
541 $pagenb = $pageposbeforeprintlines;
542 for ($i = 0; $i < $nblines; $i++) {
543 $curY = $nexY;
544 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
545 $pdf->SetTextColor(0, 0, 0);
546
547 // Define size of image if we need it
548 $imglinesize = array();
549 if (!empty($realpatharray[$i])) {
550 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
551 }
552
553 $pdf->setTopMargin($tab_top_newpage);
554 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
555 $pageposbefore = $pdf->getPage();
556
557
558 $showpricebeforepagebreak = 1;
559 $posYAfterImage = 0;
560 $posYAfterDescription = 0;
561
562 if ($this->getColumnStatus('photo')) {
563 // We start with Photo of product line
564 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
565 $pdf->AddPage('', '', true);
566 if (!empty($tplidx)) {
567 $pdf->useTemplate($tplidx);
568 }
569 $pdf->setPage($pageposbefore + 1);
570
571 $curY = $tab_top_newpage;
572
573 // Allows data in the first page if description is long enough to break in multiples pages
574 if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
575 $showpricebeforepagebreak = 1;
576 } else {
577 $showpricebeforepagebreak = 0;
578 }
579 }
580
581 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
582 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
583 // $pdf->Image does not increase value return by getY, so we save it manually
584 $posYAfterImage = $curY + $imglinesize['height'];
585 }
586 }
587
588 // Description of product line
589 if ($this->getColumnStatus('desc')) {
590 $pdf->startTransaction();
591
592 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
593 $pageposafter = $pdf->getPage();
594
595 if ($pageposafter > $pageposbefore) { // There is a pagebreak
596 $pdf->rollbackTransaction(true);
597 $pageposafter = $pageposbefore;
598 //print $pageposafter.'-'.$pageposbefore;exit;
599 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
600
601 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
602 $pageposafter = $pdf->getPage();
603 $posyafter = $pdf->GetY();
604 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
605 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
606 $pdf->AddPage('', '', true);
607 if (!empty($tplidx)) {
608 $pdf->useTemplate($tplidx);
609 }
610 $pdf->setPage($pageposafter + 1);
611 }
612 } else {
613 // We found a page break
614 // Allows data in the first page if description is long enough to break in multiples pages
615 if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
616 $showpricebeforepagebreak = 1;
617 } else {
618 $showpricebeforepagebreak = 0;
619 }
620 }
621 } else { // No pagebreak
622 $pdf->commitTransaction();
623 }
624 $posYAfterDescription = $pdf->GetY();
625 }
626
627
628 $nexY = max($pdf->GetY(), $posYAfterImage);
629
630
631 $pageposafter = $pdf->getPage();
632
633 $pdf->setPage($pageposbefore);
634 $pdf->setTopMargin($this->marge_haute);
635 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
636
637 // We suppose that a too long description or photo were moved completely on next page
638 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
639 $pdf->setPage($pageposafter);
640 $curY = $tab_top_newpage;
641 }
642
643 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
644
645 // # of line
646 if ($this->getColumnStatus('position')) {
647 $this->printStdColumnContent($pdf, $curY, 'position', $i + 1);
648 }
649
650 // VAT Rate
651 if ($this->getColumnStatus('vat')) {
652 $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
653 $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
654 $nexY = max($pdf->GetY(), $nexY);
655 }
656
657 // Unit price before discount
658 if ($this->getColumnStatus('subprice')) {
659 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
660 $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
661 $nexY = max($pdf->GetY(), $nexY);
662 }
663
664 // Quantity
665 // Enough for 6 chars
666 if ($this->getColumnStatus('qty')) {
667 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
668 $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
669 $nexY = max($pdf->GetY(), $nexY);
670 }
671
672
673 // Unit
674 if ($this->getColumnStatus('unit')) {
675 $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails);
676 $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
677 $nexY = max($pdf->GetY(), $nexY);
678 }
679
680 // Discount on line
681 if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
682 $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
683 $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
684 $nexY = max($pdf->GetY(), $nexY);
685 }
686
687 // Total excl tax line (HT)
688 if ($this->getColumnStatus('totalexcltax')) {
689 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
690 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
691 $nexY = max($pdf->GetY(), $nexY);
692 }
693
694 // Total with tax line (TTC)
695 if ($this->getColumnStatus('totalincltax')) {
696 $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
697 $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
698 $nexY = max($pdf->GetY(), $nexY);
699 }
700
701 // Extrafields
702 if (!empty($object->lines[$i]->array_options)) {
703 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
704 if ($this->getColumnStatus($extrafieldColKey)) {
705 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
706 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
707 $nexY = max($pdf->GetY(), $nexY);
708 }
709 }
710 }
711
712 $parameters = array(
713 'object' => $object,
714 'i' => $i,
715 'pdf' => & $pdf,
716 'curY' => & $curY,
717 'nexY' => & $nexY,
718 'outputlangs' => $outputlangs,
719 'hidedetails' => $hidedetails
720 );
721 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
722
723
724 // Collection of totals by value of vat in $this->tva["rate"] = total_tva
725 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
726 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
727 } else {
728 $tvaligne = $object->lines[$i]->total_tva;
729 }
730
731 $localtax1ligne = $object->lines[$i]->total_localtax1;
732 $localtax2ligne = $object->lines[$i]->total_localtax2;
733 $localtax1_rate = $object->lines[$i]->localtax1_tx;
734 $localtax2_rate = $object->lines[$i]->localtax2_tx;
735 $localtax1_type = $object->lines[$i]->localtax1_type;
736 $localtax2_type = $object->lines[$i]->localtax2_type;
737
738 $vatrate = (string) $object->lines[$i]->tva_tx;
739
740 // Retrieve type from database for backward compatibility with old records
741 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
742 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
743 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
744 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
745 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
746 }
747
748 // retrieve global local tax
749 if ($localtax1_type && $localtax1ligne != 0) {
750 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
751 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
752 } else {
753 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
754 }
755 }
756 if ($localtax2_type && $localtax2ligne != 0) {
757 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
758 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
759 } else {
760 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
761 }
762 }
763
764 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
765 $vatrate .= '*';
766 }
767
768 // Fill $this->tva and $this->tva_array
769 if (!isset($this->tva[$vatrate])) {
770 $this->tva[$vatrate] = 0;
771 }
772 $this->tva[$vatrate] += $tvaligne;
773 $vatcode = $object->lines[$i]->vat_src_code;
774 if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
775 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
776 }
777 $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
778
779 // Add line
780 if (getDolGlobalInt('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
781 $pdf->setPage($pageposafter);
782 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
783 //$pdf->SetDrawColor(190,190,200);
784 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
785 $pdf->SetLineStyle(array('dash' => 0));
786 }
787
788
789 // Detect if some page were added automatically and output _tableau for past pages
790 while ($pagenb < $pageposafter) {
791 $pdf->setPage($pagenb);
792 if ($pagenb == $pageposbeforeprintlines) {
793 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
794 } else {
795 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
796 }
797 $this->_pagefoot($pdf, $object, $outputlangs, 1);
798 $pagenb++;
799 $pdf->setPage($pagenb);
800 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
801 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
802 $this->_pagehead($pdf, $object, 0, $outputlangs);
803 }
804 if (!empty($tplidx)) {
805 $pdf->useTemplate($tplidx);
806 }
807 }
808 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
809 if ($pagenb == $pageposafter) {
810 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
811 } else {
812 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
813 }
814 $this->_pagefoot($pdf, $object, $outputlangs, 1);
815 // New page
816 $pdf->AddPage();
817 if (!empty($tplidx)) {
818 $pdf->useTemplate($tplidx);
819 }
820 $pagenb++;
821 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
822 $this->_pagehead($pdf, $object, 0, $outputlangs);
823 }
824 }
825 }
826
827 // Show square
828 if ($pagenb == $pageposbeforeprintlines) {
829 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
830 } else {
831 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
832 }
833 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
834
835 // Display infos area
836 $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
837
838 // Display total zone
839 $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
840
841 // Display payment area
842 /*
843 if ($deja_regle)
844 {
845 $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
846 }
847 */
848
849 // Pagefoot
850 $this->_pagefoot($pdf, $object, $outputlangs);
851 if (method_exists($pdf, 'AliasNbPages')) {
852 $pdf->AliasNbPages();
853 }
854
855 $pdf->Close();
856
857 $pdf->Output($file, 'F');
858
859 // Add pdfgeneration hook
860 $hookmanager->initHooks(array('pdfgeneration'));
861 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
862 global $action;
863 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
864 if ($reshook < 0) {
865 $this->error = $hookmanager->error;
866 $this->errors = $hookmanager->errors;
867 }
868
869 dolChmod($file);
870
871 $this->result = array('fullpath' => $file);
872
873 return 1; // No error
874 } else {
875 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
876 return 0;
877 }
878 } else {
879 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
880 return 0;
881 }
882 }
883
893 protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
894 {
895 return 0;
896 }
897
907 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
908 {
909 global $conf, $mysoc;
910 $default_font_size = pdf_getPDFFontSize($outputlangs);
911
912 $pdf->SetFont('', '', $default_font_size - 1);
913
914 $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
915
916 // If France, show VAT mention if not applicable
917 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
918 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
919 $pdf->SetXY($this->marge_gauche, $posy);
920 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
921
922 $posy = $pdf->GetY() + 4;
923 }
924
925 $posxval = 52;
926
927 $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
928
929 // Show payments conditions
930 if ($object->cond_reglement_code || $object->cond_reglement) {
931 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
932 $pdf->SetXY($this->marge_gauche, $posy);
933 $titre = $outputlangs->transnoentities("PaymentConditions").':';
934 $pdf->MultiCell(43, 4, $titre, 0, 'L');
935
936 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
937 $pdf->SetXY($posxval, $posy);
938 $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);
939 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
940 if ($object->deposit_percent > 0) {
941 $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', (string) $object->deposit_percent, $lib_condition_paiement);
942 }
943 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
944
945 $posy = $pdf->GetY() + 3;
946 }
947
948 // Check a payment mode is defined
949 /* Not used with orders
950 if (empty($object->mode_reglement_code)
951 && ! $conf->global->FACTURE_CHQ_NUMBER
952 && ! $conf->global->FACTURE_RIB_NUMBER)
953 {
954 $pdf->SetXY($this->marge_gauche, $posy);
955 $pdf->SetTextColor(200,0,0);
956 $pdf->SetFont('','B', $default_font_size - 2);
957 $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
958 $pdf->SetTextColor(0,0,0);
959
960 $posy=$pdf->GetY()+1;
961 }
962 */
963 /* TODO
964 else if (!empty($object->availability_code))
965 {
966 $pdf->SetXY($this->marge_gauche, $posy);
967 $pdf->SetTextColor(200,0,0);
968 $pdf->SetFont('','B', $default_font_size - 2);
969 $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
970 $pdf->SetTextColor(0,0,0);
971
972 $posy=$pdf->GetY()+1;
973 }*/
974
975 // Show planned date of delivery
976 if (!empty($object->delivery_date)) {
977 $outputlangs->load("sendings");
978 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
979 $pdf->SetXY($this->marge_gauche, $posy);
980 $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
981 $pdf->MultiCell(80, 4, $titre, 0, 'L');
982 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
983 $pdf->SetXY($posxval, $posy);
984 $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
985 $pdf->MultiCell(80, 4, $dlp, 0, 'L');
986
987 $posy = $pdf->GetY() + 1;
988 } elseif ($object->availability_code || $object->availability) { // Show availability conditions
989 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
990 $pdf->SetXY($this->marge_gauche, $posy);
991 $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
992 $pdf->MultiCell(80, 4, $titre, 0, 'L');
993 $pdf->SetTextColor(0, 0, 0);
994 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
995 $pdf->SetXY($posxval, $posy);
996 $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
997 $lib_availability = str_replace('\n', "\n", $lib_availability);
998 $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
999
1000 $posy = $pdf->GetY() + 1;
1001 }
1002
1003 // Show payment mode
1004 if ($object->mode_reglement_code
1005 && $object->mode_reglement_code != 'CHQ'
1006 && $object->mode_reglement_code != 'VIR') {
1007 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1008 $pdf->SetXY($this->marge_gauche, $posy);
1009 $titre = $outputlangs->transnoentities("PaymentMode").':';
1010 $pdf->MultiCell(80, 5, $titre, 0, 'L');
1011
1012 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1013 $pdf->SetXY($posxval, $posy);
1014 $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);
1015 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1016
1017 $posy = $pdf->GetY() + 2;
1018 }
1019
1020 // Show payment mode CHQ
1021 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
1022 // Si mode reglement non force ou si force a CHQ
1023 if (getDolGlobalString('FACTURE_CHQ_NUMBER')) {
1024 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
1025 $account = new Account($this->db);
1026 $account->fetch(getDolGlobalString('FACTURE_CHQ_NUMBER'));
1027
1028 $pdf->SetXY($this->marge_gauche, $posy);
1029 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1030 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', 0);
1031 $posy = $pdf->GetY() + 1;
1032
1033 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1034 $pdf->SetXY($this->marge_gauche, $posy);
1035 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1036 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1037 $posy = $pdf->GetY() + 2;
1038 }
1039 }
1040 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1041 $pdf->SetXY($this->marge_gauche, $posy);
1042 $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1043 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1044 $posy = $pdf->GetY() + 1;
1045
1046 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
1047 $pdf->SetXY($this->marge_gauche, $posy);
1048 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1049 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1050 $posy = $pdf->GetY() + 2;
1051 }
1052 }
1053 }
1054 }
1055
1056 // If payment mode not forced or forced to VIR, show payment with BAN
1057 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1058 if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1059 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1060 if ($object->fk_bank > 0) {
1061 $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1062 }
1063 $account = new Account($this->db);
1064 $account->fetch($bankid);
1065
1066 $curx = $this->marge_gauche;
1067 $cury = $posy;
1068
1069 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1070
1071 $posy += 2;
1072 }
1073 }
1074
1075 return $posy;
1076 }
1077
1078
1090 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
1091 {
1092 global $conf, $mysoc, $hookmanager;
1093
1094 $default_font_size = pdf_getPDFFontSize($outputlangs);
1095
1096 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
1097 $outputlangsbis = new Translate('', $conf);
1098 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
1099 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1100 $default_font_size--;
1101 }
1102
1103 $tab2_top = $posy;
1104 $tab2_hl = 4;
1105 $pdf->SetFont('', '', $default_font_size - 1);
1106
1107 // Total table
1108 $col1x = 120;
1109 $col2x = 170;
1110 if ($this->page_largeur < 210) { // To work with US executive format
1111 $col2x -= 20;
1112 }
1113 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1114
1115 $useborder = 0;
1116 $index = 0;
1117
1118 // Total HT
1119 $pdf->SetFillColor(255, 255, 255);
1120 $pdf->SetXY($col1x, $tab2_top);
1121 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
1122 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1123 $pdf->SetXY($col2x, $tab2_top);
1124 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
1125
1126 // Show VAT by rates and total
1127 $pdf->SetFillColor(248, 248, 248);
1128
1129 $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1130
1131 $this->atleastoneratenotnull = 0;
1132 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
1133 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1134 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1135 // Nothing to do
1136 } else {
1137 //Local tax 1 before VAT
1138 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1139 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1140 continue;
1141 }
1142 foreach ($localtax_rate as $tvakey => $tvaval) {
1143 if ($tvakey != 0) { // On affiche pas taux 0
1144 //$this->atleastoneratenotnull++;
1145 $index++;
1146 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1147
1148 $tvacompl = '';
1149 if (preg_match('/\*/', (string) $tvakey)) {
1150 $tvakey = str_replace('*', '', (string) $tvakey);
1151 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1152 }
1153 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1154 $totalvat .= ' ';
1155
1156 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1157 $totalvat .= $tvacompl;
1158 } else {
1159 $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1160 }
1161
1162 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1163
1164 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1165
1166 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1167 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1168 }
1169 }
1170 }
1171
1172 //Local tax 2 before VAT
1173 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1174 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
1175 continue;
1176 }
1177 foreach ($localtax_rate as $tvakey => $tvaval) {
1178 if ($tvakey != 0) { // On affiche pas taux 0
1179 //$this->atleastoneratenotnull++;
1180
1181 $index++;
1182 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1183
1184 $tvacompl = '';
1185 if (preg_match('/\*/', (string) $tvakey)) {
1186 $tvakey = str_replace('*', '', (string) $tvakey);
1187 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1188 }
1189 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1190 $totalvat .= ' ';
1191
1192 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1193 $totalvat .= $tvacompl;
1194 } else {
1195 $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1196 }
1197
1198 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1199
1200 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1201
1202 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1203 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1204 }
1205 }
1206 }
1207
1208 // VAT
1209 foreach ($this->tva_array as $tvakey => $tvaval) {
1210 if ($tvakey != 0) { // On affiche pas taux 0
1211 $this->atleastoneratenotnull++;
1212
1213 $index++;
1214 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1215
1216 $tvacompl = '';
1217 if (preg_match('/\*/', $tvakey)) {
1218 $tvakey = str_replace('*', '', $tvakey);
1219 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1220 }
1221 $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
1222 $totalvat .= ' ';
1223 if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
1224 $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
1225 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
1226 $totalvat .= $tvaval['vatcode'].$tvacompl;
1227 } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1228 $totalvat .= $tvacompl;
1229 } else {
1230 $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
1231 }
1232 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1233
1234 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1235 $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
1236 }
1237 }
1238
1239 //Local tax 1 after VAT
1240 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1241 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1242 continue;
1243 }
1244
1245 foreach ($localtax_rate as $tvakey => $tvaval) {
1246 if ($tvakey != 0) { // On affiche pas taux 0
1247 //$this->atleastoneratenotnull++;
1248
1249 $index++;
1250 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1251
1252 $tvacompl = '';
1253 if (preg_match('/\*/', (string) $tvakey)) {
1254 $tvakey = str_replace('*', '', (string) $tvakey);
1255 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1256 }
1257 $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
1258 $totalvat .= ' ';
1259
1260 if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1261 $totalvat .= $tvacompl;
1262 } else {
1263 $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1264 }
1265
1266 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1267
1268 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1269
1270 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1271 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1272 }
1273 }
1274 }
1275
1276 //Local tax 2 after VAT
1277 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1278 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
1279 continue;
1280 }
1281
1282 foreach ($localtax_rate as $tvakey => $tvaval) {
1283 // retrieve global local tax
1284 if ($tvakey != 0) { // On affiche pas taux 0
1285 //$this->atleastoneratenotnull++;
1286
1287 $index++;
1288 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1289
1290 $tvacompl = '';
1291 if (preg_match('/\*/', (string) $tvakey)) {
1292 $tvakey = str_replace('*', '', (string) $tvakey);
1293 $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1294 }
1295 $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
1296 $totalvat .= ' ';
1297
1298 if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
1299 $totalvat .= $tvacompl;
1300 } else {
1301 $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1302 }
1303
1304 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1305
1306 $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
1307
1308 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1309 $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
1310 }
1311 }
1312 }
1313 //}
1314
1315 // Total TTC
1316 $index++;
1317 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1318 $pdf->SetTextColor(0, 0, 60);
1319 $pdf->SetFillColor(224, 224, 224);
1320 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1);
1321
1322 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1323 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1324 }
1325 }
1326
1327 $pdf->SetTextColor(0, 0, 0);
1328
1329 $creditnoteamount = 0;
1330 $depositsamount = 0;
1331 //$creditnoteamount=$object->getSumCreditNotesUsed();
1332 //$depositsamount=$object->getSumDepositsUsed();
1333 //print "x".$creditnoteamount."-".$depositsamount;exit;
1334 $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1335 if (!empty($object->paye)) {
1336 $resteapayer = 0;
1337 }
1338
1339 if ($deja_regle > 0) {
1340 // Already paid + Deposits
1341 $index++;
1342
1343 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1344 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1345 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1346 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1347
1348 $index++;
1349 $pdf->SetTextColor(0, 0, 60);
1350 $pdf->SetFillColor(224, 224, 224);
1351 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1352 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
1353
1354 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1355 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1356
1357 $pdf->SetFont('', '', $default_font_size - 1);
1358 $pdf->SetTextColor(0, 0, 0);
1359 }
1360
1361 $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy);
1362
1363 $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks
1364 if ($reshook < 0) {
1365 $this->error = $hookmanager->error;
1366 $this->errors = $hookmanager->errors;
1367 }
1368
1369 $index++;
1370 return ($tab2_top + ($tab2_hl * $index));
1371 }
1372
1373 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1388 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
1389 {
1390 global $conf;
1391
1392 // Force to disable hidetop and hidebottom
1393 $hidebottom = 0;
1394 if ($hidetop) {
1395 $hidetop = -1;
1396 }
1397
1398 $currency = !empty($currency) ? $currency : $conf->currency;
1399 $default_font_size = pdf_getPDFFontSize($outputlangs);
1400
1401 // Amount in (at tab_top - 1)
1402 $pdf->SetTextColor(0, 0, 0);
1403 $pdf->SetFont('', '', $default_font_size - 2);
1404
1405 if (empty($hidetop)) {
1406 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1407 if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1408 $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
1409 }
1410
1411 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1412 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1413
1414 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1415 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1416 $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')));
1417 }
1418 }
1419
1420 $pdf->SetDrawColor(128, 128, 128);
1421 $pdf->SetFont('', '', $default_font_size - 1);
1422
1423 // Output Rect
1424 $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
1425
1426
1427 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1428
1429 if (empty($hidetop)) {
1430 $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
1431 }
1432 }
1433
1434 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1435 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1447 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
1448 {
1449 // phpcs:enable
1450 global $conf, $langs, $hookmanager, $mysoc;
1451
1452 $ltrdirection = 'L';
1453 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1454 $ltrdirection = 'R';
1455 }
1456
1457 // Load traductions files required by page
1458 $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1459
1460 $default_font_size = pdf_getPDFFontSize($outputlangs);
1461
1462 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1463
1464 $pdf->SetTextColor(0, 0, 60);
1465 $pdf->SetFont('', 'B', $default_font_size + 3);
1466
1467 $w = 100;
1468
1469 $posy = $this->marge_haute;
1470 $posx = $this->page_largeur - $this->marge_droite - $w;
1471
1472 $pdf->SetXY($this->marge_gauche, $posy);
1473
1474 // Logo
1475 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1476 if ($this->emetteur->logo) {
1477 $logodir = $conf->mycompany->dir_output;
1478 if (!empty(getMultidirOutput($mysoc, 'mycompany'))) {
1479 $logodir = getMultidirOutput($mysoc, 'mycompany');
1480 }
1481 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1482 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1483 } else {
1484 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1485 }
1486 if (is_readable($logo)) {
1487 $height = pdf_getHeightForLogo($logo);
1488 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1489 } else {
1490 $pdf->SetTextColor(200, 0, 0);
1491 $pdf->SetFont('', 'B', $default_font_size - 2);
1492 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1493 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1494 }
1495 } else {
1496 $text = $this->emetteur->name;
1497 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1498 }
1499 }
1500
1501 $pdf->SetFont('', 'B', $default_font_size + 3);
1502 $pdf->SetXY($posx, $posy);
1503 $pdf->SetTextColor(0, 0, 60);
1504 $title = $outputlangs->transnoentities($titlekey);
1505 if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1506 $title .= ' - ';
1507 $title .= $outputlangsbis->transnoentities($titlekey);
1508 }
1509 $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
1510 if ($object->statut == $object::STATUS_DRAFT) {
1511 $pdf->SetTextColor(128, 0, 0);
1512 $title .= ' - '.$outputlangs->transnoentities("NotValidated");
1513 }
1514
1515 $pdf->MultiCell($w, 3, $title, '', 'R');
1516
1517 $pdf->SetFont('', 'B', $default_font_size);
1518
1519 /*
1520 $posy += 5;
1521 $pdf->SetXY($posx, $posy);
1522 $pdf->SetTextColor(0, 0, 60);
1523 $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1524 if ($object->statut == $object::STATUS_DRAFT) {
1525 $pdf->SetTextColor(128, 0, 0);
1526 $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1527 }
1528 $pdf->MultiCell($w, 4, $textref, '', 'R');
1529 */
1530
1531 $posy += 3;
1532 $pdf->SetFont('', '', $default_font_size - 2);
1533
1534 if ($object->ref_client) {
1535 $posy += 4;
1536 $pdf->SetXY($posx, $posy);
1537 $pdf->SetTextColor(0, 0, 60);
1538 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
1539 }
1540
1541 if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) {
1542 $object->fetch_projet();
1543 if (!empty($object->project->ref)) {
1544 $posy += 3;
1545 $pdf->SetXY($posx, $posy);
1546 $pdf->SetTextColor(0, 0, 60);
1547 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1548 }
1549 }
1550
1551 if (getDolGlobalInt('PDF_SHOW_PROJECT')) {
1552 $object->fetch_projet();
1553 if (!empty($object->project->ref)) {
1554 $outputlangs->load("projects");
1555 $posy += 3;
1556 $pdf->SetXY($posx, $posy);
1557 $pdf->SetTextColor(0, 0, 60);
1558 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1559 }
1560 }
1561
1562 $posy += 4;
1563
1564 $pdf->SetXY($posx, $posy);
1565 $pdf->SetTextColor(0, 0, 60);
1566 $title = $outputlangs->transnoentities("OrderDate");
1567 if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1568 $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
1569 }
1570 $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1571
1572 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1573 $posy += 4;
1574 $pdf->SetXY($posx, $posy);
1575 $pdf->SetTextColor(0, 0, 60);
1576 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1577 }
1578
1579 // Get contact
1580 if (getDolGlobalInt('DOC_SHOW_FIRST_SALES_REP')) {
1581 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1582 if (count($arrayidcontact) > 0) {
1583 $usertmp = new User($this->db);
1584 $usertmp->fetch($arrayidcontact[0]);
1585 $posy += 4;
1586 $pdf->SetXY($posx, $posy);
1587 $pdf->SetTextColor(0, 0, 60);
1588 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1589 }
1590 }
1591
1592 $posy += 2;
1593
1594 $top_shift = 0;
1595 // Show list of linked objects
1596 $current_y = $pdf->getY();
1597 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1598 if ($current_y < $pdf->getY()) {
1599 $top_shift = $pdf->getY() - $current_y;
1600 }
1601
1602 if ($showaddress) {
1603 // Sender properties
1604 $carac_emetteur = '';
1605 // Add internal contact of object if defined
1606 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1607 if (count($arrayidcontact) > 0) {
1608 $object->fetch_user($arrayidcontact[0]);
1609 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1610 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1611 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1612 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1613 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1614 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1615 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1616 $carac_emetteur .= "\n";
1617 }
1618
1619 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1620
1621 // Show sender
1622 $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1623 $posy += $top_shift;
1624 $posx = $this->marge_gauche;
1625 if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) {
1626 $posx = $this->page_largeur - $this->marge_droite - 80;
1627 }
1628
1629 $hautcadre = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1630 $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1631
1632
1633 // Show sender frame
1634 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1635 $pdf->SetTextColor(0, 0, 0);
1636 $pdf->SetFont('', '', $default_font_size - 2);
1637 $pdf->SetXY($posx, $posy - 5);
1638 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
1639 $pdf->SetXY($posx, $posy);
1640 $pdf->SetFillColor(230, 230, 230);
1641 $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1642 $pdf->SetTextColor(0, 0, 60);
1643 }
1644
1645 // Show sender name
1646 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1647 $pdf->SetXY($posx + 2, $posy + 3);
1648 $pdf->SetFont('', 'B', $default_font_size);
1649 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1650 $posy = $pdf->getY();
1651 }
1652
1653 // Show sender information
1654 $pdf->SetXY($posx + 2, $posy);
1655 $pdf->SetFont('', '', $default_font_size - 1);
1656 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1657
1658 // If CUSTOMER contact defined, we use it
1659 $usecontact = false;
1660 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1661 if (count($arrayidcontact) > 0) {
1662 $usecontact = true;
1663 $result = $object->fetch_contact($arrayidcontact[0]);
1664 }
1665
1666 //Recipient name
1667 if ($usecontact && $object->contact->socid != $object->thirdparty->id && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
1668 $thirdparty = $object->contact;
1669 } else {
1670 $thirdparty = $object->thirdparty;
1671 }
1672
1673 if (is_object($thirdparty)) {
1674 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1675 }
1676
1677 $mode = 'target';
1678 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
1679
1680 // Show recipient
1681 $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1682 if ($this->page_largeur < 210) {
1683 $widthrecbox = 84; // To work with US executive format
1684 }
1685 $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1686 $posy += $top_shift;
1687 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1688 if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) {
1689 $posx = $this->marge_gauche;
1690 }
1691
1692 // Show recipient frame
1693 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1694 $pdf->SetTextColor(0, 0, 0);
1695 $pdf->SetFont('', '', $default_font_size - 2);
1696 $pdf->SetXY($posx + 2, $posy - 5);
1697 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
1698 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1699 }
1700
1701 // Show recipient name
1702 $pdf->SetXY($posx + 2, $posy + 3);
1703 $pdf->SetFont('', 'B', $default_font_size);
1704 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1705 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1706
1707 $posy = $pdf->getY();
1708
1709 // Show recipient information
1710 $pdf->SetFont('', '', $default_font_size - 1);
1711 $pdf->SetXY($posx + 2, $posy);
1712 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1713 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1714 }
1715
1716 $pdf->SetTextColor(0, 0, 0);
1717
1718 return $top_shift;
1719 }
1720
1721 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1722 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1732 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1733 {
1734 // phpcs:enable
1735 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1736 return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1737 }
1738
1739
1740
1751 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1752 {
1753 global $hookmanager;
1754
1755 // Default field style for content
1756 $this->defaultContentsFieldsStyle = array(
1757 'align' => 'R', // R,C,L
1758 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1759 );
1760
1761 // Default field style for content
1762 $this->defaultTitlesFieldsStyle = array(
1763 'align' => 'C', // R,C,L
1764 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1765 );
1766
1767 /*
1768 * For example
1769 $this->cols['theColKey'] = array(
1770 'rank' => $rank, // int : use for ordering columns
1771 'width' => 20, // the column width in mm
1772 'title' => array(
1773 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1774 'label' => ' ', // the final label : used fore final generated text
1775 'align' => 'L', // text alignment : R,C,L
1776 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1777 ),
1778 'content' => array(
1779 'align' => 'L', // text alignment : R,C,L
1780 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1781 ),
1782 );
1783 */
1784
1785 $rank = 0; // do not use negative rank
1786 $this->cols['position'] = array(
1787 'rank' => $rank,
1788 'width' => 10,
1789 'status' => getDolGlobalInt('PDF_ERATOSHTENE_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
1790 'title' => array(
1791 'textkey' => '#', // use lang key is useful in somme case with module
1792 'align' => 'C',
1793 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1794 // 'label' => ' ', // the final label
1795 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1796 ),
1797 'content' => array(
1798 'align' => 'C',
1799 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1800 ),
1801 );
1802
1803 $rank = 5; // do not use negative rank
1804 $this->cols['desc'] = array(
1805 'rank' => $rank,
1806 'width' => false, // only for desc
1807 'status' => true,
1808 'title' => array(
1809 'textkey' => 'Designation', // use lang key is useful in somme case with module
1810 'align' => 'L',
1811 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1812 // 'label' => ' ', // the final label
1813 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1814 ),
1815 'content' => array(
1816 'align' => 'L',
1817 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1818 ),
1819 );
1820
1821 // Image of product
1822 $rank = $rank + 10;
1823 $this->cols['photo'] = array(
1824 'rank' => $rank,
1825 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm
1826 'status' => false,
1827 'title' => array(
1828 'textkey' => 'Photo',
1829 'label' => ' '
1830 ),
1831 'content' => array(
1832 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1833 ),
1834 'border-left' => false, // remove left line separator
1835 );
1836
1837 if (getDolGlobalInt('MAIN_GENERATE_ORDERS_WITH_PICTURE') && !empty($this->atleastonephoto)) {
1838 $this->cols['photo']['status'] = true;
1839 }
1840
1841 $rank = $rank + 10;
1842 $this->cols['vat'] = array(
1843 'rank' => $rank,
1844 'status' => false,
1845 'width' => 16, // in mm
1846 'title' => array(
1847 'textkey' => 'VAT'
1848 ),
1849 'border-left' => true, // add left line separator
1850 );
1851
1852 if (!getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
1853 $this->cols['vat']['status'] = true;
1854 }
1855
1856 $rank = $rank + 10;
1857 $this->cols['subprice'] = array(
1858 'rank' => $rank,
1859 'width' => 19, // in mm
1860 'status' => true,
1861 'title' => array(
1862 'textkey' => 'PriceUHT'
1863 ),
1864 'border-left' => true, // add left line separator
1865 );
1866
1867 // Adapt dynamically the width of subprice, if text is too long.
1868 $tmpwidth = 0;
1869 $nblines = count($object->lines);
1870 for ($i = 0; $i < $nblines; $i++) {
1871 $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
1872 $tmpwidth = max($tmpwidth, $tmpwidth2);
1873 }
1874 if ($tmpwidth > 10) {
1875 $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
1876 }
1877
1878 $rank = $rank + 10;
1879 $this->cols['qty'] = array(
1880 'rank' => $rank,
1881 'width' => 16, // in mm
1882 'status' => true,
1883 'title' => array(
1884 'textkey' => 'Qty'
1885 ),
1886 'border-left' => true, // add left line separator
1887 );
1888
1889 $rank = $rank + 10;
1890 $this->cols['unit'] = array(
1891 'rank' => $rank,
1892 'width' => 11, // in mm
1893 'status' => false,
1894 'title' => array(
1895 'textkey' => 'Unit'
1896 ),
1897 'border-left' => true, // add left line separator
1898 );
1899 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1900 $this->cols['unit']['status'] = true;
1901 }
1902
1903 $rank = $rank + 10;
1904 $this->cols['discount'] = array(
1905 'rank' => $rank,
1906 'width' => 13, // in mm
1907 'status' => false,
1908 'title' => array(
1909 'textkey' => 'ReductionShort'
1910 ),
1911 'border-left' => true, // add left line separator
1912 );
1913 if ($this->atleastonediscount) {
1914 $this->cols['discount']['status'] = true;
1915 }
1916
1917 $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1918 $this->cols['totalexcltax'] = array(
1919 'rank' => $rank,
1920 'width' => 26, // in mm
1921 'status' => !getDolGlobalString('PDF_ORDER_HIDE_PRICE_EXCL_TAX') ? true : false,
1922 'title' => array(
1923 'textkey' => 'TotalHTShort'
1924 ),
1925 'border-left' => true, // add left line separator
1926 );
1927
1928 $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
1929 $this->cols['totalincltax'] = array(
1930 'rank' => $rank,
1931 'width' => 26, // in mm
1932 'status' => !getDolGlobalString('PDF_ORDER_SHOW_PRICE_INCL_TAX') ? false : true,
1933 'title' => array(
1934 'textkey' => 'TotalTTCShort'
1935 ),
1936 'border-left' => true, // add left line separator
1937 );
1938
1939 // Add extrafields cols
1940 if (!empty($object->lines)) {
1941 $line = reset($object->lines);
1942 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1943 }
1944
1945 $parameters = array(
1946 'object' => $object,
1947 'outputlangs' => $outputlangs,
1948 'hidedetails' => $hidedetails,
1949 'hidedesc' => $hidedesc,
1950 'hideref' => $hideref
1951 );
1952
1953 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1954 if ($reshook < 0) {
1955 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1956 } elseif (empty($reshook)) {
1957 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1958 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1959 } else {
1960 $this->cols = $hookmanager->resArray;
1961 }
1962 }
1963}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage bank accounts.
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 Dolibarr database access.
Class to manage hooks.
Parent class for orders models.
Class to manage products or services.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate PDF orders with template Eratosthene.
drawInfoTable(&$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.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
__construct(DoliDB $db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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...
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files,...
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_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:2637
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition pdf.lib.php:2376
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:290
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:315
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
Definition pdf.lib.php:2432
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:1994
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:1932
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:733
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1401
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
Definition pdf.lib.php:850
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:267
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:436
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
Definition pdf.lib.php:2239
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2282
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2079
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:769
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:388
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140