201 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
204 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
206 if (!is_object($outputlangs)) {
207 $outputlangs = $langs;
210 if (!empty($conf->global->MAIN_USE_FPDF)) {
211 $outputlangs->charset_output =
'ISO-8859-1';
215 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
218 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')) {
222 global $outputlangsbis;
223 $outputlangsbis =
null;
224 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
225 $outputlangsbis =
new Translate(
'', $conf);
226 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
227 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
230 $nblines = count($object->lines);
233 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
234 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
238 $realpatharray = array();
239 $this->atleastonephoto =
false;
240 if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
241 $objphoto =
new Product($this->db);
243 for ($i = 0; $i < $nblines; $i++) {
244 if (empty($object->lines[$i]->fk_product)) {
248 $objphoto->fetch($object->lines[$i]->fk_product);
251 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
252 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
254 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
255 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
259 foreach ($pdir as $midir) {
261 if ($conf->entity != $objphoto->entity) {
262 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
264 $dir = $conf->product->dir_output.
'/'.$midir;
267 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
269 if ($obj[
'photo_vignette']) {
270 $filename = $obj[
'photo_vignette'];
272 $filename = $obj[
'photo'];
275 $filename = $obj[
'photo'];
278 $realpath = $dir.$filename;
280 $this->atleastonephoto =
true;
285 if ($realpath && $arephoto) {
286 $realpatharray[$i] = $realpath;
294 $object->fetch_thirdparty();
299 if ($object->specimen) {
301 $file = $dir.
"/SPECIMEN.pdf";
305 $file = $dir.
"/".$objectref.
".pdf";
308 if (!file_exists($dir)) {
310 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
315 if (file_exists($dir)) {
317 if (!is_object($hookmanager)) {
318 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
321 $hookmanager->initHooks(array(
'pdfgeneration'));
322 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
324 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
327 $nblines = count($object->lines);
332 $pdf->SetAutoPageBreak(1, 0);
334 $heightforinfotot = 40;
335 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
336 $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
338 if (class_exists(
'TCPDF')) {
339 $pdf->setPrintHeader(
false);
340 $pdf->setPrintFooter(
false);
344 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
345 $logodir = $conf->mycompany->dir_output;
346 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
347 $logodir = $conf->mycompany->multidir_output[$object->entity];
349 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
350 $tplidx = $pdf->importPage(1);
355 $pdf->SetDrawColor(128, 128, 128);
357 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
358 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
359 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
360 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
361 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
363 $pdf->SetCompression(
false);
366 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
369 for ($i = 0; $i < $nblines; $i++) {
370 if ($object->lines[$i]->remise_percent) {
371 $this->atleastonediscount++;
378 if (!empty($tplidx)) {
379 $pdf->useTemplate($tplidx);
382 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
383 $pdf->SetFont(
'',
'', $default_font_size - 1);
384 $pdf->MultiCell(0, 3,
'');
385 $pdf->SetTextColor(0, 0, 0);
388 $tab_top = 90 + $top_shift;
389 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
391 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
394 $height_incoterms = 0;
395 if (isModEnabled(
'incoterm')) {
396 $desc_incoterms = $object->getIncotermsForPDF();
397 if ($desc_incoterms) {
400 $pdf->SetFont(
'',
'', $default_font_size - 1);
401 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
402 $nexY = max($pdf->GetY(), $nexY);
403 $height_incoterms = $nexY - $tab_top;
406 $pdf->SetDrawColor(192, 192, 192);
407 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
409 $tab_top = $nexY + 6;
414 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
415 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
417 if (is_object($object->thirdparty)) {
418 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
419 $salerepobj =
new User($this->db);
420 $salerepobj->fetch($salereparray[0][
'id']);
421 if (!empty($salerepobj->signature)) {
422 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
428 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
429 if (!empty($extranote)) {
433 $pagenb = $pdf->getPage();
437 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
438 $pageposbeforenote = $pagenb;
445 $pdf->startTransaction();
447 $pdf->SetFont(
'',
'', $default_font_size - 1);
448 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
450 $pageposafternote = $pdf->getPage();
451 $posyafter = $pdf->GetY();
453 if ($pageposafternote > $pageposbeforenote) {
454 $pdf->rollbackTransaction(
true);
457 while ($pagenb < $pageposafternote) {
460 if (!empty($tplidx)) {
461 $pdf->useTemplate($tplidx);
464 $this->
_pagehead($pdf, $object, 0, $outputlangs);
467 $pdf->setTopMargin($tab_top_newpage);
469 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
473 $pdf->setPage($pageposbeforenote);
474 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
475 $pdf->SetFont(
'',
'', $default_font_size - 1);
476 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
477 $pageposafternote = $pdf->getPage();
479 $posyafter = $pdf->GetY();
481 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
482 $pdf->AddPage(
'',
'',
true);
485 $pdf->setPage($pageposafternote);
486 $pdf->setTopMargin($tab_top_newpage);
488 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
494 $i = $pageposbeforenote;
495 while ($i < $pageposafternote) {
499 $pdf->SetDrawColor(128, 128, 128);
501 if ($i > $pageposbeforenote) {
502 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
503 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
505 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
506 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
510 $pdf->setPageOrientation(
'', 1, 0);
511 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
517 $pdf->setPage($pageposafternote);
518 if (!empty($tplidx)) {
519 $pdf->useTemplate($tplidx);
522 $this->
_pagehead($pdf, $object, 0, $outputlangs);
524 $height_note = $posyafter - $tab_top_newpage;
525 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
528 $pdf->commitTransaction();
529 $posyafter = $pdf->GetY();
530 $height_note = $posyafter - $tab_top;
531 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
534 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
536 $pdf->AddPage(
'',
'',
true);
539 $pdf->setPage($pageposafternote);
540 if (!empty($tplidx)) {
541 $pdf->useTemplate($tplidx);
544 $this->
_pagehead($pdf, $object, 0, $outputlangs);
547 $posyafter = $tab_top_newpage;
551 $tab_height = $tab_height - $height_note;
552 $tab_top = $posyafter + 6;
562 $pdf->startTransaction();
563 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
564 $pdf->rollbackTransaction(
true);
566 $nexY = $tab_top + $this->tabTitleHeight;
569 $pageposbeforeprintlines = $pdf->getPage();
570 $pagenb = $pageposbeforeprintlines;
571 for ($i = 0; $i < $nblines; $i++) {
573 $pdf->SetFont(
'',
'', $default_font_size - 1);
574 $pdf->SetTextColor(0, 0, 0);
577 $imglinesize = array();
578 if (!empty($realpatharray[$i])) {
582 $pdf->setTopMargin($tab_top_newpage);
583 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
584 $pageposbefore = $pdf->getPage();
587 $showpricebeforepagebreak = 1;
589 $posYAfterDescription = 0;
593 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
594 $pdf->AddPage(
'',
'',
true);
595 if (!empty($tplidx)) {
596 $pdf->useTemplate($tplidx);
598 $pdf->setPage($pageposbefore + 1);
600 $curY = $tab_top_newpage;
603 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
604 $showpricebeforepagebreak = 1;
606 $showpricebeforepagebreak = 0;
610 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
611 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
613 $posYAfterImage = $curY + $imglinesize[
'height'];
619 $pdf->startTransaction();
621 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
622 $pageposafter = $pdf->getPage();
624 if ($pageposafter > $pageposbefore) {
625 $pdf->rollbackTransaction(
true);
626 $pageposafter = $pageposbefore;
628 $pdf->setPageOrientation(
'', 1, $heightforfooter);
630 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
631 $pageposafter = $pdf->getPage();
632 $posyafter = $pdf->GetY();
633 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
634 if ($i == ($nblines - 1)) {
635 $pdf->AddPage(
'',
'',
true);
636 if (!empty($tplidx)) {
637 $pdf->useTemplate($tplidx);
640 $pdf->setPage($pageposafter + 1);
645 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
646 $showpricebeforepagebreak = 1;
648 $showpricebeforepagebreak = 0;
653 $pdf->commitTransaction();
655 $posYAfterDescription = $pdf->GetY();
659 $nexY = max($pdf->GetY(), $posYAfterImage);
662 $pageposafter = $pdf->getPage();
664 $pdf->setPage($pageposbefore);
665 $pdf->setTopMargin($this->marge_haute);
666 $pdf->setPageOrientation(
'', 1, 0);
669 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
670 $pdf->setPage($pageposafter);
671 $curY = $tab_top_newpage;
674 $pdf->SetFont(
'',
'', $default_font_size - 1);
680 $nexY = max($pdf->GetY(), $nexY);
687 $nexY = max($pdf->GetY(), $nexY);
695 $nexY = max($pdf->GetY(), $nexY);
701 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
703 $nexY = max($pdf->GetY(), $nexY);
707 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
710 $nexY = max($pdf->GetY(), $nexY);
717 $nexY = max($pdf->GetY(), $nexY);
724 $nexY = max($pdf->GetY(), $nexY);
728 if (!empty($object->lines[$i]->array_options)) {
729 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
731 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
733 $nexY = max($pdf->GetY(), $nexY);
744 'outputlangs' => $outputlangs,
745 'hidedetails' => $hidedetails
747 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
751 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
752 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
754 $tvaligne = $object->lines[$i]->total_tva;
757 $localtax1ligne = $object->lines[$i]->total_localtax1;
758 $localtax2ligne = $object->lines[$i]->total_localtax2;
759 $localtax1_rate = $object->lines[$i]->localtax1_tx;
760 $localtax2_rate = $object->lines[$i]->localtax2_tx;
761 $localtax1_type = $object->lines[$i]->localtax1_type;
762 $localtax2_type = $object->lines[$i]->localtax2_type;
775 $vatrate = (string) $object->lines[$i]->tva_tx;
778 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
779 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
781 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
782 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
786 if ($localtax1_type && $localtax1ligne != 0) {
787 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
788 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
790 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
793 if ($localtax2_type && $localtax2ligne != 0) {
794 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
795 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
797 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
801 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
806 if (!isset($this->tva[$vatrate])) {
807 $this->tva[$vatrate] = 0;
809 $this->tva[$vatrate] += $tvaligne;
810 $vatcode = $object->lines[$i]->vat_src_code;
811 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
812 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
814 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
817 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
818 $pdf->setPage($pageposafter);
819 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
821 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
822 $pdf->SetLineStyle(array(
'dash'=>0));
827 while ($pagenb < $pageposafter) {
828 $pdf->setPage($pagenb);
829 if ($pagenb == $pageposbeforeprintlines) {
830 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
832 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
834 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
836 $pdf->setPage($pagenb);
837 $pdf->setPageOrientation(
'', 1, 0);
839 $this->
_pagehead($pdf, $object, 0, $outputlangs);
841 if (!empty($tplidx)) {
842 $pdf->useTemplate($tplidx);
845 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
846 if ($pagenb == $pageposafter) {
847 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
849 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
851 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
854 if (!empty($tplidx)) {
855 $pdf->useTemplate($tplidx);
859 $this->
_pagehead($pdf, $object, 0, $outputlangs);
865 if ($pagenb == $pageposbeforeprintlines) {
866 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
868 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
870 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
873 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
876 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
887 $this->
_pagefoot($pdf, $object, $outputlangs);
888 if (method_exists($pdf,
'AliasNbPages')) {
889 $pdf->AliasNbPages();
894 $pdf->Output($file,
'F');
897 $hookmanager->initHooks(array(
'pdfgeneration'));
898 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
900 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
902 $this->error = $hookmanager->error;
903 $this->errors = $hookmanager->errors;
908 $this->result = array(
'fullpath'=>$file);
912 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
916 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
946 global $conf, $mysoc;
949 $pdf->SetFont(
'',
'', $default_font_size - 1);
951 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
954 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
955 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
956 $pdf->SetXY($this->marge_gauche, $posy);
957 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
959 $posy = $pdf->GetY() + 4;
964 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
967 if ($object->cond_reglement_code || $object->cond_reglement) {
968 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
969 $pdf->SetXY($this->marge_gauche, $posy);
970 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
971 $pdf->MultiCell(43, 4, $titre, 0,
'L');
973 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
974 $pdf->SetXY($posxval, $posy);
975 $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);
976 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
977 if ($object->deposit_percent > 0) {
978 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
980 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
982 $posy = $pdf->GetY() + 3;
1013 if (!empty($object->delivery_date)) {
1014 $outputlangs->load(
"sendings");
1015 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1016 $pdf->SetXY($this->marge_gauche, $posy);
1017 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1018 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1019 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1020 $pdf->SetXY($posxval, $posy);
1021 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
1022 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1024 $posy = $pdf->GetY() + 1;
1025 } elseif ($object->availability_code || $object->availability) {
1026 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1027 $pdf->SetXY($this->marge_gauche, $posy);
1028 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1029 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1030 $pdf->SetTextColor(0, 0, 0);
1031 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1032 $pdf->SetXY($posxval, $posy);
1033 $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 :
'');
1034 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1035 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1037 $posy = $pdf->GetY() + 1;
1041 if ($object->mode_reglement_code
1042 && $object->mode_reglement_code !=
'CHQ'
1043 && $object->mode_reglement_code !=
'VIR') {
1044 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1045 $pdf->SetXY($this->marge_gauche, $posy);
1046 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1047 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1049 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1050 $pdf->SetXY($posxval, $posy);
1051 $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);
1052 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1054 $posy = $pdf->GetY() + 2;
1058 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1060 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1061 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1062 $account =
new Account($this->db);
1063 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1065 $pdf->SetXY($this->marge_gauche, $posy);
1066 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1067 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1068 $posy = $pdf->GetY() + 1;
1070 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1071 $pdf->SetXY($this->marge_gauche, $posy);
1072 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1073 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1074 $posy = $pdf->GetY() + 2;
1077 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1078 $pdf->SetXY($this->marge_gauche, $posy);
1079 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1080 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1081 $posy = $pdf->GetY() + 1;
1083 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1084 $pdf->SetXY($this->marge_gauche, $posy);
1085 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1086 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1087 $posy = $pdf->GetY() + 2;
1094 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1095 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1096 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1097 if ($object->fk_bank > 0) {
1098 $bankid = $object->fk_bank;
1100 $account =
new Account($this->db);
1101 $account->fetch($bankid);
1103 $curx = $this->marge_gauche;
1106 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1127 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1129 global $conf, $mysoc, $hookmanager;
1133 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1134 $outputlangsbis =
new Translate(
'', $conf);
1135 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1136 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1137 $default_font_size--;
1142 $pdf->SetFont(
'',
'', $default_font_size - 1);
1147 if ($this->page_largeur < 210) {
1150 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1156 $pdf->SetFillColor(255, 255, 255);
1157 $pdf->SetXY($col1x, $tab2_top);
1158 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1159 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1160 $pdf->SetXY($col2x, $tab2_top);
1161 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1164 $pdf->SetFillColor(248, 248, 248);
1166 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1168 $this->atleastoneratenotnull = 0;
1169 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1170 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1171 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1177 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1178 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1181 foreach ($localtax_rate as $tvakey => $tvaval) {
1185 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1188 if (preg_match(
'/\*/', $tvakey)) {
1189 $tvakey = str_replace(
'*',
'', $tvakey);
1190 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1192 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1194 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1195 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1197 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1199 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1200 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1208 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1209 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1212 foreach ($localtax_rate as $tvakey => $tvaval) {
1217 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1220 if (preg_match(
'/\*/', $tvakey)) {
1221 $tvakey = str_replace(
'*',
'', $tvakey);
1222 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1224 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1226 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1227 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1229 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1231 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1232 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1239 foreach ($this->tva_array as $tvakey => $tvaval) {
1241 $this->atleastoneratenotnull++;
1244 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1247 if (preg_match(
'/\*/', $tvakey)) {
1248 $tvakey = str_replace(
'*',
'', $tvakey);
1249 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1251 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1254 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1256 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1258 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1260 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1262 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1263 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1270 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1271 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1275 foreach ($localtax_rate as $tvakey => $tvaval) {
1280 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1283 if (preg_match(
'/\*/', $tvakey)) {
1284 $tvakey = str_replace(
'*',
'', $tvakey);
1285 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1287 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1289 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1291 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1293 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1295 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1296 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1304 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1305 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1309 foreach ($localtax_rate as $tvakey => $tvaval) {
1315 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1318 if (preg_match(
'/\*/', $tvakey)) {
1319 $tvakey = str_replace(
'*',
'', $tvakey);
1320 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1322 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1325 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1326 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1328 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1330 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1331 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1339 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1340 $pdf->SetTextColor(0, 0, 60);
1341 $pdf->SetFillColor(224, 224, 224);
1342 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1344 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1345 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1349 $pdf->SetTextColor(0, 0, 0);
1351 $creditnoteamount = 0;
1352 $depositsamount = 0;
1356 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1357 if (!empty($object->paye)) {
1361 if ($deja_regle > 0) {
1365 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1366 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1367 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1368 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1371 $pdf->SetTextColor(0, 0, 60);
1372 $pdf->SetFillColor(224, 224, 224);
1373 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1374 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1376 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1377 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1379 $pdf->SetFont(
'',
'', $default_font_size - 1);
1380 $pdf->SetTextColor(0, 0, 0);
1384 return ($tab2_top + ($tab2_hl * $index));
1461 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1464 global $conf, $langs, $hookmanager, $mysoc;
1466 $ltrdirection =
'L';
1467 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1470 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1476 $pdf->SetTextColor(0, 0, 60);
1477 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1481 $posy = $this->marge_haute;
1482 $posx = $this->page_largeur - $this->marge_droite - $w;
1484 $pdf->SetXY($this->marge_gauche, $posy);
1488 if ($this->emetteur->logo) {
1489 $logodir = $conf->mycompany->dir_output;
1494 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1496 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1498 if (is_readable($logo)) {
1500 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1502 $pdf->SetTextColor(200, 0, 0);
1503 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1504 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1505 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1508 $text = $this->emetteur->name;
1509 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1513 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1514 $pdf->SetXY($posx, $posy);
1515 $pdf->SetTextColor(0, 0, 60);
1516 $title = $outputlangs->transnoentities($titlekey);
1517 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1519 $title .= $outputlangsbis->transnoentities($titlekey);
1521 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1522 if ($object->statut == $object::STATUS_DRAFT) {
1523 $pdf->SetTextColor(128, 0, 0);
1524 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1527 $pdf->MultiCell($w, 3, $title,
'',
'R');
1529 $pdf->SetFont(
'',
'B', $default_font_size);
1544 $pdf->SetFont(
'',
'', $default_font_size - 2);
1546 if ($object->ref_client) {
1548 $pdf->SetXY($posx, $posy);
1549 $pdf->SetTextColor(0, 0, 60);
1550 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65),
'',
'R');
1553 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1554 $object->fetch_projet();
1555 if (!empty($object->project->ref)) {
1557 $pdf->SetXY($posx, $posy);
1558 $pdf->SetTextColor(0, 0, 60);
1559 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1563 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1564 $object->fetch_projet();
1565 if (!empty($object->project->ref)) {
1566 $outputlangs->load(
"projects");
1568 $pdf->SetXY($posx, $posy);
1569 $pdf->SetTextColor(0, 0, 60);
1570 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1576 $pdf->SetXY($posx, $posy);
1577 $pdf->SetTextColor(0, 0, 60);
1578 $title = $outputlangs->transnoentities(
"OrderDate");
1579 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1580 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1582 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1584 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1586 $pdf->SetXY($posx, $posy);
1587 $pdf->SetTextColor(0, 0, 60);
1588 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1592 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1593 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1594 if (count($arrayidcontact) > 0) {
1595 $usertmp =
new User($this->db);
1596 $usertmp->fetch($arrayidcontact[0]);
1598 $pdf->SetXY($posx, $posy);
1599 $pdf->SetTextColor(0, 0, 60);
1600 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1608 $current_y = $pdf->getY();
1609 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1610 if ($current_y < $pdf->getY()) {
1611 $top_shift = $pdf->getY() - $current_y;
1616 $carac_emetteur =
'';
1618 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1619 if (count($arrayidcontact) > 0) {
1620 $object->fetch_user($arrayidcontact[0]);
1621 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1622 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1624 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1626 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1628 $carac_emetteur .=
"\n";
1631 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1634 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1635 $posy += $top_shift;
1636 $posx = $this->marge_gauche;
1637 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1638 $posx = $this->page_largeur - $this->marge_droite - 80;
1641 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1642 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1646 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1647 $pdf->SetTextColor(0, 0, 0);
1648 $pdf->SetFont(
'',
'', $default_font_size - 2);
1649 $pdf->SetXY($posx, $posy - 5);
1650 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1651 $pdf->SetXY($posx, $posy);
1652 $pdf->SetFillColor(230, 230, 230);
1653 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1654 $pdf->SetTextColor(0, 0, 60);
1658 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1659 $pdf->SetXY($posx + 2, $posy + 3);
1660 $pdf->SetFont(
'',
'B', $default_font_size);
1661 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1662 $posy = $pdf->getY();
1666 $pdf->SetXY($posx + 2, $posy);
1667 $pdf->SetFont(
'',
'', $default_font_size - 1);
1668 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1671 $usecontact =
false;
1672 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1673 if (count($arrayidcontact) > 0) {
1675 $result = $object->fetch_contact($arrayidcontact[0]);
1679 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1680 $thirdparty = $object->contact;
1682 $thirdparty = $object->thirdparty;
1688 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1691 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1692 if ($this->page_largeur < 210) {
1695 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1696 $posy += $top_shift;
1697 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1698 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1699 $posx = $this->marge_gauche;
1703 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1704 $pdf->SetTextColor(0, 0, 0);
1705 $pdf->SetFont(
'',
'', $default_font_size - 2);
1706 $pdf->SetXY($posx + 2, $posy - 5);
1707 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1708 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1712 $pdf->SetXY($posx + 2, $posy + 3);
1713 $pdf->SetFont(
'',
'B', $default_font_size);
1714 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1716 $posy = $pdf->getY();
1719 $pdf->SetFont(
'',
'', $default_font_size - 1);
1720 $pdf->SetXY($posx + 2, $posy);
1721 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1724 $pdf->SetTextColor(0, 0, 0);