186 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
189 global $user, $langs, $conf,
$mysoc, $db, $hookmanager, $nblines;
191 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
193 if (!is_object($outputlangs)) {
194 $outputlangs = $langs;
198 $outputlangs->charset_output =
'ISO-8859-1';
202 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"propal",
"products",
"compta");
203 $outputlangs->loadLangs($langfiles);
205 global $outputlangsbis;
206 $outputlangsbis =
null;
208 $outputlangsbis =
new Translate(
'', $conf);
210 $outputlangsbis->loadLangs($langfiles);
218 $nblines = count(
$object->lines);
221 $realpatharray = array();
222 $this->atleastonephoto =
false;
224 $objphoto =
new Product($this->db);
226 for ($i = 0; $i < $nblines; $i++) {
227 if (empty(
$object->lines[$i]->fk_product)) {
231 $objphoto->fetch(
$object->lines[$i]->fk_product);
235 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
236 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
238 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
239 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
244 foreach ($pdir as $midir) {
246 $entity = $objphoto->entity;
247 if ($entity !==
null && $conf->entity != $entity) {
248 $dir = $conf->product->multidir_output[$entity].
'/'.$midir;
250 $dir = $conf->product->dir_output.
'/'.$midir;
252 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
254 if ($obj[
'photo_vignette']) {
255 $filename = $obj[
'photo_vignette'];
257 $filename = $obj[
'photo'];
260 $filename = $obj[
'photo'];
263 $realpath = $dir.$filename;
265 $this->atleastonephoto =
true;
270 if ($realpath && $arephoto) {
271 $realpatharray[$i] = $realpath;
276 if (count($realpatharray) == 0) {
277 $this->posxpicture = $this->posxtva;
280 if ($conf->propal->multidir_output[$conf->entity]) {
287 $dir = $conf->propal->multidir_output[$conf->entity];
288 $file = $dir.
"/SPECIMEN.pdf";
291 $dir = $conf->propal->multidir_output[
$object->entity ?? $conf->entity].
"/".$objectref;
292 $file = $dir.
"/".$objectref.
".pdf";
295 if (!file_exists($dir)) {
297 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
302 if (file_exists($dir)) {
304 if (!is_object($hookmanager)) {
305 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
308 $hookmanager->initHooks(array(
'pdfgeneration'));
309 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
311 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
314 $nblines = count(
$object->lines);
320 $pdf->setAutoPageBreak(
true, 0);
322 if (class_exists(
'TCPDF')) {
323 $pdf->setPrintHeader(
false);
324 $pdf->setPrintFooter(
false);
329 $logodir = $conf->mycompany->dir_output;
330 if (!empty($conf->mycompany->multidir_output[
$object->entity ?? $conf->entity])) {
331 $logodir = $conf->mycompany->multidir_output[
$object->entity ?? $conf->entity];
333 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
334 $tplidx = $pdf->importPage(1);
339 $pdf->SetDrawColor(128, 128, 128);
341 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
342 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
343 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
344 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
345 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
347 $pdf->SetCompression(
false);
351 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
354 for ($i = 0; $i < $nblines; $i++) {
355 if (
$object->lines[$i]->remise_percent) {
356 $this->atleastonediscount++;
359 if (empty($this->atleastonediscount)) {
360 $delta = ($this->postotalht - $this->posxdiscount);
361 $this->posxpicture += $delta;
362 $this->posxtva += $delta;
363 $this->posxup += $delta;
364 $this->posxqty += $delta;
365 $this->posxunit += $delta;
366 $this->posxdiscount += $delta;
372 if (!empty($tplidx)) {
373 $pdf->useTemplate($tplidx);
377 $heightforinfotot = 40;
380 $heightforfooter = $this->marge_basse + 8;
382 $heightforfooter += 6;
386 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
387 $pdf->SetFont(
'',
'', $default_font_size - 1);
388 $pdf->MultiCell(0, 3,
'');
389 $pdf->SetTextColor(0, 0, 0);
392 $tab_top = 90 + $top_shift;
393 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
396 $height_incoterms = 0;
398 $desc_incoterms =
$object->getIncotermsForPDF();
399 if ($desc_incoterms) {
402 $pdf->SetFont(
'',
'', $default_font_size - 1);
403 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
404 $nexY = $pdf->GetY();
405 $height_incoterms = $nexY - $tab_top;
408 $pdf->SetDrawColor(192, 192, 192);
409 $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');
411 $tab_top = $nexY + 6;
412 $height_incoterms += 4;
417 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
420 if (is_object(
$object->thirdparty)) {
421 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
422 $salerepobj =
new User($this->db);
423 $salerepobj->fetch($salereparray[0][
'id']);
424 if (!empty($salerepobj->signature)) {
425 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
430 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
431 if (!empty($extranote)) {
435 $tmpuser =
new User($this->db);
436 $tmpuser->fetch(
$object->user_author_id);
439 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
440 if ($tmpuser->email) {
441 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
443 if ($tmpuser->office_phone) {
444 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
447 $notetoshow =
dol_concatdesc((
string) $notetoshow, $creator_info);
458 $pdf->SetFont(
'',
'', $default_font_size - 1);
459 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
460 $nexY = $pdf->GetY();
461 $height_note = $nexY - $tab_top;
464 $pdf->SetDrawColor(192, 192, 192);
465 $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');
467 $tab_top = $nexY + 6;
470 $iniY = $tab_top + 7;
471 $curY = $tab_top + 7;
472 $nexY = $tab_top + 7;
475 for ($i = 0; $i < $nblines; $i++) {
477 $pdf->SetFont(
'',
'', $default_font_size - 1);
478 $pdf->SetTextColor(0, 0, 0);
481 $imglinesize = array();
482 if (!empty($realpatharray[$i])) {
486 $pdf->setTopMargin($tab_top_newpage);
487 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
488 $pageposbefore = $pdf->getPage();
490 $showpricebeforepagebreak = 1;
492 $posYAfterDescription = 0;
495 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
496 $pdf->AddPage(
'',
'',
true);
497 if (!empty($tplidx)) {
498 $pdf->useTemplate($tplidx);
503 $pdf->setPage($pageposbefore + 1);
505 $curY = $tab_top_newpage;
509 $showpricebeforepagebreak = 1;
511 $showpricebeforepagebreak = 0;
515 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
516 $curX = $this->posxpicture - 1;
517 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
519 $posYAfterImage = $curY + $imglinesize[
'height'];
523 $curX = $this->posxdesc - 1;
525 $pdf->startTransaction();
526 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
527 $pageposafter = $pdf->getPage();
528 if ($pageposafter > $pageposbefore) {
529 $pdf->rollbackTransaction(
true);
530 $pageposafter = $pageposbefore;
532 $pdf->setPageOrientation(
'',
true, $heightforfooter);
533 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
535 $pageposafter = $pdf->getPage();
536 $posyafter = $pdf->GetY();
538 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
539 if ($i == ($nblines - 1)) {
540 $pdf->AddPage(
'',
'',
true);
541 if (!empty($tplidx)) {
542 $pdf->useTemplate($tplidx);
547 $pdf->setPage($pageposafter + 1);
554 $showpricebeforepagebreak = 1;
556 $showpricebeforepagebreak = 0;
560 $pdf->commitTransaction();
562 $posYAfterDescription = $pdf->GetY();
564 $nexY = $pdf->GetY();
565 $pageposafter = $pdf->getPage();
567 $pdf->setPage($pageposbefore);
568 $pdf->setTopMargin($this->marge_haute);
569 $pdf->setPageOrientation(
'',
true, 0);
572 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
573 $pdf->setPage($pageposafter);
574 $curY = $tab_top_newpage;
577 $pdf->SetFont(
'',
'', $default_font_size - 1);
582 $pdf->SetXY($this->posxtva - 5, $curY);
583 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
588 $pdf->SetXY($this->posxup, $curY);
589 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
593 $pdf->SetXY($this->posxqty, $curY);
594 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
599 $pdf->SetXY($this->posxunit, $curY);
600 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
604 $pdf->SetXY($this->posxdiscount, $curY);
605 if (
$object->lines[$i]->remise_percent) {
606 $pdf->SetXY($this->posxdiscount - 2, $curY);
608 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
613 $pdf->SetXY($this->postotalht, $curY);
614 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
618 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
620 $tvaligne =
$object->lines[$i]->total_tva;
623 $localtax1ligne =
$object->lines[$i]->total_localtax1;
624 $localtax2ligne =
$object->lines[$i]->total_localtax2;
625 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
626 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
627 $localtax1_type =
$object->lines[$i]->localtax1_type;
628 $localtax2_type =
$object->lines[$i]->localtax2_type;
641 $vatrate = (string)
$object->lines[$i]->tva_tx;
644 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
645 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
647 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
648 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
652 if ($localtax1_type && $localtax1ligne != 0) {
653 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
654 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
656 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
659 if ($localtax2_type && $localtax2ligne != 0) {
660 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
661 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
663 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
667 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
672 if (!isset($this->tva[$vatrate])) {
673 $this->tva[$vatrate] = 0;
675 $this->tva[$vatrate] += $tvaligne;
676 $vatcode =
$object->lines[$i]->vat_src_code;
677 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
678 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
680 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
682 if ($posYAfterImage > $posYAfterDescription) {
683 $nexY = $posYAfterImage;
688 $pdf->setPage($pageposafter);
689 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
691 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
692 $pdf->SetLineStyle(array(
'dash' => 0));
698 while ($pagenb < $pageposafter) {
699 $pdf->setPage($pagenb);
701 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
703 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
707 $pdf->setPage($pagenb);
708 $pdf->setPageOrientation(
'',
true, 0);
712 if (!empty($tplidx)) {
713 $pdf->useTemplate($tplidx);
716 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
718 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
720 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
725 if (!empty($tplidx)) {
726 $pdf->useTemplate($tplidx);
737 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
738 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
740 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
741 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
763 $keywords = $outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name);
764 $pdf->SetKeyWords($keywords.
" PAGESIGN=".$pdf->getPage());
769 if (method_exists($pdf,
'AliasNbPages')) {
770 $pdf->AliasNbPages();
775 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL') && $termsofsalefilename) {
776 $termsofsale = $conf->propal->dir_output.
'/'.$termsofsalefilename;
777 if (!empty($conf->propal->multidir_output[
$object->entity ?? $conf->entity])) {
778 $termsofsale = $conf->propal->multidir_output[
$object->entity ?? $conf->entity].
'/'.$termsofsalefilename;
780 if (file_exists($termsofsale) && is_readable($termsofsale)) {
781 $pagecount = $pdf->setSourceFile($termsofsale);
782 for ($i = 1; $i <= $pagecount; $i++) {
783 $tplIdx = $pdf->importPage($i);
784 if ($tplIdx !==
false) {
785 $s = $pdf->getTemplatesize($tplIdx);
786 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
787 $pdf->useTemplate($tplIdx);
789 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
797 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
799 $already_merged = array();
800 foreach (
$object->lines as $line) {
801 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
806 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
808 $filetomerge->fetch_by_product($line->fk_product);
811 $already_merged[] = $line->fk_product;
813 $product =
new Product($this->db);
814 $product->fetch($line->fk_product);
816 if ($product->entity != $conf->entity) {
817 $entity_product_file = $product->entity;
819 $entity_product_file = $conf->entity;
823 if (count($filetomerge->lines) > 0) {
824 foreach ($filetomerge->lines as $linefile) {
825 $filetomerge_dir =
null;
826 if (!empty($linefile->id) && !empty($linefile->file_name)) {
829 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file ?? $conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
831 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file ?? $conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
835 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file ?? $conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
837 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file ?? $conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
841 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, $filetomerge_dir ===
null ? LOG_ERR : LOG_DEBUG);
842 if ($filetomerge_dir ===
null) {
847 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
848 if (file_exists($infile) && is_readable($infile)) {
849 $pagecount = $pdf->setSourceFile($infile);
850 for ($i = 1; $i <= $pagecount; $i++) {
851 $tplIdx = $pdf->importPage($i);
852 if ($tplIdx !==
false) {
853 $s = $pdf->getTemplatesize($tplIdx);
854 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
855 $pdf->useTemplate($tplIdx);
857 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
870 $pdf->Output($file,
'F');
873 $hookmanager->initHooks(array(
'pdfgeneration'));
874 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
876 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
877 $this->warnings = $hookmanager->warnings;
879 $this->error = $hookmanager->error;
880 $this->errors = $hookmanager->errors;
887 $this->result = array(
'fullpath' => $file);
891 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
895 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
934 $pdf->SetFont(
'',
'', $default_font_size - 1);
939 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
940 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
941 $pdf->SetXY($this->marge_gauche, $posy);
942 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
944 $posy = $pdf->GetY() + 4;
949 $displaydate =
"daytext";
951 $displaydate =
"day";
955 if (!empty(
$object->delivery_date)) {
956 $outputlangs->load(
"sendings");
957 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
958 $pdf->SetXY($this->marge_gauche, $posy);
959 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
960 $pdf->MultiCell(80, 4, $titre, 0,
'L');
961 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
962 $pdf->SetXY($posxval, $posy);
964 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
966 $posy = $pdf->GetY() + 1;
968 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
969 $pdf->SetXY($this->marge_gauche, $posy);
970 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
971 $pdf->MultiCell(80, 4, $titre, 0,
'L');
972 $pdf->SetTextColor(0, 0, 0);
973 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
974 $pdf->SetXY($posxval, $posy);
975 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
976 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
977 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
979 $posy = $pdf->GetY() + 1;
984 $outputlangs->load(
"sendings");
986 $shipping_method_id =
$object->shipping_method_id;
987 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
988 $shipping_method_id = $this->emetteur->shipping_method_id;
990 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
991 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
993 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
994 $pdf->SetXY($this->marge_gauche, $posy);
995 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
996 $pdf->MultiCell(43, 4, $titre, 0,
'L');
998 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
999 $pdf->SetXY($posxval, $posy);
1000 $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;
1001 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1002 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1004 $posy = $pdf->GetY() + 1;
1009 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1010 $pdf->SetXY($this->marge_gauche, $posy);
1011 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1012 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1014 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1015 $pdf->SetXY($posxval, $posy);
1016 $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);
1017 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1018 if (
$object->deposit_percent > 0) {
1019 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1021 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1023 $posy = $pdf->GetY() + 3;
1028 if (
$object->mode_reglement_code
1029 &&
$object->mode_reglement_code !=
'CHQ'
1030 &&
$object->mode_reglement_code !=
'VIR') {
1031 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1032 $pdf->SetXY($this->marge_gauche, $posy);
1033 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1034 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1035 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1036 $pdf->SetXY($posxval, $posy);
1037 $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);
1038 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1040 $posy = $pdf->GetY() + 2;
1044 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1048 $account =
new Account($this->db);
1051 $pdf->SetXY($this->marge_gauche, $posy);
1052 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1053 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1054 $posy = $pdf->GetY() + 1;
1057 $pdf->SetXY($this->marge_gauche, $posy);
1058 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1059 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1060 $posy = $pdf->GetY() + 2;
1064 $pdf->SetXY($this->marge_gauche, $posy);
1065 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1066 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1067 $posy = $pdf->GetY() + 1;
1070 $pdf->SetXY($this->marge_gauche, $posy);
1071 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1072 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1073 $posy = $pdf->GetY() + 2;
1080 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1086 $account =
new Account($this->db);
1087 $account->fetch((
int) $bankid);
1089 $curx = $this->marge_gauche;
1092 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1124 $pdf->SetFont(
'',
'', $default_font_size - 1);
1129 if ($this->page_largeur < 210) {
1132 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1141 $total_discount_on_lines = 0;
1142 $multicurrency_total_discount_on_lines = 0;
1143 foreach (
$object->lines as $i => $line) {
1147 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1148 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1150 if ($line->total_ht < 0) {
1151 $total_discount_on_lines += -$line->total_ht;
1152 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1156 if ($total_discount_on_lines > 0) {
1158 $pdf->SetFillColor(255, 255, 255);
1159 $pdf->SetXY($col1x, $tab2_top);
1160 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1161 $pdf->SetXY($col2x, $tab2_top);
1163 $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));
1164 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1168 $pdf->SetFillColor(255, 255, 255);
1169 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1170 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1171 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1173 $total_discount_to_show = ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1174 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1180 $pdf->SetFillColor(255, 255, 255);
1181 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1182 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
1185 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1186 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1189 $pdf->SetFillColor(248, 248, 248);
1193 $this->atleastoneratenotnull = 0;
1195 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1196 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1200 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1201 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1205 foreach ($localtax_rate as $tvakey => $tvaval) {
1210 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1213 if (preg_match(
'/\*/', $tvakey)) {
1214 $tvakey = str_replace(
'*',
'', $tvakey);
1215 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1217 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1220 $totalvat .= $tvacompl;
1222 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1225 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1229 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1230 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1236 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1237 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1241 foreach ($localtax_rate as $tvakey => $tvaval) {
1246 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1249 if (preg_match(
'/\*/', $tvakey)) {
1250 $tvakey = str_replace(
'*',
'', $tvakey);
1251 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1253 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1256 $totalvat .= $tvacompl;
1258 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1261 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1265 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1266 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1272 foreach ($this->tva_array as $tvakey => $tvaval) {
1274 $this->atleastoneratenotnull++;
1277 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1280 if (preg_match(
'/\*/', $tvakey)) {
1281 $tvakey = str_replace(
'*',
'', $tvakey);
1282 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1284 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1287 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1289 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1291 $totalvat .= $tvacompl;
1293 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1295 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1297 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1298 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1303 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1304 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1308 foreach ($localtax_rate as $tvakey => $tvaval) {
1313 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1316 if (preg_match(
'/\*/', $tvakey)) {
1317 $tvakey = str_replace(
'*',
'', $tvakey);
1318 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1320 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1323 $totalvat .= $tvacompl;
1325 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1328 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1332 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1333 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1339 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1340 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1344 foreach ($localtax_rate as $tvakey => $tvaval) {
1350 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1353 if (preg_match(
'/\*/', $tvakey)) {
1354 $tvakey = str_replace(
'*',
'', $tvakey);
1355 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1357 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1360 $totalvat .= $tvacompl;
1362 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1365 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1369 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1370 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1378 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1379 $pdf->SetTextColor(0, 0, 60);
1380 $pdf->SetFillColor(224, 224, 224);
1381 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1383 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1384 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1388 $pdf->SetTextColor(0, 0, 0);
1396 if ($deja_regle > 0) {
1399 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1400 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
1402 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1403 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1421 $pdf->SetTextColor(0, 0, 60);
1422 $pdf->SetFillColor(224, 224, 224);
1423 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1424 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1426 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1427 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1429 $pdf->SetFont(
'',
'', $default_font_size - 1);
1430 $pdf->SetTextColor(0, 0, 0);
1434 return ($tab2_top + ($tab2_hl * $index));
1451 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1461 $currency = !empty($currency) ? $currency : $conf->currency;
1465 $pdf->SetTextColor(0, 0, 0);
1466 $pdf->SetFont(
'',
'', $default_font_size - 2);
1468 if (empty($hidetop)) {
1469 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1470 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1471 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1475 $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')));
1479 $pdf->SetDrawColor(128, 128, 128);
1480 $pdf->SetFont(
'',
'', $default_font_size - 1);
1483 $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');
1485 if (empty($hidetop)) {
1486 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1488 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1489 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1493 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1501 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1502 if (empty($hidetop)) {
1504 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1505 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1509 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1510 if (empty($hidetop)) {
1511 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1512 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1515 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1516 if (empty($hidetop)) {
1517 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1518 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1522 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1523 if (empty($hidetop)) {
1524 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1526 $this->posxdiscount - $this->posxunit - 1,
1528 $outputlangs->transnoentities(
"Unit"),
1535 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1536 if (empty($hidetop)) {
1537 if ($this->atleastonediscount) {
1538 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1539 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1542 if ($this->atleastonediscount) {
1543 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1545 if (empty($hidetop)) {
1546 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1547 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1562 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1564 global $conf, $langs;
1566 $ltrdirection =
'L';
1567 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1568 $ltrdirection =
'R';
1572 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1578 $pdf->SetTextColor(0, 0, 60);
1579 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1583 $posy = $this->marge_haute;
1584 $posx = $this->page_largeur - $this->marge_droite - $w;
1586 $pdf->SetXY($this->marge_gauche, $posy);
1590 if ($this->emetteur->logo) {
1591 $logodir = $conf->mycompany->dir_output;
1592 if (!empty($conf->mycompany->multidir_output[
$object->entity ?? $conf->entity])) {
1593 $logodir = $conf->mycompany->multidir_output[
$object->entity ?? $conf->entity];
1596 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1598 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1600 if (is_readable($logo)) {
1602 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1604 $pdf->SetTextColor(200, 0, 0);
1605 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1606 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1607 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1610 $text = $this->emetteur->name;
1611 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1615 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1616 $pdf->SetXY($posx, $posy);
1617 $pdf->SetTextColor(0, 0, 60);
1618 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1619 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1620 if (
$object->statut == $object::STATUS_DRAFT) {
1621 $pdf->SetTextColor(128, 0, 0);
1622 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1624 $pdf->MultiCell($w, 4, $title,
'',
'R');
1626 $pdf->SetFont(
'',
'B', $default_font_size);
1636 $pdf->SetFont(
'',
'', $default_font_size - 2);
1640 $pdf->SetXY($posx, $posy);
1641 $pdf->SetTextColor(0, 0, 60);
1642 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1647 if (!empty(
$object->project->ref)) {
1649 $pdf->SetXY($posx, $posy);
1650 $pdf->SetTextColor(0, 0, 60);
1651 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1657 if (!empty(
$object->project->ref)) {
1658 $outputlangs->load(
"projects");
1660 $pdf->SetXY($posx, $posy);
1661 $pdf->SetTextColor(0, 0, 60);
1662 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1667 $displaydate =
"daytext";
1669 $displaydate =
"day";
1673 $posy = $pdf->getY();
1674 $pdf->SetXY($posx, $posy);
1675 $pdf->SetTextColor(0, 0, 60);
1676 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1679 $pdf->SetXY($posx, $posy);
1680 $pdf->SetTextColor(0, 0, 60);
1681 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1685 $pdf->SetXY($posx, $posy);
1686 $pdf->SetTextColor(0, 0, 60);
1687 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1692 $pdf->SetXY($posx, $posy);
1693 $pdf->SetTextColor(0, 0, 60);
1694 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1699 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1700 if (count($arrayidcontact) > 0) {
1701 $usertmp =
new User($this->db);
1702 $usertmp->fetch($arrayidcontact[0]);
1704 $pdf->SetXY($posx, $posy);
1705 $pdf->SetTextColor(0, 0, 60);
1706 $pdf->MultiCell($w, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1714 $current_y = $pdf->getY();
1716 if ($current_y < $pdf->getY()) {
1717 $top_shift = $pdf->getY() - $current_y;
1722 $carac_emetteur =
'';
1724 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1725 if (count($arrayidcontact) > 0) {
1726 $object->fetch_user($arrayidcontact[0]);
1727 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1728 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1730 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1734 $carac_emetteur .=
"\n";
1740 $posy = 42 + $top_shift;
1741 $posx = $this->marge_gauche;
1743 $posx = $this->page_largeur - $this->marge_droite - 80;
1749 $pdf->SetTextColor(0, 0, 0);
1750 $pdf->SetFont(
'',
'', $default_font_size - 2);
1751 $pdf->SetXY($posx, $posy - 5);
1752 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1753 $pdf->SetXY($posx, $posy);
1754 $pdf->SetFillColor(230, 230, 230);
1755 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1756 $pdf->SetTextColor(0, 0, 60);
1761 $pdf->SetXY($posx + 2, $posy + 3);
1762 $pdf->SetFont(
'',
'B', $default_font_size);
1763 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1764 $posy = $pdf->getY();
1768 $pdf->SetXY($posx + 2, $posy);
1769 $pdf->SetFont(
'',
'', $default_font_size - 1);
1770 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1774 $usecontact =
false;
1775 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1776 if (count($arrayidcontact) > 0) {
1778 $result =
$object->fetch_contact($arrayidcontact[0]);
1782 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1783 $thirdparty =
$object->contact;
1785 $thirdparty =
$object->thirdparty;
1795 if ($this->page_largeur < 210) {
1798 $posy = 42 + $top_shift;
1799 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1801 $posx = $this->marge_gauche;
1806 $pdf->SetTextColor(0, 0, 0);
1807 $pdf->SetFont(
'',
'', $default_font_size - 2);
1808 $pdf->SetXY($posx + 2, $posy - 5);
1809 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1810 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1814 $pdf->SetXY($posx + 2, $posy + 3);
1815 $pdf->SetFont(
'',
'B', $default_font_size);
1817 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1819 $posy = $pdf->getY();
1822 $pdf->SetFont(
'',
'', $default_font_size - 1);
1823 $pdf->SetXY($posx + 2, $posy);
1825 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1828 $pdf->SetTextColor(0, 0, 0);