dolibarr 22.0.5
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", "deliveries", "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", "deliveries", "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])) {
298 $logodir = $conf->mycompany->multidir_output[$object->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 if ($reshook < 0) {
824 $this->error = $hookmanager->error;
825 $this->errors = $hookmanager->errors;
826 }
827
828 dolChmod($file);
829
830 $this->result = array('fullpath' => $file);
831
832 return 1; // No error
833 } else {
834 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
835 return 0;
836 }
837 } else {
838 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR");
839 return 0;
840 }
841 }
842
852 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
853 {
854 global $conf, $mysoc;
855 '@phan-var-force Commande|Propal|Facture $object'; // availability_code,... does not exist on Facture.
856
857 $default_font_size = pdf_getPDFFontSize($outputlangs);
858
859 $pdf->SetFont('', '', $default_font_size - 1);
860
861 // If France, show VAT mention if not applicable
862 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
863 $pdf->SetFont('', 'B', $default_font_size - 2);
864 $pdf->SetXY($this->marge_gauche, $posy);
865 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', false);
866
867 $posy = $pdf->GetY() + 4;
868 }
869
870 $posxval = 52;
871
872 // Show payments conditions
873 if ($object->cond_reglement_code || $object->cond_reglement) {
874 $pdf->SetFont('', 'B', $default_font_size - 2);
875 $pdf->SetXY($this->marge_gauche, $posy);
876 $titre = $outputlangs->transnoentities("PaymentConditions").':';
877 $pdf->MultiCell(43, 4, $titre, 0, 'L');
878
879 $pdf->SetFont('', '', $default_font_size - 2);
880 $pdf->SetXY($posxval, $posy);
881 $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);
882 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
883 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
884
885 $posy = $pdf->GetY() + 3;
886 }
887
888 // Check a payment mode is defined
889 /* Not used with orders
890 if (empty($object->mode_reglement_code)
891 && ! $conf->global->FACTURE_CHQ_NUMBER
892 && ! $conf->global->FACTURE_RIB_NUMBER)
893 {
894 $pdf->SetXY($this->marge_gauche, $posy);
895 $pdf->SetTextColor(200,0,0);
896 $pdf->SetFont('','B', $default_font_size - 2);
897 $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
898 $pdf->SetTextColor(0,0,0);
899
900 $posy=$pdf->GetY()+1;
901 }
902 */
903 /* TODO
904 else if (!empty($object->availability_code))
905 {
906 $pdf->SetXY($this->marge_gauche, $posy);
907 $pdf->SetTextColor(200,0,0);
908 $pdf->SetFont('','B', $default_font_size - 2);
909 $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
910 $pdf->SetTextColor(0,0,0);
911
912 $posy=$pdf->GetY()+1;
913 }*/
914
915 // Show planned date of delivery
916 if (!empty($object->delivery_date)) {
917 $outputlangs->load("sendings");
918 $pdf->SetFont('', 'B', $default_font_size - 2);
919 $pdf->SetXY($this->marge_gauche, $posy);
920 $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
921 $pdf->MultiCell(80, 4, $titre, 0, 'L');
922 $pdf->SetFont('', '', $default_font_size - 2);
923 $pdf->SetXY($posxval, $posy);
924 $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
925 $pdf->MultiCell(80, 4, $dlp, 0, 'L');
926
927 $posy = $pdf->GetY() + 1;
928 } elseif (property_exists($object, 'availability_code')
929 && property_exists($object, 'availability')
930 && (
931 $object->availability_code
932 || $object->availability
933 )
934 ) {
935 // Show availability conditions
936
937 $pdf->SetFont('', 'B', $default_font_size - 2);
938 $pdf->SetXY($this->marge_gauche, $posy);
939 $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
940 $pdf->MultiCell(80, 4, $titre, 0, 'L');
941 $pdf->SetTextColor(0, 0, 0);
942 $pdf->SetFont('', '', $default_font_size - 2);
943 $pdf->SetXY($posxval, $posy);
944 $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 : '');
945 $lib_availability = str_replace('\n', "\n", $lib_availability);
946 $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
947
948 $posy = $pdf->GetY() + 1;
949 }
950
951 // Show payment mode
952 if ($object->mode_reglement_code
953 && $object->mode_reglement_code != 'CHQ'
954 && $object->mode_reglement_code != 'VIR') {
955 $pdf->SetFont('', 'B', $default_font_size - 2);
956 $pdf->SetXY($this->marge_gauche, $posy);
957 $titre = $outputlangs->transnoentities("PaymentMode").':';
958 $pdf->MultiCell(80, 5, $titre, 0, 'L');
959
960 $pdf->SetFont('', '', $default_font_size - 2);
961 $pdf->SetXY($posxval, $posy);
962 $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);
963 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
964
965 $posy = $pdf->GetY() + 2;
966 }
967
968 // Show payment mode CHQ
969 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
970 // Si mode reglement non force ou si force a CHQ
971 if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
972 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
973 $account = new Account($this->db);
974 $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
975
976 $pdf->SetXY($this->marge_gauche, $posy);
977 $pdf->SetFont('', 'B', $default_font_size - 3);
978 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', false);
979 $posy = $pdf->GetY() + 1;
980
981 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
982 $pdf->SetXY($this->marge_gauche, $posy);
983 $pdf->SetFont('', '', $default_font_size - 3);
984 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', false);
985 $posy = $pdf->GetY() + 2;
986 }
987 }
988 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
989 $pdf->SetXY($this->marge_gauche, $posy);
990 $pdf->SetFont('', 'B', $default_font_size - 3);
991 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', false);
992 $posy = $pdf->GetY() + 1;
993
994 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
995 $pdf->SetXY($this->marge_gauche, $posy);
996 $pdf->SetFont('', '', $default_font_size - 3);
997 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', false);
998 $posy = $pdf->GetY() + 2;
999 }
1000 }
1001 }
1002 }
1003
1004 // If payment mode not forced or forced to VIR, show payment with BAN
1005 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
1006 if (!empty($object->fk_account) || !empty($object->fk_bank) || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
1007 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1008 if (!empty($object->fk_bank)) {
1009 $bankid = $object->fk_bank;
1010 } // For backward compatibility when object->fk_account is forced with object->fk_bank
1011 $account = new Account($this->db);
1012 $account->fetch($bankid);
1013
1014 $curx = $this->marge_gauche;
1015 $cury = $posy;
1016
1017 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1018
1019 $posy += 2;
1020 }
1021 }
1022
1023 return $posy;
1024 }
1025
1026
1037 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1038 {
1039 global $conf, $mysoc;
1040
1041 $default_font_size = pdf_getPDFFontSize($outputlangs);
1042
1043 $tab2_top = $posy;
1044 $tab2_hl = 4;
1045 $pdf->SetFont('', '', $default_font_size - 1);
1046
1047 // Tableau total
1048 $col1x = 120;
1049 $col2x = 170;
1050 if ($this->page_largeur < 210) { // To work with US executive format
1051 $col2x -= 20;
1052 }
1053 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1054 $useborder = 0;
1055 $index = 0;
1056
1057 $outputlangsbis = null;
1058 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
1059 $outputlangsbis = new Translate('', $conf);
1060 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
1061 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1062 }
1063
1064 // Total HT
1065 /*$pdf->SetFillColor(255, 255, 255);
1066 $pdf->SetXY($col1x, $tab2_top);
1067 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
1068 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1069 $pdf->SetXY($col2x, $tab2_top);
1070 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);*/
1071
1072 // Show VAT by rates and total
1073 $pdf->SetFillColor(248, 248, 248);
1074
1075 $total_ttc = $object->getValorisationTotale();
1076
1077 $this->atleastoneratenotnull = 0;
1078
1079 // Total TTC
1080 $index++;
1081 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1082 $pdf->SetTextColor(0, 0, 60);
1083 $pdf->SetFillColor(224, 224, 224);
1084 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("Total", $mysoc->country_code) : ''), $useborder, 'L', true);
1085
1086 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1087 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', true);
1088
1089 $pdf->SetTextColor(0, 0, 0);
1090
1091 $creditnoteamount = 0;
1092 $depositsamount = 0;
1093 //$creditnoteamount=$object->getSumCreditNotesUsed();
1094 //$depositsamount=$object->getSumDepositsUsed();
1095 //print "x".$creditnoteamount."-".$depositsamount;exit;
1096 $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1097 if (!empty($object->paye)) {
1098 $resteapayer = 0;
1099 }
1100
1101 if ($deja_regle > 0) {
1102 // Already paid + Deposits
1103 $index++;
1104
1105 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1106 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', false);
1107 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1108 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', false);
1109
1110 $index++;
1111 $pdf->SetTextColor(0, 0, 60);
1112 $pdf->SetFillColor(224, 224, 224);
1113 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1114 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', true);
1115
1116 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1117 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', true);
1118
1119 $pdf->SetFont('', '', $default_font_size - 1);
1120 $pdf->SetTextColor(0, 0, 0);
1121 }
1122
1123 $index++;
1124 return ($tab2_top + ($tab2_hl * $index));
1125 }
1126
1127 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1141 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1142 {
1143 global $conf;
1144
1145 // Force to disable hidetop and hidebottom
1146 $hidebottom = 0;
1147 if ($hidetop) {
1148 $hidetop = -1;
1149 }
1150
1151 $currency = !empty($currency) ? $currency : $conf->currency;
1152 $default_font_size = pdf_getPDFFontSize($outputlangs);
1153
1154 // Amount in (at tab_top - 1)
1155 $pdf->SetTextColor(0, 0, 0);
1156 $pdf->SetFont('', '', $default_font_size - 2);
1157
1158 if (empty($hidetop)) {
1159 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1160 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1161 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1162
1163 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1164 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1165 $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')));
1166 }
1167 }
1168
1169 $pdf->SetDrawColor(128, 128, 128);
1170 $pdf->SetFont('', '', $default_font_size - 1);
1171
1172 // Output Rect
1173 $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
1174
1175
1176 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1177
1178 if (empty($hidetop)) {
1179 $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
1180 }
1181 }
1182
1183 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1184 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1195 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "StockTransferSheetProforma")
1196 {
1197 // phpcs:enable
1198 global $conf, $langs;
1199
1200 '@phan-var-force StockTransfer $object';
1201
1202 // Load traductions files required by page
1203 $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1204
1205 $default_font_size = pdf_getPDFFontSize($outputlangs);
1206
1207 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1208
1209 // Show Draft Watermark
1210 if ($object->status == 0 && getDolGlobalString('STOCKTRANSFER_DRAFT_WATERMARK')) {
1211 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
1212 }
1213
1214 $pdf->SetTextColor(0, 0, 60);
1215 $pdf->SetFont('', 'B', $default_font_size + 3);
1216
1217 $w = 110;
1218
1219 $posy = $this->marge_haute;
1220 $posx = $this->page_largeur - $this->marge_droite - $w;
1221
1222 $pdf->SetXY($this->marge_gauche, $posy);
1223
1224 // Logo
1225 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1226 if ($this->emetteur->logo) {
1227 $logodir = $conf->mycompany->dir_output;
1228 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1229 $logodir = $conf->mycompany->multidir_output[$object->entity];
1230 }
1231 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1232 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1233 } else {
1234 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1235 }
1236 if (is_readable($logo)) {
1237 $height = pdf_getHeightForLogo($logo);
1238 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1239 } else {
1240 $pdf->SetTextColor(200, 0, 0);
1241 $pdf->SetFont('', 'B', $default_font_size - 2);
1242 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1243 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1244 }
1245 } else {
1246 $text = $this->emetteur->name;
1247 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1248 }
1249 }
1250
1251 $pdf->SetDrawColor(128, 128, 128);
1252
1253 $posx = $this->page_largeur - $w - $this->marge_droite;
1254 $posy = $this->marge_haute;
1255
1256 $pdf->SetFont('', 'B', $default_font_size + 2);
1257 $pdf->SetXY($posx, $posy);
1258 $pdf->SetTextColor(0, 0, 60);
1259 $title = $outputlangs->transnoentities("StockTransferSheet").' '.$object->ref;
1260 $pdf->MultiCell($w, 4, $title, '', 'R');
1261
1262 $pdf->SetFont('', '', $default_font_size + 1);
1263
1264 // Date prévue depart
1265 if (!empty($object->date_prevue_depart)) {
1266 $posy += 4;
1267 $pdf->SetXY($posx, $posy);
1268 $pdf->SetTextColor(0, 0, 60);
1269 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueDepart")." : ".dol_print_date($object->date_prevue_depart, "day", false, $outputlangs, true), '', 'R');
1270 }
1271
1272 // Date prévue arrivée
1273 if (!empty($object->date_prevue_arrivee)) {
1274 $posy += 4;
1275 $pdf->SetXY($posx, $posy);
1276 $pdf->SetTextColor(0, 0, 60);
1277 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueArrivee")." : ".dol_print_date($object->date_prevue_arrivee, "day", false, $outputlangs, true), '', 'R');
1278 }
1279
1280 // Date reelle depart
1281 if (!empty($object->date_reelle_depart)) {
1282 $posy += 4;
1283 $pdf->SetXY($posx, $posy);
1284 $pdf->SetTextColor(0, 0, 60);
1285 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleDepart")." : ".dol_print_date($object->date_reelle_depart, "day", false, $outputlangs, true), '', 'R');
1286 }
1287
1288 // Date reelle arrivée
1289 if (!empty($object->date_reelle_arrivee)) {
1290 $posy += 4;
1291 $pdf->SetXY($posx, $posy);
1292 $pdf->SetTextColor(0, 0, 60);
1293 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
1294 }
1295
1296 if (!empty($object->thirdparty->code_client)) {
1297 $posy += 4;
1298 $pdf->SetXY($posx, $posy);
1299 $pdf->SetTextColor(0, 0, 60);
1300 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1301 }
1302
1303 if ($object->ref_client) {
1304 $posy += 5;
1305 $pdf->SetXY($posx, $posy);
1306 $pdf->SetTextColor(0, 0, 60);
1307 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1308 }
1309
1310 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
1311 $object->fetchProject();
1312 if (!empty($object->project->ref)) {
1313 $posy += 3;
1314 $pdf->SetXY($posx, $posy);
1315 $pdf->SetTextColor(0, 0, 60);
1316 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
1317 }
1318 }
1319
1320 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
1321 $object->fetchProject();
1322 if (!empty($object->project->ref)) {
1323 $posy += 3;
1324 $pdf->SetXY($posx, $posy);
1325 $pdf->SetTextColor(0, 0, 60);
1326 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1327 }
1328 }
1329
1330 if (getDolGlobalString('DOC_SHOW_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1331 $posy += 4;
1332 $pdf->SetXY($posx, $posy);
1333 $pdf->SetTextColor(0, 0, 60);
1334 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1335 }
1336
1337 // Get contact
1338 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
1339 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1340 if (count($arrayidcontact) > 0) {
1341 $usertmp = new User($this->db);
1342 $usertmp->fetch($arrayidcontact[0]);
1343 $posy += 4;
1344 $pdf->SetXY($posx, $posy);
1345 $pdf->SetTextColor(0, 0, 60);
1346 $pdf->MultiCell(100, 3, $outputlangs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1347 }
1348 }
1349
1350 $posy += 2;
1351
1352 $top_shift = 0;
1353 // Show list of linked objects
1354 $current_y = $pdf->getY();
1355 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1356 if ($current_y < $pdf->getY()) {
1357 $top_shift = $pdf->getY() - $current_y;
1358 }
1359
1360 if ($showaddress) {
1361 // Sender properties
1362 $carac_emetteur = '';
1363 // Add internal contact of origin element if defined
1364 $arrayidcontact = array();
1365 $arrayidcontact = $object->getIdContact('external', 'STFROM');
1366
1367 $usecontact = false;
1368 if (count($arrayidcontact) > 0) {
1369 /*$object->fetch_user(reset($arrayidcontact));
1370 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
1371 $usecontact = true;
1372 $result = $object->fetch_contact($arrayidcontact[0]);
1373 }
1374
1375 if ($usecontact) {
1376 $thirdparty = $object->contact;
1377 } else {
1378 $thirdparty = $this->emetteur;
1379 }
1380
1381 if (!empty($thirdparty)) {
1382 $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1383 } else {
1384 $carac_emetteur_name = '';
1385 }
1386
1387 if ($usecontact) {
1388 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
1389 } else {
1390 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1391 }
1392
1393 // Show sender
1394 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1395 $posx = $this->marge_gauche;
1396 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1397 $posx = $this->page_largeur - $this->marge_droite - 80;
1398 }
1399
1400 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1401 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1402
1403 // Show sender frame
1404 $pdf->SetTextColor(0, 0, 0);
1405 $pdf->SetFont('', '', $default_font_size - 2);
1406 $pdf->SetXY($posx, $posy - 5);
1407 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1408 $pdf->SetXY($posx, $posy);
1409 $pdf->SetFillColor(230, 230, 230);
1410 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1411 $pdf->SetTextColor(0, 0, 60);
1412 $pdf->SetFillColor(255, 255, 255);
1413
1414 // Show sender name
1415 $pdf->SetXY($posx + 2, $posy + 3);
1416 $pdf->SetFont('', 'B', $default_font_size);
1417 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0, 'L');
1418 $posy = $pdf->getY();
1419
1420 // Show sender information
1421 $pdf->SetXY($posx + 2, $posy);
1422 $pdf->SetFont('', '', $default_font_size - 1);
1423 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1424
1425
1426 // If SHIPPING contact defined, we use it
1427 $usecontact = false;
1428 $arrayidcontact = $object->getIdContact('external', 'STDEST');
1429 if (count($arrayidcontact) > 0) {
1430 $usecontact = true;
1431 $result = $object->fetch_contact($arrayidcontact[0]);
1432 }
1433
1434 //Recipient name
1435 // On peut utiliser le nom de la societe du contact
1436 if ($usecontact/* && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)*/) {
1437 $thirdparty = $object->contact;
1438 } else {
1439 $thirdparty = $object->thirdparty;
1440 }
1441
1442 $carac_client_name = '';
1443 if (!empty($thirdparty)) {
1444 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1445 }
1446
1447 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), ($usecontact ? 1 : 0), 'targetwithdetails', $object);
1448
1449 // Show recipient
1450 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1451 if ($this->page_largeur < 210) {
1452 $widthrecbox = 84; // To work with US executive format
1453 }
1454 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1455 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1456 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1457 $posx = $this->marge_gauche;
1458 }
1459
1460 // Show recipient frame
1461 $pdf->SetTextColor(0, 0, 0);
1462 $pdf->SetFont('', '', $default_font_size - 2);
1463 $pdf->SetXY($posx + 2, $posy - 5);
1464 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1465 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1466
1467 // Show recipient name
1468 $pdf->SetXY($posx + 2, $posy + 3);
1469 $pdf->SetFont('', 'B', $default_font_size);
1470 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1471
1472 $posy = $pdf->getY();
1473
1474 // Show recipient information
1475 $pdf->SetFont('', '', $default_font_size - 1);
1476 $pdf->SetXY($posx + 2, $posy);
1477 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1478 }
1479
1480 $pdf->SetTextColor(0, 0, 0);
1481
1482 return $top_shift;
1483 }
1484
1485 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1486 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1496 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1497 {
1498 // phpcs:enable
1499 '@phan-var-force StockTransfer $object';
1500
1501 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1502 return pdf_pagefoot($pdf, $outputlangs, 'STOCKTRANSFER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1503 }
1504
1505
1506
1517 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1518 {
1519 global $conf, $hookmanager;
1520 '@phan-var-force StockTransfer $object';
1523 // Default field style for content
1524 $this->defaultContentsFieldsStyle = array(
1525 'align' => 'R', // R,C,L
1526 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1527 );
1528
1529 // Default field style for content
1530 $this->defaultTitlesFieldsStyle = array(
1531 'align' => 'C', // R,C,L
1532 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1533 );
1534
1535 /*
1536 * For example
1537 $this->cols['theColKey'] = array(
1538 'rank' => $rank, // int : use for ordering columns
1539 'width' => 20, // the column width in mm
1540 'title' => array(
1541 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1542 'label' => ' ', // the final label : used fore final generated text
1543 'align' => 'L', // text alignment : R,C,L
1544 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1545 ),
1546 'content' => array(
1547 'align' => 'L', // text alignment : R,C,L
1548 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1549 ),
1550 );
1551 */
1552
1553 $rank = 0; // do not use negative rank
1554 $this->cols['desc'] = array(
1555 'rank' => $rank,
1556 'width' => false, // only for desc
1557 'status' => true,
1558 'title' => array(
1559 'textkey' => 'Designation', // use lang key is useful in somme case with module
1560 'align' => 'L',
1561 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1562 // 'label' => ' ', // the final label
1563 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1564 ),
1565 'content' => array(
1566 'align' => 'L',
1567 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1568 ),
1569 );
1570
1571 $rank += 10;
1572 $this->cols['photo'] = array(
1573 'rank' => $rank,
1574 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
1575 'status' => false,
1576 'title' => array(
1577 'textkey' => 'Photo',
1578 'label' => ' '
1579 ),
1580 'content' => array(
1581 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1582 ),
1583 'border-left' => false, // remove left line separator
1584 );
1585
1586 if (getDolGlobalString('MAIN_GENERATE_ORDERS_WITH_PICTURE')) {
1587 $this->cols['photo']['status'] = true;
1588 }
1589
1590
1591 $rank += 10;
1592 $this->cols['vat'] = array(
1593 'rank' => $rank,
1594 'status' => false,
1595 'width' => 16, // in mm
1596 'title' => array(
1597 'textkey' => 'VAT'
1598 ),
1599 'border-left' => true, // add left line separator
1600 );
1601
1602 /*if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1603 {
1604 $this->cols['vat']['status'] = true;
1605 }*/
1606
1607 $rank += 10;
1608 $this->cols['subprice'] = array(
1609 'rank' => $rank,
1610 'width' => 19, // in mm
1611 'status' => true,
1612 'title' => array(
1613 'textkey' => 'PMPValueShort'
1614 ),
1615 'border-left' => true, // add left line separator
1616 );
1617
1618 // Adapt dynamically the width of subprice, if text is too long.
1619 $tmpwidth = 0;
1620 $nblines = is_array($object->lines) ? count($object->lines) : 0;
1621 for ($i = 0; $i < $nblines; $i++) {
1622 $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
1623 $tmpwidth = max($tmpwidth, $tmpwidth2);
1624 }
1625 if ($tmpwidth > 10) {
1626 $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
1627 }
1628
1629 $rank += 10;
1630 $this->cols['qty'] = array(
1631 'rank' => $rank,
1632 'width' => 16, // in mm
1633 'status' => true,
1634 'title' => array(
1635 'textkey' => 'Qty'
1636 ),
1637 'border-left' => true, // add left line separator
1638 );
1639
1640 $rank += 10;
1641 $this->cols['unit'] = array(
1642 'rank' => $rank,
1643 'width' => 11, // in mm
1644 'status' => false,
1645 'title' => array(
1646 'textkey' => 'Unit'
1647 ),
1648 'border-left' => true, // add left line separator
1649 );
1650 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1651 $this->cols['unit']['status'] = true;
1652 }
1653
1654 $rank += 10;
1655 $this->cols['discount'] = array(
1656 'rank' => $rank,
1657 'width' => 13, // in mm
1658 'status' => false,
1659 'title' => array(
1660 'textkey' => 'ReductionShort'
1661 ),
1662 'border-left' => true, // add left line separator
1663 );
1664 if ($this->atleastonediscount) {
1665 $this->cols['discount']['status'] = true;
1666 }
1667
1668 $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1669 $this->cols['totalexcltax'] = array(
1670 'rank' => $rank,
1671 'width' => 26, // in mm
1672 'status' => true,
1673 'title' => array(
1674 'textkey' => 'TotalHTShort'
1675 ),
1676 'border-left' => true, // add left line separator
1677 );
1678
1679 // Add extrafields cols
1680 if (!empty($object->lines)) {
1681 $line = reset($object->lines);
1682 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1683 }
1684
1685 $parameters = array(
1686 'object' => $object,
1687 'outputlangs' => $outputlangs,
1688 'hidedetails' => $hidedetails,
1689 'hidedesc' => $hidedesc,
1690 'hideref' => $hideref
1691 );
1692
1693 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1694 if ($reshook < 0) {
1695 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1696 } elseif (empty($reshook)) {
1697 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1698 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1699 } else {
1700 $this->cols = $hookmanager->resArray;
1701 }
1702 }
1703}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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.
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_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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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:2731
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: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:1047
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2080
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:2018
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:1425
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
Definition pdf.lib.php:863
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 formatted for output on PDF documents.
Definition pdf.lib.php:439
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
Definition pdf.lib.php:2325
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2368
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2165
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:778
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:391
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:798
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:158
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161