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;
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->getAnonymisableFullName($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 = 80 + $this->marge_haute + $top_shift;
327 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 32 + $this->marge_haute + $top_shift : $this->marge_haute);
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;
488 $pageposbeforeprintlines = $pdf->getPage();
489 $pagenb = $pageposbeforeprintlines;
491 'titleshowuponpdf' => 1,
492 'titleshowtotalexludingvatonpdf' => 1,
496 for ($i = 0; $i < $nblines; $i++) {
497 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
499 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
500 $level =
$object->lines[$i]->qty;
502 if (isset($sub_options[
'titleshowuponpdf'])) {
503 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
504 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
505 unset($pdf_sub_options[
'titleshowuponpdf']);
507 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
508 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
509 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
510 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
513 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
514 unset($pdf_sub_options[
'titleshowuponpdf']);
516 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
517 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
522 $pdf->SetFont(
'',
'', $default_font_size - 1);
523 $pdf->SetTextColor(0, 0, 0);
526 $imglinesize = array();
527 if (!empty($realpatharray[$i])) {
531 $pdf->setTopMargin($tab_top_newpage);
532 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
533 $pageposbefore = $pdf->getPage();
536 $showpricebeforepagebreak = 1;
542 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
543 $pdf->AddPage(
'',
'',
true);
544 if (!empty($tplidx)) {
545 $pdf->useTemplate($tplidx);
547 $pdf->setPage($pageposbefore + 1);
549 $curY = $tab_top_newpage;
553 $showpricebeforepagebreak = 1;
555 $showpricebeforepagebreak = 0;
559 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
560 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
562 $posYAfterImage = $curY + $imglinesize[
'height'];
567 $curX = $this->posxdesc - 1;
568 $showpricebeforepagebreak = 1;
573 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
574 $posYAfterDescription = $pdf->GetY();
576 $pdf->startTransaction();
579 $pageposafter = $pdf->getPage();
580 if ($pageposafter > $pageposbefore) {
581 $pdf->rollbackTransaction(
true);
585 $pageposafter = $pdf->getPage();
586 $posyafter = $pdf->GetY();
587 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
588 if ($i == ($nblines - 1)) {
589 $pdf->AddPage(
'',
'',
true);
590 if (!empty($tplidx)) {
591 $pdf->useTemplate($tplidx);
594 $pdf->setPage($pageposafter + 1);
600 $showpricebeforepagebreak = 1;
602 $showpricebeforepagebreak = 0;
606 $pdf->commitTransaction();
612 $pageposafter = $afterPosData[
'page'];
613 $pdf->setPage($pageposbefore);
614 $pdf->setTopMargin($this->marge_haute);
615 $pdf->setPageOrientation(
'',
true, 0);
618 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
619 $pdf->setPage($pageposafter);
620 $curY = $tab_top_newpage;
623 $pdf->SetFont(
'',
'', $default_font_size - 1);
633 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
656 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
664 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
667 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
669 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
671 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
679 if (!empty(
$object->lines[$i]->array_options)) {
680 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
690 $nexY = $afterPosData[
'y'];
691 $pageposafter = $afterPosData[
'page'];
699 'outputlangs' => $outputlangs,
700 'hidedetails' => $hidedetails
702 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
707 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
709 $tvaligne =
$object->lines[$i]->total_tva;
712 $localtax1ligne =
$object->lines[$i]->total_localtax1;
713 $localtax2ligne =
$object->lines[$i]->total_localtax2;
714 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
715 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
716 $localtax1_type =
$object->lines[$i]->localtax1_type;
717 $localtax2_type =
$object->lines[$i]->localtax2_type;
719 $vatrate = (string)
$object->lines[$i]->tva_tx;
722 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
723 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
725 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
726 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
730 if ($localtax1_type && $localtax1ligne != 0) {
731 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
732 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
734 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
737 if ($localtax2_type && $localtax2ligne != 0) {
738 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
739 $this->localtax2[$localtax2_type][$localtax2_rate] = (float) $localtax2ligne;
741 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
745 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
750 if (!isset($this->tva[$vatrate])) {
751 $this->tva[$vatrate] = 0;
753 $this->tva[$vatrate] += $tvaligne;
754 $vatcode =
$object->lines[$i]->vat_src_code;
755 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
756 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
758 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
762 $pdf->setPage($pageposafter);
763 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
765 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
766 $pdf->SetLineStyle(array(
'dash' => 0));
770 while ($pagenb < $pageposafter) {
771 $pdf->setPage($pagenb);
772 if ($pagenb == $pageposbeforeprintlines) {
773 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
775 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
779 $pdf->setPage($pagenb);
780 $pdf->setPageOrientation(
'',
true, 0);
784 if (!empty($tplidx)) {
785 $pdf->useTemplate($tplidx);
788 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
789 if ($pagenb == $pageposafter) {
790 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
792 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
797 if (!empty($tplidx)) {
798 $pdf->useTemplate($tplidx);
808 if ($pagenb == $pageposbeforeprintlines) {
809 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
810 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
812 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
813 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
823 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
829 if (method_exists($pdf,
'AliasNbPages')) {
830 $pdf->AliasNbPages();
835 $pdf->Output($file,
'F');
838 $hookmanager->initHooks(array(
'pdfgeneration'));
839 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
841 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
842 $this->warnings = $hookmanager->warnings;
844 $this->error = $hookmanager->error;
845 $this->errors = $hookmanager->errors;
852 $this->result = array(
'fullpath' => $file);
856 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
860 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
971 $pdf->SetFont(
'',
'', $default_font_size - 1);
976 if ($this->page_largeur < 210) {
979 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
985 $pdf->SetFillColor(255, 255, 255);
986 $pdf->SetXY($col1x, $tab2_top);
987 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
990 $pdf->SetXY($col2x, $tab2_top);
991 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht), 0,
'R',
true);
994 $pdf->SetFillColor(248, 248, 248);
996 $this->atleastoneratenotnull = 0;
997 foreach ($this->tva as $tvakey => $tvaval) {
999 $this->atleastoneratenotnull++;
1002 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1006 if (preg_match(
'/\*/', $tvakey)) {
1007 $tvakey = str_replace(
'*',
'', $tvakey);
1008 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1011 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
1012 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
1013 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1015 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1016 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
1019 if (!$this->atleastoneratenotnull) {
1021 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1022 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code), 0,
'L',
true);
1024 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1025 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R',
true);
1030 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1031 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code), 0,
'L',
true);
1032 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1033 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R',
true);
1039 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1040 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code), 0,
'L',
true);
1041 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1042 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R',
true);
1048 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1049 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1053 foreach ($localtax_rate as $tvakey => $tvaval) {
1058 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1061 if (preg_match(
'/\*/', $tvakey)) {
1062 $tvakey = str_replace(
'*',
'', $tvakey);
1063 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1065 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1066 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1067 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1069 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1070 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
1078 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1079 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1083 foreach ($localtax_rate as $tvakey => $tvaval) {
1088 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1091 if (preg_match(
'/\*/', $tvakey)) {
1092 $tvakey = str_replace(
'*',
'', $tvakey);
1093 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1095 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1096 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1097 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1099 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1100 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
1108 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1109 $pdf->SetTextColor(0, 0, 60);
1110 $pdf->SetFillColor(224, 224, 224);
1111 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1114 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1115 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R',
true);
1116 $pdf->SetFont(
'',
'', $default_font_size - 1);
1117 $pdf->SetTextColor(0, 0, 0);
1119 $creditnoteamount = 0;
1120 $depositsamount = 0;
1124 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1129 if ($deja_regle > 0) {
1133 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1134 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
1135 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1136 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R',
false);
1139 $pdf->SetTextColor(0, 0, 60);
1140 $pdf->SetFillColor(224, 224, 224);
1141 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1142 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1144 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1145 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R',
true);
1147 $pdf->SetFont(
'',
'', $default_font_size - 1);
1148 $pdf->SetTextColor(0, 0, 0);
1152 return ($tab2_top + ($tab2_hl * $index));
1224 $ltrdirection =
'L';
1225 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1226 $ltrdirection =
'R';
1230 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"sendings"));
1244 $pdf->SetTextColor(0, 0, 60);
1245 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1249 $posx = $this->page_largeur - $this->marge_droite - $w;
1250 $posy = $this->marge_haute;
1252 $pdf->SetXY($this->marge_gauche, $posy);
1255 $logodir =
$conf->mycompany->dir_output;
1256 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
1259 pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, 100, $default_font_size, $ltrdirection);
1261 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1262 $pdf->SetXY($posx, $posy);
1263 $pdf->SetTextColor(0, 0, 60);
1264 $title = $outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1265 $pdf->MultiCell($w, 3, $title,
'',
'R');
1270 $pdf->SetFont(
'',
'B', $default_font_size);
1271 $pdf->SetXY($posx, $posy);
1272 $pdf->SetTextColor(0, 0, 60);
1273 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1277 $pdf->SetFont(
'',
'', $default_font_size - 1);
1281 if (!empty(
$object->project->ref)) {
1283 $pdf->SetXY($posx, $posy);
1284 $pdf->SetTextColor(0, 0, 60);
1285 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
pdf_truncate_text($pdf,
$object->project->title, 50)),
'',
'R');
1291 if (!empty(
$object->project->ref)) {
1292 $outputlangs->load(
"projects");
1294 $pdf->SetXY($posx, $posy);
1295 $langs->load(
"projects");
1296 $pdf->SetTextColor(0, 0, 60);
1297 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1303 $pdf->SetXY($posx, $posy);
1304 $pdf->SetTextColor(0, 0, 60);
1305 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1308 $pdf->SetXY($posx, $posy);
1309 $pdf->SetTextColor(255, 0, 0);
1310 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Draft"),
'',
'R');
1313 $pdf->SetTextColor(0, 0, 60);
1314 $usehourmin =
'day';
1316 $usehourmin =
'dayhour';
1318 if (!empty(
$object->delivery_date)) {
1320 $pdf->SetXY($posx - 90, $posy);
1321 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1324 if (
$object->thirdparty->code_fournisseur) {
1326 $pdf->SetXY($posx, $posy);
1327 $pdf->SetTextColor(0, 0, 60);
1328 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_fournisseur),
'',
'R');
1333 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1335 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1336 $usertmp =
new User($this->db);
1337 $usertmp->fetch($arrayidcontact[0]);
1339 $pdf->SetXY($posx, $posy);
1340 $pdf->SetTextColor(0, 0, 60);
1341 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1346 $pdf->SetTextColor(0, 0, 60);
1350 $current_y = $pdf->getY();
1352 if ($current_y < $pdf->getY()) {
1353 $top_shift = $pdf->getY() - $current_y;
1358 $carac_emetteur =
'';
1360 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1361 if (count($arrayidcontact) > 0) {
1362 $object->fetch_user($arrayidcontact[0]);
1363 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1364 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1366 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1370 $carac_emetteur .=
"\n";
1376 $posy = 32 + $this->marge_haute + $top_shift;
1377 $posx = $this->marge_gauche;
1379 $posx = $this->page_largeur - $this->marge_droite - 80;
1384 $pdf->SetTextColor(0, 0, 0);
1385 $pdf->SetFont(
'',
'', $default_font_size - 2);
1386 $pdf->SetXY($posx, $posy - 5);
1387 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1388 $pdf->SetXY($posx, $posy);
1389 $pdf->SetFillColor(230, 230, 230);
1390 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1391 $pdf->SetTextColor(0, 0, 60);
1394 $pdf->SetXY($posx + 2, $posy + 3);
1395 $pdf->SetFont(
'',
'B', $default_font_size);
1396 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1397 $posy = $pdf->getY();
1400 $pdf->SetXY($posx + 2, $posy);
1401 $pdf->SetFont(
'',
'', $default_font_size - 1);
1402 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1407 $usecontact =
false;
1409 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1411 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'CUSTOMER'),
$object->getIdContact(
'external',
'BILLING'));
1413 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1415 $result =
$object->fetch_contact($arrayidcontact[0]);
1419 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1420 $thirdparty =
$object->contact;
1422 $thirdparty =
$object->thirdparty;
1431 if ($this->page_largeur < 210) {
1434 $posy = 32 + $this->marge_haute + $top_shift;
1435 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1437 $posx = $this->marge_gauche;
1441 $pdf->SetTextColor(0, 0, 0);
1442 $pdf->SetFont(
'',
'', $default_font_size - 2);
1443 $pdf->SetXY($posx + 2, $posy - 5);
1444 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1445 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1448 $pdf->SetXY($posx + 2, $posy + 3);
1449 $pdf->SetFont(
'',
'B', $default_font_size);
1451 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1453 $posy = $pdf->getY();
1456 $pdf->SetFont(
'',
'', $default_font_size - 1);
1457 $pdf->SetXY($posx + 2, $posy);
1459 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);