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