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