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