162 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
165 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
167 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
169 if (!is_object($outputlangs)) {
170 $outputlangs = $langs;
174 $outputlangs->charset_output =
'ISO-8859-1';
178 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"products",
"propal",
"compta");
179 $outputlangs->loadLangs($langfiles);
186 global $outputlangsbis;
187 $outputlangsbis =
null;
189 $outputlangsbis =
new Translate(
'', $conf);
191 $outputlangsbis->loadLangs($langfiles);
194 $nblines = count(
$object->lines);
202 $realpatharray = array();
203 $this->atleastonephoto =
false;
205 $objphoto =
new Product($this->db);
207 for ($i = 0; $i < $nblines; $i++) {
208 if (empty(
$object->lines[$i]->fk_product)) {
212 $objphoto->fetch(
$object->lines[$i]->fk_product);
216 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
217 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
219 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
220 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
225 foreach ($pdir as $midir) {
227 if ($conf->entity != $objphoto->entity) {
228 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
230 $dir = $conf->product->dir_output.
'/'.$midir;
233 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
235 if ($obj[
'photo_vignette']) {
236 $filename = $obj[
'photo_vignette'];
238 $filename = $obj[
'photo'];
241 $filename = $obj[
'photo'];
244 $realpath = $dir.$filename;
246 $this->atleastonephoto =
true;
251 if ($realpath && $arephoto) {
252 $realpatharray[$i] = $realpath;
257 if (count($realpatharray) == 0) {
258 $this->posxpicture = $this->posxtva;
261 if ($conf->propal->multidir_output[$conf->entity]) {
268 $dir = $conf->propal->multidir_output[$conf->entity];
269 $file = $dir.
"/SPECIMEN.pdf";
272 $dir = $conf->propal->multidir_output[
$object->entity].
"/".$objectref;
273 $file = $dir.
"/".$objectref.
".pdf";
276 if (!file_exists($dir)) {
278 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
283 if (file_exists($dir)) {
285 if (!is_object($hookmanager)) {
286 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
289 $hookmanager->initHooks(array(
'pdfgeneration'));
290 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
292 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
295 $nblines = count(
$object->lines);
301 $pdf->SetAutoPageBreak(1, 0);
303 if (class_exists(
'TCPDF')) {
304 $pdf->setPrintHeader(
false);
305 $pdf->setPrintFooter(
false);
310 $logodir = $conf->mycompany->dir_output;
311 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
312 $logodir = $conf->mycompany->multidir_output[
$object->entity];
314 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
315 $tplidx = $pdf->importPage(1);
320 $pdf->SetDrawColor(128, 128, 128);
322 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
323 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
324 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
325 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
326 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
328 $pdf->SetCompression(
false);
332 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
335 for ($i = 0; $i < $nblines; $i++) {
336 if (
$object->lines[$i]->remise_percent) {
337 $this->atleastonediscount++;
344 if (!empty($tplidx)) {
345 $pdf->useTemplate($tplidx);
349 $heightforinfotot = 40;
352 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
355 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
356 $pdf->SetFont(
'',
'', $default_font_size - 1);
357 $pdf->MultiCell(0, 3,
'');
358 $pdf->SetTextColor(0, 0, 0);
361 $tab_top = 90 + $top_shift;
362 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
367 $height_incoterms = 0;
368 if (isModEnabled(
'incoterm')) {
369 $desc_incoterms =
$object->getIncotermsForPDF();
370 if ($desc_incoterms) {
373 $pdf->SetFont(
'',
'', $default_font_size - 1);
374 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
375 $nexY = max($pdf->GetY(), $nexY);
376 $height_incoterms = $nexY - $tab_top;
379 $pdf->SetDrawColor(192, 192, 192);
380 $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');
382 $tab_top = $nexY + 6;
383 $height_incoterms += 4;
388 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
391 if (is_object(
$object->thirdparty)) {
392 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
393 $salerepobj =
new User($this->db);
394 $salerepobj->fetch($salereparray[0][
'id']);
395 if (!empty($salerepobj->signature)) {
396 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
402 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
403 if (!empty($extranote)) {
408 $tmpuser =
new User($this->db);
409 $tmpuser->fetch(
$object->user_author_id);
411 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
412 if ($tmpuser->email) {
413 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
415 if ($tmpuser->office_phone) {
416 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
422 $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
424 $pagenb = $pdf->getPage();
428 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
429 $pageposbeforenote = $pagenb;
436 $pdf->startTransaction();
438 $pdf->SetFont(
'',
'', $default_font_size - 1);
439 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
441 $pageposafternote = $pdf->getPage();
442 $posyafter = $pdf->GetY();
444 if ($pageposafternote > $pageposbeforenote) {
445 $pdf->rollbackTransaction(
true);
448 while ($pagenb < $pageposafternote) {
451 if (!empty($tplidx)) {
452 $pdf->useTemplate($tplidx);
458 $pdf->setTopMargin($tab_top_newpage);
460 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
464 $pdf->setPage($pageposbeforenote);
465 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
466 $pdf->SetFont(
'',
'', $default_font_size - 1);
467 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
468 $pageposafternote = $pdf->getPage();
470 $posyafter = $pdf->GetY();
472 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
473 $pdf->AddPage(
'',
'',
true);
476 $pdf->setPage($pageposafternote);
477 $pdf->setTopMargin($tab_top_newpage);
479 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
485 $i = $pageposbeforenote;
486 while ($i < $pageposafternote) {
490 $pdf->SetDrawColor(128, 128, 128);
492 if ($i > $pageposbeforenote) {
493 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
494 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
496 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
497 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
501 $pdf->setPageOrientation(
'', 1, 0);
508 $pdf->setPage($pageposafternote);
509 if (!empty($tplidx)) {
510 $pdf->useTemplate($tplidx);
515 $height_note = $posyafter - $tab_top_newpage;
516 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
519 $pdf->commitTransaction();
520 $posyafter = $pdf->GetY();
521 $height_note = $posyafter - $tab_top;
522 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
525 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
527 $pdf->AddPage(
'',
'',
true);
530 $pdf->setPage($pageposafternote);
531 if (!empty($tplidx)) {
532 $pdf->useTemplate($tplidx);
538 $posyafter = $tab_top_newpage;
541 $tab_height -= $height_note;
542 $tab_top = $posyafter + 6;
551 $pdf->startTransaction();
552 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
553 $pdf->rollbackTransaction(
true);
555 $nexY = $tab_top + $this->tabTitleHeight;
558 $pageposbeforeprintlines = $pdf->getPage();
559 $pagenb = $pageposbeforeprintlines;
560 for ($i = 0; $i < $nblines; $i++) {
562 $pdf->SetFont(
'',
'', $default_font_size - 1);
563 $pdf->SetTextColor(0, 0, 0);
566 $imglinesize = array();
567 if (!empty($realpatharray[$i])) {
571 $pdf->setTopMargin($tab_top_newpage);
572 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
573 $pageposbefore = $pdf->getPage();
575 $showpricebeforepagebreak = 1;
577 $posYAfterDescription = 0;
581 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
582 $pdf->AddPage(
'',
'',
true);
583 if (!empty($tplidx)) {
584 $pdf->useTemplate($tplidx);
586 $pdf->setPage($pageposbefore + 1);
588 $curY = $tab_top_newpage;
592 $showpricebeforepagebreak = 1;
594 $showpricebeforepagebreak = 0;
599 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
600 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
602 $posYAfterImage = $curY + $imglinesize[
'height'];
608 $pdf->startTransaction();
611 $pageposafter = $pdf->getPage();
613 if ($pageposafter > $pageposbefore) {
614 $pdf->rollbackTransaction(
true);
616 $pdf->setPageOrientation(
'', 1, $heightforfooter);
620 $pageposafter = $pdf->getPage();
621 $posyafter = $pdf->GetY();
623 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
624 if ($i == ($nblines - 1)) {
625 $pdf->AddPage(
'',
'',
true);
626 if (!empty($tplidx)) {
627 $pdf->useTemplate($tplidx);
629 $pdf->setPage($pageposafter + 1);
635 $showpricebeforepagebreak = 1;
637 $showpricebeforepagebreak = 0;
641 $pdf->commitTransaction();
643 $posYAfterDescription = $pdf->GetY();
646 $nexY = $pdf->GetY();
647 $pageposafter = $pdf->getPage();
649 $pdf->setPage($pageposbefore);
650 $pdf->setTopMargin($this->marge_haute);
651 $pdf->setPageOrientation(
'', 1, 0);
654 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
655 $pdf->setPage($pageposafter);
656 $curY = $tab_top_newpage;
659 $pdf->SetFont(
'',
'', $default_font_size - 1);
670 $nexY = max($pdf->GetY(), $nexY);
677 $nexY = max($pdf->GetY(), $nexY);
685 $nexY = max($pdf->GetY(), $nexY);
693 $nexY = max($pdf->GetY(), $nexY);
700 $nexY = max($pdf->GetY(), $nexY);
707 $nexY = max($pdf->GetY(), $nexY);
714 $nexY = max($pdf->GetY(), $nexY);
718 if (!empty(
$object->lines[$i]->array_options)) {
719 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
723 $nexY = max($pdf->GetY(), $nexY);
734 'outputlangs' => $outputlangs,
735 'hidedetails' => $hidedetails
737 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
741 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
742 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
744 $tvaligne =
$object->lines[$i]->total_tva;
747 $localtax1ligne =
$object->lines[$i]->total_localtax1;
748 $localtax2ligne =
$object->lines[$i]->total_localtax2;
749 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
750 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
751 $localtax1_type =
$object->lines[$i]->localtax1_type;
752 $localtax2_type =
$object->lines[$i]->localtax2_type;
765 $vatrate = (string)
$object->lines[$i]->tva_tx;
768 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
769 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
771 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
772 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
776 if ($localtax1_type && $localtax1ligne != 0) {
777 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
778 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
780 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
783 if ($localtax2_type && $localtax2ligne != 0) {
784 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
785 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
787 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
791 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
796 if (!isset($this->tva[$vatrate])) {
797 $this->tva[$vatrate] = 0;
799 $this->tva[$vatrate] += $tvaligne;
800 $vatcode =
$object->lines[$i]->vat_src_code;
801 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
802 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
804 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
806 if ($posYAfterImage > $posYAfterDescription) {
807 $nexY = max($nexY, $posYAfterImage);
812 $pdf->setPage($pageposafter);
813 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
815 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
816 $pdf->SetLineStyle(array(
'dash' => 0));
822 while ($pagenb < $pageposafter) {
823 $pdf->setPage($pagenb);
824 if ($pagenb == $pageposbeforeprintlines) {
825 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
827 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
831 $pdf->setPage($pagenb);
832 $pdf->setPageOrientation(
'', 1, 0);
836 if (!empty($tplidx)) {
837 $pdf->useTemplate($tplidx);
841 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
842 if ($pagenb == $pageposafter) {
843 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
845 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
850 if (!empty($tplidx)) {
851 $pdf->useTemplate($tplidx);
861 if ($pagenb == $pageposbeforeprintlines) {
862 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
863 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
865 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
866 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
882 if (method_exists($pdf,
'AliasNbPages')) {
883 $pdf->AliasNbPages();
888 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
890 $already_merged = array();
891 foreach (
$object->lines as $line) {
892 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
897 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
899 $filetomerge->fetch_by_product($line->fk_product);
902 $already_merged[] = $line->fk_product;
904 $product =
new Product($this->db);
905 $product->fetch($line->fk_product);
907 if ($product->entity != $conf->entity) {
908 $entity_product_file = $product->entity;
910 $entity_product_file = $conf->entity;
914 if (count($filetomerge->lines) > 0) {
915 foreach ($filetomerge->lines as $linefile) {
916 if (!empty($linefile->id) && !empty($linefile->file_name)) {
918 if (isModEnabled(
"product")) {
919 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
920 } elseif (isModEnabled(
"service")) {
921 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
924 if (isModEnabled(
"product")) {
925 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
926 } elseif (isModEnabled(
"service")) {
927 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
931 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
933 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
934 if (file_exists($infile) && is_readable($infile)) {
935 $pagecount = $pdf->setSourceFile($infile);
936 for ($i = 1; $i <= $pagecount; $i++) {
937 $tplIdx = $pdf->importPage($i);
938 if ($tplIdx !==
false) {
939 $s = $pdf->getTemplatesize($tplIdx);
940 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
941 $pdf->useTemplate($tplIdx);
943 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
956 $pdf->Output($file,
'F');
959 $hookmanager->initHooks(array(
'pdfgeneration'));
960 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
962 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
964 $this->error = $hookmanager->error;
965 $this->errors = $hookmanager->errors;
970 $this->result = array(
'fullpath' => $file);
974 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
978 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
994 global $conf, $mysoc;
997 $pdf->SetFont(
'',
'', $default_font_size - 1);
999 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1002 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1003 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1004 $pdf->SetXY($this->marge_gauche, $posy);
1005 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1007 $posy = $pdf->GetY() + 4;
1012 $displaydate =
"daytext";
1014 $displaydate =
"day";
1018 if (!empty(
$object->delivery_date)) {
1019 $outputlangs->load(
"sendings");
1020 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1021 $pdf->SetXY($this->marge_gauche, $posy);
1022 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1023 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1024 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1025 $pdf->SetXY($posxval, $posy);
1027 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1029 $posy = $pdf->GetY() + 1;
1031 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1032 $pdf->SetXY($this->marge_gauche, $posy);
1033 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1034 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1035 $pdf->SetTextColor(0, 0, 0);
1036 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1037 $pdf->SetXY($posxval, $posy);
1038 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
1039 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1040 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1042 $posy = $pdf->GetY() + 1;
1047 $outputlangs->load(
"sendings");
1049 $shipping_method_id =
$object->shipping_method_id;
1050 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1051 $shipping_method_id = $this->emetteur->shipping_method_id;
1053 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1054 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1056 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1057 $pdf->SetXY($this->marge_gauche, $posy);
1058 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1059 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1061 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1062 $pdf->SetXY($posxval, $posy);
1063 $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;
1064 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1065 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1067 $posy = $pdf->GetY() + 1;
1072 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1073 $pdf->SetXY($this->marge_gauche, $posy);
1074 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1075 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1077 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1078 $pdf->SetXY($posxval, $posy);
1079 $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);
1080 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1081 if (
$object->deposit_percent > 0) {
1082 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1084 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1086 $posy = $pdf->GetY() + 3;
1091 if (
$object->mode_reglement_code
1092 &&
$object->mode_reglement_code !=
'CHQ'
1093 &&
$object->mode_reglement_code !=
'VIR') {
1094 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1095 $pdf->SetXY($this->marge_gauche, $posy);
1096 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1097 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1098 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1099 $pdf->SetXY($posxval, $posy);
1100 $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);
1101 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1103 $posy = $pdf->GetY() + 2;
1107 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1111 $account =
new Account($this->db);
1114 $pdf->SetXY($this->marge_gauche, $posy);
1115 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1116 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1117 $posy = $pdf->GetY() + 1;
1120 $pdf->SetXY($this->marge_gauche, $posy);
1121 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1122 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1123 $posy = $pdf->GetY() + 2;
1127 $pdf->SetXY($this->marge_gauche, $posy);
1128 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1129 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1130 $posy = $pdf->GetY() + 1;
1133 $pdf->SetXY($this->marge_gauche, $posy);
1134 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1135 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1136 $posy = $pdf->GetY() + 2;
1143 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1149 $account =
new Account($this->db);
1150 $account->fetch($bankid);
1152 $curx = $this->marge_gauche;
1155 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1179 global $conf, $mysoc, $hookmanager;
1184 $outputlangsbis =
new Translate(
'', $conf);
1186 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1187 $default_font_size--;
1192 $pdf->SetFont(
'',
'', $default_font_size - 1);
1197 if ($this->page_largeur < 210) {
1200 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1206 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1209 $total_line_remise = 0;
1210 foreach (
$object->lines as $i => $line) {
1212 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1214 if ($line->total_ht < 0) {
1215 $total_line_remise += -$line->total_ht;
1218 if ($total_line_remise > 0) {
1219 $pdf->SetFillColor(255, 255, 255);
1220 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1221 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1222 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1223 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1228 $pdf->SetFillColor(255, 255, 255);
1229 $pdf->SetXY($col1x, $tab2_top);
1230 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1231 $pdf->SetXY($col2x, $tab2_top);
1232 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1238 $pdf->SetFillColor(255, 255, 255);
1239 $pdf->SetXY($col1x, $tab2_top+ $tab2_hl * $index);
1240 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1242 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1243 $pdf->SetXY($col2x, $tab2_top+ $tab2_hl * $index);
1244 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1247 $pdf->SetFillColor(248, 248, 248);
1249 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1251 $this->atleastoneratenotnull = 0;
1253 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1254 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1260 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1261 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1265 foreach ($localtax_rate as $tvakey => $tvaval) {
1270 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1273 if (preg_match(
'/\*/', $tvakey)) {
1274 $tvakey = str_replace(
'*',
'', $tvakey);
1275 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1277 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1279 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1280 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1282 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1284 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1285 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1293 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1294 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1298 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).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1312 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1313 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1315 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1317 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1318 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1325 foreach ($this->tva as $tvakey => $tvaval) {
1327 $this->atleastoneratenotnull++;
1330 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1333 if (preg_match(
'/\*/', $tvakey)) {
1334 $tvakey = str_replace(
'*',
'', $tvakey);
1335 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1337 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1339 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1340 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1342 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1343 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1350 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1351 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1355 foreach ($localtax_rate as $tvakey => $tvaval) {
1360 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1363 if (preg_match(
'/\*/', $tvakey)) {
1364 $tvakey = str_replace(
'*',
'', $tvakey);
1365 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1367 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1370 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1371 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1373 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1375 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1376 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1384 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1385 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1389 foreach ($localtax_rate as $tvakey => $tvaval) {
1395 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1398 if (preg_match(
'/\*/', $tvakey)) {
1399 $tvakey = str_replace(
'*',
'', $tvakey);
1400 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1402 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1406 $totalvat .= $tvacompl;
1408 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1411 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1413 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1415 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1416 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1424 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1425 $pdf->SetTextColor(0, 0, 60);
1426 $pdf->SetFillColor(224, 224, 224);
1427 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1429 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1430 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1434 $pdf->SetTextColor(0, 0, 0);
1442 if ($deja_regle > 0) {
1446 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1447 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1449 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1450 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1468 $pdf->SetTextColor(0, 0, 60);
1469 $pdf->SetFillColor(224, 224, 224);
1470 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1471 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1473 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1474 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1476 $pdf->SetFont(
'',
'', $default_font_size - 1);
1477 $pdf->SetTextColor(0, 0, 0);
1480 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1482 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1484 $this->error = $hookmanager->error;
1485 $this->errors = $hookmanager->errors;
1489 return ($tab2_top + ($tab2_hl * $index));
1572 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1574 global $conf, $langs;
1576 $ltrdirection =
'L';
1577 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1578 $ltrdirection =
'R';
1582 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1588 $pdf->SetTextColor(0, 0, 60);
1589 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1593 $posy = $this->marge_haute;
1594 $posx = $this->page_largeur - $this->marge_droite - $w;
1596 $pdf->SetXY($this->marge_gauche, $posy);
1600 if ($this->emetteur->logo) {
1601 $logodir = $conf->mycompany->dir_output;
1602 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1603 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1606 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1608 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1610 if (is_readable($logo)) {
1612 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1614 $pdf->SetTextColor(200, 0, 0);
1615 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1616 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1617 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1620 $text = $this->emetteur->name;
1621 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1625 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1626 $pdf->SetXY($posx, $posy);
1627 $pdf->SetTextColor(0, 0, 60);
1628 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1629 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1630 if (
$object->status == $object::STATUS_DRAFT) {
1631 $pdf->SetTextColor(128, 0, 0);
1632 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1635 $pdf->MultiCell($w, 4, $title,
'',
'R');
1637 $pdf->SetFont(
'',
'B', $default_font_size);
1652 $pdf->SetFont(
'',
'', $default_font_size - 2);
1655 if ($ref_customer) {
1657 $pdf->SetXY($posx, $posy);
1658 $pdf->SetTextColor(0, 0, 60);
1659 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65),
'',
'R');
1664 if (!empty(
$object->project->ref)) {
1666 $pdf->SetXY($posx, $posy);
1667 $pdf->SetTextColor(0, 0, 60);
1668 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1674 if (!empty(
$object->project->ref)) {
1675 $outputlangs->load(
"projects");
1677 $pdf->SetXY($posx, $posy);
1678 $pdf->SetTextColor(0, 0, 60);
1679 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1684 $displaydate =
"daytext";
1686 $displaydate =
"day";
1690 $posy = $pdf->getY();
1691 $pdf->SetXY($posx, $posy);
1692 $pdf->SetTextColor(0, 0, 60);
1693 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1696 $pdf->SetXY($posx, $posy);
1697 $pdf->SetTextColor(0, 0, 60);
1699 $title = $outputlangs->transnoentities(
"DateEndPropal");
1700 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1701 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1703 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1707 $pdf->SetXY($posx, $posy);
1708 $pdf->SetTextColor(0, 0, 60);
1709 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1714 $pdf->SetXY($posx, $posy);
1715 $pdf->SetTextColor(0, 0, 60);
1716 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1721 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1722 if (count($arrayidcontact) > 0) {
1723 $usertmp =
new User($this->db);
1724 $usertmp->fetch($arrayidcontact[0]);
1726 $pdf->SetXY($posx, $posy);
1727 $pdf->SetTextColor(0, 0, 60);
1728 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1736 $current_y = $pdf->getY();
1738 if ($current_y < $pdf->getY()) {
1739 $top_shift = $pdf->getY() - $current_y;
1744 $carac_emetteur =
'';
1746 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1747 if (count($arrayidcontact) > 0) {
1748 $object->fetch_user($arrayidcontact[0]);
1749 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1750 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1752 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1756 $carac_emetteur .=
"\n";
1763 $posy += $top_shift;
1764 $posx = $this->marge_gauche;
1766 $posx = $this->page_largeur - $this->marge_droite - 80;
1774 $pdf->SetTextColor(0, 0, 0);
1775 $pdf->SetFont(
'',
'', $default_font_size - 2);
1776 $pdf->SetXY($posx, $posy - 5);
1777 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1778 $pdf->SetXY($posx, $posy);
1779 $pdf->SetFillColor(230, 230, 230);
1780 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1781 $pdf->SetTextColor(0, 0, 60);
1786 $pdf->SetXY($posx + 2, $posy + 3);
1787 $pdf->SetFont(
'',
'B', $default_font_size);
1788 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1789 $posy = $pdf->getY();
1793 $pdf->SetXY($posx + 2, $posy);
1794 $pdf->SetFont(
'',
'', $default_font_size - 1);
1795 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1799 $usecontact =
false;
1800 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1801 if (count($arrayidcontact) > 0) {
1803 $result =
$object->fetch_contact($arrayidcontact[0]);
1807 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1808 $thirdparty =
$object->contact;
1810 $thirdparty =
$object->thirdparty;
1820 if ($this->page_largeur < 210) {
1824 $posy += $top_shift;
1825 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1827 $posx = $this->marge_gauche;
1832 $pdf->SetTextColor(0, 0, 0);
1833 $pdf->SetFont(
'',
'', $default_font_size - 2);
1834 $pdf->SetXY($posx + 2, $posy - 5);
1835 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1836 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1840 $pdf->SetXY($posx + 2, $posy + 3);
1841 $pdf->SetFont(
'',
'B', $default_font_size);
1843 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1845 $posy = $pdf->getY();
1848 $pdf->SetFont(
'',
'', $default_font_size - 1);
1849 $pdf->SetXY($posx + 2, $posy);
1851 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1854 $pdf->SetTextColor(0, 0, 0);