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