165 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
168 global $user, $langs,
$conf,
$mysoc, $db, $hookmanager, $nblines;
170 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
172 if (!is_object($outputlangs)) {
173 $outputlangs = $langs;
177 $outputlangs->charset_output =
'ISO-8859-1';
181 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"products",
"propal",
"compta");
182 $outputlangs->loadLangs($langfiles);
189 global $outputlangsbis;
190 $outputlangsbis =
null;
194 $outputlangsbis->loadLangs($langfiles);
197 $nblines = count(
$object->lines);
202 $realpatharray = array();
203 $this->atleastonephoto =
false;
205 $objphoto =
new Product($this->db);
207 for ($i = 0; $i < $nblines; $i++) {
208 if (empty(
$object->lines[$i]->fk_product)) {
212 $objphoto->fetch(
$object->lines[$i]->fk_product);
216 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
217 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
219 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
220 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
225 foreach ($pdir as $midir) {
227 $entity = $objphoto->entity;
228 if ($entity !==
null &&
$conf->entity != $entity) {
229 $dir =
$conf->product->multidir_output[$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 ??
$conf->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(
true, 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 ??
$conf->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->getAnonymisableFullName($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 $save_note_public =
$object->note_public;
358 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
359 $top_shift = $pagehead[
'top_shift'];
360 $shipp_shift = $pagehead[
'shipp_shift'];
361 $pdf->SetFont(
'',
'', $default_font_size - 1);
362 $pdf->MultiCell(0, 3,
'');
363 $pdf->SetTextColor(0, 0, 0);
366 $tab_top = 80 + $this->marge_haute + $top_shift + $shipp_shift;
367 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 32 + $this->marge_haute + $top_shift : $this->marge_haute);
368 if (!$hidetop &&
getDolGlobalInt(
'MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) {
370 $tab_top_newpage += $this->tabTitleHeight;
376 $height_incoterms = 0;
378 $desc_incoterms =
$object->getIncotermsForPDF();
379 if ($desc_incoterms) {
382 $pdf->SetFont(
'',
'', $default_font_size - 1);
383 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
384 $nexY = max($pdf->GetY(), $nexY);
385 $height_incoterms = $nexY - $tab_top;
388 $pdf->SetDrawColor(192, 192, 192);
389 $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');
391 $tab_top = $nexY + 6;
392 $height_incoterms += 4;
397 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
400 if (is_object(
$object->thirdparty)) {
401 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
402 $salerepobj =
new User($this->db);
403 $salerepobj->fetch($salereparray[0][
'id']);
404 if (!empty($salerepobj->signature)) {
405 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
410 $object->note_public = $save_note_public;
413 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
414 if (!empty($extranote)) {
419 $tmpuser =
new User($this->db);
420 $tmpuser->fetch(
$object->user_author_id);
422 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
423 if ($tmpuser->email) {
424 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
426 if ($tmpuser->office_phone) {
427 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
430 $notetoshow =
dol_concatdesc((
string) $notetoshow, $creator_info);
433 $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
435 $pagenb = $pdf->getPage();
439 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
440 $pageposbeforenote = $pagenb;
447 $pdf->startTransaction();
449 $pdf->SetFont(
'',
'', $default_font_size - 1);
450 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
452 $pageposafternote = $pdf->getPage();
453 $posyafter = $pdf->GetY();
455 if ($pageposafternote > $pageposbeforenote) {
456 $pdf->rollbackTransaction(
true);
459 while ($pagenb < $pageposafternote) {
462 if (!empty($tplidx)) {
463 $pdf->useTemplate($tplidx);
469 $pdf->setTopMargin($tab_top_newpage);
471 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
475 $pdf->setPage($pageposbeforenote);
476 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
477 $pdf->SetFont(
'',
'', $default_font_size - 1);
478 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
479 $pageposafternote = $pdf->getPage();
481 $posyafter = $pdf->GetY();
483 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
484 $pdf->AddPage(
'',
'',
true);
487 $pdf->setPage($pageposafternote);
488 $pdf->setTopMargin($tab_top_newpage);
490 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
496 $i = $pageposbeforenote;
497 while ($i < $pageposafternote) {
501 $pdf->SetDrawColor(128, 128, 128);
503 if ($i > $pageposbeforenote) {
504 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
505 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
507 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
508 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
512 $pdf->setPageOrientation(
'',
true, 0);
519 $pdf->setPage($pageposafternote);
520 if (!empty($tplidx)) {
521 $pdf->useTemplate($tplidx);
526 $height_note = $posyafter - $tab_top_newpage;
527 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
530 $pdf->commitTransaction();
531 $posyafter = $pdf->GetY();
532 $height_note = $posyafter - $tab_top;
533 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
536 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
538 $pdf->AddPage(
'',
'',
true);
541 $pdf->setPage($pageposafternote);
542 if (!empty($tplidx)) {
543 $pdf->useTemplate($tplidx);
549 $posyafter = $tab_top_newpage;
552 $tab_height -= $height_note;
553 $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;
572 $pdf_sub_options = array();
573 $pdf_sub_options[
'titleshowuponpdf'] = 1;
574 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
575 $pdf_sub_options_before_title = array();
579 for ($i = 0; $i < $nblines; $i++) {
580 $linePosition = $i + 1;
583 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
586 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
587 $level =
$object->lines[$i]->qty;
589 if ($level > 0 && !isset($pdf_sub_options_before_title[(
int) $level])) {
590 $pdf_sub_options_before_title[(int) $level] = $pdf_sub_options;
594 if (isset($sub_options[
'titleshowuponpdf'])) {
595 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
596 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
597 unset($pdf_sub_options[
'titleshowuponpdf']);
599 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
600 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
601 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
602 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
605 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
606 unset($pdf_sub_options[
'titleshowuponpdf']);
608 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
609 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
613 if ($level < 0 && isset($pdf_sub_options_before_title[(
int) abs($level)])) {
614 $pdf_sub_options = $pdf_sub_options_before_title[(int) abs($level)];
615 foreach (array_keys($pdf_sub_options_before_title) as $tmplevel) {
616 if ($tmplevel >= abs($level)) {
617 unset($pdf_sub_options_before_title[$tmplevel]);
623 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && isset($sub_options[
'subtotalshowtotalexludingvatonpdf']) &&
getDolGlobalString(
'SUBTOTAL_HIDE_LINES_UNDER_TITLE')) {
625 $pdf_sub_options = array();
626 $pdf_sub_options[
'titleshowuponpdf'] = 1;
627 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
633 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
634 $object->lines[$i]->pagebreak =
true;
638 if (isset(
$object->lines[$i]->pagebreak) &&
$object->lines[$i]->pagebreak) {
641 if (!empty($tplidx)) {
642 $pdf->useTemplate($tplidx);
645 $pdf->setPage($pdf->getNumPages());
646 $nexY = $curY = $tab_top_newpage;
651 $pdf->SetFont(
'',
'', $default_font_size - 1);
652 $pdf->SetTextColor(0, 0, 0);
655 $imglinesize = array();
656 if (!empty($realpatharray[$i])) {
660 $pdf->setTopMargin($tab_top_newpage);
661 $pdf->setPageOrientation(
'',
true, $heightforfooter);
662 $pageposbefore = $pdf->getPage();
666 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
673 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imageTopMargin + $imglinesize[
'height']) > ($this->page_hauteur - $heightforfooter)) {
674 $pdf->AddPage(
'',
'',
true);
675 if (!empty($tplidx)) {
676 $pdf->useTemplate($tplidx);
678 $pdf->setPage($pageposbefore + 1);
679 $pdf->setPageOrientation(
'',
true, $heightforfooter);
680 $curY = $tab_top_newpage;
681 $showpricebeforepagebreak = 0;
684 $pdf->setPageOrientation(
'',
false, $heightforfooter + $heightforfreetext);
686 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
687 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + $imageTopMargin, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
689 $posYAfterImage = $curY + $imglinesize[
'height'];
696 $pdf->setPageOrientation(
'',
true, $heightforfooter);
699 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
704 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
709 $pdf->setPage($pageposbefore);
710 $pdf->setTopMargin($this->marge_haute);
712 $pdf->setPageOrientation(
'',
false, $heightforfooter);
716 if ($afterPosData[
'page'] > $pageposbefore && (empty($showpricebeforepagebreak) || ($curY + 4) > ($this->page_hauteur - $heightforfooter))) {
717 $pdf->setPage($afterPosData[
'page']);
718 $curY = $tab_top_newpage;
721 $pdf->SetFont(
'',
'', $default_font_size - 1);
736 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
756 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE &&
$object->lines[$i]->remise_percent) {
763 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
766 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
768 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
770 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
777 if ($this->
getColumnStatus(
'totalincltax') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
783 if (!empty(
$object->lines[$i]->array_options)) {
784 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
800 'nexY' => & $afterPosData[
'y'],
801 'outputlangs' => $outputlangs,
802 'hidedetails' => $hidedetails
804 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
809 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
811 $tvaligne =
$object->lines[$i]->total_tva;
814 $localtax1ligne =
$object->lines[$i]->total_localtax1;
815 $localtax2ligne =
$object->lines[$i]->total_localtax2;
816 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
817 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
818 $localtax1_type =
$object->lines[$i]->localtax1_type;
819 $localtax2_type =
$object->lines[$i]->localtax2_type;
835 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
836 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
838 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
839 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
843 if ($localtax1_type && $localtax1ligne != 0) {
844 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
845 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
847 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
850 if ($localtax2_type && $localtax2ligne != 0) {
851 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
852 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
854 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
858 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
863 if (!isset($this->tva[$vatrate])) {
864 $this->tva[$vatrate] = 0;
866 $this->tva[$vatrate] += $tvaligne;
867 $vatcode =
$object->lines[$i]->vat_src_code;
868 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
869 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
871 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
874 if (!$hidenextline) {
876 $pdf->setPage($afterPosData[
'page']);
877 $nexY = $afterPosData[
'y'];
880 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $heightforfooter - 5) {
881 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
883 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
884 $pdf->SetLineStyle(array(
'dash' => 0));
888 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && (isset($sub_options[
'titleshowuponpdf']) || isset($sub_options[
'titleshowtotalexludingvatonpdf'])) &&
getDolGlobalString(
'SUBTOTAL_HIDE_LINES_UNDER_TITLE')) {
898 if (isset($afterPosData[
'y']) && $afterPosData[
'y'] > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
900 if (!empty($tplidx)) {
901 $pdf->useTemplate($tplidx);
904 $pdf->setPage($pagenb);
908 $drawTabNumbPage = $pdf->getNumPages();
909 for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) {
912 $pdf->setPageOrientation(
'',
false, 0);
914 $drawTabHideTop = $hidetop;
915 $drawTabTop = $tab_top_newpage;
916 $drawTabBottom = $this->page_hauteur - $heightforfooter;
919 if ($i == $pageposbeforeprintlines) {
921 $drawTabTop = $tab_top;
922 } elseif (!$drawTabHideTop) {
924 $drawTabTop -= $this->tabTitleHeight;
931 if ($i == $pdf->getNumPages()) {
933 $drawTabBottom -= $heightforsignature + $heightforfreetext + $heightforinfotot;
936 $drawTabHeight = $drawTabBottom - $drawTabTop;
937 $this->
_tableau($pdf, $drawTabTop, $drawTabHeight, 0, $outputlangs, $drawTabHideTop, $hideBottom,
$object->multicurrency_code, $outputlangsbis);
939 $hideFreeText = $i != $pdf->getNumPages() ? 1 : 0;
945 $pdf->setPageOrientation(
'',
true, 0);
948 if (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') && $i != $pageposbeforeprintlines) {
951 if (!empty($tplidx)) {
952 $pdf->useTemplate($tplidx);
957 $pdf->SetTextColor(0, 0, 0);
959 $pdf->setPage($pdf->getNumPages());
961 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
974 $keywords = $outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name);
975 $pdf->SetKeyWords($keywords.
" PAGESIGN=".$pdf->getPage());
979 if (method_exists($pdf,
'AliasNbPages')) {
980 $pdf->AliasNbPages();
985 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL') && $termsofsalefilename) {
986 $termsofsale =
$conf->propal->dir_output.
'/'.$termsofsalefilename;
988 $termsofsale =
$conf->propal->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
990 if (file_exists($termsofsale) && is_readable($termsofsale)) {
991 $pagecount = $pdf->setSourceFile($termsofsale);
992 for ($i = 1; $i <= $pagecount; $i++) {
993 $tplIdx = $pdf->importPage($i);
994 if ($tplIdx !==
false) {
995 $s = $pdf->getTemplatesize($tplIdx);
996 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
997 $pdf->useTemplate($tplIdx);
999 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
1007 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
1009 $already_merged = array();
1010 foreach (
$object->lines as $line) {
1011 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
1016 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
1018 $filetomerge->fetch_by_product($line->fk_product);
1021 $already_merged[] = $line->fk_product;
1023 $product =
new Product($this->db);
1024 $product->fetch($line->fk_product);
1026 if ($product->entity !=
$conf->entity) {
1027 $entity_product_file = $product->entity;
1029 $entity_product_file =
$conf->entity;
1033 if (count($filetomerge->lines) > 0) {
1034 foreach ($filetomerge->lines as $linefile) {
1035 if (!empty($linefile->id) && !empty($linefile->file_name)) {
1036 $filetomerge_dir =
null;
1039 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
1041 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
1045 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
1047 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
1051 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, $filetomerge_dir ===
null ? LOG_ERR : LOG_DEBUG);
1052 if ($filetomerge_dir ===
null) {
1057 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
1058 if (file_exists($infile) && is_readable($infile)) {
1059 $pagecount = $pdf->setSourceFile($infile);
1060 for ($i = 1; $i <= $pagecount; $i++) {
1061 $tplIdx = $pdf->importPage($i);
1062 if ($tplIdx !==
false) {
1063 $s = $pdf->getTemplatesize($tplIdx);
1064 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
1065 $pdf->useTemplate($tplIdx);
1067 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
1080 $pdf->Output($file,
'F');
1083 $hookmanager->initHooks(array(
'pdfgeneration'));
1084 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1086 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1087 $this->warnings = $hookmanager->warnings;
1089 $this->error = $hookmanager->error;
1090 $this->errors = $hookmanager->errors;
1097 $this->result = array(
'fullpath' => $file);
1101 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
1105 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
1125 $pdf->SetFont(
'',
'', $default_font_size - 1);
1130 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
1131 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1132 $pdf->SetXY($this->marge_gauche, $posy);
1133 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1135 $posy = $pdf->GetY() + 4;
1140 $displaydate =
"daytext";
1142 $displaydate =
"day";
1146 if (!empty(
$object->delivery_date)) {
1147 $outputlangs->load(
"sendings");
1148 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1149 $pdf->SetXY($this->marge_gauche, $posy);
1150 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1151 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1152 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1153 $pdf->SetXY($posxval, $posy);
1155 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1157 $posy = $pdf->GetY() + 1;
1159 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1160 $pdf->SetXY($this->marge_gauche, $posy);
1161 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1162 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1163 $pdf->SetTextColor(0, 0, 0);
1164 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1165 $pdf->SetXY($posxval, $posy);
1166 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
1167 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1168 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1170 $posy = $pdf->GetY() + 1;
1175 $outputlangs->load(
"sendings");
1177 $shipping_method_id =
$object->shipping_method_id;
1178 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1179 $shipping_method_id = $this->emetteur->shipping_method_id;
1181 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1182 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1184 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1185 $pdf->SetXY($this->marge_gauche, $posy);
1186 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1187 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1189 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1190 $pdf->SetXY($posxval, $posy);
1191 $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;
1192 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1193 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1195 $posy = $pdf->GetY() + 1;
1200 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1201 $pdf->SetXY($this->marge_gauche, $posy);
1202 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1203 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1205 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1206 $pdf->SetXY($posxval, $posy);
1207 $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);
1208 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1209 if (
$object->deposit_percent > 0) {
1210 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1212 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1214 $posy = $pdf->GetY() + 3;
1219 if (
$object->mode_reglement_code
1220 &&
$object->mode_reglement_code !=
'CHQ'
1221 &&
$object->mode_reglement_code !=
'VIR') {
1222 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1223 $pdf->SetXY($this->marge_gauche, $posy);
1224 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1225 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1226 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1227 $pdf->SetXY($posxval, $posy);
1228 $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);
1229 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1231 $posy = $pdf->GetY() + 2;
1235 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1239 $account =
new Account($this->db);
1242 $pdf->SetXY($this->marge_gauche, $posy);
1243 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1245 $posy = $pdf->GetY() + 1;
1248 $pdf->SetXY($this->marge_gauche, $posy);
1249 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1250 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1251 $posy = $pdf->GetY() + 2;
1255 $pdf->SetXY($this->marge_gauche, $posy);
1256 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1257 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1258 $posy = $pdf->GetY() + 1;
1261 $pdf->SetXY($this->marge_gauche, $posy);
1262 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1263 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1264 $posy = $pdf->GetY() + 2;
1271 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1277 $account =
new Account($this->db);
1278 $account->fetch((
int) $bankid);
1280 $curx = $this->marge_gauche;
1283 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1314 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1315 $default_font_size--;
1320 $pdf->SetFont(
'',
'', $default_font_size - 1);
1325 if ($this->page_largeur < 210) {
1328 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1337 $total_discount_on_lines = 0;
1338 $multicurrency_total_discount_on_lines = 0;
1339 foreach (
$object->lines as $i => $line) {
1343 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1344 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1346 if ($line->total_ht < 0) {
1347 $total_discount_on_lines += -$line->total_ht;
1348 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1352 if ($total_discount_on_lines > 0) {
1353 if ($this->showAmountBeforeDiscount) {
1355 $pdf->SetFillColor(255, 255, 255);
1356 $pdf->SetXY($col1x, $tab2_top);
1357 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1358 $pdf->SetXY($col2x, $tab2_top);
1360 $total_before_discount_to_show = ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? (
$object->multicurrency_total_ht + $multicurrency_total_discount_on_lines) : (
$object->total_ht + $total_discount_on_lines));
1361 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1366 if ($this->showDiscountAmount) {
1367 $pdf->SetFillColor(255, 255, 255);
1368 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1369 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1370 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1372 $total_discount_to_show = ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1373 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1380 $pdf->SetFillColor(255, 255, 255);
1381 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1382 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1385 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1386 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1389 $pdf->SetFillColor(248, 248, 248);
1392 $total_ttc_origin =
$object->total_ttc;
1394 $this->atleastoneratenotnull = 0;
1396 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1397 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1403 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1404 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1408 foreach ($localtax_rate as $tvakey => $tvaval) {
1413 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1416 if (preg_match(
'/\*/', $tvakey)) {
1417 $tvakey = str_replace(
'*',
'', $tvakey);
1418 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1420 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1422 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1423 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1427 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1428 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1436 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1437 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1441 foreach ($localtax_rate as $tvakey => $tvaval) {
1446 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1449 if (preg_match(
'/\*/', $tvakey)) {
1450 $tvakey = str_replace(
'*',
'', $tvakey);
1451 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1453 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1455 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1456 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1460 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1461 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1468 foreach ($this->tva as $tvakey => $tvaval) {
1470 $this->atleastoneratenotnull++;
1473 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1476 if (preg_match(
'/\*/', $tvakey)) {
1477 $tvakey = str_replace(
'*',
'', $tvakey);
1478 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1480 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1482 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
1483 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1485 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1486 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
1493 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1494 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1498 foreach ($localtax_rate as $tvakey => $tvaval) {
1503 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1506 if (preg_match(
'/\*/', $tvakey)) {
1507 $tvakey = str_replace(
'*',
'', $tvakey);
1508 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1510 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1513 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1514 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1518 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1519 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1527 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1528 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1532 foreach ($localtax_rate as $tvakey => $tvaval) {
1538 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1541 if (preg_match(
'/\*/', $tvakey)) {
1542 $tvakey = str_replace(
'*',
'', $tvakey);
1543 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1545 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1549 $totalvat .= $tvacompl;
1551 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1554 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1558 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1559 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1567 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1568 $pdf->SetTextColor(0, 0, 60);
1569 $pdf->SetFillColor(224, 224, 224);
1570 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L',
true);
1572 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1574 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1576 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1580 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1581 $pdf->SetTextColor(0, 0, 60);
1582 $pdf->SetFillColor(224, 224, 224);
1583 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1585 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1586 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1591 $pdf->SetTextColor(0, 0, 0);
1599 if ($deja_regle > 0) {
1603 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1604 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1606 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1607 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1625 $pdf->SetTextColor(0, 0, 60);
1626 $pdf->SetFillColor(224, 224, 224);
1627 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1628 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L',
true);
1630 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1631 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1633 $pdf->SetFont(
'',
'', $default_font_size - 1);
1634 $pdf->SetTextColor(0, 0, 0);
1637 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1639 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1641 $this->error = $hookmanager->error;
1642 $this->errors = $hookmanager->errors;
1646 return ($tab2_top + ($tab2_hl * $index));
1729 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1731 global
$conf, $langs;
1733 $ltrdirection =
'L';
1734 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1735 $ltrdirection =
'R';
1739 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1745 $pdf->SetTextColor(0, 0, 60);
1746 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1750 $posy = $this->marge_haute;
1751 $posx = $this->page_largeur - $this->marge_droite - $w;
1753 $pdf->SetXY($this->marge_gauche, $posy);
1757 if ($this->emetteur->logo) {
1758 $logodir =
$conf->mycompany->dir_output;
1759 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
1763 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1765 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1767 if (is_readable($logo)) {
1769 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1771 $pdf->SetTextColor(200, 0, 0);
1772 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1773 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1774 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1777 $text = $this->emetteur->name;
1778 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1782 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1783 $pdf->SetXY($posx, $posy);
1784 $pdf->SetTextColor(0, 0, 60);
1785 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1786 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1787 if (
$object->status == $object::STATUS_DRAFT) {
1788 $pdf->SetTextColor(128, 0, 0);
1789 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1792 $pdf->MultiCell($w, 4, $title,
'',
'R');
1794 $pdf->SetFont(
'',
'B', $default_font_size);
1809 $pdf->SetFont(
'',
'', $default_font_size - 2);
1812 if ($ref_customer) {
1814 $pdf->SetXY($posx, $posy);
1815 $pdf->SetTextColor(0, 0, 60);
1816 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65),
'',
'R');
1821 if (!empty(
$object->project->title)) {
1823 $pdf->SetXY($posx, $posy);
1824 $pdf->SetTextColor(0, 0, 60);
1825 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".
dol_trunc(
$object->project->title, 50),
'',
'R');
1826 $posy = $pdf->getY();
1832 if (!empty(
$object->project->ref)) {
1833 $outputlangs->load(
"projects");
1835 $pdf->SetXY($posx, $posy);
1836 $pdf->SetTextColor(0, 0, 60);
1837 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".
$object->project->ref,
'',
'R');
1842 $displaydate =
"daytext";
1844 $displaydate =
"day";
1848 $posy = $pdf->getY();
1849 $pdf->SetXY($posx, $posy);
1850 $pdf->SetTextColor(0, 0, 60);
1851 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1854 $pdf->SetXY($posx, $posy);
1855 $pdf->SetTextColor(0, 0, 60);
1857 $title = $outputlangs->transnoentities(
"DateEndPropal");
1858 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1859 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1861 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1865 $pdf->SetXY($posx, $posy);
1866 $pdf->SetTextColor(0, 0, 60);
1867 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
1872 $pdf->SetXY($posx, $posy);
1873 $pdf->SetTextColor(0, 0, 60);
1874 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_compta_client),
'',
'R');
1879 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1880 if (count($arrayidcontact) > 0) {
1881 $usertmp =
new User($this->db);
1882 $usertmp->fetch($arrayidcontact[0]);
1884 $pdf->SetXY($posx, $posy);
1885 $pdf->SetTextColor(0, 0, 60);
1886 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1894 $current_y = $pdf->getY();
1896 if ($current_y < $pdf->getY()) {
1897 $top_shift = $pdf->getY() - $current_y;
1902 $carac_emetteur =
'';
1904 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1905 if (count($arrayidcontact) > 0) {
1906 $object->fetch_user($arrayidcontact[0]);
1907 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1908 $carac_emetteur .= $labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1910 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1914 $carac_emetteur .=
"\n";
1921 $posy += $top_shift + $this->marge_haute;
1922 $posx = $this->marge_gauche;
1924 $posx = $this->page_largeur - $this->marge_droite - 80;
1933 $pdf->SetTextColor(0, 0, 0);
1934 $pdf->SetFont(
'',
'', $default_font_size - 2);
1935 $pdf->SetXY($posx, $posy - 5);
1936 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1937 $pdf->SetXY($posx, $posy);
1938 $pdf->SetFillColor(230, 230, 230);
1939 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1940 $pdf->SetTextColor(0, 0, 60);
1945 $pdf->SetXY($posx + 2, $posy + 3);
1946 $pdf->SetFont(
'',
'B', $default_font_size);
1947 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1948 $posy = $pdf->getY();
1952 $pdf->SetXY($posx + 2, $posy);
1953 $pdf->SetFont(
'',
'', $default_font_size - 1);
1954 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1958 $usecontact =
false;
1959 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1960 if (count($arrayidcontact) > 0) {
1962 $result =
$object->fetch_contact($arrayidcontact[0]);
1966 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1967 $thirdparty =
$object->contact;
1969 $thirdparty =
$object->thirdparty;
1979 if ($this->page_largeur < 210) {
1982 $posy =
getDolGlobalString(
'MAIN_PDF_USE_ISO_LOCATION') ? 30 + $this->marge_haute : 32 + $this->marge_haute;
1983 $posy += $top_shift;
1984 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1986 $posx = $this->marge_gauche;
1991 $pdf->SetTextColor(0, 0, 0);
1992 $pdf->SetFont(
'',
'', $default_font_size - 2);
1993 $pdf->SetXY($posx + 2, $posy - 5);
1994 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1995 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1999 $pdf->SetXY($posx + 2, $posy + 3);
2000 $pdf->SetFont(
'',
'B', $default_font_size);
2002 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
2004 $posy = $pdf->getY();
2007 $pdf->SetFont(
'',
'', $default_font_size - 1);
2008 $pdf->SetXY($posx + 2, $posy);
2010 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
2013 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2015 if (!empty($idaddressshipping)) {
2016 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2017 $companystatic =
new Societe($this->db);
2018 $companystatic->fetch(
$object->contact->fk_soc);
2025 if (!empty($carac_client_shipping)) {
2026 $posy += $hautcadre;
2031 $pdf->SetXY($posx + 2, $posy - 5);
2032 $pdf->SetFont(
'',
'', $default_font_size - 2);
2033 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
2034 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2037 $pdf->SetXY($posx + 2, $posy + 3);
2038 $pdf->SetFont(
'',
'B', $default_font_size);
2039 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2041 $posy = $pdf->getY();
2044 $pdf->SetXY($posx + 2, $posy);
2045 $pdf->SetFont(
'',
'', $default_font_size - 1);
2046 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2048 $shipp_shift += $hautcadre + 10;
2052 $pdf->SetTextColor(0, 0, 0);
2054 return array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);