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