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