dolibarr  9.0.0
pdf_standard.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@stocks.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
25 require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.php';
26 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
32 
33 
37 class pdf_standard extends ModelePDFStock
38 {
42  public $db;
43 
47  public $name;
48 
52  public $description;
53 
57  public $type;
58 
63  public $phpmin = array(5, 4);
64 
69  public $version = 'dolibarr';
70 
74  public $page_largeur;
75 
79  public $page_hauteur;
80 
84  public $format;
85 
89  public $marge_gauche;
90 
94  public $marge_droite;
95 
99  public $marge_haute;
100 
104  public $marge_basse;
105 
110  public $emetteur;
111 
112 
118  public function __construct($db)
119  {
120  global $conf,$langs,$mysoc;
121 
122  // Load traductions files requiredby by page
123  $langs->loadLangs(array("main", "companies"));
124 
125  $this->db = $db;
126  $this->name = "standard";
127  $this->description = $langs->trans("DocumentModelStandardPDF");
128 
129  // Dimension page pour format A4
130  $this->type = 'pdf';
131  $formatarray=pdf_getFormat();
132  $this->page_largeur = $formatarray['width'];
133  $this->page_hauteur = $formatarray['height'];
134  $this->format = array($this->page_largeur,$this->page_hauteur);
135  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
136  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
137  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
138  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
139 
140  $this->option_logo = 1; // Affiche logo
141  $this->option_codestockservice = 0; // Affiche code stock-service
142  $this->option_multilang = 1; // Dispo en plusieurs langues
143  $this->option_freetext = 0; // Support add of a personalised text
144 
145  // Recupere emetteur
146  $this->emetteur=$mysoc;
147  if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
148 
149  // Define position of columns
150  $this->wref = 15;
151  $this->posxdesc=$this->marge_gauche+1;
152  $this->posxlabel=$this->posxdesc+$this->wref;
153  $this->posxtva=80;
154  $this->posxqty=95;
155  $this->posxup=115;
156  $this->posxunit=135;
157  $this->posxdiscount=155;
158  $this->postotalht=175;
159 
160  if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
161  $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
162  if ($this->page_largeur < 210) // To work with US executive format
163  {
164  $this->posxpicture-=20;
165  $this->posxtva-=20;
166  $this->posxup-=20;
167  $this->posxqty-=20;
168  $this->posxunit-=20;
169  $this->posxdiscount-=20;
170  $this->postotalht-=20;
171  }
172  $this->tva=array();
173  $this->localtax1=array();
174  $this->localtax2=array();
175  $this->atleastoneratenotnull=0;
176  $this->atleastonediscount=0;
177  }
178 
179 
180  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
192  function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
193  {
194  // phpcs:enable
195  global $user,$langs,$conf,$mysoc,$db,$hookmanager;
196 
197  if (! is_object($outputlangs)) $outputlangs=$langs;
198  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
199  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
200 
201  // Load traductions files requiredby by page
202  $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
203 
204  $nblignes = count($object->lines);
205 
206  if ($conf->stock->dir_output)
207  {
208  // Definition of $dir and $file
209  if ($object->specimen)
210  {
211  $dir = $conf->stock->dir_output;
212  $file = $dir . "/SPECIMEN.pdf";
213  }
214  else
215  {
216  $objectref = dol_sanitizeFileName($object->ref);
217  $dir = $conf->stock->dir_output . "/" . $objectref;
218  $file = $dir . "/" . $objectref . ".pdf";
219  }
220 
221  $stockFournisseur = new ProductFournisseur($this->db);
222  $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
223  $object->supplierprices = $supplierprices;
224 
225  $productstatic=new Product($db);
226 
227  if (! file_exists($dir))
228  {
229  if (dol_mkdir($dir) < 0)
230  {
231  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
232  return -1;
233  }
234  }
235 
236  if (file_exists($dir))
237  {
238  // Add pdfgeneration hook
239  if (! is_object($hookmanager))
240  {
241  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
242  $hookmanager=new HookManager($this->db);
243  }
244  $hookmanager->initHooks(array('pdfgeneration'));
245  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
246  global $action;
247  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
248 
249  // Create pdf instance
250  $pdf=pdf_getInstance($this->format);
251  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
252  $pdf->SetAutoPageBreak(1,0);
253 
254  $heightforinfotot = 40; // Height reserved to output the info and total part
255  $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
256  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
257 
258  if (class_exists('TCPDF'))
259  {
260  $pdf->setPrintHeader(false);
261  $pdf->setPrintFooter(false);
262  }
263  $pdf->SetFont(pdf_getPDFFont($outputlangs));
264  // Set path to the background PDF File
265  if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
266  {
267  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
268  $tplidx = $pdf->importPage(1);
269  }
270 
271  $pdf->Open();
272  $pagenb=0;
273  $pdf->SetDrawColor(128,128,128);
274 
275  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
276  $pdf->SetSubject($outputlangs->transnoentities("Stock"));
277  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
278  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
279  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle));
280  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
281 
282  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
283 
284 
285  // New page
286  $pdf->AddPage();
287  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288  $pagenb++;
289  $this->_pagehead($pdf, $object, 1, $outputlangs);
290  $pdf->SetFont('','', $default_font_size - 1);
291  $pdf->MultiCell(0, 3, ''); // Set interline to 3
292  $pdf->SetTextColor(0,0,0);
293 
294  $tab_top = 42;
295  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
296  $tab_height = 130;
297  $tab_height_newpage = 150;
298 
299  /* ************************************************************************** */
300  /* */
301  /* Affichage de la liste des produits de l'entrepot */
302  /* */
303  /* ************************************************************************** */
304 
305  $nexY+=5;
306  $nexY = $pdf->GetY();
307  $nexY+=10;
308 
309  $totalunit=0;
310  $totalvalue=$totalvaluesell=0;
311 
312  $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,";
313  $sql.= " ps.reel as value";
314  $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
315  $sql.= " WHERE ps.fk_product = p.rowid";
316  $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse)
317  $sql.= " AND ps.fk_entrepot = ".$object->id;
318  $sql.= $db->order($sortfield,$sortorder);
319 
320  //dol_syslog('List products', LOG_DEBUG);
321  $resql = $db->query($sql);
322  if ($resql)
323  {
324  $num = $db->num_rows($resql);
325  $i = 0;
326  $nblignes = $num;
327  for ($i = 0 ; $i < $nblignes ; $i++)
328  {
329  $objp = $db->fetch_object($resql);
330 
331  // Multilangs
332  if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
333  {
334  $sql = "SELECT label";
335  $sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
336  $sql.= " WHERE fk_product=".$objp->rowid;
337  $sql.= " AND lang='". $langs->getDefaultLang() ."'";
338  $sql.= " LIMIT 1";
339 
340  $result = $db->query($sql);
341  if ($result)
342  {
343  $objtp = $db->fetch_object($result);
344  if ($objtp->label != '') $objp->produit = $objtp->label;
345  }
346  }
347 
348  $curY = $nexY;
349  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
350  $pdf->SetTextColor(0,0,0);
351 
352  $pdf->setTopMargin($tab_top_newpage);
353  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
354  $pageposbefore=$pdf->getPage();
355 
356  // Description of product line
357  $curX = $this->posxdesc-1;
358 
359  $showpricebeforepagebreak=1;
360 
361  $pdf->startTransaction();
362  pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
363  $pageposafter=$pdf->getPage();
364  if ($pageposafter > $pageposbefore) // There is a pagebreak
365  {
366  $pdf->rollbackTransaction(true);
367  $pageposafter=$pageposbefore;
368  //print $pageposafter.'-'.$pageposbefore;exit;
369  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
370  pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
371  $pageposafter=$pdf->getPage();
372  $posyafter=$pdf->GetY();
373  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
374  {
375  if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
376  {
377  $pdf->AddPage('','',true);
378  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
379  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
380  $pdf->setPage($pageposafter+1);
381  }
382  }
383  else
384  {
385  // We found a page break
386  $showpricebeforepagebreak=0;
387  }
388  }
389  else // No pagebreak
390  {
391  $pdf->commitTransaction();
392  }
393  $posYAfterDescription=$pdf->GetY();
394 
395  $nexY = $pdf->GetY();
396  $pageposafter=$pdf->getPage();
397 
398  $pdf->setPage($pageposbefore);
399  $pdf->setTopMargin($this->marge_haute);
400  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
401 
402  // We suppose that a too long description is moved completely on next page
403  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
404  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
405  }
406 
407  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
408 
409  $productstatic->id=$objp->rowid;
410  $productstatic->ref = $objp->ref;
411  $productstatic->label = $objp->produit;
412  $productstatic->type=$objp->type;
413  $productstatic->entity=$objp->entity;
414  $productstatic->status_batch=$objp->tobatch;
415 
416  // Ref.
417  $pdf->SetXY($this->posxdesc, $curY);
418  $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L');
419 
420  // Label
421  $pdf->SetXY($this->posxlabel+0.8, $curY);
422  $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 3, $objp->produit, 0, 'L');
423 
424  // Quantity
425  $valtoshow=price2num($objp->value, 'MS');
426  $towrite = (empty($valtoshow)?'0':$valtoshow);
427 
428  $pdf->SetXY($this->posxqty, $curY);
429  $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R');
430 
431  $totalunit+=$objp->value;
432 
433  $pdf->SetXY($this->posxup, $curY);
434  $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, price(price2num($objp->ppmp,'MU'), 0, $outputlangs), 0, 'R');
435 
436  // Total PMP
437  $pdf->SetXY($this->posxunit, $curY);
438  $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($objp->ppmp*$objp->value,'MT'), 0, $outputlangs), 0, 'R');
439  $totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
440 
441  // Price sell min
442  if (empty($conf->global->PRODUIT_MULTIPRICES))
443  {
444  $pricemin=$objp->price;
445  $pdf->SetXY($this->posxdiscount, $curY);
446  $pdf->MultiCell($this->postotalht-$this->posxdiscount, 3, price(price2num($pricemin,'MU'), 0, $outputlangs), 0, 'R', 0);
447 
448  // Total sell min
449  $pdf->SetXY($this->postotalht, $curY);
450  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($pricemin*$objp->value,'MT'), 0, $outputlangs), 0, 'R', 0);
451  }
452  $totalvaluesell+=price2num($pricemin*$objp->value,'MT');
453 
454  // Add line
455  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
456  {
457  $pdf->setPage($pageposafter);
458  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
459  //$pdf->SetDrawColor(190,190,200);
460  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
461  $pdf->SetLineStyle(array('dash'=>0));
462  }
463 
464  $nexY+=2; // Passe espace entre les lignes
465 
466  // Detect if some page were added automatically and output _tableau for past pages
467  while ($pagenb < $pageposafter)
468  {
469  $pdf->setPage($pagenb);
470  if ($pagenb == 1)
471  {
472  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
473  }
474  else
475  {
476  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
477  }
478  $this->_pagefoot($pdf,$object,$outputlangs,1);
479  $pagenb++;
480  $pdf->setPage($pagenb);
481  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
482  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
483  }
484  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
485  {
486  if ($pagenb == 1)
487  {
488  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
489  }
490  else
491  {
492  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
493  }
494  $this->_pagefoot($pdf,$object,$outputlangs,1);
495  // New page
496  $pdf->AddPage();
497  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
498  $pagenb++;
499  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
500  }
501  }
502 
503  $db->free($resql);
504 
508  $nexY = $pdf->GetY();
509  $nexY+=2;
510  $curY = $nexY;
511 
512  $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
513  $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1);
514  $pdf->SetLineStyle(array('dash'=>0));
515 
516  $pdf->SetFont('','B',$default_font_size-1);
517  $pdf->SetTextColor(0,0,120);
518 
519  // Ref.
520  $pdf->SetXY($this->posxdesc, $curY);
521  $pdf->MultiCell($this->wref, 3, $langs->trans("Total"), 0, 'L');
522 
523  // Quantity
524  $valtoshow=price2num($totalunit, 'MS');
525  $towrite = empty($valtoshow)?'0':$valtoshow;
526 
527  $pdf->SetXY($this->posxqty, $curY);
528  $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R');
529 
530  // Total PMP
531  $pdf->SetXY($this->posxunit, $curY);
532  $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($totalvalue,'MT'), 0, $outputlangs), 0, 'R');
533 
534  // Price sell min
535  if (empty($conf->global->PRODUIT_MULTIPRICES))
536  {
537  // Total sell min
538  $pdf->SetXY($this->postotalht, $curY);
539  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($totalvaluesell,'MT'), 0, $outputlangs), 0, 'R', 0);
540  }
541  }
542  else
543  {
544  dol_print_error($db);
545  }
546 
547  if ($notetoshow)
548  {
549  $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
550  complete_substitutions_array($substitutionarray, $outputlangs, $object);
551  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
552 
553  $tab_top = 88;
554 
555  $pdf->SetFont('','', $default_font_size - 1);
556  $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
557  $nexY = $pdf->GetY();
558  $height_note=$nexY-$tab_top;
559 
560  // Rect prend une longueur en 3eme param
561  $pdf->SetDrawColor(192,192,192);
562  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
563 
564  $tab_height = $tab_height - $height_note;
565  $tab_top = $nexY+6;
566  }
567  else
568  {
569  $height_note=0;
570  }
571 
572  $iniY = $tab_top + 7;
573  $curY = $tab_top + 7;
574  $nexY = $tab_top + 7;
575 
576  // Loop on each lines
577  /*
578  for ($i = 0 ; $i < $nblignes ; $i++)
579  {
580  $curY = $nexY;
581  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
582  $pdf->SetTextColor(0,0,0);
583 
584  $pdf->setTopMargin($tab_top_newpage);
585  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
586  $pageposbefore=$pdf->getPage();
587 
588  // Description of stock line
589  $curX = $this->posxdesc-1;
590 
591  $showpricebeforepagebreak=1;
592 
593  $pdf->startTransaction();
594  pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
595  $pageposafter=$pdf->getPage();
596  if ($pageposafter > $pageposbefore) // There is a pagebreak
597  {
598  $pdf->rollbackTransaction(true);
599  $pageposafter=$pageposbefore;
600  //print $pageposafter.'-'.$pageposbefore;exit;
601  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
602  pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
603  $pageposafter=$pdf->getPage();
604  $posyafter=$pdf->GetY();
605  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
606  {
607  if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
608  {
609  $pdf->AddPage('','',true);
610  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
611  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
612  $pdf->setPage($pageposafter+1);
613  }
614  }
615  else
616  {
617  // We found a page break
618  $showpricebeforepagebreak=0;
619  }
620  }
621  else // No pagebreak
622  {
623  $pdf->commitTransaction();
624  }
625 
626  $nexY = $pdf->GetY();
627  $pageposafter=$pdf->getPage();
628  $pdf->setPage($pageposbefore);
629  $pdf->setTopMargin($this->marge_haute);
630  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
631 
632  // We suppose that a too long description is moved completely on next page
633  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
634  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
635  }
636 
637  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
638 
639  // VAT Rate
640  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
641  {
642  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
643  $pdf->SetXY($this->posxtva, $curY);
644  $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
645  }
646 
647  // Unit price before discount
648  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
649  $pdf->SetXY($this->posxup, $curY);
650  $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
651 
652  // Quantity
653  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
654  $pdf->SetXY($this->posxqty, $curY);
655  // Enough for 6 chars
656  if($conf->global->PRODUCT_USE_UNITS)
657  {
658  $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
659  }
660  else
661  {
662  $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
663  }
664 
665  // Unit
666  if($conf->global->PRODUCT_USE_UNITS)
667  {
668  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
669  $pdf->SetXY($this->posxunit, $curY);
670  $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
671  }
672 
673  // Discount on line
674  $pdf->SetXY($this->posxdiscount, $curY);
675  if ($object->lines[$i]->remise_percent)
676  {
677  $pdf->SetXY($this->posxdiscount-2, $curY);
678  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
679  $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
680  }
681 
682  // Total HT line
683  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
684  $pdf->SetXY($this->postotalht, $curY);
685  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
686 
687  // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
688  if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
689  else $tvaligne=$object->lines[$i]->total_tva;
690 
691  $localtax1ligne=$object->lines[$i]->total_localtax1;
692  $localtax2ligne=$object->lines[$i]->total_localtax2;
693  $localtax1_rate=$object->lines[$i]->localtax1_tx;
694  $localtax2_rate=$object->lines[$i]->localtax2_tx;
695  $localtax1_type=$object->lines[$i]->localtax1_type;
696  $localtax2_type=$object->lines[$i]->localtax2_type;
697 
698  if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
699  if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
700  if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
701 
702  $vatrate=(string) $object->lines[$i]->tva_tx;
703 
704  // Retrieve type from database for backward compatibility with old records
705  if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
706  && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
707  {
708  $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
709  $localtax1_type = $localtaxtmp_array[0];
710  $localtax2_type = $localtaxtmp_array[2];
711  }
712 
713  // retrieve global local tax
714  if ($localtax1_type && $localtax1ligne != 0)
715  $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
716  if ($localtax2_type && $localtax2ligne != 0)
717  $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
718 
719  if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
720  if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
721  $this->tva[$vatrate] += $tvaligne;
722 
723  // Add line
724  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
725  {
726  $pdf->setPage($pageposafter);
727  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
728  //$pdf->SetDrawColor(190,190,200);
729  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
730  $pdf->SetLineStyle(array('dash'=>0));
731  }
732 
733  $nexY+=2; // Passe espace entre les lignes
734 
735  // Detect if some page were added automatically and output _tableau for past pages
736  while ($pagenb < $pageposafter)
737  {
738  $pdf->setPage($pagenb);
739  if ($pagenb == 1)
740  {
741  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
742  }
743  else
744  {
745  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
746  }
747  $this->_pagefoot($pdf,$object,$outputlangs,1);
748  $pagenb++;
749  $pdf->setPage($pagenb);
750  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
751  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
752  }
753  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
754  {
755  if ($pagenb == 1)
756  {
757  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
758  }
759  else
760  {
761  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
762  }
763  $this->_pagefoot($pdf,$object,$outputlangs,1);
764  // New page
765  $pdf->AddPage();
766  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
767  $pagenb++;
768  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
769  }
770  }
771  */
772  $tab_top = $tab_top_newpage+21;
773 
774  // Show square
775  if ($pagenb == 1)
776  {
777  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
778  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
779  }
780  else
781  {
782  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
783  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
784  }
785 
786  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
787 
788  // Affiche zone infos
789  //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
790 
791  // Affiche zone totaux
792  //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
793 
794  // Pied de page
795  $this->_pagefoot($pdf,$object,$outputlangs);
796  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
797 
798  $pdf->Close();
799 
800  $pdf->Output($file,'F');
801 
802  // Add pdfgeneration hook
803  $hookmanager->initHooks(array('pdfgeneration'));
804  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
805  global $action;
806  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
807 
808  if (! empty($conf->global->MAIN_UMASK))
809  @chmod($file, octdec($conf->global->MAIN_UMASK));
810 
811  $this->result = array('fullpath'=>$file);
812 
813  return 1; // Pas d'erreur
814  }
815  else
816  {
817  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
818  return 0;
819  }
820  }
821  else
822  {
823  $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR");
824  return 0;
825  }
826  }
827 
828 
842  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
843  {
844  global $conf;
845 
846  // Force to disable hidetop and hidebottom
847  $hidebottom=0;
848  if ($hidetop) $hidetop=-1;
849 
850  $currency = !empty($currency) ? $currency : $conf->currency;
851  $default_font_size = pdf_getPDFFontSize($outputlangs);
852 
853  // Amount in (at tab_top - 1)
854  $pdf->SetTextColor(0,0,0);
855  $pdf->SetFont('','', $default_font_size - 2);
856 
857  if (empty($hidetop))
858  {
859  $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
860  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
861  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
862 
863  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
864  if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
865  }
866 
867  $pdf->SetDrawColor(128,128,128);
868  $pdf->SetFont('','B', $default_font_size - 3);
869 
870  // Output Rect
871  //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
872 
873  $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
874  $pdf->SetDrawColor(220,26,26);
875  $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top);
876  $pdf->SetLineStyle(array('dash'=>0));
877  $pdf->SetDrawColor(128,128,128);
878  $pdf->SetTextColor(0,0,120);
879 
880  if (empty($hidetop))
881  {
882  //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
883  $pdf->SetXY($this->posxdesc-1, $tab_top+1);
884  $pdf->MultiCell($this->wref,3, $outputlangs->transnoentities("Ref"),'','L');
885  }
886 
887  //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
888  if (empty($hidetop))
889  {
890  $pdf->SetXY($this->posxlabel-3, $tab_top+1);
891  $pdf->MultiCell($this->posxqty-$this->posxlabel+3,2, $outputlangs->transnoentities("Label"),'','C');
892  }
893 
894  //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
895  if (empty($hidetop))
896  {
897  $pdf->SetXY($this->posxqty-1, $tab_top+1);
898  $pdf->MultiCell($this->posxup-$this->posxqty-1,2, $outputlangs->transnoentities("Units"),'','C');
899  }
900 
901  //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
902  if (empty($hidetop))
903  {
904  $pdf->SetXY($this->posxup-1, $tab_top+1);
905  $pdf->MultiCell($this->posxunit-$this->posxup-1,2, $outputlangs->transnoentities("AverageUnitPricePMPShort"),'','C');
906  }
907 
908  //$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
909  if (empty($hidetop))
910  {
911  $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
912  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '',
913  'C');
914  }
915 
916  //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
917  if (empty($hidetop))
918  {
919  $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
920  $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("SellPriceMin"),'','C');
921  }
922 
923  //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
924  if (empty($hidetop))
925  {
926  $pdf->SetXY($this->postotalht-1, $tab_top+1);
927  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("EstimatedStockValueSellShort"),'','C');
928  }
929 
930  $pdf->SetDrawColor(220,26,26);
931  $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
932  $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
933  $pdf->SetLineStyle(array('dash'=>0));
934  }
935 
946  function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
947  {
948  global $conf,$langs,$db,$hookmanager;
949 
950  // Load traductions files requiredby by page
951  $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
952 
953  $default_font_size = pdf_getPDFFontSize($outputlangs);
954 
955  if ($object->type == 1) $titlekey='ServiceSheet';
956  else $titlekey='StockSheet';
957 
958  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
959 
960  // Show Draft Watermark
961  if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
962  {
963  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
964  }
965 
966  $pdf->SetTextColor(0,0,60);
967  $pdf->SetFont('','B', $default_font_size + 3);
968 
969  $posy=$this->marge_haute;
970  $posx=$this->page_largeur-$this->marge_droite-100;
971 
972  $pdf->SetXY($this->marge_gauche,$posy);
973 
974  // Logo
975  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
976  if ($this->emetteur->logo)
977  {
978  if (is_readable($logo))
979  {
980  $height=pdf_getHeightForLogo($logo);
981  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
982  }
983  else
984  {
985  $pdf->SetTextColor(200,0,0);
986  $pdf->SetFont('','B', $default_font_size -2);
987  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
988  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
989  }
990  }
991  else
992  {
993  $text=$this->emetteur->name;
994  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
995  }
996 
997  $pdf->SetFont('','B', $default_font_size + 3);
998  $pdf->SetXY($posx,$posy);
999  $pdf->SetTextColor(0,0,60);
1000  $title=$outputlangs->transnoentities("Warehouse");
1001  $pdf->MultiCell(100, 3, $title, '', 'R');
1002 
1003  $pdf->SetFont('','B',$default_font_size);
1004 
1005  $posy+=5;
1006  $pdf->SetXY($posx,$posy);
1007  $pdf->SetTextColor(0,0,60);
1008 
1009  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R');
1010 
1011  $posy+=5;
1012  $pdf->SetFont('','', $default_font_size - 1);
1013  $pdf->SetXY($posx,$posy);
1014  $pdf->SetTextColor(0,0,60);
1015  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1016 
1017  $posy+=4;
1018  $pdf->SetXY($posx-50,$posy);
1019  $pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1020 
1021 
1022  // Parent entrepot
1023  $posy+=4;
1024  $pdf->SetXY($posx,$posy);
1025  $pdf->SetTextColor(0,0,60);
1026  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1027 
1028  $posy+=4;
1029  $pdf->SetXY($posx-50,$posy);
1030  $e = new Entrepot($db);
1031  if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1032  {
1033  $pdf->MultiCell(150, 3, $e->libelle, '', 'R');
1034  }
1035  else
1036  {
1037  $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R');
1038  }
1039 
1040  // Description
1041  $nexY = $pdf->GetY();
1042  $nexY+=5;
1043  $pdf->SetXY($posx,$posy);
1044  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1045  $nexY = $pdf->GetY();
1046 
1047  $calcproductsunique=$object->nb_different_products();
1048  $calcproducts=$object->nb_products();
1049 
1050  // Total nb of different products
1051  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1);
1052  $nexY = $pdf->GetY();
1053 
1054  // Nb of products
1055  $valtoshow=price2num($calcproducts['nb'], 'MS');
1056  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow)?'0':$valtoshow), 0, 1);
1057  $nexY = $pdf->GetY();
1058 
1059  // Value
1060  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1061  $nexY = $pdf->GetY();
1062 
1063 
1064  // Last movement
1065  $sql = "SELECT max(m.datem) as datem";
1066  $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
1067  $sql .= " WHERE m.fk_entrepot = '".$object->id."'";
1068  $resqlbis = $db->query($sql);
1069  if ($resqlbis)
1070  {
1071  $obj = $db->fetch_object($resqlbis);
1072  $lastmovementdate=$db->jdate($obj->datem);
1073  }
1074  else
1075  {
1076  dol_print_error($db);
1077  }
1078 
1079  if ($lastmovementdate)
1080  {
1081  $toWrite = dol_print_date($lastmovementdate,'dayhour').' ';
1082  }
1083  else
1084  {
1085  $toWrite = $outputlangs->transnoentities("None");
1086  }
1087 
1088  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
1089  $nexY = $pdf->GetY();
1090 
1091 
1092  /*if ($object->ref_client)
1093  {
1094  $posy+=5;
1095  $pdf->SetXY($posx,$posy);
1096  $pdf->SetTextColor(0,0,60);
1097  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1098  }*/
1099 
1100  /*$posy+=4;
1101  $pdf->SetXY($posx,$posy);
1102  $pdf->SetTextColor(0,0,60);
1103  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1104  */
1105 
1106  // Get contact
1107  /*
1108  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1109  {
1110  $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1111  if (count($arrayidcontact) > 0)
1112  {
1113  $usertmp=new User($this->db);
1114  $usertmp->fetch($arrayidcontact[0]);
1115  $posy+=4;
1116  $pdf->SetXY($posx,$posy);
1117  $pdf->SetTextColor(0,0,60);
1118  $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1119  }
1120  }*/
1121 
1122  $posy+=2;
1123 
1124  // Show list of linked objects
1125  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1126 
1127  if ($showaddress)
1128  {
1129  /*
1130  // Sender properties
1131  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1132 
1133  // Show sender
1134  $posy=42;
1135  $posx=$this->marge_gauche;
1136  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1137  $hautcadre=40;
1138 
1139  // Show sender frame
1140  $pdf->SetTextColor(0,0,0);
1141  $pdf->SetFont('','', $default_font_size - 2);
1142  $pdf->SetXY($posx,$posy-5);
1143  $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1144  $pdf->SetXY($posx,$posy);
1145  $pdf->SetFillColor(230,230,230);
1146  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1147  $pdf->SetTextColor(0,0,60);
1148 
1149  // Show sender name
1150  $pdf->SetXY($posx+2,$posy+3);
1151  $pdf->SetFont('','B', $default_font_size);
1152  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1153  $posy=$pdf->getY();
1154 
1155  // Show sender information
1156  $pdf->SetXY($posx+2,$posy);
1157  $pdf->SetFont('','', $default_font_size - 1);
1158  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1159  */
1160  }
1161 
1162  $pdf->SetTextColor(0,0,0);
1163  }
1164 
1174  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1175  {
1176  global $conf;
1177  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1178  return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1179  }
1180 }
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:82
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:600
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:643
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
pdf_getFormat(Translate $outputlangs=null)
Return array with format properties of default PDF format.
Definition: pdf.lib.php:42
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:224
Class to manage products or services.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:201
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
write_file($object, $outputlangs, $srctemplatepath, $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
Class to generate expense report based on standard model.
Class to manage hooks.
type
Definition: viewcat.php:284
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
Definition: pdf.lib.php:872
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
$version
Dolibarr version of the loaded document string.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:245
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1119
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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:623
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition: pdf.lib.php:1158
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
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...
__construct($db)
Constructor.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
Show top header of page.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Parent class for stock models of doc generators.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class to manage predefined suppliers products.
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...
Class to manage warehouses.