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;
564 for ($i = 0; $i < $nblines; $i++) {
565 $linePosition = $i + 1;
568 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
570 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
571 $level =
$object->lines[$i]->qty;
573 if (isset($sub_options[
'titleshowuponpdf'])) {
574 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
575 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
576 unset($pdf_sub_options[
'titleshowuponpdf']);
578 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
579 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
580 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
581 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
584 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
585 unset($pdf_sub_options[
'titleshowuponpdf']);
587 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
588 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
593 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
594 $object->lines[$i]->pagebreak =
true;
598 if (isset(
$object->lines[$i]->pagebreak) &&
$object->lines[$i]->pagebreak) {
601 if (!empty($tplidx)) {
602 $pdf->useTemplate($tplidx);
605 $pdf->setPage($pdf->getNumPages());
606 $nexY = $curY = $tab_top_newpage;
612 $pdf->SetFont(
'',
'', $default_font_size - 1);
613 $pdf->SetTextColor(0, 0, 0);
616 $imglinesize = array();
617 if (!empty($realpatharray[$i])) {
621 $pdf->setTopMargin($tab_top_newpage);
622 $pdf->setPageOrientation(
'',
true, $heightforfooter);
623 $pageposbefore = $pdf->getPage();
627 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
633 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imageTopMargin + $imglinesize[
'height']) > ($this->page_hauteur - $heightforfooter)) {
634 $pdf->AddPage(
'',
'',
true);
635 if (!empty($tplidx)) {
636 $pdf->useTemplate($tplidx);
638 $pdf->setPage($pageposbefore + 1);
639 $pdf->setPageOrientation(
'',
true, $heightforfooter);
640 $curY = $tab_top_newpage;
641 $showpricebeforepagebreak = 0;
648 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
649 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + $imageTopMargin, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
651 $posYAfterImage = $curY + $imglinesize[
'height'];
657 $pdf->setPageOrientation(
'',
true, $heightforfooter);
661 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
666 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
671 $pdf->setPage($pageposbefore);
672 $pdf->setTopMargin($this->marge_haute);
673 $pdf->setPageOrientation(
'',
false, $heightforfooter);
676 if ($afterPosData[
'page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
677 $pdf->setPage($afterPosData[
'page']);
678 $curY = $tab_top_newpage;
681 $pdf->SetFont(
'',
'', $default_font_size - 1);
695 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
715 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
722 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
725 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
727 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
729 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
742 if (!empty(
$object->lines[$i]->array_options)) {
743 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
758 'nexY' => & $afterPosData[
'y'],
759 'outputlangs' => $outputlangs,
760 'hidedetails' => $hidedetails
762 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
767 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
769 $tvaligne =
$object->lines[$i]->total_tva;
772 $localtax1ligne =
$object->lines[$i]->total_localtax1;
773 $localtax2ligne =
$object->lines[$i]->total_localtax2;
774 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
775 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
776 $localtax1_type =
$object->lines[$i]->localtax1_type;
777 $localtax2_type =
$object->lines[$i]->localtax2_type;
779 $vatrate = (string)
$object->lines[$i]->tva_tx;
782 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
783 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
785 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
786 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
790 if ($localtax1_type && $localtax1ligne != 0) {
791 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
792 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
794 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
797 if ($localtax2_type && $localtax2ligne != 0) {
798 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
799 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
801 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
805 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
810 if (!isset($this->tva[$vatrate])) {
811 $this->tva[$vatrate] = 0;
813 $this->tva[$vatrate] += $tvaligne;
814 $vatcode =
$object->lines[$i]->vat_src_code;
815 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
816 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
818 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
821 $pdf->setPage($afterPosData[
'page']);
822 $nexY = $afterPosData[
'y'];
825 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $heightforfooter - 5) {
826 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
828 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
829 $pdf->SetLineStyle(array(
'dash' => 0));
837 if (isset($afterPosData[
'y']) && $afterPosData[
'y'] > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
839 if (!empty($tplidx)) {
840 $pdf->useTemplate($tplidx);
843 $pdf->setPage($pagenb);
847 $drawTabNumbPage = $pdf->getNumPages();
848 for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) {
851 $pdf->setPageOrientation(
'',
false, 0);
853 $drawTabHideTop = $hidetop;
854 $drawTabTop = $tab_top_newpage;
855 $drawTabBottom = $this->page_hauteur - $heightforfooter;
858 if ($i == $pageposbeforeprintlines) {
860 $drawTabTop = $tab_top;
861 } elseif (!$drawTabHideTop) {
863 $drawTabTop -= $this->tabTitleHeight;
870 if ($i == $pdf->getNumPages()) {
872 $drawTabBottom -= $heightforfreetext + $heightforinfotot;
875 $drawTabHeight = $drawTabBottom - $drawTabTop;
876 $this->
_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom,
$object->multicurrency_code, $outputlangsbis);
878 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0;
884 $pdf->setPageOrientation(
'',
true, 0);
887 if (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
890 if (!empty($tplidx)) {
891 $pdf->useTemplate($tplidx);
896 $pdf->SetTextColor(0, 0, 0);
898 $pdf->setPage($pdf->getNumPages());
900 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
910 if (method_exists($pdf,
'AliasNbPages')) {
911 $pdf->AliasNbPages();
916 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_ORDER') && $termsofsalefilename) {
917 $termsofsale = $conf->order->dir_output.
'/'.$termsofsalefilename;
918 if (!empty($conf->order->multidir_output[$conf->entity])) {
919 $termsofsale = $conf->order->multidir_output[$conf->entity].
'/'.$termsofsalefilename;
921 if (file_exists($termsofsale) && is_readable($termsofsale)) {
922 $pagecount = $pdf->setSourceFile($termsofsale);
923 for ($i = 1; $i <= $pagecount; $i++) {
924 $tplIdx = $pdf->importPage($i);
925 if ($tplIdx !==
false) {
926 $s = $pdf->getTemplatesize($tplIdx);
927 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
928 $pdf->useTemplate($tplIdx);
930 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
938 $pdf->Output($file,
'F');
941 $hookmanager->initHooks(array(
'pdfgeneration'));
942 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
944 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
945 $this->warnings = $hookmanager->warnings;
947 $this->error = $hookmanager->error;
948 $this->errors = $hookmanager->errors;
955 $this->result = array(
'fullpath' => $file);
959 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
963 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
996 $pdf->SetFont(
'',
'', $default_font_size - 1);
1001 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
1002 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1003 $pdf->SetXY($this->marge_gauche, $posy);
1004 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1006 $posy = $pdf->GetY() + 4;
1015 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1016 $pdf->SetXY($this->marge_gauche, $posy);
1017 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1018 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1020 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1021 $pdf->SetXY($posxval, $posy);
1022 $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);
1023 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1024 if (
$object->deposit_percent > 0) {
1025 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
1027 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1029 $posy = $pdf->GetY() + 3;
1060 if (!empty(
$object->delivery_date)) {
1061 $outputlangs->load(
"sendings");
1062 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1063 $pdf->SetXY($this->marge_gauche, $posy);
1064 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1065 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1066 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1067 $pdf->SetXY($posxval, $posy);
1069 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1071 $posy = $pdf->GetY() + 1;
1073 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1074 $pdf->SetXY($this->marge_gauche, $posy);
1075 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1076 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1077 $pdf->SetTextColor(0, 0, 0);
1078 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1079 $pdf->SetXY($posxval, $posy);
1080 $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 :
'');
1081 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1082 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1084 $posy = $pdf->GetY() + 1;
1088 if (
$object->mode_reglement_code
1089 &&
$object->mode_reglement_code !=
'CHQ'
1090 &&
$object->mode_reglement_code !=
'VIR') {
1091 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1092 $pdf->SetXY($this->marge_gauche, $posy);
1093 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1094 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1096 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1097 $pdf->SetXY($posxval, $posy);
1098 $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);
1099 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1101 $posy = $pdf->GetY() + 2;
1105 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1109 $account =
new Account($this->db);
1112 $pdf->SetXY($this->marge_gauche, $posy);
1113 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1114 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1115 $posy = $pdf->GetY() + 1;
1118 $pdf->SetXY($this->marge_gauche, $posy);
1119 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1120 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1121 $posy = $pdf->GetY() + 2;
1125 $pdf->SetXY($this->marge_gauche, $posy);
1126 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1127 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1128 $posy = $pdf->GetY() + 1;
1131 $pdf->SetXY($this->marge_gauche, $posy);
1132 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1133 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1134 $posy = $pdf->GetY() + 2;
1141 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1143 $bankid = (
$object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1147 $account =
new Account($this->db);
1148 $account->fetch($bankid);
1150 $curx = $this->marge_gauche;
1153 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1176 global $conf,
$mysoc, $hookmanager;
1181 $outputlangsbis =
new Translate(
'', $conf);
1183 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1184 $default_font_size--;
1189 $pdf->SetFont(
'',
'', $default_font_size - 1);
1194 if ($this->page_largeur < 210) {
1197 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1206 $total_discount_on_lines = 0;
1207 $multicurrency_total_discount_on_lines = 0;
1208 foreach (
$object->lines as $i => $line) {
1212 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1213 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1215 if ($line->total_ht < 0) {
1216 $total_discount_on_lines += -$line->total_ht;
1217 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1221 if ($total_discount_on_lines > 0) {
1223 $pdf->SetFillColor(255, 255, 255);
1224 $pdf->SetXY($col1x, $tab2_top);
1225 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1226 $pdf->SetXY($col2x, $tab2_top);
1228 $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));
1229 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1233 $pdf->SetFillColor(255, 255, 255);
1234 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1235 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1236 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1238 $total_discount_to_show = ((
isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1239 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1245 $pdf->SetFillColor(255, 255, 255);
1246 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1247 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1249 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1250 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1253 $pdf->SetFillColor(248, 248, 248);
1256 $total_ttc_origin =
$object->total_ttc;
1258 $this->atleastoneratenotnull = 0;
1260 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1261 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1265 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1266 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1269 foreach ($localtax_rate as $tvakey => $tvaval) {
1273 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1276 if (preg_match(
'/\*/', (
string) $tvakey)) {
1277 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1278 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1280 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1284 $totalvat .= $tvacompl;
1286 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1289 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1293 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1294 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1300 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1301 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1304 foreach ($localtax_rate as $tvakey => $tvaval) {
1309 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1312 if (preg_match(
'/\*/', (
string) $tvakey)) {
1313 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1314 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1316 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1320 $totalvat .= $tvacompl;
1322 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1325 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1329 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1330 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1336 foreach ($this->tva_array as $tvakey => $tvaval) {
1338 $this->atleastoneratenotnull++;
1341 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1344 if (preg_match(
'/\*/', $tvakey)) {
1345 $tvakey = str_replace(
'*',
'', $tvakey);
1346 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1348 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1351 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1353 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1355 $totalvat .= $tvacompl;
1357 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1359 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1361 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1362 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1367 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1368 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1372 foreach ($localtax_rate as $tvakey => $tvaval) {
1377 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1380 if (preg_match(
'/\*/', (
string) $tvakey)) {
1381 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1382 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1384 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1388 $totalvat .= $tvacompl;
1390 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1393 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1397 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1398 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1404 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1405 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1409 foreach ($localtax_rate as $tvakey => $tvaval) {
1415 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1418 if (preg_match(
'/\*/', (
string) $tvakey)) {
1419 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1420 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1422 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1426 $totalvat .= $tvacompl;
1428 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1431 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1435 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1436 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1444 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1445 $pdf->SetTextColor(0, 0, 60);
1446 $pdf->SetFillColor(224, 224, 224);
1447 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC",
$mysoc->country_code) :
''), $useborder,
'L',
true);
1449 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1451 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1453 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1457 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1458 $pdf->SetTextColor(0, 0, 60);
1459 $pdf->SetFillColor(224, 224, 224);
1460 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1462 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1463 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1468 $pdf->SetTextColor(0, 0, 0);
1470 $creditnoteamount = 0;
1471 $depositsamount = 0;
1475 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1480 if ($deja_regle > 0) {
1484 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1485 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1486 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1487 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1490 $pdf->SetTextColor(0, 0, 60);
1491 $pdf->SetFillColor(224, 224, 224);
1492 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1493 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L',
true);
1495 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1496 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1498 $pdf->SetFont(
'',
'', $default_font_size - 1);
1499 $pdf->SetTextColor(0, 0, 0);
1502 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1504 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1506 $this->error = $hookmanager->error;
1507 $this->errors = $hookmanager->errors;
1511 return ($tab2_top + ($tab2_hl * $index));
1588 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1591 global $conf, $langs, $hookmanager,
$mysoc;
1593 $ltrdirection =
'L';
1594 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1595 $ltrdirection =
'R';
1599 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1605 $pdf->SetTextColor(0, 0, 60);
1606 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1610 $posy = $this->marge_haute;
1611 $posx = $this->page_largeur - $this->marge_droite - $w;
1613 $pdf->SetXY($this->marge_gauche, $posy);
1617 if ($this->emetteur->logo) {
1618 $logodir = $conf->mycompany->dir_output;
1623 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1625 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1627 if (is_readable($logo)) {
1629 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1631 $pdf->SetTextColor(200, 0, 0);
1632 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1633 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1634 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1637 $text = $this->emetteur->name;
1638 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1642 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1643 $pdf->SetXY($posx, $posy);
1644 $pdf->SetTextColor(0, 0, 60);
1645 $title = $outputlangs->transnoentities($titlekey);
1646 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1648 $title .= $outputlangsbis->transnoentities($titlekey);
1650 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1651 if (
$object->statut == $object::STATUS_DRAFT) {
1652 $pdf->SetTextColor(128, 0, 0);
1653 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1656 $pdf->MultiCell($w, 3, $title,
'',
'R');
1658 $pdf->SetFont(
'',
'B', $default_font_size);
1673 $pdf->SetFont(
'',
'', $default_font_size - 2);
1677 $pdf->SetXY($posx, $posy);
1678 $pdf->SetTextColor(0, 0, 60);
1679 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1684 if (!empty(
$object->project->ref)) {
1686 $pdf->SetXY($posx, $posy);
1687 $pdf->SetTextColor(0, 0, 60);
1688 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1694 if (!empty(
$object->project->ref)) {
1695 $outputlangs->load(
"projects");
1697 $pdf->SetXY($posx, $posy);
1698 $pdf->SetTextColor(0, 0, 60);
1699 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1705 $pdf->SetXY($posx, $posy);
1706 $pdf->SetTextColor(0, 0, 60);
1707 $title = $outputlangs->transnoentities(
"OrderDate");
1708 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1709 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1711 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1715 $pdf->SetXY($posx, $posy);
1716 $pdf->SetTextColor(0, 0, 60);
1717 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1722 $pdf->SetXY($posx, $posy);
1723 $pdf->SetTextColor(0, 0, 60);
1724 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1729 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1730 if (count($arrayidcontact) > 0) {
1731 $usertmp =
new User($this->db);
1732 $usertmp->fetch($arrayidcontact[0]);
1734 $pdf->SetXY($posx, $posy);
1735 $pdf->SetTextColor(0, 0, 60);
1736 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1745 $current_y = $pdf->getY();
1747 if ($current_y < $pdf->getY()) {
1748 $top_shift = $pdf->getY() - $current_y;
1753 $carac_emetteur =
'';
1755 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1756 if (count($arrayidcontact) > 0) {
1757 $object->fetch_user($arrayidcontact[0]);
1758 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1759 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1761 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1765 $carac_emetteur .=
"\n";
1772 $posy += $top_shift;
1773 $posx = $this->marge_gauche;
1775 $posx = $this->page_largeur - $this->marge_droite - 80;
1779 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1784 $pdf->SetTextColor(0, 0, 0);
1785 $pdf->SetFont(
'',
'', $default_font_size - 2);
1786 $pdf->SetXY($posx, $posy - 5);
1787 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1788 $pdf->SetXY($posx, $posy);
1789 $pdf->SetFillColor(230, 230, 230);
1790 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1791 $pdf->SetTextColor(0, 0, 60);
1796 $pdf->SetXY($posx + 2, $posy + 3);
1797 $pdf->SetFont(
'',
'B', $default_font_size);
1798 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1799 $posy = $pdf->getY();
1803 $pdf->SetXY($posx + 2, $posy);
1804 $pdf->SetFont(
'',
'', $default_font_size - 1);
1805 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1808 $usecontact =
false;
1809 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1810 if (count($arrayidcontact) > 0) {
1812 $result =
$object->fetch_contact($arrayidcontact[0]);
1817 $thirdparty =
$object->contact;
1819 $thirdparty =
$object->thirdparty;
1822 if (is_object($thirdparty)) {
1825 $carac_client_name =
'';
1832 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1833 if ($this->page_largeur < 210) {
1837 $posy += $top_shift;
1838 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1840 $posx = $this->marge_gauche;
1845 $pdf->SetTextColor(0, 0, 0);
1846 $pdf->SetFont(
'',
'', $default_font_size - 2);
1847 $pdf->SetXY($posx + 2, $posy - 5);
1848 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1849 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1853 $pdf->SetXY($posx + 2, $posy + 3);
1854 $pdf->SetFont(
'',
'B', $default_font_size);
1856 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1858 $posy = $pdf->getY();
1861 $pdf->SetFont(
'',
'', $default_font_size - 1);
1862 $pdf->SetXY($posx + 2, $posy);
1864 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1868 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1870 if (!empty($idaddressshipping)) {
1871 $contactshipping =
$object->fetch_contact($idaddressshipping[0]);
1872 $companystatic =
new Societe($this->db);
1873 $companystatic->fetch(
$object->contact->fk_soc);
1880 if (!empty($carac_client_shipping)) {
1881 $posy += $hautcadre;
1886 $pdf->SetXY($posx + 2, $posy - 5);
1887 $pdf->SetFont(
'',
'', $default_font_size - 2);
1888 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
1889 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1892 $pdf->SetXY($posx + 2, $posy + 1);
1893 $pdf->SetFont(
'',
'B', $default_font_size);
1894 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1896 $posy = $pdf->getY();
1899 $pdf->SetXY($posx + 2, $posy);
1900 $pdf->SetFont(
'',
'', $default_font_size - 1);
1901 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1903 $shipp_shift += $hautcadre + 10;
1908 $pdf->SetTextColor(0, 0, 0);
1910 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);