163 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
166 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
168 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
170 if (!is_object($outputlangs)) {
171 $outputlangs = $langs;
175 $outputlangs->charset_output =
'ISO-8859-1';
179 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"products",
"propal",
"compta");
180 $outputlangs->loadLangs($langfiles);
187 global $outputlangsbis;
188 $outputlangsbis =
null;
192 $outputlangsbis->loadLangs($langfiles);
195 $nblines = count(
$object->lines);
203 $realpatharray = array();
204 $this->atleastonephoto =
false;
206 $objphoto =
new Product($this->db);
208 for ($i = 0; $i < $nblines; $i++) {
209 if (empty(
$object->lines[$i]->fk_product)) {
213 $objphoto->fetch(
$object->lines[$i]->fk_product);
217 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
218 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
220 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
221 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
226 foreach ($pdir as $midir) {
228 if (
$conf->entity != $objphoto->entity) {
229 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
231 $dir =
$conf->product->dir_output.
'/'.$midir;
234 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
236 if ($obj[
'photo_vignette']) {
237 $filename = $obj[
'photo_vignette'];
239 $filename = $obj[
'photo'];
242 $filename = $obj[
'photo'];
245 $realpath = $dir.$filename;
247 $this->atleastonephoto =
true;
252 if ($realpath && $arephoto) {
253 $realpatharray[$i] = $realpath;
258 if (count($realpatharray) == 0) {
259 $this->posxpicture = $this->posxtva;
262 if (
$conf->propal->multidir_output[
$conf->entity]) {
269 $dir =
$conf->propal->multidir_output[
$conf->entity];
270 $file = $dir.
"/SPECIMEN.pdf";
273 $dir =
$conf->propal->multidir_output[
$object->entity].
"/".$objectref;
274 $file = $dir.
"/".$objectref.
".pdf";
277 if (!file_exists($dir)) {
279 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
284 if (file_exists($dir)) {
286 if (!is_object($hookmanager)) {
287 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
290 $hookmanager->initHooks(array(
'pdfgeneration'));
291 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
293 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
296 $nblines = count(
$object->lines);
302 $pdf->SetAutoPageBreak(1, 0);
304 if (class_exists(
'TCPDF')) {
305 $pdf->setPrintHeader(
false);
306 $pdf->setPrintFooter(
false);
311 $logodir =
$conf->mycompany->dir_output;
312 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
313 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
315 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
316 $tplidx = $pdf->importPage(1);
321 $pdf->SetDrawColor(128, 128, 128);
323 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
324 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
325 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
326 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
327 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
329 $pdf->SetCompression(
false);
333 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
336 for ($i = 0; $i < $nblines; $i++) {
337 if (
$object->lines[$i]->remise_percent) {
338 $this->atleastonediscount++;
345 if (!empty($tplidx)) {
346 $pdf->useTemplate($tplidx);
350 $heightforinfotot = 40;
353 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
356 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
357 $pdf->SetFont(
'',
'', $default_font_size - 1);
358 $pdf->MultiCell(0, 3,
'');
359 $pdf->SetTextColor(0, 0, 0);
362 $tab_top = 90 + $top_shift;
363 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
368 $height_incoterms = 0;
369 if (isModEnabled(
'incoterm')) {
370 $desc_incoterms =
$object->getIncotermsForPDF();
371 if ($desc_incoterms) {
374 $pdf->SetFont(
'',
'', $default_font_size - 1);
375 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
376 $nexY = max($pdf->GetY(), $nexY);
377 $height_incoterms = $nexY - $tab_top;
380 $pdf->SetDrawColor(192, 192, 192);
381 $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');
383 $tab_top = $nexY + 6;
384 $height_incoterms += 4;
389 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
392 if (is_object(
$object->thirdparty)) {
393 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
394 $salerepobj =
new User($this->db);
395 $salerepobj->fetch($salereparray[0][
'id']);
396 if (!empty($salerepobj->signature)) {
397 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
403 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
404 if (!empty($extranote)) {
409 $tmpuser =
new User($this->db);
410 $tmpuser->fetch(
$object->user_author_id);
412 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
413 if ($tmpuser->email) {
414 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
416 if ($tmpuser->office_phone) {
417 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
423 $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
425 $pagenb = $pdf->getPage();
429 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
430 $pageposbeforenote = $pagenb;
437 $pdf->startTransaction();
439 $pdf->SetFont(
'',
'', $default_font_size - 1);
440 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
442 $pageposafternote = $pdf->getPage();
443 $posyafter = $pdf->GetY();
445 if ($pageposafternote > $pageposbeforenote) {
446 $pdf->rollbackTransaction(
true);
449 while ($pagenb < $pageposafternote) {
452 if (!empty($tplidx)) {
453 $pdf->useTemplate($tplidx);
459 $pdf->setTopMargin($tab_top_newpage);
461 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
465 $pdf->setPage($pageposbeforenote);
466 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
467 $pdf->SetFont(
'',
'', $default_font_size - 1);
468 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
469 $pageposafternote = $pdf->getPage();
471 $posyafter = $pdf->GetY();
473 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
474 $pdf->AddPage(
'',
'',
true);
477 $pdf->setPage($pageposafternote);
478 $pdf->setTopMargin($tab_top_newpage);
480 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
486 $i = $pageposbeforenote;
487 while ($i < $pageposafternote) {
491 $pdf->SetDrawColor(128, 128, 128);
493 if ($i > $pageposbeforenote) {
494 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
495 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
497 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
498 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
502 $pdf->setPageOrientation(
'', 1, 0);
509 $pdf->setPage($pageposafternote);
510 if (!empty($tplidx)) {
511 $pdf->useTemplate($tplidx);
516 $height_note = $posyafter - $tab_top_newpage;
517 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
520 $pdf->commitTransaction();
521 $posyafter = $pdf->GetY();
522 $height_note = $posyafter - $tab_top;
523 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
526 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
528 $pdf->AddPage(
'',
'',
true);
531 $pdf->setPage($pageposafternote);
532 if (!empty($tplidx)) {
533 $pdf->useTemplate($tplidx);
539 $posyafter = $tab_top_newpage;
542 $tab_height -= $height_note;
543 $tab_top = $posyafter + 6;
552 $pdf->startTransaction();
553 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
554 $pdf->rollbackTransaction(
true);
556 $nexY = $tab_top + $this->tabTitleHeight;
559 $pageposbeforeprintlines = $pdf->getPage();
560 $pagenb = $pageposbeforeprintlines;
561 for ($i = 0; $i < $nblines; $i++) {
563 $pdf->SetFont(
'',
'', $default_font_size - 1);
564 $pdf->SetTextColor(0, 0, 0);
567 $imglinesize = array();
568 if (!empty($realpatharray[$i])) {
572 $pdf->setTopMargin($tab_top_newpage);
573 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
574 $pageposbefore = $pdf->getPage();
576 $showpricebeforepagebreak = 1;
578 $posYAfterDescription = 0;
582 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
583 $pdf->AddPage(
'',
'',
true);
584 if (!empty($tplidx)) {
585 $pdf->useTemplate($tplidx);
587 $pdf->setPage($pageposbefore + 1);
589 $curY = $tab_top_newpage;
593 $showpricebeforepagebreak = 1;
595 $showpricebeforepagebreak = 0;
600 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
601 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
603 $posYAfterImage = $curY + $imglinesize[
'height'];
609 $pdf->startTransaction();
612 $pageposafter = $pdf->getPage();
614 if ($pageposafter > $pageposbefore) {
615 $pdf->rollbackTransaction(
true);
617 $pdf->setPageOrientation(
'', 1, $heightforfooter);
621 $pageposafter = $pdf->getPage();
622 $posyafter = $pdf->GetY();
624 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
625 if ($i == ($nblines - 1)) {
626 $pdf->AddPage(
'',
'',
true);
627 if (!empty($tplidx)) {
628 $pdf->useTemplate($tplidx);
630 $pdf->setPage($pageposafter + 1);
636 $showpricebeforepagebreak = 1;
638 $showpricebeforepagebreak = 0;
642 $pdf->commitTransaction();
644 $posYAfterDescription = $pdf->GetY();
647 $nexY = $pdf->GetY();
648 $pageposafter = $pdf->getPage();
650 $pdf->setPage($pageposbefore);
651 $pdf->setTopMargin($this->marge_haute);
652 $pdf->setPageOrientation(
'', 1, 0);
655 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
656 $pdf->setPage($pageposafter);
657 $curY = $tab_top_newpage;
660 $pdf->SetFont(
'',
'', $default_font_size - 1);
671 $nexY = max($pdf->GetY(), $nexY);
678 $nexY = max($pdf->GetY(), $nexY);
686 $nexY = max($pdf->GetY(), $nexY);
694 $nexY = max($pdf->GetY(), $nexY);
701 $nexY = max($pdf->GetY(), $nexY);
708 $nexY = max($pdf->GetY(), $nexY);
715 $nexY = max($pdf->GetY(), $nexY);
719 if (!empty(
$object->lines[$i]->array_options)) {
720 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
724 $nexY = max($pdf->GetY(), $nexY);
735 'outputlangs' => $outputlangs,
736 'hidedetails' => $hidedetails
738 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
742 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
743 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
745 $tvaligne =
$object->lines[$i]->total_tva;
748 $localtax1ligne =
$object->lines[$i]->total_localtax1;
749 $localtax2ligne =
$object->lines[$i]->total_localtax2;
750 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
751 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
752 $localtax1_type =
$object->lines[$i]->localtax1_type;
753 $localtax2_type =
$object->lines[$i]->localtax2_type;
766 $vatrate = (string)
$object->lines[$i]->tva_tx;
769 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
770 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
772 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
773 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
777 if ($localtax1_type && $localtax1ligne != 0) {
778 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
779 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
781 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
784 if ($localtax2_type && $localtax2ligne != 0) {
785 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
786 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
788 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
792 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
797 if (!isset($this->tva[$vatrate])) {
798 $this->tva[$vatrate] = 0;
800 $this->tva[$vatrate] += $tvaligne;
801 $vatcode =
$object->lines[$i]->vat_src_code;
802 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
803 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
805 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
807 if ($posYAfterImage > $posYAfterDescription) {
808 $nexY = max($nexY, $posYAfterImage);
813 $pdf->setPage($pageposafter);
814 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
816 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
817 $pdf->SetLineStyle(array(
'dash' => 0));
823 while ($pagenb < $pageposafter) {
824 $pdf->setPage($pagenb);
825 if ($pagenb == $pageposbeforeprintlines) {
826 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
828 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
832 $pdf->setPage($pagenb);
833 $pdf->setPageOrientation(
'', 1, 0);
837 if (!empty($tplidx)) {
838 $pdf->useTemplate($tplidx);
842 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
843 if ($pagenb == $pageposafter) {
844 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
846 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
851 if (!empty($tplidx)) {
852 $pdf->useTemplate($tplidx);
862 if ($pagenb == $pageposbeforeprintlines) {
863 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
864 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
866 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
867 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
883 if (method_exists($pdf,
'AliasNbPages')) {
884 $pdf->AliasNbPages();
888 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL')) {
889 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
890 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
891 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
893 if (file_exists($termsofsale) && is_readable($termsofsale)) {
894 $pagecount = $pdf->setSourceFile($termsofsale);
895 for ($i = 1; $i <= $pagecount; $i++) {
896 $tplIdx = $pdf->importPage($i);
897 if ($tplIdx!==
false) {
898 $s = $pdf->getTemplatesize($tplIdx);
899 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
900 $pdf->useTemplate($tplIdx);
902 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
910 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
912 $already_merged = array();
913 foreach (
$object->lines as $line) {
914 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
919 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
921 $filetomerge->fetch_by_product($line->fk_product);
924 $already_merged[] = $line->fk_product;
926 $product =
new Product($this->db);
927 $product->fetch($line->fk_product);
929 if ($product->entity !=
$conf->entity) {
930 $entity_product_file = $product->entity;
932 $entity_product_file =
$conf->entity;
936 if (count($filetomerge->lines) > 0) {
937 foreach ($filetomerge->lines as $linefile) {
938 if (!empty($linefile->id) && !empty($linefile->file_name)) {
940 if (isModEnabled(
"product")) {
941 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
942 } elseif (isModEnabled(
"service")) {
943 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
946 if (isModEnabled(
"product")) {
947 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
948 } elseif (isModEnabled(
"service")) {
949 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
953 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
955 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
956 if (file_exists($infile) && is_readable($infile)) {
957 $pagecount = $pdf->setSourceFile($infile);
958 for ($i = 1; $i <= $pagecount; $i++) {
959 $tplIdx = $pdf->importPage($i);
960 if ($tplIdx !==
false) {
961 $s = $pdf->getTemplatesize($tplIdx);
962 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
963 $pdf->useTemplate($tplIdx);
965 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
978 $pdf->Output($file,
'F');
981 $hookmanager->initHooks(array(
'pdfgeneration'));
982 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
984 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
986 $this->error = $hookmanager->error;
987 $this->errors = $hookmanager->errors;
992 $this->result = array(
'fullpath' => $file);
996 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
1000 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
1016 global
$conf, $mysoc;
1019 $pdf->SetFont(
'',
'', $default_font_size - 1);
1024 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1025 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1026 $pdf->SetXY($this->marge_gauche, $posy);
1027 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1029 $posy = $pdf->GetY() + 4;
1034 $displaydate =
"daytext";
1036 $displaydate =
"day";
1040 if (!empty(
$object->delivery_date)) {
1041 $outputlangs->load(
"sendings");
1042 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1043 $pdf->SetXY($this->marge_gauche, $posy);
1044 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1045 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1046 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1047 $pdf->SetXY($posxval, $posy);
1049 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1051 $posy = $pdf->GetY() + 1;
1053 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1054 $pdf->SetXY($this->marge_gauche, $posy);
1055 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1056 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1057 $pdf->SetTextColor(0, 0, 0);
1058 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1059 $pdf->SetXY($posxval, $posy);
1060 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
1061 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1062 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1064 $posy = $pdf->GetY() + 1;
1069 $outputlangs->load(
"sendings");
1071 $shipping_method_id =
$object->shipping_method_id;
1072 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1073 $shipping_method_id = $this->emetteur->shipping_method_id;
1075 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1076 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1078 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1079 $pdf->SetXY($this->marge_gauche, $posy);
1080 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1081 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1083 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1084 $pdf->SetXY($posxval, $posy);
1085 $lib_condition_paiement = ($outputlangs->transnoentities(
"SendingMethod".strtoupper($shipping_method_code)) !=
"SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans(
"SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label;
1086 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1087 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1089 $posy = $pdf->GetY() + 1;
1094 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1095 $pdf->SetXY($this->marge_gauche, $posy);
1096 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1097 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1099 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1100 $pdf->SetXY($posxval, $posy);
1101 $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);
1102 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1103 if (
$object->deposit_percent > 0) {
1104 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1106 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1108 $posy = $pdf->GetY() + 3;
1113 if (
$object->mode_reglement_code
1114 &&
$object->mode_reglement_code !=
'CHQ'
1115 &&
$object->mode_reglement_code !=
'VIR') {
1116 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1117 $pdf->SetXY($this->marge_gauche, $posy);
1118 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1119 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1120 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1121 $pdf->SetXY($posxval, $posy);
1122 $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);
1123 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1125 $posy = $pdf->GetY() + 2;
1129 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1133 $account =
new Account($this->db);
1136 $pdf->SetXY($this->marge_gauche, $posy);
1137 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1138 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1139 $posy = $pdf->GetY() + 1;
1142 $pdf->SetXY($this->marge_gauche, $posy);
1143 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1144 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1145 $posy = $pdf->GetY() + 2;
1149 $pdf->SetXY($this->marge_gauche, $posy);
1150 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1151 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1152 $posy = $pdf->GetY() + 1;
1155 $pdf->SetXY($this->marge_gauche, $posy);
1156 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1157 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1158 $posy = $pdf->GetY() + 2;
1165 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1171 $account =
new Account($this->db);
1172 $account->fetch($bankid);
1174 $curx = $this->marge_gauche;
1177 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1201 global
$conf, $mysoc, $hookmanager;
1208 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1209 $default_font_size--;
1214 $pdf->SetFont(
'',
'', $default_font_size - 1);
1219 if ($this->page_largeur < 210) {
1222 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1228 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1231 $total_line_remise = 0;
1232 foreach (
$object->lines as $i => $line) {
1234 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1236 if ($line->total_ht < 0) {
1237 $total_line_remise += -$line->total_ht;
1240 if ($total_line_remise > 0) {
1241 $pdf->SetFillColor(255, 255, 255);
1242 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1243 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1244 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1245 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1250 $pdf->SetFillColor(255, 255, 255);
1251 $pdf->SetXY($col1x, $tab2_top);
1252 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1253 $pdf->SetXY($col2x, $tab2_top);
1254 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1260 $pdf->SetFillColor(255, 255, 255);
1261 $pdf->SetXY($col1x, $tab2_top+ $tab2_hl * $index);
1262 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1264 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1265 $pdf->SetXY($col2x, $tab2_top+ $tab2_hl * $index);
1266 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1269 $pdf->SetFillColor(248, 248, 248);
1271 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1273 $this->atleastoneratenotnull = 0;
1275 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1276 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1282 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1283 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1287 foreach ($localtax_rate as $tvakey => $tvaval) {
1292 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1295 if (preg_match(
'/\*/', $tvakey)) {
1296 $tvakey = str_replace(
'*',
'', $tvakey);
1297 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1299 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1301 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1302 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1304 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1306 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1307 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1315 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1316 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1320 foreach ($localtax_rate as $tvakey => $tvaval) {
1325 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1328 if (preg_match(
'/\*/', $tvakey)) {
1329 $tvakey = str_replace(
'*',
'', $tvakey);
1330 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1332 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1334 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1335 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1337 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1339 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1340 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1347 foreach ($this->tva as $tvakey => $tvaval) {
1349 $this->atleastoneratenotnull++;
1352 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1355 if (preg_match(
'/\*/', $tvakey)) {
1356 $tvakey = str_replace(
'*',
'', $tvakey);
1357 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1359 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1361 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1362 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1364 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1365 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1372 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1373 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1377 foreach ($localtax_rate as $tvakey => $tvaval) {
1382 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1385 if (preg_match(
'/\*/', $tvakey)) {
1386 $tvakey = str_replace(
'*',
'', $tvakey);
1387 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1389 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1392 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1393 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1395 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1397 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1398 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1406 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1407 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1411 foreach ($localtax_rate as $tvakey => $tvaval) {
1417 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1420 if (preg_match(
'/\*/', $tvakey)) {
1421 $tvakey = str_replace(
'*',
'', $tvakey);
1422 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1424 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1428 $totalvat .= $tvacompl;
1430 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1433 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1435 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1437 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1438 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1446 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1447 $pdf->SetTextColor(0, 0, 60);
1448 $pdf->SetFillColor(224, 224, 224);
1449 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1451 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1452 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1456 $pdf->SetTextColor(0, 0, 0);
1464 if ($deja_regle > 0) {
1468 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1469 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1471 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1472 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1490 $pdf->SetTextColor(0, 0, 60);
1491 $pdf->SetFillColor(224, 224, 224);
1492 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1493 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1495 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1496 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1498 $pdf->SetFont(
'',
'', $default_font_size - 1);
1499 $pdf->SetTextColor(0, 0, 0);
1502 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1504 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1506 $this->error = $hookmanager->error;
1507 $this->errors = $hookmanager->errors;
1511 return ($tab2_top + ($tab2_hl * $index));
1594 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1596 global
$conf, $langs;
1598 $ltrdirection =
'L';
1599 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1600 $ltrdirection =
'R';
1604 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1610 $pdf->SetTextColor(0, 0, 60);
1611 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1615 $posy = $this->marge_haute;
1616 $posx = $this->page_largeur - $this->marge_droite - $w;
1618 $pdf->SetXY($this->marge_gauche, $posy);
1622 if ($this->emetteur->logo) {
1623 $logodir =
$conf->mycompany->dir_output;
1624 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1625 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1628 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1630 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1632 if (is_readable($logo)) {
1634 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1636 $pdf->SetTextColor(200, 0, 0);
1637 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1638 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1639 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1642 $text = $this->emetteur->name;
1643 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1647 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1648 $pdf->SetXY($posx, $posy);
1649 $pdf->SetTextColor(0, 0, 60);
1650 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1651 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1652 if (
$object->status == $object::STATUS_DRAFT) {
1653 $pdf->SetTextColor(128, 0, 0);
1654 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1657 $pdf->MultiCell($w, 4, $title,
'',
'R');
1659 $pdf->SetFont(
'',
'B', $default_font_size);
1674 $pdf->SetFont(
'',
'', $default_font_size - 2);
1677 if ($ref_customer) {
1679 $pdf->SetXY($posx, $posy);
1680 $pdf->SetTextColor(0, 0, 60);
1681 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65),
'',
'R');
1686 if (!empty(
$object->project->ref)) {
1688 $pdf->SetXY($posx, $posy);
1689 $pdf->SetTextColor(0, 0, 60);
1690 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1696 if (!empty(
$object->project->ref)) {
1697 $outputlangs->load(
"projects");
1699 $pdf->SetXY($posx, $posy);
1700 $pdf->SetTextColor(0, 0, 60);
1701 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1706 $displaydate =
"daytext";
1708 $displaydate =
"day";
1712 $posy = $pdf->getY();
1713 $pdf->SetXY($posx, $posy);
1714 $pdf->SetTextColor(0, 0, 60);
1715 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1718 $pdf->SetXY($posx, $posy);
1719 $pdf->SetTextColor(0, 0, 60);
1721 $title = $outputlangs->transnoentities(
"DateEndPropal");
1722 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1723 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1725 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1729 $pdf->SetXY($posx, $posy);
1730 $pdf->SetTextColor(0, 0, 60);
1731 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1736 $pdf->SetXY($posx, $posy);
1737 $pdf->SetTextColor(0, 0, 60);
1738 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1743 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1744 if (count($arrayidcontact) > 0) {
1745 $usertmp =
new User($this->db);
1746 $usertmp->fetch($arrayidcontact[0]);
1748 $pdf->SetXY($posx, $posy);
1749 $pdf->SetTextColor(0, 0, 60);
1750 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1758 $current_y = $pdf->getY();
1760 if ($current_y < $pdf->getY()) {
1761 $top_shift = $pdf->getY() - $current_y;
1766 $carac_emetteur =
'';
1768 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1769 if (count($arrayidcontact) > 0) {
1770 $object->fetch_user($arrayidcontact[0]);
1771 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1772 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1774 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1778 $carac_emetteur .=
"\n";
1785 $posy += $top_shift;
1786 $posx = $this->marge_gauche;
1788 $posx = $this->page_largeur - $this->marge_droite - 80;
1796 $pdf->SetTextColor(0, 0, 0);
1797 $pdf->SetFont(
'',
'', $default_font_size - 2);
1798 $pdf->SetXY($posx, $posy - 5);
1799 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1800 $pdf->SetXY($posx, $posy);
1801 $pdf->SetFillColor(230, 230, 230);
1802 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1803 $pdf->SetTextColor(0, 0, 60);
1808 $pdf->SetXY($posx + 2, $posy + 3);
1809 $pdf->SetFont(
'',
'B', $default_font_size);
1810 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1811 $posy = $pdf->getY();
1815 $pdf->SetXY($posx + 2, $posy);
1816 $pdf->SetFont(
'',
'', $default_font_size - 1);
1817 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1821 $usecontact =
false;
1822 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1823 if (count($arrayidcontact) > 0) {
1825 $result =
$object->fetch_contact($arrayidcontact[0]);
1829 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1830 $thirdparty =
$object->contact;
1832 $thirdparty =
$object->thirdparty;
1842 if ($this->page_largeur < 210) {
1846 $posy += $top_shift;
1847 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1849 $posx = $this->marge_gauche;
1854 $pdf->SetTextColor(0, 0, 0);
1855 $pdf->SetFont(
'',
'', $default_font_size - 2);
1856 $pdf->SetXY($posx + 2, $posy - 5);
1857 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1858 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1862 $pdf->SetXY($posx + 2, $posy + 3);
1863 $pdf->SetFont(
'',
'B', $default_font_size);
1865 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1867 $posy = $pdf->getY();
1870 $pdf->SetFont(
'',
'', $default_font_size - 1);
1871 $pdf->SetXY($posx + 2, $posy);
1873 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1876 $pdf->SetTextColor(0, 0, 0);