dolibarr  16.0.5
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(5, 5);
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 = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
149  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
150  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
151  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->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 (!empty($conf->global->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 (empty($conf->global->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 (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
330 
331  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
332 
334  foreach ($object->lines as $line) {
335  if ($line->remise_percent) {
336  $this->atleastonediscount = true;
337  break;
338  }
339  }
340 
341 
342  // New page
343  $pdf->AddPage();
344  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
345  $pagenb++;
346  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
347  $pdf->SetFont('', '', $default_font_size - 1);
348  $pdf->MultiCell(0, 3, ''); // Set interline to 3
349  $pdf->SetTextColor(0, 0, 0);
350 
351 
352  $tab_top = 90 + $top_shift;
353  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
354 
355  // Incoterm
356  if ($conf->incoterm->enabled) {
357  $desc_incoterms = $object->getIncotermsForPDF();
358  if ($desc_incoterms) {
359  $tab_top -= 2;
360 
361  $pdf->SetFont('', '', $default_font_size - 1);
362  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
363  $nexY = $pdf->GetY();
364  $height_incoterms = $nexY - $tab_top;
365 
366  // Rect takes a length in 3rd parameter
367  $pdf->SetDrawColor(192, 192, 192);
368  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
369 
370  $tab_top = $nexY + 6;
371  }
372  }
373 
374  // Displays notes
375  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
376  if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
377  // Get first sale rep
378  if (is_object($object->thirdparty)) {
379  $salereparray = $object->thirdparty->getSalesRepresentatives($user);
380  $salerepobj = new User($this->db);
381  $salerepobj->fetch($salereparray[0]['id']);
382  if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
383  }
384  }
385 
386  // Extrafields in note
387  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
388  if (!empty($extranote)) {
389  $notetoshow = dol_concatdesc($notetoshow, $extranote);
390  }
391 
392  $pagenb = $pdf->getPage();
393  if ($notetoshow) {
394  $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
395  $pageposbeforenote = $pagenb;
396 
397  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
398  complete_substitutions_array($substitutionarray, $outputlangs, $object);
399  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
400  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
401 
402  $tab_top -= 2;
403 
404  $pdf->startTransaction();
405 
406  $pdf->SetFont('', '', $default_font_size - 1);
407  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
408  // Description
409  $pageposafternote = $pdf->getPage();
410  $posyafter = $pdf->GetY();
411 
412  if ($pageposafternote > $pageposbeforenote) {
413  $pdf->rollbackTransaction(true);
414 
415  // prepare pages to receive notes
416  while ($pagenb < $pageposafternote) {
417  $pdf->AddPage();
418  $pagenb++;
419  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
420  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
421  // $this->_pagefoot($pdf,$object,$outputlangs,1);
422  $pdf->setTopMargin($tab_top_newpage);
423  // The only function to edit the bottom margin of current page to set it.
424  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
425  }
426 
427  // back to start
428  $pdf->setPage($pageposbeforenote);
429  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
430  $pdf->SetFont('', '', $default_font_size - 1);
431  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
432  $pageposafternote = $pdf->getPage();
433 
434  $posyafter = $pdf->GetY();
435 
436  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
437  $pdf->AddPage('', '', true);
438  $pagenb++;
439  $pageposafternote++;
440  $pdf->setPage($pageposafternote);
441  $pdf->setTopMargin($tab_top_newpage);
442  // The only function to edit the bottom margin of current page to set it.
443  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
444  //$posyafter = $tab_top_newpage;
445  }
446 
447 
448  // apply note frame to previous pages
449  $i = $pageposbeforenote;
450  while ($i < $pageposafternote) {
451  $pdf->setPage($i);
452 
453 
454  $pdf->SetDrawColor(128, 128, 128);
455  // Draw note frame
456  if ($i > $pageposbeforenote) {
457  $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
458  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
459  } else {
460  $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
461  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
462  }
463 
464  // Add footer
465  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
466  $this->_pagefoot($pdf, $object, $outputlangs, 1);
467 
468  $i++;
469  }
470 
471  // apply note frame to last page
472  $pdf->setPage($pageposafternote);
473  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
474  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
475  $height_note = $posyafter - $tab_top_newpage;
476  $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
477  } else // No pagebreak
478  {
479  $pdf->commitTransaction();
480  $posyafter = $pdf->GetY();
481  $height_note = $posyafter - $tab_top;
482  $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
483 
484 
485  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
486  // not enough space, need to add page
487  $pdf->AddPage('', '', true);
488  $pagenb++;
489  $pageposafternote++;
490  $pdf->setPage($pageposafternote);
491  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
492  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
493 
494  $posyafter = $tab_top_newpage;
495  }
496  }
497 
498  $tab_height = $tab_height - $height_note;
499  $tab_top = $posyafter + 6;
500  } else {
501  $height_note = 0;
502  }
503 
504 
505  // Use new auto column system
506  $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
507 
508  // tab simulation to know line height
509  $pdf->startTransaction();
510  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
511  $pdf->rollbackTransaction(true);
512 
513  $nexY = $tab_top + $this->tabTitleHeight;
514 
515  // Loop on each lines
516  $pageposbeforeprintlines = $pdf->getPage();
517  $pagenb = $pageposbeforeprintlines;
518  for ($i = 0; $i < $nblines; $i++) {
519  $curY = $nexY;
520  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
521  $pdf->SetTextColor(0, 0, 0);
522 
523  // Define size of image if we need it
524  $imglinesize = array();
525  if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
526 
527  $pdf->setTopMargin($tab_top_newpage);
528  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
529  $pageposbefore = $pdf->getPage();
530 
531 
532  $showpricebeforepagebreak = 1;
533  $posYAfterImage = 0;
534 
535  if ($this->getColumnStatus('photo')) {
536  // We start with Photo of product line
537  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
538  $pdf->AddPage('', '', true);
539  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
540  $pdf->setPage($pageposbefore + 1);
541 
542  $curY = $tab_top_newpage;
543 
544  // Allows data in the first page if description is long enough to break in multiples pages
545  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
546  $showpricebeforepagebreak = 1;
547  else $showpricebeforepagebreak = 0;
548  }
549 
550  if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
551  $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
552  // $pdf->Image does not increase value return by getY, so we save it manually
553  $posYAfterImage = $curY + $imglinesize['height'];
554  }
555  }
556 
557  if ($this->getColumnStatus('desc')) {
558  $pdf->startTransaction();
559 
560  if (method_exists($object->lines[$i], 'fetch_product')) {
561  $object->lines[$i]->fetch_product();
562  $object->lines[$i]->label = $object->lines[$i]->product->label;
563  $object->lines[$i]->description = $object->lines[$i]->product->description;
564  $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
565  }
566 
567  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
568 
569  $pageposafter = $pdf->getPage();
570  if ($pageposafter > $pageposbefore) { // There is a pagebreak
571  $pdf->rollbackTransaction(true);
572  $pageposafter = $pageposbefore;
573  //print $pageposafter.'-'.$pageposbefore;exit;
574  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
575 
576  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
577  $pageposafter = $pdf->getPage();
578  $posyafter = $pdf->GetY();
579  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
580  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
581  $pdf->AddPage('', '', true);
582  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
583  //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
584  $pdf->setPage($pageposafter + 1);
585  }
586  } else {
587  // We found a page break
588  // Allows data in the first page if description is long enough to break in multiples pages
589  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
590  $showpricebeforepagebreak = 1;
591  else $showpricebeforepagebreak = 0;
592  }
593  } else // No pagebreak
594  {
595  $pdf->commitTransaction();
596  }
597  }
598 
599 
600 
601  $nexY = max($pdf->GetY(), $posYAfterImage);
602 
603 
604  $pageposafter = $pdf->getPage();
605 
606  $pdf->setPage($pageposbefore);
607  $pdf->setTopMargin($this->marge_haute);
608  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
609 
610  // We suppose that a too long description is moved completely on next page
611  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
612  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
613  }
614 
615  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
616 
617  // VAT Rate
618  if ($this->getColumnStatus('vat')) {
619  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
620  $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
621  $nexY = max($pdf->GetY(), $nexY);
622  }
623 
624  // Unit price before discount
625  if ($this->getColumnStatus('subprice')) {
626  $pmp = $object->lines[$i]->pmp;
627  $this->printStdColumnContent($pdf, $curY, 'subprice', price($pmp));
628  $nexY = max($pdf->GetY(), $nexY);
629  }
630 
631  // Quantity
632  // Enough for 6 chars
633  if ($this->getColumnStatus('qty')) {
634  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
635  $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
636  $nexY = max($pdf->GetY(), $nexY);
637  }
638 
639 
640  // Unit
641  if ($this->getColumnStatus('unit')) {
642  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
643  $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
644  $nexY = max($pdf->GetY(), $nexY);
645  }
646 
647  // Discount on line
648  if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
649  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
650  $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
651  $nexY = max($pdf->GetY(), $nexY);
652  }
653 
654  // Total HT line
655  if ($this->getColumnStatus('totalexcltax')) {
656  $pmp_qty = $pmp * $object->lines[$i]->qty;
657  $this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($pmp_qty));
658  $nexY = max($pdf->GetY(), $nexY);
659  }
660 
661  // Extrafields
662  if (!empty($object->lines[$i]->array_options)) {
663  foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
664  if ($this->getColumnStatus($extrafieldColKey)) {
665  $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
666  $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
667  $nexY = max($pdf->GetY(), $nexY);
668  }
669  }
670  }
671 
672  $parameters = array(
673  'object' => $object,
674  'i' => $i,
675  'pdf' =>& $pdf,
676  'curY' =>& $curY,
677  'nexY' =>& $nexY,
678  'outputlangs' => $outputlangs,
679  'hidedetails' => $hidedetails
680  );
681  $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
682 
683 
684  // Collection of totals by value of vat in $this->tva["rate"] = total_tva
685  if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
686  else $tvaligne = $object->lines[$i]->total_tva;
687 
688  $localtax1ligne = $object->lines[$i]->total_localtax1;
689  $localtax2ligne = $object->lines[$i]->total_localtax2;
690  $localtax1_rate = $object->lines[$i]->localtax1_tx;
691  $localtax2_rate = $object->lines[$i]->localtax2_tx;
692  $localtax1_type = $object->lines[$i]->localtax1_type;
693  $localtax2_type = $object->lines[$i]->localtax2_type;
694 
695  if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
696  if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
697  if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
698 
699  $vatrate = (string) $object->lines[$i]->tva_tx;
700 
701  // Retrieve type from database for backward compatibility with old records
702  if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
703  && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
704  $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
705  $localtax1_type = $localtaxtmp_array[0];
706  $localtax2_type = $localtaxtmp_array[2];
707  }
708 
709  // retrieve global local tax
710  if ($localtax1_type && $localtax1ligne != 0)
711  $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
712  if ($localtax2_type && $localtax2ligne != 0)
713  $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
714 
715  if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
716  if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
717  $this->tva[$vatrate] += $tvaligne;
718 
719  // Add line
720  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
721  $pdf->setPage($pageposafter);
722  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
723  //$pdf->SetDrawColor(190,190,200);
724  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
725  $pdf->SetLineStyle(array('dash'=>0));
726  }
727 
728 
729  // Detect if some page were added automatically and output _tableau for past pages
730  while ($pagenb < $pageposafter) {
731  $pdf->setPage($pagenb);
732  if ($pagenb == $pageposbeforeprintlines) {
733  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
734  } else {
735  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
736  }
737  $this->_pagefoot($pdf, $object, $outputlangs, 1);
738  $pagenb++;
739  $pdf->setPage($pagenb);
740  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
741  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
742  }
743  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
744  if ($pagenb == $pageposafter) {
745  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
746  } else {
747  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
748  }
749  $this->_pagefoot($pdf, $object, $outputlangs, 1);
750  // New page
751  $pdf->AddPage();
752  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
753  $pagenb++;
754  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
755  }
756  }
757 
758  // Show square
759  if ($pagenb == $pageposbeforeprintlines)
760  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
761  else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
762  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
763 
764  // Affiche zone infos
765  // ! No paiement information for this model !
766  //$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
767 
768  // Affiche zone totaux
769  $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
770 
771  // Affiche zone versements
772  /*
773  if ($deja_regle)
774  {
775  $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
776  }
777  */
778 
779  // Pied de page
780  $this->_pagefoot($pdf, $object, $outputlangs);
781  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
782 
783  $pdf->Close();
784 
785  $pdf->Output($file, 'F');
786 
787  // Add pdfgeneration hook
788  $hookmanager->initHooks(array('pdfgeneration'));
789  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
790  global $action;
791  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
792  if ($reshook < 0) {
793  $this->error = $hookmanager->error;
794  $this->errors = $hookmanager->errors;
795  }
796 
797  if (!empty($conf->global->MAIN_UMASK))
798  @chmod($file, octdec($conf->global->MAIN_UMASK));
799 
800  $this->result = array('fullpath'=>$file);
801 
802  return 1; // No error
803  } else {
804  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
805  return 0;
806  }
807  } else {
808  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR");
809  return 0;
810  }
811  }
812 
822  protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
823  {
824  }
825 
835  protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
836  {
837  global $conf, $mysoc;
838  $default_font_size = pdf_getPDFFontSize($outputlangs);
839 
840  $pdf->SetFont('', '', $default_font_size - 1);
841 
842  // If France, show VAT mention if not applicable
843  if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
844  $pdf->SetFont('', 'B', $default_font_size - 2);
845  $pdf->SetXY($this->marge_gauche, $posy);
846  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
847 
848  $posy = $pdf->GetY() + 4;
849  }
850 
851  $posxval = 52;
852 
853  // Show payments conditions
854  if ($object->cond_reglement_code || $object->cond_reglement) {
855  $pdf->SetFont('', 'B', $default_font_size - 2);
856  $pdf->SetXY($this->marge_gauche, $posy);
857  $titre = $outputlangs->transnoentities("PaymentConditions").':';
858  $pdf->MultiCell(43, 4, $titre, 0, 'L');
859 
860  $pdf->SetFont('', '', $default_font_size - 2);
861  $pdf->SetXY($posxval, $posy);
862  $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
863  $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
864  $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
865 
866  $posy = $pdf->GetY() + 3;
867  }
868 
869  // Check a payment mode is defined
870  /* Not used with orders
871  if (empty($object->mode_reglement_code)
872  && ! $conf->global->FACTURE_CHQ_NUMBER
873  && ! $conf->global->FACTURE_RIB_NUMBER)
874  {
875  $pdf->SetXY($this->marge_gauche, $posy);
876  $pdf->SetTextColor(200,0,0);
877  $pdf->SetFont('','B', $default_font_size - 2);
878  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
879  $pdf->SetTextColor(0,0,0);
880 
881  $posy=$pdf->GetY()+1;
882  }
883  */
884  /* TODO
885  else if (! empty($object->availability_code))
886  {
887  $pdf->SetXY($this->marge_gauche, $posy);
888  $pdf->SetTextColor(200,0,0);
889  $pdf->SetFont('','B', $default_font_size - 2);
890  $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
891  $pdf->SetTextColor(0,0,0);
892 
893  $posy=$pdf->GetY()+1;
894  }*/
895 
896  // Show planed date of delivery
897  if (!empty($object->date_livraison)) {
898  $outputlangs->load("sendings");
899  $pdf->SetFont('', 'B', $default_font_size - 2);
900  $pdf->SetXY($this->marge_gauche, $posy);
901  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
902  $pdf->MultiCell(80, 4, $titre, 0, 'L');
903  $pdf->SetFont('', '', $default_font_size - 2);
904  $pdf->SetXY($posxval, $posy);
905  $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
906  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
907 
908  $posy = $pdf->GetY() + 1;
909  } elseif ($object->availability_code || $object->availability) { // Show availability conditions
910  $pdf->SetFont('', 'B', $default_font_size - 2);
911  $pdf->SetXY($this->marge_gauche, $posy);
912  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
913  $pdf->MultiCell(80, 4, $titre, 0, 'L');
914  $pdf->SetTextColor(0, 0, 0);
915  $pdf->SetFont('', '', $default_font_size - 2);
916  $pdf->SetXY($posxval, $posy);
917  $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
918  $lib_availability = str_replace('\n', "\n", $lib_availability);
919  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
920 
921  $posy = $pdf->GetY() + 1;
922  }
923 
924  // Show payment mode
925  if ($object->mode_reglement_code
926  && $object->mode_reglement_code != 'CHQ'
927  && $object->mode_reglement_code != 'VIR') {
928  $pdf->SetFont('', 'B', $default_font_size - 2);
929  $pdf->SetXY($this->marge_gauche, $posy);
930  $titre = $outputlangs->transnoentities("PaymentMode").':';
931  $pdf->MultiCell(80, 5, $titre, 0, 'L');
932 
933  $pdf->SetFont('', '', $default_font_size - 2);
934  $pdf->SetXY($posxval, $posy);
935  $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
936  $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
937 
938  $posy = $pdf->GetY() + 2;
939  }
940 
941  // Show payment mode CHQ
942  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
943  // Si mode reglement non force ou si force a CHQ
944  if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
945  if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
946  $account = new Account($this->db);
947  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
948 
949  $pdf->SetXY($this->marge_gauche, $posy);
950  $pdf->SetFont('', 'B', $default_font_size - 3);
951  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
952  $posy = $pdf->GetY() + 1;
953 
954  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
955  $pdf->SetXY($this->marge_gauche, $posy);
956  $pdf->SetFont('', '', $default_font_size - 3);
957  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
958  $posy = $pdf->GetY() + 2;
959  }
960  }
961  if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
962  $pdf->SetXY($this->marge_gauche, $posy);
963  $pdf->SetFont('', 'B', $default_font_size - 3);
964  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
965  $posy = $pdf->GetY() + 1;
966 
967  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
968  $pdf->SetXY($this->marge_gauche, $posy);
969  $pdf->SetFont('', '', $default_font_size - 3);
970  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
971  $posy = $pdf->GetY() + 2;
972  }
973  }
974  }
975  }
976 
977  // If payment mode not forced or forced to VIR, show payment with BAN
978  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
979  if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
980  $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
981  if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
982  $account = new Account($this->db);
983  $account->fetch($bankid);
984 
985  $curx = $this->marge_gauche;
986  $cury = $posy;
987 
988  $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
989 
990  $posy += 2;
991  }
992  }
993 
994  return $posy;
995  }
996 
997 
1008  protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1009  {
1010  global $conf, $mysoc;
1011 
1012  $default_font_size = pdf_getPDFFontSize($outputlangs);
1013 
1014  $tab2_top = $posy;
1015  $tab2_hl = 4;
1016  $pdf->SetFont('', '', $default_font_size - 1);
1017 
1018  // Tableau total
1019  $col1x = 120; $col2x = 170;
1020  if ($this->page_largeur < 210) { // To work with US executive format
1021  $col2x -= 20;
1022  }
1023  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1024  $useborder = 0;
1025  $index = 0;
1026 
1027  $outputlangsbis = null;
1028  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1029  $outputlangsbis = new Translate('', $conf);
1030  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1031  $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
1032  }
1033 
1034  // Total HT
1035  /*$pdf->SetFillColor(255, 255, 255);
1036  $pdf->SetXY($col1x, $tab2_top + 0);
1037  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
1038  $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1039  $pdf->SetXY($col2x, $tab2_top + 0);
1040  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);*/
1041 
1042  // Show VAT by rates and total
1043  $pdf->SetFillColor(248, 248, 248);
1044 
1045  $total_ttc = $object->getValorisationTotale();
1046 
1047  $this->atleastoneratenotnull = 0;
1048 
1049  // Total TTC
1050  $index++;
1051  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1052  $pdf->SetTextColor(0, 0, 60);
1053  $pdf->SetFillColor(224, 224, 224);
1054  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("Total", $mysoc->country_code) : ''), $useborder, 'L', 1);
1055 
1056  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1058 
1059  $pdf->SetTextColor(0, 0, 0);
1060 
1061  $creditnoteamount = 0;
1062  $depositsamount = 0;
1063  //$creditnoteamount=$object->getSumCreditNotesUsed();
1064  //$depositsamount=$object->getSumDepositsUsed();
1065  //print "x".$creditnoteamount."-".$depositsamount;exit;
1066  $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1067  if (!empty($object->paye)) $resteapayer = 0;
1068 
1069  if ($deja_regle > 0) {
1070  // Already paid + Deposits
1071  $index++;
1072 
1073  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1074  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
1075  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1076  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1077 
1078  $index++;
1079  $pdf->SetTextColor(0, 0, 60);
1080  $pdf->SetFillColor(224, 224, 224);
1081  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1082  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
1083 
1084  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1086 
1087  $pdf->SetFont('', '', $default_font_size - 1);
1088  $pdf->SetTextColor(0, 0, 0);
1089  }
1090 
1091  $index++;
1092  return ($tab2_top + ($tab2_hl * $index));
1093  }
1094 
1095  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1109  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1110  {
1111  global $conf;
1112 
1113  // Force to disable hidetop and hidebottom
1114  $hidebottom = 0;
1115  if ($hidetop) $hidetop = -1;
1116 
1117  $currency = !empty($currency) ? $currency : $conf->currency;
1118  $default_font_size = pdf_getPDFFontSize($outputlangs);
1119 
1120  // Amount in (at tab_top - 1)
1121  $pdf->SetTextColor(0, 0, 0);
1122  $pdf->SetFont('', '', $default_font_size - 2);
1123 
1124  if (empty($hidetop)) {
1125  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1126  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1127  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1128 
1129  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1130  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1131  $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));
1132  }
1133  }
1134 
1135  $pdf->SetDrawColor(128, 128, 128);
1136  $pdf->SetFont('', '', $default_font_size - 1);
1137 
1138  // Output Rect
1139  $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
1140 
1141 
1142  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1143 
1144  if (empty($hidetop)) {
1145  $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
1146  }
1147  }
1148 
1149  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1150  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1161  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "StockTransferSheetProforma")
1162  {
1163  // phpcs:enable
1164  global $conf, $langs, $hookmanager;
1165 
1166  // Load traductions files required by page
1167  $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1168 
1169  $default_font_size = pdf_getPDFFontSize($outputlangs);
1170 
1171  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1172 
1173  // Show Draft Watermark
1174  if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
1175  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1176  }
1177 
1178  $pdf->SetTextColor(0, 0, 60);
1179  $pdf->SetFont('', 'B', $default_font_size + 3);
1180 
1181  $posy = $this->marge_haute;
1182  $posx = $this->page_largeur - $this->marge_droite - 100;
1183 
1184  $pdf->SetXY($this->marge_gauche, $posy);
1185 
1186  // Logo
1187  if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1188  if ($this->emetteur->logo) {
1189  $logodir = $conf->mycompany->dir_output;
1190  if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1191  if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1192  $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1193  } else {
1194  $logo = $logodir.'/logos/'.$this->emetteur->logo;
1195  }
1196  if (is_readable($logo)) {
1197  $height = pdf_getHeightForLogo($logo);
1198  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1199  } else {
1200  $pdf->SetTextColor(200, 0, 0);
1201  $pdf->SetFont('', 'B', $default_font_size - 2);
1202  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1203  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1204  }
1205  } else {
1206  $text = $this->emetteur->name;
1207  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1208  }
1209  }
1210 
1211  $pdf->SetFont('', 'B', $default_font_size + 3);
1212  $pdf->SetXY($posx, $posy);
1213  $pdf->SetTextColor(0, 0, 60);
1214  $title = $outputlangs->transnoentities($titlekey);
1215  $pdf->MultiCell(100, 3, $title, '', 'R');
1216 
1217  $pdf->SetFont('', 'B', $default_font_size);
1218 
1219  $posy += 5;
1220  $pdf->SetXY($posx, $posy);
1221  $pdf->SetTextColor(0, 0, 60);
1222  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1223 
1224  $posy += 1;
1225  $pdf->SetFont('', '', $default_font_size - 1);
1226 
1227  // Date prévue depart
1228  if (!empty($object->date_prevue_depart)) {
1229  $posy += 4;
1230  $pdf->SetXY($posx, $posy);
1231  $pdf->SetTextColor(0, 0, 60);
1232  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueDepart")." : ".dol_print_date($object->date_prevue_depart, "day", false, $outputlangs, true), '', 'R');
1233  }
1234 
1235  // Date prévue arrivée
1236  if (!empty($object->date_prevue_arrivee)) {
1237  $posy += 4;
1238  $pdf->SetXY($posx, $posy);
1239  $pdf->SetTextColor(0, 0, 60);
1240  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueArrivee")." : ".dol_print_date($object->date_prevue_arrivee, "day", false, $outputlangs, true), '', 'R');
1241  }
1242 
1243  // Date reelle depart
1244  if (!empty($object->date_reelle_depart)) {
1245  $posy += 4;
1246  $pdf->SetXY($posx, $posy);
1247  $pdf->SetTextColor(0, 0, 60);
1248  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleDepart")." : ".dol_print_date($object->date_reelle_depart, "day", false, $outputlangs, true), '', 'R');
1249  }
1250 
1251  // Date reelle arrivée
1252  if (!empty($object->date_reelle_arrivee)) {
1253  $posy += 4;
1254  $pdf->SetXY($posx, $posy);
1255  $pdf->SetTextColor(0, 0, 60);
1256  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
1257  }
1258 
1259  if ($object->ref_client) {
1260  $posy += 5;
1261  $pdf->SetXY($posx, $posy);
1262  $pdf->SetTextColor(0, 0, 60);
1263  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1264  }
1265 
1266  if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1267  $object->fetch_projet();
1268  if (!empty($object->project->ref)) {
1269  $posy += 3;
1270  $pdf->SetXY($posx, $posy);
1271  $pdf->SetTextColor(0, 0, 60);
1272  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
1273  }
1274  }
1275 
1276  if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1277  $object->fetch_projet();
1278  if (!empty($object->project->ref)) {
1279  $posy += 3;
1280  $pdf->SetXY($posx, $posy);
1281  $pdf->SetTextColor(0, 0, 60);
1282  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1283  }
1284  }
1285 
1286  if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1287  $posy += 4;
1288  $pdf->SetXY($posx, $posy);
1289  $pdf->SetTextColor(0, 0, 60);
1290  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1291  }
1292 
1293  // Get contact
1294  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1295  $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1296  if (count($arrayidcontact) > 0) {
1297  $usertmp = new User($this->db);
1298  $usertmp->fetch($arrayidcontact[0]);
1299  $posy += 4;
1300  $pdf->SetXY($posx, $posy);
1301  $pdf->SetTextColor(0, 0, 60);
1302  $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1303  }
1304  }
1305 
1306  $posy += 2;
1307 
1308  $top_shift = 0;
1309  // Show list of linked objects
1310  $current_y = $pdf->getY();
1311  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1312  if ($current_y < $pdf->getY()) {
1313  $top_shift = $pdf->getY() - $current_y;
1314  }
1315 
1316  if ($showaddress) {
1317  // Sender properties
1318  $carac_emetteur = '';
1319  // Add internal contact of origin element if defined
1320  $arrayidcontact = array();
1321  $arrayidcontact = $object->getIdContact('external', 'STFROM');
1322 
1323  $usecontact = false;
1324  if (count($arrayidcontact) > 0) {
1325  /*$object->fetch_user(reset($arrayidcontact));
1326  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
1327  $usecontact = true;
1328  $result = $object->fetch_contact($arrayidcontact[0]);
1329  }
1330 
1331  if ($usecontact) $thirdparty = $object->contact;
1332  else $thirdparty = $this->emetteur;
1333 
1334  if (!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1335 
1336  if ($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
1337  else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1338 
1339  // Show sender
1340  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1341  $posx = $this->marge_gauche;
1342  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1343 
1344  $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1345  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1346 
1347  // Show sender frame
1348  $pdf->SetTextColor(0, 0, 0);
1349  $pdf->SetFont('', '', $default_font_size - 2);
1350  $pdf->SetXY($posx, $posy - 5);
1351  $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1352  $pdf->SetXY($posx, $posy);
1353  $pdf->SetFillColor(230, 230, 230);
1354  $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1355  $pdf->SetTextColor(0, 0, 60);
1356  $pdf->SetFillColor(255, 255, 255);
1357 
1358  // Show sender name
1359  $pdf->SetXY($posx + 2, $posy + 3);
1360  $pdf->SetFont('', 'B', $default_font_size);
1361  $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0, 'L');
1362  $posy = $pdf->getY();
1363 
1364  // Show sender information
1365  $pdf->SetXY($posx + 2, $posy);
1366  $pdf->SetFont('', '', $default_font_size - 1);
1367  $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1368 
1369 
1370  // If SHIPPING contact defined, we use it
1371  $usecontact = false;
1372  $arrayidcontact = $object->getIdContact('external', 'STDEST');
1373  if (count($arrayidcontact) > 0) {
1374  $usecontact = true;
1375  $result = $object->fetch_contact($arrayidcontact[0]);
1376  }
1377 
1378  //Recipient name
1379  // On peut utiliser le nom de la societe du contact
1380  if ($usecontact/* && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)*/) {
1381  $thirdparty = $object->contact;
1382  } else {
1383  $thirdparty = $object->thirdparty;
1384  }
1385 
1386  if (!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1387 
1388  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1389 
1390  // Show recipient
1391  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1392  if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1393  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1394  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1395  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1396 
1397  // Show recipient frame
1398  $pdf->SetTextColor(0, 0, 0);
1399  $pdf->SetFont('', '', $default_font_size - 2);
1400  $pdf->SetXY($posx + 2, $posy - 5);
1401  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1402  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1403 
1404  // Show recipient name
1405  $pdf->SetXY($posx + 2, $posy + 3);
1406  $pdf->SetFont('', 'B', $default_font_size);
1407  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1408 
1409  $posy = $pdf->getY();
1410 
1411  // Show recipient information
1412  $pdf->SetFont('', '', $default_font_size - 1);
1413  $pdf->SetXY($posx + 2, $posy);
1414  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1415  }
1416 
1417  $pdf->SetTextColor(0, 0, 0);
1418  return $top_shift;
1419  }
1420 
1421  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1422  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1432  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1433  {
1434  // phpcs:enable
1435  global $conf;
1436  $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
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:822
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:7839
pdf_getlinevatrate
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1784
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:6097
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:2474
pdf_getlineupexcltax
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1846
pdf_getlineqty
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1931
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
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:2135
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:1106
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:1180
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:1521
pdf_getlineunit
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:2092
pdf_eagle_proforma\_pagehead
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="StockTransferSheetProforma")
Show top header of page.
Definition: pdf_eagle_proforma.modules.php:1161
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:1263
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
pdf_eagle_proforma\drawTotalTable
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
Definition: pdf_eagle_proforma.modules.php:1008
CommonDocGenerator\prepareArrayColumnField
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
Definition: commondocgenerator.class.php:1021
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:2514
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:7248
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:711
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:6549
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:812
pdf_watermark
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:757
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:977
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:1309
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:6694
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:427
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:1432
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:2711
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3747
pdf_eagle_proforma\drawInfoTable
drawInfoTable(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
Definition: pdf_eagle_proforma.modules.php:835
pdf_eagle_proforma\__construct
__construct($db)
Constructor.
Definition: pdf_eagle_proforma.modules.php:130
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:6991
CommonDocGenerator\printColDescContent
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
Definition: commondocgenerator.class.php:1226
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:737
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:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
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:1109
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:6603
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:1598
CommonDocGenerator\getColumnStatus
getColumnStatus($colKey)
get column status from column key
Definition: commondocgenerator.class.php:1502
Account
Class to manage bank accounts.
Definition: account.class.php:38
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:7961
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:989
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25