154 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
157 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
159 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
161 if (!is_object($outputlangs)) {
162 $outputlangs = $langs;
166 $outputlangs->charset_output =
'ISO-8859-1';
170 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
173 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')) {
177 global $outputlangsbis;
178 $outputlangsbis =
null;
179 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
180 $outputlangsbis =
new Translate(
'', $conf);
181 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
182 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
185 $nblines = count($object->lines);
189 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
193 $realpatharray = array();
194 $this->atleastonephoto =
false;
196 $objphoto =
new Product($this->db);
198 for ($i = 0; $i < $nblines; $i++) {
199 if (empty($object->lines[$i]->fk_product)) {
203 $objphoto->fetch($object->lines[$i]->fk_product);
206 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
207 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
209 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
210 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
214 foreach ($pdir as $midir) {
216 if ($conf->entity != $objphoto->entity) {
217 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
219 $dir = $conf->product->dir_output.
'/'.$midir;
222 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
224 if ($obj[
'photo_vignette']) {
225 $filename = $obj[
'photo_vignette'];
227 $filename = $obj[
'photo'];
230 $filename = $obj[
'photo'];
233 $realpath = $dir.$filename;
235 $this->atleastonephoto =
true;
240 if ($realpath && $arephoto) {
241 $realpatharray[$i] = $realpath;
246 if (count($realpatharray) == 0) {
247 $this->posxpicture = $this->posxtva;
250 if ($conf->propal->multidir_output[$conf->entity]) {
251 $object->fetch_thirdparty();
256 if ($object->specimen) {
257 $dir = $conf->propal->multidir_output[$conf->entity];
258 $file = $dir.
"/SPECIMEN.pdf";
261 $dir = $conf->propal->multidir_output[$object->entity].
"/".$objectref;
262 $file = $dir.
"/".$objectref.
".pdf";
265 if (!file_exists($dir)) {
267 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
272 if (file_exists($dir)) {
274 if (!is_object($hookmanager)) {
275 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
278 $hookmanager->initHooks(array(
'pdfgeneration'));
279 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
281 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
284 $nblines = count($object->lines);
290 $pdf->SetAutoPageBreak(1, 0);
292 if (class_exists(
'TCPDF')) {
293 $pdf->setPrintHeader(
false);
294 $pdf->setPrintFooter(
false);
299 $logodir = $conf->mycompany->dir_output;
300 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
301 $logodir = $conf->mycompany->multidir_output[$object->entity];
303 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
304 $tplidx = $pdf->importPage(1);
309 $pdf->SetDrawColor(128, 128, 128);
311 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
312 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
313 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
314 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
315 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
317 $pdf->SetCompression(
false);
320 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
323 for ($i = 0; $i < $nblines; $i++) {
324 if ($object->lines[$i]->remise_percent) {
325 $this->atleastonediscount++;
332 if (!empty($tplidx)) {
333 $pdf->useTemplate($tplidx);
337 $heightforinfotot = 40;
339 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
340 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
343 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
344 $pdf->SetFont(
'',
'', $default_font_size - 1);
345 $pdf->MultiCell(0, 3,
'');
346 $pdf->SetTextColor(0, 0, 0);
349 $tab_top = 90 + $top_shift;
350 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
355 $height_incoterms = 0;
356 if (isModEnabled(
'incoterm')) {
357 $desc_incoterms = $object->getIncotermsForPDF();
358 if ($desc_incoterms) {
361 $pdf->SetFont(
'',
'', $default_font_size - 1);
362 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
363 $nexY = max($pdf->GetY(), $nexY);
364 $height_incoterms = $nexY - $tab_top;
367 $pdf->SetDrawColor(192, 192, 192);
368 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
370 $tab_top = $nexY + 6;
371 $height_incoterms += 4;
376 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
379 if (is_object($object->thirdparty)) {
380 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
381 $salerepobj =
new User($this->db);
382 $salerepobj->fetch($salereparray[0][
'id']);
383 if (!empty($salerepobj->signature)) {
384 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
390 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
391 if (!empty($extranote)) {
396 $tmpuser =
new User($this->db);
397 $tmpuser->fetch($object->user_author_id);
399 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
400 if ($tmpuser->email) {
401 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
403 if ($tmpuser->office_phone) {
404 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
410 $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
412 $pagenb = $pdf->getPage();
416 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
417 $pageposbeforenote = $pagenb;
424 $pdf->startTransaction();
426 $pdf->SetFont(
'',
'', $default_font_size - 1);
427 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
429 $pageposafternote = $pdf->getPage();
430 $posyafter = $pdf->GetY();
432 if ($pageposafternote > $pageposbeforenote) {
433 $pdf->rollbackTransaction(
true);
436 while ($pagenb < $pageposafternote) {
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
443 $this->
_pagehead($pdf, $object, 0, $outputlangs);
446 $pdf->setTopMargin($tab_top_newpage);
448 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
452 $pdf->setPage($pageposbeforenote);
453 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
454 $pdf->SetFont(
'',
'', $default_font_size - 1);
455 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
456 $pageposafternote = $pdf->getPage();
458 $posyafter = $pdf->GetY();
460 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
461 $pdf->AddPage(
'',
'',
true);
464 $pdf->setPage($pageposafternote);
465 $pdf->setTopMargin($tab_top_newpage);
467 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
473 $i = $pageposbeforenote;
474 while ($i < $pageposafternote) {
478 $pdf->SetDrawColor(128, 128, 128);
480 if ($i > $pageposbeforenote) {
481 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
482 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
484 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
485 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
489 $pdf->setPageOrientation(
'', 1, 0);
490 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
496 $pdf->setPage($pageposafternote);
497 if (!empty($tplidx)) {
498 $pdf->useTemplate($tplidx);
501 $this->
_pagehead($pdf, $object, 0, $outputlangs);
503 $height_note = $posyafter - $tab_top_newpage;
504 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
507 $pdf->commitTransaction();
508 $posyafter = $pdf->GetY();
509 $height_note = $posyafter - $tab_top;
510 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
513 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
515 $pdf->AddPage(
'',
'',
true);
518 $pdf->setPage($pageposafternote);
519 if (!empty($tplidx)) {
520 $pdf->useTemplate($tplidx);
523 $this->
_pagehead($pdf, $object, 0, $outputlangs);
526 $posyafter = $tab_top_newpage;
529 $tab_height = $tab_height - $height_note;
530 $tab_top = $posyafter + 6;
539 $pdf->startTransaction();
540 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
541 $pdf->rollbackTransaction(
true);
543 $nexY = $tab_top + $this->tabTitleHeight;
546 $pageposbeforeprintlines = $pdf->getPage();
547 $pagenb = $pageposbeforeprintlines;
548 for ($i = 0; $i < $nblines; $i++) {
550 $pdf->SetFont(
'',
'', $default_font_size - 1);
551 $pdf->SetTextColor(0, 0, 0);
554 $imglinesize = array();
555 if (!empty($realpatharray[$i])) {
559 $pdf->setTopMargin($tab_top_newpage);
560 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
561 $pageposbefore = $pdf->getPage();
563 $showpricebeforepagebreak = 1;
565 $posYAfterDescription = 0;
569 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
570 $pdf->AddPage(
'',
'',
true);
571 if (!empty($tplidx)) {
572 $pdf->useTemplate($tplidx);
574 $pdf->setPage($pageposbefore + 1);
576 $curY = $tab_top_newpage;
580 $showpricebeforepagebreak = 1;
582 $showpricebeforepagebreak = 0;
587 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
588 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
590 $posYAfterImage = $curY + $imglinesize[
'height'];
596 $pdf->startTransaction();
598 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
599 $pageposafter = $pdf->getPage();
601 if ($pageposafter > $pageposbefore) {
602 $pdf->rollbackTransaction(
true);
604 $pdf->setPageOrientation(
'', 1, $heightforfooter);
606 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
608 $pageposafter = $pdf->getPage();
609 $posyafter = $pdf->GetY();
611 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
612 if ($i == ($nblines - 1)) {
613 $pdf->AddPage(
'',
'',
true);
614 if (!empty($tplidx)) {
615 $pdf->useTemplate($tplidx);
617 $pdf->setPage($pageposafter + 1);
623 $showpricebeforepagebreak = 1;
625 $showpricebeforepagebreak = 0;
629 $pdf->commitTransaction();
631 $posYAfterDescription = $pdf->GetY();
634 $nexY = $pdf->GetY();
635 $pageposafter = $pdf->getPage();
637 $pdf->setPage($pageposbefore);
638 $pdf->setTopMargin($this->marge_haute);
639 $pdf->setPageOrientation(
'', 1, 0);
642 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
643 $pdf->setPage($pageposafter);
644 $curY = $tab_top_newpage;
647 $pdf->SetFont(
'',
'', $default_font_size - 1);
653 $nexY = max($pdf->GetY(), $nexY);
660 $nexY = max($pdf->GetY(), $nexY);
668 $nexY = max($pdf->GetY(), $nexY);
674 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
676 $nexY = max($pdf->GetY(), $nexY);
680 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
683 $nexY = max($pdf->GetY(), $nexY);
690 $nexY = max($pdf->GetY(), $nexY);
697 $nexY = max($pdf->GetY(), $nexY);
701 if (!empty($object->lines[$i]->array_options)) {
702 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
704 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
706 $nexY = max($pdf->GetY(), $nexY);
717 'outputlangs' => $outputlangs,
718 'hidedetails' => $hidedetails
720 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
724 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
725 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
727 $tvaligne = $object->lines[$i]->total_tva;
730 $localtax1ligne = $object->lines[$i]->total_localtax1;
731 $localtax2ligne = $object->lines[$i]->total_localtax2;
732 $localtax1_rate = $object->lines[$i]->localtax1_tx;
733 $localtax2_rate = $object->lines[$i]->localtax2_tx;
734 $localtax1_type = $object->lines[$i]->localtax1_type;
735 $localtax2_type = $object->lines[$i]->localtax2_type;
748 $vatrate = (string) $object->lines[$i]->tva_tx;
751 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
752 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
754 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
755 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
759 if ($localtax1_type && $localtax1ligne != 0) {
760 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
761 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
763 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
766 if ($localtax2_type && $localtax2ligne != 0) {
767 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
768 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
770 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
774 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
779 if (!isset($this->tva[$vatrate])) {
780 $this->tva[$vatrate] = 0;
782 $this->tva[$vatrate] += $tvaligne;
783 $vatcode = $object->lines[$i]->vat_src_code;
784 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
785 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
787 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
789 if ($posYAfterImage > $posYAfterDescription) {
790 $nexY = max($nexY, $posYAfterImage);
795 $pdf->setPage($pageposafter);
796 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
798 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
799 $pdf->SetLineStyle(array(
'dash'=>0));
805 while ($pagenb < $pageposafter) {
806 $pdf->setPage($pagenb);
807 if ($pagenb == $pageposbeforeprintlines) {
808 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
810 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
812 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
814 $pdf->setPage($pagenb);
815 $pdf->setPageOrientation(
'', 1, 0);
817 $this->
_pagehead($pdf, $object, 0, $outputlangs);
819 if (!empty($tplidx)) {
820 $pdf->useTemplate($tplidx);
824 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
825 if ($pagenb == $pageposafter) {
826 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
828 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
830 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
833 if (!empty($tplidx)) {
834 $pdf->useTemplate($tplidx);
838 $this->
_pagehead($pdf, $object, 0, $outputlangs);
844 if ($pagenb == $pageposbeforeprintlines) {
845 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
846 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
848 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
849 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
853 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
856 $posy = $this->
drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
864 $this->
_pagefoot($pdf, $object, $outputlangs);
865 if (method_exists($pdf,
'AliasNbPages')) {
866 $pdf->AliasNbPages();
871 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
873 $already_merged = array();
874 foreach ($object->lines as $line) {
875 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
880 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
882 $filetomerge->fetch_by_product($line->fk_product);
885 $already_merged[] = $line->fk_product;
887 $product =
new Product($this->db);
888 $product->fetch($line->fk_product);
890 if ($product->entity != $conf->entity) {
891 $entity_product_file = $product->entity;
893 $entity_product_file = $conf->entity;
897 if (count($filetomerge->lines) > 0) {
898 foreach ($filetomerge->lines as $linefile) {
899 if (!empty($linefile->id) && !empty($linefile->file_name)) {
901 if (isModEnabled(
"product")) {
902 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
903 } elseif (isModEnabled(
"service")) {
904 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
907 if (isModEnabled(
"product")) {
908 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
909 } elseif (isModEnabled(
"service")) {
910 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
914 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
916 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
917 if (file_exists($infile) && is_readable($infile)) {
918 $pagecount = $pdf->setSourceFile($infile);
919 for ($i = 1; $i <= $pagecount; $i++) {
920 $tplIdx = $pdf->importPage($i);
921 if ($tplIdx !==
false) {
922 $s = $pdf->getTemplatesize($tplIdx);
923 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
924 $pdf->useTemplate($tplIdx);
926 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
939 $pdf->Output($file,
'F');
942 $hookmanager->initHooks(array(
'pdfgeneration'));
943 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
945 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
947 $this->error = $hookmanager->error;
948 $this->errors = $hookmanager->errors;
953 $this->result = array(
'fullpath'=>$file);
957 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
961 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
977 global $conf, $mysoc;
980 $pdf->SetFont(
'',
'', $default_font_size - 1);
982 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
985 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
986 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
987 $pdf->SetXY($this->marge_gauche, $posy);
988 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
990 $posy = $pdf->GetY() + 4;
995 $displaydate =
"daytext";
997 $displaydate =
"day";
1001 if (!empty($object->delivery_date)) {
1002 $outputlangs->load(
"sendings");
1003 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1004 $pdf->SetXY($this->marge_gauche, $posy);
1005 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1006 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1007 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1008 $pdf->SetXY($posxval, $posy);
1009 $dlp =
dol_print_date($object->delivery_date, $displaydate,
false, $outputlangs,
true);
1010 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1012 $posy = $pdf->GetY() + 1;
1013 } elseif ($object->availability_code || $object->availability) {
1014 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1015 $pdf->SetXY($this->marge_gauche, $posy);
1016 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1017 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1018 $pdf->SetTextColor(0, 0, 0);
1019 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1020 $pdf->SetXY($posxval, $posy);
1021 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
1022 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1023 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1025 $posy = $pdf->GetY() + 1;
1029 if (!
getDolGlobalString(
'PROPOSAL_PDF_HIDE_DELIVERYMODE') && $object->shipping_method_id > 0) {
1030 $outputlangs->load(
"sendings");
1032 $shipping_method_id = $object->shipping_method_id;
1033 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1034 $shipping_method_id = $this->emetteur->shipping_method_id;
1036 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1037 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1039 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1040 $pdf->SetXY($this->marge_gauche, $posy);
1041 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1042 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1044 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1045 $pdf->SetXY($posxval, $posy);
1046 $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;
1047 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1048 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1050 $posy = $pdf->GetY() + 1;
1054 if (!
getDolGlobalString(
'PROPOSAL_PDF_HIDE_PAYMENTTERM') && $object->cond_reglement_code) {
1055 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1056 $pdf->SetXY($this->marge_gauche, $posy);
1057 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1058 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1060 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1061 $pdf->SetXY($posxval, $posy);
1062 $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);
1063 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1064 if ($object->deposit_percent > 0) {
1065 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
1067 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1069 $posy = $pdf->GetY() + 3;
1074 if ($object->mode_reglement_code
1075 && $object->mode_reglement_code !=
'CHQ'
1076 && $object->mode_reglement_code !=
'VIR') {
1077 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1078 $pdf->SetXY($this->marge_gauche, $posy);
1079 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1080 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1081 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1082 $pdf->SetXY($posxval, $posy);
1083 $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);
1084 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1086 $posy = $pdf->GetY() + 2;
1090 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1094 $account =
new Account($this->db);
1097 $pdf->SetXY($this->marge_gauche, $posy);
1098 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1099 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1100 $posy = $pdf->GetY() + 1;
1103 $pdf->SetXY($this->marge_gauche, $posy);
1104 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1105 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1106 $posy = $pdf->GetY() + 2;
1110 $pdf->SetXY($this->marge_gauche, $posy);
1111 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1112 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1113 $posy = $pdf->GetY() + 1;
1116 $pdf->SetXY($this->marge_gauche, $posy);
1117 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1118 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1119 $posy = $pdf->GetY() + 2;
1126 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1127 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1128 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1129 if ($object->fk_bank > 0) {
1130 $bankid = $object->fk_bank;
1132 $account =
new Account($this->db);
1133 $account->fetch($bankid);
1135 $curx = $this->marge_gauche;
1138 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1160 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1162 global $conf, $mysoc, $hookmanager;
1166 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1167 $outputlangsbis =
new Translate(
'', $conf);
1168 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1169 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1170 $default_font_size--;
1175 $pdf->SetFont(
'',
'', $default_font_size - 1);
1180 if ($this->page_largeur < 210) {
1183 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1189 $pdf->SetFillColor(255, 255, 255);
1190 $pdf->SetXY($col1x, $tab2_top);
1191 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1193 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1194 $pdf->SetXY($col2x, $tab2_top);
1195 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1198 $pdf->SetFillColor(248, 248, 248);
1200 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1202 $this->atleastoneratenotnull = 0;
1204 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1205 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1211 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1212 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1216 foreach ($localtax_rate as $tvakey => $tvaval) {
1221 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1224 if (preg_match(
'/\*/', $tvakey)) {
1225 $tvakey = str_replace(
'*',
'', $tvakey);
1226 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1228 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1230 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1231 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1233 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1235 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1236 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1244 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1245 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1249 foreach ($localtax_rate as $tvakey => $tvaval) {
1254 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1257 if (preg_match(
'/\*/', $tvakey)) {
1258 $tvakey = str_replace(
'*',
'', $tvakey);
1259 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1261 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1263 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1264 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1266 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1268 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1269 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1276 foreach ($this->tva as $tvakey => $tvaval) {
1278 $this->atleastoneratenotnull++;
1281 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1284 if (preg_match(
'/\*/', $tvakey)) {
1285 $tvakey = str_replace(
'*',
'', $tvakey);
1286 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1288 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1290 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1291 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1293 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1294 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1301 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1302 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1306 foreach ($localtax_rate as $tvakey => $tvaval) {
1311 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1314 if (preg_match(
'/\*/', $tvakey)) {
1315 $tvakey = str_replace(
'*',
'', $tvakey);
1316 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1318 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1321 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1322 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1324 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1326 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1327 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1335 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1336 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1340 foreach ($localtax_rate as $tvakey => $tvaval) {
1346 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1349 if (preg_match(
'/\*/', $tvakey)) {
1350 $tvakey = str_replace(
'*',
'', $tvakey);
1351 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1353 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1356 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1357 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1359 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1361 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1362 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1370 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1371 $pdf->SetTextColor(0, 0, 60);
1372 $pdf->SetFillColor(224, 224, 224);
1373 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1375 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1376 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1380 $pdf->SetTextColor(0, 0, 0);
1388 if ($deja_regle > 0) {
1392 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1393 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1395 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1396 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1415 $pdf->SetTextColor(0, 0, 60);
1416 $pdf->SetFillColor(224, 224, 224);
1417 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1418 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1420 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1421 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1423 $pdf->SetFont(
'',
'', $default_font_size - 1);
1424 $pdf->SetTextColor(0, 0, 0);
1428 return ($tab2_top + ($tab2_hl * $index));
1511 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1513 global $conf, $langs;
1515 $ltrdirection =
'L';
1516 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1517 $ltrdirection =
'R';
1521 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1527 $pdf->SetTextColor(0, 0, 60);
1528 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1532 $posy = $this->marge_haute;
1533 $posx = $this->page_largeur - $this->marge_droite - $w;
1535 $pdf->SetXY($this->marge_gauche, $posy);
1539 if ($this->emetteur->logo) {
1540 $logodir = $conf->mycompany->dir_output;
1541 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1542 $logodir = $conf->mycompany->multidir_output[$object->entity];
1545 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1547 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1549 if (is_readable($logo)) {
1551 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1553 $pdf->SetTextColor(200, 0, 0);
1554 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1555 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1556 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1559 $text = $this->emetteur->name;
1560 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1564 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1565 $pdf->SetXY($posx, $posy);
1566 $pdf->SetTextColor(0, 0, 60);
1567 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1568 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1569 if ($object->statut == $object::STATUS_DRAFT) {
1570 $pdf->SetTextColor(128, 0, 0);
1571 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1574 $pdf->MultiCell($w, 4, $title,
'',
'R');
1576 $pdf->SetFont(
'',
'B', $default_font_size);
1591 $pdf->SetFont(
'',
'', $default_font_size - 2);
1593 if ($object->ref_client) {
1595 $pdf->SetXY($posx, $posy);
1596 $pdf->SetTextColor(0, 0, 60);
1597 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65),
'',
'R');
1601 $object->fetch_projet();
1602 if (!empty($object->project->ref)) {
1604 $pdf->SetXY($posx, $posy);
1605 $pdf->SetTextColor(0, 0, 60);
1606 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1611 $object->fetch_projet();
1612 if (!empty($object->project->ref)) {
1613 $outputlangs->load(
"projects");
1615 $pdf->SetXY($posx, $posy);
1616 $pdf->SetTextColor(0, 0, 60);
1617 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1622 $displaydate =
"daytext";
1624 $displaydate =
"day";
1628 $posy = $pdf->getY();
1629 $pdf->SetXY($posx, $posy);
1630 $pdf->SetTextColor(0, 0, 60);
1631 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date($object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1634 $pdf->SetXY($posx, $posy);
1635 $pdf->SetTextColor(0, 0, 60);
1637 $title = $outputlangs->transnoentities(
"DateEndPropal");
1638 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1639 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1641 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1643 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
1645 $pdf->SetXY($posx, $posy);
1646 $pdf->SetTextColor(0, 0, 60);
1647 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_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->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1667 $current_y = $pdf->getY();
1668 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
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 :
'';
1685 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1687 $carac_emetteur .=
"\n";
1690 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1694 $posy += $top_shift;
1695 $posx = $this->marge_gauche;
1697 $posx = $this->page_largeur - $this->marge_droite - 80;
1705 $pdf->SetTextColor(0, 0, 0);
1706 $pdf->SetFont(
'',
'', $default_font_size - 2);
1707 $pdf->SetXY($posx, $posy - 5);
1708 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1709 $pdf->SetXY($posx, $posy);
1710 $pdf->SetFillColor(230, 230, 230);
1711 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1712 $pdf->SetTextColor(0, 0, 60);
1717 $pdf->SetXY($posx + 2, $posy + 3);
1718 $pdf->SetFont(
'',
'B', $default_font_size);
1719 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1720 $posy = $pdf->getY();
1724 $pdf->SetXY($posx + 2, $posy);
1725 $pdf->SetFont(
'',
'', $default_font_size - 1);
1726 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1730 $usecontact =
false;
1731 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1732 if (count($arrayidcontact) > 0) {
1734 $result = $object->fetch_contact($arrayidcontact[0]);
1738 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1739 $thirdparty = $object->contact;
1741 $thirdparty = $object->thirdparty;
1747 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1751 if ($this->page_largeur < 210) {
1755 $posy += $top_shift;
1756 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1758 $posx = $this->marge_gauche;
1763 $pdf->SetTextColor(0, 0, 0);
1764 $pdf->SetFont(
'',
'', $default_font_size - 2);
1765 $pdf->SetXY($posx + 2, $posy - 5);
1766 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1767 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1771 $pdf->SetXY($posx + 2, $posy + 3);
1772 $pdf->SetFont(
'',
'B', $default_font_size);
1773 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1775 $posy = $pdf->getY();
1778 $pdf->SetFont(
'',
'', $default_font_size - 1);
1779 $pdf->SetXY($posx + 2, $posy);
1780 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1783 $pdf->SetTextColor(0, 0, 0);