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;
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 if (
$conf->entity != $objphoto->entity) {
247 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
249 $dir =
$conf->product->dir_output.
'/'.$midir;
251 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
253 if ($obj[
'photo_vignette']) {
254 $filename = $obj[
'photo_vignette'];
256 $filename = $obj[
'photo'];
259 $filename = $obj[
'photo'];
262 $realpath = $dir.$filename;
264 $this->atleastonephoto =
true;
269 if ($realpath && $arephoto) {
270 $realpatharray[$i] = $realpath;
275 if (count($realpatharray) == 0) {
276 $this->posxpicture = $this->posxtva;
279 if (
$conf->propal->multidir_output[
$conf->entity]) {
286 $dir =
$conf->propal->multidir_output[
$conf->entity];
287 $file = $dir.
"/SPECIMEN.pdf";
290 $dir =
$conf->propal->multidir_output[
$object->entity].
"/".$objectref;
291 $file = $dir.
"/".$objectref.
".pdf";
294 if (!file_exists($dir)) {
296 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
301 if (file_exists($dir)) {
303 if (!is_object($hookmanager)) {
304 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
307 $hookmanager->initHooks(array(
'pdfgeneration'));
308 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
310 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
313 $nblines = count(
$object->lines);
319 $pdf->setAutoPageBreak(
true, 0);
321 if (class_exists(
'TCPDF')) {
322 $pdf->setPrintHeader(
false);
323 $pdf->setPrintFooter(
false);
328 $logodir =
$conf->mycompany->dir_output;
329 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
330 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
332 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
333 $tplidx = $pdf->importPage(1);
338 $pdf->SetDrawColor(128, 128, 128);
340 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
341 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
342 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
343 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
344 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
346 $pdf->SetCompression(
false);
350 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
353 for ($i = 0; $i < $nblines; $i++) {
354 if (
$object->lines[$i]->remise_percent) {
355 $this->atleastonediscount++;
358 if (empty($this->atleastonediscount)) {
359 $delta = ($this->postotalht - $this->posxdiscount);
360 $this->posxpicture += $delta;
361 $this->posxtva += $delta;
362 $this->posxup += $delta;
363 $this->posxqty += $delta;
364 $this->posxunit += $delta;
365 $this->posxdiscount += $delta;
371 if (!empty($tplidx)) {
372 $pdf->useTemplate($tplidx);
376 $heightforinfotot = 40;
379 $heightforfooter = $this->marge_basse + 8;
381 $heightforfooter += 6;
385 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
386 $pdf->SetFont(
'',
'', $default_font_size - 1);
387 $pdf->MultiCell(0, 3,
'');
388 $pdf->SetTextColor(0, 0, 0);
391 $tab_top = 90 + $top_shift;
392 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
395 $height_incoterms = 0;
396 if (isModEnabled(
'incoterm')) {
397 $desc_incoterms =
$object->getIncotermsForPDF();
398 if ($desc_incoterms) {
401 $pdf->SetFont(
'',
'', $default_font_size - 1);
402 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
403 $nexY = $pdf->GetY();
404 $height_incoterms = $nexY - $tab_top;
407 $pdf->SetDrawColor(192, 192, 192);
408 $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');
410 $tab_top = $nexY + 6;
411 $height_incoterms += 4;
416 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
419 if (is_object(
$object->thirdparty)) {
420 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
421 $salerepobj =
new User($this->db);
422 $salerepobj->fetch($salereparray[0][
'id']);
423 if (!empty($salerepobj->signature)) {
424 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
429 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
430 if (!empty($extranote)) {
434 $tmpuser =
new User($this->db);
435 $tmpuser->fetch(
$object->user_author_id);
438 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
439 if ($tmpuser->email) {
440 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
442 if ($tmpuser->office_phone) {
443 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
446 $notetoshow =
dol_concatdesc((
string) $notetoshow, $creator_info);
457 $pdf->SetFont(
'',
'', $default_font_size - 1);
458 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
459 $nexY = $pdf->GetY();
460 $height_note = $nexY - $tab_top;
463 $pdf->SetDrawColor(192, 192, 192);
464 $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');
466 $tab_top = $nexY + 6;
469 $iniY = $tab_top + 7;
470 $curY = $tab_top + 7;
471 $nexY = $tab_top + 7;
474 for ($i = 0; $i < $nblines; $i++) {
476 $pdf->SetFont(
'',
'', $default_font_size - 1);
477 $pdf->SetTextColor(0, 0, 0);
480 $imglinesize = array();
481 if (!empty($realpatharray[$i])) {
485 $pdf->setTopMargin($tab_top_newpage);
486 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
487 $pageposbefore = $pdf->getPage();
489 $showpricebeforepagebreak = 1;
491 $posYAfterDescription = 0;
494 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
495 $pdf->AddPage(
'',
'',
true);
496 if (!empty($tplidx)) {
497 $pdf->useTemplate($tplidx);
502 $pdf->setPage($pageposbefore + 1);
504 $curY = $tab_top_newpage;
508 $showpricebeforepagebreak = 1;
510 $showpricebeforepagebreak = 0;
514 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
515 $curX = $this->posxpicture - 1;
516 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
518 $posYAfterImage = $curY + $imglinesize[
'height'];
522 $curX = $this->posxdesc - 1;
524 $pdf->startTransaction();
525 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
526 $pageposafter = $pdf->getPage();
527 if ($pageposafter > $pageposbefore) {
528 $pdf->rollbackTransaction(
true);
529 $pageposafter = $pageposbefore;
531 $pdf->setPageOrientation(
'',
true, $heightforfooter);
532 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
534 $pageposafter = $pdf->getPage();
535 $posyafter = $pdf->GetY();
537 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
538 if ($i == ($nblines - 1)) {
539 $pdf->AddPage(
'',
'',
true);
540 if (!empty($tplidx)) {
541 $pdf->useTemplate($tplidx);
546 $pdf->setPage($pageposafter + 1);
553 $showpricebeforepagebreak = 1;
555 $showpricebeforepagebreak = 0;
559 $pdf->commitTransaction();
561 $posYAfterDescription = $pdf->GetY();
563 $nexY = $pdf->GetY();
564 $pageposafter = $pdf->getPage();
566 $pdf->setPage($pageposbefore);
567 $pdf->setTopMargin($this->marge_haute);
568 $pdf->setPageOrientation(
'',
true, 0);
571 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
572 $pdf->setPage($pageposafter);
573 $curY = $tab_top_newpage;
576 $pdf->SetFont(
'',
'', $default_font_size - 1);
581 $pdf->SetXY($this->posxtva - 5, $curY);
582 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
587 $pdf->SetXY($this->posxup, $curY);
588 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
592 $pdf->SetXY($this->posxqty, $curY);
593 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
598 $pdf->SetXY($this->posxunit, $curY);
599 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
603 $pdf->SetXY($this->posxdiscount, $curY);
604 if (
$object->lines[$i]->remise_percent) {
605 $pdf->SetXY($this->posxdiscount - 2, $curY);
607 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
612 $pdf->SetXY($this->postotalht, $curY);
613 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
616 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
617 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
619 $tvaligne =
$object->lines[$i]->total_tva;
622 $localtax1ligne =
$object->lines[$i]->total_localtax1;
623 $localtax2ligne =
$object->lines[$i]->total_localtax2;
624 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
625 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
626 $localtax1_type =
$object->lines[$i]->localtax1_type;
627 $localtax2_type =
$object->lines[$i]->localtax2_type;
640 $vatrate = (string)
$object->lines[$i]->tva_tx;
643 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
644 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
646 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
647 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
651 if ($localtax1_type && $localtax1ligne != 0) {
652 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
653 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
655 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
658 if ($localtax2_type && $localtax2ligne != 0) {
659 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
660 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
662 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
666 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
671 if (!isset($this->tva[$vatrate])) {
672 $this->tva[$vatrate] = 0;
674 $this->tva[$vatrate] += $tvaligne;
675 $vatcode =
$object->lines[$i]->vat_src_code;
676 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
677 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
679 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
681 if ($posYAfterImage > $posYAfterDescription) {
682 $nexY = $posYAfterImage;
687 $pdf->setPage($pageposafter);
688 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
690 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
691 $pdf->SetLineStyle(array(
'dash' => 0));
697 while ($pagenb < $pageposafter) {
698 $pdf->setPage($pagenb);
700 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
702 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
706 $pdf->setPage($pagenb);
707 $pdf->setPageOrientation(
'',
true, 0);
711 if (!empty($tplidx)) {
712 $pdf->useTemplate($tplidx);
715 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
717 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
719 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
724 if (!empty($tplidx)) {
725 $pdf->useTemplate($tplidx);
736 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
737 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
739 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
740 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
762 $keywords = $outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name);
763 $pdf->SetKeyWords($keywords.
" PAGESIGN=".$pdf->getPage());
768 if (method_exists($pdf,
'AliasNbPages')) {
769 $pdf->AliasNbPages();
775 $termsofsale =
$conf->propal->dir_output.
'/'.$termsofsalefilename;
776 if (!empty(
$conf->propal->multidir_output[
$object->entity])) {
777 $termsofsale =
$conf->propal->multidir_output[
$object->entity].
'/'.$termsofsalefilename;
779 if (file_exists($termsofsale) && is_readable($termsofsale)) {
780 $pagecount = $pdf->setSourceFile($termsofsale);
781 for ($i = 1; $i <= $pagecount; $i++) {
782 $tplIdx = $pdf->importPage($i);
783 if ($tplIdx !==
false) {
784 $s = $pdf->getTemplatesize($tplIdx);
785 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
786 $pdf->useTemplate($tplIdx);
788 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
796 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
798 $already_merged = array();
799 foreach (
$object->lines as $line) {
800 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
805 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
807 $filetomerge->fetch_by_product($line->fk_product);
810 $already_merged[] = $line->fk_product;
812 $product =
new Product($this->db);
813 $product->fetch($line->fk_product);
815 if ($product->entity !=
$conf->entity) {
816 $entity_product_file = $product->entity;
818 $entity_product_file =
$conf->entity;
822 if (count($filetomerge->lines) > 0) {
823 foreach ($filetomerge->lines as $linefile) {
824 $filetomerge_dir =
null;
825 if (!empty($linefile->id) && !empty($linefile->file_name)) {
827 if (isModEnabled(
"product")) {
828 $filetomerge_dir =
$conf->product->multidir_output[(int) $entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
829 } elseif (isModEnabled(
"service")) {
830 $filetomerge_dir =
$conf->service->multidir_output[(int) $entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
833 if (isModEnabled(
"product")) {
834 $filetomerge_dir =
$conf->product->multidir_output[(int) $entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
835 } elseif (isModEnabled(
"service")) {
836 $filetomerge_dir =
$conf->service->multidir_output[(int) $entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
840 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, $filetomerge_dir ===
null ? LOG_ERR : LOG_DEBUG);
841 if ($filetomerge_dir ===
null) {
846 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
847 if (file_exists($infile) && is_readable($infile)) {
848 $pagecount = $pdf->setSourceFile($infile);
849 for ($i = 1; $i <= $pagecount; $i++) {
850 $tplIdx = $pdf->importPage($i);
851 if ($tplIdx !==
false) {
852 $s = $pdf->getTemplatesize($tplIdx);
853 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
854 $pdf->useTemplate($tplIdx);
856 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
869 $pdf->Output($file,
'F');
872 $hookmanager->initHooks(array(
'pdfgeneration'));
873 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
875 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
877 $this->error = $hookmanager->error;
878 $this->errors = $hookmanager->errors;
883 $this->result = array(
'fullpath' => $file);
887 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
891 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
927 global
$conf, $mysoc;
930 $pdf->SetFont(
'',
'', $default_font_size - 1);
935 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
936 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
937 $pdf->SetXY($this->marge_gauche, $posy);
938 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
940 $posy = $pdf->GetY() + 4;
945 $displaydate =
"daytext";
947 $displaydate =
"day";
951 if (!empty(
$object->delivery_date)) {
952 $outputlangs->load(
"sendings");
953 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
954 $pdf->SetXY($this->marge_gauche, $posy);
955 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
956 $pdf->MultiCell(80, 4, $titre, 0,
'L');
957 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
958 $pdf->SetXY($posxval, $posy);
960 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
962 $posy = $pdf->GetY() + 1;
964 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
965 $pdf->SetXY($this->marge_gauche, $posy);
966 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
967 $pdf->MultiCell(80, 4, $titre, 0,
'L');
968 $pdf->SetTextColor(0, 0, 0);
969 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
970 $pdf->SetXY($posxval, $posy);
971 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
972 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
973 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
975 $posy = $pdf->GetY() + 1;
980 $outputlangs->load(
"sendings");
982 $shipping_method_id =
$object->shipping_method_id;
983 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
984 $shipping_method_id = $this->emetteur->shipping_method_id;
986 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
987 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
989 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
990 $pdf->SetXY($this->marge_gauche, $posy);
991 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
992 $pdf->MultiCell(43, 4, $titre, 0,
'L');
994 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
995 $pdf->SetXY($posxval, $posy);
996 $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;
997 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
998 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1000 $posy = $pdf->GetY() + 1;
1005 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1006 $pdf->SetXY($this->marge_gauche, $posy);
1007 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1008 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1010 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1011 $pdf->SetXY($posxval, $posy);
1012 $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);
1013 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1014 if (
$object->deposit_percent > 0) {
1015 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1017 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1019 $posy = $pdf->GetY() + 3;
1024 if (
$object->mode_reglement_code
1025 &&
$object->mode_reglement_code !=
'CHQ'
1026 &&
$object->mode_reglement_code !=
'VIR') {
1027 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1028 $pdf->SetXY($this->marge_gauche, $posy);
1029 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1030 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1031 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1032 $pdf->SetXY($posxval, $posy);
1033 $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);
1034 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1036 $posy = $pdf->GetY() + 2;
1040 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1044 $account =
new Account($this->db);
1047 $pdf->SetXY($this->marge_gauche, $posy);
1048 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1049 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1050 $posy = $pdf->GetY() + 1;
1053 $pdf->SetXY($this->marge_gauche, $posy);
1054 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1055 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1056 $posy = $pdf->GetY() + 2;
1060 $pdf->SetXY($this->marge_gauche, $posy);
1061 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1062 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1063 $posy = $pdf->GetY() + 1;
1066 $pdf->SetXY($this->marge_gauche, $posy);
1067 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1068 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1069 $posy = $pdf->GetY() + 2;
1076 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1082 $account =
new Account($this->db);
1083 $account->fetch($bankid);
1085 $curx = $this->marge_gauche;
1088 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1120 $pdf->SetFont(
'',
'', $default_font_size - 1);
1125 if ($this->page_largeur < 210) {
1128 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1134 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1137 $total_discount_on_lines = 0;
1138 $multicurrency_total_discount_on_lines = 0;
1139 foreach (
$object->lines as $i => $line) {
1143 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1144 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1146 if ($line->total_ht < 0) {
1147 $total_discount_on_lines += -$line->total_ht;
1148 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1152 if ($total_discount_on_lines > 0) {
1154 $pdf->SetFillColor(255, 255, 255);
1155 $pdf->SetXY($col1x, $tab2_top);
1156 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1157 $pdf->SetXY($col2x, $tab2_top);
1159 $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));
1160 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1164 $pdf->SetFillColor(255, 255, 255);
1165 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1166 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1167 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1169 $total_discount_to_show = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1170 $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);
1180 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
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);
1187 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
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);
1223 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
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);
1259 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
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);
1326 $total_localtax = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
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);
1363 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
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);
1586 if ($this->emetteur->logo) {
1587 $logodir =
$conf->mycompany->dir_output;
1588 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1589 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1592 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1594 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1596 if (is_readable($logo)) {
1598 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1600 $pdf->SetTextColor(200, 0, 0);
1601 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1602 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1603 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1606 $text = $this->emetteur->name;
1607 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1611 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1612 $pdf->SetXY($posx, $posy);
1613 $pdf->SetTextColor(0, 0, 60);
1614 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1615 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1616 if (
$object->statut == $object::STATUS_DRAFT) {
1617 $pdf->SetTextColor(128, 0, 0);
1618 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1620 $pdf->MultiCell($w, 4, $title,
'',
'R');
1622 $pdf->SetFont(
'',
'B', $default_font_size);
1632 $pdf->SetFont(
'',
'', $default_font_size - 2);
1636 $pdf->SetXY($posx, $posy);
1637 $pdf->SetTextColor(0, 0, 60);
1638 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1643 if (!empty(
$object->project->ref)) {
1645 $pdf->SetXY($posx, $posy);
1646 $pdf->SetTextColor(0, 0, 60);
1647 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1653 if (!empty(
$object->project->ref)) {
1654 $outputlangs->load(
"projects");
1656 $pdf->SetXY($posx, $posy);
1657 $pdf->SetTextColor(0, 0, 60);
1658 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1663 $displaydate =
"daytext";
1665 $displaydate =
"day";
1669 $posy = $pdf->getY();
1670 $pdf->SetXY($posx, $posy);
1671 $pdf->SetTextColor(0, 0, 60);
1672 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1675 $pdf->SetXY($posx, $posy);
1676 $pdf->SetTextColor(0, 0, 60);
1677 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1681 $pdf->SetXY($posx, $posy);
1682 $pdf->SetTextColor(0, 0, 60);
1683 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1688 $pdf->SetXY($posx, $posy);
1689 $pdf->SetTextColor(0, 0, 60);
1690 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1695 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1696 if (count($arrayidcontact) > 0) {
1697 $usertmp =
new User($this->db);
1698 $usertmp->fetch($arrayidcontact[0]);
1700 $pdf->SetXY($posx, $posy);
1701 $pdf->SetTextColor(0, 0, 60);
1702 $pdf->MultiCell($w, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1710 $current_y = $pdf->getY();
1712 if ($current_y < $pdf->getY()) {
1713 $top_shift = $pdf->getY() - $current_y;
1718 $carac_emetteur =
'';
1720 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1721 if (count($arrayidcontact) > 0) {
1722 $object->fetch_user($arrayidcontact[0]);
1723 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1724 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1726 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1730 $carac_emetteur .=
"\n";
1736 $posy = 42 + $top_shift;
1737 $posx = $this->marge_gauche;
1739 $posx = $this->page_largeur - $this->marge_droite - 80;
1745 $pdf->SetTextColor(0, 0, 0);
1746 $pdf->SetFont(
'',
'', $default_font_size - 2);
1747 $pdf->SetXY($posx, $posy - 5);
1748 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1749 $pdf->SetXY($posx, $posy);
1750 $pdf->SetFillColor(230, 230, 230);
1751 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1752 $pdf->SetTextColor(0, 0, 60);
1757 $pdf->SetXY($posx + 2, $posy + 3);
1758 $pdf->SetFont(
'',
'B', $default_font_size);
1759 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1760 $posy = $pdf->getY();
1764 $pdf->SetXY($posx + 2, $posy);
1765 $pdf->SetFont(
'',
'', $default_font_size - 1);
1766 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1770 $usecontact =
false;
1771 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1772 if (count($arrayidcontact) > 0) {
1774 $result =
$object->fetch_contact($arrayidcontact[0]);
1778 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1779 $thirdparty =
$object->contact;
1781 $thirdparty =
$object->thirdparty;
1791 if ($this->page_largeur < 210) {
1794 $posy = 42 + $top_shift;
1795 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1797 $posx = $this->marge_gauche;
1802 $pdf->SetTextColor(0, 0, 0);
1803 $pdf->SetFont(
'',
'', $default_font_size - 2);
1804 $pdf->SetXY($posx + 2, $posy - 5);
1805 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1806 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1810 $pdf->SetXY($posx + 2, $posy + 3);
1811 $pdf->SetFont(
'',
'B', $default_font_size);
1813 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1815 $posy = $pdf->getY();
1818 $pdf->SetFont(
'',
'', $default_font_size - 1);
1819 $pdf->SetXY($posx + 2, $posy);
1821 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1824 $pdf->SetTextColor(0, 0, 0);