169 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
172 global $user, $langs, $conf,
$mysoc, $db, $hookmanager, $nblines;
174 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
176 if (!is_object($outputlangs)) {
177 $outputlangs = $langs;
181 $outputlangs->charset_output =
'ISO-8859-1';
185 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"sendginds",
"compta"));
192 global $outputlangsbis;
193 $outputlangsbis =
null;
195 $outputlangsbis =
new Translate(
'', $conf);
197 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"sendginds",
"compta"));
200 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
205 $realpatharray = array();
206 $this->atleastonephoto =
false;
208 $objphoto =
new Product($this->db);
210 for ($i = 0; $i < $nblines; $i++) {
211 if (empty(
$object->lines[$i]->fk_product)) {
217 $objphoto->fetch(
$object->lines[$i]->fk_product);
220 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
221 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
223 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
224 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
229 foreach ($pdir as $midir) {
231 $entity = $objphoto->entity;
232 if ($entity !==
null && $conf->entity != $entity) {
233 $dir = $conf->product->multidir_output[$entity].
'/'.$midir;
235 $dir = $conf->product->dir_output.
'/'.$midir;
238 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
240 if ($obj[
'photo_vignette']) {
241 $filename = $obj[
'photo_vignette'];
243 $filename = $obj[
'photo'];
246 $filename = $obj[
'photo'];
249 $realpath = $dir.$filename;
251 $this->atleastonephoto =
true;
256 if ($realpath && $arephoto) {
257 $realpatharray[$i] = $realpath;
272 $file = $dir.
"/SPECIMEN.pdf";
276 $file = $dir.
"/".$objectref.
".pdf";
281 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir",
"Null dir");
285 if (!file_exists($dir)) {
287 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
292 if (file_exists($dir)) {
294 if (!is_object($hookmanager)) {
295 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
298 $hookmanager->initHooks(array(
'pdfgeneration'));
299 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
301 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
304 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
309 $pdf->setAutoPageBreak(
true, 0);
311 $heightforinfotot = 40;
313 $heightforfooter = $this->marge_basse + 8;
315 $heightforfooter += 6;
318 if (class_exists(
'TCPDF')) {
319 $pdf->setPrintHeader(
false);
320 $pdf->setPrintFooter(
false);
325 $logodir = $conf->mycompany->dir_output;
326 if (!empty($conf->mycompany->multidir_output[
$object->entity ?? $conf->entity])) {
327 $logodir = $conf->mycompany->multidir_output[
$object->entity ?? $conf->entity];
329 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
330 $tplidx = $pdf->importPage(1);
335 $pdf->SetDrawColor(128, 128, 128);
337 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
338 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
339 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
340 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
341 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
343 $pdf->SetCompression(
false);
347 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
350 for ($i = 0; $i < $nblines; $i++) {
351 if (
$object->lines[$i]->remise_percent) {
352 $this->atleastonediscount++;
359 if (!empty($tplidx)) {
360 $pdf->useTemplate($tplidx);
363 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
364 $top_shift = $pagehead[
'top_shift'];
365 $shipp_shift = $pagehead[
'shipp_shift'];
366 $pdf->SetFont(
'',
'', $default_font_size - 1);
367 $pdf->MultiCell(0, 3,
'');
368 $pdf->SetTextColor(0, 0, 0);
371 $tab_top = 90 + $top_shift + $shipp_shift;
372 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
373 if (!$hidetop &&
getDolGlobalInt(
'MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
375 $tab_top_newpage += $this->tabTitleHeight;
378 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
380 $nexY = $tab_top - 1;
383 $height_incoterms = 0;
385 $desc_incoterms =
$object->getIncotermsForPDF();
386 if ($desc_incoterms) {
389 $pdf->SetFont(
'',
'', $default_font_size - 1);
390 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
391 $nexY = max($pdf->GetY(), $nexY);
392 $height_incoterms = $nexY - $tab_top;
395 $pdf->SetDrawColor(192, 192, 192);
396 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
398 $tab_top = $nexY + 6;
403 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
406 if (is_object(
$object->thirdparty)) {
407 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
408 $salerepobj =
new User($this->db);
409 $salerepobj->fetch($salereparray[0][
'id']);
410 if (!empty($salerepobj->signature)) {
411 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
416 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
417 if (!empty($extranote)) {
421 $pagenb = $pdf->getPage();
425 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
426 $pageposbeforenote = $pagenb;
433 $pdf->startTransaction();
435 $pdf->SetFont(
'',
'', $default_font_size - 1);
436 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
438 $pageposafternote = $pdf->getPage();
439 $posyafter = $pdf->GetY();
441 if ($pageposafternote > $pageposbeforenote) {
442 $pdf->rollbackTransaction(
true);
445 while ($pagenb < $pageposafternote) {
448 if (!empty($tplidx)) {
449 $pdf->useTemplate($tplidx);
455 $pdf->setTopMargin($tab_top_newpage);
457 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
461 $pdf->setPage($pageposbeforenote);
462 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
463 $pdf->SetFont(
'',
'', $default_font_size - 1);
464 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
465 $pageposafternote = $pdf->getPage();
467 $posyafter = $pdf->GetY();
469 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
470 $pdf->AddPage(
'',
'',
true);
473 $pdf->setPage($pageposafternote);
474 $pdf->setTopMargin($tab_top_newpage);
476 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
482 $i = $pageposbeforenote;
483 while ($i < $pageposafternote) {
487 $pdf->SetDrawColor(128, 128, 128);
489 if ($i > $pageposbeforenote) {
490 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
491 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
493 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
494 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
498 $pdf->setPageOrientation(
'',
true, 0);
505 $pdf->setPage($pageposafternote);
506 if (!empty($tplidx)) {
507 $pdf->useTemplate($tplidx);
512 $height_note = $posyafter - $tab_top_newpage;
513 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
516 $pdf->commitTransaction();
517 $posyafter = $pdf->GetY();
518 $height_note = $posyafter - $tab_top;
519 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
522 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
524 $pdf->AddPage(
'',
'',
true);
527 $pdf->setPage($pageposafternote);
528 if (!empty($tplidx)) {
529 $pdf->useTemplate($tplidx);
535 $posyafter = $tab_top_newpage;
539 $tab_height -= $height_note;
540 $tab_top = $posyafter + 6;
550 $pdf->startTransaction();
551 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
552 $pdf->rollbackTransaction(
true);
554 $nexY = $tab_top + $this->tabTitleHeight;
557 $pageposbeforeprintlines = $pdf->getPage();
558 $pagenb = $pageposbeforeprintlines;
560 $pdf_sub_options = array();
561 $pdf_sub_options[
'titleshowuponpdf'] = 1;
562 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
563 $pdf_sub_options_before_title = array();
567 for ($i = 0; $i < $nblines; $i++) {
568 $linePosition = $i + 1;
571 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
573 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
574 $level =
$object->lines[$i]->qty;
576 if ($level > 0 && !isset($pdf_sub_options_before_title[(
int) $level])) {
577 $pdf_sub_options_before_title[(int) $level] = $pdf_sub_options;
581 if (isset($sub_options[
'titleshowuponpdf'])) {
582 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
583 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
584 unset($pdf_sub_options[
'titleshowuponpdf']);
586 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
587 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
588 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
589 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
592 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
593 unset($pdf_sub_options[
'titleshowuponpdf']);
595 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
596 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
600 if ($level < 0 && isset($pdf_sub_options_before_title[(
int) abs($level)])) {
601 $pdf_sub_options = $pdf_sub_options_before_title[(int) abs($level)];
602 foreach (array_keys($pdf_sub_options_before_title) as $tmplevel) {
603 if ($tmplevel >= abs($level)) {
604 unset($pdf_sub_options_before_title[$tmplevel]);
610 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && isset($sub_options[
'subtotalshowtotalexludingvatonpdf']) &&
getDolGlobalString(
'SUBTOTAL_HIDE_LINES_UNDER_TITLE')) {
612 $pdf_sub_options = array();
613 $pdf_sub_options[
'titleshowuponpdf'] = 1;
614 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
621 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
622 $object->lines[$i]->pagebreak =
true;
626 if (isset(
$object->lines[$i]->pagebreak) &&
$object->lines[$i]->pagebreak) {
629 if (!empty($tplidx)) {
630 $pdf->useTemplate($tplidx);
633 $pdf->setPage($pdf->getNumPages());
634 $nexY = $curY = $tab_top_newpage;
640 $pdf->SetFont(
'',
'', $default_font_size - 1);
641 $pdf->SetTextColor(0, 0, 0);
644 $imglinesize = array();
645 if (!empty($realpatharray[$i])) {
649 $pdf->setTopMargin($tab_top_newpage);
650 $pdf->setPageOrientation(
'',
true, $heightforfooter);
651 $pageposbefore = $pdf->getPage();
655 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
661 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imageTopMargin + $imglinesize[
'height']) > ($this->page_hauteur - $heightforfooter)) {
662 $pdf->AddPage(
'',
'',
true);
663 if (!empty($tplidx)) {
664 $pdf->useTemplate($tplidx);
666 $pdf->setPage($pageposbefore + 1);
667 $pdf->setPageOrientation(
'',
true, $heightforfooter);
668 $curY = $tab_top_newpage;
669 $showpricebeforepagebreak = 0;
676 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
677 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + $imageTopMargin, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
679 $posYAfterImage = $curY + $imglinesize[
'height'];
685 $pdf->setPageOrientation(
'',
true, $heightforfooter);
689 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
694 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
699 $pdf->setPage($pageposbefore);
700 $pdf->setTopMargin($this->marge_haute);
701 $pdf->setPageOrientation(
'',
false, $heightforfooter);
704 if ($afterPosData[
'page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
705 $pdf->setPage($afterPosData[
'page']);
706 $curY = $tab_top_newpage;
709 $pdf->SetFont(
'',
'', $default_font_size - 1);
723 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
743 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
750 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
753 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
755 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
757 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
764 if ($this->
getColumnStatus(
'totalincltax') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
770 if (!empty(
$object->lines[$i]->array_options)) {
771 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
786 'nexY' => & $afterPosData[
'y'],
787 'outputlangs' => $outputlangs,
788 'hidedetails' => $hidedetails
790 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
795 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
797 $tvaligne =
$object->lines[$i]->total_tva;
800 $localtax1ligne =
$object->lines[$i]->total_localtax1;
801 $localtax2ligne =
$object->lines[$i]->total_localtax2;
802 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
803 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
804 $localtax1_type =
$object->lines[$i]->localtax1_type;
805 $localtax2_type =
$object->lines[$i]->localtax2_type;
807 $vatrate = (string)
$object->lines[$i]->tva_tx;
810 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
811 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
813 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
814 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
818 if ($localtax1_type && $localtax1ligne != 0) {
819 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
820 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
822 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
825 if ($localtax2_type && $localtax2ligne != 0) {
826 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
827 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
829 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
833 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
838 if (!isset($this->tva[$vatrate])) {
839 $this->tva[$vatrate] = 0;
841 $this->tva[$vatrate] += $tvaligne;
842 $vatcode =
$object->lines[$i]->vat_src_code;
843 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
844 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
846 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
849 if (!$hidenextline) {
851 $pdf->setPage($afterPosData[
'page']);
852 $nexY = $afterPosData[
'y'];
855 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $heightforfooter - 5) {
856 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
858 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
859 $pdf->SetLineStyle(array(
'dash' => 0));
862 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && (isset($sub_options[
'titleshowuponpdf']) || isset($sub_options[
'titleshowtotalexludingvatonpdf'])) &&
getDolGlobalString(
'SUBTOTAL_HIDE_LINES_UNDER_TITLE')) {
871 if (isset($afterPosData[
'y']) && $afterPosData[
'y'] > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
873 if (!empty($tplidx)) {
874 $pdf->useTemplate($tplidx);
877 $pdf->setPage($pagenb);
881 $drawTabNumbPage = $pdf->getNumPages();
882 for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) {
885 $pdf->setPageOrientation(
'',
false, 0);
887 $drawTabHideTop = $hidetop;
888 $drawTabTop = $tab_top_newpage;
889 $drawTabBottom = $this->page_hauteur - $heightforfooter;
892 if ($i == $pageposbeforeprintlines) {
894 $drawTabTop = $tab_top;
895 } elseif (!$drawTabHideTop) {
897 $drawTabTop -= $this->tabTitleHeight;
904 if ($i == $pdf->getNumPages()) {
906 $drawTabBottom -= $heightforfreetext + $heightforinfotot;
909 $drawTabHeight = $drawTabBottom - $drawTabTop;
910 $this->
_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom,
$object->multicurrency_code, $outputlangsbis);
912 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0;
918 $pdf->setPageOrientation(
'',
true, 0);
921 if (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
924 if (!empty($tplidx)) {
925 $pdf->useTemplate($tplidx);
930 $pdf->SetTextColor(0, 0, 0);
932 $pdf->setPage($pdf->getNumPages());
934 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
944 if (method_exists($pdf,
'AliasNbPages')) {
945 $pdf->AliasNbPages();
950 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_ORDER') && $termsofsalefilename) {
951 $termsofsale = $conf->order->dir_output.
'/'.$termsofsalefilename;
952 if (!empty($conf->order->multidir_output[$conf->entity])) {
953 $termsofsale = $conf->order->multidir_output[$conf->entity].
'/'.$termsofsalefilename;
955 if (file_exists($termsofsale) && is_readable($termsofsale)) {
956 $pagecount = $pdf->setSourceFile($termsofsale);
957 for ($i = 1; $i <= $pagecount; $i++) {
958 $tplIdx = $pdf->importPage($i);
959 if ($tplIdx !==
false) {
960 $s = $pdf->getTemplatesize($tplIdx);
961 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
962 $pdf->useTemplate($tplIdx);
964 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
972 $pdf->Output($file,
'F');
975 $hookmanager->initHooks(array(
'pdfgeneration'));
976 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
978 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
979 $this->warnings = $hookmanager->warnings;
981 $this->error = $hookmanager->error;
982 $this->errors = $hookmanager->errors;
989 $this->result = array(
'fullpath' => $file);
993 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
997 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
1030 $pdf->SetFont(
'',
'', $default_font_size - 1);
1035 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
1036 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1037 $pdf->SetXY($this->marge_gauche, $posy);
1038 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1040 $posy = $pdf->GetY() + 4;
1049 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1050 $pdf->SetXY($this->marge_gauche, $posy);
1051 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1052 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1054 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1055 $pdf->SetXY($posxval, $posy);
1056 $lib_condition_paiement = ($outputlangs->transnoentities(
"PaymentCondition".
$object->cond_reglement_code) !=
'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset(
$object->cond_reglement_doc ?
$object->cond_reglement_doc :
$object->cond_reglement_label);
1057 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1058 if (
$object->deposit_percent > 0) {
1059 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
1061 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1063 $posy = $pdf->GetY() + 3;
1094 if (!empty(
$object->delivery_date)) {
1095 $outputlangs->load(
"sendings");
1096 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1097 $pdf->SetXY($this->marge_gauche, $posy);
1098 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1099 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1100 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1101 $pdf->SetXY($posxval, $posy);
1103 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1105 $posy = $pdf->GetY() + 1;
1107 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1108 $pdf->SetXY($this->marge_gauche, $posy);
1109 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1110 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1111 $pdf->SetTextColor(0, 0, 0);
1112 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1113 $pdf->SetXY($posxval, $posy);
1114 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) : $outputlangs->convToOutputCharset(isset(
$object->availability) ?
$object->availability :
'');
1115 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1116 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1118 $posy = $pdf->GetY() + 1;
1122 if (
$object->mode_reglement_code
1123 &&
$object->mode_reglement_code !=
'CHQ'
1124 &&
$object->mode_reglement_code !=
'VIR') {
1125 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1126 $pdf->SetXY($this->marge_gauche, $posy);
1127 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1128 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1130 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1131 $pdf->SetXY($posxval, $posy);
1132 $lib_mode_reg = $outputlangs->transnoentities(
"PaymentType".
$object->mode_reglement_code) !=
'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities(
"PaymentType".
$object->mode_reglement_code) : $outputlangs->convToOutputCharset(
$object->mode_reglement);
1133 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1135 $posy = $pdf->GetY() + 2;
1139 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1143 $account =
new Account($this->db);
1146 $pdf->SetXY($this->marge_gauche, $posy);
1147 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1148 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1149 $posy = $pdf->GetY() + 1;
1152 $pdf->SetXY($this->marge_gauche, $posy);
1153 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1154 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1155 $posy = $pdf->GetY() + 2;
1159 $pdf->SetXY($this->marge_gauche, $posy);
1160 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1161 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1162 $posy = $pdf->GetY() + 1;
1165 $pdf->SetXY($this->marge_gauche, $posy);
1166 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1167 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1168 $posy = $pdf->GetY() + 2;
1175 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1177 $bankid = (
$object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1181 $account =
new Account($this->db);
1182 $account->fetch($bankid);
1184 $curx = $this->marge_gauche;
1187 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1210 global $conf,
$mysoc, $hookmanager;
1215 $outputlangsbis =
new Translate(
'', $conf);
1217 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1218 $default_font_size--;
1223 $pdf->SetFont(
'',
'', $default_font_size - 1);
1228 if ($this->page_largeur < 210) {
1231 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1240 $total_discount_on_lines = 0;
1241 $multicurrency_total_discount_on_lines = 0;
1242 foreach (
$object->lines as $i => $line) {
1246 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1247 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1249 if ($line->total_ht < 0) {
1250 $total_discount_on_lines += -$line->total_ht;
1251 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1255 if ($total_discount_on_lines > 0) {
1257 $pdf->SetFillColor(255, 255, 255);
1258 $pdf->SetXY($col1x, $tab2_top);
1259 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1260 $pdf->SetXY($col2x, $tab2_top);
1262 $total_before_discount_to_show = ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? (
$object->multicurrency_total_ht + $multicurrency_total_discount_on_lines) : (
$object->total_ht + $total_discount_on_lines));
1263 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1267 $pdf->SetFillColor(255, 255, 255);
1268 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1269 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1270 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1272 $total_discount_to_show = ((
isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1273 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1279 $pdf->SetFillColor(255, 255, 255);
1280 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1281 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1283 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1284 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1287 $pdf->SetFillColor(248, 248, 248);
1290 $total_ttc_origin =
$object->total_ttc;
1292 $this->atleastoneratenotnull = 0;
1294 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1295 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1299 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1300 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1303 foreach ($localtax_rate as $tvakey => $tvaval) {
1307 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1310 if (preg_match(
'/\*/', (
string) $tvakey)) {
1311 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1312 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1314 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1318 $totalvat .= $tvacompl;
1320 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1323 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1327 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1328 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1334 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1335 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1338 foreach ($localtax_rate as $tvakey => $tvaval) {
1343 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1346 if (preg_match(
'/\*/', (
string) $tvakey)) {
1347 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1348 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1350 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1354 $totalvat .= $tvacompl;
1356 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1359 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1363 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1364 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1370 foreach ($this->tva_array as $tvakey => $tvaval) {
1372 $this->atleastoneratenotnull++;
1375 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1378 if (preg_match(
'/\*/', $tvakey)) {
1379 $tvakey = str_replace(
'*',
'', $tvakey);
1380 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1382 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1385 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1387 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1389 $totalvat .= $tvacompl;
1391 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1393 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1395 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1396 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1401 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1402 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1406 foreach ($localtax_rate as $tvakey => $tvaval) {
1411 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1414 if (preg_match(
'/\*/', (
string) $tvakey)) {
1415 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1416 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1418 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1422 $totalvat .= $tvacompl;
1424 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1427 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1431 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1432 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1438 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1439 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1443 foreach ($localtax_rate as $tvakey => $tvaval) {
1449 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1452 if (preg_match(
'/\*/', (
string) $tvakey)) {
1453 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1454 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1456 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1460 $totalvat .= $tvacompl;
1462 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1465 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1469 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1470 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1478 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1479 $pdf->SetTextColor(0, 0, 60);
1480 $pdf->SetFillColor(224, 224, 224);
1481 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC",
$mysoc->country_code) :
''), $useborder,
'L',
true);
1483 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1485 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1487 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1491 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1492 $pdf->SetTextColor(0, 0, 60);
1493 $pdf->SetFillColor(224, 224, 224);
1494 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1496 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1497 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1502 $pdf->SetTextColor(0, 0, 0);
1504 $creditnoteamount = 0;
1505 $depositsamount = 0;
1509 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1514 if ($deja_regle > 0) {
1518 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1519 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1520 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1521 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1524 $pdf->SetTextColor(0, 0, 60);
1525 $pdf->SetFillColor(224, 224, 224);
1526 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1527 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L',
true);
1529 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1530 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1532 $pdf->SetFont(
'',
'', $default_font_size - 1);
1533 $pdf->SetTextColor(0, 0, 0);
1536 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1538 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1540 $this->error = $hookmanager->error;
1541 $this->errors = $hookmanager->errors;
1545 return ($tab2_top + ($tab2_hl * $index));
1622 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1625 global $conf, $langs, $hookmanager,
$mysoc;
1627 $ltrdirection =
'L';
1628 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1629 $ltrdirection =
'R';
1633 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1639 $pdf->SetTextColor(0, 0, 60);
1640 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1644 $posy = $this->marge_haute;
1645 $posx = $this->page_largeur - $this->marge_droite - $w;
1647 $pdf->SetXY($this->marge_gauche, $posy);
1651 if ($this->emetteur->logo) {
1652 $logodir = $conf->mycompany->dir_output;
1657 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1659 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1661 if (is_readable($logo)) {
1663 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1665 $pdf->SetTextColor(200, 0, 0);
1666 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1667 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1668 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1671 $text = $this->emetteur->name;
1672 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1676 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1677 $pdf->SetXY($posx, $posy);
1678 $pdf->SetTextColor(0, 0, 60);
1679 $title = $outputlangs->transnoentities($titlekey);
1680 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1682 $title .= $outputlangsbis->transnoentities($titlekey);
1684 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1685 if (
$object->statut == $object::STATUS_DRAFT) {
1686 $pdf->SetTextColor(128, 0, 0);
1687 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1690 $pdf->MultiCell($w, 3, $title,
'',
'R');
1692 $pdf->SetFont(
'',
'B', $default_font_size);
1707 $pdf->SetFont(
'',
'', $default_font_size - 2);
1711 $pdf->SetXY($posx, $posy);
1712 $pdf->SetTextColor(0, 0, 60);
1713 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1718 if (!empty(
$object->project->ref)) {
1720 $pdf->SetXY($posx, $posy);
1721 $pdf->SetTextColor(0, 0, 60);
1722 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1728 if (!empty(
$object->project->ref)) {
1729 $outputlangs->load(
"projects");
1731 $pdf->SetXY($posx, $posy);
1732 $pdf->SetTextColor(0, 0, 60);
1733 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1739 $pdf->SetXY($posx, $posy);
1740 $pdf->SetTextColor(0, 0, 60);
1741 $title = $outputlangs->transnoentities(
"OrderDate");
1742 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1743 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1745 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1749 $pdf->SetXY($posx, $posy);
1750 $pdf->SetTextColor(0, 0, 60);
1751 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1756 $pdf->SetXY($posx, $posy);
1757 $pdf->SetTextColor(0, 0, 60);
1758 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1763 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1764 if (count($arrayidcontact) > 0) {
1765 $usertmp =
new User($this->db);
1766 $usertmp->fetch($arrayidcontact[0]);
1768 $pdf->SetXY($posx, $posy);
1769 $pdf->SetTextColor(0, 0, 60);
1770 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1779 $current_y = $pdf->getY();
1781 if ($current_y < $pdf->getY()) {
1782 $top_shift = $pdf->getY() - $current_y;
1787 $carac_emetteur =
'';
1789 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1790 if (count($arrayidcontact) > 0) {
1791 $object->fetch_user($arrayidcontact[0]);
1792 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1793 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1795 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1799 $carac_emetteur .=
"\n";
1806 $posy += $top_shift;
1807 $posx = $this->marge_gauche;
1809 $posx = $this->page_largeur - $this->marge_droite - 80;
1813 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1818 $pdf->SetTextColor(0, 0, 0);
1819 $pdf->SetFont(
'',
'', $default_font_size - 2);
1820 $pdf->SetXY($posx, $posy - 5);
1821 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1822 $pdf->SetXY($posx, $posy);
1823 $pdf->SetFillColor(230, 230, 230);
1824 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1825 $pdf->SetTextColor(0, 0, 60);
1830 $pdf->SetXY($posx + 2, $posy + 3);
1831 $pdf->SetFont(
'',
'B', $default_font_size);
1832 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1833 $posy = $pdf->getY();
1837 $pdf->SetXY($posx + 2, $posy);
1838 $pdf->SetFont(
'',
'', $default_font_size - 1);
1839 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1842 $usecontact =
false;
1843 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1844 if (count($arrayidcontact) > 0) {
1846 $result =
$object->fetch_contact($arrayidcontact[0]);
1851 $thirdparty =
$object->contact;
1853 $thirdparty =
$object->thirdparty;
1856 if (is_object($thirdparty)) {
1859 $carac_client_name =
'';
1866 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1867 if ($this->page_largeur < 210) {
1871 $posy += $top_shift;
1872 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1874 $posx = $this->marge_gauche;
1879 $pdf->SetTextColor(0, 0, 0);
1880 $pdf->SetFont(
'',
'', $default_font_size - 2);
1881 $pdf->SetXY($posx + 2, $posy - 5);
1882 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1883 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1887 $pdf->SetXY($posx + 2, $posy + 3);
1888 $pdf->SetFont(
'',
'B', $default_font_size);
1890 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1892 $posy = $pdf->getY();
1895 $pdf->SetFont(
'',
'', $default_font_size - 1);
1896 $pdf->SetXY($posx + 2, $posy);
1898 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1902 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1904 if (!empty($idaddressshipping)) {
1905 $contactshipping =
$object->fetch_contact($idaddressshipping[0]);
1906 $companystatic =
new Societe($this->db);
1907 $companystatic->fetch(
$object->contact->fk_soc);
1914 if (!empty($carac_client_shipping)) {
1915 $posy += $hautcadre;
1920 $pdf->SetXY($posx + 2, $posy - 5);
1921 $pdf->SetFont(
'',
'', $default_font_size - 2);
1922 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
1923 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1926 $pdf->SetXY($posx + 2, $posy + 1);
1927 $pdf->SetFont(
'',
'B', $default_font_size);
1928 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1930 $posy = $pdf->getY();
1933 $pdf->SetXY($posx + 2, $posy);
1934 $pdf->SetFont(
'',
'', $default_font_size - 1);
1935 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1937 $shipp_shift += $hautcadre + 10;
1942 $pdf->SetTextColor(0, 0, 0);
1944 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);