170 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
173 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
175 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
177 if (!is_object($outputlangs)) {
178 $outputlangs = $langs;
182 $outputlangs->charset_output =
'ISO-8859-1';
186 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries",
"compta"));
193 global $outputlangsbis;
194 $outputlangsbis =
null;
198 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries",
"compta"));
201 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
206 $realpatharray = array();
207 $this->atleastonephoto =
false;
209 $objphoto =
new Product($this->db);
211 for ($i = 0; $i < $nblines; $i++) {
212 if (empty(
$object->lines[$i]->fk_product)) {
218 $objphoto->fetch(
$object->lines[$i]->fk_product);
221 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
222 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
224 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
225 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
229 foreach ($pdir as $midir) {
231 if (
$conf->entity != $objphoto->entity) {
232 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
234 $dir =
$conf->product->dir_output.
'/'.$midir;
237 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
239 if ($obj[
'photo_vignette']) {
240 $filename = $obj[
'photo_vignette'];
242 $filename = $obj[
'photo'];
245 $filename = $obj[
'photo'];
248 $realpath = $dir.$filename;
250 $this->atleastonephoto =
true;
255 if ($realpath && $arephoto) {
256 $realpatharray[$i] = $realpath;
271 $file = $dir.
"/SPECIMEN.pdf";
275 $file = $dir.
"/".$objectref.
".pdf";
278 if (!file_exists($dir)) {
280 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
285 if (file_exists($dir)) {
287 if (!is_object($hookmanager)) {
288 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
291 $hookmanager->initHooks(array(
'pdfgeneration'));
292 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
294 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
297 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
302 $pdf->SetAutoPageBreak(1, 0);
304 $heightforinfotot = 40;
306 $heightforfooter = $this->marge_basse + 8;
308 $heightforfooter += 6;
311 if (class_exists(
'TCPDF')) {
312 $pdf->setPrintHeader(
false);
313 $pdf->setPrintFooter(
false);
318 $logodir =
$conf->mycompany->dir_output;
319 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
320 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
322 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
323 $tplidx = $pdf->importPage(1);
328 $pdf->SetDrawColor(128, 128, 128);
330 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
331 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
332 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
333 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
334 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
336 $pdf->SetCompression(
false);
340 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
343 for ($i = 0; $i < $nblines; $i++) {
344 if (
$object->lines[$i]->remise_percent) {
345 $this->atleastonediscount++;
352 if (!empty($tplidx)) {
353 $pdf->useTemplate($tplidx);
356 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
357 $top_shift = $pagehead[
'top_shift'];
358 $shipp_shift = $pagehead[
'shipp_shift'];
359 $pdf->SetFont(
'',
'', $default_font_size - 1);
360 $pdf->MultiCell(0, 3,
'');
361 $pdf->SetTextColor(0, 0, 0);
364 $tab_top = 90 + $top_shift + $shipp_shift;
365 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
366 if (!$hidetop &&
getDolGlobalInt(
'MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
368 $tab_top_newpage+= $this->tabTitleHeight;
371 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
373 $nexY = $tab_top - 1;
376 $height_incoterms = 0;
377 if (isModEnabled(
'incoterm')) {
378 $desc_incoterms =
$object->getIncotermsForPDF();
379 if ($desc_incoterms) {
382 $pdf->SetFont(
'',
'', $default_font_size - 1);
383 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
384 $nexY = max($pdf->GetY(), $nexY);
385 $height_incoterms = $nexY - $tab_top;
388 $pdf->SetDrawColor(192, 192, 192);
389 $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');
391 $tab_top = $nexY + 6;
396 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
399 if (is_object(
$object->thirdparty)) {
400 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
401 $salerepobj =
new User($this->db);
402 $salerepobj->fetch($salereparray[0][
'id']);
403 if (!empty($salerepobj->signature)) {
404 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
409 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
410 if (!empty($extranote)) {
414 $pagenb = $pdf->getPage();
418 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
419 $pageposbeforenote = $pagenb;
426 $pdf->startTransaction();
428 $pdf->SetFont(
'',
'', $default_font_size - 1);
429 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
431 $pageposafternote = $pdf->getPage();
432 $posyafter = $pdf->GetY();
434 if ($pageposafternote > $pageposbeforenote) {
435 $pdf->rollbackTransaction(
true);
438 while ($pagenb < $pageposafternote) {
441 if (!empty($tplidx)) {
442 $pdf->useTemplate($tplidx);
448 $pdf->setTopMargin($tab_top_newpage);
450 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
454 $pdf->setPage($pageposbeforenote);
455 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
456 $pdf->SetFont(
'',
'', $default_font_size - 1);
457 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
458 $pageposafternote = $pdf->getPage();
460 $posyafter = $pdf->GetY();
462 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
463 $pdf->AddPage(
'',
'',
true);
466 $pdf->setPage($pageposafternote);
467 $pdf->setTopMargin($tab_top_newpage);
469 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
475 $i = $pageposbeforenote;
476 while ($i < $pageposafternote) {
480 $pdf->SetDrawColor(128, 128, 128);
482 if ($i > $pageposbeforenote) {
483 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
484 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
486 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
487 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
491 $pdf->setPageOrientation(
'', 1, 0);
498 $pdf->setPage($pageposafternote);
499 if (!empty($tplidx)) {
500 $pdf->useTemplate($tplidx);
505 $height_note = $posyafter - $tab_top_newpage;
506 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
509 $pdf->commitTransaction();
510 $posyafter = $pdf->GetY();
511 $height_note = $posyafter - $tab_top;
512 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
515 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
517 $pdf->AddPage(
'',
'',
true);
520 $pdf->setPage($pageposafternote);
521 if (!empty($tplidx)) {
522 $pdf->useTemplate($tplidx);
528 $posyafter = $tab_top_newpage;
532 $tab_height -= $height_note;
533 $tab_top = $posyafter + 6;
543 $pdf->startTransaction();
544 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
545 $pdf->rollbackTransaction(
true);
547 $nexY = $tab_top + $this->tabTitleHeight;
550 $pageposbeforeprintlines = $pdf->getPage();
551 $pagenb = $pageposbeforeprintlines;
552 for ($i = 0; $i < $nblines; $i++) {
553 $linePosition = $i + 1;
557 if (isset(
$object->lines[$i]->pagebreak) &&
$object->lines[$i]->pagebreak) {
560 if (!empty($tplidx)) {
561 $pdf->useTemplate($tplidx);
564 $pdf->setPage($pdf->getNumPages());
565 $nexY = $tab_top_newpage;
571 $pdf->SetFont(
'',
'', $default_font_size - 1);
572 $pdf->SetTextColor(0, 0, 0);
575 $imglinesize = array();
576 if (!empty($realpatharray[$i])) {
580 $pdf->setTopMargin($tab_top_newpage);
581 $pdf->setPageOrientation(
'', 1, $heightforfooter);
582 $pageposbefore = $pdf->getPage();
586 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
592 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imageTopMargin + $imglinesize[
'height']) > ($this->page_hauteur - $heightforfooter)) {
593 $pdf->AddPage(
'',
'',
true);
594 if (!empty($tplidx)) {
595 $pdf->useTemplate($tplidx);
597 $pdf->setPage($pageposbefore + 1);
598 $pdf->setPageOrientation(
'', 1, $heightforfooter);
599 $curY = $tab_top_newpage;
600 $showpricebeforepagebreak = 0;
606 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
607 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + $imageTopMargin, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
609 $posYAfterImage = $curY + $imglinesize[
'height'];
615 $pdf->setPageOrientation(
'', 1, $heightforfooter);
624 $pdf->setPage($pageposbefore);
625 $pdf->setTopMargin($this->marge_haute);
626 $pdf->setPageOrientation(
'', 0, $heightforfooter);
629 if ($afterPosData[
'page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
630 $pdf->setPage($afterPosData[
'page']);
631 $curY = $tab_top_newpage;
634 $pdf->SetFont(
'',
'', $default_font_size - 1);
686 if (!empty(
$object->lines[$i]->array_options)) {
687 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
702 'nexY' => & $afterPosData[
'y'],
703 'outputlangs' => $outputlangs,
704 'hidedetails' => $hidedetails
706 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
710 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
711 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
713 $tvaligne =
$object->lines[$i]->total_tva;
716 $localtax1ligne =
$object->lines[$i]->total_localtax1;
717 $localtax2ligne =
$object->lines[$i]->total_localtax2;
718 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
719 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
720 $localtax1_type =
$object->lines[$i]->localtax1_type;
721 $localtax2_type =
$object->lines[$i]->localtax2_type;
723 $vatrate = (string)
$object->lines[$i]->tva_tx;
726 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
727 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
729 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
730 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
734 if ($localtax1_type && $localtax1ligne != 0) {
735 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
736 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
738 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
741 if ($localtax2_type && $localtax2ligne != 0) {
742 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
743 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
745 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
749 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
754 if (!isset($this->tva[$vatrate])) {
755 $this->tva[$vatrate] = 0;
757 $this->tva[$vatrate] += $tvaligne;
758 $vatcode =
$object->lines[$i]->vat_src_code;
759 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
760 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
762 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
765 $pdf->setPage($afterPosData[
'page']);
766 $nexY = $afterPosData[
'y'];
769 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $heightforfooter - 5) {
770 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
772 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
773 $pdf->SetLineStyle(array(
'dash' => 0));
781 if ($afterPosData[
'y'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot) ) {
783 if (!empty($tplidx)) {
784 $pdf->useTemplate($tplidx);
787 $pdf->setPage($pagenb);
791 $drawTabNumbPage = $pdf->getNumPages();
792 for ($i=$pageposbeforeprintlines; $i<=$drawTabNumbPage; $i++) {
795 $pdf->setPageOrientation(
'', 0, 0);
797 $drawTabHideTop = $hidetop;
798 $drawTabTop = $tab_top_newpage;
799 $drawTabBottom = $this->page_hauteur - $heightforfooter;;
802 if ($i == $pageposbeforeprintlines) {
804 $drawTabTop = $tab_top;
805 } elseif (!$drawTabHideTop) {
807 $drawTabTop-= $this->tabTitleHeight;
814 if ($i == $pdf->getNumPages()) {
816 $drawTabBottom-= $heightforfreetext + $heightforinfotot;
819 $drawTabHeight = $drawTabBottom - $drawTabTop;
820 $this->
_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom,
$object->multicurrency_code, $outputlangsbis);
822 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0;
828 $pdf->setPageOrientation(
'', 1, 0);
831 if (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
834 if (!empty($tplidx)) {
835 $pdf->useTemplate($tplidx);
840 $pdf->SetTextColor(0, 0, 0);
842 $pdf->setPage($pdf->getNumPages());
844 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
854 if (method_exists($pdf,
'AliasNbPages')) {
855 $pdf->AliasNbPages();
859 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_ORDER')) {
860 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
861 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
862 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
864 if (file_exists($termsofsale) && is_readable($termsofsale)) {
865 $pagecount = $pdf->setSourceFile($termsofsale);
866 for ($i = 1; $i <= $pagecount; $i++) {
867 $tplIdx = $pdf->importPage($i);
868 if ($tplIdx!==
false) {
869 $s = $pdf->getTemplatesize($tplIdx);
870 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
871 $pdf->useTemplate($tplIdx);
873 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
881 $pdf->Output($file,
'F');
884 $hookmanager->initHooks(array(
'pdfgeneration'));
885 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
887 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
889 $this->error = $hookmanager->error;
890 $this->errors = $hookmanager->errors;
895 $this->result = array(
'fullpath' => $file);
899 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
903 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
933 global
$conf, $mysoc;
936 $pdf->SetFont(
'',
'', $default_font_size - 1);
941 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
942 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
943 $pdf->SetXY($this->marge_gauche, $posy);
944 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
946 $posy = $pdf->GetY() + 4;
955 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
956 $pdf->SetXY($this->marge_gauche, $posy);
957 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
958 $pdf->MultiCell(43, 4, $titre, 0,
'L');
960 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
961 $pdf->SetXY($posxval, $posy);
962 $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);
963 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
964 if (
$object->deposit_percent > 0) {
965 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
967 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
969 $posy = $pdf->GetY() + 3;
1000 if (!empty(
$object->delivery_date)) {
1001 $outputlangs->load(
"sendings");
1002 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1003 $pdf->SetXY($this->marge_gauche, $posy);
1004 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1005 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1006 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1007 $pdf->SetXY($posxval, $posy);
1009 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1011 $posy = $pdf->GetY() + 1;
1013 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1014 $pdf->SetXY($this->marge_gauche, $posy);
1015 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1016 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1017 $pdf->SetTextColor(0, 0, 0);
1018 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1019 $pdf->SetXY($posxval, $posy);
1020 $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 :
'');
1021 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1022 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1024 $posy = $pdf->GetY() + 1;
1028 if (
$object->mode_reglement_code
1029 &&
$object->mode_reglement_code !=
'CHQ'
1030 &&
$object->mode_reglement_code !=
'VIR') {
1031 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1032 $pdf->SetXY($this->marge_gauche, $posy);
1033 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1034 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1036 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1037 $pdf->SetXY($posxval, $posy);
1038 $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);
1039 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1041 $posy = $pdf->GetY() + 2;
1045 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1049 $account =
new Account($this->db);
1052 $pdf->SetXY($this->marge_gauche, $posy);
1053 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1054 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1055 $posy = $pdf->GetY() + 1;
1058 $pdf->SetXY($this->marge_gauche, $posy);
1059 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1060 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1061 $posy = $pdf->GetY() + 2;
1064 if (
$conf->global->FACTURE_CHQ_NUMBER == -1) {
1065 $pdf->SetXY($this->marge_gauche, $posy);
1066 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1067 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1068 $posy = $pdf->GetY() + 1;
1071 $pdf->SetXY($this->marge_gauche, $posy);
1072 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1073 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1074 $posy = $pdf->GetY() + 2;
1081 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1083 $bankid = (
$object->fk_account <= 0 ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1087 $account =
new Account($this->db);
1088 $account->fetch($bankid);
1090 $curx = $this->marge_gauche;
1093 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1116 global
$conf, $mysoc, $hookmanager;
1123 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1124 $default_font_size--;
1129 $pdf->SetFont(
'',
'', $default_font_size - 1);
1134 if ($this->page_largeur < 210) {
1137 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1143 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1146 $total_line_remise = 0;
1147 foreach (
$object->lines as $i => $line) {
1149 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1151 if ($line->total_ht < 0) {
1152 $total_line_remise += -$line->total_ht;
1155 $total_line_remise = (float)
price2num($total_line_remise,
'MT', 1);
1157 if ($total_line_remise > 0) {
1158 $pdf->SetFillColor(255, 255, 255);
1159 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1160 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1161 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1162 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1167 $pdf->SetFillColor(255, 255, 255);
1168 $pdf->SetXY($col1x, $tab2_top);
1169 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1170 $pdf->SetXY($col2x, $tab2_top);
1171 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1177 $pdf->SetFillColor(255, 255, 255);
1178 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1179 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1180 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1181 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1182 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1185 $pdf->SetFillColor(248, 248, 248);
1187 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1189 $this->atleastoneratenotnull = 0;
1191 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1192 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1196 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1197 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1200 foreach ($localtax_rate as $tvakey => $tvaval) {
1204 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1207 if (preg_match(
'/\*/', (
string) $tvakey)) {
1208 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1209 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1211 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1215 $totalvat .= $tvacompl;
1217 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1220 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1222 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1224 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1225 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1231 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1232 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1235 foreach ($localtax_rate as $tvakey => $tvaval) {
1240 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1243 if (preg_match(
'/\*/', (
string) $tvakey)) {
1244 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1245 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1247 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1251 $totalvat .= $tvacompl;
1253 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1256 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1258 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1260 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1261 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1267 foreach ($this->tva_array as $tvakey => $tvaval) {
1269 $this->atleastoneratenotnull++;
1272 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1275 if (preg_match(
'/\*/', $tvakey)) {
1276 $tvakey = str_replace(
'*',
'', $tvakey);
1277 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1279 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1282 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).$tvacompl;
1284 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1286 $totalvat .= $tvacompl;
1288 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1290 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1292 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1293 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1298 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1299 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1303 foreach ($localtax_rate as $tvakey => $tvaval) {
1308 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1311 if (preg_match(
'/\*/', (
string) $tvakey)) {
1312 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1313 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1315 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1319 $totalvat .= $tvacompl;
1321 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1324 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1326 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1328 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1329 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1335 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1336 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1340 foreach ($localtax_rate as $tvakey => $tvaval) {
1346 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1349 if (preg_match(
'/\*/', (
string) $tvakey)) {
1350 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1351 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1353 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1357 $totalvat .= $tvacompl;
1359 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1362 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1364 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1366 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1367 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1375 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1376 $pdf->SetTextColor(0, 0, 60);
1377 $pdf->SetFillColor(224, 224, 224);
1378 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1380 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1381 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1385 $pdf->SetTextColor(0, 0, 0);
1387 $creditnoteamount = 0;
1388 $depositsamount = 0;
1392 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1397 if ($deja_regle > 0) {
1401 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1402 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1403 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1404 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1407 $pdf->SetTextColor(0, 0, 60);
1408 $pdf->SetFillColor(224, 224, 224);
1409 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1410 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1412 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1413 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1415 $pdf->SetFont(
'',
'', $default_font_size - 1);
1416 $pdf->SetTextColor(0, 0, 0);
1419 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1421 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1423 $this->error = $hookmanager->error;
1424 $this->errors = $hookmanager->errors;
1428 return ($tab2_top + ($tab2_hl * $index));
1505 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1508 global
$conf, $langs, $hookmanager, $mysoc;
1510 $ltrdirection =
'L';
1511 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1512 $ltrdirection =
'R';
1516 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1522 $pdf->SetTextColor(0, 0, 60);
1523 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1527 $posy = $this->marge_haute;
1528 $posx = $this->page_largeur - $this->marge_droite - $w;
1530 $pdf->SetXY($this->marge_gauche, $posy);
1534 if ($this->emetteur->logo) {
1535 $logodir =
$conf->mycompany->dir_output;
1540 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1542 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1544 if (is_readable($logo)) {
1546 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1548 $pdf->SetTextColor(200, 0, 0);
1549 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1550 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1551 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1554 $text = $this->emetteur->name;
1555 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1559 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1560 $pdf->SetXY($posx, $posy);
1561 $pdf->SetTextColor(0, 0, 60);
1562 $title = $outputlangs->transnoentities($titlekey);
1563 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1565 $title .= $outputlangsbis->transnoentities($titlekey);
1567 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1568 if (
$object->statut == $object::STATUS_DRAFT) {
1569 $pdf->SetTextColor(128, 0, 0);
1570 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1573 $pdf->MultiCell($w, 3, $title,
'',
'R');
1575 $pdf->SetFont(
'',
'B', $default_font_size);
1590 $pdf->SetFont(
'',
'', $default_font_size - 2);
1594 $pdf->SetXY($posx, $posy);
1595 $pdf->SetTextColor(0, 0, 60);
1596 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1601 if (!empty(
$object->project->ref)) {
1603 $pdf->SetXY($posx, $posy);
1604 $pdf->SetTextColor(0, 0, 60);
1605 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1611 if (!empty(
$object->project->ref)) {
1612 $outputlangs->load(
"projects");
1614 $pdf->SetXY($posx, $posy);
1615 $pdf->SetTextColor(0, 0, 60);
1616 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1622 $pdf->SetXY($posx, $posy);
1623 $pdf->SetTextColor(0, 0, 60);
1624 $title = $outputlangs->transnoentities(
"OrderDate");
1625 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1626 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1628 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1632 $pdf->SetXY($posx, $posy);
1633 $pdf->SetTextColor(0, 0, 60);
1634 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1639 $pdf->SetXY($posx, $posy);
1640 $pdf->SetTextColor(0, 0, 60);
1641 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1646 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1647 if (count($arrayidcontact) > 0) {
1648 $usertmp =
new User($this->db);
1649 $usertmp->fetch($arrayidcontact[0]);
1651 $pdf->SetXY($posx, $posy);
1652 $pdf->SetTextColor(0, 0, 60);
1653 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1662 $current_y = $pdf->getY();
1664 if ($current_y < $pdf->getY()) {
1665 $top_shift = $pdf->getY() - $current_y;
1670 $carac_emetteur =
'';
1672 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1673 if (count($arrayidcontact) > 0) {
1674 $object->fetch_user($arrayidcontact[0]);
1675 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1676 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1678 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1682 $carac_emetteur .=
"\n";
1689 $posy += $top_shift;
1690 $posx = $this->marge_gauche;
1692 $posx = $this->page_largeur - $this->marge_droite - 80;
1696 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1701 $pdf->SetTextColor(0, 0, 0);
1702 $pdf->SetFont(
'',
'', $default_font_size - 2);
1703 $pdf->SetXY($posx, $posy - 5);
1704 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1705 $pdf->SetXY($posx, $posy);
1706 $pdf->SetFillColor(230, 230, 230);
1707 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1708 $pdf->SetTextColor(0, 0, 60);
1713 $pdf->SetXY($posx + 2, $posy + 3);
1714 $pdf->SetFont(
'',
'B', $default_font_size);
1715 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1716 $posy = $pdf->getY();
1720 $pdf->SetXY($posx + 2, $posy);
1721 $pdf->SetFont(
'',
'', $default_font_size - 1);
1722 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1725 $usecontact =
false;
1726 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1727 if (count($arrayidcontact) > 0) {
1729 $result =
$object->fetch_contact($arrayidcontact[0]);
1734 $thirdparty =
$object->contact;
1736 $thirdparty =
$object->thirdparty;
1739 if (is_object($thirdparty)) {
1747 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1748 if ($this->page_largeur < 210) {
1752 $posy += $top_shift;
1753 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1755 $posx = $this->marge_gauche;
1760 $pdf->SetTextColor(0, 0, 0);
1761 $pdf->SetFont(
'',
'', $default_font_size - 2);
1762 $pdf->SetXY($posx + 2, $posy - 5);
1763 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1764 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1768 $pdf->SetXY($posx + 2, $posy + 3);
1769 $pdf->SetFont(
'',
'B', $default_font_size);
1771 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1773 $posy = $pdf->getY();
1776 $pdf->SetFont(
'',
'', $default_font_size - 1);
1777 $pdf->SetXY($posx + 2, $posy);
1779 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1783 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1785 if (!empty($idaddressshipping)) {
1786 $contactshipping =
$object->fetch_contact($idaddressshipping[0]);
1787 $companystatic =
new Societe($this->db);
1788 $companystatic->fetch(
$object->contact->fk_soc);
1790 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
1795 if (!empty($carac_client_shipping)) {
1796 $posy += $hautcadre;
1801 $pdf->SetXY($posx + 2, $posy - 5);
1802 $pdf->SetFont(
'',
'', $default_font_size - 2);
1803 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
1804 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1807 $pdf->SetXY($posx + 2, $posy + 1);
1808 $pdf->SetFont(
'',
'B', $default_font_size);
1809 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1811 $posy = $pdf->getY();
1814 $pdf->SetXY($posx + 2, $posy);
1815 $pdf->SetFont(
'',
'', $default_font_size - 1);
1816 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1818 $shipp_shift += $hautcadre + 10;
1823 $pdf->SetTextColor(0, 0, 0);
1825 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);