165 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
168 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
170 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
172 if (!is_object($outputlangs)) {
173 $outputlangs = $langs;
177 $outputlangs->charset_output =
'ISO-8859-1';
181 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
188 global $outputlangsbis;
189 $outputlangsbis =
null;
191 $outputlangsbis =
new Translate(
'', $conf);
193 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
196 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
204 $realpatharray = array();
205 $this->atleastonephoto =
false;
268 $file = $dir.
"/SPECIMEN.pdf";
272 $file = $dir.
"/".$objectref.
".pdf";
277 if (!file_exists($dir)) {
279 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
284 if (file_exists($dir)) {
286 if (!is_object($hookmanager)) {
287 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
290 $hookmanager->initHooks(array(
'pdfgeneration'));
291 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
293 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
296 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
300 '@phan-var-force TCPDI|TCPDF $pdf';
302 $pdf->SetAutoPageBreak(1, 0);
304 $heightforinfotot = 50;
306 $heightforfooter = $this->marge_basse + (
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
308 if (class_exists(
'TCPDF')) {
309 $pdf->setPrintHeader(
false);
310 $pdf->setPrintFooter(
false);
316 $logodir = $conf->mycompany->dir_output;
317 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
318 $logodir = $conf->mycompany->multidir_output[
$object->entity];
320 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
321 $tplidx = $pdf->importPage(1);
326 $pdf->SetDrawColor(128, 128, 128);
328 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
329 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
330 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
331 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
332 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
334 $pdf->SetCompression(
false);
338 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
346 'Name' => $this->emetteur->name,
347 'Location' =>
getCountry($this->emetteur->country_code,
''),
348 'Reason' =>
'MYOBJECT',
349 'ContactInfo' => $this->emetteur->email
351 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
355 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
360 if (!empty($tplidx)) {
361 $pdf->useTemplate($tplidx);
365 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
366 $pdf->SetFont(
'',
'', $default_font_size - 1);
367 $pdf->MultiCell(0, 3,
'');
368 $pdf->SetTextColor(0, 0, 0);
370 $tab_top = 90 + $top_shift;
371 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
373 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
375 $tab_height_newpage = 150;
377 $tab_height_newpage -= $top_shift;
380 $nexY = $tab_top - 1;
383 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
385 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
386 if (!empty($extranote)) {
390 $pagenb = $pdf->getPage();
394 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
395 $pageposbeforenote = $pagenb;
402 $pdf->startTransaction();
404 $pdf->SetFont(
'',
'', $default_font_size - 1);
405 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
407 $pageposafternote = $pdf->getPage();
408 $posyafter = $pdf->GetY();
410 if ($pageposafternote > $pageposbeforenote) {
411 $pdf->rollbackTransaction(
true);
414 while ($pagenb < $pageposafternote) {
417 if (!empty($tplidx)) {
418 $pdf->useTemplate($tplidx);
424 $pdf->setTopMargin($tab_top_newpage);
426 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
430 $pdf->setPage($pageposbeforenote);
431 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
432 $pdf->SetFont(
'',
'', $default_font_size - 1);
433 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
434 $pageposafternote = $pdf->getPage();
436 $posyafter = $pdf->GetY();
438 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
439 $pdf->AddPage(
'',
'',
true);
442 $pdf->setPage($pageposafternote);
443 $pdf->setTopMargin($tab_top_newpage);
445 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
451 $i = $pageposbeforenote;
452 while ($i < $pageposafternote) {
456 $pdf->SetDrawColor(128, 128, 128);
458 if ($i > $pageposbeforenote) {
459 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
460 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
462 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
463 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
467 $pdf->setPageOrientation(
'', 1, 0);
474 $pdf->setPage($pageposafternote);
475 if (!empty($tplidx)) {
476 $pdf->useTemplate($tplidx);
481 $height_note = $posyafter - $tab_top_newpage;
482 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
485 $pdf->commitTransaction();
486 $posyafter = $pdf->GetY();
487 $height_note = $posyafter - $tab_top;
488 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
491 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
493 $pdf->AddPage(
'',
'',
true);
496 $pdf->setPage($pageposafternote);
497 if (!empty($tplidx)) {
498 $pdf->useTemplate($tplidx);
504 $posyafter = $tab_top_newpage;
508 $tab_height -= $height_note;
509 $tab_top = $posyafter + 6;
518 $pdf->startTransaction();
519 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
520 $pdf->rollbackTransaction(
true);
522 $nexY = $tab_top + $this->tabTitleHeight;
525 $pageposbeforeprintlines = $pdf->getPage();
526 $pagenb = $pageposbeforeprintlines;
527 for ($i = 0; $i < $nblines; $i++) {
529 $pdf->SetFont(
'',
'', $default_font_size - 1);
530 $pdf->SetTextColor(0, 0, 0);
538 $pdf->setTopMargin($tab_top_newpage);
539 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
540 $pageposbefore = $pdf->getPage();
542 $showpricebeforepagebreak = 1;
544 $posYAfterDescription = 0;
574 $pdf->startTransaction();
577 $pageposafter = $pdf->getPage();
579 if ($pageposafter > $pageposbefore) {
580 $pdf->rollbackTransaction(
true);
581 $pageposafter = $pageposbefore;
582 $pdf->setPageOrientation(
'', 1, $heightforfooter);
586 $pageposafter = $pdf->getPage();
587 $posyafter = $pdf->GetY();
589 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
590 if ($i == ($nblines - 1)) {
591 $pdf->AddPage(
'',
'',
true);
592 if (!empty($tplidx)) {
593 $pdf->useTemplate($tplidx);
595 $pdf->setPage($pageposafter + 1);
601 $showpricebeforepagebreak = 1;
603 $showpricebeforepagebreak = 0;
607 $pdf->commitTransaction();
609 $posYAfterDescription = $pdf->GetY();
612 $nexY = max($pdf->GetY(), $posYAfterImage);
615 $pageposafter = $pdf->getPage();
616 $pdf->setPage($pageposbefore);
617 $pdf->setTopMargin($this->marge_haute);
618 $pdf->setPageOrientation(
'', 1, 0);
621 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
622 $pdf->setPage($pageposafter);
623 $curY = $tab_top_newpage;
626 $pdf->SetFont(
'',
'', $default_font_size - 1);
633 $nexY = max($pdf->GetY(), $nexY);
637 if (!empty(
$object->lines[$i]->array_options)) {
638 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
642 $nexY = max($pdf->GetY(), $nexY);
654 'outputlangs' => $outputlangs,
655 'hidedetails' => $hidedetails
657 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
662 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
663 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
664 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
665 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
667 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
670 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
671 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
673 $tvaligne = $sign *
$object->lines[$i]->total_tva;
677 $localtax1ligne =
$object->lines[$i]->total_localtax1;
678 $localtax2ligne =
$object->lines[$i]->total_localtax2;
679 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
680 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
681 $localtax1_type =
$object->lines[$i]->localtax1_type;
682 $localtax2_type =
$object->lines[$i]->localtax2_type;
684 $vatrate = (string)
$object->lines[$i]->tva_tx;
687 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
688 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
690 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
691 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
695 if ($localtax1_type && $localtax1ligne != 0) {
696 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
697 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
699 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
702 if ($localtax2_type && $localtax2ligne != 0) {
703 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
704 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
706 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
710 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
715 if (!isset($this->tva[$vatrate])) {
716 $this->tva[$vatrate] = 0;
718 $this->tva[$vatrate] += $tvaligne;
719 $vatcode =
$object->lines[$i]->vat_src_code;
720 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
721 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
723 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
725 $nexY = max($nexY, $posYAfterImage);
728 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
729 $pdf->setPage($pageposafter);
730 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
732 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
733 $pdf->SetLineStyle(array(
'dash' => 0));
737 while ($pagenb < $pageposafter) {
738 $pdf->setPage($pagenb);
739 if ($pagenb == $pageposbeforeprintlines) {
740 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
742 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
746 $pdf->setPage($pagenb);
747 $pdf->setPageOrientation(
'', 1, 0);
751 if (!empty($tplidx)) {
752 $pdf->useTemplate($tplidx);
756 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
757 if ($pagenb == $pageposafter) {
758 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
760 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
765 if (!empty($tplidx)) {
766 $pdf->useTemplate($tplidx);
776 if ($pagenb == $pageposbeforeprintlines) {
777 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
779 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
781 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
799 if (method_exists($pdf,
'AliasNbPages')) {
800 $pdf->AliasNbPages();
805 $pdf->Output($file,
'F');
808 $hookmanager->initHooks(array(
'pdfgeneration'));
809 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
811 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
813 $this->error = $hookmanager->error;
814 $this->errors = $hookmanager->errors;
819 $this->result = array(
'fullpath' => $file);
823 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
827 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
918 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
921 global $conf, $langs;
924 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
929 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
940 $pdf->SetTextColor(0, 0, 60);
941 $pdf->SetFont(
'',
'B', $default_font_size + 3);
945 $posy = $this->marge_haute;
946 $posx = $this->page_largeur - $this->marge_droite - $w;
948 $pdf->SetXY($this->marge_gauche, $posy);
952 if ($this->emetteur->logo) {
953 $logodir = $conf->mycompany->dir_output;
958 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
960 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
962 if (is_readable($logo)) {
964 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
966 $pdf->SetTextColor(200, 0, 0);
967 $pdf->SetFont(
'',
'B', $default_font_size - 2);
968 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
969 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
972 $text = $this->emetteur->name;
973 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
977 $pdf->SetFont(
'',
'B', $default_font_size + 3);
978 $pdf->SetXY($posx, $posy);
979 $pdf->SetTextColor(0, 0, 60);
980 $title = $outputlangs->transnoentities(
"PdfTitle");
981 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
983 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
985 $pdf->MultiCell($w, 3, $title,
'',
'R');
987 $pdf->SetFont(
'',
'B', $default_font_size);
990 $pdf->SetXY($posx, $posy);
991 $pdf->SetTextColor(0, 0, 60);
992 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref);
993 if (
$object->statut == $object::STATUS_DRAFT) {
994 $pdf->SetTextColor(128, 0, 0);
995 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
997 $pdf->MultiCell($w, 4, $textref,
'',
'R');
1000 $pdf->SetFont(
'',
'', $default_font_size - 2);
1003 if (property_exists(
$object,
'ref_client') &&
$object->ref_client) {
1005 $pdf->SetXY($posx, $posy);
1006 $pdf->SetTextColor(0, 0, 60);
1008 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1013 if (!empty(
$object->project->ref)) {
1015 $pdf->SetXY($posx, $posy);
1016 $pdf->SetTextColor(0, 0, 60);
1017 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1023 if (!empty(
$object->project->ref)) {
1024 $outputlangs->load(
"projects");
1026 $pdf->SetXY($posx, $posy);
1027 $pdf->SetTextColor(0, 0, 60);
1028 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1033 $pdf->SetXY($posx, $posy);
1034 $pdf->SetTextColor(0, 0, 60);
1036 $title = $outputlangs->transnoentities(
"Date");
1037 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1038 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
1040 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_creation,
"day",
false, $outputlangs,
true),
'',
'R');
1044 $pdf->SetXY($posx, $posy);
1045 $pdf->SetTextColor(0, 0, 60);
1046 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1051 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1052 if (count($arrayidcontact) > 0) {
1053 $usertmp =
new User($this->db);
1054 $usertmp->fetch($arrayidcontact[0]);
1056 $pdf->SetXY($posx, $posy);
1057 $pdf->SetTextColor(0, 0, 60);
1058 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1066 $current_y = $pdf->getY();
1068 if ($current_y < $pdf->getY()) {
1069 $top_shift = $pdf->getY() - $current_y;
1078 $posy += $top_shift;
1079 $posx = $this->marge_gauche;
1081 $posx = $this->page_largeur - $this->marge_droite - 80;
1085 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1090 $pdf->SetTextColor(0, 0, 0);
1091 $pdf->SetFont(
'',
'', $default_font_size - 2);
1092 $pdf->SetXY($posx, $posy - 5);
1093 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0, $ltrdirection);
1094 $pdf->SetXY($posx, $posy);
1095 $pdf->SetFillColor(230, 230, 230);
1096 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1097 $pdf->SetTextColor(0, 0, 60);
1102 $pdf->SetXY($posx + 2, $posy + 3);
1103 $pdf->SetFont(
'',
'B', $default_font_size);
1104 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1105 $posy = $pdf->getY();
1109 $pdf->SetXY($posx + 2, $posy);
1110 $pdf->SetFont(
'',
'', $default_font_size - 1);
1111 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1114 $usecontact =
false;
1115 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
1116 if (count($arrayidcontact) > 0) {
1118 $result =
$object->fetch_contact($arrayidcontact[0]);
1123 $thirdparty =
$object->contact;
1125 $thirdparty =
$object->thirdparty;
1128 if (is_object($thirdparty)) {
1131 $carac_client_name =
null;
1138 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1139 if ($this->page_largeur < 210) {
1143 $posy += $top_shift;
1144 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1146 $posx = $this->marge_gauche;
1151 $pdf->SetTextColor(0, 0, 0);
1152 $pdf->SetFont(
'',
'', $default_font_size - 2);
1153 $pdf->SetXY($posx + 2, $posy - 5);
1154 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"To").
":", 0, $ltrdirection);
1155 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1159 $pdf->SetXY($posx + 2, $posy + 3);
1160 $pdf->SetFont(
'',
'B', $default_font_size);
1162 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1164 $posy = $pdf->getY();
1167 $pdf->SetFont(
'',
'', $default_font_size - 1);
1168 $pdf->SetXY($posx + 2, $posy);
1170 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1173 $pdf->SetTextColor(0, 0, 0);