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