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