177 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
180 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
182 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
184 if (!is_object($outputlangs)) {
185 $outputlangs = $langs;
189 $outputlangs->charset_output =
'ISO-8859-1';
193 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
195 global $outputlangsbis;
196 $outputlangsbis =
null;
197 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
198 $outputlangsbis =
new Translate(
'', $conf);
199 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
200 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
204 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')) {
208 $nblines = count($object->lines);
211 $realpatharray = array();
212 $this->atleastonephoto =
false;
214 $objphoto =
new Product($this->db);
216 for ($i = 0; $i < $nblines; $i++) {
217 if (empty($object->lines[$i]->fk_product)) {
221 $objphoto->fetch($object->lines[$i]->fk_product);
224 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
225 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
227 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
228 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
233 foreach ($pdir as $midir) {
235 if ($conf->entity != $objphoto->entity) {
236 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
238 $dir = $conf->product->dir_output.
'/'.$midir;
240 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
242 if ($obj[
'photo_vignette']) {
243 $filename = $obj[
'photo_vignette'];
245 $filename = $obj[
'photo'];
248 $filename = $obj[
'photo'];
251 $realpath = $dir.$filename;
253 $this->atleastonephoto =
true;
258 if ($realpath && $arephoto) {
259 $realpatharray[$i] = $realpath;
264 if (count($realpatharray) == 0) {
265 $this->posxpicture = $this->posxtva;
268 if ($conf->propal->multidir_output[$conf->entity]) {
269 $object->fetch_thirdparty();
274 if ($object->specimen) {
275 $dir = $conf->propal->multidir_output[$conf->entity];
276 $file = $dir.
"/SPECIMEN.pdf";
279 $dir = $conf->propal->multidir_output[$object->entity].
"/".$objectref;
280 $file = $dir.
"/".$objectref.
".pdf";
283 if (!file_exists($dir)) {
285 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
290 if (file_exists($dir)) {
292 if (!is_object($hookmanager)) {
293 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
296 $hookmanager->initHooks(array(
'pdfgeneration'));
297 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
299 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
302 $nblines = count($object->lines);
308 $pdf->SetAutoPageBreak(1, 0);
310 if (class_exists(
'TCPDF')) {
311 $pdf->setPrintHeader(
false);
312 $pdf->setPrintFooter(
false);
317 $logodir = $conf->mycompany->dir_output;
318 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
319 $logodir = $conf->mycompany->multidir_output[$object->entity];
321 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
322 $tplidx = $pdf->importPage(1);
327 $pdf->SetDrawColor(128, 128, 128);
329 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
330 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
331 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
332 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
335 $pdf->SetCompression(
false);
338 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
341 for ($i = 0; $i < $nblines; $i++) {
342 if ($object->lines[$i]->remise_percent) {
343 $this->atleastonediscount++;
346 if (empty($this->atleastonediscount)) {
347 $delta = ($this->postotalht - $this->posxdiscount);
348 $this->posxpicture += $delta;
349 $this->posxtva += $delta;
350 $this->posxup += $delta;
351 $this->posxqty += $delta;
352 $this->posxunit += $delta;
353 $this->posxdiscount += $delta;
359 if (!empty($tplidx)) {
360 $pdf->useTemplate($tplidx);
364 $heightforinfotot = 40;
366 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
367 $heightforfooter = $this->marge_basse + 8;
369 $heightforfooter += 6;
373 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
374 $pdf->SetFont(
'',
'', $default_font_size - 1);
375 $pdf->MultiCell(0, 3,
'');
376 $pdf->SetTextColor(0, 0, 0);
379 $tab_top = 90 + $top_shift;
380 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
383 $height_incoterms = 0;
384 if (isModEnabled(
'incoterm')) {
385 $desc_incoterms = $object->getIncotermsForPDF();
386 if ($desc_incoterms) {
389 $pdf->SetFont(
'',
'', $default_font_size - 1);
390 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
391 $nexY = $pdf->GetY();
392 $height_incoterms = $nexY - $tab_top;
395 $pdf->SetDrawColor(192, 192, 192);
396 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
398 $tab_top = $nexY + 6;
399 $height_incoterms += 4;
404 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
407 if (is_object($object->thirdparty)) {
408 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
409 $salerepobj =
new User($this->db);
410 $salerepobj->fetch($salereparray[0][
'id']);
411 if (!empty($salerepobj->signature)) {
412 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
417 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
418 if (!empty($extranote)) {
422 $tmpuser =
new User($this->db);
423 $tmpuser->fetch($object->user_author_id);
426 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
427 if ($tmpuser->email) {
428 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
430 if ($tmpuser->office_phone) {
431 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
445 $pdf->SetFont(
'',
'', $default_font_size - 1);
446 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
447 $nexY = $pdf->GetY();
448 $height_note = $nexY - $tab_top;
451 $pdf->SetDrawColor(192, 192, 192);
452 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
454 $tab_top = $nexY + 6;
457 $iniY = $tab_top + 7;
458 $curY = $tab_top + 7;
459 $nexY = $tab_top + 7;
462 for ($i = 0; $i < $nblines; $i++) {
464 $pdf->SetFont(
'',
'', $default_font_size - 1);
465 $pdf->SetTextColor(0, 0, 0);
468 $imglinesize = array();
469 if (!empty($realpatharray[$i])) {
473 $pdf->setTopMargin($tab_top_newpage);
474 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
475 $pageposbefore = $pdf->getPage();
477 $showpricebeforepagebreak = 1;
479 $posYAfterDescription = 0;
482 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
483 $pdf->AddPage(
'',
'',
true);
484 if (!empty($tplidx)) {
485 $pdf->useTemplate($tplidx);
488 $this->
_pagehead($pdf, $object, 0, $outputlangs);
490 $pdf->setPage($pageposbefore + 1);
492 $curY = $tab_top_newpage;
496 $showpricebeforepagebreak = 1;
498 $showpricebeforepagebreak = 0;
502 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
503 $curX = $this->posxpicture - 1;
504 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
506 $posYAfterImage = $curY + $imglinesize[
'height'];
510 $curX = $this->posxdesc - 1;
512 $pdf->startTransaction();
513 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
514 $pageposafter = $pdf->getPage();
515 if ($pageposafter > $pageposbefore) {
516 $pdf->rollbackTransaction(
true);
517 $pageposafter = $pageposbefore;
519 $pdf->setPageOrientation(
'', 1, $heightforfooter);
520 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
522 $pageposafter = $pdf->getPage();
523 $posyafter = $pdf->GetY();
525 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
526 if ($i == ($nblines - 1)) {
527 $pdf->AddPage(
'',
'',
true);
528 if (!empty($tplidx)) {
529 $pdf->useTemplate($tplidx);
532 $this->
_pagehead($pdf, $object, 0, $outputlangs);
534 $pdf->setPage($pageposafter + 1);
541 $showpricebeforepagebreak = 1;
543 $showpricebeforepagebreak = 0;
547 $pdf->commitTransaction();
549 $posYAfterDescription = $pdf->GetY();
551 $nexY = $pdf->GetY();
552 $pageposafter = $pdf->getPage();
554 $pdf->setPage($pageposbefore);
555 $pdf->setTopMargin($this->marge_haute);
556 $pdf->setPageOrientation(
'', 1, 0);
559 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
560 $pdf->setPage($pageposafter);
561 $curY = $tab_top_newpage;
564 $pdf->SetFont(
'',
'', $default_font_size - 1);
569 $pdf->SetXY($this->posxtva - 5, $curY);
570 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
575 $pdf->SetXY($this->posxup, $curY);
576 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
580 $pdf->SetXY($this->posxqty, $curY);
581 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
585 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
586 $pdf->SetXY($this->posxunit, $curY);
587 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
591 $pdf->SetXY($this->posxdiscount, $curY);
592 if ($object->lines[$i]->remise_percent) {
593 $pdf->SetXY($this->posxdiscount - 2, $curY);
595 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
600 $pdf->SetXY($this->postotalht, $curY);
601 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
604 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
605 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
607 $tvaligne = $object->lines[$i]->total_tva;
610 $localtax1ligne = $object->lines[$i]->total_localtax1;
611 $localtax2ligne = $object->lines[$i]->total_localtax2;
612 $localtax1_rate = $object->lines[$i]->localtax1_tx;
613 $localtax2_rate = $object->lines[$i]->localtax2_tx;
614 $localtax1_type = $object->lines[$i]->localtax1_type;
615 $localtax2_type = $object->lines[$i]->localtax2_type;
628 $vatrate = (string) $object->lines[$i]->tva_tx;
631 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
632 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
634 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
635 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
639 if ($localtax1_type && $localtax1ligne != 0) {
640 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
641 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
643 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
646 if ($localtax2_type && $localtax2ligne != 0) {
647 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
648 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
650 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
654 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
659 if (!isset($this->tva[$vatrate])) {
660 $this->tva[$vatrate] = 0;
662 $this->tva[$vatrate] += $tvaligne;
663 $vatcode = $object->lines[$i]->vat_src_code;
664 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
665 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
667 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
669 if ($posYAfterImage > $posYAfterDescription) {
670 $nexY = $posYAfterImage;
675 $pdf->setPage($pageposafter);
676 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
678 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
679 $pdf->SetLineStyle(array(
'dash'=>0));
685 while ($pagenb < $pageposafter) {
686 $pdf->setPage($pagenb);
688 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
690 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
692 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
694 $pdf->setPage($pagenb);
695 $pdf->setPageOrientation(
'', 1, 0);
697 $this->
_pagehead($pdf, $object, 0, $outputlangs);
699 if (!empty($tplidx)) {
700 $pdf->useTemplate($tplidx);
703 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
705 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
707 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
709 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
712 if (!empty($tplidx)) {
713 $pdf->useTemplate($tplidx);
717 $this->
_pagehead($pdf, $object, 0, $outputlangs);
724 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
725 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
727 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
728 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
732 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
735 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
751 $this->
_pagefoot($pdf, $object, $outputlangs);
752 if (method_exists($pdf,
'AliasNbPages')) {
753 $pdf->AliasNbPages();
758 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
760 $already_merged = array();
761 foreach ($object->lines as $line) {
762 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
767 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
769 $filetomerge->fetch_by_product($line->fk_product);
772 $already_merged[] = $line->fk_product;
774 $product =
new Product($this->db);
775 $product->fetch($line->fk_product);
777 if ($product->entity != $conf->entity) {
778 $entity_product_file = $product->entity;
780 $entity_product_file = $conf->entity;
784 if (count($filetomerge->lines) > 0) {
785 foreach ($filetomerge->lines as $linefile) {
786 if (!empty($linefile->id) && !empty($linefile->file_name)) {
788 if (isModEnabled(
"product")) {
789 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
790 } elseif (isModEnabled(
"service")) {
791 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
794 if (isModEnabled(
"product")) {
795 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
796 } elseif (isModEnabled(
"service")) {
797 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
801 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
803 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
804 if (file_exists($infile) && is_readable($infile)) {
805 $pagecount = $pdf->setSourceFile($infile);
806 for ($i = 1; $i <= $pagecount; $i++) {
807 $tplIdx = $pdf->importPage($i);
808 if ($tplIdx !==
false) {
809 $s = $pdf->getTemplatesize($tplIdx);
810 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
811 $pdf->useTemplate($tplIdx);
813 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
826 $pdf->Output($file,
'F');
829 $hookmanager->initHooks(array(
'pdfgeneration'));
830 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
832 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
834 $this->error = $hookmanager->error;
835 $this->errors = $hookmanager->errors;
840 $this->result = array(
'fullpath'=>$file);
844 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
848 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
884 global $conf, $mysoc;
887 $pdf->SetFont(
'',
'', $default_font_size - 1);
889 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
892 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
893 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
894 $pdf->SetXY($this->marge_gauche, $posy);
895 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
897 $posy = $pdf->GetY() + 4;
902 $displaydate =
"daytext";
904 $displaydate =
"day";
908 if (!empty($object->delivery_date)) {
909 $outputlangs->load(
"sendings");
910 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
911 $pdf->SetXY($this->marge_gauche, $posy);
912 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
913 $pdf->MultiCell(80, 4, $titre, 0,
'L');
914 $pdf->SetFont(
'',
'', $default_font_size -$diffsizetitle);
915 $pdf->SetXY($posxval, $posy);
916 $dlp =
dol_print_date($object->delivery_date, $displaydate,
false, $outputlangs,
true);
917 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
919 $posy = $pdf->GetY() + 1;
920 } elseif ($object->availability_code || $object->availability) {
921 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
922 $pdf->SetXY($this->marge_gauche, $posy);
923 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
924 $pdf->MultiCell(80, 4, $titre, 0,
'L');
925 $pdf->SetTextColor(0, 0, 0);
926 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
927 $pdf->SetXY($posxval, $posy);
928 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
929 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
930 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
932 $posy = $pdf->GetY() + 1;
936 if (!
getDolGlobalString(
'PROPOSAL_PDF_HIDE_DELIVERYMODE') && $object->shipping_method_id > 0) {
937 $outputlangs->load(
"sendings");
939 $shipping_method_id = $object->shipping_method_id;
940 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
941 $shipping_method_id = $this->emetteur->shipping_method_id;
943 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
944 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
946 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
947 $pdf->SetXY($this->marge_gauche, $posy);
948 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
949 $pdf->MultiCell(43, 4, $titre, 0,
'L');
951 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
952 $pdf->SetXY($posxval, $posy);
953 $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;
954 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
955 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
957 $posy = $pdf->GetY() + 1;
961 if (!
getDolGlobalString(
'PROPOSAL_PDF_HIDE_PAYMENTTERM') && $object->cond_reglement_code) {
962 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
963 $pdf->SetXY($this->marge_gauche, $posy);
964 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
965 $pdf->MultiCell(43, 4, $titre, 0,
'L');
967 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
968 $pdf->SetXY($posxval, $posy);
969 $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);
970 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
971 if ($object->deposit_percent > 0) {
972 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
974 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
976 $posy = $pdf->GetY() + 3;
981 if ($object->mode_reglement_code
982 && $object->mode_reglement_code !=
'CHQ'
983 && $object->mode_reglement_code !=
'VIR') {
984 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
985 $pdf->SetXY($this->marge_gauche, $posy);
986 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
987 $pdf->MultiCell(80, 5, $titre, 0,
'L');
988 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
989 $pdf->SetXY($posxval, $posy);
990 $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);
991 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
993 $posy = $pdf->GetY() + 2;
997 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1001 $account =
new Account($this->db);
1004 $pdf->SetXY($this->marge_gauche, $posy);
1005 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1006 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1007 $posy = $pdf->GetY() + 1;
1010 $pdf->SetXY($this->marge_gauche, $posy);
1011 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1012 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1013 $posy = $pdf->GetY() + 2;
1016 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1017 $pdf->SetXY($this->marge_gauche, $posy);
1018 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1019 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1020 $posy = $pdf->GetY() + 1;
1023 $pdf->SetXY($this->marge_gauche, $posy);
1024 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1025 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1026 $posy = $pdf->GetY() + 2;
1033 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1034 if (!empty($object->fk_account) || !empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1035 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1036 if (!empty($object->fk_bank)) {
1037 $bankid = $object->fk_bank;
1039 $account =
new Account($this->db);
1040 $account->fetch($bankid);
1042 $curx = $this->marge_gauche;
1045 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1068 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1071 global $conf, $mysoc;
1076 $pdf->SetFont(
'',
'', $default_font_size - 1);
1081 if ($this->page_largeur < 210) {
1084 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1090 $pdf->SetFillColor(255, 255, 255);
1091 $pdf->SetXY($col1x, $tab2_top);
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1094 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1095 $pdf->SetXY($col2x, $tab2_top);
1096 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1099 $pdf->SetFillColor(248, 248, 248);
1101 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1103 $this->atleastoneratenotnull = 0;
1105 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1106 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1112 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1113 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1117 foreach ($localtax_rate as $tvakey => $tvaval) {
1122 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1125 if (preg_match(
'/\*/', $tvakey)) {
1126 $tvakey = str_replace(
'*',
'', $tvakey);
1127 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1129 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1130 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1131 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1133 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1135 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1136 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1144 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1145 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1149 foreach ($localtax_rate as $tvakey => $tvaval) {
1154 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1157 if (preg_match(
'/\*/', $tvakey)) {
1158 $tvakey = str_replace(
'*',
'', $tvakey);
1159 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1161 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1162 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1163 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1165 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1167 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1168 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1175 foreach ($this->tva_array as $tvakey => $tvaval) {
1177 $this->atleastoneratenotnull++;
1180 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1183 if (preg_match(
'/\*/', $tvakey)) {
1184 $tvakey = str_replace(
'*',
'', $tvakey);
1185 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1187 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1190 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1192 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1194 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1196 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1198 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1199 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1206 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1207 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1211 foreach ($localtax_rate as $tvakey => $tvaval) {
1216 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1219 if (preg_match(
'/\*/', $tvakey)) {
1220 $tvakey = str_replace(
'*',
'', $tvakey);
1221 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1223 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1225 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1226 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1228 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1230 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1231 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1239 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1240 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1244 foreach ($localtax_rate as $tvakey => $tvaval) {
1250 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1253 if (preg_match(
'/\*/', $tvakey)) {
1254 $tvakey = str_replace(
'*',
'', $tvakey);
1255 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1257 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1259 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1260 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1262 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1264 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1265 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1273 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1274 $pdf->SetTextColor(0, 0, 60);
1275 $pdf->SetFillColor(224, 224, 224);
1276 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1278 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1279 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1283 $pdf->SetTextColor(0, 0, 0);
1291 if ($deja_regle > 0) {
1294 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1295 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1297 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1298 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1316 $pdf->SetTextColor(0, 0, 60);
1317 $pdf->SetFillColor(224, 224, 224);
1318 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1319 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1321 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1322 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1324 $pdf->SetFont(
'',
'', $default_font_size - 1);
1325 $pdf->SetTextColor(0, 0, 0);
1329 return ($tab2_top + ($tab2_hl * $index));
1346 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1356 $currency = !empty($currency) ? $currency : $conf->currency;
1360 $pdf->SetTextColor(0, 0, 0);
1361 $pdf->SetFont(
'',
'', $default_font_size - 2);
1363 if (empty($hidetop)) {
1364 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1365 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1366 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1370 $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')));
1374 $pdf->SetDrawColor(128, 128, 128);
1375 $pdf->SetFont(
'',
'', $default_font_size - 1);
1378 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1380 if (empty($hidetop)) {
1381 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1383 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1384 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1388 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1389 if (empty($hidetop)) {
1396 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1397 if (empty($hidetop)) {
1399 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1400 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1404 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1405 if (empty($hidetop)) {
1406 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1407 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1410 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1411 if (empty($hidetop)) {
1412 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1413 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1417 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1418 if (empty($hidetop)) {
1419 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1421 $this->posxdiscount - $this->posxunit - 1,
1423 $outputlangs->transnoentities(
"Unit"),
1430 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1431 if (empty($hidetop)) {
1432 if ($this->atleastonediscount) {
1433 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1434 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1437 if ($this->atleastonediscount) {
1438 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1440 if (empty($hidetop)) {
1441 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1442 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1457 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1459 global $conf, $langs;
1461 $ltrdirection =
'L';
1462 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1463 $ltrdirection =
'R';
1467 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1473 $pdf->SetTextColor(0, 0, 60);
1474 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1478 $posy = $this->marge_haute;
1479 $posx = $this->page_largeur - $this->marge_droite - $w;
1481 $pdf->SetXY($this->marge_gauche, $posy);
1485 if ($this->emetteur->logo) {
1486 $logodir = $conf->mycompany->dir_output;
1487 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1488 $logodir = $conf->mycompany->multidir_output[$object->entity];
1491 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1493 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1495 if (is_readable($logo)) {
1497 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1499 $pdf->SetTextColor(200, 0, 0);
1500 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1501 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1502 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1505 $text = $this->emetteur->name;
1506 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1510 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1511 $pdf->SetXY($posx, $posy);
1512 $pdf->SetTextColor(0, 0, 60);
1513 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1514 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1515 if ($object->statut == $object::STATUS_DRAFT) {
1516 $pdf->SetTextColor(128, 0, 0);
1517 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1519 $pdf->MultiCell(100, 4, $title,
'',
'R');
1521 $pdf->SetFont(
'',
'B', $default_font_size);
1531 $pdf->SetFont(
'',
'', $default_font_size - 2);
1533 if ($object->ref_client) {
1535 $pdf->SetXY($posx, $posy);
1536 $pdf->SetTextColor(0, 0, 60);
1537 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1541 $object->fetch_projet();
1542 if (!empty($object->project->ref)) {
1544 $pdf->SetXY($posx, $posy);
1545 $pdf->SetTextColor(0, 0, 60);
1546 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1551 $object->fetch_projet();
1552 if (!empty($object->project->ref)) {
1553 $outputlangs->load(
"projects");
1555 $pdf->SetXY($posx, $posy);
1556 $pdf->SetTextColor(0, 0, 60);
1557 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1562 $displaydate =
"daytext";
1564 $displaydate =
"day";
1568 $posy = $pdf->getY();
1569 $pdf->SetXY($posx, $posy);
1570 $pdf->SetTextColor(0, 0, 60);
1571 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date($object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1574 $pdf->SetXY($posx, $posy);
1575 $pdf->SetTextColor(0, 0, 60);
1576 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date($object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1578 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
1580 $pdf->SetXY($posx, $posy);
1581 $pdf->SetTextColor(0, 0, 60);
1582 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1587 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1588 if (count($arrayidcontact) > 0) {
1589 $usertmp =
new User($this->db);
1590 $usertmp->fetch($arrayidcontact[0]);
1592 $pdf->SetXY($posx, $posy);
1593 $pdf->SetTextColor(0, 0, 60);
1594 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1602 $current_y = $pdf->getY();
1603 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1604 if ($current_y < $pdf->getY()) {
1605 $top_shift = $pdf->getY() - $current_y;
1610 $carac_emetteur =
'';
1612 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1613 if (count($arrayidcontact) > 0) {
1614 $object->fetch_user($arrayidcontact[0]);
1615 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1616 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1618 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1620 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1622 $carac_emetteur .=
"\n";
1625 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1628 $posy = 42 + $top_shift;
1629 $posx = $this->marge_gauche;
1631 $posx = $this->page_largeur - $this->marge_droite - 80;
1637 $pdf->SetTextColor(0, 0, 0);
1638 $pdf->SetFont(
'',
'', $default_font_size - 2);
1639 $pdf->SetXY($posx, $posy - 5);
1640 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1641 $pdf->SetXY($posx, $posy);
1642 $pdf->SetFillColor(230, 230, 230);
1643 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1644 $pdf->SetTextColor(0, 0, 60);
1649 $pdf->SetXY($posx + 2, $posy + 3);
1650 $pdf->SetFont(
'',
'B', $default_font_size);
1651 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1652 $posy = $pdf->getY();
1656 $pdf->SetXY($posx + 2, $posy);
1657 $pdf->SetFont(
'',
'', $default_font_size - 1);
1658 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1662 $usecontact =
false;
1663 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1664 if (count($arrayidcontact) > 0) {
1666 $result = $object->fetch_contact($arrayidcontact[0]);
1670 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1671 $thirdparty = $object->contact;
1673 $thirdparty = $object->thirdparty;
1679 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1683 if ($this->page_largeur < 210) {
1686 $posy = 42 + $top_shift;
1687 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1689 $posx = $this->marge_gauche;
1694 $pdf->SetTextColor(0, 0, 0);
1695 $pdf->SetFont(
'',
'', $default_font_size - 2);
1696 $pdf->SetXY($posx + 2, $posy - 5);
1697 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1698 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1702 $pdf->SetXY($posx + 2, $posy + 3);
1703 $pdf->SetFont(
'',
'B', $default_font_size);
1704 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1706 $posy = $pdf->getY();
1709 $pdf->SetFont(
'',
'', $default_font_size - 1);
1710 $pdf->SetXY($posx + 2, $posy);
1711 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1714 $pdf->SetTextColor(0, 0, 0);