178 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
181 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
183 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
185 if (!is_object($outputlangs)) {
186 $outputlangs = $langs;
190 $outputlangs->charset_output =
'ISO-8859-1';
194 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
196 global $outputlangsbis;
197 $outputlangsbis =
null;
199 $outputlangsbis =
new Translate(
'', $conf);
201 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
209 $nblines = count(
$object->lines);
212 $realpatharray = array();
213 $this->atleastonephoto =
false;
215 $objphoto =
new Product($this->db);
217 for ($i = 0; $i < $nblines; $i++) {
218 if (empty(
$object->lines[$i]->fk_product)) {
222 $objphoto->fetch(
$object->lines[$i]->fk_product);
226 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
227 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
229 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
230 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
235 foreach ($pdir as $midir) {
237 if ($conf->entity != $objphoto->entity) {
238 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
240 $dir = $conf->product->dir_output.
'/'.$midir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
244 if ($obj[
'photo_vignette']) {
245 $filename = $obj[
'photo_vignette'];
247 $filename = $obj[
'photo'];
250 $filename = $obj[
'photo'];
253 $realpath = $dir.$filename;
255 $this->atleastonephoto =
true;
260 if ($realpath && $arephoto) {
261 $realpatharray[$i] = $realpath;
266 if (count($realpatharray) == 0) {
267 $this->posxpicture = $this->posxtva;
270 if ($conf->propal->multidir_output[$conf->entity]) {
277 $dir = $conf->propal->multidir_output[$conf->entity];
278 $file = $dir.
"/SPECIMEN.pdf";
281 $dir = $conf->propal->multidir_output[
$object->entity].
"/".$objectref;
282 $file = $dir.
"/".$objectref.
".pdf";
285 if (!file_exists($dir)) {
287 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
292 if (file_exists($dir)) {
294 if (!is_object($hookmanager)) {
295 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
298 $hookmanager->initHooks(array(
'pdfgeneration'));
299 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
301 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
304 $nblines = count(
$object->lines);
310 $pdf->SetAutoPageBreak(1, 0);
312 if (class_exists(
'TCPDF')) {
313 $pdf->setPrintHeader(
false);
314 $pdf->setPrintFooter(
false);
319 $logodir = $conf->mycompany->dir_output;
320 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
321 $logodir = $conf->mycompany->multidir_output[
$object->entity];
323 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
324 $tplidx = $pdf->importPage(1);
329 $pdf->SetDrawColor(128, 128, 128);
331 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
332 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
333 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
334 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
335 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
337 $pdf->SetCompression(
false);
341 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
344 for ($i = 0; $i < $nblines; $i++) {
345 if (
$object->lines[$i]->remise_percent) {
346 $this->atleastonediscount++;
349 if (empty($this->atleastonediscount)) {
350 $delta = ($this->postotalht - $this->posxdiscount);
351 $this->posxpicture += $delta;
352 $this->posxtva += $delta;
353 $this->posxup += $delta;
354 $this->posxqty += $delta;
355 $this->posxunit += $delta;
356 $this->posxdiscount += $delta;
362 if (!empty($tplidx)) {
363 $pdf->useTemplate($tplidx);
367 $heightforinfotot = 40;
369 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
370 $heightforfooter = $this->marge_basse + 8;
372 $heightforfooter += 6;
376 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
377 $pdf->SetFont(
'',
'', $default_font_size - 1);
378 $pdf->MultiCell(0, 3,
'');
379 $pdf->SetTextColor(0, 0, 0);
382 $tab_top = 90 + $top_shift;
383 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
386 $height_incoterms = 0;
387 if (isModEnabled(
'incoterm')) {
388 $desc_incoterms =
$object->getIncotermsForPDF();
389 if ($desc_incoterms) {
392 $pdf->SetFont(
'',
'', $default_font_size - 1);
393 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
394 $nexY = $pdf->GetY();
395 $height_incoterms = $nexY - $tab_top;
398 $pdf->SetDrawColor(192, 192, 192);
399 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
401 $tab_top = $nexY + 6;
402 $height_incoterms += 4;
407 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
410 if (is_object(
$object->thirdparty)) {
411 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
412 $salerepobj =
new User($this->db);
413 $salerepobj->fetch($salereparray[0][
'id']);
414 if (!empty($salerepobj->signature)) {
415 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
420 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
421 if (!empty($extranote)) {
425 $tmpuser =
new User($this->db);
426 $tmpuser->fetch(
$object->user_author_id);
429 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
430 if ($tmpuser->email) {
431 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
433 if ($tmpuser->office_phone) {
434 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
448 $pdf->SetFont(
'',
'', $default_font_size - 1);
449 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
450 $nexY = $pdf->GetY();
451 $height_note = $nexY - $tab_top;
454 $pdf->SetDrawColor(192, 192, 192);
455 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
457 $tab_top = $nexY + 6;
460 $iniY = $tab_top + 7;
461 $curY = $tab_top + 7;
462 $nexY = $tab_top + 7;
465 for ($i = 0; $i < $nblines; $i++) {
467 $pdf->SetFont(
'',
'', $default_font_size - 1);
468 $pdf->SetTextColor(0, 0, 0);
471 $imglinesize = array();
472 if (!empty($realpatharray[$i])) {
476 $pdf->setTopMargin($tab_top_newpage);
477 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
478 $pageposbefore = $pdf->getPage();
480 $showpricebeforepagebreak = 1;
482 $posYAfterDescription = 0;
485 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
486 $pdf->AddPage(
'',
'',
true);
487 if (!empty($tplidx)) {
488 $pdf->useTemplate($tplidx);
493 $pdf->setPage($pageposbefore + 1);
495 $curY = $tab_top_newpage;
499 $showpricebeforepagebreak = 1;
501 $showpricebeforepagebreak = 0;
505 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
506 $curX = $this->posxpicture - 1;
507 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
509 $posYAfterImage = $curY + $imglinesize[
'height'];
513 $curX = $this->posxdesc - 1;
515 $pdf->startTransaction();
516 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
517 $pageposafter = $pdf->getPage();
518 if ($pageposafter > $pageposbefore) {
519 $pdf->rollbackTransaction(
true);
520 $pageposafter = $pageposbefore;
522 $pdf->setPageOrientation(
'', 1, $heightforfooter);
523 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
525 $pageposafter = $pdf->getPage();
526 $posyafter = $pdf->GetY();
528 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
529 if ($i == ($nblines - 1)) {
530 $pdf->AddPage(
'',
'',
true);
531 if (!empty($tplidx)) {
532 $pdf->useTemplate($tplidx);
537 $pdf->setPage($pageposafter + 1);
544 $showpricebeforepagebreak = 1;
546 $showpricebeforepagebreak = 0;
550 $pdf->commitTransaction();
552 $posYAfterDescription = $pdf->GetY();
554 $nexY = $pdf->GetY();
555 $pageposafter = $pdf->getPage();
557 $pdf->setPage($pageposbefore);
558 $pdf->setTopMargin($this->marge_haute);
559 $pdf->setPageOrientation(
'', 1, 0);
562 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
563 $pdf->setPage($pageposafter);
564 $curY = $tab_top_newpage;
567 $pdf->SetFont(
'',
'', $default_font_size - 1);
572 $pdf->SetXY($this->posxtva - 5, $curY);
573 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
578 $pdf->SetXY($this->posxup, $curY);
579 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
583 $pdf->SetXY($this->posxqty, $curY);
584 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
589 $pdf->SetXY($this->posxunit, $curY);
590 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
594 $pdf->SetXY($this->posxdiscount, $curY);
595 if (
$object->lines[$i]->remise_percent) {
596 $pdf->SetXY($this->posxdiscount - 2, $curY);
598 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
603 $pdf->SetXY($this->postotalht, $curY);
604 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
607 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
608 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
610 $tvaligne =
$object->lines[$i]->total_tva;
613 $localtax1ligne =
$object->lines[$i]->total_localtax1;
614 $localtax2ligne =
$object->lines[$i]->total_localtax2;
615 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
616 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
617 $localtax1_type =
$object->lines[$i]->localtax1_type;
618 $localtax2_type =
$object->lines[$i]->localtax2_type;
631 $vatrate = (string)
$object->lines[$i]->tva_tx;
634 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
635 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
637 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
638 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
642 if ($localtax1_type && $localtax1ligne != 0) {
643 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
644 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
646 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
649 if ($localtax2_type && $localtax2ligne != 0) {
650 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
651 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
653 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
657 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
662 if (!isset($this->tva[$vatrate])) {
663 $this->tva[$vatrate] = 0;
665 $this->tva[$vatrate] += $tvaligne;
666 $vatcode =
$object->lines[$i]->vat_src_code;
667 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
668 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
670 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
672 if ($posYAfterImage > $posYAfterDescription) {
673 $nexY = $posYAfterImage;
678 $pdf->setPage($pageposafter);
679 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
681 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
682 $pdf->SetLineStyle(array(
'dash' => 0));
688 while ($pagenb < $pageposafter) {
689 $pdf->setPage($pagenb);
691 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
693 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
697 $pdf->setPage($pagenb);
698 $pdf->setPageOrientation(
'', 1, 0);
702 if (!empty($tplidx)) {
703 $pdf->useTemplate($tplidx);
706 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
708 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
710 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
715 if (!empty($tplidx)) {
716 $pdf->useTemplate($tplidx);
727 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
728 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
730 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
731 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
755 if (method_exists($pdf,
'AliasNbPages')) {
756 $pdf->AliasNbPages();
761 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
763 $already_merged = array();
764 foreach (
$object->lines as $line) {
765 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
770 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
772 $filetomerge->fetch_by_product($line->fk_product);
775 $already_merged[] = $line->fk_product;
777 $product =
new Product($this->db);
778 $product->fetch($line->fk_product);
780 if ($product->entity != $conf->entity) {
781 $entity_product_file = $product->entity;
783 $entity_product_file = $conf->entity;
787 if (count($filetomerge->lines) > 0) {
788 foreach ($filetomerge->lines as $linefile) {
789 if (!empty($linefile->id) && !empty($linefile->file_name)) {
791 if (isModEnabled(
"product")) {
792 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
793 } elseif (isModEnabled(
"service")) {
794 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
797 if (isModEnabled(
"product")) {
798 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
799 } elseif (isModEnabled(
"service")) {
800 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
804 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
806 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
807 if (file_exists($infile) && is_readable($infile)) {
808 $pagecount = $pdf->setSourceFile($infile);
809 for ($i = 1; $i <= $pagecount; $i++) {
810 $tplIdx = $pdf->importPage($i);
811 if ($tplIdx !==
false) {
812 $s = $pdf->getTemplatesize($tplIdx);
813 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
814 $pdf->useTemplate($tplIdx);
816 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
829 $pdf->Output($file,
'F');
832 $hookmanager->initHooks(array(
'pdfgeneration'));
833 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
835 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
837 $this->error = $hookmanager->error;
838 $this->errors = $hookmanager->errors;
843 $this->result = array(
'fullpath' => $file);
847 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
851 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
887 global $conf, $mysoc;
890 $pdf->SetFont(
'',
'', $default_font_size - 1);
892 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
895 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
896 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
897 $pdf->SetXY($this->marge_gauche, $posy);
898 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
900 $posy = $pdf->GetY() + 4;
905 $displaydate =
"daytext";
907 $displaydate =
"day";
911 if (!empty(
$object->delivery_date)) {
912 $outputlangs->load(
"sendings");
913 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
914 $pdf->SetXY($this->marge_gauche, $posy);
915 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
916 $pdf->MultiCell(80, 4, $titre, 0,
'L');
917 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
918 $pdf->SetXY($posxval, $posy);
920 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
922 $posy = $pdf->GetY() + 1;
924 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
925 $pdf->SetXY($this->marge_gauche, $posy);
926 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
927 $pdf->MultiCell(80, 4, $titre, 0,
'L');
928 $pdf->SetTextColor(0, 0, 0);
929 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
930 $pdf->SetXY($posxval, $posy);
931 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
932 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
933 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
935 $posy = $pdf->GetY() + 1;
940 $outputlangs->load(
"sendings");
942 $shipping_method_id =
$object->shipping_method_id;
943 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
944 $shipping_method_id = $this->emetteur->shipping_method_id;
946 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
947 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
949 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
950 $pdf->SetXY($this->marge_gauche, $posy);
951 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
952 $pdf->MultiCell(43, 4, $titre, 0,
'L');
954 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
955 $pdf->SetXY($posxval, $posy);
956 $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;
957 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
958 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
960 $posy = $pdf->GetY() + 1;
965 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
966 $pdf->SetXY($this->marge_gauche, $posy);
967 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
968 $pdf->MultiCell(43, 4, $titre, 0,
'L');
970 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
971 $pdf->SetXY($posxval, $posy);
972 $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);
973 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
974 if (
$object->deposit_percent > 0) {
975 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
977 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
979 $posy = $pdf->GetY() + 3;
984 if (
$object->mode_reglement_code
985 &&
$object->mode_reglement_code !=
'CHQ'
986 &&
$object->mode_reglement_code !=
'VIR') {
987 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
988 $pdf->SetXY($this->marge_gauche, $posy);
989 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
990 $pdf->MultiCell(80, 5, $titre, 0,
'L');
991 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
992 $pdf->SetXY($posxval, $posy);
993 $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);
994 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
996 $posy = $pdf->GetY() + 2;
1000 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1004 $account =
new Account($this->db);
1007 $pdf->SetXY($this->marge_gauche, $posy);
1008 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1009 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1010 $posy = $pdf->GetY() + 1;
1013 $pdf->SetXY($this->marge_gauche, $posy);
1014 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1015 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1016 $posy = $pdf->GetY() + 2;
1019 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1020 $pdf->SetXY($this->marge_gauche, $posy);
1021 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1022 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1023 $posy = $pdf->GetY() + 1;
1026 $pdf->SetXY($this->marge_gauche, $posy);
1027 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1028 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1029 $posy = $pdf->GetY() + 2;
1036 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1038 $bankid = (empty(
$object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1039 if (!empty(
$object->fk_bank)) {
1042 $account =
new Account($this->db);
1043 $account->fetch($bankid);
1045 $curx = $this->marge_gauche;
1048 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1074 global $conf, $mysoc;
1079 $pdf->SetFont(
'',
'', $default_font_size - 1);
1084 if ($this->page_largeur < 210) {
1087 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1093 $pdf->SetFillColor(255, 255, 255);
1094 $pdf->SetXY($col1x, $tab2_top);
1095 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1097 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1098 $pdf->SetXY($col2x, $tab2_top);
1099 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1102 $pdf->SetFillColor(248, 248, 248);
1104 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1106 $this->atleastoneratenotnull = 0;
1108 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1109 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1113 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1114 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1118 foreach ($localtax_rate as $tvakey => $tvaval) {
1123 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1126 if (preg_match(
'/\*/', $tvakey)) {
1127 $tvakey = str_replace(
'*',
'', $tvakey);
1128 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1130 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1133 $totalvat .= $tvacompl;
1135 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1138 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1140 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1142 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1143 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1149 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1150 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1154 foreach ($localtax_rate as $tvakey => $tvaval) {
1159 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1162 if (preg_match(
'/\*/', $tvakey)) {
1163 $tvakey = str_replace(
'*',
'', $tvakey);
1164 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1166 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1169 $totalvat .= $tvacompl;
1171 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1174 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1176 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1178 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1179 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1185 foreach ($this->tva_array as $tvakey => $tvaval) {
1187 $this->atleastoneratenotnull++;
1190 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1193 if (preg_match(
'/\*/', $tvakey)) {
1194 $tvakey = str_replace(
'*',
'', $tvakey);
1195 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1197 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1200 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1202 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1204 $totalvat .= $tvacompl;
1206 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1208 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1210 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1211 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1216 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1217 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1221 foreach ($localtax_rate as $tvakey => $tvaval) {
1226 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1229 if (preg_match(
'/\*/', $tvakey)) {
1230 $tvakey = str_replace(
'*',
'', $tvakey);
1231 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1233 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1236 $totalvat .= $tvacompl;
1238 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1241 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1243 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1245 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1246 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1252 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1253 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1257 foreach ($localtax_rate as $tvakey => $tvaval) {
1263 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1266 if (preg_match(
'/\*/', $tvakey)) {
1267 $tvakey = str_replace(
'*',
'', $tvakey);
1268 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1270 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1273 $totalvat .= $tvacompl;
1275 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1278 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1280 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1282 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1283 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1291 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1292 $pdf->SetTextColor(0, 0, 60);
1293 $pdf->SetFillColor(224, 224, 224);
1294 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1296 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1297 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1301 $pdf->SetTextColor(0, 0, 0);
1309 if ($deja_regle > 0) {
1312 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1313 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1315 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1316 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1334 $pdf->SetTextColor(0, 0, 60);
1335 $pdf->SetFillColor(224, 224, 224);
1336 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1337 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1339 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1340 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1342 $pdf->SetFont(
'',
'', $default_font_size - 1);
1343 $pdf->SetTextColor(0, 0, 0);
1347 return ($tab2_top + ($tab2_hl * $index));
1364 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1374 $currency = !empty($currency) ? $currency : $conf->currency;
1378 $pdf->SetTextColor(0, 0, 0);
1379 $pdf->SetFont(
'',
'', $default_font_size - 2);
1381 if (empty($hidetop)) {
1382 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1383 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1384 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1388 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1392 $pdf->SetDrawColor(128, 128, 128);
1393 $pdf->SetFont(
'',
'', $default_font_size - 1);
1396 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1398 if (empty($hidetop)) {
1399 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1401 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1402 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1406 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1407 if (empty($hidetop)) {
1414 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1415 if (empty($hidetop)) {
1417 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1418 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1422 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1423 if (empty($hidetop)) {
1424 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1425 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1428 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1429 if (empty($hidetop)) {
1430 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1431 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1435 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1436 if (empty($hidetop)) {
1437 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1439 $this->posxdiscount - $this->posxunit - 1,
1441 $outputlangs->transnoentities(
"Unit"),
1448 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1449 if (empty($hidetop)) {
1450 if ($this->atleastonediscount) {
1451 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1452 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1455 if ($this->atleastonediscount) {
1456 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1458 if (empty($hidetop)) {
1459 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1460 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1475 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1477 global $conf, $langs;
1479 $ltrdirection =
'L';
1480 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1481 $ltrdirection =
'R';
1485 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1491 $pdf->SetTextColor(0, 0, 60);
1492 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1496 $posy = $this->marge_haute;
1497 $posx = $this->page_largeur - $this->marge_droite - $w;
1499 $pdf->SetXY($this->marge_gauche, $posy);
1503 if ($this->emetteur->logo) {
1504 $logodir = $conf->mycompany->dir_output;
1505 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1506 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1509 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1511 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1513 if (is_readable($logo)) {
1515 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1517 $pdf->SetTextColor(200, 0, 0);
1518 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1519 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1520 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1523 $text = $this->emetteur->name;
1524 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1528 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1529 $pdf->SetXY($posx, $posy);
1530 $pdf->SetTextColor(0, 0, 60);
1531 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1532 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1533 if (
$object->statut == $object::STATUS_DRAFT) {
1534 $pdf->SetTextColor(128, 0, 0);
1535 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1537 $pdf->MultiCell(100, 4, $title,
'',
'R');
1539 $pdf->SetFont(
'',
'B', $default_font_size);
1549 $pdf->SetFont(
'',
'', $default_font_size - 2);
1553 $pdf->SetXY($posx, $posy);
1554 $pdf->SetTextColor(0, 0, 60);
1555 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1560 if (!empty(
$object->project->ref)) {
1562 $pdf->SetXY($posx, $posy);
1563 $pdf->SetTextColor(0, 0, 60);
1564 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1570 if (!empty(
$object->project->ref)) {
1571 $outputlangs->load(
"projects");
1573 $pdf->SetXY($posx, $posy);
1574 $pdf->SetTextColor(0, 0, 60);
1575 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1580 $displaydate =
"daytext";
1582 $displaydate =
"day";
1586 $posy = $pdf->getY();
1587 $pdf->SetXY($posx, $posy);
1588 $pdf->SetTextColor(0, 0, 60);
1589 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1592 $pdf->SetXY($posx, $posy);
1593 $pdf->SetTextColor(0, 0, 60);
1594 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1598 $pdf->SetXY($posx, $posy);
1599 $pdf->SetTextColor(0, 0, 60);
1600 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1605 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1606 if (count($arrayidcontact) > 0) {
1607 $usertmp =
new User($this->db);
1608 $usertmp->fetch($arrayidcontact[0]);
1610 $pdf->SetXY($posx, $posy);
1611 $pdf->SetTextColor(0, 0, 60);
1612 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1620 $current_y = $pdf->getY();
1622 if ($current_y < $pdf->getY()) {
1623 $top_shift = $pdf->getY() - $current_y;
1628 $carac_emetteur =
'';
1630 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1631 if (count($arrayidcontact) > 0) {
1632 $object->fetch_user($arrayidcontact[0]);
1633 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1634 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1636 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1640 $carac_emetteur .=
"\n";
1646 $posy = 42 + $top_shift;
1647 $posx = $this->marge_gauche;
1649 $posx = $this->page_largeur - $this->marge_droite - 80;
1655 $pdf->SetTextColor(0, 0, 0);
1656 $pdf->SetFont(
'',
'', $default_font_size - 2);
1657 $pdf->SetXY($posx, $posy - 5);
1658 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1659 $pdf->SetXY($posx, $posy);
1660 $pdf->SetFillColor(230, 230, 230);
1661 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1662 $pdf->SetTextColor(0, 0, 60);
1667 $pdf->SetXY($posx + 2, $posy + 3);
1668 $pdf->SetFont(
'',
'B', $default_font_size);
1669 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1670 $posy = $pdf->getY();
1674 $pdf->SetXY($posx + 2, $posy);
1675 $pdf->SetFont(
'',
'', $default_font_size - 1);
1676 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1680 $usecontact =
false;
1681 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1682 if (count($arrayidcontact) > 0) {
1684 $result =
$object->fetch_contact($arrayidcontact[0]);
1688 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1689 $thirdparty =
$object->contact;
1691 $thirdparty =
$object->thirdparty;
1701 if ($this->page_largeur < 210) {
1704 $posy = 42 + $top_shift;
1705 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1707 $posx = $this->marge_gauche;
1712 $pdf->SetTextColor(0, 0, 0);
1713 $pdf->SetFont(
'',
'', $default_font_size - 2);
1714 $pdf->SetXY($posx + 2, $posy - 5);
1715 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1716 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1720 $pdf->SetXY($posx + 2, $posy + 3);
1721 $pdf->SetFont(
'',
'B', $default_font_size);
1723 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1725 $posy = $pdf->getY();
1728 $pdf->SetFont(
'',
'', $default_font_size - 1);
1729 $pdf->SetXY($posx + 2, $posy);
1731 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1734 $pdf->SetTextColor(0, 0, 0);