189 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
192 global $user, $langs,
$conf,
$mysoc, $db, $hookmanager, $nblines;
194 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
196 if (!is_object($outputlangs)) {
197 $outputlangs = $langs;
201 $outputlangs->charset_output =
'ISO-8859-1';
205 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"propal",
"products",
"compta");
206 $outputlangs->loadLangs($langfiles);
208 global $outputlangsbis;
209 $outputlangsbis =
null;
213 $outputlangsbis->loadLangs($langfiles);
221 $nblines = count(
$object->lines);
224 $realpatharray = array();
225 $this->atleastonephoto =
false;
227 $objphoto =
new Product($this->db);
229 for ($i = 0; $i < $nblines; $i++) {
230 if (empty(
$object->lines[$i]->fk_product)) {
234 $objphoto->fetch(
$object->lines[$i]->fk_product);
238 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
239 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
241 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
242 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
247 foreach ($pdir as $midir) {
249 $entity = $objphoto->entity;
250 if ($entity !==
null &&
$conf->entity != $entity) {
251 $dir =
$conf->product->multidir_output[$entity].
'/'.$midir;
253 $dir =
$conf->product->dir_output.
'/'.$midir;
255 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
257 if ($obj[
'photo_vignette']) {
258 $filename = $obj[
'photo_vignette'];
260 $filename = $obj[
'photo'];
263 $filename = $obj[
'photo'];
266 $realpath = $dir.$filename;
268 $this->atleastonephoto =
true;
273 if ($realpath && $arephoto) {
274 $realpatharray[$i] = $realpath;
279 if (count($realpatharray) == 0) {
280 $this->posxpicture = $this->posxtva;
283 if (
$conf->propal->multidir_output[
$conf->entity]) {
290 $dir =
$conf->propal->multidir_output[
$conf->entity];
291 $file = $dir.
"/SPECIMEN.pdf";
294 $dir =
$conf->propal->multidir_output[
$object->entity ??
$conf->entity].
"/".$objectref;
295 $file = $dir.
"/".$objectref.
".pdf";
298 if (!file_exists($dir)) {
300 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
305 if (file_exists($dir)) {
307 if (!is_object($hookmanager)) {
308 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
311 $hookmanager->initHooks(array(
'pdfgeneration'));
312 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
314 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
317 $nblines = count(
$object->lines);
323 $pdf->setAutoPageBreak(
true, 0);
325 if (class_exists(
'TCPDF')) {
326 $pdf->setPrintHeader(
false);
327 $pdf->setPrintFooter(
false);
332 $logodir =
$conf->mycompany->dir_output;
333 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
336 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
337 $tplidx = $pdf->importPage(1);
342 $pdf->SetDrawColor(128, 128, 128);
344 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
345 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
346 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
347 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
348 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
350 $pdf->SetCompression(
false);
354 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
357 for ($i = 0; $i < $nblines; $i++) {
358 if (
$object->lines[$i]->remise_percent) {
359 $this->atleastonediscount++;
362 if (empty($this->atleastonediscount)) {
363 $delta = ($this->postotalht - $this->posxdiscount);
364 $this->posxpicture += $delta;
365 $this->posxtva += $delta;
366 $this->posxup += $delta;
367 $this->posxqty += $delta;
368 $this->posxunit += $delta;
369 $this->posxdiscount += $delta;
375 if (!empty($tplidx)) {
376 $pdf->useTemplate($tplidx);
380 $heightforinfotot = 40;
383 $heightforfooter = $this->marge_basse + 8;
385 $heightforfooter += 6;
389 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
390 $pdf->SetFont(
'',
'', $default_font_size - 1);
391 $pdf->MultiCell(0, 3,
'');
392 $pdf->SetTextColor(0, 0, 0);
395 $tab_top = 90 + $top_shift;
396 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
399 $height_incoterms = 0;
401 $desc_incoterms =
$object->getIncotermsForPDF();
402 if ($desc_incoterms) {
405 $pdf->SetFont(
'',
'', $default_font_size - 1);
406 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
407 $nexY = $pdf->GetY();
408 $height_incoterms = $nexY - $tab_top;
411 $pdf->SetDrawColor(192, 192, 192);
412 $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');
414 $tab_top = $nexY + 6;
415 $height_incoterms += 4;
420 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
423 if (is_object(
$object->thirdparty)) {
424 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
425 $salerepobj =
new User($this->db);
426 $salerepobj->fetch($salereparray[0][
'id']);
427 if (!empty($salerepobj->signature)) {
428 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
433 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
434 if (!empty($extranote)) {
438 $tmpuser =
new User($this->db);
439 $tmpuser->fetch(
$object->user_author_id);
442 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
443 if ($tmpuser->email) {
444 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
446 if ($tmpuser->office_phone) {
447 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
450 $notetoshow =
dol_concatdesc((
string) $notetoshow, $creator_info);
461 $pdf->SetFont(
'',
'', $default_font_size - 1);
462 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
463 $nexY = $pdf->GetY();
464 $height_note = $nexY - $tab_top;
467 $pdf->SetDrawColor(192, 192, 192);
468 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
470 $tab_top = $nexY + 6;
473 $iniY = $tab_top + 7;
474 $curY = $tab_top + 7;
475 $nexY = $tab_top + 7;
478 for ($i = 0; $i < $nblines; $i++) {
480 $pdf->SetFont(
'',
'', $default_font_size - 1);
481 $pdf->SetTextColor(0, 0, 0);
484 $imglinesize = array();
485 if (!empty($realpatharray[$i])) {
489 $pdf->setTopMargin($tab_top_newpage);
490 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
491 $pageposbefore = $pdf->getPage();
493 $showpricebeforepagebreak = 1;
495 $posYAfterDescription = 0;
498 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
499 $pdf->AddPage(
'',
'',
true);
500 if (!empty($tplidx)) {
501 $pdf->useTemplate($tplidx);
506 $pdf->setPage($pageposbefore + 1);
508 $curY = $tab_top_newpage;
512 $showpricebeforepagebreak = 1;
514 $showpricebeforepagebreak = 0;
518 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
519 $curX = $this->posxpicture - 1;
520 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
522 $posYAfterImage = $curY + $imglinesize[
'height'];
526 $curX = $this->posxdesc - 1;
528 $pdf->startTransaction();
529 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
530 $pageposafter = $pdf->getPage();
531 if ($pageposafter > $pageposbefore) {
532 $pdf->rollbackTransaction(
true);
533 $pageposafter = $pageposbefore;
535 $pdf->setPageOrientation(
'',
true, $heightforfooter);
536 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
538 $pageposafter = $pdf->getPage();
539 $posyafter = $pdf->GetY();
541 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
542 if ($i == ($nblines - 1)) {
543 $pdf->AddPage(
'',
'',
true);
544 if (!empty($tplidx)) {
545 $pdf->useTemplate($tplidx);
550 $pdf->setPage($pageposafter + 1);
557 $showpricebeforepagebreak = 1;
559 $showpricebeforepagebreak = 0;
563 $pdf->commitTransaction();
565 $posYAfterDescription = $pdf->GetY();
567 $nexY = $pdf->GetY();
568 $pageposafter = $pdf->getPage();
570 $pdf->setPage($pageposbefore);
571 $pdf->setTopMargin($this->marge_haute);
572 $pdf->setPageOrientation(
'',
true, 0);
575 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
576 $pdf->setPage($pageposafter);
577 $curY = $tab_top_newpage;
580 $pdf->SetFont(
'',
'', $default_font_size - 1);
585 $pdf->SetXY($this->posxtva - 5, $curY);
586 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
591 $pdf->SetXY($this->posxup, $curY);
592 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
596 $pdf->SetXY($this->posxqty, $curY);
597 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
602 $pdf->SetXY($this->posxunit, $curY);
603 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
607 $pdf->SetXY($this->posxdiscount, $curY);
608 if (
$object->lines[$i]->remise_percent) {
609 $pdf->SetXY($this->posxdiscount - 2, $curY);
611 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
616 $pdf->SetXY($this->postotalht, $curY);
617 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
621 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
623 $tvaligne =
$object->lines[$i]->total_tva;
626 $localtax1ligne =
$object->lines[$i]->total_localtax1;
627 $localtax2ligne =
$object->lines[$i]->total_localtax2;
628 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
629 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
630 $localtax1_type =
$object->lines[$i]->localtax1_type;
631 $localtax2_type =
$object->lines[$i]->localtax2_type;
647 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
648 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
650 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
651 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
655 if ($localtax1_type && $localtax1ligne != 0) {
656 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
657 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
659 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
662 if ($localtax2_type && $localtax2ligne != 0) {
663 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
664 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
666 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
670 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
675 if (!isset($this->tva[$vatrate])) {
676 $this->tva[$vatrate] = 0;
678 $this->tva[$vatrate] += $tvaligne;
679 $vatcode =
$object->lines[$i]->vat_src_code;
680 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
681 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
683 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
685 if ($posYAfterImage > $posYAfterDescription) {
686 $nexY = $posYAfterImage;
691 $pdf->setPage($pageposafter);
692 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
694 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
695 $pdf->SetLineStyle(array(
'dash' => 0));
701 while ($pagenb < $pageposafter) {
702 $pdf->setPage($pagenb);
704 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
706 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
710 $pdf->setPage($pagenb);
711 $pdf->setPageOrientation(
'',
true, 0);
715 if (!empty($tplidx)) {
716 $pdf->useTemplate($tplidx);
719 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
721 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
723 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
728 if (!empty($tplidx)) {
729 $pdf->useTemplate($tplidx);
740 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
741 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
743 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
744 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
766 $keywords = $outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name);
767 $pdf->SetKeyWords($keywords.
" PAGESIGN=".$pdf->getPage());
772 if (method_exists($pdf,
'AliasNbPages')) {
773 $pdf->AliasNbPages();
778 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL') && $termsofsalefilename) {
779 $termsofsale =
$conf->propal->dir_output.
'/'.$termsofsalefilename;
781 $termsofsale =
$conf->propal->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
783 if (file_exists($termsofsale) && is_readable($termsofsale)) {
784 $pagecount = $pdf->setSourceFile($termsofsale);
785 for ($i = 1; $i <= $pagecount; $i++) {
786 $tplIdx = $pdf->importPage($i);
787 if ($tplIdx !==
false) {
788 $s = $pdf->getTemplatesize($tplIdx);
789 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
790 $pdf->useTemplate($tplIdx);
792 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
800 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
802 $already_merged = array();
803 foreach (
$object->lines as $line) {
804 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
809 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
811 $filetomerge->fetch_by_product($line->fk_product);
814 $already_merged[] = $line->fk_product;
816 $product =
new Product($this->db);
817 $product->fetch($line->fk_product);
819 if ($product->entity !=
$conf->entity) {
820 $entity_product_file = $product->entity;
822 $entity_product_file =
$conf->entity;
826 if (count($filetomerge->lines) > 0) {
827 foreach ($filetomerge->lines as $linefile) {
828 $filetomerge_dir =
null;
829 if (!empty($linefile->id) && !empty($linefile->file_name)) {
832 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
834 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
838 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
840 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
844 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, $filetomerge_dir ===
null ? LOG_ERR : LOG_DEBUG);
845 if ($filetomerge_dir ===
null) {
850 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
851 if (file_exists($infile) && is_readable($infile)) {
852 $pagecount = $pdf->setSourceFile($infile);
853 for ($i = 1; $i <= $pagecount; $i++) {
854 $tplIdx = $pdf->importPage($i);
855 if ($tplIdx !==
false) {
856 $s = $pdf->getTemplatesize($tplIdx);
857 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
858 $pdf->useTemplate($tplIdx);
860 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
873 $pdf->Output($file,
'F');
876 $hookmanager->initHooks(array(
'pdfgeneration'));
877 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
879 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
880 $this->warnings = $hookmanager->warnings;
882 $this->error = $hookmanager->error;
883 $this->errors = $hookmanager->errors;
890 $this->result = array(
'fullpath' => $file);
894 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
898 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
937 $pdf->SetFont(
'',
'', $default_font_size - 1);
942 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
943 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
944 $pdf->SetXY($this->marge_gauche, $posy);
945 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
947 $posy = $pdf->GetY() + 4;
952 $displaydate =
"daytext";
954 $displaydate =
"day";
958 if (!empty(
$object->delivery_date)) {
959 $outputlangs->load(
"sendings");
960 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
961 $pdf->SetXY($this->marge_gauche, $posy);
962 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
963 $pdf->MultiCell(80, 4, $titre, 0,
'L');
964 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
965 $pdf->SetXY($posxval, $posy);
967 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
969 $posy = $pdf->GetY() + 1;
971 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
972 $pdf->SetXY($this->marge_gauche, $posy);
973 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
974 $pdf->MultiCell(80, 4, $titre, 0,
'L');
975 $pdf->SetTextColor(0, 0, 0);
976 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
977 $pdf->SetXY($posxval, $posy);
978 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
979 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
980 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
982 $posy = $pdf->GetY() + 1;
987 $outputlangs->load(
"sendings");
989 $shipping_method_id =
$object->shipping_method_id;
990 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
991 $shipping_method_id = $this->emetteur->shipping_method_id;
993 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
994 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
996 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
997 $pdf->SetXY($this->marge_gauche, $posy);
998 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
999 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1001 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1002 $pdf->SetXY($posxval, $posy);
1003 $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;
1004 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1005 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1007 $posy = $pdf->GetY() + 1;
1012 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1013 $pdf->SetXY($this->marge_gauche, $posy);
1014 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1015 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1017 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1018 $pdf->SetXY($posxval, $posy);
1019 $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);
1020 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1021 if (
$object->deposit_percent > 0) {
1022 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1024 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1026 $posy = $pdf->GetY() + 3;
1031 if (
$object->mode_reglement_code
1032 &&
$object->mode_reglement_code !=
'CHQ'
1033 &&
$object->mode_reglement_code !=
'VIR') {
1034 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1035 $pdf->SetXY($this->marge_gauche, $posy);
1036 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1037 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1038 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1039 $pdf->SetXY($posxval, $posy);
1040 $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);
1041 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1043 $posy = $pdf->GetY() + 2;
1047 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1051 $account =
new Account($this->db);
1054 $pdf->SetXY($this->marge_gauche, $posy);
1055 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1056 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1057 $posy = $pdf->GetY() + 1;
1060 $pdf->SetXY($this->marge_gauche, $posy);
1061 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1062 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1063 $posy = $pdf->GetY() + 2;
1067 $pdf->SetXY($this->marge_gauche, $posy);
1068 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1069 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1070 $posy = $pdf->GetY() + 1;
1073 $pdf->SetXY($this->marge_gauche, $posy);
1074 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1075 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1076 $posy = $pdf->GetY() + 2;
1083 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1089 $account =
new Account($this->db);
1090 $account->fetch((
int) $bankid);
1092 $curx = $this->marge_gauche;
1095 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1127 $pdf->SetFont(
'',
'', $default_font_size - 1);
1132 if ($this->page_largeur < 210) {
1135 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1144 $total_discount_on_lines = 0;
1145 $multicurrency_total_discount_on_lines = 0;
1146 foreach (
$object->lines as $i => $line) {
1150 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1151 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1153 if ($line->total_ht < 0) {
1154 $total_discount_on_lines += -$line->total_ht;
1155 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1159 if ($total_discount_on_lines > 0) {
1160 if ($this->showAmountBeforeDiscount) {
1162 $pdf->SetFillColor(255, 255, 255);
1163 $pdf->SetXY($col1x, $tab2_top);
1164 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1165 $pdf->SetXY($col2x, $tab2_top);
1167 $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));
1168 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1173 if ($this->showDiscountAmount) {
1174 $pdf->SetFillColor(255, 255, 255);
1175 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1176 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1177 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1179 $total_discount_to_show = ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1180 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1187 $pdf->SetFillColor(255, 255, 255);
1188 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1189 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
1192 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1193 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1196 $pdf->SetFillColor(248, 248, 248);
1200 $this->atleastoneratenotnull = 0;
1202 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1203 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1207 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1208 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1212 foreach ($localtax_rate as $tvakey => $tvaval) {
1217 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1220 if (preg_match(
'/\*/', $tvakey)) {
1221 $tvakey = str_replace(
'*',
'', $tvakey);
1222 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1224 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1227 $totalvat .= $tvacompl;
1229 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1232 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1236 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1237 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1243 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1244 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1248 foreach ($localtax_rate as $tvakey => $tvaval) {
1253 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1256 if (preg_match(
'/\*/', $tvakey)) {
1257 $tvakey = str_replace(
'*',
'', $tvakey);
1258 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1260 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1263 $totalvat .= $tvacompl;
1265 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1268 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1272 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1273 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1279 foreach ($this->tva_array as $tvakey => $tvaval) {
1281 $this->atleastoneratenotnull++;
1284 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1287 if (preg_match(
'/\*/', $tvakey)) {
1288 $tvakey = str_replace(
'*',
'', $tvakey);
1289 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1291 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1294 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1296 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1298 $totalvat .= $tvacompl;
1300 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1302 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1304 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1305 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1310 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1311 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1315 foreach ($localtax_rate as $tvakey => $tvaval) {
1320 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1323 if (preg_match(
'/\*/', $tvakey)) {
1324 $tvakey = str_replace(
'*',
'', $tvakey);
1325 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1327 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1330 $totalvat .= $tvacompl;
1332 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1335 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1339 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1340 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1346 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1347 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1351 foreach ($localtax_rate as $tvakey => $tvaval) {
1357 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1360 if (preg_match(
'/\*/', $tvakey)) {
1361 $tvakey = str_replace(
'*',
'', $tvakey);
1362 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1364 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1367 $totalvat .= $tvacompl;
1369 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1372 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1376 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1377 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1385 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1386 $pdf->SetTextColor(0, 0, 60);
1387 $pdf->SetFillColor(224, 224, 224);
1388 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1390 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1391 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1395 $pdf->SetTextColor(0, 0, 0);
1403 if ($deja_regle > 0) {
1406 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1407 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
1409 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1410 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1428 $pdf->SetTextColor(0, 0, 60);
1429 $pdf->SetFillColor(224, 224, 224);
1430 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1431 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1433 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1434 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1436 $pdf->SetFont(
'',
'', $default_font_size - 1);
1437 $pdf->SetTextColor(0, 0, 0);
1441 return ($tab2_top + ($tab2_hl * $index));
1458 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1468 $currency = !empty($currency) ? $currency :
$conf->currency;
1472 $pdf->SetTextColor(0, 0, 0);
1473 $pdf->SetFont(
'',
'', $default_font_size - 2);
1475 if (empty($hidetop)) {
1476 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1477 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1478 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1482 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1486 $pdf->SetDrawColor(128, 128, 128);
1487 $pdf->SetFont(
'',
'', $default_font_size - 1);
1490 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1492 if (empty($hidetop)) {
1493 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1495 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1496 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1500 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1508 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1509 if (empty($hidetop)) {
1511 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1512 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1516 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1517 if (empty($hidetop)) {
1518 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1519 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1522 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1523 if (empty($hidetop)) {
1524 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1525 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1529 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1530 if (empty($hidetop)) {
1531 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1533 $this->posxdiscount - $this->posxunit - 1,
1535 $outputlangs->transnoentities(
"Unit"),
1542 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1543 if (empty($hidetop)) {
1544 if ($this->atleastonediscount) {
1545 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1546 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1549 if ($this->atleastonediscount) {
1550 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1552 if (empty($hidetop)) {
1553 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1554 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1569 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1571 global
$conf, $langs;
1573 $ltrdirection =
'L';
1574 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1575 $ltrdirection =
'R';
1579 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1585 $pdf->SetTextColor(0, 0, 60);
1586 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1590 $posy = $this->marge_haute;
1591 $posx = $this->page_largeur - $this->marge_droite - $w;
1593 $pdf->SetXY($this->marge_gauche, $posy);
1597 if ($this->emetteur->logo) {
1598 $logodir =
$conf->mycompany->dir_output;
1599 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
1603 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1605 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1607 if (is_readable($logo)) {
1609 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1611 $pdf->SetTextColor(200, 0, 0);
1612 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1613 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1614 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1617 $text = $this->emetteur->name;
1618 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1622 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1623 $pdf->SetXY($posx, $posy);
1624 $pdf->SetTextColor(0, 0, 60);
1625 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1626 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1627 if (
$object->statut == $object::STATUS_DRAFT) {
1628 $pdf->SetTextColor(128, 0, 0);
1629 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1631 $pdf->MultiCell($w, 4, $title,
'',
'R');
1633 $pdf->SetFont(
'',
'B', $default_font_size);
1643 $pdf->SetFont(
'',
'', $default_font_size - 2);
1646 if ($ref_customer) {
1648 $pdf->SetXY($posx, $posy);
1649 $pdf->SetTextColor(0, 0, 60);
1650 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($ref_customer),
'',
'R');
1655 if (!empty(
$object->project->title)) {
1657 $pdf->SetXY($posx, $posy);
1658 $pdf->SetTextColor(0, 0, 60);
1659 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".
$object->project->title,
'',
'R');
1665 if (!empty(
$object->project->ref)) {
1666 $outputlangs->load(
"projects");
1668 $pdf->SetXY($posx, $posy);
1669 $pdf->SetTextColor(0, 0, 60);
1670 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".
$object->project->ref,
'',
'R');
1675 $displaydate =
"daytext";
1677 $displaydate =
"day";
1681 $posy = $pdf->getY();
1682 $pdf->SetXY($posx, $posy);
1683 $pdf->SetTextColor(0, 0, 60);
1684 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1687 $pdf->SetXY($posx, $posy);
1688 $pdf->SetTextColor(0, 0, 60);
1689 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1693 $pdf->SetXY($posx, $posy);
1694 $pdf->SetTextColor(0, 0, 60);
1695 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
1700 $pdf->SetXY($posx, $posy);
1701 $pdf->SetTextColor(0, 0, 60);
1702 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_compta_client),
'',
'R');
1707 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1708 if (count($arrayidcontact) > 0) {
1709 $usertmp =
new User($this->db);
1710 $usertmp->fetch($arrayidcontact[0]);
1712 $pdf->SetXY($posx, $posy);
1713 $pdf->SetTextColor(0, 0, 60);
1714 $pdf->MultiCell($w, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1722 $current_y = $pdf->getY();
1724 if ($current_y < $pdf->getY()) {
1725 $top_shift = $pdf->getY() - $current_y;
1730 $carac_emetteur =
'';
1732 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1733 if (count($arrayidcontact) > 0) {
1734 $object->fetch_user($arrayidcontact[0]);
1735 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1736 $carac_emetteur .= $labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1738 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1742 $carac_emetteur .=
"\n";
1748 $posy = 42 + $top_shift;
1749 $posx = $this->marge_gauche;
1751 $posx = $this->page_largeur - $this->marge_droite - 80;
1757 $pdf->SetTextColor(0, 0, 0);
1758 $pdf->SetFont(
'',
'', $default_font_size - 2);
1759 $pdf->SetXY($posx, $posy - 5);
1760 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1761 $pdf->SetXY($posx, $posy);
1762 $pdf->SetFillColor(230, 230, 230);
1763 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1764 $pdf->SetTextColor(0, 0, 60);
1769 $pdf->SetXY($posx + 2, $posy + 3);
1770 $pdf->SetFont(
'',
'B', $default_font_size);
1771 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1772 $posy = $pdf->getY();
1776 $pdf->SetXY($posx + 2, $posy);
1777 $pdf->SetFont(
'',
'', $default_font_size - 1);
1778 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1782 $usecontact =
false;
1783 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1784 if (count($arrayidcontact) > 0) {
1786 $result =
$object->fetch_contact($arrayidcontact[0]);
1790 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1791 $thirdparty =
$object->contact;
1793 $thirdparty =
$object->thirdparty;
1803 if ($this->page_largeur < 210) {
1806 $posy = 42 + $top_shift;
1807 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1809 $posx = $this->marge_gauche;
1814 $pdf->SetTextColor(0, 0, 0);
1815 $pdf->SetFont(
'',
'', $default_font_size - 2);
1816 $pdf->SetXY($posx + 2, $posy - 5);
1817 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1818 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1822 $pdf->SetXY($posx + 2, $posy + 3);
1823 $pdf->SetFont(
'',
'B', $default_font_size);
1825 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1827 $posy = $pdf->getY();
1830 $pdf->SetFont(
'',
'', $default_font_size - 1);
1831 $pdf->SetXY($posx + 2, $posy);
1833 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1836 $pdf->SetTextColor(0, 0, 0);