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;
577 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
578 $pdf->AddPage(
'',
'',
true);
579 if (!empty($tplidx)) {
580 $pdf->useTemplate($tplidx);
582 $pdf->setPage($pageposbefore + 1);
584 $curY = $tab_top_newpage;
588 $showpricebeforepagebreak = 1;
590 $showpricebeforepagebreak = 0;
595 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
596 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
598 $posYAfterImage = $curY + $imglinesize[
'height'];
604 $pdf->startTransaction();
607 $pageposafter = $pdf->getPage();
609 if ($pageposafter > $pageposbefore) {
610 $pdf->rollbackTransaction(
true);
612 $pdf->setPageOrientation(
'', 1, $heightforfooter);
616 $pageposafter = $pdf->getPage();
617 $posyafter = $pdf->GetY();
619 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
620 if ($i == ($nblines - 1)) {
621 $pdf->AddPage(
'',
'',
true);
622 if (!empty($tplidx)) {
623 $pdf->useTemplate($tplidx);
625 $pdf->setPage($pageposafter + 1);
631 $showpricebeforepagebreak = 1;
633 $showpricebeforepagebreak = 0;
637 $pdf->commitTransaction();
639 $posYAfterDescription = $pdf->GetY();
642 $nexY = $pdf->GetY();
643 $pageposafter = $pdf->getPage();
645 $pdf->setPage($pageposbefore);
646 $pdf->setTopMargin($this->marge_haute);
647 $pdf->setPageOrientation(
'', 1, 0);
650 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
651 $pdf->setPage($pageposafter);
652 $curY = $tab_top_newpage;
655 $pdf->SetFont(
'',
'', $default_font_size - 1);
661 $nexY = max($pdf->GetY(), $nexY);
668 $nexY = max($pdf->GetY(), $nexY);
676 $nexY = max($pdf->GetY(), $nexY);
684 $nexY = max($pdf->GetY(), $nexY);
691 $nexY = max($pdf->GetY(), $nexY);
698 $nexY = max($pdf->GetY(), $nexY);
705 $nexY = max($pdf->GetY(), $nexY);
709 if (!empty(
$object->lines[$i]->array_options)) {
710 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
714 $nexY = max($pdf->GetY(), $nexY);
725 'outputlangs' => $outputlangs,
726 'hidedetails' => $hidedetails
728 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
732 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
733 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
735 $tvaligne =
$object->lines[$i]->total_tva;
738 $localtax1ligne =
$object->lines[$i]->total_localtax1;
739 $localtax2ligne =
$object->lines[$i]->total_localtax2;
740 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
741 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
742 $localtax1_type =
$object->lines[$i]->localtax1_type;
743 $localtax2_type =
$object->lines[$i]->localtax2_type;
756 $vatrate = (string)
$object->lines[$i]->tva_tx;
759 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
760 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
762 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
763 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
767 if ($localtax1_type && $localtax1ligne != 0) {
768 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
769 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
771 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
774 if ($localtax2_type && $localtax2ligne != 0) {
775 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
776 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
778 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
782 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
787 if (!isset($this->tva[$vatrate])) {
788 $this->tva[$vatrate] = 0;
790 $this->tva[$vatrate] += $tvaligne;
791 $vatcode =
$object->lines[$i]->vat_src_code;
792 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
793 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
795 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
797 if ($posYAfterImage > $posYAfterDescription) {
798 $nexY = max($nexY, $posYAfterImage);
803 $pdf->setPage($pageposafter);
804 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
806 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
807 $pdf->SetLineStyle(array(
'dash' => 0));
813 while ($pagenb < $pageposafter) {
814 $pdf->setPage($pagenb);
815 if ($pagenb == $pageposbeforeprintlines) {
816 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
818 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
822 $pdf->setPage($pagenb);
823 $pdf->setPageOrientation(
'', 1, 0);
827 if (!empty($tplidx)) {
828 $pdf->useTemplate($tplidx);
832 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
833 if ($pagenb == $pageposafter) {
834 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
836 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
841 if (!empty($tplidx)) {
842 $pdf->useTemplate($tplidx);
852 if ($pagenb == $pageposbeforeprintlines) {
853 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
854 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
856 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
857 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
873 if (method_exists($pdf,
'AliasNbPages')) {
874 $pdf->AliasNbPages();
879 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
881 $already_merged = array();
882 foreach (
$object->lines as $line) {
883 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
888 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
890 $filetomerge->fetch_by_product($line->fk_product);
893 $already_merged[] = $line->fk_product;
895 $product =
new Product($this->db);
896 $product->fetch($line->fk_product);
898 if ($product->entity != $conf->entity) {
899 $entity_product_file = $product->entity;
901 $entity_product_file = $conf->entity;
905 if (count($filetomerge->lines) > 0) {
906 foreach ($filetomerge->lines as $linefile) {
907 if (!empty($linefile->id) && !empty($linefile->file_name)) {
909 if (isModEnabled(
"product")) {
910 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
911 } elseif (isModEnabled(
"service")) {
912 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
915 if (isModEnabled(
"product")) {
916 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
917 } elseif (isModEnabled(
"service")) {
918 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
922 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
924 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
925 if (file_exists($infile) && is_readable($infile)) {
926 $pagecount = $pdf->setSourceFile($infile);
927 for ($i = 1; $i <= $pagecount; $i++) {
928 $tplIdx = $pdf->importPage($i);
929 if ($tplIdx !==
false) {
930 $s = $pdf->getTemplatesize($tplIdx);
931 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
932 $pdf->useTemplate($tplIdx);
934 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
947 $pdf->Output($file,
'F');
950 $hookmanager->initHooks(array(
'pdfgeneration'));
951 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
953 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
955 $this->error = $hookmanager->error;
956 $this->errors = $hookmanager->errors;
961 $this->result = array(
'fullpath' => $file);
965 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
969 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
985 global $conf, $mysoc;
988 $pdf->SetFont(
'',
'', $default_font_size - 1);
990 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
993 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
994 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
995 $pdf->SetXY($this->marge_gauche, $posy);
996 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
998 $posy = $pdf->GetY() + 4;
1003 $displaydate =
"daytext";
1005 $displaydate =
"day";
1009 if (!empty(
$object->delivery_date)) {
1010 $outputlangs->load(
"sendings");
1011 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1012 $pdf->SetXY($this->marge_gauche, $posy);
1013 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
1014 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1015 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1016 $pdf->SetXY($posxval, $posy);
1018 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
1020 $posy = $pdf->GetY() + 1;
1022 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1023 $pdf->SetXY($this->marge_gauche, $posy);
1024 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
1025 $pdf->MultiCell(80, 4, $titre, 0,
'L');
1026 $pdf->SetTextColor(0, 0, 0);
1027 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1028 $pdf->SetXY($posxval, $posy);
1029 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
1030 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
1031 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
1033 $posy = $pdf->GetY() + 1;
1038 $outputlangs->load(
"sendings");
1040 $shipping_method_id =
$object->shipping_method_id;
1041 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
1042 $shipping_method_id = $this->emetteur->shipping_method_id;
1044 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1045 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
1047 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1048 $pdf->SetXY($this->marge_gauche, $posy);
1049 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
1050 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1052 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1053 $pdf->SetXY($posxval, $posy);
1054 $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;
1055 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1056 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1058 $posy = $pdf->GetY() + 1;
1063 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1064 $pdf->SetXY($this->marge_gauche, $posy);
1065 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1066 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1068 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1069 $pdf->SetXY($posxval, $posy);
1070 $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);
1071 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1072 if (
$object->deposit_percent > 0) {
1073 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1075 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1077 $posy = $pdf->GetY() + 3;
1082 if (
$object->mode_reglement_code
1083 &&
$object->mode_reglement_code !=
'CHQ'
1084 &&
$object->mode_reglement_code !=
'VIR') {
1085 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1086 $pdf->SetXY($this->marge_gauche, $posy);
1087 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1088 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1089 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1090 $pdf->SetXY($posxval, $posy);
1091 $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);
1092 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1094 $posy = $pdf->GetY() + 2;
1098 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1102 $account =
new Account($this->db);
1105 $pdf->SetXY($this->marge_gauche, $posy);
1106 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1107 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1108 $posy = $pdf->GetY() + 1;
1111 $pdf->SetXY($this->marge_gauche, $posy);
1112 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1113 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1114 $posy = $pdf->GetY() + 2;
1118 $pdf->SetXY($this->marge_gauche, $posy);
1119 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1120 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1121 $posy = $pdf->GetY() + 1;
1124 $pdf->SetXY($this->marge_gauche, $posy);
1125 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1126 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1127 $posy = $pdf->GetY() + 2;
1134 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1136 $bankid = (
$object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1140 $account =
new Account($this->db);
1141 $account->fetch($bankid);
1143 $curx = $this->marge_gauche;
1146 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1170 global $conf, $mysoc, $hookmanager;
1175 $outputlangsbis =
new Translate(
'', $conf);
1177 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1178 $default_font_size--;
1183 $pdf->SetFont(
'',
'', $default_font_size - 1);
1188 if ($this->page_largeur < 210) {
1191 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1197 $pdf->SetFillColor(255, 255, 255);
1198 $pdf->SetXY($col1x, $tab2_top);
1199 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1201 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1202 $pdf->SetXY($col2x, $tab2_top);
1203 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1206 $pdf->SetFillColor(248, 248, 248);
1208 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1210 $this->atleastoneratenotnull = 0;
1212 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1213 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1219 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1220 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1224 foreach ($localtax_rate as $tvakey => $tvaval) {
1229 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1232 if (preg_match(
'/\*/', $tvakey)) {
1233 $tvakey = str_replace(
'*',
'', $tvakey);
1234 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1236 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1238 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1239 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1241 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1243 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1244 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1252 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1253 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1257 foreach ($localtax_rate as $tvakey => $tvaval) {
1262 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1265 if (preg_match(
'/\*/', $tvakey)) {
1266 $tvakey = str_replace(
'*',
'', $tvakey);
1267 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1269 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1271 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1272 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1274 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1276 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1277 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1284 foreach ($this->tva as $tvakey => $tvaval) {
1286 $this->atleastoneratenotnull++;
1289 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1292 if (preg_match(
'/\*/', $tvakey)) {
1293 $tvakey = str_replace(
'*',
'', $tvakey);
1294 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1296 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1298 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1299 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1301 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1302 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1309 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1310 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1314 foreach ($localtax_rate as $tvakey => $tvaval) {
1319 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1322 if (preg_match(
'/\*/', $tvakey)) {
1323 $tvakey = str_replace(
'*',
'', $tvakey);
1324 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1326 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1329 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1330 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1332 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1334 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1335 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1343 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1344 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1348 foreach ($localtax_rate as $tvakey => $tvaval) {
1354 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1357 if (preg_match(
'/\*/', $tvakey)) {
1358 $tvakey = str_replace(
'*',
'', $tvakey);
1359 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1361 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1364 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1365 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1367 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1369 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1370 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1378 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1379 $pdf->SetTextColor(0, 0, 60);
1380 $pdf->SetFillColor(224, 224, 224);
1381 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1383 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1384 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1388 $pdf->SetTextColor(0, 0, 0);
1396 if ($deja_regle > 0) {
1400 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1401 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1403 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1404 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1423 $pdf->SetTextColor(0, 0, 60);
1424 $pdf->SetFillColor(224, 224, 224);
1425 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1426 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1428 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1429 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1431 $pdf->SetFont(
'',
'', $default_font_size - 1);
1432 $pdf->SetTextColor(0, 0, 0);
1435 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1437 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1439 $this->error = $hookmanager->error;
1440 $this->errors = $hookmanager->errors;
1444 return ($tab2_top + ($tab2_hl * $index));
1527 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1529 global $conf, $langs;
1531 $ltrdirection =
'L';
1532 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1533 $ltrdirection =
'R';
1537 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1543 $pdf->SetTextColor(0, 0, 60);
1544 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1548 $posy = $this->marge_haute;
1549 $posx = $this->page_largeur - $this->marge_droite - $w;
1551 $pdf->SetXY($this->marge_gauche, $posy);
1555 if ($this->emetteur->logo) {
1556 $logodir = $conf->mycompany->dir_output;
1557 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1558 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1561 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1563 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1565 if (is_readable($logo)) {
1567 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1569 $pdf->SetTextColor(200, 0, 0);
1570 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1571 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1572 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1575 $text = $this->emetteur->name;
1576 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1580 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1581 $pdf->SetXY($posx, $posy);
1582 $pdf->SetTextColor(0, 0, 60);
1583 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1584 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1585 if (
$object->status == $object::STATUS_DRAFT) {
1586 $pdf->SetTextColor(128, 0, 0);
1587 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1590 $pdf->MultiCell($w, 4, $title,
'',
'R');
1592 $pdf->SetFont(
'',
'B', $default_font_size);
1607 $pdf->SetFont(
'',
'', $default_font_size - 2);
1610 if ($ref_customer) {
1612 $pdf->SetXY($posx, $posy);
1613 $pdf->SetTextColor(0, 0, 60);
1614 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65),
'',
'R');
1619 if (!empty(
$object->project->ref)) {
1621 $pdf->SetXY($posx, $posy);
1622 $pdf->SetTextColor(0, 0, 60);
1623 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1629 if (!empty(
$object->project->ref)) {
1630 $outputlangs->load(
"projects");
1632 $pdf->SetXY($posx, $posy);
1633 $pdf->SetTextColor(0, 0, 60);
1634 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1639 $displaydate =
"daytext";
1641 $displaydate =
"day";
1645 $posy = $pdf->getY();
1646 $pdf->SetXY($posx, $posy);
1647 $pdf->SetTextColor(0, 0, 60);
1648 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1651 $pdf->SetXY($posx, $posy);
1652 $pdf->SetTextColor(0, 0, 60);
1654 $title = $outputlangs->transnoentities(
"DateEndPropal");
1655 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1656 $title .=
' - '.$outputlangsbis->transnoentities(
"DateEndPropal");
1658 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1662 $pdf->SetXY($posx, $posy);
1663 $pdf->SetTextColor(0, 0, 60);
1664 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1669 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1670 if (count($arrayidcontact) > 0) {
1671 $usertmp =
new User($this->db);
1672 $usertmp->fetch($arrayidcontact[0]);
1674 $pdf->SetXY($posx, $posy);
1675 $pdf->SetTextColor(0, 0, 60);
1676 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1684 $current_y = $pdf->getY();
1686 if ($current_y < $pdf->getY()) {
1687 $top_shift = $pdf->getY() - $current_y;
1692 $carac_emetteur =
'';
1694 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1695 if (count($arrayidcontact) > 0) {
1696 $object->fetch_user($arrayidcontact[0]);
1697 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1698 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1700 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1704 $carac_emetteur .=
"\n";
1711 $posy += $top_shift;
1712 $posx = $this->marge_gauche;
1714 $posx = $this->page_largeur - $this->marge_droite - 80;
1722 $pdf->SetTextColor(0, 0, 0);
1723 $pdf->SetFont(
'',
'', $default_font_size - 2);
1724 $pdf->SetXY($posx, $posy - 5);
1725 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1726 $pdf->SetXY($posx, $posy);
1727 $pdf->SetFillColor(230, 230, 230);
1728 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1729 $pdf->SetTextColor(0, 0, 60);
1734 $pdf->SetXY($posx + 2, $posy + 3);
1735 $pdf->SetFont(
'',
'B', $default_font_size);
1736 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1737 $posy = $pdf->getY();
1741 $pdf->SetXY($posx + 2, $posy);
1742 $pdf->SetFont(
'',
'', $default_font_size - 1);
1743 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1747 $usecontact =
false;
1748 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1749 if (count($arrayidcontact) > 0) {
1751 $result =
$object->fetch_contact($arrayidcontact[0]);
1755 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1756 $thirdparty =
$object->contact;
1758 $thirdparty =
$object->thirdparty;
1768 if ($this->page_largeur < 210) {
1772 $posy += $top_shift;
1773 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1775 $posx = $this->marge_gauche;
1780 $pdf->SetTextColor(0, 0, 0);
1781 $pdf->SetFont(
'',
'', $default_font_size - 2);
1782 $pdf->SetXY($posx + 2, $posy - 5);
1783 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1784 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1788 $pdf->SetXY($posx + 2, $posy + 3);
1789 $pdf->SetFont(
'',
'B', $default_font_size);
1791 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1793 $posy = $pdf->getY();
1796 $pdf->SetFont(
'',
'', $default_font_size - 1);
1797 $pdf->SetXY($posx + 2, $posy);
1799 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1802 $pdf->SetTextColor(0, 0, 0);