155 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
158 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
160 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
162 if (!is_object($outputlangs)) {
163 $outputlangs = $langs;
167 $outputlangs->charset_output =
'ISO-8859-1';
171 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
178 global $outputlangsbis;
179 $outputlangsbis =
null;
181 $outputlangsbis =
new Translate(
'', $conf);
183 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
186 $nblines = count(
$object->lines);
194 $realpatharray = array();
195 $this->atleastonephoto =
false;
197 $objphoto =
new Product($this->db);
199 for ($i = 0; $i < $nblines; $i++) {
200 if (empty(
$object->lines[$i]->fk_product)) {
204 $objphoto->fetch(
$object->lines[$i]->fk_product);
208 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
209 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
211 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
212 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
217 foreach ($pdir as $midir) {
219 if ($conf->entity != $objphoto->entity) {
220 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
222 $dir = $conf->product->dir_output.
'/'.$midir;
225 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
227 if ($obj[
'photo_vignette']) {
228 $filename = $obj[
'photo_vignette'];
230 $filename = $obj[
'photo'];
233 $filename = $obj[
'photo'];
236 $realpath = $dir.$filename;
238 $this->atleastonephoto =
true;
243 if ($realpath && $arephoto) {
244 $realpatharray[$i] = $realpath;
249 if (count($realpatharray) == 0) {
250 $this->posxpicture = $this->posxtva;
253 if ($conf->propal->multidir_output[$conf->entity]) {
260 $dir = $conf->propal->multidir_output[$conf->entity];
261 $file = $dir.
"/SPECIMEN.pdf";
264 $dir = $conf->propal->multidir_output[
$object->entity].
"/".$objectref;
265 $file = $dir.
"/".$objectref.
".pdf";
268 if (!file_exists($dir)) {
270 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
275 if (file_exists($dir)) {
277 if (!is_object($hookmanager)) {
278 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
281 $hookmanager->initHooks(array(
'pdfgeneration'));
282 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
284 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
287 $nblines = count(
$object->lines);
293 $pdf->SetAutoPageBreak(1, 0);
295 if (class_exists(
'TCPDF')) {
296 $pdf->setPrintHeader(
false);
297 $pdf->setPrintFooter(
false);
302 $logodir = $conf->mycompany->dir_output;
303 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
304 $logodir = $conf->mycompany->multidir_output[
$object->entity];
306 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
307 $tplidx = $pdf->importPage(1);
312 $pdf->SetDrawColor(128, 128, 128);
314 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
315 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
316 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
317 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
318 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
320 $pdf->SetCompression(
false);
324 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
327 for ($i = 0; $i < $nblines; $i++) {
328 if (
$object->lines[$i]->remise_percent) {
329 $this->atleastonediscount++;
336 if (!empty($tplidx)) {
337 $pdf->useTemplate($tplidx);
341 $heightforinfotot = 40;
343 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
344 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
347 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
348 $pdf->SetFont(
'',
'', $default_font_size - 1);
349 $pdf->MultiCell(0, 3,
'');
350 $pdf->SetTextColor(0, 0, 0);
353 $tab_top = 90 + $top_shift;
354 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
359 $height_incoterms = 0;
360 if (isModEnabled(
'incoterm')) {
361 $desc_incoterms =
$object->getIncotermsForPDF();
362 if ($desc_incoterms) {
365 $pdf->SetFont(
'',
'', $default_font_size - 1);
366 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
367 $nexY = max($pdf->GetY(), $nexY);
368 $height_incoterms = $nexY - $tab_top;
371 $pdf->SetDrawColor(192, 192, 192);
372 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
374 $tab_top = $nexY + 6;
375 $height_incoterms += 4;
380 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
383 if (is_object(
$object->thirdparty)) {
384 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
385 $salerepobj =
new User($this->db);
386 $salerepobj->fetch($salereparray[0][
'id']);
387 if (!empty($salerepobj->signature)) {
388 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
394 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
395 if (!empty($extranote)) {
400 $tmpuser =
new User($this->db);
401 $tmpuser->fetch(
$object->user_author_id);
403 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
404 if ($tmpuser->email) {
405 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
407 if ($tmpuser->office_phone) {
408 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
414 $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
416 $pagenb = $pdf->getPage();
420 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
421 $pageposbeforenote = $pagenb;
428 $pdf->startTransaction();
430 $pdf->SetFont(
'',
'', $default_font_size - 1);
431 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
433 $pageposafternote = $pdf->getPage();
434 $posyafter = $pdf->GetY();
436 if ($pageposafternote > $pageposbeforenote) {
437 $pdf->rollbackTransaction(
true);
440 while ($pagenb < $pageposafternote) {
443 if (!empty($tplidx)) {
444 $pdf->useTemplate($tplidx);
450 $pdf->setTopMargin($tab_top_newpage);
452 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
456 $pdf->setPage($pageposbeforenote);
457 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
458 $pdf->SetFont(
'',
'', $default_font_size - 1);
459 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
460 $pageposafternote = $pdf->getPage();
462 $posyafter = $pdf->GetY();
464 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
465 $pdf->AddPage(
'',
'',
true);
468 $pdf->setPage($pageposafternote);
469 $pdf->setTopMargin($tab_top_newpage);
471 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
477 $i = $pageposbeforenote;
478 while ($i < $pageposafternote) {
482 $pdf->SetDrawColor(128, 128, 128);
484 if ($i > $pageposbeforenote) {
485 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
486 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
488 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
489 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
493 $pdf->setPageOrientation(
'', 1, 0);
500 $pdf->setPage($pageposafternote);
501 if (!empty($tplidx)) {
502 $pdf->useTemplate($tplidx);
507 $height_note = $posyafter - $tab_top_newpage;
508 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
511 $pdf->commitTransaction();
512 $posyafter = $pdf->GetY();
513 $height_note = $posyafter - $tab_top;
514 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
517 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
519 $pdf->AddPage(
'',
'',
true);
522 $pdf->setPage($pageposafternote);
523 if (!empty($tplidx)) {
524 $pdf->useTemplate($tplidx);
530 $posyafter = $tab_top_newpage;
533 $tab_height = $tab_height - $height_note;
534 $tab_top = $posyafter + 6;
543 $pdf->startTransaction();
544 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
545 $pdf->rollbackTransaction(
true);
547 $nexY = $tab_top + $this->tabTitleHeight;
550 $pageposbeforeprintlines = $pdf->getPage();
551 $pagenb = $pageposbeforeprintlines;
552 for ($i = 0; $i < $nblines; $i++) {
554 $pdf->SetFont(
'',
'', $default_font_size - 1);
555 $pdf->SetTextColor(0, 0, 0);
558 $imglinesize = array();
559 if (!empty($realpatharray[$i])) {
563 $pdf->setTopMargin($tab_top_newpage);
564 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
565 $pageposbefore = $pdf->getPage();
567 $showpricebeforepagebreak = 1;
569 $posYAfterDescription = 0;
573 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
574 $pdf->AddPage(
'',
'',
true);
575 if (!empty($tplidx)) {
576 $pdf->useTemplate($tplidx);
578 $pdf->setPage($pageposbefore + 1);
580 $curY = $tab_top_newpage;
584 $showpricebeforepagebreak = 1;
586 $showpricebeforepagebreak = 0;
591 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
592 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
594 $posYAfterImage = $curY + $imglinesize[
'height'];
600 $pdf->startTransaction();
603 $pageposafter = $pdf->getPage();
605 if ($pageposafter > $pageposbefore) {
606 $pdf->rollbackTransaction(
true);
608 $pdf->setPageOrientation(
'', 1, $heightforfooter);
612 $pageposafter = $pdf->getPage();
613 $posyafter = $pdf->GetY();
615 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
616 if ($i == ($nblines - 1)) {
617 $pdf->AddPage(
'',
'',
true);
618 if (!empty($tplidx)) {
619 $pdf->useTemplate($tplidx);
621 $pdf->setPage($pageposafter + 1);
627 $showpricebeforepagebreak = 1;
629 $showpricebeforepagebreak = 0;
633 $pdf->commitTransaction();
635 $posYAfterDescription = $pdf->GetY();
638 $nexY = $pdf->GetY();
639 $pageposafter = $pdf->getPage();
641 $pdf->setPage($pageposbefore);
642 $pdf->setTopMargin($this->marge_haute);
643 $pdf->setPageOrientation(
'', 1, 0);
646 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
647 $pdf->setPage($pageposafter);
648 $curY = $tab_top_newpage;
651 $pdf->SetFont(
'',
'', $default_font_size - 1);
662 $nexY = max($pdf->GetY(), $nexY);
669 $nexY = max($pdf->GetY(), $nexY);
677 $nexY = max($pdf->GetY(), $nexY);
685 $nexY = max($pdf->GetY(), $nexY);
692 $nexY = max($pdf->GetY(), $nexY);
699 $nexY = max($pdf->GetY(), $nexY);
706 $nexY = max($pdf->GetY(), $nexY);
710 if (!empty(
$object->lines[$i]->array_options)) {
711 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
715 $nexY = max($pdf->GetY(), $nexY);
726 'outputlangs' => $outputlangs,
727 'hidedetails' => $hidedetails
729 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
733 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
734 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
736 $tvaligne =
$object->lines[$i]->total_tva;
739 $localtax1ligne =
$object->lines[$i]->total_localtax1;
740 $localtax2ligne =
$object->lines[$i]->total_localtax2;
741 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
742 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
743 $localtax1_type =
$object->lines[$i]->localtax1_type;
744 $localtax2_type =
$object->lines[$i]->localtax2_type;
757 $vatrate = (string)
$object->lines[$i]->tva_tx;
760 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
761 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
763 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
764 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
768 if ($localtax1_type && $localtax1ligne != 0) {
769 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
770 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
772 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
775 if ($localtax2_type && $localtax2ligne != 0) {
776 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
777 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
779 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
783 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
788 if (!isset($this->tva[$vatrate])) {
789 $this->tva[$vatrate] = 0;
791 $this->tva[$vatrate] += $tvaligne;
792 $vatcode =
$object->lines[$i]->vat_src_code;
793 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
794 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
796 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
798 if ($posYAfterImage > $posYAfterDescription) {
799 $nexY = max($nexY, $posYAfterImage);
804 $pdf->setPage($pageposafter);
805 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
807 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
808 $pdf->SetLineStyle(array(
'dash' => 0));
814 while ($pagenb < $pageposafter) {
815 $pdf->setPage($pagenb);
816 if ($pagenb == $pageposbeforeprintlines) {
817 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
819 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
823 $pdf->setPage($pagenb);
824 $pdf->setPageOrientation(
'', 1, 0);
828 if (!empty($tplidx)) {
829 $pdf->useTemplate($tplidx);
833 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
834 if ($pagenb == $pageposafter) {
835 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
837 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
842 if (!empty($tplidx)) {
843 $pdf->useTemplate($tplidx);
853 if ($pagenb == $pageposbeforeprintlines) {
854 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
855 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
857 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
858 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
874 if (method_exists($pdf,
'AliasNbPages')) {
875 $pdf->AliasNbPages();
880 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
882 $already_merged = array();
883 foreach (
$object->lines as $line) {
884 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
889 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
891 $filetomerge->fetch_by_product($line->fk_product);
894 $already_merged[] = $line->fk_product;
896 $product =
new Product($this->db);
897 $product->fetch($line->fk_product);
899 if ($product->entity != $conf->entity) {
900 $entity_product_file = $product->entity;
902 $entity_product_file = $conf->entity;
906 if (count($filetomerge->lines) > 0) {
907 foreach ($filetomerge->lines as $linefile) {
908 if (!empty($linefile->id) && !empty($linefile->file_name)) {
910 if (isModEnabled(
"product")) {
911 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
912 } elseif (isModEnabled(
"service")) {
913 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
916 if (isModEnabled(
"product")) {
917 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
918 } elseif (isModEnabled(
"service")) {
919 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
923 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
925 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
926 if (file_exists($infile) && is_readable($infile)) {
927 $pagecount = $pdf->setSourceFile($infile);
928 for ($i = 1; $i <= $pagecount; $i++) {
929 $tplIdx = $pdf->importPage($i);
930 if ($tplIdx !==
false) {
931 $s = $pdf->getTemplatesize($tplIdx);
932 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
933 $pdf->useTemplate($tplIdx);
935 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
948 $pdf->Output($file,
'F');
951 $hookmanager->initHooks(array(
'pdfgeneration'));
952 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
954 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
956 $this->error = $hookmanager->error;
957 $this->errors = $hookmanager->errors;
962 $this->result = array(
'fullpath' => $file);
966 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
970 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
986 global $conf, $mysoc;
989 $pdf->SetFont(
'',
'', $default_font_size - 1);
991 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
994 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
995 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
996 $pdf->SetXY($this->marge_gauche, $posy);
997 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
999 $posy = $pdf->GetY() + 4;
1004 $displaydate =
"daytext";
1006 $displaydate =
"day";
1010 if (!empty(
$object->delivery_date)) {
1011 $outputlangs->load(
"sendings");
1012 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1013 $pdf->SetXY($this->marge_gauche, $posy);
1014 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1015 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1016 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1017 $pdf->SetXY($posxval, $posy);
1019 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1021 $posy = $pdf->GetY() + 1;
1023 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1024 $pdf->SetXY($this->marge_gauche, $posy);
1025 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1026 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1027 $pdf->SetTextColor(0, 0, 0);
1028 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1029 $pdf->SetXY($posxval, $posy);
1030 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
1031 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1032 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1034 $posy = $pdf->GetY() + 1;
1039 $outputlangs->load(
"sendings");
1041 $shipping_method_id =
$object->shipping_method_id;
1042 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1043 $shipping_method_id = $this->emetteur->shipping_method_id;
1045 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1046 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1048 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1049 $pdf->SetXY($this->marge_gauche, $posy);
1050 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1051 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1053 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1054 $pdf->SetXY($posxval, $posy);
1055 $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;
1056 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1057 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1059 $posy = $pdf->GetY() + 1;
1064 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1065 $pdf->SetXY($this->marge_gauche, $posy);
1066 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1067 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1069 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1070 $pdf->SetXY($posxval, $posy);
1071 $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);
1072 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1073 if (
$object->deposit_percent > 0) {
1074 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1076 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1078 $posy = $pdf->GetY() + 3;
1083 if (
$object->mode_reglement_code
1084 &&
$object->mode_reglement_code !=
'CHQ'
1085 &&
$object->mode_reglement_code !=
'VIR') {
1086 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1087 $pdf->SetXY($this->marge_gauche, $posy);
1088 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1089 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1090 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1091 $pdf->SetXY($posxval, $posy);
1092 $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);
1093 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1095 $posy = $pdf->GetY() + 2;
1099 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1103 $account =
new Account($this->db);
1106 $pdf->SetXY($this->marge_gauche, $posy);
1107 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1108 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1109 $posy = $pdf->GetY() + 1;
1112 $pdf->SetXY($this->marge_gauche, $posy);
1113 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1114 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1115 $posy = $pdf->GetY() + 2;
1119 $pdf->SetXY($this->marge_gauche, $posy);
1120 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1121 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1122 $posy = $pdf->GetY() + 1;
1125 $pdf->SetXY($this->marge_gauche, $posy);
1126 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1127 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1128 $posy = $pdf->GetY() + 2;
1135 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1141 $account =
new Account($this->db);
1142 $account->fetch($bankid);
1144 $curx = $this->marge_gauche;
1147 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1171 global $conf, $mysoc, $hookmanager;
1176 $outputlangsbis =
new Translate(
'', $conf);
1178 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1179 $default_font_size--;
1184 $pdf->SetFont(
'',
'', $default_font_size - 1);
1189 if ($this->page_largeur < 210) {
1192 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1198 $pdf->SetFillColor(255, 255, 255);
1199 $pdf->SetXY($col1x, $tab2_top);
1200 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1202 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1203 $pdf->SetXY($col2x, $tab2_top);
1204 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1207 $pdf->SetFillColor(248, 248, 248);
1209 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1211 $this->atleastoneratenotnull = 0;
1213 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1214 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1220 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1221 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1225 foreach ($localtax_rate as $tvakey => $tvaval) {
1230 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1233 if (preg_match(
'/\*/', $tvakey)) {
1234 $tvakey = str_replace(
'*',
'', $tvakey);
1235 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1237 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1239 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1240 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1242 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1244 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1245 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1253 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1254 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1258 foreach ($localtax_rate as $tvakey => $tvaval) {
1263 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1266 if (preg_match(
'/\*/', $tvakey)) {
1267 $tvakey = str_replace(
'*',
'', $tvakey);
1268 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1270 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1272 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1273 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1275 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1277 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1278 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1285 foreach ($this->tva as $tvakey => $tvaval) {
1287 $this->atleastoneratenotnull++;
1290 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1293 if (preg_match(
'/\*/', $tvakey)) {
1294 $tvakey = str_replace(
'*',
'', $tvakey);
1295 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1297 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1299 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1300 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1302 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1303 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1310 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1311 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1315 foreach ($localtax_rate as $tvakey => $tvaval) {
1320 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1323 if (preg_match(
'/\*/', $tvakey)) {
1324 $tvakey = str_replace(
'*',
'', $tvakey);
1325 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1327 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1330 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1331 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1333 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1335 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1336 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1344 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1345 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1349 foreach ($localtax_rate as $tvakey => $tvaval) {
1355 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1358 if (preg_match(
'/\*/', $tvakey)) {
1359 $tvakey = str_replace(
'*',
'', $tvakey);
1360 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1362 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1366 $totalvat .= $tvacompl;
1368 $totalvat .=
vatrate(abs($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 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1385 $pdf->SetTextColor(0, 0, 60);
1386 $pdf->SetFillColor(224, 224, 224);
1387 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1389 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1390 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1394 $pdf->SetTextColor(0, 0, 0);
1402 if ($deja_regle > 0) {
1406 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1407 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1409 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1410 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1428 $pdf->SetTextColor(0, 0, 60);
1429 $pdf->SetFillColor(224, 224, 224);
1430 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1431 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1433 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1434 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1436 $pdf->SetFont(
'',
'', $default_font_size - 1);
1437 $pdf->SetTextColor(0, 0, 0);
1440 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1442 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1444 $this->error = $hookmanager->error;
1445 $this->errors = $hookmanager->errors;
1449 return ($tab2_top + ($tab2_hl * $index));
1532 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1534 global $conf, $langs;
1536 $ltrdirection =
'L';
1537 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1538 $ltrdirection =
'R';
1542 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1548 $pdf->SetTextColor(0, 0, 60);
1549 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1553 $posy = $this->marge_haute;
1554 $posx = $this->page_largeur - $this->marge_droite - $w;
1556 $pdf->SetXY($this->marge_gauche, $posy);
1560 if ($this->emetteur->logo) {
1561 $logodir = $conf->mycompany->dir_output;
1562 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1563 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1566 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1568 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1570 if (is_readable($logo)) {
1572 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1574 $pdf->SetTextColor(200, 0, 0);
1575 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1576 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1577 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1580 $text = $this->emetteur->name;
1581 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1585 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1586 $pdf->SetXY($posx, $posy);
1587 $pdf->SetTextColor(0, 0, 60);
1588 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1589 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1590 if (
$object->status == $object::STATUS_DRAFT) {
1591 $pdf->SetTextColor(128, 0, 0);
1592 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1595 $pdf->MultiCell($w, 4, $title,
'',
'R');
1597 $pdf->SetFont(
'',
'B', $default_font_size);
1612 $pdf->SetFont(
'',
'', $default_font_size - 2);
1615 if ($ref_customer) {
1617 $pdf->SetXY($posx, $posy);
1618 $pdf->SetTextColor(0, 0, 60);
1619 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65),
'',
'R');
1624 if (!empty(
$object->project->ref)) {
1626 $pdf->SetXY($posx, $posy);
1627 $pdf->SetTextColor(0, 0, 60);
1628 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1634 if (!empty(
$object->project->ref)) {
1635 $outputlangs->load(
"projects");
1637 $pdf->SetXY($posx, $posy);
1638 $pdf->SetTextColor(0, 0, 60);
1639 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1644 $displaydate =
"daytext";
1646 $displaydate =
"day";
1650 $posy = $pdf->getY();
1651 $pdf->SetXY($posx, $posy);
1652 $pdf->SetTextColor(0, 0, 60);
1653 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1656 $pdf->SetXY($posx, $posy);
1657 $pdf->SetTextColor(0, 0, 60);
1659 $title = $outputlangs->transnoentities(
"DateEndPropal");
1660 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1661 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1663 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1667 $pdf->SetXY($posx, $posy);
1668 $pdf->SetTextColor(0, 0, 60);
1669 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1674 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1675 if (count($arrayidcontact) > 0) {
1676 $usertmp =
new User($this->db);
1677 $usertmp->fetch($arrayidcontact[0]);
1679 $pdf->SetXY($posx, $posy);
1680 $pdf->SetTextColor(0, 0, 60);
1681 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1689 $current_y = $pdf->getY();
1691 if ($current_y < $pdf->getY()) {
1692 $top_shift = $pdf->getY() - $current_y;
1697 $carac_emetteur =
'';
1699 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1700 if (count($arrayidcontact) > 0) {
1701 $object->fetch_user($arrayidcontact[0]);
1702 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1703 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1705 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1709 $carac_emetteur .=
"\n";
1716 $posy += $top_shift;
1717 $posx = $this->marge_gauche;
1719 $posx = $this->page_largeur - $this->marge_droite - 80;
1727 $pdf->SetTextColor(0, 0, 0);
1728 $pdf->SetFont(
'',
'', $default_font_size - 2);
1729 $pdf->SetXY($posx, $posy - 5);
1730 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1731 $pdf->SetXY($posx, $posy);
1732 $pdf->SetFillColor(230, 230, 230);
1733 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1734 $pdf->SetTextColor(0, 0, 60);
1739 $pdf->SetXY($posx + 2, $posy + 3);
1740 $pdf->SetFont(
'',
'B', $default_font_size);
1741 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1742 $posy = $pdf->getY();
1746 $pdf->SetXY($posx + 2, $posy);
1747 $pdf->SetFont(
'',
'', $default_font_size - 1);
1748 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1752 $usecontact =
false;
1753 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1754 if (count($arrayidcontact) > 0) {
1756 $result =
$object->fetch_contact($arrayidcontact[0]);
1760 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1761 $thirdparty =
$object->contact;
1763 $thirdparty =
$object->thirdparty;
1773 if ($this->page_largeur < 210) {
1777 $posy += $top_shift;
1778 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1780 $posx = $this->marge_gauche;
1785 $pdf->SetTextColor(0, 0, 0);
1786 $pdf->SetFont(
'',
'', $default_font_size - 2);
1787 $pdf->SetXY($posx + 2, $posy - 5);
1788 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1789 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1793 $pdf->SetXY($posx + 2, $posy + 3);
1794 $pdf->SetFont(
'',
'B', $default_font_size);
1796 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1798 $posy = $pdf->getY();
1801 $pdf->SetFont(
'',
'', $default_font_size - 1);
1802 $pdf->SetXY($posx + 2, $posy);
1804 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1807 $pdf->SetTextColor(0, 0, 0);