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 = 80 + $this->marge_haute + $top_shift;
396 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 32 + $this->marge_haute + $top_shift : $this->marge_haute);
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;
636 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
637 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
639 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
640 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
644 if ($localtax1_type && $localtax1ligne != 0) {
645 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
646 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
648 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
651 if ($localtax2_type && $localtax2ligne != 0) {
652 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
653 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
655 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
659 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
664 if (!isset($this->tva[$vatrate])) {
665 $this->tva[$vatrate] = 0;
667 $this->tva[$vatrate] += $tvaligne;
668 $vatcode =
$object->lines[$i]->vat_src_code;
669 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
670 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
672 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
674 if ($posYAfterImage > $posYAfterDescription) {
675 $nexY = $posYAfterImage;
680 $pdf->setPage($pageposafter);
681 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
683 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
684 $pdf->SetLineStyle(array(
'dash' => 0));
690 while ($pagenb < $pageposafter) {
691 $pdf->setPage($pagenb);
693 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
695 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
699 $pdf->setPage($pagenb);
700 $pdf->setPageOrientation(
'',
true, 0);
704 if (!empty($tplidx)) {
705 $pdf->useTemplate($tplidx);
708 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
710 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
712 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
717 if (!empty($tplidx)) {
718 $pdf->useTemplate($tplidx);
729 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
730 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
732 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
733 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
755 $keywords = $outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name);
756 $pdf->SetKeyWords($keywords.
" PAGESIGN=".$pdf->getPage());
761 if (method_exists($pdf,
'AliasNbPages')) {
762 $pdf->AliasNbPages();
767 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL') && $termsofsalefilename) {
768 $termsofsale =
$conf->propal->dir_output.
'/'.$termsofsalefilename;
770 $termsofsale =
$conf->propal->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
772 if (file_exists($termsofsale) && is_readable($termsofsale)) {
773 $pagecount = $pdf->setSourceFile($termsofsale);
774 for ($i = 1; $i <= $pagecount; $i++) {
775 $tplIdx = $pdf->importPage($i);
776 if ($tplIdx !==
false) {
777 $s = $pdf->getTemplatesize($tplIdx);
778 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
779 $pdf->useTemplate($tplIdx);
781 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
789 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
791 $already_merged = array();
792 foreach (
$object->lines as $line) {
793 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
798 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
800 $filetomerge->fetch_by_product($line->fk_product);
803 $already_merged[] = $line->fk_product;
805 $product =
new Product($this->db);
806 $product->fetch($line->fk_product);
808 if ($product->entity !=
$conf->entity) {
809 $entity_product_file = $product->entity;
811 $entity_product_file =
$conf->entity;
815 if (count($filetomerge->lines) > 0) {
816 foreach ($filetomerge->lines as $linefile) {
817 $filetomerge_dir =
null;
818 if (!empty($linefile->id) && !empty($linefile->file_name)) {
821 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
823 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
827 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
829 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file ??
$conf->entity].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
833 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, $filetomerge_dir ===
null ? LOG_ERR : LOG_DEBUG);
834 if ($filetomerge_dir ===
null) {
839 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
840 if (file_exists($infile) && is_readable($infile)) {
841 $pagecount = $pdf->setSourceFile($infile);
842 for ($i = 1; $i <= $pagecount; $i++) {
843 $tplIdx = $pdf->importPage($i);
844 if ($tplIdx !==
false) {
845 $s = $pdf->getTemplatesize($tplIdx);
846 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
847 $pdf->useTemplate($tplIdx);
849 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
862 $pdf->Output($file,
'F');
865 $hookmanager->initHooks(array(
'pdfgeneration'));
866 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
868 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
869 $this->warnings = $hookmanager->warnings;
871 $this->error = $hookmanager->error;
872 $this->errors = $hookmanager->errors;
879 $this->result = array(
'fullpath' => $file);
883 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
887 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
926 $pdf->SetFont(
'',
'', $default_font_size - 1);
931 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
932 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
933 $pdf->SetXY($this->marge_gauche, $posy);
934 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
936 $posy = $pdf->GetY() + 4;
941 $displaydate =
"daytext";
943 $displaydate =
"day";
947 if (!empty(
$object->delivery_date)) {
948 $outputlangs->load(
"sendings");
949 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
950 $pdf->SetXY($this->marge_gauche, $posy);
951 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
952 $pdf->MultiCell(80, 4, $titre, 0,
'L');
953 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
954 $pdf->SetXY($posxval, $posy);
956 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
958 $posy = $pdf->GetY() + 1;
960 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
961 $pdf->SetXY($this->marge_gauche, $posy);
962 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
963 $pdf->MultiCell(80, 4, $titre, 0,
'L');
964 $pdf->SetTextColor(0, 0, 0);
965 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
966 $pdf->SetXY($posxval, $posy);
967 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
968 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
969 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
971 $posy = $pdf->GetY() + 1;
976 $outputlangs->load(
"sendings");
978 $shipping_method_id =
$object->shipping_method_id;
979 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
980 $shipping_method_id = $this->emetteur->shipping_method_id;
982 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
983 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
985 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
986 $pdf->SetXY($this->marge_gauche, $posy);
987 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
988 $pdf->MultiCell(43, 4, $titre, 0,
'L');
990 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
991 $pdf->SetXY($posxval, $posy);
992 $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;
993 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
994 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
996 $posy = $pdf->GetY() + 1;
1001 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1002 $pdf->SetXY($this->marge_gauche, $posy);
1003 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1004 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1006 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1007 $pdf->SetXY($posxval, $posy);
1008 $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);
1009 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1010 if (
$object->deposit_percent > 0) {
1011 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1013 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1015 $posy = $pdf->GetY() + 3;
1020 if (
$object->mode_reglement_code
1021 &&
$object->mode_reglement_code !=
'CHQ'
1022 &&
$object->mode_reglement_code !=
'VIR') {
1023 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1024 $pdf->SetXY($this->marge_gauche, $posy);
1025 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1026 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1027 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1028 $pdf->SetXY($posxval, $posy);
1029 $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);
1030 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1032 $posy = $pdf->GetY() + 2;
1036 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1040 $account =
new Account($this->db);
1043 $pdf->SetXY($this->marge_gauche, $posy);
1044 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1045 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1046 $posy = $pdf->GetY() + 1;
1049 $pdf->SetXY($this->marge_gauche, $posy);
1050 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1051 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1052 $posy = $pdf->GetY() + 2;
1056 $pdf->SetXY($this->marge_gauche, $posy);
1057 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1058 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1059 $posy = $pdf->GetY() + 1;
1062 $pdf->SetXY($this->marge_gauche, $posy);
1063 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1064 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1065 $posy = $pdf->GetY() + 2;
1072 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1078 $account =
new Account($this->db);
1079 $account->fetch((
int) $bankid);
1081 $curx = $this->marge_gauche;
1084 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1116 $pdf->SetFont(
'',
'', $default_font_size - 1);
1121 if ($this->page_largeur < 210) {
1124 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1133 $total_discount_on_lines = 0;
1134 $multicurrency_total_discount_on_lines = 0;
1135 foreach (
$object->lines as $i => $line) {
1139 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1140 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1142 if ($line->total_ht < 0) {
1143 $total_discount_on_lines += -$line->total_ht;
1144 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1148 if ($total_discount_on_lines > 0) {
1149 if ($this->showAmountBeforeDiscount) {
1151 $pdf->SetFillColor(255, 255, 255);
1152 $pdf->SetXY($col1x, $tab2_top);
1153 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1154 $pdf->SetXY($col2x, $tab2_top);
1156 $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));
1157 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1162 if ($this->showDiscountAmount) {
1163 $pdf->SetFillColor(255, 255, 255);
1164 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1165 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount") . (is_object($outputlangsbis) ?
' / ' . $outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1166 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1168 $total_discount_to_show = ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1169 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1176 $pdf->SetFillColor(255, 255, 255);
1177 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1178 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
1181 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1182 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
1185 $pdf->SetFillColor(248, 248, 248);
1189 $this->atleastoneratenotnull = 0;
1191 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1192 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1196 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1197 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1201 foreach ($localtax_rate as $tvakey => $tvaval) {
1206 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1209 if (preg_match(
'/\*/', $tvakey)) {
1210 $tvakey = str_replace(
'*',
'', $tvakey);
1211 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1213 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1216 $totalvat .= $tvacompl;
1218 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1221 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1225 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1226 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1232 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1233 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1237 foreach ($localtax_rate as $tvakey => $tvaval) {
1242 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1245 if (preg_match(
'/\*/', $tvakey)) {
1246 $tvakey = str_replace(
'*',
'', $tvakey);
1247 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1249 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1252 $totalvat .= $tvacompl;
1254 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1257 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1261 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1262 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1268 foreach ($this->tva_array as $tvakey => $tvaval) {
1270 $this->atleastoneratenotnull++;
1273 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1276 if (preg_match(
'/\*/', $tvakey)) {
1277 $tvakey = str_replace(
'*',
'', $tvakey);
1278 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1280 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
1283 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1285 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1287 $totalvat .= $tvacompl;
1289 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1291 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1293 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1294 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1299 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1300 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1304 foreach ($localtax_rate as $tvakey => $tvaval) {
1309 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1312 if (preg_match(
'/\*/', $tvakey)) {
1313 $tvakey = str_replace(
'*',
'', $tvakey);
1314 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1316 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1319 $totalvat .= $tvacompl;
1321 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1324 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1328 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1329 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1335 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1336 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1340 foreach ($localtax_rate as $tvakey => $tvaval) {
1346 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1349 if (preg_match(
'/\*/', $tvakey)) {
1350 $tvakey = str_replace(
'*',
'', $tvakey);
1351 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1353 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1356 $totalvat .= $tvacompl;
1358 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1361 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1365 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1366 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1374 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1375 $pdf->SetTextColor(0, 0, 60);
1376 $pdf->SetFillColor(224, 224, 224);
1377 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1379 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1380 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1384 $pdf->SetTextColor(0, 0, 0);
1392 if ($deja_regle > 0) {
1395 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1396 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
1398 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1399 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1417 $pdf->SetTextColor(0, 0, 60);
1418 $pdf->SetFillColor(224, 224, 224);
1419 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1420 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1422 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1423 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1425 $pdf->SetFont(
'',
'', $default_font_size - 1);
1426 $pdf->SetTextColor(0, 0, 0);
1430 return ($tab2_top + ($tab2_hl * $index));
1447 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1457 $currency = !empty($currency) ? $currency :
$conf->currency;
1461 $pdf->SetTextColor(0, 0, 0);
1462 $pdf->SetFont(
'',
'', $default_font_size - 2);
1464 if (empty($hidetop)) {
1465 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1466 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1467 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1471 $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')));
1475 $pdf->SetDrawColor(128, 128, 128);
1476 $pdf->SetFont(
'',
'', $default_font_size - 1);
1479 $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');
1481 if (empty($hidetop)) {
1482 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1484 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1485 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1489 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1497 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1498 if (empty($hidetop)) {
1500 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1501 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1505 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1506 if (empty($hidetop)) {
1507 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1508 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1511 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1512 if (empty($hidetop)) {
1513 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1514 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1518 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1519 if (empty($hidetop)) {
1520 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1522 $this->posxdiscount - $this->posxunit - 1,
1524 $outputlangs->transnoentities(
"Unit"),
1531 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1532 if (empty($hidetop)) {
1533 if ($this->atleastonediscount) {
1534 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1535 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1538 if ($this->atleastonediscount) {
1539 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1541 if (empty($hidetop)) {
1542 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1543 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1558 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1560 global
$conf, $langs;
1562 $ltrdirection =
'L';
1563 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1564 $ltrdirection =
'R';
1568 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1574 $pdf->SetTextColor(0, 0, 60);
1575 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1579 $posy = $this->marge_haute;
1580 $posx = $this->page_largeur - $this->marge_droite - $w;
1582 $pdf->SetXY($this->marge_gauche, $posy);
1585 $logodir =
$conf->mycompany->dir_output;
1586 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
1589 pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection);
1591 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1592 $pdf->SetXY($posx, $posy);
1593 $pdf->SetTextColor(0, 0, 60);
1594 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1595 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1596 if (
$object->statut == $object::STATUS_DRAFT) {
1597 $pdf->SetTextColor(128, 0, 0);
1598 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1600 $pdf->MultiCell($w, 4, $title,
'',
'R');
1602 $pdf->SetFont(
'',
'B', $default_font_size);
1612 $pdf->SetFont(
'',
'', $default_font_size - 2);
1615 if ($ref_customer) {
1617 $pdf->SetXY($posx, $posy);
1618 $pdf->SetTextColor(0, 0, 60);
1619 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($ref_customer),
'',
'R');
1624 if (!empty(
$object->project->title)) {
1626 $pdf->SetXY($posx, $posy);
1627 $pdf->SetTextColor(0, 0, 60);
1628 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".
$object->project->title,
'',
'R');
1634 if (!empty(
$object->project->ref)) {
1635 $outputlangs->load(
"projects");
1637 $pdf->SetXY($posx, $posy);
1638 $pdf->SetTextColor(0, 0, 60);
1639 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".
$object->project->ref,
'',
'R');
1644 $displaydate =
"daytext";
1646 $displaydate =
"day";
1650 $posy = $pdf->getY();
1651 $pdf->SetXY($posx, $posy);
1652 $pdf->SetTextColor(0, 0, 60);
1653 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1656 $pdf->SetXY($posx, $posy);
1657 $pdf->SetTextColor(0, 0, 60);
1658 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1662 $pdf->SetXY($posx, $posy);
1663 $pdf->SetTextColor(0, 0, 60);
1664 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
1669 $pdf->SetXY($posx, $posy);
1670 $pdf->SetTextColor(0, 0, 60);
1671 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_compta_client),
'',
'R');
1676 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1677 if (count($arrayidcontact) > 0) {
1678 $usertmp =
new User($this->db);
1679 $usertmp->fetch($arrayidcontact[0]);
1681 $pdf->SetXY($posx, $posy);
1682 $pdf->SetTextColor(0, 0, 60);
1683 $pdf->MultiCell($w, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1691 $current_y = $pdf->getY();
1693 if ($current_y < $pdf->getY()) {
1694 $top_shift = $pdf->getY() - $current_y;
1699 $carac_emetteur =
'';
1701 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1702 if (count($arrayidcontact) > 0) {
1703 $object->fetch_user($arrayidcontact[0]);
1704 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1705 $carac_emetteur .= $labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1707 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1711 $carac_emetteur .=
"\n";
1717 $posy = 32 + $this->marge_haute + $top_shift;
1718 $posx = $this->marge_gauche;
1720 $posx = $this->page_largeur - $this->marge_droite - 80;
1726 $pdf->SetTextColor(0, 0, 0);
1727 $pdf->SetFont(
'',
'', $default_font_size - 2);
1728 $pdf->SetXY($posx, $posy - 5);
1729 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1730 $pdf->SetXY($posx, $posy);
1731 $pdf->SetFillColor(230, 230, 230);
1732 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1733 $pdf->SetTextColor(0, 0, 60);
1738 $pdf->SetXY($posx + 2, $posy + 3);
1739 $pdf->SetFont(
'',
'B', $default_font_size);
1740 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1741 $posy = $pdf->getY();
1745 $pdf->SetXY($posx + 2, $posy);
1746 $pdf->SetFont(
'',
'', $default_font_size - 1);
1747 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1751 $usecontact =
false;
1752 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1753 if (count($arrayidcontact) > 0) {
1755 $result =
$object->fetch_contact($arrayidcontact[0]);
1759 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1760 $thirdparty =
$object->contact;
1762 $thirdparty =
$object->thirdparty;
1772 if ($this->page_largeur < 210) {
1775 $posy = 32 + $this->marge_haute + $top_shift;
1776 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1778 $posx = $this->marge_gauche;
1783 $pdf->SetTextColor(0, 0, 0);
1784 $pdf->SetFont(
'',
'', $default_font_size - 2);
1785 $pdf->SetXY($posx + 2, $posy - 5);
1786 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1787 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1791 $pdf->SetXY($posx + 2, $posy + 3);
1792 $pdf->SetFont(
'',
'B', $default_font_size);
1794 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1796 $posy = $pdf->getY();
1799 $pdf->SetFont(
'',
'', $default_font_size - 1);
1800 $pdf->SetXY($posx + 2, $posy);
1802 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1805 $pdf->SetTextColor(0, 0, 0);