dolibarr  7.0.0-beta
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 {
41  var $db;
42  var $name;
43  var $description;
44  var $type;
45 
46  var $phpmin = array(4,3,0); // Minimum version of PHP required by module
47  var $version = 'dolibarr';
48 
49  var $page_largeur;
50  var $page_hauteur;
51  var $format;
52  var $marge_gauche;
53  var $marge_droite;
54  var $marge_haute;
55  var $marge_basse;
56 
57  var $emetteur; // Objet societe qui emet
58 
59 
65  function __construct($db)
66  {
67  global $conf,$langs,$mysoc;
68 
69  $langs->load("main");
70  $langs->load("bills");
71 
72  $this->db = $db;
73  $this->name = "standard";
74  $this->description = $langs->trans('DocumentModelStandardPDF');
75 
76  // Dimension page pour format A4
77  $this->type = 'pdf';
78  $formatarray=pdf_getFormat();
79  $this->page_largeur = $formatarray['width'];
80  $this->page_hauteur = $formatarray['height'];
81  $this->format = array($this->page_largeur,$this->page_hauteur);
82  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
83  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
84  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
85  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
86 
87  $this->option_logo = 1; // Affiche logo
88  $this->option_multilang = 1; // Dispo en plusieurs langues
89 
90  $this->franchise=!$mysoc->tva_assuj;
91 
92  // Defini position des colonnes
93  $this->posxdate=$this->marge_gauche+1;
94  $this->posxreffacturefourn=30;
95  $this->posxreffacture=65;
96  $this->posxtype=100;
97  $this->posxtotalht=80;
98  $this->posxtva=90;
99  $this->posxtotalttc=180;
100 
101  //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
102  if ($this->page_largeur < 210) // To work with US executive format
103  {
104  $this->posxreffacturefourn-=20;
105  $this->posxreffacture-=20;
106  $this->posxtype-=20;
107  $this->posxtotalht-=20;
108  $this->posxtva-=20;
109  $this->posxtotalttc-=20;
110  }
111 
112  $this->tva=array();
113  $this->localtax1=array();
114  $this->localtax2=array();
115  $this->atleastoneratenotnull=0;
116  $this->atleastonediscount=0;
117 
118  // Recupere emetteur
119  $this->emetteur=$mysoc;
120  if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
121  }
122 
123 
135  function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
136  {
137  global $user,$langs,$conf,$mysoc,$hookmanager;
138 
139  if (! is_object($outputlangs)) $outputlangs=$langs;
140  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
141  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
142 
143  $outputlangs->load("main");
144  $outputlangs->load("dict");
145  $outputlangs->load("companies");
146  $outputlangs->load("bills");
147  $outputlangs->load("products");
148  $outputlangs->load("suppliers");
149  $object->factures = array();
150 
151  if ($conf->fournisseur->payment->dir_output)
152  {
153  $object->fetch_thirdparty();
157  $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';
158  $sql .= ', f.fk_statut, s.nom as name, s.rowid as socid';
159  $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
160  $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
161  $sql .= ' AND pf.fk_paiementfourn = '.$object->id;
162  $resql=$this->db->query($sql);
163  if ($resql)
164  {
165  if ($this->db->num_rows($resql) > 0)
166  {
167  while($objp = $this->db->fetch_object($resql)) {
168  $objp->type = $outputlangs->trans('SupplierInvoice');
169  $object->lines[] = $objp;
170  }
171  }
172  }
173 
174  $total = $object->montant;
175 
176  // Definition of $dir and $file
177  if ($object->specimen)
178  {
179  $dir = $conf->fournisseur->payment->dir_output;
180  $file = $dir . "/SPECIMEN.pdf";
181  }
182  else
183  {
184  $objectref = dol_sanitizeFileName($object->ref);
185  $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
186  $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref;
187  $file = $dir . "/" . $objectref . ".pdf";
188  if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
189  }
190 
191  if (! file_exists($dir))
192  {
193  if (dol_mkdir($dir) < 0)
194  {
195  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
196  return 0;
197  }
198  }
199 
200  if (file_exists($dir))
201  {
202  // Add pdfgeneration hook
203  if (! is_object($hookmanager))
204  {
205  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
206  $hookmanager=new HookManager($this->db);
207  }
208  $hookmanager->initHooks(array('pdfgeneration'));
209  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
210  global $action;
211  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
212 
213  $nblignes = count($object->lines);
214 
215  $pdf=pdf_getInstance($this->format);
216  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
217  $heightforinfotot = 50; // Height reserved to output the info and total part
218  $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
219  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
220  $pdf->SetAutoPageBreak(1,0);
221 
222  if (class_exists('TCPDF'))
223  {
224  $pdf->setPrintHeader(false);
225  $pdf->setPrintFooter(false);
226  }
227  $pdf->SetFont(pdf_getPDFFont($outputlangs));
228  // Set path to the background PDF File
229  if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
230  {
231  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
232  $tplidx = $pdf->importPage(1);
233  }
234 
235  $pdf->Open();
236  $pagenb=0;
237  $pdf->SetDrawColor(128,128,128);
238 
239  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
240  $pdf->SetSubject($outputlangs->transnoentities("Invoice"));
241  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
242  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
243  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
244  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
245 
246  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
247 
248 
249  // New page
250  $pdf->AddPage();
251  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
252  $pagenb++;
253  $this->_pagehead($pdf, $object, 1, $outputlangs);
254  $pdf->SetFont('','', $default_font_size - 1);
255  $pdf->MultiCell(0, 3, ''); // Set interline to 3
256  $pdf->SetTextColor(0,0,0);
257 
258  $tab_top = 90;
259  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
260  $tab_height = 130;
261  $tab_height_newpage = 150;
262 
263  // Incoterm
264  $height_incoterms = 0;
265 
266  $height_note=0;
267 
268  $iniY = $tab_top + 7;
269  $curY = $tab_top + 7;
270  $nexY = $tab_top + 7;
271 
272  // Loop on each lines
273  for ($i = 0 ; $i < $nblignes ; $i++)
274  {
275  $curY = $nexY;
276  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
277  $pdf->SetTextColor(0,0,0);
278 
279  $pdf->setTopMargin($tab_top_newpage);
280  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
281  $pageposbefore=$pdf->getPage();
282 
283  // Description of product line
284  $curX = $this->posxdate-1;
285  $showpricebeforepagebreak=1;
286 
287  $pdf->startTransaction();
288  //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
289  $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true);
290  $pageposafter=$pdf->getPage();
291  if ($pageposafter > $pageposbefore) // There is a pagebreak
292  {
293  $pdf->rollbackTransaction(true);
294  $pageposafter=$pageposbefore;
295  //print $pageposafter.'-'.$pageposbefore;exit;
296  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
297  //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
298  $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true);
299  $posyafter=$pdf->GetY();
300  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
301  {
302  if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
303  {
304  $pdf->AddPage('','',true);
305  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
306  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
307  $pdf->setPage($pageposafter+1);
308  }
309  }
310  else
311  {
312  // We found a page break
313  $showpricebeforepagebreak=0;
314  }
315  }
316  else // No pagebreak
317  {
318  $pdf->commitTransaction();
319  }
320 
321  $nexY = $pdf->GetY();
322  $pageposafter=$pdf->getPage();
323  $pdf->setPage($pageposbefore);
324  $pdf->setTopMargin($this->marge_haute);
325  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
326 
327  // We suppose that a too long description is moved completely on next page
328  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
329  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
330  }
331 
332  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
333 
334  // ref fourn
335  $pdf->SetXY($this->posxreffacturefourn, $curY);
336  $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0);
337 
338  // ref facture fourn
339  $pdf->SetXY($this->posxreffacture, $curY);
340  $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0);
341 
342  // type
343  $pdf->SetXY($this->posxtype, $curY);
344  $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0);
345 
346  // Total ht
347  $pdf->SetXY($this->posxtotalht, $curY);
348  $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0);
349 
350  // Total tva
351  $pdf->SetXY($this->posxtva, $curY);
352  $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0);
353 
354  // Total TTC line
355  $pdf->SetXY($this->posxtotalttc, $curY);
356  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0);
357 
358 
359  // Add line
360  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361  {
362  $pdf->setPage($pageposafter);
363  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
364  //$pdf->SetDrawColor(190,190,200);
365  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
366  $pdf->SetLineStyle(array('dash'=>0));
367  }
368 
369  $nexY+=2; // Passe espace entre les lignes
370 
371  // Detect if some page were added automatically and output _tableau for past pages
372  while ($pagenb < $pageposafter)
373  {
374  $pdf->setPage($pagenb);
375  if ($pagenb == 1)
376  {
377  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378  }
379  else
380  {
381  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382  }
383  $this->_pagefoot($pdf,$object,$outputlangs,1);
384  $pagenb++;
385  $pdf->setPage($pagenb);
386  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
387  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388  }
389  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390  {
391  if ($pagenb == 1)
392  {
393  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394  }
395  else
396  {
397  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398  }
399  $this->_pagefoot($pdf,$object,$outputlangs,1);
400  // New page
401  $pdf->AddPage();
402  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
403  $pagenb++;
404  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405  }
406  }
407 
408  // Show square
409  if ($pagenb == 1)
410  {
411  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
412  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
413  }
414  else
415  {
416  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
417  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
418  }
419 
420  // Affiche zone cheèque
421  $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs);
422 
423  // Affiche zone totaux
424  //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
425 
426  // Pied de page
427  $this->_pagefoot($pdf, $object, $outputlangs);
428  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
429 
430  $pdf->Close();
431 
432  $pdf->Output($file,'F');
433 
434  // Add pdfgeneration hook
435  $hookmanager->initHooks(array('pdfgeneration'));
436  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
437  global $action;
438  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
439 
440  if (! empty($conf->global->MAIN_UMASK))
441  @chmod($file, octdec($conf->global->MAIN_UMASK));
442 
443  $this->result = array('fullpath'=>$file);
444 
445  return 1; // Pas d'erreur
446  }
447  else
448  {
449  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
450  return 0;
451  }
452  }
453  else
454  {
455  $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
456  return 0;
457  }
458  }
459 
469  function _tableau_cheque(&$pdf, $object, $posy, $outputlangs)
470  {
471  global $conf,$mysoc;
472 
473  $default_font_size = pdf_getPDFFontSize($outputlangs);
474 
475  $pdf->SetFont('','', $default_font_size - 1);
476  $pdf->SetFillColor(255,255,255);
477 
478  // N° payment
479  $pdf->SetXY($this->marge_gauche, $posy);
480  $pdf->MultiCell(30, 4, 'N° '.$outputlangs->transnoentities("Payment"), 0, 'L', 1);
481 
482  // Ref payment
483  $pdf->SetXY($this->marge_gauche + 30, $posy);
484  $pdf->MultiCell(50, 4, $object->ref, 0, 'L', 1);
485 
486  // Total payments
487  $pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy);
488  $pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1);
489  $posy += 20;
490 
491  // translate amount
492  $currency = $conf->currency;
493  $translateinletter = strtoupper(dol_convertToWord($object->montant,$outputlangs,$currency));
494  $pdf->SetXY($this->marge_gauche + 50, $posy);
495  $pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1);
496  $posy += 8;
497 
498  // To
499  $pdf->SetXY($this->marge_gauche + 50, $posy);
500  $pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1);
501 
502  $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
503  $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency,18,'*',STR_PAD_LEFT), 0, 'R', 1);
504  $posy += 10;
505 
506 
507  // City
508  $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
509  $pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', 1);
510  $posy += 4;
511 
512  // Date
513  $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
514  $pdf->MultiCell(150, 4, date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"), 0, 'L', 1);
515 
516  }
517 
518 
532  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
533  {
534  global $conf,$mysoc;
535 
536  // Force to disable hidetop and hidebottom
537  $hidebottom=0;
538  if ($hidetop) $hidetop=-1;
539 
540  $currency = !empty($currency) ? $currency : $conf->currency;
541  $default_font_size = pdf_getPDFFontSize($outputlangs);
542 
543  // Amount in (at tab_top - 1)
544  $pdf->SetTextColor(0,0,0);
545  $pdf->SetFont('','',$default_font_size - 2);
546 
547  $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y");
548  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6);
549  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
550 
551  $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
552  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top);
553  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
554 
555 
556  $pdf->SetDrawColor(128,128,128);
557  $pdf->SetFont('','', $default_font_size - 1);
558 
559  // Output Rect
560  //$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
561 
562  }
563 
564 
574  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
575  {
576  global $langs,$conf,$mysoc;
577 
578  $outputlangs->load("main");
579  $outputlangs->load("bills");
580  $outputlangs->load("orders");
581  $outputlangs->load("companies");
582  $default_font_size = pdf_getPDFFontSize($outputlangs);
583 
584  // Do not add the BACKGROUND as this is for suppliers
585  //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
586 
587  $pdf->SetTextColor(0,0,60);
588  $pdf->SetFont('','B', $default_font_size + 3);
589 
590  $posy=$this->marge_haute;
591  $posx=$this->page_largeur-$this->marge_droite-100;
592 
593  $pdf->SetXY($this->marge_gauche,$posy);
594 
595  // Logo
596  $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
597  if ($mysoc->logo)
598  {
599  if (is_readable($logo))
600  {
601  $height=pdf_getHeightForLogo($logo);
602  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
603  }
604  else
605  {
606  $pdf->SetTextColor(200,0,0);
607  $pdf->SetFont('','B', $default_font_size - 2);
608  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
609  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
610  }
611  }
612  else
613  {
614  $text=$this->emetteur->name;
615  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
616  }
617 /*
618  $pdf->SetFont('','B', $default_font_size + 3);
619  $pdf->SetXY($posx,$posy);
620  $pdf->SetTextColor(0,0,60);
621  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
622  $posy+=1;
623 
624  if ($object->ref_supplier)
625  {
626  $posy+=4;
627  $pdf->SetFont('','B', $default_font_size);
628  $pdf->SetXY($posx,$posy);
629  $pdf->SetTextColor(0,0,60);
630  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
631  $posy+=1;
632  }
633 
634  $pdf->SetFont('','', $default_font_size - 1);
635 
636  if (! empty($conf->global->PDF_SHOW_PROJECT))
637  {
638  $object->fetch_projet();
639  if (! empty($object->project->ref))
640  {
641  $posy+=4;
642  $pdf->SetXY($posx,$posy);
643  $langs->load("projects");
644  $pdf->SetTextColor(0,0,60);
645  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
646  }
647  }
648 
649  if ($object->date)
650  {
651  $posy+=4;
652  $pdf->SetXY($posx,$posy);
653  $pdf->SetTextColor(0,0,60);
654  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
655  }
656  else
657  {
658  $posy+=4;
659  $pdf->SetXY($posx,$posy);
660  $pdf->SetTextColor(255,0,0);
661  $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
662  }
663 
664  if ($object->thirdparty->code_fournisseur)
665  {
666  $posy+=4;
667  $pdf->SetXY($posx,$posy);
668  $pdf->SetTextColor(0,0,60);
669  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
670  }
671 
672  $posy+=1;
673  $pdf->SetTextColor(0,0,60);
674 
675  // Show list of linked objects
676  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
677 */
678  if ($showaddress)
679  {
680  // Sender properties
681  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
682 
683  // Show payer
684  $posy=42;
685  $posx=$this->marge_gauche;
686  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
687  $hautcadre=40;
688 
689  // Show sender frame
690  $pdf->SetTextColor(0,0,0);
691  $pdf->SetFont('','', $default_font_size - 2);
692  $pdf->SetXY($posx,$posy-5);
693  $pdf->MultiCell(66,5, $outputlangs->transnoentities("PayedBy").":", 0, 'L');
694  $pdf->SetXY($posx,$posy);
695  $pdf->SetFillColor(230,230,230);
696  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
697  $pdf->SetTextColor(0,0,60);
698 
699  // Show sender name
700  $pdf->SetXY($posx+2,$posy+3);
701  $pdf->SetFont('','B', $default_font_size);
702  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
703  $posy=$pdf->getY();
704 
705  // Show sender information
706  $pdf->SetXY($posx+2,$posy);
707  $pdf->SetFont('','', $default_font_size - 1);
708  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
709 
710  // Payed
711  $thirdparty = $object->thirdparty;
712 
713  $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
714 
715  $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
716 
717  // Show recipient
718  $widthrecbox=90;
719  if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
720  $posy=42;
721  $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
722  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
723 
724  // Show recipient frame
725  $pdf->SetTextColor(0,0,0);
726  $pdf->SetFont('','', $default_font_size - 2);
727  $pdf->SetXY($posx+2,$posy-5);
728  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":",0,'L');
729  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
730 
731  // Show recipient name
732  $pdf->SetXY($posx+2,$posy+3);
733  $pdf->SetFont('','B', $default_font_size);
734  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
735 
736  $posy = $pdf->getY();
737 
738  // Show recipient information
739  $pdf->SetFont('','', $default_font_size - 1);
740  $pdf->SetXY($posx+2,$posy);
741  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
742  }
743  }
744 
754  function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
755  {
756  global $conf;
757  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
758  return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
759  }
760 
761 }
762 
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:350
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:384
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="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< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
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:256
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:233
Class to generate expense report based on standard model.
Class to manage hooks.
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:852
_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:277
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
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)
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:1013
__construct($db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
type
Definition: viewcat.php:283