193 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
196 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
198 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
200 if (!is_object($outputlangs)) {
201 $outputlangs = $langs;
204 if (!empty($conf->global->MAIN_USE_FPDF)) {
205 $outputlangs->charset_output =
'ISO-8859-1';
209 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
211 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
212 global $outputlangsbis;
213 $outputlangsbis =
new Translate(
'', $conf);
214 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
215 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
218 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
221 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
222 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
226 $realpatharray = array();
227 $this->atleastonephoto =
false;
281 if ($conf->asset->dir_output.
'/asset') {
282 $object->fetch_thirdparty();
285 if ($object->specimen) {
286 $dir = $conf->asset->dir_output.
'/asset';
287 $file = $dir.
"/SPECIMEN.pdf";
290 $dir = $conf->asset->dir_output.
'/asset/'.$objectref;
291 $file = $dir.
"/".$objectref.
".pdf";
293 if (!file_exists($dir)) {
295 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
300 if (file_exists($dir)) {
302 if (!is_object($hookmanager)) {
303 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
306 $hookmanager->initHooks(array(
'pdfgeneration'));
307 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
309 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
312 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
317 $pdf->SetAutoPageBreak(1, 0);
319 $heightforinfotot = 50;
320 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
321 $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
323 if (class_exists(
'TCPDF')) {
324 $pdf->setPrintHeader(
false);
325 $pdf->setPrintFooter(
false);
330 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
331 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
332 $tplidx = $pdf->importPage(1);
337 $pdf->SetDrawColor(128, 128, 128);
339 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
340 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
341 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
342 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
343 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
345 $pdf->SetCompression(
false);
349 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
352 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
357 'Name' => $this->emetteur->name,
358 'Location' =>
getCountry($this->emetteur->country_code, 0),
360 'ContactInfo' => $this->emetteur->email
362 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
365 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
369 if (!empty($tplidx)) {
370 $pdf->useTemplate($tplidx);
374 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
375 $pdf->SetFont(
'',
'', $default_font_size - 1);
376 $pdf->MultiCell(0, 3,
'');
377 $pdf->SetTextColor(0, 0, 0);
379 $tab_top = 90 + $top_shift;
380 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
381 $tab_height = 130 - $top_shift;
382 $tab_height_newpage = 150;
384 $tab_height_newpage -= $top_shift;
387 $nexY = $tab_top - 1;
390 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
392 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
393 if (!empty($extranote)) {
397 $pagenb = $pdf->getPage();
401 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
402 $pageposbeforenote = $pagenb;
409 $pdf->startTransaction();
411 $pdf->SetFont(
'',
'', $default_font_size - 1);
412 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
414 $pageposafternote = $pdf->getPage();
415 $posyafter = $pdf->GetY();
417 if ($pageposafternote > $pageposbeforenote) {
418 $pdf->rollbackTransaction(
true);
421 while ($pagenb < $pageposafternote) {
424 if (!empty($tplidx)) {
425 $pdf->useTemplate($tplidx);
428 $this->
_pagehead($pdf, $object, 0, $outputlangs);
431 $pdf->setTopMargin($tab_top_newpage);
433 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
437 $pdf->setPage($pageposbeforenote);
438 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
439 $pdf->SetFont(
'',
'', $default_font_size - 1);
440 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
441 $pageposafternote = $pdf->getPage();
443 $posyafter = $pdf->GetY();
445 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
446 $pdf->AddPage(
'',
'',
true);
449 $pdf->setPage($pageposafternote);
450 $pdf->setTopMargin($tab_top_newpage);
452 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
458 $i = $pageposbeforenote;
459 while ($i < $pageposafternote) {
463 $pdf->SetDrawColor(128, 128, 128);
465 if ($i > $pageposbeforenote) {
466 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
467 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
469 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
470 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
474 $pdf->setPageOrientation(
'', 1, 0);
475 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
481 $pdf->setPage($pageposafternote);
482 if (!empty($tplidx)) {
483 $pdf->useTemplate($tplidx);
486 $this->
_pagehead($pdf, $object, 0, $outputlangs);
488 $height_note = $posyafter - $tab_top_newpage;
489 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
492 $pdf->commitTransaction();
493 $posyafter = $pdf->GetY();
494 $height_note = $posyafter - $tab_top;
495 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
498 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
500 $pdf->AddPage(
'',
'',
true);
503 $pdf->setPage($pageposafternote);
504 if (!empty($tplidx)) {
505 $pdf->useTemplate($tplidx);
508 $this->
_pagehead($pdf, $object, 0, $outputlangs);
511 $posyafter = $tab_top_newpage;
515 $tab_height = $tab_height - $height_note;
516 $tab_top = $posyafter + 6;
525 $pdf->startTransaction();
526 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
527 $pdf->rollbackTransaction(
true);
529 $nexY = $tab_top + $this->tabTitleHeight;
532 $pageposbeforeprintlines = $pdf->getPage();
533 $pagenb = $pageposbeforeprintlines;
534 for ($i = 0; $i < $nblines; $i++) {
536 $pdf->SetFont(
'',
'', $default_font_size - 1);
537 $pdf->SetTextColor(0, 0, 0);
540 $imglinesize = array();
541 if (!empty($realpatharray[$i])) {
545 $pdf->setTopMargin($tab_top_newpage);
546 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
547 $pageposbefore = $pdf->getPage();
549 $showpricebeforepagebreak = 1;
554 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
555 $pdf->AddPage(
'',
'',
true);
556 if (!empty($tplidx)) {
557 $pdf->useTemplate($tplidx);
559 $pdf->setPage($pageposbefore + 1);
561 $curY = $tab_top_newpage;
564 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
565 $showpricebeforepagebreak = 1;
567 $showpricebeforepagebreak = 0;
571 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
572 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
574 $posYAfterImage = $curY + $imglinesize[
'height'];
580 $pdf->startTransaction();
582 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
583 $pageposafter = $pdf->getPage();
585 if ($pageposafter > $pageposbefore) {
586 $pdf->rollbackTransaction(
true);
587 $pdf->setPageOrientation(
'', 1, $heightforfooter);
589 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
591 $pageposafter = $pdf->getPage();
592 $posyafter = $pdf->GetY();
594 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
595 if ($i == ($nblines - 1)) {
596 $pdf->AddPage(
'',
'',
true);
597 if (!empty($tplidx)) {
598 $pdf->useTemplate($tplidx);
600 $pdf->setPage($pageposafter + 1);
605 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
606 $showpricebeforepagebreak = 1;
608 $showpricebeforepagebreak = 0;
613 $pdf->commitTransaction();
617 $nexY = $pdf->GetY();
618 $pageposafter = $pdf->getPage();
619 $pdf->setPage($pageposbefore);
620 $pdf->setTopMargin($this->marge_haute);
621 $pdf->setPageOrientation(
'', 1, 0);
624 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
625 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
628 $pdf->SetFont(
'',
'', $default_font_size - 1);
635 $nexY = max($pdf->GetY(), $nexY);
639 if (!empty($object->lines[$i]->array_options)) {
640 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
642 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
644 $nexY = max($pdf->GetY(), $nexY);
656 'outputlangs' => $outputlangs,
657 'hidedetails' => $hidedetails
659 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
664 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
665 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
666 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
667 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
669 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
672 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
673 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
675 $tvaligne = $sign * $object->lines[$i]->total_tva;
679 $localtax1ligne = $object->lines[$i]->total_localtax1;
680 $localtax2ligne = $object->lines[$i]->total_localtax2;
681 $localtax1_rate = $object->lines[$i]->localtax1_tx;
682 $localtax2_rate = $object->lines[$i]->localtax2_tx;
683 $localtax1_type = $object->lines[$i]->localtax1_type;
684 $localtax2_type = $object->lines[$i]->localtax2_type;
697 $vatrate = (string) $object->lines[$i]->tva_tx;
700 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
701 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
703 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
704 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
708 if ($localtax1_type && $localtax1ligne != 0) {
709 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
710 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
712 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
715 if ($localtax2_type && $localtax2ligne != 0) {
716 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
717 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
719 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
723 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
726 if (!isset($this->tva[$vatrate])) {
727 $this->tva[$vatrate] = 0;
729 $this->tva[$vatrate] += $tvaligne;
731 $nexY = max($nexY, $posYAfterImage);
734 if (!empty($conf->global->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);
750 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
752 $pdf->setPage($pagenb);
753 $pdf->setPageOrientation(
'', 1, 0);
755 $this->
_pagehead($pdf, $object, 0, $outputlangs);
759 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
760 if ($pagenb == $pageposafter) {
761 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
763 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
765 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
768 if (!empty($tplidx)) {
769 $pdf->useTemplate($tplidx);
773 $this->
_pagehead($pdf, $object, 0, $outputlangs);
779 if ($pagenb == $pageposbeforeprintlines) {
780 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
781 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
783 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
784 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
802 $this->
_pagefoot($pdf, $object, $outputlangs);
803 if (method_exists($pdf,
'AliasNbPages')) {
804 $pdf->AliasNbPages();
809 $pdf->Output($file,
'F');
812 $hookmanager->initHooks(array(
'pdfgeneration'));
813 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
815 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
817 $this->error = $hookmanager->error;
818 $this->errors = $hookmanager->errors;
823 $this->result = array(
'fullpath'=>$file);
827 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
831 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
922 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
924 global $conf, $langs;
927 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
934 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
935 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
938 $pdf->SetTextColor(0, 0, 60);
939 $pdf->SetFont(
'',
'B', $default_font_size + 3);
943 $posy = $this->marge_haute;
944 $posx = $this->page_largeur - $this->marge_droite - $w;
946 $pdf->SetXY($this->marge_gauche, $posy);
950 if ($this->emetteur->logo) {
951 $logodir = $conf->mycompany->dir_output;
952 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
953 $logodir = $conf->mycompany->multidir_output[$object->entity];
956 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
958 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
960 if (is_readable($logo)) {
962 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
964 $pdf->SetTextColor(200, 0, 0);
965 $pdf->SetFont(
'',
'B', $default_font_size - 2);
966 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
967 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
970 $text = $this->emetteur->name;
971 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
975 $pdf->SetFont(
'',
'B', $default_font_size + 3);
976 $pdf->SetXY($posx, $posy);
977 $pdf->SetTextColor(0, 0, 60);
978 $title = $outputlangs->transnoentities(
"PdfTitle");
979 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
981 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
983 $pdf->MultiCell($w, 3, $title,
'',
'R');
985 $pdf->SetFont(
'',
'B', $default_font_size);
988 $pdf->SetXY($posx, $posy);
989 $pdf->SetTextColor(0, 0, 60);
990 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
991 if ($object->statut == $object::STATUS_DRAFT) {
992 $pdf->SetTextColor(128, 0, 0);
993 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
995 $pdf->MultiCell($w, 4, $textref,
'',
'R');
998 $pdf->SetFont(
'',
'', $default_font_size - 2);
1000 if ($object->ref_client) {
1002 $pdf->SetXY($posx, $posy);
1003 $pdf->SetTextColor(0, 0, 60);
1004 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1007 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1008 $object->fetch_projet();
1009 if (!empty($object->project->ref)) {
1011 $pdf->SetXY($posx, $posy);
1012 $pdf->SetTextColor(0, 0, 60);
1013 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1017 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1018 $object->fetch_projet();
1019 if (!empty($object->project->ref)) {
1020 $outputlangs->load(
"projects");
1022 $pdf->SetXY($posx, $posy);
1023 $pdf->SetTextColor(0, 0, 60);
1024 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1029 $pdf->SetXY($posx, $posy);
1030 $pdf->SetTextColor(0, 0, 60);
1032 $title = $outputlangs->transnoentities(
"Date");
1033 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1034 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
1036 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs),
'',
'R');
1038 if ($object->thirdparty->code_client) {
1040 $pdf->SetXY($posx, $posy);
1041 $pdf->SetTextColor(0, 0, 60);
1042 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1046 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1047 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1048 if (count($arrayidcontact) > 0) {
1049 $usertmp =
new User($this->db);
1050 $usertmp->fetch($arrayidcontact[0]);
1052 $pdf->SetXY($posx, $posy);
1053 $pdf->SetTextColor(0, 0, 60);
1054 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1062 $current_y = $pdf->getY();
1063 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1064 if ($current_y < $pdf->getY()) {
1065 $top_shift = $pdf->getY() - $current_y;
1070 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1073 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1074 $posy += $top_shift;
1075 $posx = $this->marge_gauche;
1076 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1077 $posx = $this->page_largeur - $this->marge_droite - 80;
1080 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1081 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1085 $pdf->SetTextColor(0, 0, 0);
1086 $pdf->SetFont(
'',
'', $default_font_size - 2);
1087 $pdf->SetXY($posx, $posy - 5);
1088 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1089 $pdf->SetXY($posx, $posy);
1090 $pdf->SetFillColor(230, 230, 230);
1091 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1092 $pdf->SetTextColor(0, 0, 60);
1095 $pdf->SetXY($posx + 2, $posy + 3);
1096 $pdf->SetFont(
'',
'B', $default_font_size);
1097 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1098 $posy = $pdf->getY();
1101 $pdf->SetXY($posx + 2, $posy);
1102 $pdf->SetFont(
'',
'', $default_font_size - 1);
1103 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1106 $usecontact =
false;
1107 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
1108 if (count($arrayidcontact) > 0) {
1110 $result = $object->fetch_contact($arrayidcontact[0]);
1114 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
1115 $thirdparty = $object->contact;
1117 $thirdparty = $object->thirdparty;
1120 if (is_object($thirdparty)) {
1124 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1127 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1128 if ($this->page_largeur < 210) {
1131 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1132 $posy += $top_shift;
1133 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1134 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1135 $posx = $this->marge_gauche;
1139 $pdf->SetTextColor(0, 0, 0);
1140 $pdf->SetFont(
'',
'', $default_font_size - 2);
1141 $pdf->SetXY($posx + 2, $posy - 5);
1142 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1143 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1146 $pdf->SetXY($posx + 2, $posy + 3);
1147 $pdf->SetFont(
'',
'B', $default_font_size);
1148 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1150 $posy = $pdf->getY();
1153 $pdf->SetFont(
'',
'', $default_font_size - 1);
1154 $pdf->SetXY($posx + 2, $posy);
1155 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1158 $pdf->SetTextColor(0, 0, 0);