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();
535 $showpricebeforepagebreak = 1;
537 $posYAfterDescription = 0;
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'];
566 $curX = $this->posxdesc - 1;
567 $showpricebeforepagebreak = 1;
572 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
573 $posYAfterDescription = $pdf->GetY();
575 $pdf->startTransaction();
578 $pageposafter = $pdf->getPage();
579 if ($pageposafter > $pageposbefore) {
580 $pdf->rollbackTransaction(
true);
584 $pageposafter = $pdf->getPage();
585 $posyafter = $pdf->GetY();
586 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
587 if ($i == ($nblines - 1)) {
588 $pdf->AddPage(
'',
'',
true);
589 if (!empty($tplidx)) {
590 $pdf->useTemplate($tplidx);
593 $pdf->setPage($pageposafter + 1);
599 $showpricebeforepagebreak = 1;
601 $showpricebeforepagebreak = 0;
605 $pdf->commitTransaction();
607 $posYAfterDescription = $pdf->GetY();
610 $nexY = $pdf->GetY();
611 $pageposafter = $pdf->getPage();
612 $pdf->setPage($pageposbefore);
613 $pdf->setTopMargin($this->marge_haute);
614 $pdf->setPageOrientation(
'',
true, 0);
617 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
618 $pdf->setPage($pageposafter);
619 $curY = $tab_top_newpage;
622 $pdf->SetFont(
'',
'', $default_font_size - 1);
628 $nexY = max($pdf->GetY(), $nexY);
632 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
635 $nexY = max($pdf->GetY(), $nexY);
643 $nexY = max($pdf->GetY(), $nexY);
651 $nexY = max($pdf->GetY(), $nexY);
655 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
658 $nexY = max($pdf->GetY(), $nexY);
663 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
666 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
668 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
670 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
674 $nexY = max($pdf->GetY(), $nexY);
678 if (!empty(
$object->lines[$i]->array_options)) {
679 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
683 $nexY = max($pdf->GetY(), $nexY);
694 'outputlangs' => $outputlangs,
695 'hidedetails' => $hidedetails
697 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
702 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
704 $tvaligne =
$object->lines[$i]->total_tva;
707 $localtax1ligne =
$object->lines[$i]->total_localtax1;
708 $localtax2ligne =
$object->lines[$i]->total_localtax2;
709 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
710 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
711 $localtax1_type =
$object->lines[$i]->localtax1_type;
712 $localtax2_type =
$object->lines[$i]->localtax2_type;
728 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
729 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
731 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
732 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
736 if ($localtax1_type && $localtax1ligne != 0) {
737 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
738 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
740 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
743 if ($localtax2_type && $localtax2ligne != 0) {
744 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
745 $this->localtax2[$localtax2_type][$localtax2_rate] = (float) $localtax2ligne;
747 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
751 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
756 if (!isset($this->tva[$vatrate])) {
757 $this->tva[$vatrate] = 0;
759 $this->tva[$vatrate] += $tvaligne;
760 $vatcode =
$object->lines[$i]->vat_src_code;
761 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
762 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
764 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
766 if ($posYAfterImage > $posYAfterDescription) {
767 $nexY = $posYAfterImage;
772 $pdf->setPage($pageposafter);
773 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
775 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
776 $pdf->SetLineStyle(array(
'dash' => 0));
780 while ($pagenb < $pageposafter) {
781 $pdf->setPage($pagenb);
782 if ($pagenb == $pageposbeforeprintlines) {
783 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
785 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
789 $pdf->setPage($pagenb);
790 $pdf->setPageOrientation(
'',
true, 0);
794 if (!empty($tplidx)) {
795 $pdf->useTemplate($tplidx);
798 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
799 if ($pagenb == $pageposafter) {
800 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
802 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
807 if (!empty($tplidx)) {
808 $pdf->useTemplate($tplidx);
818 if ($pagenb == $pageposbeforeprintlines) {
819 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
820 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
822 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
823 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
833 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
839 if (method_exists($pdf,
'AliasNbPages')) {
840 $pdf->AliasNbPages();
845 $pdf->Output($file,
'F');
848 $hookmanager->initHooks(array(
'pdfgeneration'));
849 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
851 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
852 $this->warnings = $hookmanager->warnings;
854 $this->error = $hookmanager->error;
855 $this->errors = $hookmanager->errors;
862 $this->result = array(
'fullpath' => $file);
866 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
870 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
981 $pdf->SetFont(
'',
'', $default_font_size - 1);
986 if ($this->page_largeur < 210) {
989 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
995 $pdf->SetFillColor(255, 255, 255);
996 $pdf->SetXY($col1x, $tab2_top);
997 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
1000 $pdf->SetXY($col2x, $tab2_top);
1001 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R',
true);
1004 $pdf->SetFillColor(248, 248, 248);
1006 $this->atleastoneratenotnull = 0;
1007 foreach ($this->tva as $tvakey => $tvaval) {
1009 $this->atleastoneratenotnull++;
1012 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 if (preg_match(
'/\*/', $tvakey)) {
1017 $tvakey = str_replace(
'*',
'', $tvakey);
1018 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1021 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
1022 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
1023 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1025 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
1029 if (!$this->atleastoneratenotnull) {
1031 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1032 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code), 0,
'L',
true);
1034 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1035 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R',
true);
1040 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1041 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code), 0,
'L',
true);
1042 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1043 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R',
true);
1049 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1050 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code), 0,
'L',
true);
1051 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1052 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R',
true);
1058 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1059 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1063 foreach ($localtax_rate as $tvakey => $tvaval) {
1068 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1071 if (preg_match(
'/\*/', $tvakey)) {
1072 $tvakey = str_replace(
'*',
'', $tvakey);
1073 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1075 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
1076 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1077 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1079 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1080 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
1088 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1089 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1093 foreach ($localtax_rate as $tvakey => $tvaval) {
1098 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1101 if (preg_match(
'/\*/', $tvakey)) {
1102 $tvakey = str_replace(
'*',
'', $tvakey);
1103 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1105 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
1106 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1107 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1109 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1110 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
1118 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1119 $pdf->SetTextColor(0, 0, 60);
1120 $pdf->SetFillColor(224, 224, 224);
1121 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1124 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1125 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R',
true);
1126 $pdf->SetFont(
'',
'', $default_font_size - 1);
1127 $pdf->SetTextColor(0, 0, 0);
1129 $creditnoteamount = 0;
1130 $depositsamount = 0;
1134 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1139 if ($deja_regle > 0) {
1143 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1144 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
1145 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1146 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R',
false);
1149 $pdf->SetTextColor(0, 0, 60);
1150 $pdf->SetFillColor(224, 224, 224);
1151 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1154 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1155 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R',
true);
1157 $pdf->SetFont(
'',
'', $default_font_size - 1);
1158 $pdf->SetTextColor(0, 0, 0);
1162 return ($tab2_top + ($tab2_hl * $index));
1234 $ltrdirection =
'L';
1235 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1236 $ltrdirection =
'R';
1240 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"sendings"));
1254 $pdf->SetTextColor(0, 0, 60);
1255 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1259 $posx = $this->page_largeur - $this->marge_droite - $w;
1260 $posy = $this->marge_haute;
1262 $pdf->SetXY($this->marge_gauche, $posy);
1266 if ($this->emetteur->logo) {
1267 $logodir =
$conf->mycompany->dir_output;
1268 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
1272 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1274 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1276 if (is_readable($logo)) {
1278 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1280 $pdf->SetTextColor(200, 0, 0);
1281 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1282 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1283 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1286 $text = $this->emetteur->name;
1287 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1291 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1292 $pdf->SetXY($posx, $posy);
1293 $pdf->SetTextColor(0, 0, 60);
1294 $title = $outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1295 $pdf->MultiCell($w, 3, $title,
'',
'R');
1300 $pdf->SetFont(
'',
'B', $default_font_size);
1301 $pdf->SetXY($posx, $posy);
1302 $pdf->SetTextColor(0, 0, 60);
1303 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1307 $pdf->SetFont(
'',
'', $default_font_size - 1);
1311 if (!empty(
$object->project->ref)) {
1313 $pdf->SetXY($posx, $posy);
1314 $pdf->SetTextColor(0, 0, 60);
1315 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
dol_trunc(
$object->project->title, 50)),
'',
'R');
1321 if (!empty(
$object->project->ref)) {
1322 $outputlangs->load(
"projects");
1324 $pdf->SetXY($posx, $posy);
1325 $langs->load(
"projects");
1326 $pdf->SetTextColor(0, 0, 60);
1327 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1333 $pdf->SetXY($posx, $posy);
1334 $pdf->SetTextColor(0, 0, 60);
1335 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1338 $pdf->SetXY($posx, $posy);
1339 $pdf->SetTextColor(255, 0, 0);
1340 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Draft"),
'',
'R');
1343 $pdf->SetTextColor(0, 0, 60);
1344 $usehourmin =
'day';
1346 $usehourmin =
'dayhour';
1348 if (!empty(
$object->delivery_date)) {
1350 $pdf->SetXY($posx - 90, $posy);
1351 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1354 if (
$object->thirdparty->code_fournisseur) {
1356 $pdf->SetXY($posx, $posy);
1357 $pdf->SetTextColor(0, 0, 60);
1358 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_fournisseur),
'',
'R');
1363 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1365 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1366 $usertmp =
new User($this->db);
1367 $usertmp->fetch($arrayidcontact[0]);
1369 $pdf->SetXY($posx, $posy);
1370 $pdf->SetTextColor(0, 0, 60);
1371 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1376 $pdf->SetTextColor(0, 0, 60);
1380 $current_y = $pdf->getY();
1382 if ($current_y < $pdf->getY()) {
1383 $top_shift = $pdf->getY() - $current_y;
1388 $carac_emetteur =
'';
1390 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1391 if (count($arrayidcontact) > 0) {
1392 $object->fetch_user($arrayidcontact[0]);
1393 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1394 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1396 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1400 $carac_emetteur .=
"\n";
1406 $posy = 32 + $this->marge_haute + $top_shift;
1407 $posx = $this->marge_gauche;
1409 $posx = $this->page_largeur - $this->marge_droite - 80;
1414 $pdf->SetTextColor(0, 0, 0);
1415 $pdf->SetFont(
'',
'', $default_font_size - 2);
1416 $pdf->SetXY($posx, $posy - 5);
1417 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1418 $pdf->SetXY($posx, $posy);
1419 $pdf->SetFillColor(230, 230, 230);
1420 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1421 $pdf->SetTextColor(0, 0, 60);
1424 $pdf->SetXY($posx + 2, $posy + 3);
1425 $pdf->SetFont(
'',
'B', $default_font_size);
1426 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1427 $posy = $pdf->getY();
1430 $pdf->SetXY($posx + 2, $posy);
1431 $pdf->SetFont(
'',
'', $default_font_size - 1);
1432 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1437 $usecontact =
false;
1439 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1441 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'CUSTOMER'),
$object->getIdContact(
'external',
'BILLING'));
1443 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1445 $result =
$object->fetch_contact($arrayidcontact[0]);
1449 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1450 $thirdparty =
$object->contact;
1452 $thirdparty =
$object->thirdparty;
1461 if ($this->page_largeur < 210) {
1464 $posy = 32 + $this->marge_haute + $top_shift;
1465 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1467 $posx = $this->marge_gauche;
1471 $pdf->SetTextColor(0, 0, 0);
1472 $pdf->SetFont(
'',
'', $default_font_size - 2);
1473 $pdf->SetXY($posx + 2, $posy - 5);
1474 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1475 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1478 $pdf->SetXY($posx + 2, $posy + 3);
1479 $pdf->SetFont(
'',
'B', $default_font_size);
1481 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1483 $posy = $pdf->getY();
1486 $pdf->SetFont(
'',
'', $default_font_size - 1);
1487 $pdf->SetXY($posx + 2, $posy);
1489 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);