dolibarr  7.0.0-beta
pdf_standard.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
4  * Copyright (C) 2016 Philippe Grand <philippe.grand@atoo-net.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/expensereport/modules_expensereport.php';
28 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 
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("trips");
71  $langs->load("projects");
72 
73  $this->db = $db;
74  $this->name = "";
75  $this->description = $langs->trans('PDFStandardExpenseReports');
76 
77  // Dimension page pour format A4
78  $this->type = 'pdf';
79  $formatarray=pdf_getFormat();
80  $this->page_largeur = $formatarray['width'];
81  $this->page_hauteur = $formatarray['height'];
82  $this->format = array($this->page_largeur,$this->page_hauteur);
83  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
84  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
85  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
86  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
87 
88  $this->option_logo = 1; // Affiche logo
89  $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
90  $this->option_modereg = 1; // Affiche mode reglement
91  $this->option_condreg = 1; // Affiche conditions reglement
92  $this->option_codeproduitservice = 1; // Affiche code produit-service
93  $this->option_multilang = 1; // Dispo en plusieurs langues
94  $this->option_escompte = 0; // Affiche si il y a eu escompte
95  $this->option_credit_note = 0; // Support credit notes
96  $this->option_freetext = 1; // Support add of a personalised text
97  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
98 
99  $this->franchise=!$mysoc->tva_assuj;
100 
101  // Get source company
102  $this->emetteur=$mysoc;
103  if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
104 
105  // Define position of columns
106  $this->posxpiece=$this->marge_gauche+1;
107  $this->posxcomment=$this->marge_gauche+10;
108  $this->posxdate=88;
109  $this->posxtype=107;
110  $this->posxprojet=120;
111  $this->posxtva=136;
112  $this->posxup=152;
113  $this->posxqty=168;
114  $this->postotalttc=178;
115  if (empty($conf->projet->enabled)) {
116  $this->posxtva-=20;
117  $this->posxup-=20;
118  $this->posxqty-=20;
119  $this->postotalttc-=20;
120  }
121  if ($this->page_largeur < 210) // To work with US executive format
122  {
123  $this->posxdate-=20;
124  $this->posxtype-=20;
125  $this->posxprojet-=20;
126  $this->posxtva-=20;
127  $this->posxup-=20;
128  $this->posxqty-=20;
129  $this->postotalttc-=20;
130  }
131 
132  $this->tva=array();
133  $this->localtax1=array();
134  $this->localtax2=array();
135  $this->atleastoneratenotnull=0;
136  }
137 
138 
150  function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
151  {
152  global $user,$langs,$conf,$mysoc,$db,$hookmanager;
153 
154  if (! is_object($outputlangs)) $outputlangs=$langs;
155  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
156  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
157 
158  $outputlangs->load("main");
159  $outputlangs->load("dict");
160  $outputlangs->load("trips");
161  $outputlangs->load("projects");
162 
163  $nblignes = count($object->lines);
164 
165  if ($conf->expensereport->dir_output)
166  {
167  // Definition of $dir and $file
168  if ($object->specimen)
169  {
170  $dir = $conf->expensereport->dir_output;
171  $file = $dir . "/SPECIMEN.pdf";
172  }
173  else
174  {
175  $objectref = dol_sanitizeFileName($object->ref);
176  $dir = $conf->expensereport->dir_output . "/" . $objectref;
177  $file = $dir . "/" . $objectref . ".pdf";
178  }
179 
180  if (! file_exists($dir))
181  {
182  if (dol_mkdir($dir) < 0)
183  {
184  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
185  return 0;
186  }
187  }
188 
189  if (file_exists($dir))
190  {
191  // Add pdfgeneration hook
192  if (! is_object($hookmanager))
193  {
194  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
195  $hookmanager=new HookManager($this->db);
196  }
197  $hookmanager->initHooks(array('pdfgeneration'));
198  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
199  global $action;
200  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
201 
202  // Create pdf instance
203  $pdf=pdf_getInstance($this->format);
204  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
205  $heightforinfotot = 40; // Height reserved to output the info and total part
206  $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
207  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
208  $pdf->SetAutoPageBreak(1,0);
209 
210  if (class_exists('TCPDF'))
211  {
212  $pdf->setPrintHeader(false);
213  $pdf->setPrintFooter(false);
214  }
215  $pdf->SetFont(pdf_getPDFFont($outputlangs));
216  // Set path to the background PDF File
217  if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
218  {
219  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
220  $tplidx = $pdf->importPage(1);
221  }
222 
223  $pdf->Open();
224  $pagenb=0;
225  $pdf->SetDrawColor(128,128,128);
226 
227  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref_number));
228  $pdf->SetSubject($outputlangs->transnoentities("Trips"));
229  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
230  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
231  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips"));
232  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
233 
234  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
235 
236  // New page
237  $pdf->AddPage();
238  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
239  $pagenb++;
240  $this->_pagehead($pdf, $object, 1, $outputlangs);
241  $pdf->SetFont('','', $default_font_size - 1);
242  $pdf->MultiCell(0, 3, ''); // Set interline to 3
243  $pdf->SetTextColor(0,0,0);
244 
245  $tab_top = 95;
246  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10);
247  $tab_height = 130;
248  $tab_height_newpage = 150;
249 
250  // Show notes
251  $notetoshow=empty($object->note_public)?'':$object->note_public;
252  if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
253  {
254  // Get first sale rep
255  if (is_object($object->thirdparty))
256  {
257  $salereparray=$object->thirdparty->getSalesRepresentatives($user);
258  $salerepobj=new User($this->db);
259  $salerepobj->fetch($salereparray[0]['id']);
260  if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
261  }
262  }
263  if ($notetoshow)
264  {
265  $tab_top = 95;
266 
267  $pdf->SetFont('','', $default_font_size - 1);
268  $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
269  $nexY = $pdf->GetY();
270  $height_note=$nexY-$tab_top;
271 
272  // Rect prend une longueur en 3eme param
273  $pdf->SetDrawColor(192,192,192);
274  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
275 
276  $tab_height = $tab_height - $height_note;
277  $tab_top = $nexY+6;
278  }
279  else
280  {
281  $height_note=0;
282  }
283 
284  $iniY = $tab_top + 7;
285  $initialY = $tab_top + 7;
286  $nexY = $tab_top + 7;
287 
288  // Loop on each lines
289  for ($i = 0 ; $i < $nblignes ; $i++)
290  {
291  $piece_comptable = $i +1;
292 
293  $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage
294  $pdf->SetTextColor(0,0,0);
295 
296  $pdf->setTopMargin($tab_top_newpage);
297  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
298  $pageposbefore=$pdf->getPage();
299  $curY = $nexY;
300 
301  $pdf->SetFont('','', $default_font_size - 1);
302 
303  // Accountancy piece
304  $pdf->SetXY($this->posxpiece, $curY);
305  $pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-0.8, 4, $this->posxpiece-1, $curY, $piece_comptable, 0, 1);
306  $curY = ($pdf->PageNo() > $pageposbefore) ? $pdf->GetY()-4 : $curY;
307 
308  // Comments
309  $pdf->SetXY($this->posxcomment, $curY );
310  $pdf->writeHTMLCell($this->posxdate-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $object->lines[$i]->comments, 0, 1);
311  $curY = ($pdf->PageNo() > $pageposbefore) ? $pdf->GetY()-4 : $curY;
312 
313  // Date
314  $pdf->SetXY($this->posxdate -1, $curY);
315  $pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$i]->date,"day",false,$outputlangs), 0, 'C');
316 
317  // Type
318  $pdf->SetXY($this->posxtype -1, $curY);
319  $nextColumnPosX = $this->posxup;
320  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
321  $nextColumnPosX = $this->posxtva;
322  }
323  if (!empty($conf->projet->enabled)) {
324  $nextColumnPosX = $this->posxprojet;
325  }
326 
327  $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, dol_trunc($outputlangs->transnoentities($object->lines[$i]->type_fees_code), 12), 0, 'C');
328 
329  // Project
330  if (! empty($conf->projet->enabled))
331  {
332  $pdf->SetFont('','', $default_font_size - 1);
333  $pdf->SetXY($this->posxprojet, $curY);
334  $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$i]->projet_ref, 0, 'C');
335  }
336 
337  // VAT Rate
338  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
339  {
340  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
341  $pdf->SetXY($this->posxtva, $curY);
342  $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 4,$vat_rate, 0, 'C');
343  }
344 
345  // Unit price
346  $pdf->SetXY($this->posxup, $curY);
347  $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 4,price($object->lines[$i]->value_unit), 0, 'R');
348 
349  // Quantity
350  $pdf->SetXY($this->posxqty, $curY);
351  $pdf->MultiCell($this->postotalttc-$this->posxqty-0.8, 4,$object->lines[$i]->qty, 0, 'R');
352 
353  // Total with all taxes
354  $pdf->SetXY($this->postotalttc-1, $curY);
355  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 4, price($object->lines[$i]->total_ttc), 0, 'R');
356 
357  //nexY
358  $nexY = $pdf->GetY();
359  $pageposafter=$pdf->getPage();
360  $pdf->setPage($pageposbefore);
361  $pdf->setTopMargin($this->marge_haute);
362  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
363 
364  $nblineFollowComment = 1;
365  // Cherche nombre de lignes a venir pour savoir si place suffisante
366  if ($i < ($nblignes - 1)) // If it's not last line
367  {
368  //Fetch current description to know on which line the next one should be placed
369  $follow_comment = $object->lines[$i]->comments;
370  $follow_type = $object->lines[$i]->type_fees_code;
371 
372  //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
373  $nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output);
374  $nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output);
375 
376  $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed);
377  }
378 
379  $nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Passe espace entre les lignes
380 
381  // Detect if some page were added automatically and output _tableau for past pages
382  while ($pagenb < $pageposafter)
383  {
384  $pdf->setPage($pagenb);
385  if ($pagenb == 1)
386  {
387  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
388  }
389  else
390  {
391  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
392  }
393  $this->_pagefoot($pdf,$object,$outputlangs,1);
394  $pagenb++;
395  $pdf->setPage($pagenb);
396  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
397  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
398  }
399  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
400  {
401  if ($pagenb == 1)
402  {
403  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
404  }
405  else
406  {
407  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
408  }
409  $this->_pagefoot($pdf,$object,$outputlangs,1);
410  // New page
411  $pdf->AddPage();
412  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
413  $pagenb++;
414  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
415  }
416 
417  }
418 
419  // Show square
420  if ($pagenb == 1)
421  {
422  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
423  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
424  }
425  else
426  {
427  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
428  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
429  }
430 
431  $pdf->SetFont('','', 10);
432 
433  // Show total area box
434  $posy=$bottomlasttab+5;
435  $pdf->SetXY(100, $posy);
436  $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L');
437  $pdf->SetXY(160, $posy);
438  $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R');
439  $pdf->SetFillColor(248,248,248);
440 
441  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
442  {
443  // TODO Show vat amout per tax level
444  $posy+=5;
445  $pdf->SetXY(100, $posy);
446  $pdf->SetTextColor(0,0,60);
447  $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L');
448  $pdf->SetXY(160, $posy);
449  $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva),1, 'R');
450  }
451 
452  $posy+=5;
453  $pdf->SetXY(100, $posy);
454  $pdf->SetFont('','B', 10);
455  $pdf->SetTextColor(0,0,60);
456  $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L');
457  $pdf->SetXY(160, $posy);
458  $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ttc),1, 'R');
459 
460  // Pied de page
461  $this->_pagefoot($pdf,$object,$outputlangs);
462  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
463 
464  $pdf->Close();
465 
466  $pdf->Output($file,'F');
467 
468  // Add pdfgeneration hook
469  $hookmanager->initHooks(array('pdfgeneration'));
470  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
471  global $action;
472  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
473 
474  if (! empty($conf->global->MAIN_UMASK))
475  @chmod($file, octdec($conf->global->MAIN_UMASK));
476 
477  $this->result = array('fullpath'=>$file);
478 
479  return 1; // Pas d'erreur
480  }
481  else
482  {
483  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
484  return 0;
485  }
486  }
487  else
488  {
489  $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR");
490  return 0;
491  }
492  }
493 
503  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
504  {
505  global $conf,$langs,$hookmanager;
506 
507  $outputlangs->load("main");
508  $outputlangs->load("trips");
509  $outputlangs->load("companies");
510  $default_font_size = pdf_getPDFFontSize($outputlangs);
511 
512  /*
513  // ajout du fondu vert en bas de page à droite
514  $image_fondue = $conf->mycompany->dir_output.'/fondu_vert_.jpg';
515  $pdf->Image($image_fondue,20,107,200,190);
516 
517  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
518  */
519 
520  // Draft watermark
521  if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK))
522  {
523  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
524  }
525 
526  $pdf->SetTextColor(0,0,60);
527  $pdf->SetFont('','B', $default_font_size + 3);
528 
529  $posy=$this->marge_haute;
530  $posx=$this->page_largeur-$this->marge_droite-100;
531 
532  $pdf->SetXY($this->marge_gauche,$posy);
533 
534  // Logo
535  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
536  if ($this->emetteur->logo)
537  {
538  if (is_readable($logo))
539  {
540  $height=pdf_getHeightForLogo($logo);
541  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
542  }
543  else
544  {
545  $pdf->SetTextColor(200,0,0);
546  $pdf->SetFont('','B', $default_font_size -2);
547  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
548  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
549  }
550  }
551  else
552  {
553  $text=$this->emetteur->name;
554  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
555  }
556 
557  $pdf->SetFont('','B', $default_font_size + 4);
558  $pdf->SetXY($posx,$posy);
559  $pdf->SetTextColor(0,0,60);
560  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'R');
561 
562  $pdf->SetFont('','', $default_font_size -1);
563 
564  // Ref complete
565  $posy+=8;
566  $pdf->SetXY($posx,$posy);
567  $pdf->SetTextColor(0,0,60);
568  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R');
569 
570  // Date start period
571  $posy+=5;
572  $pdf->SetXY($posx,$posy);
573  $pdf->SetTextColor(0,0,60);
574  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outputlangs):''), '', 'R');
575 
576  // Date end period
577  $posy+=5;
578  $pdf->SetXY($posx,$posy);
579  $pdf->SetTextColor(0,0,60);
580  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outputlangs):''), '', 'R');
581 
582  // Status Expense Report
583  $posy+=6;
584  $pdf->SetXY($posx,$posy);
585  $pdf->SetFont('','B', $default_font_size + 2);
586  $pdf->SetTextColor(111,81,124);
587  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R');
588 
589  if ($showaddress)
590  {
591  // Sender properties
592  $carac_emetteur = '';
593  $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address);
594  $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town);
595  $carac_emetteur .= "\n";
596  // Phone
597  if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
598  // Fax
599  if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
600  // EMail
601  if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email);
602  // Web
603  if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url);
604 
605  // Show sender
606  $posy=50;
607  $posx=$this->marge_gauche;
608  $hautcadre=40;
609  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;
610 
611  // Show sender frame
612  $pdf->SetTextColor(0,0,0);
613  $pdf->SetFont('','B', $default_font_size - 2);
614  $pdf->SetXY($posx,$posy-5);
615  $pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L');
616  $pdf->SetXY($posx,$posy);
617  $pdf->SetFillColor(224,224,224);
618  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
619  $pdf->SetTextColor(0,0,60);
620 
621  // Show sender name
622  $pdf->SetXY($posx+2,$posy+3);
623  $pdf->SetFont('','B', $default_font_size);
624  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
625 
626  // Show sender information
627  $pdf->SetXY($posx+2,$posy+8);
628  $pdf->SetFont('','', $default_font_size - 1);
629  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
630 
631  // Show recipient
632  $posy=50;
633  $posx=100;
634 
635  // Show recipient frame
636  $pdf->SetTextColor(0,0,0);
637  $pdf->SetFont('','B',8);
638  $pdf->SetXY($posx,$posy-5);
639  $pdf->MultiCell(80,5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L');
640  $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
641 
642  // Informations for trip (dates and users workflow)
643  if ($object->fk_user_author > 0)
644  {
645  $userfee=new User($this->db);
646  $userfee->fetch($object->fk_user_author); $posy+=3;
647  $pdf->SetXY($posx+2,$posy);
648  $pdf->SetFont('','',10);
649  $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
650  $posy+=5;
651  $pdf->SetXY($posx+2,$posy);
652  $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outputlangs),0,'L');
653  }
654 
655  if ($object->fk_statut==99)
656  {
657  if ($object->fk_user_refuse > 0)
658  {
659  $userfee=new User($this->db);
660  $userfee->fetch($object->fk_user_refuse); $posy+=6;
661  $pdf->SetXY($posx+2,$posy);
662  $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
663  $posy+=5;
664  $pdf->SetXY($posx+2,$posy);
665  $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L');
666  $posy+=5;
667  $pdf->SetXY($posx+2,$posy);
668  $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outputlangs),0,'L');
669  }
670  }
671  else if($object->fk_statut==4)
672  {
673  if ($object->fk_user_cancel > 0)
674  {
675  $userfee=new User($this->db);
676  $userfee->fetch($object->fk_user_cancel); $posy+=6;
677  $pdf->SetXY($posx+2,$posy);
678  $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
679  $posy+=5;
680  $pdf->SetXY($posx+2,$posy);
681  $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L');
682  $posy+=5;
683  $pdf->SetXY($posx+2,$posy);
684  $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outputlangs),0,'L');
685  }
686  }
687  else
688  {
689  if ($object->fk_user_approve > 0)
690  {
691  $userfee=new User($this->db);
692  $userfee->fetch($object->fk_user_approve); $posy+=6;
693  $pdf->SetXY($posx+2,$posy);
694  $pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
695  $posy+=5;
696  $pdf->SetXY($posx+2,$posy);
697  $pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outputlangs),0,'L');
698  }
699  }
700 
701  if($object->fk_statut==6)
702  {
703  if ($object->fk_user_paid > 0)
704  {
705  $userfee=new User($this->db);
706  $userfee->fetch($object->fk_user_paid); $posy+=6;
707  $pdf->SetXY($posx+2,$posy);
708  $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
709  $posy+=5;
710  $pdf->SetXY($posx+2,$posy);
711  $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outputlangs),0,'L');
712  }
713  }
714  }
715 
716  }
717 
731  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
732  {
733  global $conf;
734 
735  // Force to disable hidetop and hidebottom
736  $hidebottom=0;
737  if ($hidetop) $hidetop=-1;
738 
739  $currency = !empty($currency) ? $currency : $conf->currency;
740  $default_font_size = pdf_getPDFFontSize($outputlangs);
741 
742  // Amount in (at tab_top - 1)
743  $pdf->SetTextColor(0,0,0);
744  $pdf->SetFont('','', $default_font_size - 2);
745  $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
746  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4);
747  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
748 
749  $pdf->SetDrawColor(128,128,128);
750 
751  // Rect prend une longueur en 3eme param
752  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
753  // line prend une position y en 3eme param
754  if (empty($hidetop))
755  {
756  $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
757  }
758 
759  $pdf->SetFont('','',8);
760 
761  // Accountancy piece
762  if (empty($hidetop))
763  {
764  $pdf->SetXY($this->posxpiece-1, $tab_top+1);
765  $pdf->MultiCell($this->posxcomment-$this->posxpiece-1,1,'','','R');
766  }
767 
768  // Comments
769  $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height);
770  if (empty($hidetop))
771  {
772  $pdf->SetXY($this->posxcomment-1, $tab_top+1);
773  $pdf->MultiCell($this->posxdate-$this->posxcomment-1,1,$outputlangs->transnoentities("Description"),'','L');
774  }
775 
776  // Date
777  $pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height);
778  if (empty($hidetop))
779  {
780  $pdf->SetXY($this->posxdate-1, $tab_top+1);
781  $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C');
782  }
783 
784  // Type
785  $pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height);
786  if (empty($hidetop))
787  {
788  $pdf->SetXY($this->posxtype-1, $tab_top+1);
789  $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C');
790  }
791 
792  if (!empty($conf->projet->enabled))
793  {
794  // Project
795  $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height);
796  if (empty($hidetop))
797  {
798  $pdf->SetXY($this->posxprojet - 1, $tab_top + 1);
799  $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C');
800  }
801  }
802 
803  // VAT
804  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
805  {
806  $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
807  if (empty($hidetop))
808  {
809  $pdf->SetXY($this->posxtva-1, $tab_top+1);
810  $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C');
811  }
812  }
813 
814  // Unit price
815  $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
816  if (empty($hidetop))
817  {
818  $pdf->SetXY($this->posxup-1, $tab_top+1);
819  $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C');
820  }
821 
822  // Quantity
823  $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
824  if (empty($hidetop))
825  {
826  $pdf->SetXY($this->posxqty-1, $tab_top+1);
827  $pdf->MultiCell($this->postotalttc-$this->posxqty - 1,2, $outputlangs->transnoentities("Qty"),'','R');
828  }
829 
830  // Total with all taxes
831  $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
832  if (empty($hidetop))
833  {
834  $pdf->SetXY($this->postotalttc-1, $tab_top+1);
835  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R');
836  }
837 
838  $pdf->SetTextColor(0,0,0);
839  }
840 
850  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
851  {
852  global $conf;
853  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
854  return pdf_pagefoot($pdf,$outputlangs,'EXPENSEREPORT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
855  }
856 
857 }
858 
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:82
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:623
</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.
Class to manage Dolibarr users.
Definition: user.class.php:39
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:233
dol_concatdesc($text1, $text2, $forxml=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
Parent class for trips and expenses templates.
Class to generate expense report based on standard model.
Class to manage hooks.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1472
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.
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...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
_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)
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.
dol_nboflines_bis($text, $maxlinesize=0, $charset='UTF-8')
Return nb of lines of a formated text with and (WARNING: string must not have mixed and br sepa...
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
type
Definition: viewcat.php:283
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.