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