35 require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
70 public $update_main_doc_field;
81 public $version =
'dolibarr';
91 global $langs, $mysoc;
94 $langs->loadLangs(array(
"main",
"bills"));
98 $this->
description = $langs->trans(
'DocModelAzurDescription');
99 $this->update_main_doc_field = 1;
104 $this->page_largeur = $formatarray[
'width'];
105 $this->page_hauteur = $formatarray[
'height'];
106 $this->format = array($this->page_largeur, $this->page_hauteur);
112 $this->option_logo = 1;
113 $this->option_tva = 1;
114 $this->option_modereg = 1;
115 $this->option_condreg = 1;
116 $this->option_multilang = 1;
117 $this->option_escompte = 0;
118 $this->option_credit_note = 0;
119 $this->option_freetext = 1;
120 $this->option_draft_watermark = 1;
121 $this->watermark =
'';
124 $this->emetteur = $mysoc;
125 if (empty($this->emetteur->country_code)) {
126 $this->emetteur->country_code = substr($langs->defaultlang, -2);
130 $this->posxdesc = $this->marge_gauche + 1;
132 $this->posxtva = 101;
134 $this->posxqty = 135;
135 $this->posxunit = 151;
137 $this->posxtva = 106;
139 $this->posxqty = 145;
140 $this->posxunit = 162;
142 $this->posxdiscount = 162;
143 $this->postotalht = 174;
145 $this->posxtva = $this->posxup;
147 $this->posxpicture = $this->posxtva -
getDolGlobalInt(
'MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20);
148 if ($this->page_largeur < 210) {
149 $this->posxpicture -= 20;
150 $this->posxtva -= 20;
152 $this->posxqty -= 20;
153 $this->posxunit -= 20;
154 $this->posxdiscount -= 20;
155 $this->postotalht -= 20;
158 $this->tva = array();
159 $this->tva_array = array();
160 $this->localtax1 = array();
161 $this->localtax2 = array();
162 $this->atleastoneratenotnull = 0;
163 $this->atleastonediscount = 0;
178 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
181 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
183 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
185 if (!is_object($outputlangs)) {
186 $outputlangs = $langs;
190 $outputlangs->charset_output =
'ISO-8859-1';
194 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
196 global $outputlangsbis;
197 $outputlangsbis =
null;
199 $outputlangsbis =
new Translate(
'', $conf);
201 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
209 $nblines = count(
$object->lines);
212 $realpatharray = array();
213 $this->atleastonephoto =
false;
215 $objphoto =
new Product($this->db);
217 for ($i = 0; $i < $nblines; $i++) {
218 if (empty(
$object->lines[$i]->fk_product)) {
222 $objphoto->fetch(
$object->lines[$i]->fk_product);
226 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
227 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
229 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
230 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
235 foreach ($pdir as $midir) {
237 if ($conf->entity != $objphoto->entity) {
238 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
240 $dir = $conf->product->dir_output.
'/'.$midir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
244 if ($obj[
'photo_vignette']) {
245 $filename = $obj[
'photo_vignette'];
247 $filename = $obj[
'photo'];
250 $filename = $obj[
'photo'];
253 $realpath = $dir.$filename;
255 $this->atleastonephoto =
true;
260 if ($realpath && $arephoto) {
261 $realpatharray[$i] = $realpath;
266 if (count($realpatharray) == 0) {
267 $this->posxpicture = $this->posxtva;
270 if ($conf->propal->multidir_output[$conf->entity]) {
277 $dir = $conf->propal->multidir_output[$conf->entity];
278 $file = $dir.
"/SPECIMEN.pdf";
281 $dir = $conf->propal->multidir_output[
$object->entity].
"/".$objectref;
282 $file = $dir.
"/".$objectref.
".pdf";
285 if (!file_exists($dir)) {
287 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
292 if (file_exists($dir)) {
294 if (!is_object($hookmanager)) {
295 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
298 $hookmanager->initHooks(array(
'pdfgeneration'));
299 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
301 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
304 $nblines = count(
$object->lines);
310 $pdf->SetAutoPageBreak(1, 0);
312 if (class_exists(
'TCPDF')) {
313 $pdf->setPrintHeader(
false);
314 $pdf->setPrintFooter(
false);
319 $logodir = $conf->mycompany->dir_output;
320 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
321 $logodir = $conf->mycompany->multidir_output[
$object->entity];
323 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
324 $tplidx = $pdf->importPage(1);
329 $pdf->SetDrawColor(128, 128, 128);
331 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
332 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
333 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
334 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
335 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
337 $pdf->SetCompression(
false);
341 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
344 for ($i = 0; $i < $nblines; $i++) {
345 if (
$object->lines[$i]->remise_percent) {
346 $this->atleastonediscount++;
349 if (empty($this->atleastonediscount)) {
350 $delta = ($this->postotalht - $this->posxdiscount);
351 $this->posxpicture += $delta;
352 $this->posxtva += $delta;
353 $this->posxup += $delta;
354 $this->posxqty += $delta;
355 $this->posxunit += $delta;
356 $this->posxdiscount += $delta;
362 if (!empty($tplidx)) {
363 $pdf->useTemplate($tplidx);
367 $heightforinfotot = 40;
369 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
370 $heightforfooter = $this->marge_basse + 8;
372 $heightforfooter += 6;
376 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
377 $pdf->SetFont(
'',
'', $default_font_size - 1);
378 $pdf->MultiCell(0, 3,
'');
379 $pdf->SetTextColor(0, 0, 0);
382 $tab_top = 90 + $top_shift;
383 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
386 $height_incoterms = 0;
388 $desc_incoterms =
$object->getIncotermsForPDF();
389 if ($desc_incoterms) {
392 $pdf->SetFont(
'',
'', $default_font_size - 1);
393 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
394 $nexY = $pdf->GetY();
395 $height_incoterms = $nexY - $tab_top;
398 $pdf->SetDrawColor(192, 192, 192);
399 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
401 $tab_top = $nexY + 6;
402 $height_incoterms += 4;
407 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
410 if (is_object(
$object->thirdparty)) {
411 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
412 $salerepobj =
new User($this->db);
413 $salerepobj->fetch($salereparray[0][
'id']);
414 if (!empty($salerepobj->signature)) {
415 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
420 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
421 if (!empty($extranote)) {
425 $tmpuser =
new User($this->db);
426 $tmpuser->fetch(
$object->user_author_id);
429 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
430 if ($tmpuser->email) {
431 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
433 if ($tmpuser->office_phone) {
434 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
448 $pdf->SetFont(
'',
'', $default_font_size - 1);
449 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
450 $nexY = $pdf->GetY();
451 $height_note = $nexY - $tab_top;
454 $pdf->SetDrawColor(192, 192, 192);
455 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
457 $tab_top = $nexY + 6;
460 $iniY = $tab_top + 7;
461 $curY = $tab_top + 7;
462 $nexY = $tab_top + 7;
465 for ($i = 0; $i < $nblines; $i++) {
467 $pdf->SetFont(
'',
'', $default_font_size - 1);
468 $pdf->SetTextColor(0, 0, 0);
471 $imglinesize = array();
472 if (!empty($realpatharray[$i])) {
476 $pdf->setTopMargin($tab_top_newpage);
477 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
478 $pageposbefore = $pdf->getPage();
480 $showpricebeforepagebreak = 1;
482 $posYAfterDescription = 0;
485 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
486 $pdf->AddPage(
'',
'',
true);
487 if (!empty($tplidx)) {
488 $pdf->useTemplate($tplidx);
493 $pdf->setPage($pageposbefore + 1);
495 $curY = $tab_top_newpage;
499 $showpricebeforepagebreak = 1;
501 $showpricebeforepagebreak = 0;
505 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
506 $curX = $this->posxpicture - 1;
507 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
509 $posYAfterImage = $curY + $imglinesize[
'height'];
513 $curX = $this->posxdesc - 1;
515 $pdf->startTransaction();
516 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
517 $pageposafter = $pdf->getPage();
518 if ($pageposafter > $pageposbefore) {
519 $pdf->rollbackTransaction(
true);
520 $pageposafter = $pageposbefore;
522 $pdf->setPageOrientation(
'', 1, $heightforfooter);
523 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
525 $pageposafter = $pdf->getPage();
526 $posyafter = $pdf->GetY();
528 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
529 if ($i == ($nblines - 1)) {
530 $pdf->AddPage(
'',
'',
true);
531 if (!empty($tplidx)) {
532 $pdf->useTemplate($tplidx);
537 $pdf->setPage($pageposafter + 1);
544 $showpricebeforepagebreak = 1;
546 $showpricebeforepagebreak = 0;
550 $pdf->commitTransaction();
552 $posYAfterDescription = $pdf->GetY();
554 $nexY = $pdf->GetY();
555 $pageposafter = $pdf->getPage();
557 $pdf->setPage($pageposbefore);
558 $pdf->setTopMargin($this->marge_haute);
559 $pdf->setPageOrientation(
'', 1, 0);
562 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
563 $pdf->setPage($pageposafter);
564 $curY = $tab_top_newpage;
567 $pdf->SetFont(
'',
'', $default_font_size - 1);
572 $pdf->SetXY($this->posxtva - 5, $curY);
573 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
578 $pdf->SetXY($this->posxup, $curY);
579 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
583 $pdf->SetXY($this->posxqty, $curY);
584 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
589 $pdf->SetXY($this->posxunit, $curY);
590 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
594 $pdf->SetXY($this->posxdiscount, $curY);
595 if (
$object->lines[$i]->remise_percent) {
596 $pdf->SetXY($this->posxdiscount - 2, $curY);
598 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
603 $pdf->SetXY($this->postotalht, $curY);
604 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
608 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
610 $tvaligne =
$object->lines[$i]->total_tva;
613 $localtax1ligne =
$object->lines[$i]->total_localtax1;
614 $localtax2ligne =
$object->lines[$i]->total_localtax2;
615 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
616 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
617 $localtax1_type =
$object->lines[$i]->localtax1_type;
618 $localtax2_type =
$object->lines[$i]->localtax2_type;
631 $vatrate = (string)
$object->lines[$i]->tva_tx;
634 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
635 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
637 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
638 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
642 if ($localtax1_type && $localtax1ligne != 0) {
643 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
644 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
646 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
649 if ($localtax2_type && $localtax2ligne != 0) {
650 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
651 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
653 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
657 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
662 if (!isset($this->tva[$vatrate])) {
663 $this->tva[$vatrate] = 0;
665 $this->tva[$vatrate] += $tvaligne;
666 $vatcode =
$object->lines[$i]->vat_src_code;
667 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
668 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
670 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
672 if ($posYAfterImage > $posYAfterDescription) {
673 $nexY = $posYAfterImage;
678 $pdf->setPage($pageposafter);
679 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
681 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
682 $pdf->SetLineStyle(array(
'dash' => 0));
688 while ($pagenb < $pageposafter) {
689 $pdf->setPage($pagenb);
691 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
693 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
697 $pdf->setPage($pagenb);
698 $pdf->setPageOrientation(
'', 1, 0);
702 if (!empty($tplidx)) {
703 $pdf->useTemplate($tplidx);
706 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
708 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
710 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
715 if (!empty($tplidx)) {
716 $pdf->useTemplate($tplidx);
727 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
728 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
730 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
731 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
755 if (method_exists($pdf,
'AliasNbPages')) {
756 $pdf->AliasNbPages();
761 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
763 $already_merged = array();
764 foreach (
$object->lines as $line) {
765 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
770 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
772 $filetomerge->fetch_by_product($line->fk_product);
775 $already_merged[] = $line->fk_product;
777 $product =
new Product($this->db);
778 $product->fetch($line->fk_product);
780 if ($product->entity != $conf->entity) {
781 $entity_product_file = $product->entity;
783 $entity_product_file = $conf->entity;
787 if (count($filetomerge->lines) > 0) {
788 foreach ($filetomerge->lines as $linefile) {
789 if (!empty($linefile->id) && !empty($linefile->file_name)) {
792 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
794 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
798 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
800 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
804 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
806 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
807 if (file_exists($infile) && is_readable($infile)) {
808 $pagecount = $pdf->setSourceFile($infile);
809 for ($i = 1; $i <= $pagecount; $i++) {
810 $tplIdx = $pdf->importPage($i);
811 if ($tplIdx !==
false) {
812 $s = $pdf->getTemplatesize($tplIdx);
813 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
814 $pdf->useTemplate($tplIdx);
816 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
829 $pdf->Output($file,
'F');
832 $hookmanager->initHooks(array(
'pdfgeneration'));
833 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
835 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
837 $this->error = $hookmanager->error;
838 $this->errors = $hookmanager->errors;
843 $this->result = array(
'fullpath' => $file);
847 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
851 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
887 global $conf, $mysoc;
890 $pdf->SetFont(
'',
'', $default_font_size - 1);
892 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
895 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
896 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
897 $pdf->SetXY($this->marge_gauche, $posy);
898 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
900 $posy = $pdf->GetY() + 4;
905 $displaydate =
"daytext";
907 $displaydate =
"day";
911 if (!empty(
$object->delivery_date)) {
912 $outputlangs->load(
"sendings");
913 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
914 $pdf->SetXY($this->marge_gauche, $posy);
915 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
916 $pdf->MultiCell(80, 4, $titre, 0,
'L');
917 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
918 $pdf->SetXY($posxval, $posy);
920 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
922 $posy = $pdf->GetY() + 1;
924 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
925 $pdf->SetXY($this->marge_gauche, $posy);
926 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
927 $pdf->MultiCell(80, 4, $titre, 0,
'L');
928 $pdf->SetTextColor(0, 0, 0);
929 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
930 $pdf->SetXY($posxval, $posy);
931 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
932 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
933 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
935 $posy = $pdf->GetY() + 1;
940 $outputlangs->load(
"sendings");
942 $shipping_method_id =
$object->shipping_method_id;
943 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
944 $shipping_method_id = $this->emetteur->shipping_method_id;
946 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
947 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
949 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
950 $pdf->SetXY($this->marge_gauche, $posy);
951 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
952 $pdf->MultiCell(43, 4, $titre, 0,
'L');
954 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
955 $pdf->SetXY($posxval, $posy);
956 $lib_condition_paiement = ($outputlangs->transnoentities(
"SendingMethod".strtoupper($shipping_method_code)) !=
"SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans(
"SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label;
957 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
958 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
960 $posy = $pdf->GetY() + 1;
965 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
966 $pdf->SetXY($this->marge_gauche, $posy);
967 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
968 $pdf->MultiCell(43, 4, $titre, 0,
'L');
970 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
971 $pdf->SetXY($posxval, $posy);
972 $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 ?
$object->cond_reglement_doc :
$object->cond_reglement_label);
973 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
974 if (
$object->deposit_percent > 0) {
975 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
977 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
979 $posy = $pdf->GetY() + 3;
984 if (
$object->mode_reglement_code
985 &&
$object->mode_reglement_code !=
'CHQ'
986 &&
$object->mode_reglement_code !=
'VIR') {
987 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
988 $pdf->SetXY($this->marge_gauche, $posy);
989 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
990 $pdf->MultiCell(80, 5, $titre, 0,
'L');
991 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
992 $pdf->SetXY($posxval, $posy);
993 $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);
994 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
996 $posy = $pdf->GetY() + 2;
1000 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1004 $account =
new Account($this->db);
1007 $pdf->SetXY($this->marge_gauche, $posy);
1008 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1009 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1010 $posy = $pdf->GetY() + 1;
1013 $pdf->SetXY($this->marge_gauche, $posy);
1014 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1015 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1016 $posy = $pdf->GetY() + 2;
1019 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1020 $pdf->SetXY($this->marge_gauche, $posy);
1021 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1022 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1023 $posy = $pdf->GetY() + 1;
1026 $pdf->SetXY($this->marge_gauche, $posy);
1027 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1028 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1029 $posy = $pdf->GetY() + 2;
1036 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1038 $bankid = (empty(
$object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1039 if (!empty(
$object->fk_bank)) {
1042 $account =
new Account($this->db);
1043 $account->fetch($bankid);
1045 $curx = $this->marge_gauche;
1048 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1074 global $conf, $mysoc;
1079 $pdf->SetFont(
'',
'', $default_font_size - 1);
1084 if ($this->page_largeur < 210) {
1087 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1093 $pdf->SetFillColor(255, 255, 255);
1094 $pdf->SetXY($col1x, $tab2_top);
1095 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1098 $pdf->SetXY($col2x, $tab2_top);
1099 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1102 $pdf->SetFillColor(248, 248, 248);
1106 $this->atleastoneratenotnull = 0;
1108 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1109 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1115 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1116 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1120 foreach ($localtax_rate as $tvakey => $tvaval) {
1125 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1128 if (preg_match(
'/\*/', $tvakey)) {
1129 $tvakey = str_replace(
'*',
'', $tvakey);
1130 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1132 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1133 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1134 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1138 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1139 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1147 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1148 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1152 foreach ($localtax_rate as $tvakey => $tvaval) {
1157 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160 if (preg_match(
'/\*/', $tvakey)) {
1161 $tvakey = str_replace(
'*',
'', $tvakey);
1162 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1164 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1165 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1166 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1170 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1171 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1178 foreach ($this->tva_array as $tvakey => $tvaval) {
1180 $this->atleastoneratenotnull++;
1183 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1186 if (preg_match(
'/\*/', $tvakey)) {
1187 $tvakey = str_replace(
'*',
'', $tvakey);
1188 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1190 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1193 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1195 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1197 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1199 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1201 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1202 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1209 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1210 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1214 foreach ($localtax_rate as $tvakey => $tvaval) {
1219 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1222 if (preg_match(
'/\*/', $tvakey)) {
1223 $tvakey = str_replace(
'*',
'', $tvakey);
1224 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1226 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1228 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1229 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1233 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1234 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1242 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1243 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1247 foreach ($localtax_rate as $tvakey => $tvaval) {
1253 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1256 if (preg_match(
'/\*/', $tvakey)) {
1257 $tvakey = str_replace(
'*',
'', $tvakey);
1258 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1260 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1262 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1263 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1267 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1268 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1276 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1277 $pdf->SetTextColor(0, 0, 60);
1278 $pdf->SetFillColor(224, 224, 224);
1279 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1281 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1282 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1286 $pdf->SetTextColor(0, 0, 0);
1294 if ($deja_regle > 0) {
1297 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1298 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1300 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1301 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1319 $pdf->SetTextColor(0, 0, 60);
1320 $pdf->SetFillColor(224, 224, 224);
1321 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1322 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1324 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1325 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1327 $pdf->SetFont(
'',
'', $default_font_size - 1);
1328 $pdf->SetTextColor(0, 0, 0);
1332 return ($tab2_top + ($tab2_hl * $index));
1349 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1359 $currency = !empty($currency) ? $currency : $conf->currency;
1363 $pdf->SetTextColor(0, 0, 0);
1364 $pdf->SetFont(
'',
'', $default_font_size - 2);
1366 if (empty($hidetop)) {
1367 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1368 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1369 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1373 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1377 $pdf->SetDrawColor(128, 128, 128);
1378 $pdf->SetFont(
'',
'', $default_font_size - 1);
1381 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1383 if (empty($hidetop)) {
1384 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1386 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1387 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1391 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1392 if (empty($hidetop)) {
1399 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1400 if (empty($hidetop)) {
1402 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1403 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1407 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1408 if (empty($hidetop)) {
1409 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1410 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1413 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1414 if (empty($hidetop)) {
1415 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1416 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1420 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1421 if (empty($hidetop)) {
1422 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1424 $this->posxdiscount - $this->posxunit - 1,
1426 $outputlangs->transnoentities(
"Unit"),
1433 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1434 if (empty($hidetop)) {
1435 if ($this->atleastonediscount) {
1436 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1437 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1440 if ($this->atleastonediscount) {
1441 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1443 if (empty($hidetop)) {
1444 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1445 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1460 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1462 global $conf, $langs;
1464 $ltrdirection =
'L';
1465 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1466 $ltrdirection =
'R';
1470 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1476 $pdf->SetTextColor(0, 0, 60);
1477 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1481 $posy = $this->marge_haute;
1482 $posx = $this->page_largeur - $this->marge_droite - $w;
1484 $pdf->SetXY($this->marge_gauche, $posy);
1488 if ($this->emetteur->logo) {
1489 $logodir = $conf->mycompany->dir_output;
1490 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1491 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1494 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1496 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1498 if (is_readable($logo)) {
1500 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1502 $pdf->SetTextColor(200, 0, 0);
1503 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1504 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1505 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1508 $text = $this->emetteur->name;
1509 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1513 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1514 $pdf->SetXY($posx, $posy);
1515 $pdf->SetTextColor(0, 0, 60);
1516 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1517 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1518 if (
$object->statut == $object::STATUS_DRAFT) {
1519 $pdf->SetTextColor(128, 0, 0);
1520 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1522 $pdf->MultiCell(100, 4, $title,
'',
'R');
1524 $pdf->SetFont(
'',
'B', $default_font_size);
1534 $pdf->SetFont(
'',
'', $default_font_size - 2);
1538 $pdf->SetXY($posx, $posy);
1539 $pdf->SetTextColor(0, 0, 60);
1540 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1545 if (!empty(
$object->project->ref)) {
1547 $pdf->SetXY($posx, $posy);
1548 $pdf->SetTextColor(0, 0, 60);
1549 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1555 if (!empty(
$object->project->ref)) {
1556 $outputlangs->load(
"projects");
1558 $pdf->SetXY($posx, $posy);
1559 $pdf->SetTextColor(0, 0, 60);
1560 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1565 $displaydate =
"daytext";
1567 $displaydate =
"day";
1571 $posy = $pdf->getY();
1572 $pdf->SetXY($posx, $posy);
1573 $pdf->SetTextColor(0, 0, 60);
1574 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1577 $pdf->SetXY($posx, $posy);
1578 $pdf->SetTextColor(0, 0, 60);
1579 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1583 $pdf->SetXY($posx, $posy);
1584 $pdf->SetTextColor(0, 0, 60);
1585 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1590 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1591 if (count($arrayidcontact) > 0) {
1592 $usertmp =
new User($this->db);
1593 $usertmp->fetch($arrayidcontact[0]);
1595 $pdf->SetXY($posx, $posy);
1596 $pdf->SetTextColor(0, 0, 60);
1597 $pdf->MultiCell(100, 3, $langs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1605 $current_y = $pdf->getY();
1607 if ($current_y < $pdf->getY()) {
1608 $top_shift = $pdf->getY() - $current_y;
1613 $carac_emetteur =
'';
1615 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1616 if (count($arrayidcontact) > 0) {
1617 $object->fetch_user($arrayidcontact[0]);
1618 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1619 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1621 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1625 $carac_emetteur .=
"\n";
1631 $posy = 42 + $top_shift;
1632 $posx = $this->marge_gauche;
1634 $posx = $this->page_largeur - $this->marge_droite - 80;
1640 $pdf->SetTextColor(0, 0, 0);
1641 $pdf->SetFont(
'',
'', $default_font_size - 2);
1642 $pdf->SetXY($posx, $posy - 5);
1643 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1644 $pdf->SetXY($posx, $posy);
1645 $pdf->SetFillColor(230, 230, 230);
1646 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1647 $pdf->SetTextColor(0, 0, 60);
1652 $pdf->SetXY($posx + 2, $posy + 3);
1653 $pdf->SetFont(
'',
'B', $default_font_size);
1654 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1655 $posy = $pdf->getY();
1659 $pdf->SetXY($posx + 2, $posy);
1660 $pdf->SetFont(
'',
'', $default_font_size - 1);
1661 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1665 $usecontact =
false;
1666 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1667 if (count($arrayidcontact) > 0) {
1669 $result =
$object->fetch_contact($arrayidcontact[0]);
1673 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1674 $thirdparty =
$object->contact;
1676 $thirdparty =
$object->thirdparty;
1686 if ($this->page_largeur < 210) {
1689 $posy = 42 + $top_shift;
1690 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1692 $posx = $this->marge_gauche;
1697 $pdf->SetTextColor(0, 0, 0);
1698 $pdf->SetFont(
'',
'', $default_font_size - 2);
1699 $pdf->SetXY($posx + 2, $posy - 5);
1700 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1701 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1705 $pdf->SetXY($posx + 2, $posy + 3);
1706 $pdf->SetFont(
'',
'B', $default_font_size);
1708 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1710 $posy = $pdf->getY();
1713 $pdf->SetFont(
'',
'', $default_font_size - 1);
1714 $pdf->SetXY($posx + 2, $posy);
1716 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1719 $pdf->SetTextColor(0, 0, 0);
1736 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1737 return pdf_pagefoot($pdf, $outputlangs,
'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur,
$object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1755 $tab_top = $posy + 4;
1759 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1762 $pdf->SetFillColor(255, 255, 255);
1763 $pdf->SetXY($posx, $tab_top);
1764 $pdf->SetFont(
'',
'', $default_font_size - 2);
1765 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities(
"ProposalCustomerSignature"), 0,
'L', 1);
1767 $pdf->SetXY($posx, $tab_top + $tab_hl);
1768 $pdf->MultiCell($largcol, $tab_hl * 3,
'', 1,
'R');
1772 $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1775 return ($tab_hl * 7);
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage bank accounts.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class mere des modeles de propale.
Class to manage products or services.
Put here description of your class.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate PDF proposal Azur.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
__construct($db)
Constructor.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
_signature_area(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0, $align='J')
Output line description into PDF.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
pdfGetHeightForHtmlContent(&$pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.