185 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
188 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
190 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
192 if (!is_object($outputlangs)) {
193 $outputlangs = $langs;
197 $outputlangs->charset_output =
'ISO-8859-1';
201 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"propal",
"products",
"compta");
202 $outputlangs->loadLangs($langfiles);
204 global $outputlangsbis;
205 $outputlangsbis =
null;
207 $outputlangsbis =
new Translate(
'', $conf);
209 $outputlangsbis->loadLangs($langfiles);
217 $nblines = count(
$object->lines);
220 $realpatharray = array();
221 $this->atleastonephoto =
false;
223 $objphoto =
new Product($this->db);
225 for ($i = 0; $i < $nblines; $i++) {
226 if (empty(
$object->lines[$i]->fk_product)) {
230 $objphoto->fetch(
$object->lines[$i]->fk_product);
234 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
235 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
237 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
238 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
243 foreach ($pdir as $midir) {
245 if ($conf->entity != $objphoto->entity) {
246 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
248 $dir = $conf->product->dir_output.
'/'.$midir;
250 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
252 if ($obj[
'photo_vignette']) {
253 $filename = $obj[
'photo_vignette'];
255 $filename = $obj[
'photo'];
258 $filename = $obj[
'photo'];
261 $realpath = $dir.$filename;
263 $this->atleastonephoto =
true;
268 if ($realpath && $arephoto) {
269 $realpatharray[$i] = $realpath;
274 if (count($realpatharray) == 0) {
275 $this->posxpicture = $this->posxtva;
278 if ($conf->propal->multidir_output[$conf->entity]) {
285 $dir = $conf->propal->multidir_output[$conf->entity];
286 $file = $dir.
"/SPECIMEN.pdf";
289 $dir = $conf->propal->multidir_output[
$object->entity].
"/".$objectref;
290 $file = $dir.
"/".$objectref.
".pdf";
293 if (!file_exists($dir)) {
295 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
300 if (file_exists($dir)) {
302 if (!is_object($hookmanager)) {
303 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
306 $hookmanager->initHooks(array(
'pdfgeneration'));
307 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
309 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
312 $nblines = count(
$object->lines);
318 $pdf->SetAutoPageBreak(1, 0);
320 if (class_exists(
'TCPDF')) {
321 $pdf->setPrintHeader(
false);
322 $pdf->setPrintFooter(
false);
327 $logodir = $conf->mycompany->dir_output;
328 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
329 $logodir = $conf->mycompany->multidir_output[
$object->entity];
331 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
332 $tplidx = $pdf->importPage(1);
337 $pdf->SetDrawColor(128, 128, 128);
339 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
340 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
341 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
342 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
343 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
345 $pdf->SetCompression(
false);
349 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
352 for ($i = 0; $i < $nblines; $i++) {
353 if (
$object->lines[$i]->remise_percent) {
354 $this->atleastonediscount++;
357 if (empty($this->atleastonediscount)) {
358 $delta = ($this->postotalht - $this->posxdiscount);
359 $this->posxpicture += $delta;
360 $this->posxtva += $delta;
361 $this->posxup += $delta;
362 $this->posxqty += $delta;
363 $this->posxunit += $delta;
364 $this->posxdiscount += $delta;
370 if (!empty($tplidx)) {
371 $pdf->useTemplate($tplidx);
375 $heightforinfotot = 40;
378 $heightforfooter = $this->marge_basse + 8;
380 $heightforfooter += 6;
384 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
385 $pdf->SetFont(
'',
'', $default_font_size - 1);
386 $pdf->MultiCell(0, 3,
'');
387 $pdf->SetTextColor(0, 0, 0);
390 $tab_top = 90 + $top_shift;
391 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
394 $height_incoterms = 0;
395 if (isModEnabled(
'incoterm')) {
396 $desc_incoterms =
$object->getIncotermsForPDF();
397 if ($desc_incoterms) {
400 $pdf->SetFont(
'',
'', $default_font_size - 1);
401 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
402 $nexY = $pdf->GetY();
403 $height_incoterms = $nexY - $tab_top;
406 $pdf->SetDrawColor(192, 192, 192);
407 $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');
409 $tab_top = $nexY + 6;
410 $height_incoterms += 4;
415 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
418 if (is_object(
$object->thirdparty)) {
419 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
420 $salerepobj =
new User($this->db);
421 $salerepobj->fetch($salereparray[0][
'id']);
422 if (!empty($salerepobj->signature)) {
423 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
428 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
429 if (!empty($extranote)) {
433 $tmpuser =
new User($this->db);
434 $tmpuser->fetch(
$object->user_author_id);
437 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
438 if ($tmpuser->email) {
439 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
441 if ($tmpuser->office_phone) {
442 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
456 $pdf->SetFont(
'',
'', $default_font_size - 1);
457 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
458 $nexY = $pdf->GetY();
459 $height_note = $nexY - $tab_top;
462 $pdf->SetDrawColor(192, 192, 192);
463 $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');
465 $tab_top = $nexY + 6;
468 $iniY = $tab_top + 7;
469 $curY = $tab_top + 7;
470 $nexY = $tab_top + 7;
473 for ($i = 0; $i < $nblines; $i++) {
475 $pdf->SetFont(
'',
'', $default_font_size - 1);
476 $pdf->SetTextColor(0, 0, 0);
479 $imglinesize = array();
480 if (!empty($realpatharray[$i])) {
484 $pdf->setTopMargin($tab_top_newpage);
485 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
486 $pageposbefore = $pdf->getPage();
488 $showpricebeforepagebreak = 1;
490 $posYAfterDescription = 0;
493 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
494 $pdf->AddPage(
'',
'',
true);
495 if (!empty($tplidx)) {
496 $pdf->useTemplate($tplidx);
501 $pdf->setPage($pageposbefore + 1);
503 $curY = $tab_top_newpage;
507 $showpricebeforepagebreak = 1;
509 $showpricebeforepagebreak = 0;
513 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
514 $curX = $this->posxpicture - 1;
515 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
517 $posYAfterImage = $curY + $imglinesize[
'height'];
521 $curX = $this->posxdesc - 1;
523 $pdf->startTransaction();
524 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
525 $pageposafter = $pdf->getPage();
526 if ($pageposafter > $pageposbefore) {
527 $pdf->rollbackTransaction(
true);
528 $pageposafter = $pageposbefore;
530 $pdf->setPageOrientation(
'', 1, $heightforfooter);
531 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
533 $pageposafter = $pdf->getPage();
534 $posyafter = $pdf->GetY();
536 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
537 if ($i == ($nblines - 1)) {
538 $pdf->AddPage(
'',
'',
true);
539 if (!empty($tplidx)) {
540 $pdf->useTemplate($tplidx);
545 $pdf->setPage($pageposafter + 1);
552 $showpricebeforepagebreak = 1;
554 $showpricebeforepagebreak = 0;
558 $pdf->commitTransaction();
560 $posYAfterDescription = $pdf->GetY();
562 $nexY = $pdf->GetY();
563 $pageposafter = $pdf->getPage();
565 $pdf->setPage($pageposbefore);
566 $pdf->setTopMargin($this->marge_haute);
567 $pdf->setPageOrientation(
'', 1, 0);
570 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
571 $pdf->setPage($pageposafter);
572 $curY = $tab_top_newpage;
575 $pdf->SetFont(
'',
'', $default_font_size - 1);
580 $pdf->SetXY($this->posxtva - 5, $curY);
581 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
586 $pdf->SetXY($this->posxup, $curY);
587 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
591 $pdf->SetXY($this->posxqty, $curY);
592 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
597 $pdf->SetXY($this->posxunit, $curY);
598 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
602 $pdf->SetXY($this->posxdiscount, $curY);
603 if (
$object->lines[$i]->remise_percent) {
604 $pdf->SetXY($this->posxdiscount - 2, $curY);
606 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
611 $pdf->SetXY($this->postotalht, $curY);
612 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
615 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
616 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
618 $tvaligne =
$object->lines[$i]->total_tva;
621 $localtax1ligne =
$object->lines[$i]->total_localtax1;
622 $localtax2ligne =
$object->lines[$i]->total_localtax2;
623 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
624 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
625 $localtax1_type =
$object->lines[$i]->localtax1_type;
626 $localtax2_type =
$object->lines[$i]->localtax2_type;
639 $vatrate = (string)
$object->lines[$i]->tva_tx;
642 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
643 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
645 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
646 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
650 if ($localtax1_type && $localtax1ligne != 0) {
651 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
652 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
654 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
657 if ($localtax2_type && $localtax2ligne != 0) {
658 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
659 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
661 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
665 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
670 if (!isset($this->tva[$vatrate])) {
671 $this->tva[$vatrate] = 0;
673 $this->tva[$vatrate] += $tvaligne;
674 $vatcode =
$object->lines[$i]->vat_src_code;
675 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
676 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
678 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
680 if ($posYAfterImage > $posYAfterDescription) {
681 $nexY = $posYAfterImage;
686 $pdf->setPage($pageposafter);
687 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
689 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
690 $pdf->SetLineStyle(array(
'dash' => 0));
696 while ($pagenb < $pageposafter) {
697 $pdf->setPage($pagenb);
699 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
701 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
705 $pdf->setPage($pagenb);
706 $pdf->setPageOrientation(
'', 1, 0);
710 if (!empty($tplidx)) {
711 $pdf->useTemplate($tplidx);
714 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
716 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
718 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
723 if (!empty($tplidx)) {
724 $pdf->useTemplate($tplidx);
735 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
736 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
738 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
739 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
763 if (method_exists($pdf,
'AliasNbPages')) {
764 $pdf->AliasNbPages();
769 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
771 $already_merged = array();
772 foreach (
$object->lines as $line) {
773 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
778 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
780 $filetomerge->fetch_by_product($line->fk_product);
783 $already_merged[] = $line->fk_product;
785 $product =
new Product($this->db);
786 $product->fetch($line->fk_product);
788 if ($product->entity != $conf->entity) {
789 $entity_product_file = $product->entity;
791 $entity_product_file = $conf->entity;
795 if (count($filetomerge->lines) > 0) {
796 foreach ($filetomerge->lines as $linefile) {
797 if (!empty($linefile->id) && !empty($linefile->file_name)) {
799 if (isModEnabled(
"product")) {
800 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
801 } elseif (isModEnabled(
"service")) {
802 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
805 if (isModEnabled(
"product")) {
806 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
807 } elseif (isModEnabled(
"service")) {
808 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
812 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
814 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
815 if (file_exists($infile) && is_readable($infile)) {
816 $pagecount = $pdf->setSourceFile($infile);
817 for ($i = 1; $i <= $pagecount; $i++) {
818 $tplIdx = $pdf->importPage($i);
819 if ($tplIdx !==
false) {
820 $s = $pdf->getTemplatesize($tplIdx);
821 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
822 $pdf->useTemplate($tplIdx);
824 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
837 $pdf->Output($file,
'F');
840 $hookmanager->initHooks(array(
'pdfgeneration'));
841 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
843 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
845 $this->error = $hookmanager->error;
846 $this->errors = $hookmanager->errors;
851 $this->result = array(
'fullpath' => $file);
855 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
859 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
895 global $conf, $mysoc;
898 $pdf->SetFont(
'',
'', $default_font_size - 1);
900 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
903 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
904 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
905 $pdf->SetXY($this->marge_gauche, $posy);
906 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
908 $posy = $pdf->GetY() + 4;
913 $displaydate =
"daytext";
915 $displaydate =
"day";
919 if (!empty(
$object->delivery_date)) {
920 $outputlangs->load(
"sendings");
921 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
922 $pdf->SetXY($this->marge_gauche, $posy);
923 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
924 $pdf->MultiCell(80, 4, $titre, 0,
'L');
925 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
926 $pdf->SetXY($posxval, $posy);
928 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
930 $posy = $pdf->GetY() + 1;
932 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
933 $pdf->SetXY($this->marge_gauche, $posy);
934 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
935 $pdf->MultiCell(80, 4, $titre, 0,
'L');
936 $pdf->SetTextColor(0, 0, 0);
937 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
938 $pdf->SetXY($posxval, $posy);
939 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
940 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
941 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
943 $posy = $pdf->GetY() + 1;
948 $outputlangs->load(
"sendings");
950 $shipping_method_id =
$object->shipping_method_id;
951 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
952 $shipping_method_id = $this->emetteur->shipping_method_id;
954 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
955 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
957 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
958 $pdf->SetXY($this->marge_gauche, $posy);
959 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
960 $pdf->MultiCell(43, 4, $titre, 0,
'L');
962 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
963 $pdf->SetXY($posxval, $posy);
964 $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;
965 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
966 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
968 $posy = $pdf->GetY() + 1;
973 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
974 $pdf->SetXY($this->marge_gauche, $posy);
975 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
976 $pdf->MultiCell(43, 4, $titre, 0,
'L');
978 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
979 $pdf->SetXY($posxval, $posy);
980 $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);
981 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
982 if (
$object->deposit_percent > 0) {
983 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
985 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
987 $posy = $pdf->GetY() + 3;
992 if (
$object->mode_reglement_code
993 &&
$object->mode_reglement_code !=
'CHQ'
994 &&
$object->mode_reglement_code !=
'VIR') {
995 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
996 $pdf->SetXY($this->marge_gauche, $posy);
997 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
998 $pdf->MultiCell(80, 5, $titre, 0,
'L');
999 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1000 $pdf->SetXY($posxval, $posy);
1001 $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);
1002 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1004 $posy = $pdf->GetY() + 2;
1008 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1012 $account =
new Account($this->db);
1015 $pdf->SetXY($this->marge_gauche, $posy);
1016 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1017 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1018 $posy = $pdf->GetY() + 1;
1021 $pdf->SetXY($this->marge_gauche, $posy);
1022 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1023 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1024 $posy = $pdf->GetY() + 2;
1028 $pdf->SetXY($this->marge_gauche, $posy);
1029 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1030 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1031 $posy = $pdf->GetY() + 1;
1034 $pdf->SetXY($this->marge_gauche, $posy);
1035 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1036 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1037 $posy = $pdf->GetY() + 2;
1044 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1050 $account =
new Account($this->db);
1051 $account->fetch($bankid);
1053 $curx = $this->marge_gauche;
1056 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1082 global $conf, $mysoc;
1087 $pdf->SetFont(
'',
'', $default_font_size - 1);
1092 if ($this->page_largeur < 210) {
1095 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1101 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1104 $total_line_remise = 0;
1105 foreach (
$object->lines as $i => $line) {
1107 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1109 if ($line->total_ht < 0) {
1110 $total_line_remise += -$line->total_ht;
1113 if ($total_line_remise > 0) {
1114 $pdf->SetFillColor(255, 255, 255);
1115 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1116 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1117 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1118 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1123 $pdf->SetFillColor(255, 255, 255);
1124 $pdf->SetXY($col1x, $tab2_top);
1125 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1126 $pdf->SetXY($col2x, $tab2_top);
1127 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1133 $pdf->SetFillColor(255, 255, 255);
1134 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1135 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1137 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1138 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1139 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1142 $pdf->SetFillColor(248, 248, 248);
1144 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1146 $this->atleastoneratenotnull = 0;
1148 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1149 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1153 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1154 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1158 foreach ($localtax_rate as $tvakey => $tvaval) {
1163 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1166 if (preg_match(
'/\*/', $tvakey)) {
1167 $tvakey = str_replace(
'*',
'', $tvakey);
1168 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1170 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1173 $totalvat .= $tvacompl;
1175 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1178 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1180 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1182 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1183 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1189 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1190 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1194 foreach ($localtax_rate as $tvakey => $tvaval) {
1199 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1202 if (preg_match(
'/\*/', $tvakey)) {
1203 $tvakey = str_replace(
'*',
'', $tvakey);
1204 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1206 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1209 $totalvat .= $tvacompl;
1211 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1214 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1216 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1218 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1219 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1225 foreach ($this->tva_array as $tvakey => $tvaval) {
1227 $this->atleastoneratenotnull++;
1230 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1233 if (preg_match(
'/\*/', $tvakey)) {
1234 $tvakey = str_replace(
'*',
'', $tvakey);
1235 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1237 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1240 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1242 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1244 $totalvat .= $tvacompl;
1246 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1248 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1250 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1251 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1256 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1257 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1261 foreach ($localtax_rate as $tvakey => $tvaval) {
1266 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1269 if (preg_match(
'/\*/', $tvakey)) {
1270 $tvakey = str_replace(
'*',
'', $tvakey);
1271 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1273 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1276 $totalvat .= $tvacompl;
1278 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1281 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1283 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1285 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1286 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1292 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1293 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1297 foreach ($localtax_rate as $tvakey => $tvaval) {
1303 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1306 if (preg_match(
'/\*/', $tvakey)) {
1307 $tvakey = str_replace(
'*',
'', $tvakey);
1308 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1310 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1313 $totalvat .= $tvacompl;
1315 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1318 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1320 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1322 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1323 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1331 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1332 $pdf->SetTextColor(0, 0, 60);
1333 $pdf->SetFillColor(224, 224, 224);
1334 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1336 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1337 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1341 $pdf->SetTextColor(0, 0, 0);
1349 if ($deja_regle > 0) {
1352 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1353 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1355 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1356 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1374 $pdf->SetTextColor(0, 0, 60);
1375 $pdf->SetFillColor(224, 224, 224);
1376 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1377 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1379 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1380 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1382 $pdf->SetFont(
'',
'', $default_font_size - 1);
1383 $pdf->SetTextColor(0, 0, 0);
1387 return ($tab2_top + ($tab2_hl * $index));
1404 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1414 $currency = !empty($currency) ? $currency : $conf->currency;
1418 $pdf->SetTextColor(0, 0, 0);
1419 $pdf->SetFont(
'',
'', $default_font_size - 2);
1421 if (empty($hidetop)) {
1422 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1423 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1424 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1428 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1432 $pdf->SetDrawColor(128, 128, 128);
1433 $pdf->SetFont(
'',
'', $default_font_size - 1);
1436 $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');
1438 if (empty($hidetop)) {
1439 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1441 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1442 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1446 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1447 if (empty($hidetop)) {
1454 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1455 if (empty($hidetop)) {
1457 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1458 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1462 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1463 if (empty($hidetop)) {
1464 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1465 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1468 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1469 if (empty($hidetop)) {
1470 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1471 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1475 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1476 if (empty($hidetop)) {
1477 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1479 $this->posxdiscount - $this->posxunit - 1,
1481 $outputlangs->transnoentities(
"Unit"),
1488 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1489 if (empty($hidetop)) {
1490 if ($this->atleastonediscount) {
1491 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1492 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1495 if ($this->atleastonediscount) {
1496 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1498 if (empty($hidetop)) {
1499 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1500 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1515 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1517 global $conf, $langs;
1519 $ltrdirection =
'L';
1520 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1521 $ltrdirection =
'R';
1525 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1531 $pdf->SetTextColor(0, 0, 60);
1532 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1536 $posy = $this->marge_haute;
1537 $posx = $this->page_largeur - $this->marge_droite - $w;
1539 $pdf->SetXY($this->marge_gauche, $posy);
1543 if ($this->emetteur->logo) {
1544 $logodir = $conf->mycompany->dir_output;
1545 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1546 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1549 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1551 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1553 if (is_readable($logo)) {
1555 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1557 $pdf->SetTextColor(200, 0, 0);
1558 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1559 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1560 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1563 $text = $this->emetteur->name;
1564 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1568 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1569 $pdf->SetXY($posx, $posy);
1570 $pdf->SetTextColor(0, 0, 60);
1571 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1572 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1573 if (
$object->statut == $object::STATUS_DRAFT) {
1574 $pdf->SetTextColor(128, 0, 0);
1575 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1577 $pdf->MultiCell($w, 4, $title,
'',
'R');
1579 $pdf->SetFont(
'',
'B', $default_font_size);
1589 $pdf->SetFont(
'',
'', $default_font_size - 2);
1593 $pdf->SetXY($posx, $posy);
1594 $pdf->SetTextColor(0, 0, 60);
1595 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1600 if (!empty(
$object->project->ref)) {
1602 $pdf->SetXY($posx, $posy);
1603 $pdf->SetTextColor(0, 0, 60);
1604 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1610 if (!empty(
$object->project->ref)) {
1611 $outputlangs->load(
"projects");
1613 $pdf->SetXY($posx, $posy);
1614 $pdf->SetTextColor(0, 0, 60);
1615 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1620 $displaydate =
"daytext";
1622 $displaydate =
"day";
1626 $posy = $pdf->getY();
1627 $pdf->SetXY($posx, $posy);
1628 $pdf->SetTextColor(0, 0, 60);
1629 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1632 $pdf->SetXY($posx, $posy);
1633 $pdf->SetTextColor(0, 0, 60);
1634 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1638 $pdf->SetXY($posx, $posy);
1639 $pdf->SetTextColor(0, 0, 60);
1640 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1645 $pdf->SetXY($posx, $posy);
1646 $pdf->SetTextColor(0, 0, 60);
1647 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1652 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1653 if (count($arrayidcontact) > 0) {
1654 $usertmp =
new User($this->db);
1655 $usertmp->fetch($arrayidcontact[0]);
1657 $pdf->SetXY($posx, $posy);
1658 $pdf->SetTextColor(0, 0, 60);
1659 $pdf->MultiCell($w, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1667 $current_y = $pdf->getY();
1669 if ($current_y < $pdf->getY()) {
1670 $top_shift = $pdf->getY() - $current_y;
1675 $carac_emetteur =
'';
1677 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1678 if (count($arrayidcontact) > 0) {
1679 $object->fetch_user($arrayidcontact[0]);
1680 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1681 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1683 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1687 $carac_emetteur .=
"\n";
1693 $posy = 42 + $top_shift;
1694 $posx = $this->marge_gauche;
1696 $posx = $this->page_largeur - $this->marge_droite - 80;
1702 $pdf->SetTextColor(0, 0, 0);
1703 $pdf->SetFont(
'',
'', $default_font_size - 2);
1704 $pdf->SetXY($posx, $posy - 5);
1705 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1706 $pdf->SetXY($posx, $posy);
1707 $pdf->SetFillColor(230, 230, 230);
1708 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1709 $pdf->SetTextColor(0, 0, 60);
1714 $pdf->SetXY($posx + 2, $posy + 3);
1715 $pdf->SetFont(
'',
'B', $default_font_size);
1716 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1717 $posy = $pdf->getY();
1721 $pdf->SetXY($posx + 2, $posy);
1722 $pdf->SetFont(
'',
'', $default_font_size - 1);
1723 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1727 $usecontact =
false;
1728 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1729 if (count($arrayidcontact) > 0) {
1731 $result =
$object->fetch_contact($arrayidcontact[0]);
1735 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1736 $thirdparty =
$object->contact;
1738 $thirdparty =
$object->thirdparty;
1748 if ($this->page_largeur < 210) {
1751 $posy = 42 + $top_shift;
1752 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1754 $posx = $this->marge_gauche;
1759 $pdf->SetTextColor(0, 0, 0);
1760 $pdf->SetFont(
'',
'', $default_font_size - 2);
1761 $pdf->SetXY($posx + 2, $posy - 5);
1762 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1763 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1767 $pdf->SetXY($posx + 2, $posy + 3);
1768 $pdf->SetFont(
'',
'B', $default_font_size);
1770 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1772 $posy = $pdf->getY();
1775 $pdf->SetFont(
'',
'', $default_font_size - 1);
1776 $pdf->SetXY($posx + 2, $posy);
1778 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1781 $pdf->SetTextColor(0, 0, 0);