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",
"deliveries",
"compta"));
192 global $outputlangsbis;
193 $outputlangsbis =
null;
195 $outputlangsbis =
new Translate(
'', $conf);
197 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries",
"compta"));
200 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
208 $realpatharray = array();
209 $this->atleastonephoto =
false;
211 $objphoto =
new Product($this->db);
213 for ($i = 0; $i < $nblines; $i++) {
214 if (empty(
$object->lines[$i]->fk_product)) {
220 $objphoto->fetch(
$object->lines[$i]->fk_product);
223 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
224 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
226 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
227 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
231 foreach ($pdir as $midir) {
233 if ($conf->entity != $objphoto->entity) {
234 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
236 $dir = $conf->product->dir_output.
'/'.$midir;
239 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
241 if ($obj[
'photo_vignette']) {
242 $filename = $obj[
'photo_vignette'];
244 $filename = $obj[
'photo'];
247 $filename = $obj[
'photo'];
250 $realpath = $dir.$filename;
252 $this->atleastonephoto =
true;
257 if ($realpath && $arephoto) {
258 $realpatharray[$i] = $realpath;
273 $file = $dir.
"/SPECIMEN.pdf";
277 $file = $dir.
"/".$objectref.
".pdf";
280 if (!file_exists($dir)) {
282 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
287 if (file_exists($dir)) {
289 if (!is_object($hookmanager)) {
290 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
293 $hookmanager->initHooks(array(
'pdfgeneration'));
294 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
296 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
299 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
304 $pdf->SetAutoPageBreak(1, 0);
306 $heightforinfotot = 40;
308 $heightforfooter = $this->marge_basse + 8;
310 $heightforfooter += 6;
313 if (class_exists(
'TCPDF')) {
314 $pdf->setPrintHeader(
false);
315 $pdf->setPrintFooter(
false);
320 $logodir = $conf->mycompany->dir_output;
321 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
322 $logodir = $conf->mycompany->multidir_output[
$object->entity];
324 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
325 $tplidx = $pdf->importPage(1);
330 $pdf->SetDrawColor(128, 128, 128);
332 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
333 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
334 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
335 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
336 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
338 $pdf->SetCompression(
false);
342 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
345 for ($i = 0; $i < $nblines; $i++) {
346 if (
$object->lines[$i]->remise_percent) {
347 $this->atleastonediscount++;
354 if (!empty($tplidx)) {
355 $pdf->useTemplate($tplidx);
358 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
359 $top_shift = $pagehead[
'top_shift'];
360 $shipp_shift = $pagehead[
'shipp_shift'];
361 $pdf->SetFont(
'',
'', $default_font_size - 1);
362 $pdf->MultiCell(0, 3,
'');
363 $pdf->SetTextColor(0, 0, 0);
366 $tab_top = 90 + $top_shift + $shipp_shift;
367 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
369 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
371 $nexY = $tab_top - 1;
374 $height_incoterms = 0;
375 if (isModEnabled(
'incoterm')) {
376 $desc_incoterms =
$object->getIncotermsForPDF();
377 if ($desc_incoterms) {
380 $pdf->SetFont(
'',
'', $default_font_size - 1);
381 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
382 $nexY = max($pdf->GetY(), $nexY);
383 $height_incoterms = $nexY - $tab_top;
386 $pdf->SetDrawColor(192, 192, 192);
387 $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');
389 $tab_top = $nexY + 6;
394 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
397 if (is_object(
$object->thirdparty)) {
398 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
399 $salerepobj =
new User($this->db);
400 $salerepobj->fetch($salereparray[0][
'id']);
401 if (!empty($salerepobj->signature)) {
402 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
407 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
408 if (!empty($extranote)) {
412 $pagenb = $pdf->getPage();
416 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
417 $pageposbeforenote = $pagenb;
424 $pdf->startTransaction();
426 $pdf->SetFont(
'',
'', $default_font_size - 1);
427 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
429 $pageposafternote = $pdf->getPage();
430 $posyafter = $pdf->GetY();
432 if ($pageposafternote > $pageposbeforenote) {
433 $pdf->rollbackTransaction(
true);
436 while ($pagenb < $pageposafternote) {
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
446 $pdf->setTopMargin($tab_top_newpage);
448 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
452 $pdf->setPage($pageposbeforenote);
453 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
454 $pdf->SetFont(
'',
'', $default_font_size - 1);
455 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
456 $pageposafternote = $pdf->getPage();
458 $posyafter = $pdf->GetY();
460 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
461 $pdf->AddPage(
'',
'',
true);
464 $pdf->setPage($pageposafternote);
465 $pdf->setTopMargin($tab_top_newpage);
467 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
473 $i = $pageposbeforenote;
474 while ($i < $pageposafternote) {
478 $pdf->SetDrawColor(128, 128, 128);
480 if ($i > $pageposbeforenote) {
481 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
482 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
484 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
485 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
489 $pdf->setPageOrientation(
'', 1, 0);
496 $pdf->setPage($pageposafternote);
497 if (!empty($tplidx)) {
498 $pdf->useTemplate($tplidx);
503 $height_note = $posyafter - $tab_top_newpage;
504 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
507 $pdf->commitTransaction();
508 $posyafter = $pdf->GetY();
509 $height_note = $posyafter - $tab_top;
510 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
513 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
515 $pdf->AddPage(
'',
'',
true);
518 $pdf->setPage($pageposafternote);
519 if (!empty($tplidx)) {
520 $pdf->useTemplate($tplidx);
526 $posyafter = $tab_top_newpage;
530 $tab_height -= $height_note;
531 $tab_top = $posyafter + 6;
541 $pdf->startTransaction();
542 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
543 $pdf->rollbackTransaction(
true);
545 $nexY = $tab_top + $this->tabTitleHeight;
548 $pageposbeforeprintlines = $pdf->getPage();
549 $pagenb = $pageposbeforeprintlines;
550 for ($i = 0; $i < $nblines; $i++) {
552 $pdf->SetFont(
'',
'', $default_font_size - 1);
553 $pdf->SetTextColor(0, 0, 0);
556 $imglinesize = array();
557 if (!empty($realpatharray[$i])) {
561 $pdf->setTopMargin($tab_top_newpage);
562 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
563 $pageposbefore = $pdf->getPage();
566 $showpricebeforepagebreak = 1;
568 $posYAfterDescription = 0;
572 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
573 $pdf->AddPage(
'',
'',
true);
574 if (!empty($tplidx)) {
575 $pdf->useTemplate($tplidx);
577 $pdf->setPage($pageposbefore + 1);
579 $curY = $tab_top_newpage;
583 $showpricebeforepagebreak = 1;
585 $showpricebeforepagebreak = 0;
589 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
590 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
592 $posYAfterImage = $curY + $imglinesize[
'height'];
598 $pdf->startTransaction();
601 $pageposafter = $pdf->getPage();
603 if ($pageposafter > $pageposbefore) {
604 $pdf->rollbackTransaction(
true);
605 $pageposafter = $pageposbefore;
607 $pdf->setPageOrientation(
'', 1, $heightforfooter);
610 $pageposafter = $pdf->getPage();
611 $posyafter = $pdf->GetY();
612 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
613 if ($i == ($nblines - 1)) {
614 $pdf->AddPage(
'',
'',
true);
615 if (!empty($tplidx)) {
616 $pdf->useTemplate($tplidx);
618 $pdf->setPage($pageposafter + 1);
624 $showpricebeforepagebreak = 1;
626 $showpricebeforepagebreak = 0;
630 $pdf->commitTransaction();
632 $posYAfterDescription = $pdf->GetY();
636 $nexY = max($pdf->GetY(), $posYAfterImage);
639 $pageposafter = $pdf->getPage();
641 $pdf->setPage($pageposbefore);
642 $pdf->setTopMargin($this->marge_haute);
643 $pdf->setPageOrientation(
'', 1, 0);
646 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
647 $pdf->setPage($pageposafter);
648 $curY = $tab_top_newpage;
651 $pdf->SetFont(
'',
'', $default_font_size - 1);
662 $nexY = max($pdf->GetY(), $nexY);
669 $nexY = max($pdf->GetY(), $nexY);
677 $nexY = max($pdf->GetY(), $nexY);
685 $nexY = max($pdf->GetY(), $nexY);
692 $nexY = max($pdf->GetY(), $nexY);
699 $nexY = max($pdf->GetY(), $nexY);
706 $nexY = max($pdf->GetY(), $nexY);
710 if (!empty(
$object->lines[$i]->array_options)) {
711 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
715 $nexY = max($pdf->GetY(), $nexY);
726 'outputlangs' => $outputlangs,
727 'hidedetails' => $hidedetails
729 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
733 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
734 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
736 $tvaligne =
$object->lines[$i]->total_tva;
739 $localtax1ligne =
$object->lines[$i]->total_localtax1;
740 $localtax2ligne =
$object->lines[$i]->total_localtax2;
741 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
742 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
743 $localtax1_type =
$object->lines[$i]->localtax1_type;
744 $localtax2_type =
$object->lines[$i]->localtax2_type;
746 $vatrate = (string)
$object->lines[$i]->tva_tx;
749 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
750 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
752 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
753 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
757 if ($localtax1_type && $localtax1ligne != 0) {
758 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
759 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
761 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
764 if ($localtax2_type && $localtax2ligne != 0) {
765 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
766 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
768 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
772 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
777 if (!isset($this->tva[$vatrate])) {
778 $this->tva[$vatrate] = 0;
780 $this->tva[$vatrate] += $tvaligne;
781 $vatcode =
$object->lines[$i]->vat_src_code;
782 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
783 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
785 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
788 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
789 $pdf->setPage($pageposafter);
790 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
792 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
793 $pdf->SetLineStyle(array(
'dash' => 0));
798 while ($pagenb < $pageposafter) {
799 $pdf->setPage($pagenb);
800 if ($pagenb == $pageposbeforeprintlines) {
801 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
803 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
807 $pdf->setPage($pagenb);
808 $pdf->setPageOrientation(
'', 1, 0);
812 if (!empty($tplidx)) {
813 $pdf->useTemplate($tplidx);
816 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
817 if ($pagenb == $pageposafter) {
818 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
820 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
825 if (!empty($tplidx)) {
826 $pdf->useTemplate($tplidx);
836 if ($pagenb == $pageposbeforeprintlines) {
837 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
839 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
841 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
859 if (method_exists($pdf,
'AliasNbPages')) {
860 $pdf->AliasNbPages();
865 $pdf->Output($file,
'F');
868 $hookmanager->initHooks(array(
'pdfgeneration'));
869 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
871 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
873 $this->error = $hookmanager->error;
874 $this->errors = $hookmanager->errors;
879 $this->result = array(
'fullpath' => $file);
883 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
887 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
917 global $conf, $mysoc;
920 $pdf->SetFont(
'',
'', $default_font_size - 1);
922 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
925 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
926 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
927 $pdf->SetXY($this->marge_gauche, $posy);
928 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
930 $posy = $pdf->GetY() + 4;
935 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
939 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
940 $pdf->SetXY($this->marge_gauche, $posy);
941 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
942 $pdf->MultiCell(43, 4, $titre, 0,
'L');
944 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
945 $pdf->SetXY($posxval, $posy);
946 $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);
947 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
948 if (
$object->deposit_percent > 0) {
949 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
951 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
953 $posy = $pdf->GetY() + 3;
984 if (!empty(
$object->delivery_date)) {
985 $outputlangs->load(
"sendings");
986 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
987 $pdf->SetXY($this->marge_gauche, $posy);
988 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
989 $pdf->MultiCell(80, 4, $titre, 0,
'L');
990 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
991 $pdf->SetXY($posxval, $posy);
993 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
995 $posy = $pdf->GetY() + 1;
997 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
998 $pdf->SetXY($this->marge_gauche, $posy);
999 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1000 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1001 $pdf->SetTextColor(0, 0, 0);
1002 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1003 $pdf->SetXY($posxval, $posy);
1004 $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 :
'');
1005 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1006 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1008 $posy = $pdf->GetY() + 1;
1012 if (
$object->mode_reglement_code
1013 &&
$object->mode_reglement_code !=
'CHQ'
1014 &&
$object->mode_reglement_code !=
'VIR') {
1015 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1016 $pdf->SetXY($this->marge_gauche, $posy);
1017 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1018 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1020 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1021 $pdf->SetXY($posxval, $posy);
1022 $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);
1023 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1025 $posy = $pdf->GetY() + 2;
1029 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1033 $account =
new Account($this->db);
1036 $pdf->SetXY($this->marge_gauche, $posy);
1037 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1038 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1039 $posy = $pdf->GetY() + 1;
1042 $pdf->SetXY($this->marge_gauche, $posy);
1043 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1044 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1045 $posy = $pdf->GetY() + 2;
1048 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1049 $pdf->SetXY($this->marge_gauche, $posy);
1050 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1051 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1052 $posy = $pdf->GetY() + 1;
1055 $pdf->SetXY($this->marge_gauche, $posy);
1056 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1057 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1058 $posy = $pdf->GetY() + 2;
1065 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1067 $bankid = (
$object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1071 $account =
new Account($this->db);
1072 $account->fetch($bankid);
1074 $curx = $this->marge_gauche;
1077 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1100 global $conf, $mysoc, $hookmanager;
1105 $outputlangsbis =
new Translate(
'', $conf);
1107 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1108 $default_font_size--;
1113 $pdf->SetFont(
'',
'', $default_font_size - 1);
1118 if ($this->page_largeur < 210) {
1121 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1127 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1130 $total_line_remise = 0;
1131 foreach (
$object->lines as $i => $line) {
1133 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1135 if ($line->total_ht < 0) {
1136 $total_line_remise += -$line->total_ht;
1139 if ($total_line_remise > 0) {
1140 $pdf->SetFillColor(255, 255, 255);
1141 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1142 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1143 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1144 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1149 $pdf->SetFillColor(255, 255, 255);
1150 $pdf->SetXY($col1x, $tab2_top);
1151 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1152 $pdf->SetXY($col2x, $tab2_top);
1153 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1159 $pdf->SetFillColor(255, 255, 255);
1160 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1161 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1162 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1163 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1164 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1167 $pdf->SetFillColor(248, 248, 248);
1169 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1171 $this->atleastoneratenotnull = 0;
1173 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1174 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1178 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1179 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1182 foreach ($localtax_rate as $tvakey => $tvaval) {
1186 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1189 if (preg_match(
'/\*/', (
string) $tvakey)) {
1190 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1191 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1193 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1197 $totalvat .= $tvacompl;
1199 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1202 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1204 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1206 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1207 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1213 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1214 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1217 foreach ($localtax_rate as $tvakey => $tvaval) {
1222 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1225 if (preg_match(
'/\*/', (
string) $tvakey)) {
1226 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1227 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1229 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1233 $totalvat .= $tvacompl;
1235 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1238 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1240 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1242 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1243 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1249 foreach ($this->tva_array as $tvakey => $tvaval) {
1251 $this->atleastoneratenotnull++;
1254 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1257 if (preg_match(
'/\*/', $tvakey)) {
1258 $tvakey = str_replace(
'*',
'', $tvakey);
1259 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1261 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1264 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1266 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1268 $totalvat .= $tvacompl;
1270 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1272 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1274 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1275 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1280 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1281 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1285 foreach ($localtax_rate as $tvakey => $tvaval) {
1290 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1293 if (preg_match(
'/\*/', (
string) $tvakey)) {
1294 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1295 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1297 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1301 $totalvat .= $tvacompl;
1303 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1306 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1308 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1310 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1311 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1317 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1318 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1322 foreach ($localtax_rate as $tvakey => $tvaval) {
1328 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1331 if (preg_match(
'/\*/', (
string) $tvakey)) {
1332 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1333 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1335 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1339 $totalvat .= $tvacompl;
1341 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1344 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1346 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1348 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1349 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1357 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1358 $pdf->SetTextColor(0, 0, 60);
1359 $pdf->SetFillColor(224, 224, 224);
1360 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1362 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1363 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1367 $pdf->SetTextColor(0, 0, 0);
1369 $creditnoteamount = 0;
1370 $depositsamount = 0;
1374 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1379 if ($deja_regle > 0) {
1383 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1384 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1385 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1386 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1389 $pdf->SetTextColor(0, 0, 60);
1390 $pdf->SetFillColor(224, 224, 224);
1391 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1392 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1394 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1395 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1397 $pdf->SetFont(
'',
'', $default_font_size - 1);
1398 $pdf->SetTextColor(0, 0, 0);
1401 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1403 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1405 $this->error = $hookmanager->error;
1406 $this->errors = $hookmanager->errors;
1410 return ($tab2_top + ($tab2_hl * $index));
1487 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1490 global $conf, $langs, $hookmanager, $mysoc;
1492 $ltrdirection =
'L';
1493 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1494 $ltrdirection =
'R';
1498 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1504 $pdf->SetTextColor(0, 0, 60);
1505 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1509 $posy = $this->marge_haute;
1510 $posx = $this->page_largeur - $this->marge_droite - $w;
1512 $pdf->SetXY($this->marge_gauche, $posy);
1516 if ($this->emetteur->logo) {
1517 $logodir = $conf->mycompany->dir_output;
1522 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1524 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1526 if (is_readable($logo)) {
1528 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1530 $pdf->SetTextColor(200, 0, 0);
1531 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1532 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1533 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1536 $text = $this->emetteur->name;
1537 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1541 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1542 $pdf->SetXY($posx, $posy);
1543 $pdf->SetTextColor(0, 0, 60);
1544 $title = $outputlangs->transnoentities($titlekey);
1545 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1547 $title .= $outputlangsbis->transnoentities($titlekey);
1549 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1550 if (
$object->statut == $object::STATUS_DRAFT) {
1551 $pdf->SetTextColor(128, 0, 0);
1552 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1555 $pdf->MultiCell($w, 3, $title,
'',
'R');
1557 $pdf->SetFont(
'',
'B', $default_font_size);
1572 $pdf->SetFont(
'',
'', $default_font_size - 2);
1576 $pdf->SetXY($posx, $posy);
1577 $pdf->SetTextColor(0, 0, 60);
1578 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1583 if (!empty(
$object->project->ref)) {
1585 $pdf->SetXY($posx, $posy);
1586 $pdf->SetTextColor(0, 0, 60);
1587 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1593 if (!empty(
$object->project->ref)) {
1594 $outputlangs->load(
"projects");
1596 $pdf->SetXY($posx, $posy);
1597 $pdf->SetTextColor(0, 0, 60);
1598 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1604 $pdf->SetXY($posx, $posy);
1605 $pdf->SetTextColor(0, 0, 60);
1606 $title = $outputlangs->transnoentities(
"OrderDate");
1607 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1608 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1610 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1614 $pdf->SetXY($posx, $posy);
1615 $pdf->SetTextColor(0, 0, 60);
1616 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1621 $pdf->SetXY($posx, $posy);
1622 $pdf->SetTextColor(0, 0, 60);
1623 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1628 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1629 if (count($arrayidcontact) > 0) {
1630 $usertmp =
new User($this->db);
1631 $usertmp->fetch($arrayidcontact[0]);
1633 $pdf->SetXY($posx, $posy);
1634 $pdf->SetTextColor(0, 0, 60);
1635 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1644 $current_y = $pdf->getY();
1646 if ($current_y < $pdf->getY()) {
1647 $top_shift = $pdf->getY() - $current_y;
1652 $carac_emetteur =
'';
1654 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1655 if (count($arrayidcontact) > 0) {
1656 $object->fetch_user($arrayidcontact[0]);
1657 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1658 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1660 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1664 $carac_emetteur .=
"\n";
1671 $posy += $top_shift;
1672 $posx = $this->marge_gauche;
1674 $posx = $this->page_largeur - $this->marge_droite - 80;
1678 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1683 $pdf->SetTextColor(0, 0, 0);
1684 $pdf->SetFont(
'',
'', $default_font_size - 2);
1685 $pdf->SetXY($posx, $posy - 5);
1686 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1687 $pdf->SetXY($posx, $posy);
1688 $pdf->SetFillColor(230, 230, 230);
1689 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1690 $pdf->SetTextColor(0, 0, 60);
1695 $pdf->SetXY($posx + 2, $posy + 3);
1696 $pdf->SetFont(
'',
'B', $default_font_size);
1697 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1698 $posy = $pdf->getY();
1702 $pdf->SetXY($posx + 2, $posy);
1703 $pdf->SetFont(
'',
'', $default_font_size - 1);
1704 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1707 $usecontact =
false;
1708 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1709 if (count($arrayidcontact) > 0) {
1711 $result =
$object->fetch_contact($arrayidcontact[0]);
1716 $thirdparty =
$object->contact;
1718 $thirdparty =
$object->thirdparty;
1721 if (is_object($thirdparty)) {
1729 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1730 if ($this->page_largeur < 210) {
1734 $posy += $top_shift;
1735 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1737 $posx = $this->marge_gauche;
1742 $pdf->SetTextColor(0, 0, 0);
1743 $pdf->SetFont(
'',
'', $default_font_size - 2);
1744 $pdf->SetXY($posx + 2, $posy - 5);
1745 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1746 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1750 $pdf->SetXY($posx + 2, $posy + 3);
1751 $pdf->SetFont(
'',
'B', $default_font_size);
1753 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1755 $posy = $pdf->getY();
1758 $pdf->SetFont(
'',
'', $default_font_size - 1);
1759 $pdf->SetXY($posx + 2, $posy);
1761 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1765 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1767 if (!empty($idaddressshipping)) {
1768 $contactshipping =
$object->fetch_contact($idaddressshipping[0]);
1769 $companystatic =
new Societe($this->db);
1770 $companystatic->fetch(
$object->contact->fk_soc);
1772 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
1777 if (!empty($carac_client_shipping)) {
1778 $posy += $hautcadre;
1783 $pdf->SetXY($posx + 2, $posy - 5);
1784 $pdf->SetFont(
'',
'', $default_font_size - 2);
1785 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
1786 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1789 $pdf->SetXY($posx + 2, $posy + 1);
1790 $pdf->SetFont(
'',
'B', $default_font_size);
1791 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1793 $posy = $pdf->getY();
1796 $pdf->SetXY($posx + 2, $posy);
1797 $pdf->SetFont(
'',
'', $default_font_size - 1);
1798 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1800 $shipp_shift += $hautcadre + 10;
1805 $pdf->SetTextColor(0, 0, 0);
1807 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);