170 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
173 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
175 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
177 if (!is_object($outputlangs)) {
178 $outputlangs = $langs;
182 $outputlangs->charset_output =
'ISO-8859-1';
186 $langfiles = array(
"main",
"bills",
"products",
"dict",
"companies",
"compta");
187 $outputlangs->loadLangs($langfiles);
194 global $outputlangsbis;
195 $outputlangsbis =
null;
197 $outputlangsbis =
new Translate(
'', $conf);
199 $outputlangsbis->loadLangs($langfiles);
202 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
210 $realpatharray = array();
211 $this->atleastonephoto =
false;
274 $file = $dir.
"/SPECIMEN.pdf";
278 $file = $dir.
"/".$objectref.
".pdf";
283 if (!file_exists($dir)) {
285 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
290 if (file_exists($dir)) {
292 if (!is_object($hookmanager)) {
293 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
296 $hookmanager->initHooks(array(
'pdfgeneration'));
297 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
299 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
302 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
306 '@phan-var-force TCPDI|TCPDF $pdf';
308 $pdf->SetAutoPageBreak(1, 0);
310 $heightforinfotot = 50;
312 $heightforfooter = $this->marge_basse + (
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
314 if (class_exists(
'TCPDF')) {
315 $pdf->setPrintHeader(
false);
316 $pdf->setPrintFooter(
false);
322 $logodir = $conf->mycompany->dir_output;
323 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
324 $logodir = $conf->mycompany->multidir_output[
$object->entity];
326 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
327 $tplidx = $pdf->importPage(1);
332 $pdf->SetDrawColor(128, 128, 128);
334 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
335 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
336 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
337 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
338 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
340 $pdf->SetCompression(
false);
344 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
352 'Name' => $this->emetteur->name,
353 'Location' =>
getCountry($this->emetteur->country_code,
''),
354 'Reason' =>
'MYOBJECT',
355 'ContactInfo' => $this->emetteur->email
357 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
361 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
366 if (!empty($tplidx)) {
367 $pdf->useTemplate($tplidx);
371 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
372 $pdf->SetFont(
'',
'', $default_font_size - 1);
373 $pdf->MultiCell(0, 3,
'');
374 $pdf->SetTextColor(0, 0, 0);
376 $tab_top = 90 + $top_shift;
377 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
379 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
381 $tab_height_newpage = 150;
383 $tab_height_newpage -= $top_shift;
386 $nexY = $tab_top - 1;
389 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
391 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
392 if (!empty($extranote)) {
396 $pagenb = $pdf->getPage();
400 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
401 $pageposbeforenote = $pagenb;
408 $pdf->startTransaction();
410 $pdf->SetFont(
'',
'', $default_font_size - 1);
411 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
413 $pageposafternote = $pdf->getPage();
414 $posyafter = $pdf->GetY();
416 if ($pageposafternote > $pageposbeforenote) {
417 $pdf->rollbackTransaction(
true);
420 while ($pagenb < $pageposafternote) {
423 if (!empty($tplidx)) {
424 $pdf->useTemplate($tplidx);
430 $pdf->setTopMargin($tab_top_newpage);
432 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
436 $pdf->setPage($pageposbeforenote);
437 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
438 $pdf->SetFont(
'',
'', $default_font_size - 1);
439 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
440 $pageposafternote = $pdf->getPage();
442 $posyafter = $pdf->GetY();
444 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
445 $pdf->AddPage(
'',
'',
true);
448 $pdf->setPage($pageposafternote);
449 $pdf->setTopMargin($tab_top_newpage);
451 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
457 $i = $pageposbeforenote;
458 while ($i < $pageposafternote) {
462 $pdf->SetDrawColor(128, 128, 128);
464 if ($i > $pageposbeforenote) {
465 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
466 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
468 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
469 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
473 $pdf->setPageOrientation(
'', 1, 0);
480 $pdf->setPage($pageposafternote);
481 if (!empty($tplidx)) {
482 $pdf->useTemplate($tplidx);
487 $height_note = $posyafter - $tab_top_newpage;
488 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
491 $pdf->commitTransaction();
492 $posyafter = $pdf->GetY();
493 $height_note = $posyafter - $tab_top;
494 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
497 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
499 $pdf->AddPage(
'',
'',
true);
502 $pdf->setPage($pageposafternote);
503 if (!empty($tplidx)) {
504 $pdf->useTemplate($tplidx);
510 $posyafter = $tab_top_newpage;
514 $tab_height -= $height_note;
515 $tab_top = $posyafter + 6;
524 $pdf->startTransaction();
525 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
526 $pdf->rollbackTransaction(
true);
528 $nexY = $tab_top + $this->tabTitleHeight;
531 $pageposbeforeprintlines = $pdf->getPage();
532 $pagenb = $pageposbeforeprintlines;
533 for ($i = 0; $i < $nblines; $i++) {
535 $pdf->SetFont(
'',
'', $default_font_size - 1);
536 $pdf->SetTextColor(0, 0, 0);
544 $pdf->setTopMargin($tab_top_newpage);
545 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
546 $pageposbefore = $pdf->getPage();
548 $showpricebeforepagebreak = 1;
550 $posYAfterDescription = 0;
580 $pdf->startTransaction();
583 $pageposafter = $pdf->getPage();
585 if ($pageposafter > $pageposbefore) {
586 $pdf->rollbackTransaction(
true);
587 $pageposafter = $pageposbefore;
588 $pdf->setPageOrientation(
'', 1, $heightforfooter);
592 $pageposafter = $pdf->getPage();
593 $posyafter = $pdf->GetY();
595 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
596 if ($i == ($nblines - 1)) {
597 $pdf->AddPage(
'',
'',
true);
598 if (!empty($tplidx)) {
599 $pdf->useTemplate($tplidx);
601 $pdf->setPage($pageposafter + 1);
607 $showpricebeforepagebreak = 1;
609 $showpricebeforepagebreak = 0;
613 $pdf->commitTransaction();
615 $posYAfterDescription = $pdf->GetY();
618 $nexY = max($pdf->GetY(), $posYAfterImage);
621 $pageposafter = $pdf->getPage();
622 $pdf->setPage($pageposbefore);
623 $pdf->setTopMargin($this->marge_haute);
624 $pdf->setPageOrientation(
'', 1, 0);
627 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
628 $pdf->setPage($pageposafter);
629 $curY = $tab_top_newpage;
632 $pdf->SetFont(
'',
'', $default_font_size - 1);
639 $nexY = max($pdf->GetY(), $nexY);
643 if (!empty(
$object->lines[$i]->array_options)) {
644 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
648 $nexY = max($pdf->GetY(), $nexY);
660 'outputlangs' => $outputlangs,
661 'hidedetails' => $hidedetails
663 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
668 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
669 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
670 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
671 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
673 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
676 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
677 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
679 $tvaligne = $sign *
$object->lines[$i]->total_tva;
683 $localtax1ligne =
$object->lines[$i]->total_localtax1;
684 $localtax2ligne =
$object->lines[$i]->total_localtax2;
685 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
686 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
687 $localtax1_type =
$object->lines[$i]->localtax1_type;
688 $localtax2_type =
$object->lines[$i]->localtax2_type;
690 $vatrate = (string)
$object->lines[$i]->tva_tx;
693 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
694 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
696 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
697 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
701 if ($localtax1_type && $localtax1ligne != 0) {
702 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
703 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
705 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
708 if ($localtax2_type && $localtax2ligne != 0) {
709 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
710 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
712 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
716 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
721 if (!isset($this->tva[$vatrate])) {
722 $this->tva[$vatrate] = 0;
724 $this->tva[$vatrate] += $tvaligne;
725 $vatcode =
$object->lines[$i]->vat_src_code;
726 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
727 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
729 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
731 $nexY = max($nexY, $posYAfterImage);
734 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
735 $pdf->setPage($pageposafter);
736 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
738 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
739 $pdf->SetLineStyle(array(
'dash' => 0));
743 while ($pagenb < $pageposafter) {
744 $pdf->setPage($pagenb);
745 if ($pagenb == $pageposbeforeprintlines) {
746 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
748 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
752 $pdf->setPage($pagenb);
753 $pdf->setPageOrientation(
'', 1, 0);
757 if (!empty($tplidx)) {
758 $pdf->useTemplate($tplidx);
762 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
763 if ($pagenb == $pageposafter) {
764 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
766 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
771 if (!empty($tplidx)) {
772 $pdf->useTemplate($tplidx);
782 if ($pagenb == $pageposbeforeprintlines) {
783 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
785 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
787 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
805 if (method_exists($pdf,
'AliasNbPages')) {
806 $pdf->AliasNbPages();
811 $pdf->Output($file,
'F');
814 $hookmanager->initHooks(array(
'pdfgeneration'));
815 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
817 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
819 $this->error = $hookmanager->error;
820 $this->errors = $hookmanager->errors;
825 $this->result = array(
'fullpath' => $file);
829 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
833 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
924 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
927 global $conf, $langs;
930 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
935 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
946 $pdf->SetTextColor(0, 0, 60);
947 $pdf->SetFont(
'',
'B', $default_font_size + 3);
951 $posy = $this->marge_haute;
952 $posx = $this->page_largeur - $this->marge_droite - $w;
954 $pdf->SetXY($this->marge_gauche, $posy);
958 if ($this->emetteur->logo) {
959 $logodir = $conf->mycompany->dir_output;
964 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
966 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
968 if (is_readable($logo)) {
970 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
972 $pdf->SetTextColor(200, 0, 0);
973 $pdf->SetFont(
'',
'B', $default_font_size - 2);
974 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
975 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
978 $text = $this->emetteur->name;
979 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
983 $pdf->SetFont(
'',
'B', $default_font_size + 3);
984 $pdf->SetXY($posx, $posy);
985 $pdf->SetTextColor(0, 0, 60);
986 $title = $outputlangs->transnoentities(
"PdfTitle");
987 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
989 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
991 $pdf->MultiCell($w, 3, $title,
'',
'R');
993 $pdf->SetFont(
'',
'B', $default_font_size);
996 $pdf->SetXY($posx, $posy);
997 $pdf->SetTextColor(0, 0, 60);
998 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref);
999 if (
$object->status == $object::STATUS_DRAFT) {
1000 $pdf->SetTextColor(128, 0, 0);
1001 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1003 $pdf->MultiCell($w, 4, $textref,
'',
'R');
1006 $pdf->SetFont(
'',
'', $default_font_size - 2);
1009 if (property_exists(
$object,
'ref_client') &&
$object->ref_client) {
1011 $pdf->SetXY($posx, $posy);
1012 $pdf->SetTextColor(0, 0, 60);
1014 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1019 if (!empty(
$object->project->ref)) {
1021 $pdf->SetXY($posx, $posy);
1022 $pdf->SetTextColor(0, 0, 60);
1023 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1029 if (!empty(
$object->project->ref)) {
1030 $outputlangs->load(
"projects");
1032 $pdf->SetXY($posx, $posy);
1033 $pdf->SetTextColor(0, 0, 60);
1034 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1039 $pdf->SetXY($posx, $posy);
1040 $pdf->SetTextColor(0, 0, 60);
1042 $title = $outputlangs->transnoentities(
"Date");
1043 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1044 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
1046 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_creation,
"day",
false, $outputlangs,
true),
'',
'R');
1050 $pdf->SetXY($posx, $posy);
1051 $pdf->SetTextColor(0, 0, 60);
1052 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1057 $pdf->SetXY($posx, $posy);
1058 $pdf->SetTextColor(0, 0, 60);
1059 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1064 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1065 if (count($arrayidcontact) > 0) {
1066 $usertmp =
new User($this->db);
1067 $usertmp->fetch($arrayidcontact[0]);
1069 $pdf->SetXY($posx, $posy);
1070 $pdf->SetTextColor(0, 0, 60);
1071 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1079 $current_y = $pdf->getY();
1081 if ($current_y < $pdf->getY()) {
1082 $top_shift = $pdf->getY() - $current_y;
1091 $posy += $top_shift;
1092 $posx = $this->marge_gauche;
1094 $posx = $this->page_largeur - $this->marge_droite - 80;
1098 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1103 $pdf->SetTextColor(0, 0, 0);
1104 $pdf->SetFont(
'',
'', $default_font_size - 2);
1105 $pdf->SetXY($posx, $posy - 5);
1106 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0, $ltrdirection);
1107 $pdf->SetXY($posx, $posy);
1108 $pdf->SetFillColor(230, 230, 230);
1109 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1110 $pdf->SetTextColor(0, 0, 60);
1115 $pdf->SetXY($posx + 2, $posy + 3);
1116 $pdf->SetFont(
'',
'B', $default_font_size);
1117 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1118 $posy = $pdf->getY();
1122 $pdf->SetXY($posx + 2, $posy);
1123 $pdf->SetFont(
'',
'', $default_font_size - 1);
1124 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1127 $usecontact =
false;
1128 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
1129 if (count($arrayidcontact) > 0) {
1131 $result =
$object->fetch_contact($arrayidcontact[0]);
1136 $thirdparty =
$object->contact;
1138 $thirdparty =
$object->thirdparty;
1141 if (is_object($thirdparty)) {
1144 $carac_client_name =
null;
1151 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1152 if ($this->page_largeur < 210) {
1156 $posy += $top_shift;
1157 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1159 $posx = $this->marge_gauche;
1164 $pdf->SetTextColor(0, 0, 0);
1165 $pdf->SetFont(
'',
'', $default_font_size - 2);
1166 $pdf->SetXY($posx + 2, $posy - 5);
1167 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"To").
":", 0, $ltrdirection);
1168 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1172 $pdf->SetXY($posx + 2, $posy + 3);
1173 $pdf->SetFont(
'',
'B', $default_font_size);
1175 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1177 $posy = $pdf->getY();
1180 $pdf->SetFont(
'',
'', $default_font_size - 1);
1181 $pdf->SetXY($posx + 2, $posy);
1183 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1186 $pdf->SetTextColor(0, 0, 0);