173 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
176 global $user, $langs,
$conf,
$mysoc, $db, $hookmanager, $nblines;
178 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
180 if (!is_object($outputlangs)) {
181 $outputlangs = $langs;
185 $outputlangs->charset_output =
'ISO-8859-1';
189 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"sendginds",
"compta"));
196 global $outputlangsbis;
197 $outputlangsbis =
null;
201 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"sendginds",
"compta"));
204 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
209 $realpatharray = array();
210 $this->atleastonephoto =
false;
212 $objphoto =
new Product($this->db);
214 for ($i = 0; $i < $nblines; $i++) {
215 if (empty(
$object->lines[$i]->fk_product)) {
221 $objphoto->fetch(
$object->lines[$i]->fk_product);
224 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
225 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
227 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
228 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
233 foreach ($pdir as $midir) {
235 $entity = $objphoto->entity;
236 if ($entity !==
null &&
$conf->entity != $entity) {
237 $dir =
$conf->product->multidir_output[$entity].
'/'.$midir;
239 $dir =
$conf->product->dir_output.
'/'.$midir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
244 if ($obj[
'photo_vignette']) {
245 $filename = $obj[
'photo_vignette'];
247 $filename = $obj[
'photo'];
250 $filename = $obj[
'photo'];
253 $realpath = $dir.$filename;
255 $this->atleastonephoto =
true;
260 if ($realpath && $arephoto) {
261 $realpatharray[$i] = $realpath;
276 $file = $dir.
"/SPECIMEN.pdf";
280 $file = $dir.
"/".$objectref.
".pdf";
285 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir",
"Null dir");
289 if (!file_exists($dir)) {
291 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
296 if (file_exists($dir)) {
298 if (!is_object($hookmanager)) {
299 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
302 $hookmanager->initHooks(array(
'pdfgeneration'));
303 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
305 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
308 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
313 $pdf->setAutoPageBreak(
true, 0);
315 $heightforinfotot = 40;
317 $heightforfooter = $this->marge_basse + 8;
319 $heightforfooter += 6;
322 if (class_exists(
'TCPDF')) {
323 $pdf->setPrintHeader(
false);
324 $pdf->setPrintFooter(
false);
329 $logodir =
$conf->mycompany->dir_output;
330 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
333 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
334 $tplidx = $pdf->importPage(1);
339 $pdf->SetDrawColor(128, 128, 128);
341 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
342 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
343 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
344 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
345 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
347 $pdf->SetCompression(
false);
351 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
354 for ($i = 0; $i < $nblines; $i++) {
355 if (
$object->lines[$i]->remise_percent) {
356 $this->atleastonediscount++;
363 if (!empty($tplidx)) {
364 $pdf->useTemplate($tplidx);
367 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
368 $top_shift = $pagehead[
'top_shift'];
369 $shipp_shift = $pagehead[
'shipp_shift'];
370 $pdf->SetFont(
'',
'', $default_font_size - 1);
371 $pdf->MultiCell(0, 3,
'');
372 $pdf->SetTextColor(0, 0, 0);
375 $tab_top = 90 + $top_shift + $shipp_shift;
376 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
377 if (!$hidetop &&
getDolGlobalInt(
'MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
379 $tab_top_newpage += $this->tabTitleHeight;
382 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
384 $nexY = $tab_top - 1;
387 $height_incoterms = 0;
389 $desc_incoterms =
$object->getIncotermsForPDF();
390 if ($desc_incoterms) {
393 $pdf->SetFont(
'',
'', $default_font_size - 1);
394 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
395 $nexY = max($pdf->GetY(), $nexY);
396 $height_incoterms = $nexY - $tab_top;
399 $pdf->SetDrawColor(192, 192, 192);
400 $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');
402 $tab_top = $nexY + 6;
407 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
410 if (is_object(
$object->thirdparty)) {
411 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
412 $salerepobj =
new User($this->db);
413 $salerepobj->fetch($salereparray[0][
'id']);
414 if (!empty($salerepobj->signature)) {
415 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
420 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
421 if (!empty($extranote)) {
425 $pagenb = $pdf->getPage();
429 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
430 $pageposbeforenote = $pagenb;
437 $pdf->startTransaction();
439 $pdf->SetFont(
'',
'', $default_font_size - 1);
440 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
442 $pageposafternote = $pdf->getPage();
443 $posyafter = $pdf->GetY();
445 if ($pageposafternote > $pageposbeforenote) {
446 $pdf->rollbackTransaction(
true);
449 while ($pagenb < $pageposafternote) {
452 if (!empty($tplidx)) {
453 $pdf->useTemplate($tplidx);
459 $pdf->setTopMargin($tab_top_newpage);
461 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
465 $pdf->setPage($pageposbeforenote);
466 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
467 $pdf->SetFont(
'',
'', $default_font_size - 1);
468 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
469 $pageposafternote = $pdf->getPage();
471 $posyafter = $pdf->GetY();
473 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
474 $pdf->AddPage(
'',
'',
true);
477 $pdf->setPage($pageposafternote);
478 $pdf->setTopMargin($tab_top_newpage);
480 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
486 $i = $pageposbeforenote;
487 while ($i < $pageposafternote) {
491 $pdf->SetDrawColor(128, 128, 128);
493 if ($i > $pageposbeforenote) {
494 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
495 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
497 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
498 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
502 $pdf->setPageOrientation(
'',
true, 0);
509 $pdf->setPage($pageposafternote);
510 if (!empty($tplidx)) {
511 $pdf->useTemplate($tplidx);
516 $height_note = $posyafter - $tab_top_newpage;
517 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
520 $pdf->commitTransaction();
521 $posyafter = $pdf->GetY();
522 $height_note = $posyafter - $tab_top;
523 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
526 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
528 $pdf->AddPage(
'',
'',
true);
531 $pdf->setPage($pageposafternote);
532 if (!empty($tplidx)) {
533 $pdf->useTemplate($tplidx);
539 $posyafter = $tab_top_newpage;
543 $tab_height -= $height_note;
544 $tab_top = $posyafter + 6;
554 $pdf->startTransaction();
555 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
556 $pdf->rollbackTransaction(
true);
558 $nexY = $tab_top + $this->tabTitleHeight;
561 $pageposbeforeprintlines = $pdf->getPage();
562 $pagenb = $pageposbeforeprintlines;
564 $pdf_sub_options = array();
565 $pdf_sub_options[
'titleshowuponpdf'] = 1;
566 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
568 for ($i = 0; $i < $nblines; $i++) {
569 $linePosition = $i + 1;
572 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
574 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
575 $level =
$object->lines[$i]->qty;
577 if (isset($sub_options[
'titleshowuponpdf'])) {
578 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
579 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
580 unset($pdf_sub_options[
'titleshowuponpdf']);
582 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
583 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
584 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
585 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
588 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
589 unset($pdf_sub_options[
'titleshowuponpdf']);
591 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
592 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
597 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
598 $object->lines[$i]->pagebreak =
true;
602 if (isset(
$object->lines[$i]->pagebreak) &&
$object->lines[$i]->pagebreak) {
605 if (!empty($tplidx)) {
606 $pdf->useTemplate($tplidx);
609 $pdf->setPage($pdf->getNumPages());
610 $nexY = $curY = $tab_top_newpage;
616 $pdf->SetFont(
'',
'', $default_font_size - 1);
617 $pdf->SetTextColor(0, 0, 0);
620 $imglinesize = array();
621 if (!empty($realpatharray[$i])) {
625 $pdf->setTopMargin($tab_top_newpage);
626 $pdf->setPageOrientation(
'',
true, $heightforfooter);
627 $pageposbefore = $pdf->getPage();
631 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
637 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imageTopMargin + $imglinesize[
'height']) > ($this->page_hauteur - $heightforfooter)) {
638 $pdf->AddPage(
'',
'',
true);
639 if (!empty($tplidx)) {
640 $pdf->useTemplate($tplidx);
642 $pdf->setPage($pageposbefore + 1);
643 $pdf->setPageOrientation(
'',
true, $heightforfooter);
644 $curY = $tab_top_newpage;
645 $showpricebeforepagebreak = 0;
652 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
653 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + $imageTopMargin, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
655 $posYAfterImage = $curY + $imglinesize[
'height'];
661 $pdf->setPageOrientation(
'',
true, $heightforfooter);
665 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
670 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
675 $pdf->setPage($pageposbefore);
676 $pdf->setTopMargin($this->marge_haute);
677 $pdf->setPageOrientation(
'',
false, $heightforfooter);
680 if ($afterPosData[
'page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
681 $pdf->setPage($afterPosData[
'page']);
682 $curY = $tab_top_newpage;
685 $pdf->SetFont(
'',
'', $default_font_size - 1);
699 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
719 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
726 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
729 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
731 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
733 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
746 if (!empty(
$object->lines[$i]->array_options)) {
747 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
762 'nexY' => & $afterPosData[
'y'],
763 'outputlangs' => $outputlangs,
764 'hidedetails' => $hidedetails
766 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
771 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
773 $tvaligne =
$object->lines[$i]->total_tva;
776 $localtax1ligne =
$object->lines[$i]->total_localtax1;
777 $localtax2ligne =
$object->lines[$i]->total_localtax2;
778 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
779 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
780 $localtax1_type =
$object->lines[$i]->localtax1_type;
781 $localtax2_type =
$object->lines[$i]->localtax2_type;
786 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
787 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
789 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
790 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
794 if ($localtax1_type && $localtax1ligne != 0) {
795 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
796 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
798 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
801 if ($localtax2_type && $localtax2ligne != 0) {
802 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
803 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
805 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
809 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
814 if (!isset($this->tva[$vatrate])) {
815 $this->tva[$vatrate] = 0;
817 $this->tva[$vatrate] += $tvaligne;
818 $vatcode =
$object->lines[$i]->vat_src_code;
819 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
820 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
822 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
825 $pdf->setPage($afterPosData[
'page']);
826 $nexY = $afterPosData[
'y'];
829 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $heightforfooter - 5) {
830 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
832 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
833 $pdf->SetLineStyle(array(
'dash' => 0));
841 if (isset($afterPosData[
'y']) && $afterPosData[
'y'] > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
843 if (!empty($tplidx)) {
844 $pdf->useTemplate($tplidx);
847 $pdf->setPage($pagenb);
851 $drawTabNumbPage = $pdf->getNumPages();
852 for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) {
855 $pdf->setPageOrientation(
'',
false, 0);
857 $drawTabHideTop = $hidetop;
858 $drawTabTop = $tab_top_newpage;
859 $drawTabBottom = $this->page_hauteur - $heightforfooter;
862 if ($i == $pageposbeforeprintlines) {
864 $drawTabTop = $tab_top;
865 } elseif (!$drawTabHideTop) {
867 $drawTabTop -= $this->tabTitleHeight;
874 if ($i == $pdf->getNumPages()) {
876 $drawTabBottom -= $heightforfreetext + $heightforinfotot;
879 $drawTabHeight = $drawTabBottom - $drawTabTop;
880 $this->
_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom,
$object->multicurrency_code, $outputlangsbis);
882 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0;
888 $pdf->setPageOrientation(
'',
true, 0);
891 if (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
894 if (!empty($tplidx)) {
895 $pdf->useTemplate($tplidx);
900 $pdf->SetTextColor(0, 0, 0);
902 $pdf->setPage($pdf->getNumPages());
904 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
914 if (method_exists($pdf,
'AliasNbPages')) {
915 $pdf->AliasNbPages();
920 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_ORDER') && $termsofsalefilename) {
921 $termsofsale =
$conf->order->dir_output.
'/'.$termsofsalefilename;
922 if (!empty(
$conf->order->multidir_output[
$conf->entity])) {
923 $termsofsale =
$conf->order->multidir_output[
$conf->entity].
'/'.$termsofsalefilename;
925 if (file_exists($termsofsale) && is_readable($termsofsale)) {
926 $pagecount = $pdf->setSourceFile($termsofsale);
927 for ($i = 1; $i <= $pagecount; $i++) {
928 $tplIdx = $pdf->importPage($i);
929 if ($tplIdx !==
false) {
930 $s = $pdf->getTemplatesize($tplIdx);
931 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
932 $pdf->useTemplate($tplIdx);
934 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
942 $pdf->Output($file,
'F');
945 $hookmanager->initHooks(array(
'pdfgeneration'));
946 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
948 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
949 $this->warnings = $hookmanager->warnings;
951 $this->error = $hookmanager->error;
952 $this->errors = $hookmanager->errors;
959 $this->result = array(
'fullpath' => $file);
963 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
967 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
1000 $pdf->SetFont(
'',
'', $default_font_size - 1);
1005 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
1006 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1007 $pdf->SetXY($this->marge_gauche, $posy);
1008 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1010 $posy = $pdf->GetY() + 4;
1019 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1020 $pdf->SetXY($this->marge_gauche, $posy);
1021 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1022 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1024 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1025 $pdf->SetXY($posxval, $posy);
1026 $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);
1027 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1028 if (
$object->deposit_percent > 0) {
1029 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
1031 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1033 $posy = $pdf->GetY() + 3;
1064 if (!empty(
$object->delivery_date)) {
1065 $outputlangs->load(
"sendings");
1066 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1067 $pdf->SetXY($this->marge_gauche, $posy);
1068 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1069 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1070 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1071 $pdf->SetXY($posxval, $posy);
1073 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1075 $posy = $pdf->GetY() + 1;
1077 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1078 $pdf->SetXY($this->marge_gauche, $posy);
1079 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1080 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1081 $pdf->SetTextColor(0, 0, 0);
1082 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1083 $pdf->SetXY($posxval, $posy);
1084 $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 :
'');
1085 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1086 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1088 $posy = $pdf->GetY() + 1;
1092 if (
$object->mode_reglement_code
1093 &&
$object->mode_reglement_code !=
'CHQ'
1094 &&
$object->mode_reglement_code !=
'VIR') {
1095 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1096 $pdf->SetXY($this->marge_gauche, $posy);
1097 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1098 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1100 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1101 $pdf->SetXY($posxval, $posy);
1102 $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);
1103 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1105 $posy = $pdf->GetY() + 2;
1109 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1113 $account =
new Account($this->db);
1116 $pdf->SetXY($this->marge_gauche, $posy);
1117 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1118 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1119 $posy = $pdf->GetY() + 1;
1122 $pdf->SetXY($this->marge_gauche, $posy);
1123 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1124 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1125 $posy = $pdf->GetY() + 2;
1129 $pdf->SetXY($this->marge_gauche, $posy);
1130 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1131 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1132 $posy = $pdf->GetY() + 1;
1135 $pdf->SetXY($this->marge_gauche, $posy);
1136 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1137 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1138 $posy = $pdf->GetY() + 2;
1145 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1147 $bankid = (
$object->fk_account <= 0 ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1151 $account =
new Account($this->db);
1152 $account->fetch($bankid);
1154 $curx = $this->marge_gauche;
1157 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1187 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1188 $default_font_size--;
1193 $pdf->SetFont(
'',
'', $default_font_size - 1);
1198 if ($this->page_largeur < 210) {
1201 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1210 $total_discount_on_lines = 0;
1211 $multicurrency_total_discount_on_lines = 0;
1212 foreach (
$object->lines as $i => $line) {
1216 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1217 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1219 if ($line->total_ht < 0) {
1220 $total_discount_on_lines += -$line->total_ht;
1221 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1225 if ($total_discount_on_lines > 0) {
1226 if ($this->showAmountBeforeDiscount) {
1228 $pdf->SetFillColor(255, 255, 255);
1229 $pdf->SetXY($col1x, $tab2_top);
1230 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1231 $pdf->SetXY($col2x, $tab2_top);
1233 $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));
1234 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1239 if ($this->showDiscountAmount) {
1240 $pdf->SetFillColor(255, 255, 255);
1241 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1242 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1243 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1245 $total_discount_to_show = ((
isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1246 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1253 $pdf->SetFillColor(255, 255, 255);
1254 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1255 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1257 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1258 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1261 $pdf->SetFillColor(248, 248, 248);
1264 $total_ttc_origin =
$object->total_ttc;
1266 $this->atleastoneratenotnull = 0;
1268 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1269 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1273 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1274 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1277 foreach ($localtax_rate as $tvakey => $tvaval) {
1281 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1284 if (preg_match(
'/\*/', (
string) $tvakey)) {
1285 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1286 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1288 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1292 $totalvat .= $tvacompl;
1294 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1297 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1301 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1302 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1308 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1309 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1312 foreach ($localtax_rate as $tvakey => $tvaval) {
1317 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1320 if (preg_match(
'/\*/', (
string) $tvakey)) {
1321 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1322 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1324 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1328 $totalvat .= $tvacompl;
1330 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1333 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1337 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1338 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1344 foreach ($this->tva_array as $tvakey => $tvaval) {
1346 $this->atleastoneratenotnull++;
1349 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1352 if (preg_match(
'/\*/', $tvakey)) {
1353 $tvakey = str_replace(
'*',
'', $tvakey);
1354 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1356 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1359 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1361 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1363 $totalvat .= $tvacompl;
1365 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1367 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1369 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1370 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1375 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1376 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1380 foreach ($localtax_rate as $tvakey => $tvaval) {
1385 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1388 if (preg_match(
'/\*/', (
string) $tvakey)) {
1389 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1390 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1392 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1396 $totalvat .= $tvacompl;
1398 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1401 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1405 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1406 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1412 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1413 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1417 foreach ($localtax_rate as $tvakey => $tvaval) {
1423 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1426 if (preg_match(
'/\*/', (
string) $tvakey)) {
1427 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1428 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1430 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1434 $totalvat .= $tvacompl;
1436 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1439 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1443 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1444 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1452 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1453 $pdf->SetTextColor(0, 0, 60);
1454 $pdf->SetFillColor(224, 224, 224);
1455 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC",
$mysoc->country_code) :
''), $useborder,
'L',
true);
1457 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1459 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1461 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1465 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1466 $pdf->SetTextColor(0, 0, 60);
1467 $pdf->SetFillColor(224, 224, 224);
1468 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1470 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1471 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1476 $pdf->SetTextColor(0, 0, 0);
1478 $creditnoteamount = 0;
1479 $depositsamount = 0;
1483 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1488 if ($deja_regle > 0) {
1492 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1493 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1494 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1495 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1498 $pdf->SetTextColor(0, 0, 60);
1499 $pdf->SetFillColor(224, 224, 224);
1500 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1501 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L',
true);
1503 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1504 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1506 $pdf->SetFont(
'',
'', $default_font_size - 1);
1507 $pdf->SetTextColor(0, 0, 0);
1510 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1512 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1514 $this->error = $hookmanager->error;
1515 $this->errors = $hookmanager->errors;
1519 return ($tab2_top + ($tab2_hl * $index));
1596 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1601 $ltrdirection =
'L';
1602 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1603 $ltrdirection =
'R';
1607 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1613 $pdf->SetTextColor(0, 0, 60);
1614 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1618 $posy = $this->marge_haute;
1619 $posx = $this->page_largeur - $this->marge_droite - $w;
1621 $pdf->SetXY($this->marge_gauche, $posy);
1625 if ($this->emetteur->logo) {
1626 $logodir =
$conf->mycompany->dir_output;
1631 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1633 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1635 if (is_readable($logo)) {
1637 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1639 $pdf->SetTextColor(200, 0, 0);
1640 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1641 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1642 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1645 $text = $this->emetteur->name;
1646 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1650 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1651 $pdf->SetXY($posx, $posy);
1652 $pdf->SetTextColor(0, 0, 60);
1653 $title = $outputlangs->transnoentities($titlekey);
1654 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1656 $title .= $outputlangsbis->transnoentities($titlekey);
1658 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1659 if (
$object->status == $object::STATUS_DRAFT) {
1660 $pdf->SetTextColor(128, 0, 0);
1661 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1664 $pdf->MultiCell($w, 3, $title,
'',
'R');
1666 $pdf->SetFont(
'',
'B', $default_font_size);
1681 $pdf->SetFont(
'',
'', $default_font_size - 2);
1685 $pdf->SetXY($posx, $posy);
1686 $pdf->SetTextColor(0, 0, 60);
1687 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset((
string)
$object->ref_client), 65),
'',
'R');
1692 if (!empty(
$object->project->ref)) {
1694 $pdf->SetXY($posx, $posy);
1695 $pdf->SetTextColor(0, 0, 60);
1696 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1702 if (!empty(
$object->project->ref)) {
1703 $outputlangs->load(
"projects");
1705 $pdf->SetXY($posx, $posy);
1706 $pdf->SetTextColor(0, 0, 60);
1707 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1713 $pdf->SetXY($posx, $posy);
1714 $pdf->SetTextColor(0, 0, 60);
1715 $title = $outputlangs->transnoentities(
"OrderDate");
1716 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1717 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1719 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1723 $pdf->SetXY($posx, $posy);
1724 $pdf->SetTextColor(0, 0, 60);
1725 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
1730 $pdf->SetXY($posx, $posy);
1731 $pdf->SetTextColor(0, 0, 60);
1732 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_compta_client),
'',
'R');
1737 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1738 if (count($arrayidcontact) > 0) {
1739 $usertmp =
new User($this->db);
1740 $usertmp->fetch($arrayidcontact[0]);
1742 $pdf->SetXY($posx, $posy);
1743 $pdf->SetTextColor(0, 0, 60);
1744 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1753 $current_y = $pdf->getY();
1755 if ($current_y < $pdf->getY()) {
1756 $top_shift = $pdf->getY() - $current_y;
1761 $carac_emetteur =
'';
1763 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1764 if (count($arrayidcontact) > 0) {
1765 $object->fetch_user($arrayidcontact[0]);
1766 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1767 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1769 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1773 $carac_emetteur .=
"\n";
1780 $posy += $top_shift;
1781 $posx = $this->marge_gauche;
1783 $posx = $this->page_largeur - $this->marge_droite - 80;
1787 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1792 $pdf->SetTextColor(0, 0, 0);
1793 $pdf->SetFont(
'',
'', $default_font_size - 2);
1794 $pdf->SetXY($posx, $posy - 5);
1795 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1796 $pdf->SetXY($posx, $posy);
1797 $pdf->SetFillColor(230, 230, 230);
1798 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1799 $pdf->SetTextColor(0, 0, 60);
1804 $pdf->SetXY($posx + 2, $posy + 3);
1805 $pdf->SetFont(
'',
'B', $default_font_size);
1806 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1807 $posy = $pdf->getY();
1811 $pdf->SetXY($posx + 2, $posy);
1812 $pdf->SetFont(
'',
'', $default_font_size - 1);
1813 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1816 $usecontact =
false;
1817 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1818 if (count($arrayidcontact) > 0) {
1820 $result =
$object->fetch_contact($arrayidcontact[0]);
1825 $thirdparty =
$object->contact;
1827 $thirdparty =
$object->thirdparty;
1830 if (is_object($thirdparty)) {
1833 $carac_client_name =
'';
1840 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1841 if ($this->page_largeur < 210) {
1845 $posy += $top_shift;
1846 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1848 $posx = $this->marge_gauche;
1853 $pdf->SetTextColor(0, 0, 0);
1854 $pdf->SetFont(
'',
'', $default_font_size - 2);
1855 $pdf->SetXY($posx + 2, $posy - 5);
1856 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1857 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1861 $pdf->SetXY($posx + 2, $posy + 3);
1862 $pdf->SetFont(
'',
'B', $default_font_size);
1864 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1866 $posy = $pdf->getY();
1869 $pdf->SetFont(
'',
'', $default_font_size - 1);
1870 $pdf->SetXY($posx + 2, $posy);
1872 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1876 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1878 if (!empty($idaddressshipping)) {
1879 $contactshipping =
$object->fetch_contact($idaddressshipping[0]);
1880 $companystatic =
new Societe($this->db);
1881 $companystatic->fetch(
$object->contact->fk_soc);
1888 if (!empty($carac_client_shipping)) {
1889 $posy += $hautcadre;
1894 $pdf->SetXY($posx + 2, $posy - 5);
1895 $pdf->SetFont(
'',
'', $default_font_size - 2);
1896 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
1897 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1900 $pdf->SetXY($posx + 2, $posy + 1);
1901 $pdf->SetFont(
'',
'B', $default_font_size);
1902 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1904 $posy = $pdf->getY();
1907 $pdf->SetXY($posx + 2, $posy);
1908 $pdf->SetFont(
'',
'', $default_font_size - 1);
1909 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1911 $shipp_shift += $hautcadre + 10;
1916 $pdf->SetTextColor(0, 0, 0);
1918 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);