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