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(1, 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;
332 if (isModEnabled(
'incoterm')) {
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(
'', 1, $heightforfooter + $heightforfreetext);
399 $pdf->setPage($pageposbeforenote);
400 $pdf->setPageOrientation(
'', 1, $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(
'', 1, $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(
'', 1, 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(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
504 $pageposbefore = $pdf->getPage();
506 $showpricebeforepagebreak = 1;
508 $posYAfterDescription = 0;
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'];
537 $curX = $this->posxdesc - 1;
538 $showpricebeforepagebreak = 1;
541 $pdf->startTransaction();
544 $pageposafter = $pdf->getPage();
545 if ($pageposafter > $pageposbefore) {
546 $pdf->rollbackTransaction(
true);
550 $pageposafter = $pdf->getPage();
551 $posyafter = $pdf->GetY();
552 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
553 if ($i == ($nblines - 1)) {
554 $pdf->AddPage(
'',
'',
true);
555 if (!empty($tplidx)) {
556 $pdf->useTemplate($tplidx);
559 $pdf->setPage($pageposafter + 1);
565 $showpricebeforepagebreak = 1;
567 $showpricebeforepagebreak = 0;
571 $pdf->commitTransaction();
573 $posYAfterDescription = $pdf->GetY();
576 $nexY = $pdf->GetY();
577 $pageposafter = $pdf->getPage();
578 $pdf->setPage($pageposbefore);
579 $pdf->setTopMargin($this->marge_haute);
580 $pdf->setPageOrientation(
'', 1, 0);
583 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
584 $pdf->setPage($pageposafter);
585 $curY = $tab_top_newpage;
588 $pdf->SetFont(
'',
'', $default_font_size - 1);
594 $nexY = max($pdf->GetY(), $nexY);
601 $nexY = max($pdf->GetY(), $nexY);
609 $nexY = max($pdf->GetY(), $nexY);
617 $nexY = max($pdf->GetY(), $nexY);
624 $nexY = max($pdf->GetY(), $nexY);
631 $nexY = max($pdf->GetY(), $nexY);
635 if (!empty(
$object->lines[$i]->array_options)) {
636 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
640 $nexY = max($pdf->GetY(), $nexY);
651 'outputlangs' => $outputlangs,
652 'hidedetails' => $hidedetails
654 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
658 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
659 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
661 $tvaligne =
$object->lines[$i]->total_tva;
664 $localtax1ligne =
$object->lines[$i]->total_localtax1;
665 $localtax2ligne =
$object->lines[$i]->total_localtax2;
666 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
667 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
668 $localtax1_type =
$object->lines[$i]->localtax1_type;
669 $localtax2_type =
$object->lines[$i]->localtax2_type;
682 $vatrate = (string)
$object->lines[$i]->tva_tx;
685 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
686 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
688 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
689 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
693 if ($localtax1_type && $localtax1ligne != 0) {
694 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
695 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
697 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
700 if ($localtax2_type && $localtax2ligne != 0) {
701 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
702 $this->localtax2[$localtax2_type][$localtax2_rate] = (float) $localtax2ligne;
704 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
708 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
713 if (!isset($this->tva[$vatrate])) {
714 $this->tva[$vatrate] = 0;
716 $this->tva[$vatrate] += $tvaligne;
717 $vatcode =
$object->lines[$i]->vat_src_code;
718 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
719 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
721 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
723 if ($posYAfterImage > $posYAfterDescription) {
724 $nexY = $posYAfterImage;
729 $pdf->setPage($pageposafter);
730 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
732 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
733 $pdf->SetLineStyle(array(
'dash' => 0));
737 while ($pagenb < $pageposafter) {
738 $pdf->setPage($pagenb);
739 if ($pagenb == $pageposbeforeprintlines) {
740 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
742 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
746 $pdf->setPage($pagenb);
747 $pdf->setPageOrientation(
'', 1, 0);
751 if (!empty($tplidx)) {
752 $pdf->useTemplate($tplidx);
755 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
756 if ($pagenb == $pageposafter) {
757 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
759 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
764 if (!empty($tplidx)) {
765 $pdf->useTemplate($tplidx);
775 if ($pagenb == $pageposbeforeprintlines) {
776 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
777 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
779 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
780 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
790 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
796 if (method_exists($pdf,
'AliasNbPages')) {
797 $pdf->AliasNbPages();
802 $pdf->Output($file,
'F');
805 $hookmanager->initHooks(array(
'pdfgeneration'));
806 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
808 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
810 $this->error = $hookmanager->error;
811 $this->errors = $hookmanager->errors;
816 $this->result = array(
'fullpath' => $file);
820 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
824 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
926 global $conf, $mysoc;
932 $pdf->SetFont(
'',
'', $default_font_size - 1);
937 if ($this->page_largeur < 210) {
940 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
946 $pdf->SetFillColor(255, 255, 255);
947 $pdf->SetXY($col1x, $tab2_top);
948 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
950 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
951 $pdf->SetXY($col2x, $tab2_top);
952 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
955 $pdf->SetFillColor(248, 248, 248);
957 $this->atleastoneratenotnull = 0;
958 foreach ($this->tva as $tvakey => $tvaval) {
960 $this->atleastoneratenotnull++;
963 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
967 if (preg_match(
'/\*/', $tvakey)) {
968 $tvakey = str_replace(
'*',
'', $tvakey);
969 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
972 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
973 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
974 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
976 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
977 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
980 if (!$this->atleastoneratenotnull) {
982 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
986 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
991 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
992 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
993 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
994 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
1000 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1001 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1002 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1003 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
1009 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1010 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1014 foreach ($localtax_rate as $tvakey => $tvaval) {
1019 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1022 if (preg_match(
'/\*/', $tvakey)) {
1023 $tvakey = str_replace(
'*',
'', $tvakey);
1024 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1026 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1027 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1028 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1030 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1031 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1039 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1040 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1044 foreach ($localtax_rate as $tvakey => $tvaval) {
1049 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1052 if (preg_match(
'/\*/', $tvakey)) {
1053 $tvakey = str_replace(
'*',
'', $tvakey);
1054 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1056 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1057 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1058 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1060 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1061 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1069 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1070 $pdf->SetTextColor(0, 0, 60);
1071 $pdf->SetFillColor(224, 224, 224);
1072 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1074 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1075 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1076 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1077 $pdf->SetFont(
'',
'', $default_font_size - 1);
1078 $pdf->SetTextColor(0, 0, 0);
1080 $creditnoteamount = 0;
1081 $depositsamount = 0;
1085 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1090 if ($deja_regle > 0) {
1094 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1095 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1096 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1097 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1100 $pdf->SetTextColor(0, 0, 60);
1101 $pdf->SetFillColor(224, 224, 224);
1102 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1105 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1106 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1108 $pdf->SetFont(
'',
'', $default_font_size - 1);
1109 $pdf->SetTextColor(0, 0, 0);
1113 return ($tab2_top + ($tab2_hl * $index));
1183 global $langs, $conf, $mysoc;
1185 $ltrdirection =
'L';
1186 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1187 $ltrdirection =
'R';
1191 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"sendings"));
1205 $pdf->SetTextColor(0, 0, 60);
1206 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1208 $posx = $this->page_largeur - $this->marge_droite - 100;
1209 $posy = $this->marge_haute;
1211 $pdf->SetXY($this->marge_gauche, $posy);
1215 if ($this->emetteur->logo) {
1216 $logodir = $conf->mycompany->dir_output;
1217 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1218 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1221 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1223 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1225 if (is_readable($logo)) {
1227 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1229 $pdf->SetTextColor(200, 0, 0);
1230 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1231 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1232 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1235 $text = $this->emetteur->name;
1236 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1240 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1241 $pdf->SetXY($posx, $posy);
1242 $pdf->SetTextColor(0, 0, 60);
1243 $title = $outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1244 $pdf->MultiCell(100, 3, $title,
'',
'R');
1249 $pdf->SetFont(
'',
'B', $default_font_size);
1250 $pdf->SetXY($posx, $posy);
1251 $pdf->SetTextColor(0, 0, 60);
1252 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1256 $pdf->SetFont(
'',
'', $default_font_size - 1);
1260 if (!empty(
$object->project->ref)) {
1262 $pdf->SetXY($posx, $posy);
1263 $pdf->SetTextColor(0, 0, 60);
1264 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1270 if (!empty(
$object->project->ref)) {
1271 $outputlangs->load(
"projects");
1273 $pdf->SetXY($posx, $posy);
1274 $langs->load(
"projects");
1275 $pdf->SetTextColor(0, 0, 60);
1276 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1282 $pdf->SetXY($posx, $posy);
1283 $pdf->SetTextColor(0, 0, 60);
1284 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1287 $pdf->SetXY($posx, $posy);
1288 $pdf->SetTextColor(255, 0, 0);
1289 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Draft"),
'',
'R');
1292 $pdf->SetTextColor(0, 0, 60);
1293 $usehourmin =
'day';
1295 $usehourmin =
'dayhour';
1297 if (!empty(
$object->delivery_date)) {
1299 $pdf->SetXY($posx - 90, $posy);
1300 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1303 if (
$object->thirdparty->code_fournisseur) {
1305 $pdf->SetXY($posx, $posy);
1306 $pdf->SetTextColor(0, 0, 60);
1307 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1312 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1314 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1315 $usertmp =
new User($this->db);
1316 $usertmp->fetch($arrayidcontact[0]);
1318 $pdf->SetXY($posx, $posy);
1319 $pdf->SetTextColor(0, 0, 60);
1320 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1325 $pdf->SetTextColor(0, 0, 60);
1329 $current_y = $pdf->getY();
1331 if ($current_y < $pdf->getY()) {
1332 $top_shift = $pdf->getY() - $current_y;
1337 $carac_emetteur =
'';
1339 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1340 if (count($arrayidcontact) > 0) {
1341 $object->fetch_user($arrayidcontact[0]);
1342 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1343 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1345 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1349 $carac_emetteur .=
"\n";
1355 $posy = 42 + $top_shift;
1356 $posx = $this->marge_gauche;
1358 $posx = $this->page_largeur - $this->marge_droite - 80;
1363 $pdf->SetTextColor(0, 0, 0);
1364 $pdf->SetFont(
'',
'', $default_font_size - 2);
1365 $pdf->SetXY($posx, $posy - 5);
1366 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1367 $pdf->SetXY($posx, $posy);
1368 $pdf->SetFillColor(230, 230, 230);
1369 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1370 $pdf->SetTextColor(0, 0, 60);
1373 $pdf->SetXY($posx + 2, $posy + 3);
1374 $pdf->SetFont(
'',
'B', $default_font_size);
1375 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1376 $posy = $pdf->getY();
1379 $pdf->SetXY($posx + 2, $posy);
1380 $pdf->SetFont(
'',
'', $default_font_size - 1);
1381 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1386 $usecontact =
false;
1388 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1390 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'CUSTOMER'),
$object->getIdContact(
'external',
'BILLING'));
1392 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1394 $result =
$object->fetch_contact($arrayidcontact[0]);
1398 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1399 $thirdparty =
$object->contact;
1401 $thirdparty =
$object->thirdparty;
1410 if ($this->page_largeur < 210) {
1413 $posy = 42 + $top_shift;
1414 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1416 $posx = $this->marge_gauche;
1420 $pdf->SetTextColor(0, 0, 0);
1421 $pdf->SetFont(
'',
'', $default_font_size - 2);
1422 $pdf->SetXY($posx + 2, $posy - 5);
1423 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1424 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1427 $pdf->SetXY($posx + 2, $posy + 3);
1428 $pdf->SetFont(
'',
'B', $default_font_size);
1430 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1432 $posy = $pdf->getY();
1435 $pdf->SetFont(
'',
'', $default_font_size - 1);
1436 $pdf->SetXY($posx + 2, $posy);
1438 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);