164 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
167 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
169 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
171 if (!is_object($outputlangs)) {
172 $outputlangs = $langs;
176 $outputlangs->charset_output =
'ISO-8859-1';
180 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
183 global $outputlangsbis;
184 $outputlangsbis =
new Translate(
'', $conf);
186 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
189 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
197 $realpatharray = array();
198 $this->atleastonephoto =
false;
251 if ($conf->mymodule->dir_output.
'/myobject') {
252 $object->fetch_thirdparty();
255 if ($object->specimen) {
256 $dir = $conf->mymodule->dir_output.
'/myobject';
257 $file = $dir.
"/SPECIMEN.pdf";
260 $dir = $conf->mymodule->dir_output.
'/myobject/'.$objectref;
261 $file = $dir.
"/".$objectref.
".pdf";
263 if (!file_exists($dir)) {
265 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
270 if (file_exists($dir)) {
272 $hookmanager->initHooks(array(
'pdfgeneration'));
273 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
275 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
278 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
283 $pdf->SetAutoPageBreak(1, 0);
285 $heightforinfotot = 50;
287 $heightforfooter = $this->marge_basse + (
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
289 if (class_exists(
'TCPDF')) {
290 $pdf->setPrintHeader(
false);
291 $pdf->setPrintFooter(
false);
297 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
298 $tplidx = $pdf->importPage(1);
303 $pdf->SetDrawColor(128, 128, 128);
305 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
306 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
307 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
308 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
309 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
311 $pdf->SetCompression(
false);
315 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
323 'Name' => $this->emetteur->name,
324 'Location' =>
getCountry($this->emetteur->country_code, 0),
325 'Reason' =>
'MYOBJECT',
326 'ContactInfo' => $this->emetteur->email
328 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
331 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
335 if (!empty($tplidx)) {
336 $pdf->useTemplate($tplidx);
340 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
341 $pdf->SetFont(
'',
'', $default_font_size - 1);
342 $pdf->MultiCell(0, 3,
'');
343 $pdf->SetTextColor(0, 0, 0);
345 $tab_top = 90 + $top_shift;
346 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
347 $tab_height = 130 - $top_shift;
348 $tab_height_newpage = 150;
350 $tab_height_newpage -= $top_shift;
353 $nexY = $tab_top - 1;
356 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
358 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
359 if (!empty($extranote)) {
363 $pagenb = $pdf->getPage();
367 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
368 $pageposbeforenote = $pagenb;
375 $pdf->startTransaction();
377 $pdf->SetFont(
'',
'', $default_font_size - 1);
378 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
380 $pageposafternote = $pdf->getPage();
381 $posyafter = $pdf->GetY();
383 if ($pageposafternote > $pageposbeforenote) {
384 $pdf->rollbackTransaction(
true);
387 while ($pagenb < $pageposafternote) {
390 if (!empty($tplidx)) {
391 $pdf->useTemplate($tplidx);
394 $this->
_pagehead($pdf, $object, 0, $outputlangs);
397 $pdf->setTopMargin($tab_top_newpage);
399 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
403 $pdf->setPage($pageposbeforenote);
404 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
405 $pdf->SetFont(
'',
'', $default_font_size - 1);
406 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
407 $pageposafternote = $pdf->getPage();
409 $posyafter = $pdf->GetY();
411 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
412 $pdf->AddPage(
'',
'',
true);
415 $pdf->setPage($pageposafternote);
416 $pdf->setTopMargin($tab_top_newpage);
418 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
424 $i = $pageposbeforenote;
425 while ($i < $pageposafternote) {
429 $pdf->SetDrawColor(128, 128, 128);
431 if ($i > $pageposbeforenote) {
432 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
433 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
435 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
436 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
440 $pdf->setPageOrientation(
'', 1, 0);
441 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
447 $pdf->setPage($pageposafternote);
448 if (!empty($tplidx)) {
449 $pdf->useTemplate($tplidx);
452 $this->
_pagehead($pdf, $object, 0, $outputlangs);
454 $height_note = $posyafter - $tab_top_newpage;
455 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
458 $pdf->commitTransaction();
459 $posyafter = $pdf->GetY();
460 $height_note = $posyafter - $tab_top;
461 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
464 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
466 $pdf->AddPage(
'',
'',
true);
469 $pdf->setPage($pageposafternote);
470 if (!empty($tplidx)) {
471 $pdf->useTemplate($tplidx);
474 $this->
_pagehead($pdf, $object, 0, $outputlangs);
477 $posyafter = $tab_top_newpage;
481 $tab_height = $tab_height - $height_note;
482 $tab_top = $posyafter + 6;
491 $pdf->startTransaction();
492 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
493 $pdf->rollbackTransaction(
true);
495 $nexY = $tab_top + $this->tabTitleHeight;
498 $pageposbeforeprintlines = $pdf->getPage();
499 $pagenb = $pageposbeforeprintlines;
500 for ($i = 0; $i < $nblines; $i++) {
502 $pdf->SetFont(
'',
'', $default_font_size - 1);
503 $pdf->SetTextColor(0, 0, 0);
506 $imglinesize = array();
507 if (!empty($realpatharray[$i])) {
511 $pdf->setTopMargin($tab_top_newpage);
512 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
513 $pageposbefore = $pdf->getPage();
515 $showpricebeforepagebreak = 1;
520 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
521 $pdf->AddPage(
'',
'',
true);
522 if (!empty($tplidx)) {
523 $pdf->useTemplate($tplidx);
525 $pdf->setPage($pageposbefore + 1);
527 $curY = $tab_top_newpage;
531 $showpricebeforepagebreak = 1;
533 $showpricebeforepagebreak = 0;
537 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
538 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
540 $posYAfterImage = $curY + $imglinesize[
'height'];
546 $pdf->startTransaction();
548 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
549 $pageposafter = $pdf->getPage();
551 if ($pageposafter > $pageposbefore) {
552 $pdf->rollbackTransaction(
true);
553 $pdf->setPageOrientation(
'', 1, $heightforfooter);
555 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
557 $pageposafter = $pdf->getPage();
558 $posyafter = $pdf->GetY();
560 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
561 if ($i == ($nblines - 1)) {
562 $pdf->AddPage(
'',
'',
true);
563 if (!empty($tplidx)) {
564 $pdf->useTemplate($tplidx);
566 $pdf->setPage($pageposafter + 1);
572 $showpricebeforepagebreak = 1;
574 $showpricebeforepagebreak = 0;
579 $pdf->commitTransaction();
583 $nexY = $pdf->GetY();
584 $pageposafter = $pdf->getPage();
585 $pdf->setPage($pageposbefore);
586 $pdf->setTopMargin($this->marge_haute);
587 $pdf->setPageOrientation(
'', 1, 0);
590 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
591 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
594 $pdf->SetFont(
'',
'', $default_font_size - 1);
601 $nexY = max($pdf->GetY(), $nexY);
605 if (!empty($object->lines[$i]->array_options)) {
606 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
608 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
610 $nexY = max($pdf->GetY(), $nexY);
622 'outputlangs' => $outputlangs,
623 'hidedetails' => $hidedetails
625 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
630 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
631 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
632 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
633 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
635 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
638 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
639 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
641 $tvaligne = $sign * $object->lines[$i]->total_tva;
645 $localtax1ligne = $object->lines[$i]->total_localtax1;
646 $localtax2ligne = $object->lines[$i]->total_localtax2;
647 $localtax1_rate = $object->lines[$i]->localtax1_tx;
648 $localtax2_rate = $object->lines[$i]->localtax2_tx;
649 $localtax1_type = $object->lines[$i]->localtax1_type;
650 $localtax2_type = $object->lines[$i]->localtax2_type;
652 if ($object->remise_percent) {
653 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
655 if ($object->remise_percent) {
656 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
658 if ($object->remise_percent) {
659 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
662 $vatrate = (string) $object->lines[$i]->tva_tx;
665 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
666 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
668 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
669 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
673 if ($localtax1_type && $localtax1ligne != 0) {
674 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
675 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
677 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
680 if ($localtax2_type && $localtax2ligne != 0) {
681 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
682 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
684 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
688 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
691 if (!isset($this->tva[$vatrate])) {
692 $this->tva[$vatrate] = 0;
694 $this->tva[$vatrate] += $tvaligne;
696 $nexY = max($nexY, $posYAfterImage);
699 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
700 $pdf->setPage($pageposafter);
701 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
703 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
704 $pdf->SetLineStyle(array(
'dash'=>0));
708 while ($pagenb < $pageposafter) {
709 $pdf->setPage($pagenb);
710 if ($pagenb == $pageposbeforeprintlines) {
711 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
713 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
715 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
717 $pdf->setPage($pagenb);
718 $pdf->setPageOrientation(
'', 1, 0);
720 $this->
_pagehead($pdf, $object, 0, $outputlangs);
722 if (!empty($tplidx)) {
723 $pdf->useTemplate($tplidx);
727 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
728 if ($pagenb == $pageposafter) {
729 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
731 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
733 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
736 if (!empty($tplidx)) {
737 $pdf->useTemplate($tplidx);
741 $this->
_pagehead($pdf, $object, 0, $outputlangs);
747 if ($pagenb == $pageposbeforeprintlines) {
748 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
749 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
751 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
752 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
770 $this->
_pagefoot($pdf, $object, $outputlangs);
771 if (method_exists($pdf,
'AliasNbPages')) {
772 $pdf->AliasNbPages();
777 $pdf->Output($file,
'F');
780 $hookmanager->initHooks(array(
'pdfgeneration'));
781 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
783 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
785 $this->error = $hookmanager->error;
786 $this->errors = $hookmanager->errors;
791 $this->result = array(
'fullpath'=>$file);
795 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
799 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
890 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
892 global $conf, $langs;
895 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
902 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'MYMODULE_DRAFT_WATERMARK')) {
906 $pdf->SetTextColor(0, 0, 60);
907 $pdf->SetFont(
'',
'B', $default_font_size + 3);
911 $posy = $this->marge_haute;
912 $posx = $this->page_largeur - $this->marge_droite - $w;
914 $pdf->SetXY($this->marge_gauche, $posy);
918 if ($this->emetteur->logo) {
919 $logodir = $conf->mycompany->dir_output;
920 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
921 $logodir = $conf->mycompany->multidir_output[$object->entity];
924 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
926 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
928 if (is_readable($logo)) {
930 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
932 $pdf->SetTextColor(200, 0, 0);
933 $pdf->SetFont(
'',
'B', $default_font_size - 2);
934 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
935 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
938 $text = $this->emetteur->name;
939 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
943 $pdf->SetFont(
'',
'B', $default_font_size + 3);
944 $pdf->SetXY($posx, $posy);
945 $pdf->SetTextColor(0, 0, 60);
946 $title = $outputlangs->transnoentities(
"PdfTitle");
949 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
951 $pdf->MultiCell($w, 3, $title,
'',
'R');
953 $pdf->SetFont(
'',
'B', $default_font_size);
956 $pdf->SetXY($posx, $posy);
957 $pdf->SetTextColor(0, 0, 60);
958 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
959 if ($object->statut == $object::STATUS_DRAFT) {
960 $pdf->SetTextColor(128, 0, 0);
961 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
963 $pdf->MultiCell($w, 4, $textref,
'',
'R');
966 $pdf->SetFont(
'',
'', $default_font_size - 2);
968 if ($object->ref_client) {
970 $pdf->SetXY($posx, $posy);
971 $pdf->SetTextColor(0, 0, 60);
972 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
976 $object->fetch_projet();
977 if (!empty($object->project->ref)) {
979 $pdf->SetXY($posx, $posy);
980 $pdf->SetTextColor(0, 0, 60);
981 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
986 $object->fetch_projet();
987 if (!empty($object->project->ref)) {
988 $outputlangs->load(
"projects");
990 $pdf->SetXY($posx, $posy);
991 $pdf->SetTextColor(0, 0, 60);
992 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
997 $pdf->SetXY($posx, $posy);
998 $pdf->SetTextColor(0, 0, 60);
1000 $title = $outputlangs->transnoentities(
"Date");
1001 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1002 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
1004 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs),
'',
'R');
1006 if ($object->thirdparty->code_client) {
1008 $pdf->SetXY($posx, $posy);
1009 $pdf->SetTextColor(0, 0, 60);
1010 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1015 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1016 if (count($arrayidcontact) > 0) {
1017 $usertmp =
new User($this->db);
1018 $usertmp->fetch($arrayidcontact[0]);
1020 $pdf->SetXY($posx, $posy);
1021 $pdf->SetTextColor(0, 0, 60);
1022 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1030 $current_y = $pdf->getY();
1031 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1032 if ($current_y < $pdf->getY()) {
1033 $top_shift = $pdf->getY() - $current_y;
1038 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1042 $posy += $top_shift;
1043 $posx = $this->marge_gauche;
1045 $posx = $this->page_largeur - $this->marge_droite - 80;
1049 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1053 $pdf->SetTextColor(0, 0, 0);
1054 $pdf->SetFont(
'',
'', $default_font_size - 2);
1055 $pdf->SetXY($posx, $posy - 5);
1056 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1057 $pdf->SetXY($posx, $posy);
1058 $pdf->SetFillColor(230, 230, 230);
1059 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1060 $pdf->SetTextColor(0, 0, 60);
1063 $pdf->SetXY($posx + 2, $posy + 3);
1064 $pdf->SetFont(
'',
'B', $default_font_size);
1065 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1066 $posy = $pdf->getY();
1069 $pdf->SetXY($posx + 2, $posy);
1070 $pdf->SetFont(
'',
'', $default_font_size - 1);
1071 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1074 $usecontact =
false;
1075 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
1076 if (count($arrayidcontact) > 0) {
1078 $result = $object->fetch_contact($arrayidcontact[0]);
1082 if ($object->contact->socid != $object->thirdparty->id &&
getDolGlobalInt(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
1083 $thirdparty = $object->contact;
1085 $thirdparty = $object->thirdparty;
1088 if (is_object($thirdparty)) {
1092 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1095 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1096 if ($this->page_largeur < 210) {
1100 $posy += $top_shift;
1101 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1103 $posx = $this->marge_gauche;
1107 $pdf->SetTextColor(0, 0, 0);
1108 $pdf->SetFont(
'',
'', $default_font_size - 2);
1109 $pdf->SetXY($posx + 2, $posy - 5);
1110 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1111 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1114 $pdf->SetXY($posx + 2, $posy + 3);
1115 $pdf->SetFont(
'',
'B', $default_font_size);
1116 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1118 $posy = $pdf->getY();
1121 $pdf->SetFont(
'',
'', $default_font_size - 1);
1122 $pdf->SetXY($posx + 2, $posy);
1123 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1126 $pdf->SetTextColor(0, 0, 0);