dolibarr 20.0.5
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 $logodir = $conf->mycompany->dir_output;
286 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
287 $logodir = $conf->mycompany->multidir_output[$object->entity];
288 }
289 $pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
290 $tplidx = $pdf->importPage(1);
291 }
292
293 $pdf->Open();
294 $pagenb = 0;
295 $pdf->SetDrawColor(128, 128, 128);
296
297 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
298 $pdf->SetSubject($outputlangs->transnoentities("StockTransferSheetProforma"));
299 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
300 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
301 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("StockTransfer"));
302 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
303 $pdf->SetCompression(false);
304 }
305
306 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
307 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
308
310 if (is_array($object->lines)) {
311 foreach ($object->lines as $line) {
312 if ($line->remise_percent) {
313 $this->atleastonediscount = true;
314 break;
315 }
316 }
317 }
318
319 // New page
320 $pdf->AddPage();
321 if (!empty($tplidx)) {
322 $pdf->useTemplate($tplidx);
323 }
324 $pagenb++;
325 $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
326 $pdf->SetFont('', '', $default_font_size - 1);
327 $pdf->MultiCell(0, 3, ''); // Set interline to 3
328 $pdf->SetTextColor(0, 0, 0);
329
330
331 $tab_top = 90 + $top_shift;
332 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
333 $tab_height = 130;
334
335 // Incoterm
336 $height_incoterms = 0;
337 if (isModEnabled('incoterm')) {
338 $desc_incoterms = $object->getIncotermsForPDF();
339 if ($desc_incoterms) {
340 $tab_top -= 2;
341
342 $pdf->SetFont('', '', $default_font_size - 1);
343 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
344 $nexY = $pdf->GetY();
345 $height_incoterms = $nexY - $tab_top;
346
347 // Rect takes a length in 3rd parameter
348 $pdf->SetDrawColor(192, 192, 192);
349 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
350
351 $tab_top = $nexY + 6;
352 $height_incoterms += 4;
353 }
354 }
355
356 // Displays notes
357 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
358 if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
359 // Get first sale rep
360 if (is_object($object->thirdparty)) {
361 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
362 $salerepobj = new User($this->db);
363 $salerepobj->fetch($salereparray[0]['id']);
364 if (!empty($salerepobj->signature)) {
365 $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
366 }
367 }
368 }
369
370 // Extrafields in note
371 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
372 if (!empty($extranote)) {
373 $notetoshow = dol_concatdesc($notetoshow, $extranote);
374 }
375
376 $pagenb = $pdf->getPage();
377 if ($notetoshow) {
378 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
379 $pageposbeforenote = $pagenb;
380
381 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
382 complete_substitutions_array($substitutionarray, $outputlangs, $object);
383 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
384 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
385
386 $tab_top -= 2;
387
388 $pdf->startTransaction();
389
390 $pdf->SetFont('', '', $default_font_size - 1);
391 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
392 // Description
393 $pageposafternote = $pdf->getPage();
394 $posyafter = $pdf->GetY();
395
396 if ($pageposafternote > $pageposbeforenote) {
397 $pdf->rollbackTransaction(true);
398
399 // prepare pages to receive notes
400 while ($pagenb < $pageposafternote) {
401 $pdf->AddPage();
402 $pagenb++;
403 if (!empty($tplidx)) {
404 $pdf->useTemplate($tplidx);
405 }
406 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
407 $this->_pagehead($pdf, $object, 0, $outputlangs);
408 }
409 // $this->_pagefoot($pdf,$object,$outputlangs,1);
410 $pdf->setTopMargin($tab_top_newpage);
411 // The only function to edit the bottom margin of current page to set it.
412 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
413 }
414
415 // back to start
416 $pdf->setPage($pageposbeforenote);
417 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
418 $pdf->SetFont('', '', $default_font_size - 1);
419 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
420 $pageposafternote = $pdf->getPage();
421
422 $posyafter = $pdf->GetY();
423
424 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
425 $pdf->AddPage('', '', true);
426 $pagenb++;
427 $pageposafternote++;
428 $pdf->setPage($pageposafternote);
429 $pdf->setTopMargin($tab_top_newpage);
430 // The only function to edit the bottom margin of current page to set it.
431 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
432 //$posyafter = $tab_top_newpage;
433 }
434
435
436 // apply note frame to previous pages
437 $i = $pageposbeforenote;
438 while ($i < $pageposafternote) {
439 $pdf->setPage($i);
440
441
442 $pdf->SetDrawColor(128, 128, 128);
443 // Draw note frame
444 if ($i > $pageposbeforenote) {
445 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
446 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
447 } else {
448 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
449 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
450 }
451
452 // Add footer
453 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
454 $this->_pagefoot($pdf, $object, $outputlangs, 1);
455
456 $i++;
457 }
458
459 // apply note frame to last page
460 $pdf->setPage($pageposafternote);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
463 }
464 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
465 $this->_pagehead($pdf, $object, 0, $outputlangs);
466 }
467 $height_note = $posyafter - $tab_top_newpage;
468 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
469 } else { // No pagebreak
470 $pdf->commitTransaction();
471 $posyafter = $pdf->GetY();
472 $height_note = $posyafter - $tab_top;
473 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
474
475
476 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
477 // not enough space, need to add page
478 $pdf->AddPage('', '', true);
479 $pagenb++;
480 $pageposafternote++;
481 $pdf->setPage($pageposafternote);
482 if (!empty($tplidx)) {
483 $pdf->useTemplate($tplidx);
484 }
485 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
486 $this->_pagehead($pdf, $object, 0, $outputlangs);
487 }
488
489 $posyafter = $tab_top_newpage;
490 }
491 }
492
493 $tab_height = $tab_height - $height_note;
494 $tab_top = $posyafter + 6;
495 } else {
496 $height_note = 0;
497 }
498
499
500 // Use new auto column system
501 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
502
503 // tab simulation to know line height
504 $pdf->startTransaction();
505 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
506 $pdf->rollbackTransaction(true);
507
508 $nexY = $tab_top + $this->tabTitleHeight;
509
510 // Loop on each lines
511 $pageposbeforeprintlines = $pdf->getPage();
512 $pagenb = $pageposbeforeprintlines;
513 for ($i = 0; $i < $nblines; $i++) {
514 $curY = $nexY;
515 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
516 $pdf->SetTextColor(0, 0, 0);
517
518 // Define size of image if we need it
519 $imglinesize = array();
520 if (!empty($realpatharray[$i])) {
521 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
522 }
523
524 $pdf->setTopMargin($tab_top_newpage);
525 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
526 $pageposbefore = $pdf->getPage();
527
528
529 $showpricebeforepagebreak = 1;
530 $posYAfterImage = 0;
531
532 if ($this->getColumnStatus('photo')) {
533 // We start with Photo of product line
534 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
535 $pdf->AddPage('', '', true);
536 if (!empty($tplidx)) {
537 $pdf->useTemplate($tplidx);
538 }
539 $pdf->setPage($pageposbefore + 1);
540
541 $curY = $tab_top_newpage;
542
543 // Allows data in the first page if description is long enough to break in multiples pages
544 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
545 $showpricebeforepagebreak = 1;
546 } else {
547 $showpricebeforepagebreak = 0;
548 }
549 }
550
551 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
552 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
553 // $pdf->Image does not increase value return by getY, so we save it manually
554 $posYAfterImage = $curY + $imglinesize['height'];
555 }
556 }
557
558 if ($this->getColumnStatus('desc')) {
559 $pdf->startTransaction();
560
561 if (method_exists($object->lines[$i], 'fetch_product')) {
562 $object->lines[$i]->fetch_product();
563 $object->lines[$i]->label = $object->lines[$i]->product->label;
564 $object->lines[$i]->description = $object->lines[$i]->product->description;
565 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
566 }
567
568 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
569
570 $pageposafter = $pdf->getPage();
571 if ($pageposafter > $pageposbefore) { // There is a pagebreak
572 $pdf->rollbackTransaction(true);
573 $pageposafter = $pageposbefore;
574 //print $pageposafter.'-'.$pageposbefore;exit;
575 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
576 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
577
578 $pageposafter = $pdf->getPage();
579 $posyafter = $pdf->GetY();
580 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
581 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
582 $pdf->AddPage('', '', true);
583 if (!empty($tplidx)) {
584 $pdf->useTemplate($tplidx);
585 }
586 //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
587 $pdf->setPage($pageposafter + 1);
588 }
589 } else {
590 // We found a page break
591 // Allows data in the first page if description is long enough to break in multiples pages
592 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
593 $showpricebeforepagebreak = 1;
594 } else {
595 $showpricebeforepagebreak = 0;
596 }
597 }
598 } else { // No pagebreak
599 $pdf->commitTransaction();
600 }
601 }
602
603
604
605 $nexY = max($pdf->GetY(), $posYAfterImage);
606
607
608 $pageposafter = $pdf->getPage();
609
610 $pdf->setPage($pageposbefore);
611 $pdf->setTopMargin($this->marge_haute);
612 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
613
614 // We suppose that a too long description is moved completely on next page
615 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
616 $pdf->setPage($pageposafter);
617 $curY = $tab_top_newpage;
618 }
619
620 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
621
622 // VAT Rate
623 if ($this->getColumnStatus('vat')) {
624 $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
625 $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
626 $nexY = max($pdf->GetY(), $nexY);
627 }
628
629 // Unit price before discount
630 if ($this->getColumnStatus('subprice')) {
631 $pmp = $object->lines[$i]->pmp;
632 $this->printStdColumnContent($pdf, $curY, 'subprice', price($pmp));
633 $nexY = max($pdf->GetY(), $nexY);
634 }
635
636 // Quantity
637 // Enough for 6 chars
638 if ($this->getColumnStatus('qty')) {
639 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
640 $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
641 $nexY = max($pdf->GetY(), $nexY);
642 }
643
644
645 // Unit
646 if ($this->getColumnStatus('unit')) {
647 $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails);
648 $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
649 $nexY = max($pdf->GetY(), $nexY);
650 }
651
652 // Discount on line
653 if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
654 $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
655 $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
656 $nexY = max($pdf->GetY(), $nexY);
657 }
658
659 // Total HT line
660 if ($this->getColumnStatus('totalexcltax')) {
661 $pmp_qty = $pmp * $object->lines[$i]->qty;
662 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($pmp_qty));
663 $nexY = max($pdf->GetY(), $nexY);
664 }
665
666 // Extrafields
667 if (!empty($object->lines[$i]->array_options)) {
668 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
669 if ($this->getColumnStatus($extrafieldColKey)) {
670 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
671 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
672 $nexY = max($pdf->GetY(), $nexY);
673 }
674 }
675 }
676
677 $parameters = array(
678 'object' => $object,
679 'i' => $i,
680 'pdf' => & $pdf,
681 'curY' => & $curY,
682 'nexY' => & $nexY,
683 'outputlangs' => $outputlangs,
684 'hidedetails' => $hidedetails
685 );
686 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
687
688
689 // Collection of totals by value of vat in $this->tva["rate"] = total_tva
690 if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
691 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
692 } else {
693 $tvaligne = $object->lines[$i]->total_tva;
694 }
695
696 /*
697 $localtax1ligne = $object->lines[$i]->total_localtax1;
698 $localtax2ligne = $object->lines[$i]->total_localtax2;
699 $localtax1_rate = $object->lines[$i]->localtax1_tx;
700 $localtax2_rate = $object->lines[$i]->localtax2_tx;
701 $localtax1_type = $object->lines[$i]->localtax1_type;
702 $localtax2_type = $object->lines[$i]->localtax2_type;
703
704 $vatrate = (string) $object->lines[$i]->tva_tx;
705
706 // Retrieve type from database for backward compatibility with old records
707 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
708 && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
709 $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
710 $localtax1_type = $localtaxtmp_array[0];
711 $localtax2_type = $localtaxtmp_array[2];
712 }
713
714 // retrieve global local tax
715 if ($localtax1_type && $localtax1ligne != 0) {
716 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
717 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
718 } else {
719 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
720 }
721 }
722 if ($localtax2_type && $localtax2ligne != 0) {
723 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
724 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
725 } else {
726 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
727 }
728 }
729
730 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
731 $vatrate .= '*';
732 }
733 if (!isset($this->tva[$vatrate])) {
734 $this->tva[$vatrate] = 0;
735 }
736 $this->tva[$vatrate] += $tvaligne;
737 */
738
739 // Add line
740 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
741 $pdf->setPage($pageposafter);
742 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
743 //$pdf->SetDrawColor(190,190,200);
744 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
745 $pdf->SetLineStyle(array('dash' => 0));
746 }
747
748
749 // Detect if some page were added automatically and output _tableau for past pages
750 while ($pagenb < $pageposafter) {
751 $pdf->setPage($pagenb);
752 if ($pagenb == $pageposbeforeprintlines) {
753 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
754 } else {
755 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
756 }
757 $this->_pagefoot($pdf, $object, $outputlangs, 1);
758 $pagenb++;
759 $pdf->setPage($pagenb);
760 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
761 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
762 $this->_pagehead($pdf, $object, 0, $outputlangs);
763 }
764 }
765 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
766 if ($pagenb == $pageposafter) {
767 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
768 } else {
769 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
770 }
771 $this->_pagefoot($pdf, $object, $outputlangs, 1);
772 // New page
773 $pdf->AddPage();
774 if (!empty($tplidx)) {
775 $pdf->useTemplate($tplidx);
776 }
777 $pagenb++;
778 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
779 $this->_pagehead($pdf, $object, 0, $outputlangs);
780 }
781 }
782 }
783
784 // Show square
785 if ($pagenb == $pageposbeforeprintlines) {
786 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
787 } else {
788 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
789 }
790 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
791
792 // Display total area
793 $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
794
795 // Pagefoot
796 $this->_pagefoot($pdf, $object, $outputlangs);
797 if (method_exists($pdf, 'AliasNbPages')) {
798 $pdf->AliasNbPages();
799 }
800
801 $pdf->Close();
802
803 $pdf->Output($file, 'F');
804
805 // Add pdfgeneration hook
806 $hookmanager->initHooks(array('pdfgeneration'));
807 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
808 global $action;
809 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
810 if ($reshook < 0) {
811 $this->error = $hookmanager->error;
812 $this->errors = $hookmanager->errors;
813 }
814
815 dolChmod($file);
816
817 $this->result = array('fullpath' => $file);
818
819 return 1; // No error
820 } else {
821 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
822 return 0;
823 }
824 } else {
825 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR");
826 return 0;
827 }
828 }
829
839 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
840 {
841 global $conf, $mysoc;
842 $default_font_size = pdf_getPDFFontSize($outputlangs);
843
844 $pdf->SetFont('', '', $default_font_size - 1);
845
846 // If France, show VAT mention if not applicable
847 if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
848 $pdf->SetFont('', 'B', $default_font_size - 2);
849 $pdf->SetXY($this->marge_gauche, $posy);
850 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
851
852 $posy = $pdf->GetY() + 4;
853 }
854
855 $posxval = 52;
856
857 // Show payments conditions
858 if ($object->cond_reglement_code || $object->cond_reglement) {
859 $pdf->SetFont('', 'B', $default_font_size - 2);
860 $pdf->SetXY($this->marge_gauche, $posy);
861 $titre = $outputlangs->transnoentities("PaymentConditions").':';
862 $pdf->MultiCell(43, 4, $titre, 0, 'L');
863
864 $pdf->SetFont('', '', $default_font_size - 2);
865 $pdf->SetXY($posxval, $posy);
866 $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);
867 $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
868 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
869
870 $posy = $pdf->GetY() + 3;
871 }
872
873 // Check a payment mode is defined
874 /* Not used with orders
875 if (empty($object->mode_reglement_code)
876 && ! $conf->global->FACTURE_CHQ_NUMBER
877 && ! $conf->global->FACTURE_RIB_NUMBER)
878 {
879 $pdf->SetXY($this->marge_gauche, $posy);
880 $pdf->SetTextColor(200,0,0);
881 $pdf->SetFont('','B', $default_font_size - 2);
882 $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
883 $pdf->SetTextColor(0,0,0);
884
885 $posy=$pdf->GetY()+1;
886 }
887 */
888 /* TODO
889 else if (!empty($object->availability_code))
890 {
891 $pdf->SetXY($this->marge_gauche, $posy);
892 $pdf->SetTextColor(200,0,0);
893 $pdf->SetFont('','B', $default_font_size - 2);
894 $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
895 $pdf->SetTextColor(0,0,0);
896
897 $posy=$pdf->GetY()+1;
898 }*/
899
900 // Show planned date of delivery
901 if (!empty($object->delivery_date)) {
902 $outputlangs->load("sendings");
903 $pdf->SetFont('', 'B', $default_font_size - 2);
904 $pdf->SetXY($this->marge_gauche, $posy);
905 $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
906 $pdf->MultiCell(80, 4, $titre, 0, 'L');
907 $pdf->SetFont('', '', $default_font_size - 2);
908 $pdf->SetXY($posxval, $posy);
909 $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
910 $pdf->MultiCell(80, 4, $dlp, 0, 'L');
911
912 $posy = $pdf->GetY() + 1;
913 } elseif ($object->availability_code || $object->availability) { // Show availability conditions
914 $pdf->SetFont('', 'B', $default_font_size - 2);
915 $pdf->SetXY($this->marge_gauche, $posy);
916 $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
917 $pdf->MultiCell(80, 4, $titre, 0, 'L');
918 $pdf->SetTextColor(0, 0, 0);
919 $pdf->SetFont('', '', $default_font_size - 2);
920 $pdf->SetXY($posxval, $posy);
921 $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 : '');
922 $lib_availability = str_replace('\n', "\n", $lib_availability);
923 $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
924
925 $posy = $pdf->GetY() + 1;
926 }
927
928 // Show payment mode
929 if ($object->mode_reglement_code
930 && $object->mode_reglement_code != 'CHQ'
931 && $object->mode_reglement_code != 'VIR') {
932 $pdf->SetFont('', 'B', $default_font_size - 2);
933 $pdf->SetXY($this->marge_gauche, $posy);
934 $titre = $outputlangs->transnoentities("PaymentMode").':';
935 $pdf->MultiCell(80, 5, $titre, 0, 'L');
936
937 $pdf->SetFont('', '', $default_font_size - 2);
938 $pdf->SetXY($posxval, $posy);
939 $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);
940 $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
941
942 $posy = $pdf->GetY() + 2;
943 }
944
945 // Show payment mode CHQ
946 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
947 // Si mode reglement non force ou si force a CHQ
948 if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
949 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
950 $account = new Account($this->db);
951 $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
952
953 $pdf->SetXY($this->marge_gauche, $posy);
954 $pdf->SetFont('', 'B', $default_font_size - 3);
955 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->owner_name), 0, 'L', 0);
956 $posy = $pdf->GetY() + 1;
957
958 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
959 $pdf->SetXY($this->marge_gauche, $posy);
960 $pdf->SetFont('', '', $default_font_size - 3);
961 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
962 $posy = $pdf->GetY() + 2;
963 }
964 }
965 if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
966 $pdf->SetXY($this->marge_gauche, $posy);
967 $pdf->SetFont('', 'B', $default_font_size - 3);
968 $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
969 $posy = $pdf->GetY() + 1;
970
971 if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
972 $pdf->SetXY($this->marge_gauche, $posy);
973 $pdf->SetFont('', '', $default_font_size - 3);
974 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
975 $posy = $pdf->GetY() + 2;
976 }
977 }
978 }
979 }
980
981 // If payment mode not forced or forced to VIR, show payment with BAN
982 if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
983 if (!empty($object->fk_account) || !empty($object->fk_bank) || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
984 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
985 if (!empty($object->fk_bank)) {
986 $bankid = $object->fk_bank;
987 } // For backward compatibility when object->fk_account is forced with object->fk_bank
988 $account = new Account($this->db);
989 $account->fetch($bankid);
990
991 $curx = $this->marge_gauche;
992 $cury = $posy;
993
994 $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
995
996 $posy += 2;
997 }
998 }
999
1000 return $posy;
1001 }
1002
1003
1014 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1015 {
1016 global $conf, $mysoc;
1017
1018 $default_font_size = pdf_getPDFFontSize($outputlangs);
1019
1020 $tab2_top = $posy;
1021 $tab2_hl = 4;
1022 $pdf->SetFont('', '', $default_font_size - 1);
1023
1024 // Tableau total
1025 $col1x = 120;
1026 $col2x = 170;
1027 if ($this->page_largeur < 210) { // To work with US executive format
1028 $col2x -= 20;
1029 }
1030 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1031 $useborder = 0;
1032 $index = 0;
1033
1034 $outputlangsbis = null;
1035 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
1036 $outputlangsbis = new Translate('', $conf);
1037 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
1038 $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1039 }
1040
1041 // Total HT
1042 /*$pdf->SetFillColor(255, 255, 255);
1043 $pdf->SetXY($col1x, $tab2_top);
1044 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
1045 $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1046 $pdf->SetXY($col2x, $tab2_top);
1047 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);*/
1048
1049 // Show VAT by rates and total
1050 $pdf->SetFillColor(248, 248, 248);
1051
1052 $total_ttc = $object->getValorisationTotale();
1053
1054 $this->atleastoneratenotnull = 0;
1055
1056 // Total TTC
1057 $index++;
1058 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1059 $pdf->SetTextColor(0, 0, 60);
1060 $pdf->SetFillColor(224, 224, 224);
1061 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("Total", $mysoc->country_code) : ''), $useborder, 'L', 1);
1062
1063 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1064 $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1065
1066 $pdf->SetTextColor(0, 0, 0);
1067
1068 $creditnoteamount = 0;
1069 $depositsamount = 0;
1070 //$creditnoteamount=$object->getSumCreditNotesUsed();
1071 //$depositsamount=$object->getSumDepositsUsed();
1072 //print "x".$creditnoteamount."-".$depositsamount;exit;
1073 $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1074 if (!empty($object->paye)) {
1075 $resteapayer = 0;
1076 }
1077
1078 if ($deja_regle > 0) {
1079 // Already paid + Deposits
1080 $index++;
1081
1082 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1083 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1084 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1086
1087 $index++;
1088 $pdf->SetTextColor(0, 0, 60);
1089 $pdf->SetFillColor(224, 224, 224);
1090 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1091 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
1092
1093 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1094 $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1095
1096 $pdf->SetFont('', '', $default_font_size - 1);
1097 $pdf->SetTextColor(0, 0, 0);
1098 }
1099
1100 $index++;
1101 return ($tab2_top + ($tab2_hl * $index));
1102 }
1103
1104 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1118 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1119 {
1120 global $conf;
1121
1122 // Force to disable hidetop and hidebottom
1123 $hidebottom = 0;
1124 if ($hidetop) {
1125 $hidetop = -1;
1126 }
1127
1128 $currency = !empty($currency) ? $currency : $conf->currency;
1129 $default_font_size = pdf_getPDFFontSize($outputlangs);
1130
1131 // Amount in (at tab_top - 1)
1132 $pdf->SetTextColor(0, 0, 0);
1133 $pdf->SetFont('', '', $default_font_size - 2);
1134
1135 if (empty($hidetop)) {
1136 $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1137 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1138 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1139
1140 //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1141 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1142 $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')));
1143 }
1144 }
1145
1146 $pdf->SetDrawColor(128, 128, 128);
1147 $pdf->SetFont('', '', $default_font_size - 1);
1148
1149 // Output Rect
1150 $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
1151
1152
1153 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1154
1155 if (empty($hidetop)) {
1156 $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
1157 }
1158 }
1159
1160 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1161 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1172 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "StockTransferSheetProforma")
1173 {
1174 // phpcs:enable
1175 global $conf, $langs;
1176
1177 // Load traductions files required by page
1178 $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1179
1180 $default_font_size = pdf_getPDFFontSize($outputlangs);
1181
1182 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1183
1184 // Show Draft Watermark
1185 if ($object->statut == 0 && getDolGlobalString('STOCKTRANSFER_DRAFT_WATERMARK')) {
1186 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
1187 }
1188
1189 $pdf->SetTextColor(0, 0, 60);
1190 $pdf->SetFont('', 'B', $default_font_size + 3);
1191
1192 $w = 110;
1193
1194 $posy = $this->marge_haute;
1195 $posx = $this->page_largeur - $this->marge_droite - $w;
1196
1197 $pdf->SetXY($this->marge_gauche, $posy);
1198
1199 // Logo
1200 if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
1201 if ($this->emetteur->logo) {
1202 $logodir = $conf->mycompany->dir_output;
1203 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1204 $logodir = $conf->mycompany->multidir_output[$object->entity];
1205 }
1206 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1207 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1208 } else {
1209 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1210 }
1211 if (is_readable($logo)) {
1212 $height = pdf_getHeightForLogo($logo);
1213 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1214 } else {
1215 $pdf->SetTextColor(200, 0, 0);
1216 $pdf->SetFont('', 'B', $default_font_size - 2);
1217 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1218 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1219 }
1220 } else {
1221 $text = $this->emetteur->name;
1222 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1223 }
1224 }
1225
1226 $pdf->SetDrawColor(128, 128, 128);
1227
1228 $posx = $this->page_largeur - $w - $this->marge_droite;
1229 $posy = $this->marge_haute;
1230
1231 $pdf->SetFont('', 'B', $default_font_size + 2);
1232 $pdf->SetXY($posx, $posy);
1233 $pdf->SetTextColor(0, 0, 60);
1234 $title = $outputlangs->transnoentities("StockTransferSheet").' '.$object->ref;
1235 $pdf->MultiCell($w, 4, $title, '', 'R');
1236
1237 $pdf->SetFont('', '', $default_font_size + 1);
1238
1239 // Date prévue depart
1240 if (!empty($object->date_prevue_depart)) {
1241 $posy += 4;
1242 $pdf->SetXY($posx, $posy);
1243 $pdf->SetTextColor(0, 0, 60);
1244 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueDepart")." : ".dol_print_date($object->date_prevue_depart, "day", false, $outputlangs, true), '', 'R');
1245 }
1246
1247 // Date prévue arrivée
1248 if (!empty($object->date_prevue_arrivee)) {
1249 $posy += 4;
1250 $pdf->SetXY($posx, $posy);
1251 $pdf->SetTextColor(0, 0, 60);
1252 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueArrivee")." : ".dol_print_date($object->date_prevue_arrivee, "day", false, $outputlangs, true), '', 'R');
1253 }
1254
1255 // Date reelle depart
1256 if (!empty($object->date_reelle_depart)) {
1257 $posy += 4;
1258 $pdf->SetXY($posx, $posy);
1259 $pdf->SetTextColor(0, 0, 60);
1260 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleDepart")." : ".dol_print_date($object->date_reelle_depart, "day", false, $outputlangs, true), '', 'R');
1261 }
1262
1263 // Date reelle arrivée
1264 if (!empty($object->date_reelle_arrivee)) {
1265 $posy += 4;
1266 $pdf->SetXY($posx, $posy);
1267 $pdf->SetTextColor(0, 0, 60);
1268 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
1269 }
1270
1271 if (!empty($object->thirdparty->code_client)) {
1272 $posy += 4;
1273 $pdf->SetXY($posx, $posy);
1274 $pdf->SetTextColor(0, 0, 60);
1275 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1276 }
1277
1278 if ($object->ref_client) {
1279 $posy += 5;
1280 $pdf->SetXY($posx, $posy);
1281 $pdf->SetTextColor(0, 0, 60);
1282 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1283 }
1284
1285 if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
1286 $object->fetch_projet();
1287 if (!empty($object->project->ref)) {
1288 $posy += 3;
1289 $pdf->SetXY($posx, $posy);
1290 $pdf->SetTextColor(0, 0, 60);
1291 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
1292 }
1293 }
1294
1295 if (getDolGlobalString('PDF_SHOW_PROJECT')) {
1296 $object->fetch_projet();
1297 if (!empty($object->project->ref)) {
1298 $posy += 3;
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetTextColor(0, 0, 60);
1301 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1302 }
1303 }
1304
1305 if (getDolGlobalString('DOC_SHOW_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1306 $posy += 4;
1307 $pdf->SetXY($posx, $posy);
1308 $pdf->SetTextColor(0, 0, 60);
1309 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1310 }
1311
1312 // Get contact
1313 if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
1314 $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1315 if (count($arrayidcontact) > 0) {
1316 $usertmp = new User($this->db);
1317 $usertmp->fetch($arrayidcontact[0]);
1318 $posy += 4;
1319 $pdf->SetXY($posx, $posy);
1320 $pdf->SetTextColor(0, 0, 60);
1321 $pdf->MultiCell(100, 3, $outputlangs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1322 }
1323 }
1324
1325 $posy += 2;
1326
1327 $top_shift = 0;
1328 // Show list of linked objects
1329 $current_y = $pdf->getY();
1330 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1331 if ($current_y < $pdf->getY()) {
1332 $top_shift = $pdf->getY() - $current_y;
1333 }
1334
1335 if ($showaddress) {
1336 // Sender properties
1337 $carac_emetteur = '';
1338 // Add internal contact of origin element if defined
1339 $arrayidcontact = array();
1340 $arrayidcontact = $object->getIdContact('external', 'STFROM');
1341
1342 $usecontact = false;
1343 if (count($arrayidcontact) > 0) {
1344 /*$object->fetch_user(reset($arrayidcontact));
1345 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
1346 $usecontact = true;
1347 $result = $object->fetch_contact($arrayidcontact[0]);
1348 }
1349
1350 if ($usecontact) {
1351 $thirdparty = $object->contact;
1352 } else {
1353 $thirdparty = $this->emetteur;
1354 }
1355
1356 if (!empty($thirdparty)) {
1357 $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1358 }
1359
1360 if ($usecontact) {
1361 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
1362 } else {
1363 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1364 }
1365
1366 // Show sender
1367 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1368 $posx = $this->marge_gauche;
1369 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1370 $posx = $this->page_largeur - $this->marge_droite - 80;
1371 }
1372
1373 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1374 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1375
1376 // Show sender frame
1377 $pdf->SetTextColor(0, 0, 0);
1378 $pdf->SetFont('', '', $default_font_size - 2);
1379 $pdf->SetXY($posx, $posy - 5);
1380 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1381 $pdf->SetXY($posx, $posy);
1382 $pdf->SetFillColor(230, 230, 230);
1383 $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1384 $pdf->SetTextColor(0, 0, 60);
1385 $pdf->SetFillColor(255, 255, 255);
1386
1387 // Show sender name
1388 $pdf->SetXY($posx + 2, $posy + 3);
1389 $pdf->SetFont('', 'B', $default_font_size);
1390 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0, 'L');
1391 $posy = $pdf->getY();
1392
1393 // Show sender information
1394 $pdf->SetXY($posx + 2, $posy);
1395 $pdf->SetFont('', '', $default_font_size - 1);
1396 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1397
1398
1399 // If SHIPPING contact defined, we use it
1400 $usecontact = false;
1401 $arrayidcontact = $object->getIdContact('external', 'STDEST');
1402 if (count($arrayidcontact) > 0) {
1403 $usecontact = true;
1404 $result = $object->fetch_contact($arrayidcontact[0]);
1405 }
1406
1407 //Recipient name
1408 // On peut utiliser le nom de la societe du contact
1409 if ($usecontact/* && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)*/) {
1410 $thirdparty = $object->contact;
1411 } else {
1412 $thirdparty = $object->thirdparty;
1413 }
1414
1415 $carac_client_name = '';
1416 if (!empty($thirdparty)) {
1417 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1418 }
1419
1420 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1421
1422 // Show recipient
1423 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1424 if ($this->page_largeur < 210) {
1425 $widthrecbox = 84; // To work with US executive format
1426 }
1427 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1428 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1429 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1430 $posx = $this->marge_gauche;
1431 }
1432
1433 // Show recipient frame
1434 $pdf->SetTextColor(0, 0, 0);
1435 $pdf->SetFont('', '', $default_font_size - 2);
1436 $pdf->SetXY($posx + 2, $posy - 5);
1437 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1438 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1439
1440 // Show recipient name
1441 $pdf->SetXY($posx + 2, $posy + 3);
1442 $pdf->SetFont('', 'B', $default_font_size);
1443 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1444
1445 $posy = $pdf->getY();
1446
1447 // Show recipient information
1448 $pdf->SetFont('', '', $default_font_size - 1);
1449 $pdf->SetXY($posx + 2, $posy);
1450 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1451 }
1452
1453 $pdf->SetTextColor(0, 0, 0);
1454
1455 return $top_shift;
1456 }
1457
1458 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1459 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1469 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1470 {
1471 // phpcs:enable
1472 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1473 return pdf_pagefoot($pdf, $outputlangs, 'STOCKTRANSFER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1474 }
1475
1476
1477
1488 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1489 {
1490 global $conf, $hookmanager;
1491
1492 // Default field style for content
1493 $this->defaultContentsFieldsStyle = array(
1494 'align' => 'R', // R,C,L
1495 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1496 );
1497
1498 // Default field style for content
1499 $this->defaultTitlesFieldsStyle = array(
1500 'align' => 'C', // R,C,L
1501 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1502 );
1503
1504 /*
1505 * For example
1506 $this->cols['theColKey'] = array(
1507 'rank' => $rank, // int : use for ordering columns
1508 'width' => 20, // the column width in mm
1509 'title' => array(
1510 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1511 'label' => ' ', // the final label : used fore final generated text
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 'content' => array(
1516 'align' => 'L', // text alignment : R,C,L
1517 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1518 ),
1519 );
1520 */
1521
1522 $rank = 0; // do not use negative rank
1523 $this->cols['desc'] = array(
1524 'rank' => $rank,
1525 'width' => false, // only for desc
1526 'status' => true,
1527 'title' => array(
1528 'textkey' => 'Designation', // use lang key is useful in somme case with module
1529 'align' => 'L',
1530 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1531 // 'label' => ' ', // the final label
1532 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1533 ),
1534 'content' => array(
1535 'align' => 'L',
1536 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1537 ),
1538 );
1539
1540 $rank = $rank + 10;
1541 $this->cols['photo'] = array(
1542 'rank' => $rank,
1543 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
1544 'status' => false,
1545 'title' => array(
1546 'textkey' => 'Photo',
1547 'label' => ' '
1548 ),
1549 'content' => array(
1550 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1551 ),
1552 'border-left' => false, // remove left line separator
1553 );
1554
1555 if (getDolGlobalString('MAIN_GENERATE_ORDERS_WITH_PICTURE')) {
1556 $this->cols['photo']['status'] = true;
1557 }
1558
1559
1560 $rank = $rank + 10;
1561 $this->cols['vat'] = array(
1562 'rank' => $rank,
1563 'status' => false,
1564 'width' => 16, // in mm
1565 'title' => array(
1566 'textkey' => 'VAT'
1567 ),
1568 'border-left' => true, // add left line separator
1569 );
1570
1571 /*if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1572 {
1573 $this->cols['vat']['status'] = true;
1574 }*/
1575
1576 $rank = $rank + 10;
1577 $this->cols['subprice'] = array(
1578 'rank' => $rank,
1579 'width' => 19, // in mm
1580 'status' => true,
1581 'title' => array(
1582 'textkey' => 'PMPValueShort'
1583 ),
1584 'border-left' => true, // add left line separator
1585 );
1586
1587 // Adapt dynamically the width of subprice, if text is too long.
1588 $tmpwidth = 0;
1589 $nblines = is_array($object->lines) ? count($object->lines) : 0;
1590 for ($i = 0; $i < $nblines; $i++) {
1591 $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
1592 $tmpwidth = max($tmpwidth, $tmpwidth2);
1593 }
1594 if ($tmpwidth > 10) {
1595 $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
1596 }
1597
1598 $rank = $rank + 10;
1599 $this->cols['qty'] = array(
1600 'rank' => $rank,
1601 'width' => 16, // in mm
1602 'status' => true,
1603 'title' => array(
1604 'textkey' => 'Qty'
1605 ),
1606 'border-left' => true, // add left line separator
1607 );
1608
1609 $rank = $rank + 10;
1610 $this->cols['unit'] = array(
1611 'rank' => $rank,
1612 'width' => 11, // in mm
1613 'status' => false,
1614 'title' => array(
1615 'textkey' => 'Unit'
1616 ),
1617 'border-left' => true, // add left line separator
1618 );
1619 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
1620 $this->cols['unit']['status'] = true;
1621 }
1622
1623 $rank = $rank + 10;
1624 $this->cols['discount'] = array(
1625 'rank' => $rank,
1626 'width' => 13, // in mm
1627 'status' => false,
1628 'title' => array(
1629 'textkey' => 'ReductionShort'
1630 ),
1631 'border-left' => true, // add left line separator
1632 );
1633 if ($this->atleastonediscount) {
1634 $this->cols['discount']['status'] = true;
1635 }
1636
1637 $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
1638 $this->cols['totalexcltax'] = array(
1639 'rank' => $rank,
1640 'width' => 26, // in mm
1641 'status' => true,
1642 'title' => array(
1643 'textkey' => 'TotalHTShort'
1644 ),
1645 'border-left' => true, // add left line separator
1646 );
1647
1648 // Add extrafields cols
1649 if (!empty($object->lines)) {
1650 $line = reset($object->lines);
1651 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1652 }
1653
1654 $parameters = array(
1655 'object' => $object,
1656 'outputlangs' => $outputlangs,
1657 'hidedetails' => $hidedetails,
1658 'hidedesc' => $hidedesc,
1659 'hideref' => $hideref
1660 );
1661
1662 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1663 if ($reshook < 0) {
1664 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1665 } elseif (empty($reshook)) {
1666 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1667 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1668 } else {
1669 $this->cols = $hookmanager->resArray;
1670 }
1671 }
1672}
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:2686
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:290
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:315
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1027
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition pdf.lib.php:2040
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition pdf.lib.php:1978
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:1401
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
Definition pdf.lib.php:850
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:2285
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition pdf.lib.php:2328
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition pdf.lib.php:2125
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:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140