151 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
154 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
156 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
158 if (!is_object($outputlangs)) {
159 $outputlangs = $langs;
163 $outputlangs->charset_output =
'ISO-8859-1';
167 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
169 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
170 global $outputlangsbis;
171 $outputlangsbis =
new Translate(
'', $conf);
172 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
173 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
176 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
180 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
184 $realpatharray = array();
185 $this->atleastonephoto =
false;
239 if ($conf->asset->dir_output.
'/asset') {
240 $object->fetch_thirdparty();
243 if ($object->specimen) {
244 $dir = $conf->asset->dir_output.
'/asset';
245 $file = $dir.
"/SPECIMEN.pdf";
248 $dir = $conf->asset->dir_output.
'/asset/'.$objectref;
249 $file = $dir.
"/".$objectref.
".pdf";
251 if (!file_exists($dir)) {
253 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
258 if (file_exists($dir)) {
260 if (!is_object($hookmanager)) {
261 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
264 $hookmanager->initHooks(array(
'pdfgeneration'));
265 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
267 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
270 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
275 $pdf->SetAutoPageBreak(1, 0);
277 $heightforinfotot = 50;
278 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
279 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
281 if (class_exists(
'TCPDF')) {
282 $pdf->setPrintHeader(
false);
283 $pdf->setPrintFooter(
false);
289 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
290 $tplidx = $pdf->importPage(1);
295 $pdf->SetDrawColor(128, 128, 128);
297 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
298 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
299 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
300 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
301 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
303 $pdf->SetCompression(
false);
307 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
315 'Name' => $this->emetteur->name,
316 'Location' =>
getCountry($this->emetteur->country_code, 0),
318 'ContactInfo' => $this->emetteur->email
320 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
323 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
327 if (!empty($tplidx)) {
328 $pdf->useTemplate($tplidx);
332 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
333 $pdf->SetFont(
'',
'', $default_font_size - 1);
334 $pdf->MultiCell(0, 3,
'');
335 $pdf->SetTextColor(0, 0, 0);
337 $tab_top = 90 + $top_shift;
338 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
339 $tab_height = 130 - $top_shift;
340 $tab_height_newpage = 150;
342 $tab_height_newpage -= $top_shift;
345 $nexY = $tab_top - 1;
348 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
350 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
351 if (!empty($extranote)) {
355 $pagenb = $pdf->getPage();
359 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
360 $pageposbeforenote = $pagenb;
367 $pdf->startTransaction();
369 $pdf->SetFont(
'',
'', $default_font_size - 1);
370 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
372 $pageposafternote = $pdf->getPage();
373 $posyafter = $pdf->GetY();
375 if ($pageposafternote > $pageposbeforenote) {
376 $pdf->rollbackTransaction(
true);
379 while ($pagenb < $pageposafternote) {
382 if (!empty($tplidx)) {
383 $pdf->useTemplate($tplidx);
386 $this->
_pagehead($pdf, $object, 0, $outputlangs);
389 $pdf->setTopMargin($tab_top_newpage);
391 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
395 $pdf->setPage($pageposbeforenote);
396 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
397 $pdf->SetFont(
'',
'', $default_font_size - 1);
398 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
399 $pageposafternote = $pdf->getPage();
401 $posyafter = $pdf->GetY();
403 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
404 $pdf->AddPage(
'',
'',
true);
407 $pdf->setPage($pageposafternote);
408 $pdf->setTopMargin($tab_top_newpage);
410 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
416 $i = $pageposbeforenote;
417 while ($i < $pageposafternote) {
421 $pdf->SetDrawColor(128, 128, 128);
423 if ($i > $pageposbeforenote) {
424 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
425 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
427 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
428 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
432 $pdf->setPageOrientation(
'', 1, 0);
433 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
439 $pdf->setPage($pageposafternote);
440 if (!empty($tplidx)) {
441 $pdf->useTemplate($tplidx);
444 $this->
_pagehead($pdf, $object, 0, $outputlangs);
446 $height_note = $posyafter - $tab_top_newpage;
447 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
449 $pdf->commitTransaction();
450 $posyafter = $pdf->GetY();
451 $height_note = $posyafter - $tab_top;
452 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
455 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
457 $pdf->AddPage(
'',
'',
true);
460 $pdf->setPage($pageposafternote);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
465 $this->
_pagehead($pdf, $object, 0, $outputlangs);
468 $posyafter = $tab_top_newpage;
472 $tab_height = $tab_height - $height_note;
473 $tab_top = $posyafter + 6;
482 $pdf->startTransaction();
483 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
484 $pdf->rollbackTransaction(
true);
486 $nexY = $tab_top + $this->tabTitleHeight;
489 $pageposbeforeprintlines = $pdf->getPage();
490 $pagenb = $pageposbeforeprintlines;
491 for ($i = 0; $i < $nblines; $i++) {
493 $pdf->SetFont(
'',
'', $default_font_size - 1);
494 $pdf->SetTextColor(0, 0, 0);
497 $imglinesize = array();
498 if (!empty($realpatharray[$i])) {
502 $pdf->setTopMargin($tab_top_newpage);
503 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
504 $pageposbefore = $pdf->getPage();
506 $showpricebeforepagebreak = 1;
511 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
512 $pdf->AddPage(
'',
'',
true);
513 if (!empty($tplidx)) {
514 $pdf->useTemplate($tplidx);
516 $pdf->setPage($pageposbefore + 1);
518 $curY = $tab_top_newpage;
522 $showpricebeforepagebreak = 1;
524 $showpricebeforepagebreak = 0;
528 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
529 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
531 $posYAfterImage = $curY + $imglinesize[
'height'];
537 $pdf->startTransaction();
539 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
540 $pageposafter = $pdf->getPage();
542 if ($pageposafter > $pageposbefore) {
543 $pdf->rollbackTransaction(
true);
544 $pdf->setPageOrientation(
'', 1, $heightforfooter);
546 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
548 $pageposafter = $pdf->getPage();
549 $posyafter = $pdf->GetY();
551 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
552 if ($i == ($nblines - 1)) {
553 $pdf->AddPage(
'',
'',
true);
554 if (!empty($tplidx)) {
555 $pdf->useTemplate($tplidx);
557 $pdf->setPage($pageposafter + 1);
563 $showpricebeforepagebreak = 1;
565 $showpricebeforepagebreak = 0;
569 $pdf->commitTransaction();
573 $nexY = $pdf->GetY();
574 $pageposafter = $pdf->getPage();
575 $pdf->setPage($pageposbefore);
576 $pdf->setTopMargin($this->marge_haute);
577 $pdf->setPageOrientation(
'', 1, 0);
580 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
581 $pdf->setPage($pageposafter);
582 $curY = $tab_top_newpage;
585 $pdf->SetFont(
'',
'', $default_font_size - 1);
592 $nexY = max($pdf->GetY(), $nexY);
596 if (!empty($object->lines[$i]->array_options)) {
597 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
599 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
601 $nexY = max($pdf->GetY(), $nexY);
613 'outputlangs' => $outputlangs,
614 'hidedetails' => $hidedetails
616 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
621 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
622 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
623 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
624 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
626 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
629 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
630 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
632 $tvaligne = $sign * $object->lines[$i]->total_tva;
636 $localtax1ligne = $object->lines[$i]->total_localtax1;
637 $localtax2ligne = $object->lines[$i]->total_localtax2;
638 $localtax1_rate = $object->lines[$i]->localtax1_tx;
639 $localtax2_rate = $object->lines[$i]->localtax2_tx;
640 $localtax1_type = $object->lines[$i]->localtax1_type;
641 $localtax2_type = $object->lines[$i]->localtax2_type;
654 $vatrate = (string) $object->lines[$i]->tva_tx;
657 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
658 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
660 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
661 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
665 if ($localtax1_type && $localtax1ligne != 0) {
666 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
667 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
669 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
672 if ($localtax2_type && $localtax2ligne != 0) {
673 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
674 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
676 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
680 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
683 if (!isset($this->tva[$vatrate])) {
684 $this->tva[$vatrate] = 0;
686 $this->tva[$vatrate] += $tvaligne;
688 $nexY = max($nexY, $posYAfterImage);
692 $pdf->setPage($pageposafter);
693 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
695 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
696 $pdf->SetLineStyle(array(
'dash'=>0));
700 while ($pagenb < $pageposafter) {
701 $pdf->setPage($pagenb);
702 if ($pagenb == $pageposbeforeprintlines) {
703 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
705 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
707 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
709 $pdf->setPage($pagenb);
710 $pdf->setPageOrientation(
'', 1, 0);
712 $this->
_pagehead($pdf, $object, 0, $outputlangs);
716 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
717 if ($pagenb == $pageposafter) {
718 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
720 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
722 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
725 if (!empty($tplidx)) {
726 $pdf->useTemplate($tplidx);
730 $this->
_pagehead($pdf, $object, 0, $outputlangs);
736 if ($pagenb == $pageposbeforeprintlines) {
737 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
738 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
740 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
741 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
759 $this->
_pagefoot($pdf, $object, $outputlangs);
760 if (method_exists($pdf,
'AliasNbPages')) {
761 $pdf->AliasNbPages();
766 $pdf->Output($file,
'F');
769 $hookmanager->initHooks(array(
'pdfgeneration'));
770 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
772 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
774 $this->error = $hookmanager->error;
775 $this->errors = $hookmanager->errors;
780 $this->result = array(
'fullpath'=>$file);
784 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
788 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
879 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
881 global $conf, $langs;
884 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
891 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'FACTURE_DRAFT_WATERMARK'))) {
892 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
895 $pdf->SetTextColor(0, 0, 60);
896 $pdf->SetFont(
'',
'B', $default_font_size + 3);
900 $posy = $this->marge_haute;
901 $posx = $this->page_largeur - $this->marge_droite - $w;
903 $pdf->SetXY($this->marge_gauche, $posy);
907 if ($this->emetteur->logo) {
908 $logodir = $conf->mycompany->dir_output;
909 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
910 $logodir = $conf->mycompany->multidir_output[$object->entity];
913 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
915 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
917 if (is_readable($logo)) {
919 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
921 $pdf->SetTextColor(200, 0, 0);
922 $pdf->SetFont(
'',
'B', $default_font_size - 2);
923 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
924 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
927 $text = $this->emetteur->name;
928 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
932 $pdf->SetFont(
'',
'B', $default_font_size + 3);
933 $pdf->SetXY($posx, $posy);
934 $pdf->SetTextColor(0, 0, 60);
935 $title = $outputlangs->transnoentities(
"PdfTitle");
938 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
940 $pdf->MultiCell($w, 3, $title,
'',
'R');
942 $pdf->SetFont(
'',
'B', $default_font_size);
945 $pdf->SetXY($posx, $posy);
946 $pdf->SetTextColor(0, 0, 60);
947 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
948 if ($object->statut == $object::STATUS_DRAFT) {
949 $pdf->SetTextColor(128, 0, 0);
950 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
952 $pdf->MultiCell($w, 4, $textref,
'',
'R');
955 $pdf->SetFont(
'',
'', $default_font_size - 2);
957 if ($object->ref_client) {
959 $pdf->SetXY($posx, $posy);
960 $pdf->SetTextColor(0, 0, 60);
961 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
965 $object->fetch_projet();
966 if (!empty($object->project->ref)) {
968 $pdf->SetXY($posx, $posy);
969 $pdf->SetTextColor(0, 0, 60);
970 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
975 $object->fetch_projet();
976 if (!empty($object->project->ref)) {
977 $outputlangs->load(
"projects");
979 $pdf->SetXY($posx, $posy);
980 $pdf->SetTextColor(0, 0, 60);
981 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
986 $pdf->SetXY($posx, $posy);
987 $pdf->SetTextColor(0, 0, 60);
989 $title = $outputlangs->transnoentities(
"Date");
991 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
993 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs),
'',
'R');
995 if ($object->thirdparty->code_client) {
997 $pdf->SetXY($posx, $posy);
998 $pdf->SetTextColor(0, 0, 60);
999 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1004 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1005 if (count($arrayidcontact) > 0) {
1006 $usertmp =
new User($this->db);
1007 $usertmp->fetch($arrayidcontact[0]);
1009 $pdf->SetXY($posx, $posy);
1010 $pdf->SetTextColor(0, 0, 60);
1011 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1019 $current_y = $pdf->getY();
1020 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1021 if ($current_y < $pdf->getY()) {
1022 $top_shift = $pdf->getY() - $current_y;
1027 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1031 $posy += $top_shift;
1032 $posx = $this->marge_gauche;
1034 $posx = $this->page_largeur - $this->marge_droite - 80;
1042 $pdf->SetTextColor(0, 0, 0);
1043 $pdf->SetFont(
'',
'', $default_font_size - 2);
1044 $pdf->SetXY($posx, $posy - 5);
1045 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1046 $pdf->SetXY($posx, $posy);
1047 $pdf->SetFillColor(230, 230, 230);
1048 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1049 $pdf->SetTextColor(0, 0, 60);
1052 $pdf->SetXY($posx + 2, $posy + 3);
1053 $pdf->SetFont(
'',
'B', $default_font_size);
1054 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1055 $posy = $pdf->getY();
1058 $pdf->SetXY($posx + 2, $posy);
1059 $pdf->SetFont(
'',
'', $default_font_size - 1);
1060 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1063 $usecontact =
false;
1064 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
1065 if (count($arrayidcontact) > 0) {
1067 $result = $object->fetch_contact($arrayidcontact[0]);
1071 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
1072 $thirdparty = $object->contact;
1074 $thirdparty = $object->thirdparty;
1077 if (is_object($thirdparty)) {
1081 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1085 if ($this->page_largeur < 210) {
1089 $posy += $top_shift;
1090 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1092 $posx = $this->marge_gauche;
1096 $pdf->SetTextColor(0, 0, 0);
1097 $pdf->SetFont(
'',
'', $default_font_size - 2);
1098 $pdf->SetXY($posx + 2, $posy - 5);
1099 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1100 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1103 $pdf->SetXY($posx + 2, $posy + 3);
1104 $pdf->SetFont(
'',
'B', $default_font_size);
1105 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1107 $posy = $pdf->getY();
1110 $pdf->SetFont(
'',
'', $default_font_size - 1);
1111 $pdf->SetXY($posx + 2, $posy);
1112 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1115 $pdf->SetTextColor(0, 0, 0);