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);
209 $realpatharray = array();
210 $this->atleastonephoto =
false;
212 $objphoto =
new Product($this->db);
214 for ($i = 0; $i < $nblines; $i++) {
215 if (empty(
$object->lines[$i]->fk_product)) {
221 $objphoto->fetch(
$object->lines[$i]->fk_product);
224 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
225 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
227 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
228 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
232 foreach ($pdir as $midir) {
234 if (
$conf->entity != $objphoto->entity) {
235 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
237 $dir =
$conf->product->dir_output.
'/'.$midir;
240 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
242 if ($obj[
'photo_vignette']) {
243 $filename = $obj[
'photo_vignette'];
245 $filename = $obj[
'photo'];
248 $filename = $obj[
'photo'];
251 $realpath = $dir.$filename;
253 $this->atleastonephoto =
true;
258 if ($realpath && $arephoto) {
259 $realpatharray[$i] = $realpath;
274 $file = $dir.
"/SPECIMEN.pdf";
278 $file = $dir.
"/".$objectref.
".pdf";
281 if (!file_exists($dir)) {
283 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
288 if (file_exists($dir)) {
290 if (!is_object($hookmanager)) {
291 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
294 $hookmanager->initHooks(array(
'pdfgeneration'));
295 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
297 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
300 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
305 $pdf->SetAutoPageBreak(1, 0);
307 $heightforinfotot = 40;
309 $heightforfooter = $this->marge_basse + 8;
311 $heightforfooter += 6;
314 if (class_exists(
'TCPDF')) {
315 $pdf->setPrintHeader(
false);
316 $pdf->setPrintFooter(
false);
321 $logodir =
$conf->mycompany->dir_output;
322 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
323 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
325 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
326 $tplidx = $pdf->importPage(1);
331 $pdf->SetDrawColor(128, 128, 128);
333 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
334 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
335 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
336 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
337 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
339 $pdf->SetCompression(
false);
343 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
346 for ($i = 0; $i < $nblines; $i++) {
347 if (
$object->lines[$i]->remise_percent) {
348 $this->atleastonediscount++;
355 if (!empty($tplidx)) {
356 $pdf->useTemplate($tplidx);
359 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
360 $top_shift = $pagehead[
'top_shift'];
361 $shipp_shift = $pagehead[
'shipp_shift'];
362 $pdf->SetFont(
'',
'', $default_font_size - 1);
363 $pdf->MultiCell(0, 3,
'');
364 $pdf->SetTextColor(0, 0, 0);
367 $tab_top = 90 + $top_shift + $shipp_shift;
368 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
370 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
372 $nexY = $tab_top - 1;
375 $height_incoterms = 0;
376 if (isModEnabled(
'incoterm')) {
377 $desc_incoterms =
$object->getIncotermsForPDF();
378 if ($desc_incoterms) {
381 $pdf->SetFont(
'',
'', $default_font_size - 1);
382 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
383 $nexY = max($pdf->GetY(), $nexY);
384 $height_incoterms = $nexY - $tab_top;
387 $pdf->SetDrawColor(192, 192, 192);
388 $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');
390 $tab_top = $nexY + 6;
395 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
398 if (is_object(
$object->thirdparty)) {
399 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
400 $salerepobj =
new User($this->db);
401 $salerepobj->fetch($salereparray[0][
'id']);
402 if (!empty($salerepobj->signature)) {
403 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
408 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
409 if (!empty($extranote)) {
413 $pagenb = $pdf->getPage();
417 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
418 $pageposbeforenote = $pagenb;
425 $pdf->startTransaction();
427 $pdf->SetFont(
'',
'', $default_font_size - 1);
428 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
430 $pageposafternote = $pdf->getPage();
431 $posyafter = $pdf->GetY();
433 if ($pageposafternote > $pageposbeforenote) {
434 $pdf->rollbackTransaction(
true);
437 while ($pagenb < $pageposafternote) {
440 if (!empty($tplidx)) {
441 $pdf->useTemplate($tplidx);
447 $pdf->setTopMargin($tab_top_newpage);
449 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
453 $pdf->setPage($pageposbeforenote);
454 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
455 $pdf->SetFont(
'',
'', $default_font_size - 1);
456 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
457 $pageposafternote = $pdf->getPage();
459 $posyafter = $pdf->GetY();
461 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
462 $pdf->AddPage(
'',
'',
true);
465 $pdf->setPage($pageposafternote);
466 $pdf->setTopMargin($tab_top_newpage);
468 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
474 $i = $pageposbeforenote;
475 while ($i < $pageposafternote) {
479 $pdf->SetDrawColor(128, 128, 128);
481 if ($i > $pageposbeforenote) {
482 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
483 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
485 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
486 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
490 $pdf->setPageOrientation(
'', 1, 0);
497 $pdf->setPage($pageposafternote);
498 if (!empty($tplidx)) {
499 $pdf->useTemplate($tplidx);
504 $height_note = $posyafter - $tab_top_newpage;
505 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
508 $pdf->commitTransaction();
509 $posyafter = $pdf->GetY();
510 $height_note = $posyafter - $tab_top;
511 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
514 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
516 $pdf->AddPage(
'',
'',
true);
519 $pdf->setPage($pageposafternote);
520 if (!empty($tplidx)) {
521 $pdf->useTemplate($tplidx);
527 $posyafter = $tab_top_newpage;
531 $tab_height -= $height_note;
532 $tab_top = $posyafter + 6;
542 $pdf->startTransaction();
543 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
544 $pdf->rollbackTransaction(
true);
546 $nexY = $tab_top + $this->tabTitleHeight;
549 $pageposbeforeprintlines = $pdf->getPage();
550 $pagenb = $pageposbeforeprintlines;
551 for ($i = 0; $i < $nblines; $i++) {
553 $pdf->SetFont(
'',
'', $default_font_size - 1);
554 $pdf->SetTextColor(0, 0, 0);
557 $imglinesize = array();
558 if (!empty($realpatharray[$i])) {
562 $pdf->setTopMargin($tab_top_newpage);
563 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
564 $pageposbefore = $pdf->getPage();
567 $showpricebeforepagebreak = 1;
569 $posYAfterDescription = 0;
573 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
574 $pdf->AddPage(
'',
'',
true);
575 if (!empty($tplidx)) {
576 $pdf->useTemplate($tplidx);
578 $pdf->setPage($pageposbefore + 1);
580 $curY = $tab_top_newpage;
584 $showpricebeforepagebreak = 1;
586 $showpricebeforepagebreak = 0;
590 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
591 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
593 $posYAfterImage = $curY + $imglinesize[
'height'];
599 $pdf->startTransaction();
602 $pageposafter = $pdf->getPage();
604 if ($pageposafter > $pageposbefore) {
605 $pdf->rollbackTransaction(
true);
606 $pageposafter = $pageposbefore;
608 $pdf->setPageOrientation(
'', 1, $heightforfooter);
611 $pageposafter = $pdf->getPage();
612 $posyafter = $pdf->GetY();
613 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
614 if ($i == ($nblines - 1)) {
615 $pdf->AddPage(
'',
'',
true);
616 if (!empty($tplidx)) {
617 $pdf->useTemplate($tplidx);
619 $pdf->setPage($pageposafter + 1);
625 $showpricebeforepagebreak = 1;
627 $showpricebeforepagebreak = 0;
631 $pdf->commitTransaction();
633 $posYAfterDescription = $pdf->GetY();
637 $nexY = max($pdf->GetY(), $posYAfterImage);
640 $pageposafter = $pdf->getPage();
642 $pdf->setPage($pageposbefore);
643 $pdf->setTopMargin($this->marge_haute);
644 $pdf->setPageOrientation(
'', 1, 0);
647 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
648 $pdf->setPage($pageposafter);
649 $curY = $tab_top_newpage;
652 $pdf->SetFont(
'',
'', $default_font_size - 1);
663 $nexY = max($pdf->GetY(), $nexY);
670 $nexY = max($pdf->GetY(), $nexY);
678 $nexY = max($pdf->GetY(), $nexY);
686 $nexY = max($pdf->GetY(), $nexY);
693 $nexY = max($pdf->GetY(), $nexY);
700 $nexY = max($pdf->GetY(), $nexY);
707 $nexY = max($pdf->GetY(), $nexY);
711 if (!empty(
$object->lines[$i]->array_options)) {
712 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
716 $nexY = max($pdf->GetY(), $nexY);
727 'outputlangs' => $outputlangs,
728 'hidedetails' => $hidedetails
730 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
734 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
735 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
737 $tvaligne =
$object->lines[$i]->total_tva;
740 $localtax1ligne =
$object->lines[$i]->total_localtax1;
741 $localtax2ligne =
$object->lines[$i]->total_localtax2;
742 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
743 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
744 $localtax1_type =
$object->lines[$i]->localtax1_type;
745 $localtax2_type =
$object->lines[$i]->localtax2_type;
747 $vatrate = (string)
$object->lines[$i]->tva_tx;
750 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
751 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
753 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
754 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
758 if ($localtax1_type && $localtax1ligne != 0) {
759 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
760 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
762 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
765 if ($localtax2_type && $localtax2ligne != 0) {
766 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
767 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
769 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
773 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
778 if (!isset($this->tva[$vatrate])) {
779 $this->tva[$vatrate] = 0;
781 $this->tva[$vatrate] += $tvaligne;
782 $vatcode =
$object->lines[$i]->vat_src_code;
783 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
784 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
786 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
789 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
790 $pdf->setPage($pageposafter);
791 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
793 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
794 $pdf->SetLineStyle(array(
'dash' => 0));
799 while ($pagenb < $pageposafter) {
800 $pdf->setPage($pagenb);
801 if ($pagenb == $pageposbeforeprintlines) {
802 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
804 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
808 $pdf->setPage($pagenb);
809 $pdf->setPageOrientation(
'', 1, 0);
813 if (!empty($tplidx)) {
814 $pdf->useTemplate($tplidx);
817 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
818 if ($pagenb == $pageposafter) {
819 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
821 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
826 if (!empty($tplidx)) {
827 $pdf->useTemplate($tplidx);
837 if ($pagenb == $pageposbeforeprintlines) {
838 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
840 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
842 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
860 if (method_exists($pdf,
'AliasNbPages')) {
861 $pdf->AliasNbPages();
865 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_ORDER')) {
866 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
867 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
868 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
870 if (file_exists($termsofsale) && is_readable($termsofsale)) {
871 $pagecount = $pdf->setSourceFile($termsofsale);
872 for ($i = 1; $i <= $pagecount; $i++) {
873 $tplIdx = $pdf->importPage($i);
874 if ($tplIdx!==
false) {
875 $s = $pdf->getTemplatesize($tplIdx);
876 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
877 $pdf->useTemplate($tplIdx);
879 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
887 $pdf->Output($file,
'F');
890 $hookmanager->initHooks(array(
'pdfgeneration'));
891 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
893 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
895 $this->error = $hookmanager->error;
896 $this->errors = $hookmanager->errors;
901 $this->result = array(
'fullpath' => $file);
905 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
909 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
939 global
$conf, $mysoc;
942 $pdf->SetFont(
'',
'', $default_font_size - 1);
947 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
948 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
949 $pdf->SetXY($this->marge_gauche, $posy);
950 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
952 $posy = $pdf->GetY() + 4;
961 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
962 $pdf->SetXY($this->marge_gauche, $posy);
963 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
964 $pdf->MultiCell(43, 4, $titre, 0,
'L');
966 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
967 $pdf->SetXY($posxval, $posy);
968 $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);
969 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
970 if (
$object->deposit_percent > 0) {
971 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
973 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
975 $posy = $pdf->GetY() + 3;
1006 if (!empty(
$object->delivery_date)) {
1007 $outputlangs->load(
"sendings");
1008 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1009 $pdf->SetXY($this->marge_gauche, $posy);
1010 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1011 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1012 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1013 $pdf->SetXY($posxval, $posy);
1015 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1017 $posy = $pdf->GetY() + 1;
1019 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1020 $pdf->SetXY($this->marge_gauche, $posy);
1021 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1022 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1023 $pdf->SetTextColor(0, 0, 0);
1024 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1025 $pdf->SetXY($posxval, $posy);
1026 $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 :
'');
1027 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1028 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1030 $posy = $pdf->GetY() + 1;
1034 if (
$object->mode_reglement_code
1035 &&
$object->mode_reglement_code !=
'CHQ'
1036 &&
$object->mode_reglement_code !=
'VIR') {
1037 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1038 $pdf->SetXY($this->marge_gauche, $posy);
1039 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1040 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1042 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1043 $pdf->SetXY($posxval, $posy);
1044 $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);
1045 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1047 $posy = $pdf->GetY() + 2;
1051 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1055 $account =
new Account($this->db);
1058 $pdf->SetXY($this->marge_gauche, $posy);
1059 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1060 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1061 $posy = $pdf->GetY() + 1;
1064 $pdf->SetXY($this->marge_gauche, $posy);
1065 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1066 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1067 $posy = $pdf->GetY() + 2;
1070 if (
$conf->global->FACTURE_CHQ_NUMBER == -1) {
1071 $pdf->SetXY($this->marge_gauche, $posy);
1072 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1073 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1074 $posy = $pdf->GetY() + 1;
1077 $pdf->SetXY($this->marge_gauche, $posy);
1078 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1079 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1080 $posy = $pdf->GetY() + 2;
1087 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1089 $bankid = (
$object->fk_account <= 0 ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1093 $account =
new Account($this->db);
1094 $account->fetch($bankid);
1096 $curx = $this->marge_gauche;
1099 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1122 global
$conf, $mysoc, $hookmanager;
1129 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1130 $default_font_size--;
1135 $pdf->SetFont(
'',
'', $default_font_size - 1);
1140 if ($this->page_largeur < 210) {
1143 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1149 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1152 $total_line_remise = 0;
1153 foreach (
$object->lines as $i => $line) {
1155 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1157 if ($line->total_ht < 0) {
1158 $total_line_remise += -$line->total_ht;
1161 $total_line_remise = (float)
price2num($total_line_remise,
'MT', 1);
1163 if ($total_line_remise > 0) {
1164 $pdf->SetFillColor(255, 255, 255);
1165 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1166 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1167 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1168 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1173 $pdf->SetFillColor(255, 255, 255);
1174 $pdf->SetXY($col1x, $tab2_top);
1175 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1176 $pdf->SetXY($col2x, $tab2_top);
1177 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1183 $pdf->SetFillColor(255, 255, 255);
1184 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1185 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1186 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1187 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1188 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1191 $pdf->SetFillColor(248, 248, 248);
1193 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1195 $this->atleastoneratenotnull = 0;
1197 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1198 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1202 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1203 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1206 foreach ($localtax_rate as $tvakey => $tvaval) {
1210 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1213 if (preg_match(
'/\*/', (
string) $tvakey)) {
1214 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1215 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1217 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1221 $totalvat .= $tvacompl;
1223 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1226 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1228 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1230 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1231 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1237 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1238 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1241 foreach ($localtax_rate as $tvakey => $tvaval) {
1246 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1249 if (preg_match(
'/\*/', (
string) $tvakey)) {
1250 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1251 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1253 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1257 $totalvat .= $tvacompl;
1259 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1262 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1264 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1266 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1267 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1273 foreach ($this->tva_array as $tvakey => $tvaval) {
1275 $this->atleastoneratenotnull++;
1278 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1281 if (preg_match(
'/\*/', $tvakey)) {
1282 $tvakey = str_replace(
'*',
'', $tvakey);
1283 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1285 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1288 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).$tvacompl;
1290 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1292 $totalvat .= $tvacompl;
1294 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1296 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1298 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1299 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1304 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1305 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1309 foreach ($localtax_rate as $tvakey => $tvaval) {
1314 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1317 if (preg_match(
'/\*/', (
string) $tvakey)) {
1318 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1319 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1321 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1325 $totalvat .= $tvacompl;
1327 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1330 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1332 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1334 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1335 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1341 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1342 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1346 foreach ($localtax_rate as $tvakey => $tvaval) {
1352 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1355 if (preg_match(
'/\*/', (
string) $tvakey)) {
1356 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1357 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1359 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1363 $totalvat .= $tvacompl;
1365 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1368 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1370 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1372 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1373 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1381 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1382 $pdf->SetTextColor(0, 0, 60);
1383 $pdf->SetFillColor(224, 224, 224);
1384 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1386 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1387 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1391 $pdf->SetTextColor(0, 0, 0);
1393 $creditnoteamount = 0;
1394 $depositsamount = 0;
1398 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1403 if ($deja_regle > 0) {
1407 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1408 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1409 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1410 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1413 $pdf->SetTextColor(0, 0, 60);
1414 $pdf->SetFillColor(224, 224, 224);
1415 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1416 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1418 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1419 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1421 $pdf->SetFont(
'',
'', $default_font_size - 1);
1422 $pdf->SetTextColor(0, 0, 0);
1425 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1427 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1429 $this->error = $hookmanager->error;
1430 $this->errors = $hookmanager->errors;
1434 return ($tab2_top + ($tab2_hl * $index));
1511 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1514 global
$conf, $langs, $hookmanager, $mysoc;
1516 $ltrdirection =
'L';
1517 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1518 $ltrdirection =
'R';
1522 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1528 $pdf->SetTextColor(0, 0, 60);
1529 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1533 $posy = $this->marge_haute;
1534 $posx = $this->page_largeur - $this->marge_droite - $w;
1536 $pdf->SetXY($this->marge_gauche, $posy);
1540 if ($this->emetteur->logo) {
1541 $logodir =
$conf->mycompany->dir_output;
1546 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1548 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1550 if (is_readable($logo)) {
1552 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1554 $pdf->SetTextColor(200, 0, 0);
1555 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1556 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1557 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1560 $text = $this->emetteur->name;
1561 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1565 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1566 $pdf->SetXY($posx, $posy);
1567 $pdf->SetTextColor(0, 0, 60);
1568 $title = $outputlangs->transnoentities($titlekey);
1569 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1571 $title .= $outputlangsbis->transnoentities($titlekey);
1573 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1574 if (
$object->statut == $object::STATUS_DRAFT) {
1575 $pdf->SetTextColor(128, 0, 0);
1576 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1579 $pdf->MultiCell($w, 3, $title,
'',
'R');
1581 $pdf->SetFont(
'',
'B', $default_font_size);
1596 $pdf->SetFont(
'',
'', $default_font_size - 2);
1600 $pdf->SetXY($posx, $posy);
1601 $pdf->SetTextColor(0, 0, 60);
1602 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
1607 if (!empty(
$object->project->ref)) {
1609 $pdf->SetXY($posx, $posy);
1610 $pdf->SetTextColor(0, 0, 60);
1611 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1617 if (!empty(
$object->project->ref)) {
1618 $outputlangs->load(
"projects");
1620 $pdf->SetXY($posx, $posy);
1621 $pdf->SetTextColor(0, 0, 60);
1622 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1628 $pdf->SetXY($posx, $posy);
1629 $pdf->SetTextColor(0, 0, 60);
1630 $title = $outputlangs->transnoentities(
"OrderDate");
1631 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1632 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1634 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1638 $pdf->SetXY($posx, $posy);
1639 $pdf->SetTextColor(0, 0, 60);
1640 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1645 $pdf->SetXY($posx, $posy);
1646 $pdf->SetTextColor(0, 0, 60);
1647 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1652 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1653 if (count($arrayidcontact) > 0) {
1654 $usertmp =
new User($this->db);
1655 $usertmp->fetch($arrayidcontact[0]);
1657 $pdf->SetXY($posx, $posy);
1658 $pdf->SetTextColor(0, 0, 60);
1659 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1668 $current_y = $pdf->getY();
1670 if ($current_y < $pdf->getY()) {
1671 $top_shift = $pdf->getY() - $current_y;
1676 $carac_emetteur =
'';
1678 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1679 if (count($arrayidcontact) > 0) {
1680 $object->fetch_user($arrayidcontact[0]);
1681 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1682 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1684 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1688 $carac_emetteur .=
"\n";
1695 $posy += $top_shift;
1696 $posx = $this->marge_gauche;
1698 $posx = $this->page_largeur - $this->marge_droite - 80;
1702 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1707 $pdf->SetTextColor(0, 0, 0);
1708 $pdf->SetFont(
'',
'', $default_font_size - 2);
1709 $pdf->SetXY($posx, $posy - 5);
1710 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1711 $pdf->SetXY($posx, $posy);
1712 $pdf->SetFillColor(230, 230, 230);
1713 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1714 $pdf->SetTextColor(0, 0, 60);
1719 $pdf->SetXY($posx + 2, $posy + 3);
1720 $pdf->SetFont(
'',
'B', $default_font_size);
1721 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1722 $posy = $pdf->getY();
1726 $pdf->SetXY($posx + 2, $posy);
1727 $pdf->SetFont(
'',
'', $default_font_size - 1);
1728 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1731 $usecontact =
false;
1732 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1733 if (count($arrayidcontact) > 0) {
1735 $result =
$object->fetch_contact($arrayidcontact[0]);
1740 $thirdparty =
$object->contact;
1742 $thirdparty =
$object->thirdparty;
1745 if (is_object($thirdparty)) {
1753 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1754 if ($this->page_largeur < 210) {
1758 $posy += $top_shift;
1759 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1761 $posx = $this->marge_gauche;
1766 $pdf->SetTextColor(0, 0, 0);
1767 $pdf->SetFont(
'',
'', $default_font_size - 2);
1768 $pdf->SetXY($posx + 2, $posy - 5);
1769 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1770 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1774 $pdf->SetXY($posx + 2, $posy + 3);
1775 $pdf->SetFont(
'',
'B', $default_font_size);
1777 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1779 $posy = $pdf->getY();
1782 $pdf->SetFont(
'',
'', $default_font_size - 1);
1783 $pdf->SetXY($posx + 2, $posy);
1785 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1789 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1791 if (!empty($idaddressshipping)) {
1792 $contactshipping =
$object->fetch_contact($idaddressshipping[0]);
1793 $companystatic =
new Societe($this->db);
1794 $companystatic->fetch(
$object->contact->fk_soc);
1796 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
1801 if (!empty($carac_client_shipping)) {
1802 $posy += $hautcadre;
1807 $pdf->SetXY($posx + 2, $posy - 5);
1808 $pdf->SetFont(
'',
'', $default_font_size - 2);
1809 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
1810 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1813 $pdf->SetXY($posx + 2, $posy + 1);
1814 $pdf->SetFont(
'',
'B', $default_font_size);
1815 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1817 $posy = $pdf->getY();
1820 $pdf->SetXY($posx + 2, $posy);
1821 $pdf->SetFont(
'',
'', $default_font_size - 1);
1822 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1824 $shipp_shift += $hautcadre + 10;
1829 $pdf->SetTextColor(0, 0, 0);
1831 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);