dolibarr  9.0.0
pdf_standard.modules.php
1 <?php
2 /* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
3  * Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  * or see http://www.gnu.org/
19  */
20 
27 require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php';
28 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
34 
35 
40 {
44  public $db;
45 
49  public $name;
50 
54  public $description;
55 
59  public $type;
60 
65  public $phpmin = array(5, 4);
66 
71  public $version = 'dolibarr';
72 
76  public $page_largeur;
77 
81  public $page_hauteur;
82 
86  public $format;
87 
91  public $marge_gauche;
92 
96  public $marge_droite;
97 
101  public $marge_haute;
102 
106  public $marge_basse;
107 
112  public $emetteur;
113 
114 
120  function __construct($db)
121  {
122  global $conf, $langs, $mysoc;
123 
124  // Load translation files required by the page
125  $langs->loadLangs(array("main", "bills"));
126 
127  $this->db = $db;
128  $this->name = "standard";
129  $this->description = $langs->trans('DocumentModelStandardPDF');
130 
131  // Dimension page pour format A4
132  $this->type = 'pdf';
133  $formatarray=pdf_getFormat();
134  $this->page_largeur = $formatarray['width'];
135  $this->page_hauteur = $formatarray['height'];
136  $this->format = array($this->page_largeur,$this->page_hauteur);
137  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141 
142  $this->option_logo = 1; // Affiche logo
143  $this->option_multilang = 1; // Dispo en plusieurs langues
144 
145  $this->franchise=!$mysoc->tva_assuj;
146 
147  // Defini position des colonnes
148  $this->posxdate=$this->marge_gauche+1;
149  $this->posxreffacturefourn=30;
150  $this->posxreffacture=65;
151  $this->posxtype=100;
152  $this->posxtotalht=80;
153  $this->posxtva=90;
154  $this->posxtotalttc=180;
155 
156  //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
157  if ($this->page_largeur < 210) // To work with US executive format
158  {
159  $this->posxreffacturefourn-=20;
160  $this->posxreffacture-=20;
161  $this->posxtype-=20;
162  $this->posxtotalht-=20;
163  $this->posxtva-=20;
164  $this->posxtotalttc-=20;
165  }
166 
167  $this->tva=array();
168  $this->localtax1=array();
169  $this->localtax2=array();
170  $this->atleastoneratenotnull=0;
171  $this->atleastonediscount=0;
172 
173  // Recupere emetteur
174  $this->emetteur=$mysoc;
175  if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
176  }
177 
178 
179  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
191  function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
192  {
193  // phpcs:enable
194  global $user, $langs, $conf, $mysoc, $hookmanager;
195 
196  if (! is_object($outputlangs)) $outputlangs=$langs;
197  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
198  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
199 
200  // Load translation files required by the page
201  $outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products"));
202 
203  $object->factures = array();
204 
205  if ($conf->fournisseur->payment->dir_output)
206  {
207  $object->fetch_thirdparty();
211  $sql = 'SELECT f.rowid, f.ref, f.datef, f.ref_supplier, f.total_ht, f.total_tva, f.total_ttc, pf.amount, f.rowid as facid, f.paye';
212  $sql .= ', f.fk_statut, s.nom as name, s.rowid as socid';
213  $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
214  $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
215  $sql .= ' AND pf.fk_paiementfourn = '.$object->id;
216  $resql=$this->db->query($sql);
217  if ($resql)
218  {
219  if ($this->db->num_rows($resql) > 0)
220  {
221  while($objp = $this->db->fetch_object($resql)) {
222  $objp->type = $outputlangs->trans('SupplierInvoice');
223  $object->lines[] = $objp;
224  }
225  }
226  }
227 
228  $total = $object->montant;
229 
230  // Definition of $dir and $file
231  if ($object->specimen)
232  {
233  $dir = $conf->fournisseur->payment->dir_output;
234  $file = $dir . "/SPECIMEN.pdf";
235  }
236  else
237  {
238  $objectref = dol_sanitizeFileName($object->ref);
239  $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
240  $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref;
241  $file = $dir . "/" . $objectref . ".pdf";
242  if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
243  }
244 
245  if (! file_exists($dir))
246  {
247  if (dol_mkdir($dir) < 0)
248  {
249  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
250  return 0;
251  }
252  }
253 
254  if (file_exists($dir))
255  {
256  // Add pdfgeneration hook
257  if (! is_object($hookmanager))
258  {
259  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
260  $hookmanager=new HookManager($this->db);
261  }
262  $hookmanager->initHooks(array('pdfgeneration'));
263  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
264  global $action;
265  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
266 
267  $nblignes = count($object->lines);
268 
269  $pdf=pdf_getInstance($this->format);
270  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
271  $heightforinfotot = 50; // Height reserved to output the info and total part
272  $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
273  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
274  if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
275  $pdf->SetAutoPageBreak(1,0);
276 
277  if (class_exists('TCPDF'))
278  {
279  $pdf->setPrintHeader(false);
280  $pdf->setPrintFooter(false);
281  }
282  $pdf->SetFont(pdf_getPDFFont($outputlangs));
283  // Set path to the background PDF File
284  if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
285  {
286  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
287  $tplidx = $pdf->importPage(1);
288  }
289 
290  $pdf->Open();
291  $pagenb=0;
292  $pdf->SetDrawColor(128,128,128);
293 
294  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
295  $pdf->SetSubject($outputlangs->transnoentities("Invoice"));
296  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
297  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
298  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
299  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
300 
301  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
302 
303 
304  // New page
305  $pdf->AddPage();
306  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
307  $pagenb++;
308  $this->_pagehead($pdf, $object, 1, $outputlangs);
309  $pdf->SetFont('','', $default_font_size - 1);
310  $pdf->MultiCell(0, 3, ''); // Set interline to 3
311  $pdf->SetTextColor(0,0,0);
312 
313  $tab_top = 90;
314  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
315  $tab_height = 130;
316  $tab_height_newpage = 150;
317 
318  // Incoterm
319  $height_incoterms = 0;
320 
321  $height_note=0;
322 
323  $iniY = $tab_top + 7;
324  $curY = $tab_top + 7;
325  $nexY = $tab_top + 7;
326 
327  // Loop on each lines
328  for ($i = 0 ; $i < $nblignes ; $i++)
329  {
330  $curY = $nexY;
331  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
332  $pdf->SetTextColor(0,0,0);
333 
334  $pdf->setTopMargin($tab_top_newpage);
335  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
336  $pageposbefore=$pdf->getPage();
337 
338  // Description of product line
339  $curX = $this->posxdate-1;
340  $showpricebeforepagebreak=1;
341 
342  $pdf->startTransaction();
343  //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
344  $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true);
345  $pageposafter=$pdf->getPage();
346  if ($pageposafter > $pageposbefore) // There is a pagebreak
347  {
348  $pdf->rollbackTransaction(true);
349  $pageposafter=$pageposbefore;
350  //print $pageposafter.'-'.$pageposbefore;exit;
351  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
352  //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
353  $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true);
354  $posyafter=$pdf->GetY();
355  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
356  {
357  if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
358  {
359  $pdf->AddPage('','',true);
360  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
361  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
362  $pdf->setPage($pageposafter+1);
363  }
364  }
365  else
366  {
367  // We found a page break
368  $showpricebeforepagebreak=0;
369  }
370  }
371  else // No pagebreak
372  {
373  $pdf->commitTransaction();
374  }
375 
376  $nexY = $pdf->GetY();
377  $pageposafter=$pdf->getPage();
378  $pdf->setPage($pageposbefore);
379  $pdf->setTopMargin($this->marge_haute);
380  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
381 
382  // We suppose that a too long description is moved completely on next page
383  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
384  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
385  }
386 
387  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
388 
389  // ref fourn
390  $pdf->SetXY($this->posxreffacturefourn, $curY);
391  $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0);
392 
393  // ref facture fourn
394  $pdf->SetXY($this->posxreffacture, $curY);
395  $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0);
396 
397  // type
398  $pdf->SetXY($this->posxtype, $curY);
399  $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0);
400 
401  // Total ht
402  $pdf->SetXY($this->posxtotalht, $curY);
403  $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0);
404 
405  // Total tva
406  $pdf->SetXY($this->posxtva, $curY);
407  $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0);
408 
409  // Total TTC line
410  $pdf->SetXY($this->posxtotalttc, $curY);
411  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0);
412 
413 
414  // Add line
415  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
416  {
417  $pdf->setPage($pageposafter);
418  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
419  //$pdf->SetDrawColor(190,190,200);
420  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
421  $pdf->SetLineStyle(array('dash'=>0));
422  }
423 
424  $nexY+=2; // Passe espace entre les lignes
425 
426  // Detect if some page were added automatically and output _tableau for past pages
427  while ($pagenb < $pageposafter)
428  {
429  $pdf->setPage($pagenb);
430  if ($pagenb == 1)
431  {
432  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
433  }
434  else
435  {
436  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
437  }
438  $this->_pagefoot($pdf,$object,$outputlangs,1);
439  $pagenb++;
440  $pdf->setPage($pagenb);
441  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
442  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
443  }
444  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
445  {
446  if ($pagenb == 1)
447  {
448  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
449  }
450  else
451  {
452  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
453  }
454  $this->_pagefoot($pdf,$object,$outputlangs,1);
455  // New page
456  $pdf->AddPage();
457  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
458  $pagenb++;
459  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
460  }
461  }
462 
463  // Show square
464  if ($pagenb == 1)
465  {
466  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
467  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
468  }
469  else
470  {
471  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
472  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
473  }
474 
475  // Affiche zone cheèque
476  $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs);
477 
478  // Affiche zone totaux
479  //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
480 
481  // Pied de page
482  $this->_pagefoot($pdf, $object, $outputlangs);
483  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
484 
485  $pdf->Close();
486 
487  $pdf->Output($file,'F');
488 
489  // Add pdfgeneration hook
490  $hookmanager->initHooks(array('pdfgeneration'));
491  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
492  global $action;
493  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
494 
495  if (! empty($conf->global->MAIN_UMASK))
496  @chmod($file, octdec($conf->global->MAIN_UMASK));
497 
498  $this->result = array('fullpath'=>$file);
499 
500  return 1; // Pas d'erreur
501  }
502  else
503  {
504  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
505  return 0;
506  }
507  }
508  else
509  {
510  $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
511  return 0;
512  }
513  }
514 
515  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
525  function _tableau_cheque(&$pdf, $object, $posy, $outputlangs)
526  {
527  // phpcs:enable
528  global $conf,$mysoc;
529 
530  $default_font_size = pdf_getPDFFontSize($outputlangs);
531 
532  $pdf->SetFont('','', $default_font_size - 1);
533  $pdf->SetFillColor(255,255,255);
534 
535  // N° payment
536  $pdf->SetXY($this->marge_gauche, $posy);
537  $pdf->MultiCell(30, 4, 'N° '.$outputlangs->transnoentities("Payment"), 0, 'L', 1);
538 
539  // Ref payment
540  $pdf->SetXY($this->marge_gauche + 30, $posy);
541  $pdf->MultiCell(50, 4, $object->ref, 0, 'L', 1);
542 
543  // Total payments
544  $pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy);
545  $pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1);
546  $posy += 20;
547 
548  // translate amount
549  $currency = $conf->currency;
550  $translateinletter = strtoupper(dol_convertToWord($object->montant,$outputlangs,$currency));
551  $pdf->SetXY($this->marge_gauche + 50, $posy);
552  $pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1);
553  $posy += 8;
554 
555  // To
556  $pdf->SetXY($this->marge_gauche + 50, $posy);
557  $pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1);
558 
559  $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
560  $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency,18,'*',STR_PAD_LEFT), 0, 'R', 1);
561  $posy += 10;
562 
563 
564  // City
565  $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
566  $pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', 1);
567  $posy += 4;
568 
569  // Date
570  $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
571  $pdf->MultiCell(150, 4, date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"), 0, 'L', 1);
572  }
573 
574 
588  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
589  {
590  global $conf,$mysoc;
591 
592  // Force to disable hidetop and hidebottom
593  $hidebottom=0;
594  if ($hidetop) $hidetop=-1;
595 
596  $currency = !empty($currency) ? $currency : $conf->currency;
597  $default_font_size = pdf_getPDFFontSize($outputlangs);
598 
599  // Amount in (at tab_top - 1)
600  $pdf->SetTextColor(0,0,0);
601  $pdf->SetFont('','',$default_font_size - 2);
602 
603  $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y");
604  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6);
605  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
606 
607  $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
608  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top);
609  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
610 
611 
612  $pdf->SetDrawColor(128,128,128);
613  $pdf->SetFont('','', $default_font_size - 1);
614 
615  // Output Rect
616  //$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
617  }
618 
619 
629  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
630  {
631  global $langs, $conf, $mysoc;
632 
633  // Load translation files required by the page
634  $outputlangs->loadLangs(array("main", "orders", "companies", "bills"));
635 
636  $default_font_size = pdf_getPDFFontSize($outputlangs);
637 
638  // Do not add the BACKGROUND as this is for suppliers
639  //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
640 
641  $pdf->SetTextColor(0,0,60);
642  $pdf->SetFont('','B', $default_font_size + 3);
643 
644  $posy=$this->marge_haute;
645  $posx=$this->page_largeur-$this->marge_droite-100;
646 
647  $pdf->SetXY($this->marge_gauche,$posy);
648 
649  // Logo
650  $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
651  if ($mysoc->logo)
652  {
653  if (is_readable($logo))
654  {
655  $height=pdf_getHeightForLogo($logo);
656  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
657  }
658  else
659  {
660  $pdf->SetTextColor(200,0,0);
661  $pdf->SetFont('','B', $default_font_size - 2);
662  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
663  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
664  }
665  }
666  else
667  {
668  $text=$this->emetteur->name;
669  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
670  }
671 /*
672  $pdf->SetFont('','B', $default_font_size + 3);
673  $pdf->SetXY($posx,$posy);
674  $pdf->SetTextColor(0,0,60);
675  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
676  $posy+=1;
677 
678  if ($object->ref_supplier)
679  {
680  $posy+=4;
681  $pdf->SetFont('','B', $default_font_size);
682  $pdf->SetXY($posx,$posy);
683  $pdf->SetTextColor(0,0,60);
684  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
685  $posy+=1;
686  }
687 
688  $pdf->SetFont('','', $default_font_size - 1);
689 
690  if (! empty($conf->global->PDF_SHOW_PROJECT))
691  {
692  $object->fetch_projet();
693  if (! empty($object->project->ref))
694  {
695  $posy+=4;
696  $pdf->SetXY($posx,$posy);
697  $langs->load("projects");
698  $pdf->SetTextColor(0,0,60);
699  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
700  }
701  }
702 
703  if ($object->date)
704  {
705  $posy+=4;
706  $pdf->SetXY($posx,$posy);
707  $pdf->SetTextColor(0,0,60);
708  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
709  }
710  else
711  {
712  $posy+=4;
713  $pdf->SetXY($posx,$posy);
714  $pdf->SetTextColor(255,0,0);
715  $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
716  }
717 
718  if ($object->thirdparty->code_fournisseur)
719  {
720  $posy+=4;
721  $pdf->SetXY($posx,$posy);
722  $pdf->SetTextColor(0,0,60);
723  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
724  }
725 
726  $posy+=1;
727  $pdf->SetTextColor(0,0,60);
728 
729  // Show list of linked objects
730  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
731 */
732  if ($showaddress)
733  {
734  // Sender properties
735  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
736 
737  // Show payer
738  $posy=42;
739  $posx=$this->marge_gauche;
740  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
741  $hautcadre=40;
742 
743  // Show sender frame
744  $pdf->SetTextColor(0,0,0);
745  $pdf->SetFont('','', $default_font_size - 2);
746  $pdf->SetXY($posx,$posy-5);
747  $pdf->MultiCell(66,5, $outputlangs->transnoentities("PayedBy").":", 0, 'L');
748  $pdf->SetXY($posx,$posy);
749  $pdf->SetFillColor(230,230,230);
750  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
751  $pdf->SetTextColor(0,0,60);
752 
753  // Show sender name
754  $pdf->SetXY($posx+2,$posy+3);
755  $pdf->SetFont('','B', $default_font_size);
756  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
757  $posy=$pdf->getY();
758 
759  // Show sender information
760  $pdf->SetXY($posx+2,$posy);
761  $pdf->SetFont('','', $default_font_size - 1);
762  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
763 
764  // Payed
765  $thirdparty = $object->thirdparty;
766 
767  $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
768 
769  $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
770 
771  // Show recipient
772  $widthrecbox=90;
773  if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
774  $posy=42;
775  $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
776  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
777 
778  // Show recipient frame
779  $pdf->SetTextColor(0,0,0);
780  $pdf->SetFont('','', $default_font_size - 2);
781  $pdf->SetXY($posx+2,$posy-5);
782  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":",0,'L');
783  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
784 
785  // Show recipient name
786  $pdf->SetXY($posx+2,$posy+3);
787  $pdf->SetFont('','B', $default_font_size);
788  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
789 
790  $posy = $pdf->getY();
791 
792  // Show recipient information
793  $pdf->SetFont('','', $default_font_size - 1);
794  $pdf->SetXY($posx+2,$posy);
795  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
796  }
797  }
798 
808  function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
809  {
810  global $conf;
811  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
812  return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
813  }
814 }
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:82
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:319
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_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:353
</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
write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
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
Class to generate expense report based on standard model.
Class to manage hooks.
type
Definition: viewcat.php:284
Parent class for supplier invoices models.
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.
_tableau_cheque(&$pdf, $object, $posy, $outputlangs)
Show total to pay.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:245
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...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
__construct($db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.