162 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
165 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
167 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
169 if (!is_object($outputlangs)) {
170 $outputlangs = $langs;
174 $outputlangs->charset_output =
'ISO-8859-1';
178 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"products",
"propal",
"compta");
179 $outputlangs->loadLangs($langfiles);
186 global $outputlangsbis;
187 $outputlangsbis =
null;
191 $outputlangsbis->loadLangs($langfiles);
194 $nblines = count(
$object->lines);
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);
213 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
214 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
216 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
217 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
222 foreach ($pdir as $midir) {
224 if (
$conf->entity != $objphoto->entity) {
225 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
227 $dir =
$conf->product->dir_output.
'/'.$midir;
230 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
232 if ($obj[
'photo_vignette']) {
233 $filename = $obj[
'photo_vignette'];
235 $filename = $obj[
'photo'];
238 $filename = $obj[
'photo'];
241 $realpath = $dir.$filename;
243 $this->atleastonephoto =
true;
248 if ($realpath && $arephoto) {
249 $realpatharray[$i] = $realpath;
254 if (count($realpatharray) == 0) {
255 $this->posxpicture = $this->posxtva;
258 if (
$conf->propal->multidir_output[
$conf->entity]) {
265 $dir =
$conf->propal->multidir_output[
$conf->entity];
266 $file = $dir.
"/SPECIMEN.pdf";
269 $dir =
$conf->propal->multidir_output[
$object->entity].
"/".$objectref;
270 $file = $dir.
"/".$objectref.
".pdf";
273 if (!file_exists($dir)) {
275 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
280 if (file_exists($dir)) {
282 if (!is_object($hookmanager)) {
283 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
286 $hookmanager->initHooks(array(
'pdfgeneration'));
287 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
289 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
292 $nblines = count(
$object->lines);
298 $pdf->SetAutoPageBreak(1, 0);
300 if (class_exists(
'TCPDF')) {
301 $pdf->setPrintHeader(
false);
302 $pdf->setPrintFooter(
false);
307 $logodir =
$conf->mycompany->dir_output;
308 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
309 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
311 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
312 $tplidx = $pdf->importPage(1);
317 $pdf->SetDrawColor(128, 128, 128);
319 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
320 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
321 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
322 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
323 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
325 $pdf->SetCompression(
false);
329 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
332 for ($i = 0; $i < $nblines; $i++) {
333 if (
$object->lines[$i]->remise_percent) {
334 $this->atleastonediscount++;
341 if (!empty($tplidx)) {
342 $pdf->useTemplate($tplidx);
346 $heightforinfotot = 40;
349 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
352 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
353 $pdf->SetFont(
'',
'', $default_font_size - 1);
354 $pdf->MultiCell(0, 3,
'');
355 $pdf->SetTextColor(0, 0, 0);
358 $tab_top = 90 + $top_shift;
359 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
360 if (!$hidetop &&
getDolGlobalInt(
'MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
362 $tab_top_newpage+= $this->tabTitleHeight;
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;
562 for ($i = 0; $i < $nblines; $i++) {
563 $linePosition = $i + 1;
567 if (isset(
$object->lines[$i]->pagebreak) &&
$object->lines[$i]->pagebreak) {
570 if (!empty($tplidx)) {
571 $pdf->useTemplate($tplidx);
574 $pdf->setPage($pdf->getNumPages());
575 $nexY = $tab_top_newpage;
580 $pdf->SetFont(
'',
'', $default_font_size - 1);
581 $pdf->SetTextColor(0, 0, 0);
584 $imglinesize = array();
585 if (!empty($realpatharray[$i])) {
589 $pdf->setTopMargin($tab_top_newpage);
590 $pdf->setPageOrientation(
'', 1, $heightforfooter);
591 $pageposbefore = $pdf->getPage();
595 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
602 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imageTopMargin + $imglinesize[
'height']) > ($this->page_hauteur - $heightforfooter)) {
603 $pdf->AddPage(
'',
'',
true);
604 if (!empty($tplidx)) {
605 $pdf->useTemplate($tplidx);
607 $pdf->setPage($pageposbefore + 1);
608 $pdf->setPageOrientation(
'', 1, $heightforfooter);
609 $curY = $tab_top_newpage;
610 $showpricebeforepagebreak = 0;
613 $pdf->setPageOrientation(
'', 0, $heightforfooter + $heightforfreetext);
614 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
615 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + $imageTopMargin, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
617 $posYAfterImage = $curY + $imglinesize[
'height'];
624 $pdf->setPageOrientation(
'', 1, $heightforfooter);
632 $pdf->setPage($pageposbefore);
633 $pdf->setTopMargin($this->marge_haute);
635 $pdf->setPageOrientation(
'', 0, $heightforfooter);
639 if ($afterPosData[
'page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
640 $pdf->setPage($afterPosData[
'page']);
641 $curY = $tab_top_newpage;
644 $pdf->SetFont(
'',
'', $default_font_size - 1);
697 if (!empty(
$object->lines[$i]->array_options)) {
698 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
714 'nexY' => & $afterPosData[
'y'],
715 'outputlangs' => $outputlangs,
716 'hidedetails' => $hidedetails
718 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
722 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
723 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
725 $tvaligne =
$object->lines[$i]->total_tva;
728 $localtax1ligne =
$object->lines[$i]->total_localtax1;
729 $localtax2ligne =
$object->lines[$i]->total_localtax2;
730 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
731 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
732 $localtax1_type =
$object->lines[$i]->localtax1_type;
733 $localtax2_type =
$object->lines[$i]->localtax2_type;
746 $vatrate = (string)
$object->lines[$i]->tva_tx;
749 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
750 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
752 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
753 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
757 if ($localtax1_type && $localtax1ligne != 0) {
758 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
759 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
761 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
764 if ($localtax2_type && $localtax2ligne != 0) {
765 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
766 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
768 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
772 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
777 if (!isset($this->tva[$vatrate])) {
778 $this->tva[$vatrate] = 0;
780 $this->tva[$vatrate] += $tvaligne;
781 $vatcode =
$object->lines[$i]->vat_src_code;
782 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
783 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
785 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
790 $pdf->setPage($afterPosData[
'page']);
791 $nexY = $afterPosData[
'y'];
794 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $heightforfooter - 5) {
795 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
797 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
798 $pdf->SetLineStyle(array(
'dash' => 0));
807 if ($afterPosData[
'y'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot) ) {
809 if (!empty($tplidx)) {
810 $pdf->useTemplate($tplidx);
813 $pdf->setPage($pagenb);
817 $drawTabNumbPage = $pdf->getNumPages();
818 for ($i=$pageposbeforeprintlines; $i<=$drawTabNumbPage; $i++) {
821 $pdf->setPageOrientation(
'', 0, 0);
823 $drawTabHideTop = $hidetop;
824 $drawTabTop = $tab_top_newpage;
825 $drawTabBottom = $this->page_hauteur - $heightforfooter;;
828 if ($i == $pageposbeforeprintlines) {
830 $drawTabTop = $tab_top;
831 } elseif (!$drawTabHideTop) {
833 $drawTabTop-= $this->tabTitleHeight;
840 if ($i == $pdf->getNumPages()) {
842 $drawTabBottom-= $heightforsignature + $heightforfreetext + $heightforinfotot;
845 $drawTabHeight = $drawTabBottom - $drawTabTop;
846 $this->
_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom,
$object->multicurrency_code, $outputlangsbis);
848 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0;
854 $pdf->setPageOrientation(
'', 1, 0);
857 if (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
860 if (!empty($tplidx)) {
861 $pdf->useTemplate($tplidx);
866 $pdf->SetTextColor(0, 0, 0);
868 $pdf->setPage($pdf->getNumPages());
870 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
884 if (method_exists($pdf,
'AliasNbPages')) {
885 $pdf->AliasNbPages();
889 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL')) {
890 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
891 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
892 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
894 if (file_exists($termsofsale) && is_readable($termsofsale)) {
895 $pagecount = $pdf->setSourceFile($termsofsale);
896 for ($i = 1; $i <= $pagecount; $i++) {
897 $tplIdx = $pdf->importPage($i);
898 if ($tplIdx!==
false) {
899 $s = $pdf->getTemplatesize($tplIdx);
900 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
901 $pdf->useTemplate($tplIdx);
903 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
911 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
913 $already_merged = array();
914 foreach (
$object->lines as $line) {
915 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
920 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
922 $filetomerge->fetch_by_product($line->fk_product);
925 $already_merged[] = $line->fk_product;
927 $product =
new Product($this->db);
928 $product->fetch($line->fk_product);
930 if ($product->entity !=
$conf->entity) {
931 $entity_product_file = $product->entity;
933 $entity_product_file =
$conf->entity;
937 if (count($filetomerge->lines) > 0) {
938 foreach ($filetomerge->lines as $linefile) {
939 if (!empty($linefile->id) && !empty($linefile->file_name)) {
941 if (isModEnabled(
"product")) {
942 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
943 } elseif (isModEnabled(
"service")) {
944 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
947 if (isModEnabled(
"product")) {
948 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
949 } elseif (isModEnabled(
"service")) {
950 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
954 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
956 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
957 if (file_exists($infile) && is_readable($infile)) {
958 $pagecount = $pdf->setSourceFile($infile);
959 for ($i = 1; $i <= $pagecount; $i++) {
960 $tplIdx = $pdf->importPage($i);
961 if ($tplIdx !==
false) {
962 $s = $pdf->getTemplatesize($tplIdx);
963 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
964 $pdf->useTemplate($tplIdx);
966 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
979 $pdf->Output($file,
'F');
982 $hookmanager->initHooks(array(
'pdfgeneration'));
983 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
985 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
987 $this->error = $hookmanager->error;
988 $this->errors = $hookmanager->errors;
993 $this->result = array(
'fullpath' => $file);
997 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
1001 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
1017 global
$conf, $mysoc;
1020 $pdf->SetFont(
'',
'', $default_font_size - 1);
1025 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1026 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1027 $pdf->SetXY($this->marge_gauche, $posy);
1028 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1030 $posy = $pdf->GetY() + 4;
1035 $displaydate =
"daytext";
1037 $displaydate =
"day";
1041 if (!empty(
$object->delivery_date)) {
1042 $outputlangs->load(
"sendings");
1043 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1044 $pdf->SetXY($this->marge_gauche, $posy);
1045 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1046 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1047 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1048 $pdf->SetXY($posxval, $posy);
1050 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1052 $posy = $pdf->GetY() + 1;
1054 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1055 $pdf->SetXY($this->marge_gauche, $posy);
1056 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1057 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1058 $pdf->SetTextColor(0, 0, 0);
1059 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1060 $pdf->SetXY($posxval, $posy);
1061 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
1062 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1063 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1065 $posy = $pdf->GetY() + 1;
1070 $outputlangs->load(
"sendings");
1072 $shipping_method_id =
$object->shipping_method_id;
1073 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1074 $shipping_method_id = $this->emetteur->shipping_method_id;
1076 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1077 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1079 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1080 $pdf->SetXY($this->marge_gauche, $posy);
1081 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1082 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1084 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1085 $pdf->SetXY($posxval, $posy);
1086 $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;
1087 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1088 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1090 $posy = $pdf->GetY() + 1;
1095 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1096 $pdf->SetXY($this->marge_gauche, $posy);
1097 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1098 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1100 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1101 $pdf->SetXY($posxval, $posy);
1102 $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);
1103 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1104 if (
$object->deposit_percent > 0) {
1105 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1107 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1109 $posy = $pdf->GetY() + 3;
1114 if (
$object->mode_reglement_code
1115 &&
$object->mode_reglement_code !=
'CHQ'
1116 &&
$object->mode_reglement_code !=
'VIR') {
1117 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1118 $pdf->SetXY($this->marge_gauche, $posy);
1119 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1120 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1121 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1122 $pdf->SetXY($posxval, $posy);
1123 $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);
1124 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1126 $posy = $pdf->GetY() + 2;
1130 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1134 $account =
new Account($this->db);
1137 $pdf->SetXY($this->marge_gauche, $posy);
1138 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1139 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1140 $posy = $pdf->GetY() + 1;
1143 $pdf->SetXY($this->marge_gauche, $posy);
1144 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1145 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1146 $posy = $pdf->GetY() + 2;
1150 $pdf->SetXY($this->marge_gauche, $posy);
1151 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1152 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1153 $posy = $pdf->GetY() + 1;
1156 $pdf->SetXY($this->marge_gauche, $posy);
1157 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1158 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1159 $posy = $pdf->GetY() + 2;
1166 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1172 $account =
new Account($this->db);
1173 $account->fetch($bankid);
1175 $curx = $this->marge_gauche;
1178 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1202 global
$conf, $mysoc, $hookmanager;
1209 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1210 $default_font_size--;
1215 $pdf->SetFont(
'',
'', $default_font_size - 1);
1220 if ($this->page_largeur < 210) {
1223 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1229 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1232 $total_line_remise = 0;
1233 foreach (
$object->lines as $i => $line) {
1235 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1237 if ($line->total_ht < 0) {
1238 $total_line_remise += -$line->total_ht;
1241 if ($total_line_remise > 0) {
1242 $pdf->SetFillColor(255, 255, 255);
1243 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1244 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1245 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1246 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1251 $pdf->SetFillColor(255, 255, 255);
1252 $pdf->SetXY($col1x, $tab2_top);
1253 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1254 $pdf->SetXY($col2x, $tab2_top);
1255 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1261 $pdf->SetFillColor(255, 255, 255);
1262 $pdf->SetXY($col1x, $tab2_top+ $tab2_hl * $index);
1263 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1265 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1266 $pdf->SetXY($col2x, $tab2_top+ $tab2_hl * $index);
1267 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1270 $pdf->SetFillColor(248, 248, 248);
1272 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1274 $this->atleastoneratenotnull = 0;
1276 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1277 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1283 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1284 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1288 foreach ($localtax_rate as $tvakey => $tvaval) {
1293 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1296 if (preg_match(
'/\*/', $tvakey)) {
1297 $tvakey = str_replace(
'*',
'', $tvakey);
1298 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1300 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1302 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1303 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1305 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1307 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1308 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1316 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1317 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1321 foreach ($localtax_rate as $tvakey => $tvaval) {
1326 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1329 if (preg_match(
'/\*/', $tvakey)) {
1330 $tvakey = str_replace(
'*',
'', $tvakey);
1331 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1333 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1335 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1336 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1338 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1340 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1341 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1348 foreach ($this->tva as $tvakey => $tvaval) {
1350 $this->atleastoneratenotnull++;
1353 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1356 if (preg_match(
'/\*/', $tvakey)) {
1357 $tvakey = str_replace(
'*',
'', $tvakey);
1358 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1360 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1362 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1363 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1365 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1366 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1373 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1374 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1378 foreach ($localtax_rate as $tvakey => $tvaval) {
1383 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1386 if (preg_match(
'/\*/', $tvakey)) {
1387 $tvakey = str_replace(
'*',
'', $tvakey);
1388 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1390 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1393 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1394 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1396 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1398 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1399 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1407 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1408 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1412 foreach ($localtax_rate as $tvakey => $tvaval) {
1418 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1421 if (preg_match(
'/\*/', $tvakey)) {
1422 $tvakey = str_replace(
'*',
'', $tvakey);
1423 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1425 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1429 $totalvat .= $tvacompl;
1431 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1434 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1436 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1438 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1439 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1447 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1448 $pdf->SetTextColor(0, 0, 60);
1449 $pdf->SetFillColor(224, 224, 224);
1450 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1452 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1453 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1457 $pdf->SetTextColor(0, 0, 0);
1465 if ($deja_regle > 0) {
1469 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1470 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1472 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1473 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1491 $pdf->SetTextColor(0, 0, 60);
1492 $pdf->SetFillColor(224, 224, 224);
1493 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1494 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1496 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1497 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1499 $pdf->SetFont(
'',
'', $default_font_size - 1);
1500 $pdf->SetTextColor(0, 0, 0);
1503 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1505 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1507 $this->error = $hookmanager->error;
1508 $this->errors = $hookmanager->errors;
1512 return ($tab2_top + ($tab2_hl * $index));
1595 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1597 global
$conf, $langs;
1599 $ltrdirection =
'L';
1600 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1601 $ltrdirection =
'R';
1605 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1611 $pdf->SetTextColor(0, 0, 60);
1612 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1616 $posy = $this->marge_haute;
1617 $posx = $this->page_largeur - $this->marge_droite - $w;
1619 $pdf->SetXY($this->marge_gauche, $posy);
1623 if ($this->emetteur->logo) {
1624 $logodir =
$conf->mycompany->dir_output;
1625 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1626 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1629 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1631 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1633 if (is_readable($logo)) {
1635 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1637 $pdf->SetTextColor(200, 0, 0);
1638 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1639 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1640 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1643 $text = $this->emetteur->name;
1644 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1648 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1649 $pdf->SetXY($posx, $posy);
1650 $pdf->SetTextColor(0, 0, 60);
1651 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1652 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1653 if (
$object->status == $object::STATUS_DRAFT) {
1654 $pdf->SetTextColor(128, 0, 0);
1655 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1658 $pdf->MultiCell($w, 4, $title,
'',
'R');
1660 $pdf->SetFont(
'',
'B', $default_font_size);
1675 $pdf->SetFont(
'',
'', $default_font_size - 2);
1678 if ($ref_customer) {
1680 $pdf->SetXY($posx, $posy);
1681 $pdf->SetTextColor(0, 0, 60);
1682 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65),
'',
'R');
1687 if (!empty(
$object->project->ref)) {
1689 $pdf->SetXY($posx, $posy);
1690 $pdf->SetTextColor(0, 0, 60);
1691 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1697 if (!empty(
$object->project->ref)) {
1698 $outputlangs->load(
"projects");
1700 $pdf->SetXY($posx, $posy);
1701 $pdf->SetTextColor(0, 0, 60);
1702 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1707 $displaydate =
"daytext";
1709 $displaydate =
"day";
1713 $posy = $pdf->getY();
1714 $pdf->SetXY($posx, $posy);
1715 $pdf->SetTextColor(0, 0, 60);
1716 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1719 $pdf->SetXY($posx, $posy);
1720 $pdf->SetTextColor(0, 0, 60);
1722 $title = $outputlangs->transnoentities(
"DateEndPropal");
1723 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1724 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1726 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1730 $pdf->SetXY($posx, $posy);
1731 $pdf->SetTextColor(0, 0, 60);
1732 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1737 $pdf->SetXY($posx, $posy);
1738 $pdf->SetTextColor(0, 0, 60);
1739 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1744 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1745 if (count($arrayidcontact) > 0) {
1746 $usertmp =
new User($this->db);
1747 $usertmp->fetch($arrayidcontact[0]);
1749 $pdf->SetXY($posx, $posy);
1750 $pdf->SetTextColor(0, 0, 60);
1751 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1759 $current_y = $pdf->getY();
1761 if ($current_y < $pdf->getY()) {
1762 $top_shift = $pdf->getY() - $current_y;
1767 $carac_emetteur =
'';
1769 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1770 if (count($arrayidcontact) > 0) {
1771 $object->fetch_user($arrayidcontact[0]);
1772 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1773 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1775 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1779 $carac_emetteur .=
"\n";
1786 $posy += $top_shift;
1787 $posx = $this->marge_gauche;
1789 $posx = $this->page_largeur - $this->marge_droite - 80;
1797 $pdf->SetTextColor(0, 0, 0);
1798 $pdf->SetFont(
'',
'', $default_font_size - 2);
1799 $pdf->SetXY($posx, $posy - 5);
1800 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1801 $pdf->SetXY($posx, $posy);
1802 $pdf->SetFillColor(230, 230, 230);
1803 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1804 $pdf->SetTextColor(0, 0, 60);
1809 $pdf->SetXY($posx + 2, $posy + 3);
1810 $pdf->SetFont(
'',
'B', $default_font_size);
1811 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1812 $posy = $pdf->getY();
1816 $pdf->SetXY($posx + 2, $posy);
1817 $pdf->SetFont(
'',
'', $default_font_size - 1);
1818 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1822 $usecontact =
false;
1823 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1824 if (count($arrayidcontact) > 0) {
1826 $result =
$object->fetch_contact($arrayidcontact[0]);
1830 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1831 $thirdparty =
$object->contact;
1833 $thirdparty =
$object->thirdparty;
1843 if ($this->page_largeur < 210) {
1847 $posy += $top_shift;
1848 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1850 $posx = $this->marge_gauche;
1855 $pdf->SetTextColor(0, 0, 0);
1856 $pdf->SetFont(
'',
'', $default_font_size - 2);
1857 $pdf->SetXY($posx + 2, $posy - 5);
1858 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1859 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1863 $pdf->SetXY($posx + 2, $posy + 3);
1864 $pdf->SetFont(
'',
'B', $default_font_size);
1866 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1868 $posy = $pdf->getY();
1871 $pdf->SetFont(
'',
'', $default_font_size - 1);
1872 $pdf->SetXY($posx + 2, $posy);
1874 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1877 $pdf->SetTextColor(0, 0, 0);