dolibarr  7.0.0-beta
pdf_azur.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
4  * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
5  * Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
7  * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
9  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  * or see http://www.gnu.org/
24  */
25 
31 require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
32 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
36 
37 
42 {
43  var $db;
44  var $name;
45  var $description;
46  var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
47  var $type;
48 
49  var $phpmin = array(4,3,0); // Minimum version of PHP required by module
50  var $version = 'dolibarr';
51 
52  var $page_largeur;
53  var $page_hauteur;
54  var $format;
55  var $marge_gauche;
56  var $marge_droite;
57  var $marge_haute;
58  var $marge_basse;
59 
60  var $emetteur; // Objet societe qui emet
61 
62 
68  function __construct($db)
69  {
70  global $conf,$langs,$mysoc;
71 
72  $langs->load("main");
73  $langs->load("bills");
74 
75  $this->db = $db;
76  $this->name = "azur";
77  $this->description = $langs->trans('DocModelAzurDescription');
78  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
79 
80  // Dimension page
81  $this->type = 'pdf';
82  $formatarray=pdf_getFormat();
83  $this->page_largeur = $formatarray['width'];
84  $this->page_hauteur = $formatarray['height'];
85  $this->format = array($this->page_largeur,$this->page_hauteur);
86  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
87  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
88  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
89  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
90 
91  $this->option_logo = 1; // Affiche logo
92  $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
93  $this->option_modereg = 1; // Affiche mode reglement
94  $this->option_condreg = 1; // Affiche conditions reglement
95  $this->option_codeproduitservice = 1; // Affiche code produit-service
96  $this->option_multilang = 1; // Dispo en plusieurs langues
97  $this->option_escompte = 0; // Affiche si il y a eu escompte
98  $this->option_credit_note = 0; // Support credit notes
99  $this->option_freetext = 1; // Support add of a personalised text
100  $this->option_draft_watermark = 1; //Support add of a watermark on drafts
101 
102  $this->franchise=!$mysoc->tva_assuj;
103 
104  // Get source company
105  $this->emetteur=$mysoc;
106  if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
107 
108  // Define position of columns
109  $this->posxdesc=$this->marge_gauche+1;
110  if($conf->global->PRODUCT_USE_UNITS)
111  {
112  $this->posxtva=99;
113  $this->posxup=114;
114  $this->posxqty=130;
115  $this->posxunit=147;
116  }
117  else
118  {
119  $this->posxtva=110;
120  $this->posxup=126;
121  $this->posxqty=145;
122  }
123  $this->posxdiscount=162;
124  $this->postotalht=174;
125  if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
126  $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
127  if ($this->page_largeur < 210) // To work with US executive format
128  {
129  $this->posxpicture-=20;
130  $this->posxtva-=20;
131  $this->posxup-=20;
132  $this->posxqty-=20;
133  $this->posxunit-=20;
134  $this->posxdiscount-=20;
135  $this->postotalht-=20;
136  }
137 
138  $this->tva=array();
139  $this->localtax1=array();
140  $this->localtax2=array();
141  $this->atleastoneratenotnull=0;
142  $this->atleastonediscount=0;
143  }
144 
156  function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
157  {
158  global $user,$langs,$conf,$mysoc,$db,$hookmanager;
159 
160  if (! is_object($outputlangs)) $outputlangs=$langs;
161  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
162  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
163 
164  $outputlangs->load("main");
165  $outputlangs->load("dict");
166  $outputlangs->load("companies");
167  $outputlangs->load("bills");
168  $outputlangs->load("propal");
169  $outputlangs->load("products");
170 
171  $nblignes = count($object->lines);
172 
173  // Loop on each lines to detect if there is at least one image to show
174  $realpatharray=array();
175  if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
176  {
177  $objphoto = new Product($this->db);
178 
179  for ($i = 0 ; $i < $nblignes ; $i++)
180  {
181  if (empty($object->lines[$i]->fk_product)) continue;
182 
183  $objphoto->fetch($object->lines[$i]->fk_product);
184  //var_dump($objphoto->ref);exit;
185  if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
186  {
187  $pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
188  $pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
189  }
190  else
191  {
192  $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
193  $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/"; // alternative
194  }
195 
196  $arephoto = false;
197  foreach ($pdir as $midir)
198  {
199  if (! $arephoto)
200  {
201  $dir = $conf->product->dir_output.'/'.$midir;
202 
203  foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
204  {
205  if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
206  {
207  if ($obj['photo_vignette'])
208  {
209  $filename= $obj['photo_vignette'];
210  }
211  else
212  {
213  $filename=$obj['photo'];
214  }
215  }
216  else
217  {
218  $filename=$obj['photo'];
219  }
220 
221  $realpath = $dir.$filename;
222  $arephoto = true;
223  }
224  }
225  }
226 
227  if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
228  }
229  }
230 
231  if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
232 
233  if ($conf->propal->dir_output)
234  {
235  $object->fetch_thirdparty();
236 
237  $deja_regle = 0;
238 
239  // Definition of $dir and $file
240  if ($object->specimen)
241  {
242  $dir = $conf->propal->dir_output;
243  $file = $dir . "/SPECIMEN.pdf";
244  }
245  else
246  {
247  $objectref = dol_sanitizeFileName($object->ref);
248  $dir = $conf->propal->dir_output . "/" . $objectref;
249  $file = $dir . "/" . $objectref . ".pdf";
250  }
251 
252  if (! file_exists($dir))
253  {
254  if (dol_mkdir($dir) < 0)
255  {
256  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
257  return 0;
258  }
259  }
260 
261  if (file_exists($dir))
262  {
263  // Add pdfgeneration hook
264  if (! is_object($hookmanager))
265  {
266  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
267  $hookmanager=new HookManager($this->db);
268  }
269  $hookmanager->initHooks(array('pdfgeneration'));
270  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
271  global $action;
272  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
273 
274  // Create pdf instance
275  $pdf=pdf_getInstance($this->format);
276  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
277  $pdf->SetAutoPageBreak(1,0);
278 
279  if (class_exists('TCPDF'))
280  {
281  $pdf->setPrintHeader(false);
282  $pdf->setPrintFooter(false);
283  }
284  $pdf->SetFont(pdf_getPDFFont($outputlangs));
285  // Set path to the background PDF File
286  if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
287  {
288  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
289  $tplidx = $pdf->importPage(1);
290  }
291 
292  $pdf->Open();
293  $pagenb=0;
294  $pdf->SetDrawColor(128,128,128);
295 
296  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
297  $pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle"));
298  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
299  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
300  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
301  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
302 
303  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
304 
305  // Positionne $this->atleastonediscount si on a au moins une remise
306  for ($i = 0 ; $i < $nblignes ; $i++)
307  {
308  if ($object->lines[$i]->remise_percent)
309  {
310  $this->atleastonediscount++;
311  }
312  }
313  if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
314  {
315  $this->posxpicture+=($this->postotalht - $this->posxdiscount);
316  $this->posxtva+=($this->postotalht - $this->posxdiscount);
317  $this->posxup+=($this->postotalht - $this->posxdiscount);
318  $this->posxqty+=($this->postotalht - $this->posxdiscount);
319  $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
320  //$this->postotalht;
321  }
322 
323  // New page
324  $pdf->AddPage();
325  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
326  $pagenb++;
327 
328  $heightforinfotot = 40; // Height reserved to output the info and total part
329  $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
330  $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
331  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
332  //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
333 
334  $this->_pagehead($pdf, $object, 1, $outputlangs);
335  $pdf->SetFont('','', $default_font_size - 1);
336  $pdf->MultiCell(0, 3, ''); // Set interline to 3
337  $pdf->SetTextColor(0,0,0);
338 
339 
340  $tab_top = 90;
341  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
342  $tab_height = 130;
343  $tab_height_newpage = 150;
344 
345  // Incoterm
346  $height_incoterms = 0;
347  if ($conf->incoterm->enabled)
348  {
349  $desc_incoterms = $object->getIncotermsForPDF();
350  if ($desc_incoterms)
351  {
352  $tab_top = 88;
353 
354  $pdf->SetFont('','', $default_font_size - 1);
355  $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
356  $nexY = $pdf->GetY();
357  $height_incoterms=$nexY-$tab_top;
358 
359  // Rect prend une longueur en 3eme param
360  $pdf->SetDrawColor(192,192,192);
361  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
362 
363  $tab_top = $nexY+6;
364  $height_incoterms += 4;
365  }
366  }
367 
368  // Affiche notes
369  $notetoshow=empty($object->note_public)?'':$object->note_public;
370  if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
371  {
372  // Get first sale rep
373  if (is_object($object->thirdparty))
374  {
375  $salereparray=$object->thirdparty->getSalesRepresentatives($user);
376  $salerepobj=new User($this->db);
377  $salerepobj->fetch($salereparray[0]['id']);
378  if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
379  }
380  }
381  if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
382  {
383  $tmpuser=new User($this->db);
384  $tmpuser->fetch($object->user_author_id);
385  $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
386  if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email;
387  if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
388  }
389  if ($notetoshow)
390  {
391  $tab_top = 88 + $height_incoterms;
392 
393  $pdf->SetFont('','', $default_font_size - 1);
394  $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
395  $nexY = $pdf->GetY();
396  $height_note=$nexY-$tab_top;
397 
398  // Rect prend une longueur en 3eme param
399  $pdf->SetDrawColor(192,192,192);
400  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
401 
402  $tab_height = $tab_height - $height_note;
403  $tab_top = $nexY+6;
404  }
405  else
406  {
407  $height_note=0;
408  }
409 
410  $iniY = $tab_top + 7;
411  $curY = $tab_top + 7;
412  $nexY = $tab_top + 7;
413 
414  // Loop on each lines
415  for ($i = 0; $i < $nblignes; $i++)
416  {
417  $curY = $nexY;
418  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
419  $pdf->SetTextColor(0,0,0);
420 
421  // Define size of image if we need it
422  $imglinesize=array();
423  if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
424 
425  $pdf->setTopMargin($tab_top_newpage);
426  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
427  $pageposbefore=$pdf->getPage();
428 
429  $showpricebeforepagebreak=1;
430  $posYAfterImage=0;
431  $posYAfterDescription=0;
432 
433  // We start with Photo of product line
434  if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page
435  {
436  $pdf->AddPage('','',true);
437  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
438  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
439  $pdf->setPage($pageposbefore+1);
440 
441  $curY = $tab_top_newpage;
442  $showpricebeforepagebreak=0;
443  }
444 
445  if (isset($imglinesize['width']) && isset($imglinesize['height']))
446  {
447  $curX = $this->posxpicture-1;
448  $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
449  // $pdf->Image does not increase value return by getY, so we save it manually
450  $posYAfterImage=$curY+$imglinesize['height'];
451  }
452 
453  // Description of product line
454  $curX = $this->posxdesc-1;
455 
456  $pdf->startTransaction();
457  pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
458  $pageposafter=$pdf->getPage();
459  if ($pageposafter > $pageposbefore) // There is a pagebreak
460  {
461  $pdf->rollbackTransaction(true);
462  $pageposafter=$pageposbefore;
463  //print $pageposafter.'-'.$pageposbefore;exit;
464  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
465  pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
466 
467  $pageposafter=$pdf->getPage();
468  $posyafter=$pdf->GetY();
469  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
470  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
471  {
472  if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
473  {
474  $pdf->AddPage('','',true);
475  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
476  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
477  $pdf->setPage($pageposafter+1);
478  }
479  }
480  else
481  {
482  // We found a page break
483  $showpricebeforepagebreak=0;
484  }
485  }
486  else // No pagebreak
487  {
488  $pdf->commitTransaction();
489  }
490  $posYAfterDescription=$pdf->GetY();
491 
492  $nexY = $pdf->GetY();
493  $pageposafter=$pdf->getPage();
494 
495  $pdf->setPage($pageposbefore);
496  $pdf->setTopMargin($this->marge_haute);
497  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
498 
499  // We suppose that a too long description or photo were moved completely on next page
500  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
501  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
502  }
503 
504  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
505 
506  // VAT Rate
507  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
508  {
509  $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
510  $pdf->SetXY($this->posxtva-5, $curY);
511  $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
512  }
513 
514  // Unit price before discount
515  $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
516  $pdf->SetXY($this->posxup, $curY);
517  $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
518 
519  // Quantity
520  $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
521  $pdf->SetXY($this->posxqty, $curY);
522  // Enough for 6 chars
523  if($conf->global->PRODUCT_USE_UNITS)
524  {
525  $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
526  }
527  else
528  {
529  $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
530  }
531 
532  // Unit
533  if($conf->global->PRODUCT_USE_UNITS)
534  {
535  $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
536  $pdf->SetXY($this->posxunit, $curY);
537  $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
538  }
539 
540  // Discount on line
541  $pdf->SetXY($this->posxdiscount, $curY);
542  if ($object->lines[$i]->remise_percent)
543  {
544  $pdf->SetXY($this->posxdiscount-2, $curY);
545  $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
546  $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
547  }
548 
549  // Total HT line
550  $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
551  $pdf->SetXY($this->postotalht, $curY);
552  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
553 
554  // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
555  if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
556  else $tvaligne=$object->lines[$i]->total_tva;
557 
558  $localtax1ligne=$object->lines[$i]->total_localtax1;
559  $localtax2ligne=$object->lines[$i]->total_localtax2;
560  $localtax1_rate=$object->lines[$i]->localtax1_tx;
561  $localtax2_rate=$object->lines[$i]->localtax2_tx;
562  $localtax1_type=$object->lines[$i]->localtax1_type;
563  $localtax2_type=$object->lines[$i]->localtax2_type;
564 
565  if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
566  if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
567  if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
568 
569  $vatrate=(string) $object->lines[$i]->tva_tx;
570 
571  // Retrieve type from database for backward compatibility with old records
572  if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
573  && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
574  {
575  $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
576  $localtax1_type = $localtaxtmp_array[0];
577  $localtax2_type = $localtaxtmp_array[2];
578  }
579 
580  // retrieve global local tax
581  if ($localtax1_type && $localtax1ligne != 0)
582  $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
583  if ($localtax2_type && $localtax2ligne != 0)
584  $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
585 
586  if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
587  if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
588  $this->tva[$vatrate] += $tvaligne;
589 
590  if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
591 
592  // Add line
593  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
594  {
595  $pdf->setPage($pageposafter);
596  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
597  //$pdf->SetDrawColor(190,190,200);
598  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
599  $pdf->SetLineStyle(array('dash'=>0));
600  }
601 
602  $nexY+=2; // Passe espace entre les lignes
603 
604  // Detect if some page were added automatically and output _tableau for past pages
605  while ($pagenb < $pageposafter)
606  {
607  $pdf->setPage($pagenb);
608  if ($pagenb == 1)
609  {
610  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
611  }
612  else
613  {
614  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
615  }
616  $this->_pagefoot($pdf,$object,$outputlangs,1);
617  $pagenb++;
618  $pdf->setPage($pagenb);
619  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
620  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
621  }
622  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
623  {
624  if ($pagenb == 1)
625  {
626  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
627  }
628  else
629  {
630  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
631  }
632  $this->_pagefoot($pdf,$object,$outputlangs,1);
633  // New page
634  $pdf->AddPage();
635  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
636  $pagenb++;
637  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
638  }
639  }
640 
641  // Show square
642  if ($pagenb == 1)
643  {
644  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
645  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
646  }
647  else
648  {
649  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
650  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
651  }
652 
653  // Affiche zone infos
654  $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
655 
656  // Affiche zone totaux
657  $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
658 
659  // Affiche zone versements
660  /*
661  if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
662  {
663  $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
664  }
665  */
666 
667  // Customer signature area
668  if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
669  {
670  $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
671  }
672 
673  // Pied de page
674  $this->_pagefoot($pdf,$object,$outputlangs);
675  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
676 
677  //If propal merge product PDF is active
678  if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
679  {
680  require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
681 
682  $already_merged = array ();
683  foreach ( $object->lines as $line ) {
684  if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) {
685  // Find the desire PDF
686  $filetomerge = new Propalmergepdfproduct($this->db);
687 
688  if ($conf->global->MAIN_MULTILANGS) {
689  $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
690  } else {
691  $filetomerge->fetch_by_product($line->fk_product);
692  }
693 
694  $already_merged[] = $line->fk_product;
695 
696  $product = new Product($this->db);
697  $product->fetch($line->fk_product);
698 
699  if ($product->entity!=$conf->entity) {
700  $entity_product_file=$product->entity;
701  } else {
702  $entity_product_file=$conf->entity;
703  }
704 
705  // If PDF is selected and file is not empty
706  if (count($filetomerge->lines) > 0) {
707  foreach ( $filetomerge->lines as $linefile ) {
708  if (! empty($linefile->id) && ! empty($linefile->file_name)) {
709 
710 
711  if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
712  {
713  if (! empty($conf->product->enabled)) {
714  $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
715  } elseif (! empty($conf->service->enabled)) {
716  $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
717  }
718  }
719  else
720  {
721  if (! empty($conf->product->enabled)) {
722  $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
723  } elseif (! empty($conf->service->enabled)) {
724  $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
725  }
726  }
727 
728  dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
729 
730  $infile = $filetomerge_dir . '/' . $linefile->file_name;
731  if (file_exists($infile) && is_readable($infile)) {
732  $pagecount = $pdf->setSourceFile($infile);
733  for($i = 1; $i <= $pagecount; $i ++) {
734  $tplIdx = $pdf->importPage($i);
735  if ($tplIdx!==false) {
736  $s = $pdf->getTemplatesize($tplIdx);
737  $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
738  $pdf->useTemplate($tplIdx);
739  } else {
740  setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
741  }
742  }
743  }
744  }
745  }
746  }
747  }
748  }
749  }
750 
751  $pdf->Close();
752 
753  $pdf->Output($file,'F');
754 
755  //Add pdfgeneration hook
756  $hookmanager->initHooks(array('pdfgeneration'));
757  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
758  global $action;
759  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
760 
761  if (! empty($conf->global->MAIN_UMASK))
762  @chmod($file, octdec($conf->global->MAIN_UMASK));
763 
764  $this->result = array('fullpath'=>$file);
765 
766  return 1; // Pas d'erreur
767  }
768  else
769  {
770  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
771  return 0;
772  }
773  }
774  else
775  {
776  $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
777  return 0;
778  }
779  }
780 
790  function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
791  {
792 
793  }
794 
795 
805  function _tableau_info(&$pdf, $object, $posy, $outputlangs)
806  {
807  global $conf;
808  $default_font_size = pdf_getPDFFontSize($outputlangs);
809 
810  $pdf->SetFont('','', $default_font_size - 1);
811 
812  // If France, show VAT mention if not applicable
813  if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
814  {
815  $pdf->SetFont('','B', $default_font_size - 2);
816  $pdf->SetXY($this->marge_gauche, $posy);
817  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
818 
819  $posy=$pdf->GetY()+4;
820  }
821 
822  $posxval=52;
823 
824  // Show shipping date
825  if (! empty($object->date_livraison))
826  {
827  $outputlangs->load("sendings");
828  $pdf->SetFont('','B', $default_font_size - 2);
829  $pdf->SetXY($this->marge_gauche, $posy);
830  $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
831  $pdf->MultiCell(80, 4, $titre, 0, 'L');
832  $pdf->SetFont('','', $default_font_size - 2);
833  $pdf->SetXY($posxval, $posy);
834  $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
835  $pdf->MultiCell(80, 4, $dlp, 0, 'L');
836 
837  $posy=$pdf->GetY()+1;
838  }
839  elseif ($object->availability_code || $object->availability) // Show availability conditions
840  {
841  $pdf->SetFont('','B', $default_font_size - 2);
842  $pdf->SetXY($this->marge_gauche, $posy);
843  $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
844  $pdf->MultiCell(80, 4, $titre, 0, 'L');
845  $pdf->SetTextColor(0,0,0);
846  $pdf->SetFont('','', $default_font_size - 2);
847  $pdf->SetXY($posxval, $posy);
848  $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
849  $lib_availability=str_replace('\n',"\n",$lib_availability);
850  $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
851 
852  $posy=$pdf->GetY()+1;
853  }
854 
855  // Show payments conditions
856  if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
857  {
858  $pdf->SetFont('','B', $default_font_size - 2);
859  $pdf->SetXY($this->marge_gauche, $posy);
860  $titre = $outputlangs->transnoentities("PaymentConditions").':';
861  $pdf->MultiCell(43, 4, $titre, 0, 'L');
862 
863  $pdf->SetFont('','', $default_font_size - 2);
864  $pdf->SetXY($posxval, $posy);
865  $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
866  $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
867  $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
868 
869  $posy=$pdf->GetY()+3;
870  }
871 
872  if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE))
873  {
874  // Check a payment mode is defined
875  /* Not required on a proposal
876  if (empty($object->mode_reglement_code)
877  && ! $conf->global->FACTURE_CHQ_NUMBER
878  && ! $conf->global->FACTURE_RIB_NUMBER)
879  {
880  $pdf->SetXY($this->marge_gauche, $posy);
881  $pdf->SetTextColor(200,0,0);
882  $pdf->SetFont('','B', $default_font_size - 2);
883  $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
884  $pdf->SetTextColor(0,0,0);
885 
886  $posy=$pdf->GetY()+1;
887  }
888  */
889 
890  // Show payment mode
891  if ($object->mode_reglement_code
892  && $object->mode_reglement_code != 'CHQ'
893  && $object->mode_reglement_code != 'VIR')
894  {
895  $pdf->SetFont('','B', $default_font_size - 2);
896  $pdf->SetXY($this->marge_gauche, $posy);
897  $titre = $outputlangs->transnoentities("PaymentMode").':';
898  $pdf->MultiCell(80, 5, $titre, 0, 'L');
899  $pdf->SetFont('','', $default_font_size - 2);
900  $pdf->SetXY($posxval, $posy);
901  $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
902  $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
903 
904  $posy=$pdf->GetY()+2;
905  }
906 
907  // Show payment mode CHQ
908  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
909  {
910  // Si mode reglement non force ou si force a CHQ
911  if (! empty($conf->global->FACTURE_CHQ_NUMBER))
912  {
913  $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
914 
915  if ($conf->global->FACTURE_CHQ_NUMBER > 0)
916  {
917  $account = new Account($this->db);
918  $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
919 
920  $pdf->SetXY($this->marge_gauche, $posy);
921  $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
922  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
923  $posy=$pdf->GetY()+1;
924 
925  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
926  {
927  $pdf->SetXY($this->marge_gauche, $posy);
928  $pdf->SetFont('','', $default_font_size - $diffsizetitle);
929  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
930  $posy=$pdf->GetY()+2;
931  }
932  }
933  if ($conf->global->FACTURE_CHQ_NUMBER == -1)
934  {
935  $pdf->SetXY($this->marge_gauche, $posy);
936  $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
937  $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
938  $posy=$pdf->GetY()+1;
939 
940  if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
941  {
942  $pdf->SetXY($this->marge_gauche, $posy);
943  $pdf->SetFont('','', $default_font_size - $diffsizetitle);
944  $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
945  $posy=$pdf->GetY()+2;
946  }
947  }
948  }
949  }
950 
951  // If payment mode not forced or forced to VIR, show payment with BAN
952  if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
953  {
954  if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
955  {
956  $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
957  if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
958  $account = new Account($this->db);
959  $account->fetch($bankid);
960 
961  $curx=$this->marge_gauche;
962  $cury=$posy;
963 
964  $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
965 
966  $posy+=2;
967  }
968  }
969  }
970 
971  return $posy;
972  }
973 
974 
985  function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
986  {
987  global $conf,$mysoc;
988  $default_font_size = pdf_getPDFFontSize($outputlangs);
989 
990  $tab2_top = $posy;
991  $tab2_hl = 4;
992  $pdf->SetFont('','', $default_font_size - 1);
993 
994  // Tableau total
995  $col1x = 120; $col2x = 170;
996  if ($this->page_largeur < 210) // To work with US executive format
997  {
998  $col2x-=20;
999  }
1000  $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1001 
1002  $useborder=0;
1003  $index = 0;
1004 
1005  // Total HT
1006  $pdf->SetFillColor(255,255,255);
1007  $pdf->SetXY($col1x, $tab2_top + 0);
1008  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1009 
1010  $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1011  $pdf->SetXY($col2x, $tab2_top + 0);
1012  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
1013 
1014  // Show VAT by rates and total
1015  $pdf->SetFillColor(248,248,248);
1016 
1017  $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1018 
1019  $this->atleastoneratenotnull=0;
1020  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1021  {
1022  $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1023  if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1024  {
1025  // Nothing to do
1026  }
1027  else
1028  {
1029  //Local tax 1 before VAT
1030  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1031  //{
1032  foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1033  {
1034  if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1035 
1036  foreach( $localtax_rate as $tvakey => $tvaval )
1037  {
1038  if ($tvakey!=0) // On affiche pas taux 0
1039  {
1040  //$this->atleastoneratenotnull++;
1041 
1042  $index++;
1043  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1044 
1045  $tvacompl='';
1046  if (preg_match('/\*/',$tvakey))
1047  {
1048  $tvakey=str_replace('*','',$tvakey);
1049  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1050  }
1051  $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1052  $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1053  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1054 
1055  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1056  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1057  }
1058  }
1059  }
1060  //}
1061  //Local tax 2 before VAT
1062  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1063  //{
1064  foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1065  {
1066  if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1067 
1068  foreach( $localtax_rate as $tvakey => $tvaval )
1069  {
1070  if ($tvakey!=0) // On affiche pas taux 0
1071  {
1072  //$this->atleastoneratenotnull++;
1073 
1074 
1075 
1076  $index++;
1077  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078 
1079  $tvacompl='';
1080  if (preg_match('/\*/',$tvakey))
1081  {
1082  $tvakey=str_replace('*','',$tvakey);
1083  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084  }
1085  $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1086  $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1087  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1088 
1089  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1090  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1091 
1092  }
1093  }
1094  }
1095  //}
1096  // VAT
1097  foreach($this->tva as $tvakey => $tvaval)
1098  {
1099  if ($tvakey != 0) // On affiche pas taux 0
1100  {
1101  $this->atleastoneratenotnull++;
1102 
1103  $index++;
1104  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105 
1106  $tvacompl='';
1107  if (preg_match('/\*/',$tvakey))
1108  {
1109  $tvakey=str_replace('*','',$tvakey);
1110  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111  }
1112  $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1113  $totalvat.=vatrate($tvakey,1).$tvacompl;
1114  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1115 
1116  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1117  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1118  }
1119  }
1120 
1121  //Local tax 1 after VAT
1122  //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1123  //{
1124  foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1125  {
1126  if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1127 
1128  foreach( $localtax_rate as $tvakey => $tvaval )
1129  {
1130  if ($tvakey != 0) // On affiche pas taux 0
1131  {
1132  //$this->atleastoneratenotnull++;
1133 
1134  $index++;
1135  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1136 
1137  $tvacompl='';
1138  if (preg_match('/\*/',$tvakey))
1139  {
1140  $tvakey=str_replace('*','',$tvakey);
1141  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1142  }
1143  $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1144 
1145  $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1146  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1147  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1148  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1149  }
1150  }
1151  }
1152  //}
1153  //Local tax 2 after VAT
1154  //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1155  //{
1156  foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1157  {
1158  if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1159 
1160  foreach( $localtax_rate as $tvakey => $tvaval )
1161  {
1162  // retrieve global local tax
1163  if ($tvakey != 0) // On affiche pas taux 0
1164  {
1165  //$this->atleastoneratenotnull++;
1166 
1167  $index++;
1168  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1169 
1170  $tvacompl='';
1171  if (preg_match('/\*/',$tvakey))
1172  {
1173  $tvakey=str_replace('*','',$tvakey);
1174  $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1175  }
1176  $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1177 
1178  $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1179  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1180 
1181  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1182  $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1183  }
1184  }
1185  }
1186  //}
1187 
1188  // Total TTC
1189  $index++;
1190  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1191  $pdf->SetTextColor(0,0,60);
1192  $pdf->SetFillColor(224,224,224);
1193  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1194 
1195  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1196  $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1197  }
1198  }
1199 
1200  $pdf->SetTextColor(0,0,0);
1201 
1202  /*
1203  $resteapayer = $object->total_ttc - $deja_regle;
1204  if (! empty($object->paye)) $resteapayer=0;
1205  */
1206 
1207  if ($deja_regle > 0)
1208  {
1209  $index++;
1210 
1211  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1212  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1213 
1214  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1215  $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1216 
1217  /*
1218  if ($object->close_code == 'discount_vat')
1219  {
1220  $index++;
1221  $pdf->SetFillColor(255,255,255);
1222 
1223  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1224  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1225 
1226  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1227  $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1);
1228 
1229  $resteapayer=0;
1230  }
1231  */
1232 
1233  $index++;
1234  $pdf->SetTextColor(0,0,60);
1235  $pdf->SetFillColor(224,224,224);
1236  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1237  $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1238 
1239  $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1240  $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1241 
1242  $pdf->SetFont('','', $default_font_size - 1);
1243  $pdf->SetTextColor(0,0,0);
1244  }
1245 
1246  $index++;
1247  return ($tab2_top + ($tab2_hl * $index));
1248  }
1249 
1263  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1264  {
1265  global $conf;
1266 
1267  // Force to disable hidetop and hidebottom
1268  $hidebottom=0;
1269  if ($hidetop) $hidetop=-1;
1270 
1271  $currency = !empty($currency) ? $currency : $conf->currency;
1272  $default_font_size = pdf_getPDFFontSize($outputlangs);
1273 
1274  // Amount in (at tab_top - 1)
1275  $pdf->SetTextColor(0,0,0);
1276  $pdf->SetFont('','',$default_font_size - 2);
1277 
1278  if (empty($hidetop))
1279  {
1280  $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1281  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1282  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1283 
1284  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1285  if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1286  }
1287 
1288  $pdf->SetDrawColor(128,128,128);
1289  $pdf->SetFont('','',$default_font_size - 1);
1290 
1291  // Output Rect
1292  $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
1293 
1294  if (empty($hidetop))
1295  {
1296  $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
1297 
1298  $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1299  $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1300  }
1301 
1302  if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
1303  {
1304  $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
1305  if (empty($hidetop))
1306  {
1307  //$pdf->SetXY($this->posxpicture-1, $tab_top+1);
1308  //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
1309  }
1310  }
1311 
1312  if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1313  {
1314  $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1315  if (empty($hidetop))
1316  {
1317  // Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax'
1318  $pdf->SetXY($this->posxtva-3, $tab_top+1);
1319  $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1320  }
1321  }
1322 
1323  $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1324  if (empty($hidetop))
1325  {
1326  $pdf->SetXY($this->posxup-1, $tab_top+1);
1327  $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1328  }
1329 
1330  $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1331  if (empty($hidetop))
1332  {
1333  $pdf->SetXY($this->posxqty-1, $tab_top+1);
1334  if($conf->global->PRODUCT_USE_UNITS)
1335  {
1336  $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1337  }
1338  else
1339  {
1340  $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1341  }
1342  }
1343 
1344  if($conf->global->PRODUCT_USE_UNITS) {
1345  $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1346  if (empty($hidetop)) {
1347  $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1348  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1349  'C');
1350  }
1351  }
1352 
1353  $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1354  if (empty($hidetop))
1355  {
1356  if ($this->atleastonediscount)
1357  {
1358  $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1359  $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1360  }
1361  }
1362  if ($this->atleastonediscount)
1363  {
1364  $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1365  }
1366  if (empty($hidetop))
1367  {
1368  $pdf->SetXY($this->postotalht-1, $tab_top+1);
1369  $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1370  }
1371  }
1372 
1382  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1383  {
1384  global $conf,$langs;
1385 
1386  $outputlangs->load("main");
1387  $outputlangs->load("bills");
1388  $outputlangs->load("propal");
1389  $outputlangs->load("companies");
1390 
1391  $default_font_size = pdf_getPDFFontSize($outputlangs);
1392 
1393  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1394 
1395  // Show Draft Watermark
1396  if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
1397  {
1398  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
1399  }
1400 
1401  $pdf->SetTextColor(0,0,60);
1402  $pdf->SetFont('','B', $default_font_size + 3);
1403 
1404  $posy=$this->marge_haute;
1405  $posx=$this->page_largeur-$this->marge_droite-100;
1406 
1407  $pdf->SetXY($this->marge_gauche,$posy);
1408 
1409  // Logo
1410  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1411  if ($this->emetteur->logo)
1412  {
1413  if (is_readable($logo))
1414  {
1415  $height=pdf_getHeightForLogo($logo);
1416  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1417  }
1418  else
1419  {
1420  $pdf->SetTextColor(200,0,0);
1421  $pdf->SetFont('','B',$default_font_size - 2);
1422  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1423  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1424  }
1425  }
1426  else
1427  {
1428  $text=$this->emetteur->name;
1429  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1430  }
1431 
1432  $pdf->SetFont('','B',$default_font_size + 3);
1433  $pdf->SetXY($posx,$posy);
1434  $pdf->SetTextColor(0,0,60);
1435  $title=$outputlangs->transnoentities("PdfCommercialProposalTitle");
1436  $pdf->MultiCell(100, 4, $title, '', 'R');
1437 
1438  $pdf->SetFont('','B',$default_font_size);
1439 
1440  $posy+=5;
1441  $pdf->SetXY($posx,$posy);
1442  $pdf->SetTextColor(0,0,60);
1443  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1444 
1445  $posy+=1;
1446  $pdf->SetFont('','', $default_font_size - 2);
1447 
1448  if ($object->ref_client)
1449  {
1450  $posy+=4;
1451  $pdf->SetXY($posx,$posy);
1452  $pdf->SetTextColor(0,0,60);
1453  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1454  }
1455 
1456  $posy+=4;
1457  $pdf->SetXY($posx,$posy);
1458  $pdf->SetTextColor(0,0,60);
1459  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1460 
1461  $posy+=4;
1462  $pdf->SetXY($posx,$posy);
1463  $pdf->SetTextColor(0,0,60);
1464  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
1465 
1466  if ($object->thirdparty->code_client)
1467  {
1468  $posy+=4;
1469  $pdf->SetXY($posx,$posy);
1470  $pdf->SetTextColor(0,0,60);
1471  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1472  }
1473 
1474  // Get contact
1475  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1476  {
1477  $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1478  if (count($arrayidcontact) > 0)
1479  {
1480  $usertmp=new User($this->db);
1481  $usertmp->fetch($arrayidcontact[0]);
1482  $posy+=4;
1483  $pdf->SetXY($posx,$posy);
1484  $pdf->SetTextColor(0,0,60);
1485  $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1486  }
1487  }
1488 
1489  $posy+=2;
1490 
1491  // Show list of linked objects
1492  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1493 
1494  if ($showaddress)
1495  {
1496  // Sender properties
1497  $carac_emetteur='';
1498  // Add internal contact of proposal if defined
1499  $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1500  if (count($arrayidcontact) > 0)
1501  {
1502  $object->fetch_user($arrayidcontact[0]);
1503  $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1504  $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1505  }
1506 
1507  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1508 
1509  // Show sender
1510  $posy=42;
1511  $posx=$this->marge_gauche;
1512  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1513  $hautcadre=40;
1514 
1515  // Show sender frame
1516  $pdf->SetTextColor(0,0,0);
1517  $pdf->SetFont('','', $default_font_size - 2);
1518  $pdf->SetXY($posx,$posy-5);
1519  $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1520  $pdf->SetXY($posx,$posy);
1521  $pdf->SetFillColor(230,230,230);
1522  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1523  $pdf->SetTextColor(0,0,60);
1524 
1525  // Show sender name
1526  $pdf->SetXY($posx+2,$posy+3);
1527  $pdf->SetFont('','B', $default_font_size);
1528  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1529  $posy=$pdf->getY();
1530 
1531  // Show sender information
1532  $pdf->SetXY($posx+2,$posy);
1533  $pdf->SetFont('','', $default_font_size - 1);
1534  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1535 
1536 
1537  // If CUSTOMER contact defined, we use it
1538  $usecontact=false;
1539  $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1540  if (count($arrayidcontact) > 0)
1541  {
1542  $usecontact=true;
1543  $result=$object->fetch_contact($arrayidcontact[0]);
1544  }
1545 
1546  //Recipient name
1547  // On peut utiliser le nom de la societe du contact
1548  if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1549  $thirdparty = $object->contact;
1550  } else {
1551  $thirdparty = $object->thirdparty;
1552  }
1553 
1554  $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1555 
1556  $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1557 
1558  // Show recipient
1559  $widthrecbox=100;
1560  if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
1561  $posy=42;
1562  $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1563  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1564 
1565  // Show recipient frame
1566  $pdf->SetTextColor(0,0,0);
1567  $pdf->SetFont('','', $default_font_size - 2);
1568  $pdf->SetXY($posx+2,$posy-5);
1569  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1570  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1571 
1572  // Show recipient name
1573  $pdf->SetXY($posx+2,$posy+3);
1574  $pdf->SetFont('','B', $default_font_size);
1575  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1576 
1577  $posy = $pdf->getY();
1578 
1579  // Show recipient information
1580  $pdf->SetFont('','', $default_font_size - 1);
1581  $pdf->SetXY($posx+2,$posy);
1582  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1583  }
1584 
1585  $pdf->SetTextColor(0,0,0);
1586  }
1587 
1597  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1598  {
1599  global $conf;
1600  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1601  return pdf_pagefoot($pdf,$outputlangs,'PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1602  }
1603 
1613  function _signature_area(&$pdf, $object, $posy, $outputlangs)
1614  {
1615  $default_font_size = pdf_getPDFFontSize($outputlangs);
1616  $tab_top = $posy + 4;
1617  $tab_hl = 4;
1618 
1619  $posx = 120;
1620  $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1621  $useborder=0;
1622  $index = 0;
1623  // Total HT
1624  $pdf->SetFillColor(255,255,255);
1625  $pdf->SetXY($posx, $tab_top + 0);
1626  $pdf->SetFont('','', $default_font_size - 2);
1627  $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
1628 
1629  $pdf->SetXY($posx, $tab_top + $tab_hl);
1630  $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R');
1631 
1632  return ($tab_hl*7);
1633  }
1634 }
1635 
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
Definition: pdf.lib.php:672
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_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:580
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:623
Put here description of your class.
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.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
Return a path to have a the directory according to object where files are stored. ...
Class to generate PDF proposal Azur.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:256
Class to manage products or services.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
Class to manage Dolibarr users.
Definition: user.class.php:39
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
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...
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
Definition: pdf.lib.php:1744
Classe mere des modeles de propale.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
Class to manage bank accounts.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
Definition: pdf.lib.php:1870
Class to manage hooks.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Definition: pdf.lib.php:1472
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
Definition: pdf.lib.php:1607
_signature_area(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
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
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Definition: pdf.lib.php:1531
pdfGetHeightForHtmlContent(&$pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
Definition: pdf.lib.php:300
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
__construct($db)
Constructor.
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition: pdf.lib.php:2115
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
Definition: pdf.lib.php:1786
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:277
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1100
$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).
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition: pdf.lib.php:1139
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...
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
type
Definition: viewcat.php:283
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.