153 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
156 global $user, $langs, $conf, $hookmanager,
$mysoc, $nblines;
158 if (!is_object($outputlangs)) {
159 $outputlangs = $langs;
163 $outputlangs->charset_output =
'ISO-8859-1';
167 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"dict",
"products"));
169 global $outputlangsbis;
170 $outputlangsbis =
null;
172 $outputlangsbis =
new Translate(
'', $conf);
174 $outputlangsbis->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"dict",
"products"));
177 $nblines = count(
$object->lines);
185 $realpatharray = array();
187 for ($i = 0; $i < $nblines; $i++) {
188 if (empty(
$object->lines[$i]->fk_product)) {
192 $objphoto =
new Product($this->db);
193 $objphoto->fetch(
$object->lines[$i]->fk_product);
196 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
197 $dir = $conf->product->dir_output.
'/'.$pdir;
199 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
200 $dir = $conf->product->dir_output.
'/'.$pdir;
204 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
206 if ($obj[
'photo_vignette']) {
207 $filename = $obj[
'photo_vignette'];
209 $filename = $obj[
'photo'];
212 $filename = $obj[
'photo'];
214 $realpath = $dir.$filename;
219 $realpatharray[$i] = $realpath;
223 if (count($realpatharray) == 0) {
224 $this->posxpicture = $this->posxtva;
227 if ($conf->supplier_proposal->dir_output) {
231 $amount_credit_notes_included = 0;
232 $amount_deposits_included = 0;
238 $dir = $conf->supplier_proposal->dir_output;
239 $file = $dir.
"/SPECIMEN.pdf";
243 $dir = $conf->supplier_proposal->dir_output.
'/'.$objectref;
244 $file = $dir.
"/".$objectref.
".pdf";
246 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
250 if (!file_exists($dir)) {
252 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
257 if (file_exists($dir)) {
259 if (!is_object($hookmanager)) {
260 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
263 $hookmanager->initHooks(array(
'pdfgeneration'));
264 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
266 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
268 $nblines = count(
$object->lines);
272 $heightforinfotot = 50;
274 $heightforfooter = $this->marge_basse + 8;
276 $heightforfooter += 6;
278 $pdf->setAutoPageBreak(
true, 0);
280 if (class_exists(
'TCPDF')) {
281 $pdf->setPrintHeader(
false);
282 $pdf->setPrintFooter(
false);
287 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
288 $tplidx = $pdf->importPage(1);
293 $pdf->SetDrawColor(128, 128, 128);
295 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
296 $pdf->SetSubject($outputlangs->transnoentities(
"SupplierProposal"));
297 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
298 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
299 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
301 $pdf->SetCompression(
false);
305 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
308 foreach (
$object->lines as $line) {
309 if ($line->remise_percent) {
310 $this->atleastonediscount =
true;
317 if (!empty($tplidx)) {
318 $pdf->useTemplate($tplidx);
322 $pdf->SetFont(
'',
'', $default_font_size - 1);
323 $pdf->MultiCell(0, 3,
'');
324 $pdf->SetTextColor(0, 0, 0);
326 $tab_top = 90 + $top_shift;
327 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
329 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
333 $desc_incoterms =
$object->getIncotermsForPDF();
334 if ($desc_incoterms) {
337 $pdf->SetFont(
'',
'', $default_font_size - 1);
338 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
339 $nexY = $pdf->GetY();
340 $height_incoterms = $nexY - $tab_top;
343 $pdf->SetDrawColor(192, 192, 192);
344 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
346 $tab_top = $nexY + 6;
351 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
354 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
355 if (!empty($extranote)) {
359 $pagenb = $pdf->getPage();
361 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
362 $pageposbeforenote = $pagenb;
371 $pdf->startTransaction();
373 $pdf->SetFont(
'',
'', $default_font_size - 1);
374 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
376 $pageposafternote = $pdf->getPage();
377 $posyafter = $pdf->GetY();
379 if ($pageposafternote > $pageposbeforenote) {
380 $pdf->rollbackTransaction(
true);
383 while ($pagenb < $pageposafternote) {
386 if (!empty($tplidx)) {
387 $pdf->useTemplate($tplidx);
393 $pdf->setTopMargin($tab_top_newpage);
395 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
399 $pdf->setPage($pageposbeforenote);
400 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
401 $pdf->SetFont(
'',
'', $default_font_size - 1);
402 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
403 $pageposafternote = $pdf->getPage();
405 $posyafter = $pdf->GetY();
407 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
408 $pdf->AddPage(
'',
'',
true);
411 $pdf->setPage($pageposafternote);
412 $pdf->setTopMargin($tab_top_newpage);
414 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
420 $i = $pageposbeforenote;
421 while ($i < $pageposafternote) {
425 $pdf->SetDrawColor(128, 128, 128);
427 if ($i > $pageposbeforenote) {
428 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
429 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
431 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
432 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
436 $pdf->setPageOrientation(
'',
true, 0);
443 $pdf->setPage($pageposafternote);
444 if (!empty($tplidx)) {
445 $pdf->useTemplate($tplidx);
450 $height_note = $posyafter - $tab_top_newpage;
451 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
454 $pdf->commitTransaction();
455 $posyafter = $pdf->GetY();
456 $height_note = $posyafter - $tab_top;
457 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
460 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
462 $pdf->AddPage(
'',
'',
true);
465 $pdf->setPage($pageposafternote);
466 if (!empty($tplidx)) {
467 $pdf->useTemplate($tplidx);
473 $posyafter = $tab_top_newpage;
477 $tab_height -= $height_note;
478 $tab_top = $posyafter + 6;
486 $nexY = $tab_top + $this->tabTitleHeight;
489 $pageposbeforeprintlines = $pdf->getPage();
490 $pagenb = $pageposbeforeprintlines;
491 for ($i = 0; $i < $nblines; $i++) {
493 $pdf->SetFont(
'',
'', $default_font_size - 1);
494 $pdf->SetTextColor(0, 0, 0);
497 $imglinesize = array();
498 if (!empty($realpatharray[$i])) {
502 $pdf->setTopMargin($tab_top_newpage);
503 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
504 $pageposbefore = $pdf->getPage();
507 $showpricebeforepagebreak = 1;
513 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
514 $pdf->AddPage(
'',
'',
true);
515 if (!empty($tplidx)) {
516 $pdf->useTemplate($tplidx);
518 $pdf->setPage($pageposbefore + 1);
520 $curY = $tab_top_newpage;
524 $showpricebeforepagebreak = 1;
526 $showpricebeforepagebreak = 0;
530 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
531 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
533 $posYAfterImage = $curY + $imglinesize[
'height'];
538 $curX = $this->posxdesc - 1;
539 $showpricebeforepagebreak = 1;
542 $pdf->startTransaction();
545 $pageposafter = $pdf->getPage();
546 if ($pageposafter > $pageposbefore) {
547 $pdf->rollbackTransaction(
true);
551 $pageposafter = $pdf->getPage();
552 $posyafter = $pdf->GetY();
553 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
554 if ($i == ($nblines - 1)) {
555 $pdf->AddPage(
'',
'',
true);
556 if (!empty($tplidx)) {
557 $pdf->useTemplate($tplidx);
560 $pdf->setPage($pageposafter + 1);
566 $showpricebeforepagebreak = 1;
568 $showpricebeforepagebreak = 0;
572 $pdf->commitTransaction();
578 $pageposafter = $afterPosData[
'page'];
579 $pdf->setPage($pageposbefore);
580 $pdf->setTopMargin($this->marge_haute);
581 $pdf->setPageOrientation(
'',
true, 0);
584 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
585 $pdf->setPage($pageposafter);
586 $curY = $tab_top_newpage;
589 $pdf->SetFont(
'',
'', $default_font_size - 1);
636 if (!empty(
$object->lines[$i]->array_options)) {
637 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
647 $nexY = $afterPosData[
'y'];
648 $pageposafter = $afterPosData[
'page'];
656 'outputlangs' => $outputlangs,
657 'hidedetails' => $hidedetails
659 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
664 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
666 $tvaligne =
$object->lines[$i]->total_tva;
669 $localtax1ligne =
$object->lines[$i]->total_localtax1;
670 $localtax2ligne =
$object->lines[$i]->total_localtax2;
671 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
672 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
673 $localtax1_type =
$object->lines[$i]->localtax1_type;
674 $localtax2_type =
$object->lines[$i]->localtax2_type;
687 $vatrate = (string)
$object->lines[$i]->tva_tx;
690 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
691 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
693 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
694 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
698 if ($localtax1_type && $localtax1ligne != 0) {
699 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
700 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
702 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
705 if ($localtax2_type && $localtax2ligne != 0) {
706 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
707 $this->localtax2[$localtax2_type][$localtax2_rate] = (float) $localtax2ligne;
709 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
713 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
718 if (!isset($this->tva[$vatrate])) {
719 $this->tva[$vatrate] = 0;
721 $this->tva[$vatrate] += $tvaligne;
722 $vatcode =
$object->lines[$i]->vat_src_code;
723 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
724 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
726 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
730 $pdf->setPage($pageposafter);
731 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
733 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
734 $pdf->SetLineStyle(array(
'dash' => 0));
738 while ($pagenb < $pageposafter) {
739 $pdf->setPage($pagenb);
740 if ($pagenb == $pageposbeforeprintlines) {
741 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
743 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
747 $pdf->setPage($pagenb);
748 $pdf->setPageOrientation(
'',
true, 0);
752 if (!empty($tplidx)) {
753 $pdf->useTemplate($tplidx);
756 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
757 if ($pagenb == $pageposafter) {
758 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
760 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
765 if (!empty($tplidx)) {
766 $pdf->useTemplate($tplidx);
776 if ($pagenb == $pageposbeforeprintlines) {
777 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
778 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
780 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
781 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
791 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
797 if (method_exists($pdf,
'AliasNbPages')) {
798 $pdf->AliasNbPages();
803 $pdf->Output($file,
'F');
806 $hookmanager->initHooks(array(
'pdfgeneration'));
807 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
809 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
810 $this->warnings = $hookmanager->warnings;
812 $this->error = $hookmanager->error;
813 $this->errors = $hookmanager->errors;
820 $this->result = array(
'fullpath' => $file);
824 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
828 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
939 $pdf->SetFont(
'',
'', $default_font_size - 1);
944 if ($this->page_largeur < 210) {
947 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
953 $pdf->SetFillColor(255, 255, 255);
954 $pdf->SetXY($col1x, $tab2_top);
955 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
958 $pdf->SetXY($col2x, $tab2_top);
959 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R',
true);
962 $pdf->SetFillColor(248, 248, 248);
964 $this->atleastoneratenotnull = 0;
965 foreach ($this->tva as $tvakey => $tvaval) {
967 $this->atleastoneratenotnull++;
970 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
974 if (preg_match(
'/\*/', $tvakey)) {
975 $tvakey = str_replace(
'*',
'', $tvakey);
976 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
979 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
980 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
981 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
983 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
984 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
987 if (!$this->atleastoneratenotnull) {
989 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
990 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code), 0,
'L',
true);
992 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
993 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R',
true);
998 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
999 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code), 0,
'L',
true);
1000 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1001 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R',
true);
1007 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1008 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code), 0,
'L',
true);
1009 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1010 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R',
true);
1016 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1017 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1021 foreach ($localtax_rate as $tvakey => $tvaval) {
1026 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1029 if (preg_match(
'/\*/', $tvakey)) {
1030 $tvakey = str_replace(
'*',
'', $tvakey);
1031 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1033 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1034 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1035 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1037 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1038 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
1046 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1047 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1051 foreach ($localtax_rate as $tvakey => $tvaval) {
1056 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1059 if (preg_match(
'/\*/', $tvakey)) {
1060 $tvakey = str_replace(
'*',
'', $tvakey);
1061 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1063 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1064 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1065 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1067 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1068 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
1076 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1077 $pdf->SetTextColor(0, 0, 60);
1078 $pdf->SetFillColor(224, 224, 224);
1079 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1082 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1083 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R',
true);
1084 $pdf->SetFont(
'',
'', $default_font_size - 1);
1085 $pdf->SetTextColor(0, 0, 0);
1087 $creditnoteamount = 0;
1088 $depositsamount = 0;
1092 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1097 if ($deja_regle > 0) {
1101 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
1103 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1104 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R',
false);
1107 $pdf->SetTextColor(0, 0, 60);
1108 $pdf->SetFillColor(224, 224, 224);
1109 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1110 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1112 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1113 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R',
true);
1115 $pdf->SetFont(
'',
'', $default_font_size - 1);
1116 $pdf->SetTextColor(0, 0, 0);
1120 return ($tab2_top + ($tab2_hl * $index));
1190 global $langs, $conf,
$mysoc;
1192 $ltrdirection =
'L';
1193 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1194 $ltrdirection =
'R';
1198 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"sendings"));
1212 $pdf->SetTextColor(0, 0, 60);
1213 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1215 $posx = $this->page_largeur - $this->marge_droite - 100;
1216 $posy = $this->marge_haute;
1218 $pdf->SetXY($this->marge_gauche, $posy);
1222 if ($this->emetteur->logo) {
1223 $logodir = $conf->mycompany->dir_output;
1224 if (!empty($conf->mycompany->multidir_output[
$object->entity ?? $conf->entity])) {
1225 $logodir = $conf->mycompany->multidir_output[
$object->entity ?? $conf->entity];
1228 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1230 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1232 if (is_readable($logo)) {
1234 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1236 $pdf->SetTextColor(200, 0, 0);
1237 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1238 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1239 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1242 $text = $this->emetteur->name;
1243 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1247 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1248 $pdf->SetXY($posx, $posy);
1249 $pdf->SetTextColor(0, 0, 60);
1250 $title = $outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1251 $pdf->MultiCell(100, 3, $title,
'',
'R');
1256 $pdf->SetFont(
'',
'B', $default_font_size);
1257 $pdf->SetXY($posx, $posy);
1258 $pdf->SetTextColor(0, 0, 60);
1259 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1263 $pdf->SetFont(
'',
'', $default_font_size - 1);
1267 if (!empty(
$object->project->ref)) {
1269 $pdf->SetXY($posx, $posy);
1270 $pdf->SetTextColor(0, 0, 60);
1271 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1277 if (!empty(
$object->project->ref)) {
1278 $outputlangs->load(
"projects");
1280 $pdf->SetXY($posx, $posy);
1281 $langs->load(
"projects");
1282 $pdf->SetTextColor(0, 0, 60);
1283 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1289 $pdf->SetXY($posx, $posy);
1290 $pdf->SetTextColor(0, 0, 60);
1291 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1294 $pdf->SetXY($posx, $posy);
1295 $pdf->SetTextColor(255, 0, 0);
1296 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Draft"),
'',
'R');
1299 $pdf->SetTextColor(0, 0, 60);
1300 $usehourmin =
'day';
1302 $usehourmin =
'dayhour';
1304 if (!empty(
$object->delivery_date)) {
1306 $pdf->SetXY($posx - 90, $posy);
1307 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1310 if (
$object->thirdparty->code_fournisseur) {
1312 $pdf->SetXY($posx, $posy);
1313 $pdf->SetTextColor(0, 0, 60);
1314 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1319 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1321 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1322 $usertmp =
new User($this->db);
1323 $usertmp->fetch($arrayidcontact[0]);
1325 $pdf->SetXY($posx, $posy);
1326 $pdf->SetTextColor(0, 0, 60);
1327 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1332 $pdf->SetTextColor(0, 0, 60);
1336 $current_y = $pdf->getY();
1338 if ($current_y < $pdf->getY()) {
1339 $top_shift = $pdf->getY() - $current_y;
1344 $carac_emetteur =
'';
1346 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1347 if (count($arrayidcontact) > 0) {
1348 $object->fetch_user($arrayidcontact[0]);
1349 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1350 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1352 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1356 $carac_emetteur .=
"\n";
1362 $posy = 42 + $top_shift;
1363 $posx = $this->marge_gauche;
1365 $posx = $this->page_largeur - $this->marge_droite - 80;
1370 $pdf->SetTextColor(0, 0, 0);
1371 $pdf->SetFont(
'',
'', $default_font_size - 2);
1372 $pdf->SetXY($posx, $posy - 5);
1373 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1374 $pdf->SetXY($posx, $posy);
1375 $pdf->SetFillColor(230, 230, 230);
1376 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1377 $pdf->SetTextColor(0, 0, 60);
1380 $pdf->SetXY($posx + 2, $posy + 3);
1381 $pdf->SetFont(
'',
'B', $default_font_size);
1382 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1383 $posy = $pdf->getY();
1386 $pdf->SetXY($posx + 2, $posy);
1387 $pdf->SetFont(
'',
'', $default_font_size - 1);
1388 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1393 $usecontact =
false;
1395 $arrayidcontact =
$object->getIdContact(
'external',
'SERVICE');
1397 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'SERVICE'),
$object->getIdContact(
'external',
'BILLING'));
1399 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1401 $result =
$object->fetch_contact($arrayidcontact[0]);
1405 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1406 $thirdparty =
$object->contact;
1408 $thirdparty =
$object->thirdparty;
1417 if ($this->page_largeur < 210) {
1420 $posy = 42 + $top_shift;
1421 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1423 $posx = $this->marge_gauche;
1427 $pdf->SetTextColor(0, 0, 0);
1428 $pdf->SetFont(
'',
'', $default_font_size - 2);
1429 $pdf->SetXY($posx + 2, $posy - 5);
1430 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1431 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1434 $pdf->SetXY($posx + 2, $posy + 3);
1435 $pdf->SetFont(
'',
'B', $default_font_size);
1437 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1439 $posy = $pdf->getY();
1442 $pdf->SetFont(
'',
'', $default_font_size - 1);
1443 $pdf->SetXY($posx + 2, $posy);
1445 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);