160 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
163 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
165 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
167 if (!is_object($outputlangs)) {
168 $outputlangs = $langs;
172 $outputlangs->charset_output =
'ISO-8859-1';
176 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
179 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')) {
183 global $outputlangsbis;
184 $outputlangsbis =
null;
186 $outputlangsbis =
new Translate(
'', $conf);
188 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
191 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
199 $realpatharray = array();
200 $this->atleastonephoto =
false;
202 $objphoto =
new Product($this->db);
204 for ($i = 0; $i < $nblines; $i++) {
205 if (empty($object->lines[$i]->fk_product)) {
209 $objphoto->fetch($object->lines[$i]->fk_product);
212 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
213 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
215 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
216 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
220 foreach ($pdir as $midir) {
222 if ($conf->entity != $objphoto->entity) {
223 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
225 $dir = $conf->product->dir_output.
'/'.$midir;
228 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
230 if ($obj[
'photo_vignette']) {
231 $filename = $obj[
'photo_vignette'];
233 $filename = $obj[
'photo'];
236 $filename = $obj[
'photo'];
239 $realpath = $dir.$filename;
241 $this->atleastonephoto =
true;
246 if ($realpath && $arephoto) {
247 $realpatharray[$i] = $realpath;
255 $object->fetch_thirdparty();
260 if ($object->specimen) {
262 $file = $dir.
"/SPECIMEN.pdf";
266 $file = $dir.
"/".$objectref.
".pdf";
269 if (!file_exists($dir)) {
271 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
276 if (file_exists($dir)) {
278 if (!is_object($hookmanager)) {
279 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
282 $hookmanager->initHooks(array(
'pdfgeneration'));
283 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
285 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
288 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
293 $pdf->SetAutoPageBreak(1, 0);
295 $heightforinfotot = 40;
296 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
297 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
299 if (class_exists(
'TCPDF')) {
300 $pdf->setPrintHeader(
false);
301 $pdf->setPrintFooter(
false);
306 $logodir = $conf->mycompany->dir_output;
307 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
308 $logodir = $conf->mycompany->multidir_output[$object->entity];
310 $pagecount = $pdf->setSourceFile($logodir.
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
311 $tplidx = $pdf->importPage(1);
316 $pdf->SetDrawColor(128, 128, 128);
318 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
319 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
320 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
321 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
322 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
324 $pdf->SetCompression(
false);
327 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
330 for ($i = 0; $i < $nblines; $i++) {
331 if ($object->lines[$i]->remise_percent) {
332 $this->atleastonediscount++;
339 if (!empty($tplidx)) {
340 $pdf->useTemplate($tplidx);
343 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
344 $pdf->SetFont(
'',
'', $default_font_size - 1);
345 $pdf->MultiCell(0, 3,
'');
346 $pdf->SetTextColor(0, 0, 0);
349 $tab_top = 90 + $top_shift;
350 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
352 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
354 $nexY = $tab_top - 1;
357 $height_incoterms = 0;
358 if (isModEnabled(
'incoterm')) {
359 $desc_incoterms = $object->getIncotermsForPDF();
360 if ($desc_incoterms) {
363 $pdf->SetFont(
'',
'', $default_font_size - 1);
364 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
365 $nexY = max($pdf->GetY(), $nexY);
366 $height_incoterms = $nexY - $tab_top;
369 $pdf->SetDrawColor(192, 192, 192);
370 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
372 $tab_top = $nexY + 6;
377 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
380 if (is_object($object->thirdparty)) {
381 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
382 $salerepobj =
new User($this->db);
383 $salerepobj->fetch($salereparray[0][
'id']);
384 if (!empty($salerepobj->signature)) {
385 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
390 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
391 if (!empty($extranote)) {
395 $pagenb = $pdf->getPage();
399 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
400 $pageposbeforenote = $pagenb;
407 $pdf->startTransaction();
409 $pdf->SetFont(
'',
'', $default_font_size - 1);
410 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
412 $pageposafternote = $pdf->getPage();
413 $posyafter = $pdf->GetY();
415 if ($pageposafternote > $pageposbeforenote) {
416 $pdf->rollbackTransaction(
true);
419 while ($pagenb < $pageposafternote) {
422 if (!empty($tplidx)) {
423 $pdf->useTemplate($tplidx);
426 $this->
_pagehead($pdf, $object, 0, $outputlangs);
429 $pdf->setTopMargin($tab_top_newpage);
431 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
435 $pdf->setPage($pageposbeforenote);
436 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
437 $pdf->SetFont(
'',
'', $default_font_size - 1);
438 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
439 $pageposafternote = $pdf->getPage();
441 $posyafter = $pdf->GetY();
443 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
444 $pdf->AddPage(
'',
'',
true);
447 $pdf->setPage($pageposafternote);
448 $pdf->setTopMargin($tab_top_newpage);
450 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
456 $i = $pageposbeforenote;
457 while ($i < $pageposafternote) {
461 $pdf->SetDrawColor(128, 128, 128);
463 if ($i > $pageposbeforenote) {
464 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
465 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
467 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
468 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
472 $pdf->setPageOrientation(
'', 1, 0);
473 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
479 $pdf->setPage($pageposafternote);
480 if (!empty($tplidx)) {
481 $pdf->useTemplate($tplidx);
484 $this->
_pagehead($pdf, $object, 0, $outputlangs);
486 $height_note = $posyafter - $tab_top_newpage;
487 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
490 $pdf->commitTransaction();
491 $posyafter = $pdf->GetY();
492 $height_note = $posyafter - $tab_top;
493 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
496 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
498 $pdf->AddPage(
'',
'',
true);
501 $pdf->setPage($pageposafternote);
502 if (!empty($tplidx)) {
503 $pdf->useTemplate($tplidx);
506 $this->
_pagehead($pdf, $object, 0, $outputlangs);
509 $posyafter = $tab_top_newpage;
513 $tab_height = $tab_height - $height_note;
514 $tab_top = $posyafter + 6;
524 $pdf->startTransaction();
525 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
526 $pdf->rollbackTransaction(
true);
528 $nexY = $tab_top + $this->tabTitleHeight;
531 $pageposbeforeprintlines = $pdf->getPage();
532 $pagenb = $pageposbeforeprintlines;
533 for ($i = 0; $i < $nblines; $i++) {
535 $pdf->SetFont(
'',
'', $default_font_size - 1);
536 $pdf->SetTextColor(0, 0, 0);
539 $imglinesize = array();
540 if (!empty($realpatharray[$i])) {
544 $pdf->setTopMargin($tab_top_newpage);
545 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
546 $pageposbefore = $pdf->getPage();
549 $showpricebeforepagebreak = 1;
551 $posYAfterDescription = 0;
555 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
556 $pdf->AddPage(
'',
'',
true);
557 if (!empty($tplidx)) {
558 $pdf->useTemplate($tplidx);
560 $pdf->setPage($pageposbefore + 1);
562 $curY = $tab_top_newpage;
566 $showpricebeforepagebreak = 1;
568 $showpricebeforepagebreak = 0;
572 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
573 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
575 $posYAfterImage = $curY + $imglinesize[
'height'];
581 $pdf->startTransaction();
583 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
584 $pageposafter = $pdf->getPage();
586 if ($pageposafter > $pageposbefore) {
587 $pdf->rollbackTransaction(
true);
588 $pageposafter = $pageposbefore;
590 $pdf->setPageOrientation(
'', 1, $heightforfooter);
592 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
593 $pageposafter = $pdf->getPage();
594 $posyafter = $pdf->GetY();
595 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
596 if ($i == ($nblines - 1)) {
597 $pdf->AddPage(
'',
'',
true);
598 if (!empty($tplidx)) {
599 $pdf->useTemplate($tplidx);
601 $pdf->setPage($pageposafter + 1);
607 $showpricebeforepagebreak = 1;
609 $showpricebeforepagebreak = 0;
613 $pdf->commitTransaction();
615 $posYAfterDescription = $pdf->GetY();
619 $nexY = max($pdf->GetY(), $posYAfterImage);
622 $pageposafter = $pdf->getPage();
624 $pdf->setPage($pageposbefore);
625 $pdf->setTopMargin($this->marge_haute);
626 $pdf->setPageOrientation(
'', 1, 0);
629 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
630 $pdf->setPage($pageposafter);
631 $curY = $tab_top_newpage;
634 $pdf->SetFont(
'',
'', $default_font_size - 1);
640 $nexY = max($pdf->GetY(), $nexY);
647 $nexY = max($pdf->GetY(), $nexY);
655 $nexY = max($pdf->GetY(), $nexY);
661 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
663 $nexY = max($pdf->GetY(), $nexY);
667 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
670 $nexY = max($pdf->GetY(), $nexY);
677 $nexY = max($pdf->GetY(), $nexY);
684 $nexY = max($pdf->GetY(), $nexY);
688 if (!empty($object->lines[$i]->array_options)) {
689 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
691 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
693 $nexY = max($pdf->GetY(), $nexY);
704 'outputlangs' => $outputlangs,
705 'hidedetails' => $hidedetails
707 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
711 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
712 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
714 $tvaligne = $object->lines[$i]->total_tva;
717 $localtax1ligne = $object->lines[$i]->total_localtax1;
718 $localtax2ligne = $object->lines[$i]->total_localtax2;
719 $localtax1_rate = $object->lines[$i]->localtax1_tx;
720 $localtax2_rate = $object->lines[$i]->localtax2_tx;
721 $localtax1_type = $object->lines[$i]->localtax1_type;
722 $localtax2_type = $object->lines[$i]->localtax2_type;
724 $vatrate = (string) $object->lines[$i]->tva_tx;
727 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
728 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
730 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
731 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
735 if ($localtax1_type && $localtax1ligne != 0) {
736 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
737 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
739 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
742 if ($localtax2_type && $localtax2ligne != 0) {
743 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
744 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
746 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
750 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
755 if (!isset($this->tva[$vatrate])) {
756 $this->tva[$vatrate] = 0;
758 $this->tva[$vatrate] += $tvaligne;
759 $vatcode = $object->lines[$i]->vat_src_code;
760 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
761 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
763 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
766 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
767 $pdf->setPage($pageposafter);
768 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
770 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
771 $pdf->SetLineStyle(array(
'dash'=>0));
776 while ($pagenb < $pageposafter) {
777 $pdf->setPage($pagenb);
778 if ($pagenb == $pageposbeforeprintlines) {
779 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
781 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
783 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
785 $pdf->setPage($pagenb);
786 $pdf->setPageOrientation(
'', 1, 0);
788 $this->
_pagehead($pdf, $object, 0, $outputlangs);
790 if (!empty($tplidx)) {
791 $pdf->useTemplate($tplidx);
794 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
795 if ($pagenb == $pageposafter) {
796 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
798 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
800 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
803 if (!empty($tplidx)) {
804 $pdf->useTemplate($tplidx);
808 $this->
_pagehead($pdf, $object, 0, $outputlangs);
814 if ($pagenb == $pageposbeforeprintlines) {
815 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
817 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
819 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
822 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
825 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
836 $this->
_pagefoot($pdf, $object, $outputlangs);
837 if (method_exists($pdf,
'AliasNbPages')) {
838 $pdf->AliasNbPages();
843 $pdf->Output($file,
'F');
846 $hookmanager->initHooks(array(
'pdfgeneration'));
847 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
849 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
851 $this->error = $hookmanager->error;
852 $this->errors = $hookmanager->errors;
857 $this->result = array(
'fullpath'=>$file);
861 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
865 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
895 global $conf, $mysoc;
898 $pdf->SetFont(
'',
'', $default_font_size - 1);
900 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
903 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
904 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
905 $pdf->SetXY($this->marge_gauche, $posy);
906 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
908 $posy = $pdf->GetY() + 4;
913 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
916 if ($object->cond_reglement_code || $object->cond_reglement) {
917 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
918 $pdf->SetXY($this->marge_gauche, $posy);
919 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
920 $pdf->MultiCell(43, 4, $titre, 0,
'L');
922 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
923 $pdf->SetXY($posxval, $posy);
924 $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);
925 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
926 if ($object->deposit_percent > 0) {
927 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
929 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
931 $posy = $pdf->GetY() + 3;
962 if (!empty($object->delivery_date)) {
963 $outputlangs->load(
"sendings");
964 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
965 $pdf->SetXY($this->marge_gauche, $posy);
966 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
967 $pdf->MultiCell(80, 4, $titre, 0,
'L');
968 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
969 $pdf->SetXY($posxval, $posy);
970 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
971 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
973 $posy = $pdf->GetY() + 1;
974 } elseif ($object->availability_code || $object->availability) {
975 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
976 $pdf->SetXY($this->marge_gauche, $posy);
977 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
978 $pdf->MultiCell(80, 4, $titre, 0,
'L');
979 $pdf->SetTextColor(0, 0, 0);
980 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
981 $pdf->SetXY($posxval, $posy);
982 $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 :
'');
983 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
984 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
986 $posy = $pdf->GetY() + 1;
990 if ($object->mode_reglement_code
991 && $object->mode_reglement_code !=
'CHQ'
992 && $object->mode_reglement_code !=
'VIR') {
993 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
994 $pdf->SetXY($this->marge_gauche, $posy);
995 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
996 $pdf->MultiCell(80, 5, $titre, 0,
'L');
998 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
999 $pdf->SetXY($posxval, $posy);
1000 $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);
1001 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1003 $posy = $pdf->GetY() + 2;
1007 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1011 $account =
new Account($this->db);
1012 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1014 $pdf->SetXY($this->marge_gauche, $posy);
1015 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1016 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1017 $posy = $pdf->GetY() + 1;
1020 $pdf->SetXY($this->marge_gauche, $posy);
1021 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1022 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1023 $posy = $pdf->GetY() + 2;
1026 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1027 $pdf->SetXY($this->marge_gauche, $posy);
1028 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1029 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1030 $posy = $pdf->GetY() + 1;
1033 $pdf->SetXY($this->marge_gauche, $posy);
1034 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1035 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1036 $posy = $pdf->GetY() + 2;
1043 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1044 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1045 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1046 if ($object->fk_bank > 0) {
1047 $bankid = $object->fk_bank;
1049 $account =
new Account($this->db);
1050 $account->fetch($bankid);
1052 $curx = $this->marge_gauche;
1055 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1076 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1078 global $conf, $mysoc, $hookmanager;
1082 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1083 $outputlangsbis =
new Translate(
'', $conf);
1084 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1085 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1086 $default_font_size--;
1091 $pdf->SetFont(
'',
'', $default_font_size - 1);
1096 if ($this->page_largeur < 210) {
1099 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1105 $pdf->SetFillColor(255, 255, 255);
1106 $pdf->SetXY($col1x, $tab2_top);
1107 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1108 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1109 $pdf->SetXY($col2x, $tab2_top);
1110 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1113 $pdf->SetFillColor(248, 248, 248);
1115 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1117 $this->atleastoneratenotnull = 0;
1119 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1120 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1126 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1127 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1130 foreach ($localtax_rate as $tvakey => $tvaval) {
1134 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137 if (preg_match(
'/\*/', $tvakey)) {
1138 $tvakey = str_replace(
'*',
'', $tvakey);
1139 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1141 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1143 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1144 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1146 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1148 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1157 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1158 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1161 foreach ($localtax_rate as $tvakey => $tvaval) {
1166 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1169 if (preg_match(
'/\*/', $tvakey)) {
1170 $tvakey = str_replace(
'*',
'', $tvakey);
1171 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1173 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1175 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1176 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1178 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1180 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1181 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1188 foreach ($this->tva_array as $tvakey => $tvaval) {
1190 $this->atleastoneratenotnull++;
1193 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1196 if (preg_match(
'/\*/', $tvakey)) {
1197 $tvakey = str_replace(
'*',
'', $tvakey);
1198 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1200 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1203 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1205 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1207 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1209 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1211 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1212 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1219 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1220 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1224 foreach ($localtax_rate as $tvakey => $tvaval) {
1229 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1232 if (preg_match(
'/\*/', $tvakey)) {
1233 $tvakey = str_replace(
'*',
'', $tvakey);
1234 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1236 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1238 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1240 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1242 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1244 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1245 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1253 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1254 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1258 foreach ($localtax_rate as $tvakey => $tvaval) {
1264 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1267 if (preg_match(
'/\*/', $tvakey)) {
1268 $tvakey = str_replace(
'*',
'', $tvakey);
1269 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1271 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1274 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1275 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1277 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1279 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1280 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1288 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1289 $pdf->SetTextColor(0, 0, 60);
1290 $pdf->SetFillColor(224, 224, 224);
1291 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1293 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1294 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1298 $pdf->SetTextColor(0, 0, 0);
1300 $creditnoteamount = 0;
1301 $depositsamount = 0;
1305 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1306 if (!empty($object->paye)) {
1310 if ($deja_regle > 0) {
1314 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1315 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1316 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1317 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1320 $pdf->SetTextColor(0, 0, 60);
1321 $pdf->SetFillColor(224, 224, 224);
1322 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1323 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1325 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1326 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1328 $pdf->SetFont(
'',
'', $default_font_size - 1);
1329 $pdf->SetTextColor(0, 0, 0);
1333 return ($tab2_top + ($tab2_hl * $index));
1410 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1413 global $conf, $langs, $hookmanager, $mysoc;
1415 $ltrdirection =
'L';
1416 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1417 $ltrdirection =
'R';
1421 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1427 $pdf->SetTextColor(0, 0, 60);
1428 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1432 $posy = $this->marge_haute;
1433 $posx = $this->page_largeur - $this->marge_droite - $w;
1435 $pdf->SetXY($this->marge_gauche, $posy);
1439 if ($this->emetteur->logo) {
1440 $logodir = $conf->mycompany->dir_output;
1445 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1447 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1449 if (is_readable($logo)) {
1451 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1453 $pdf->SetTextColor(200, 0, 0);
1454 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1455 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1456 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1459 $text = $this->emetteur->name;
1460 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1464 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1465 $pdf->SetXY($posx, $posy);
1466 $pdf->SetTextColor(0, 0, 60);
1467 $title = $outputlangs->transnoentities($titlekey);
1468 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1470 $title .= $outputlangsbis->transnoentities($titlekey);
1472 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1473 if ($object->statut == $object::STATUS_DRAFT) {
1474 $pdf->SetTextColor(128, 0, 0);
1475 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1478 $pdf->MultiCell($w, 3, $title,
'',
'R');
1480 $pdf->SetFont(
'',
'B', $default_font_size);
1495 $pdf->SetFont(
'',
'', $default_font_size - 2);
1497 if ($object->ref_client) {
1499 $pdf->SetXY($posx, $posy);
1500 $pdf->SetTextColor(0, 0, 60);
1501 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65),
'',
'R');
1505 $object->fetch_projet();
1506 if (!empty($object->project->ref)) {
1508 $pdf->SetXY($posx, $posy);
1509 $pdf->SetTextColor(0, 0, 60);
1510 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1515 $object->fetch_projet();
1516 if (!empty($object->project->ref)) {
1517 $outputlangs->load(
"projects");
1519 $pdf->SetXY($posx, $posy);
1520 $pdf->SetTextColor(0, 0, 60);
1521 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1527 $pdf->SetXY($posx, $posy);
1528 $pdf->SetTextColor(0, 0, 60);
1529 $title = $outputlangs->transnoentities(
"OrderDate");
1530 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1531 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1533 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1535 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1537 $pdf->SetXY($posx, $posy);
1538 $pdf->SetTextColor(0, 0, 60);
1539 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1544 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1545 if (count($arrayidcontact) > 0) {
1546 $usertmp =
new User($this->db);
1547 $usertmp->fetch($arrayidcontact[0]);
1549 $pdf->SetXY($posx, $posy);
1550 $pdf->SetTextColor(0, 0, 60);
1551 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1559 $current_y = $pdf->getY();
1560 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1561 if ($current_y < $pdf->getY()) {
1562 $top_shift = $pdf->getY() - $current_y;
1567 $carac_emetteur =
'';
1569 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1570 if (count($arrayidcontact) > 0) {
1571 $object->fetch_user($arrayidcontact[0]);
1572 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1573 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1575 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1577 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1579 $carac_emetteur .=
"\n";
1582 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1586 $posy += $top_shift;
1587 $posx = $this->marge_gauche;
1589 $posx = $this->page_largeur - $this->marge_droite - 80;
1593 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1598 $pdf->SetTextColor(0, 0, 0);
1599 $pdf->SetFont(
'',
'', $default_font_size - 2);
1600 $pdf->SetXY($posx, $posy - 5);
1601 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1602 $pdf->SetXY($posx, $posy);
1603 $pdf->SetFillColor(230, 230, 230);
1604 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1605 $pdf->SetTextColor(0, 0, 60);
1610 $pdf->SetXY($posx + 2, $posy + 3);
1611 $pdf->SetFont(
'',
'B', $default_font_size);
1612 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1613 $posy = $pdf->getY();
1617 $pdf->SetXY($posx + 2, $posy);
1618 $pdf->SetFont(
'',
'', $default_font_size - 1);
1619 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1622 $usecontact =
false;
1623 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1624 if (count($arrayidcontact) > 0) {
1626 $result = $object->fetch_contact($arrayidcontact[0]);
1630 if ($usecontact && $object->contact->socid != $object->thirdparty->id &&
getDolGlobalInt(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
1631 $thirdparty = $object->contact;
1633 $thirdparty = $object->thirdparty;
1636 if (is_object($thirdparty)) {
1641 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1644 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1645 if ($this->page_largeur < 210) {
1649 $posy += $top_shift;
1650 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1652 $posx = $this->marge_gauche;
1657 $pdf->SetTextColor(0, 0, 0);
1658 $pdf->SetFont(
'',
'', $default_font_size - 2);
1659 $pdf->SetXY($posx + 2, $posy - 5);
1660 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1661 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1665 $pdf->SetXY($posx + 2, $posy + 3);
1666 $pdf->SetFont(
'',
'B', $default_font_size);
1667 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1669 $posy = $pdf->getY();
1672 $pdf->SetFont(
'',
'', $default_font_size - 1);
1673 $pdf->SetXY($posx + 2, $posy);
1674 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1677 $pdf->SetTextColor(0, 0, 0);