154 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
157 global $user, $langs,
$conf, $hookmanager, $mysoc, $nblines;
159 if (!is_object($outputlangs)) {
160 $outputlangs = $langs;
164 $outputlangs->charset_output =
'ISO-8859-1';
168 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
170 global $outputlangsbis;
171 $outputlangsbis =
null;
175 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
178 $nblines = count(
$object->lines);
186 $realpatharray = array();
188 for ($i = 0; $i < $nblines; $i++) {
189 if (empty(
$object->lines[$i]->fk_product)) {
193 $objphoto =
new Product($this->db);
194 $objphoto->fetch(
$object->lines[$i]->fk_product);
197 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
198 $dir =
$conf->product->dir_output.
'/'.$pdir;
200 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
201 $dir =
$conf->product->dir_output.
'/'.$pdir;
207 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
209 if ($obj[
'photo_vignette']) {
210 $filename = $obj[
'photo_vignette'];
212 $filename = $obj[
'photo'];
215 $filename = $obj[
'photo'];
217 $realpath = $dir.$filename;
219 $this->atleastonephoto =
true;
223 if ($realpath && $arephoto) {
224 $realpatharray[$i] = $realpath;
228 if (count($realpatharray) == 0) {
229 $this->posxpicture = $this->posxtva;
232 if (
$conf->fournisseur->commande->dir_output) {
236 $amount_credit_notes_included = 0;
237 $amount_deposits_included = 0;
243 $dir =
$conf->fournisseur->commande->dir_output;
244 $file = $dir.
"/SPECIMEN.pdf";
248 $dir =
$conf->fournisseur->commande->dir_output.
'/'.$objectref;
249 $file = $dir.
"/".$objectref.
".pdf";
251 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
255 if (!file_exists($dir)) {
257 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
262 if (file_exists($dir)) {
264 if (!is_object($hookmanager)) {
265 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
268 $hookmanager->initHooks(array(
'pdfgeneration'));
269 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
271 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
278 $pdf->SetAutoPageBreak(1, 0);
280 $heightforinfotot = 40;
282 $heightforfooter = $this->marge_basse + 8;
284 $heightforfooter += 6;
287 if (class_exists(
'TCPDF')) {
288 $pdf->setPrintHeader(
false);
289 $pdf->setPrintFooter(
false);
294 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
295 $tplidx = $pdf->importPage(1);
300 $pdf->SetDrawColor(128, 128, 128);
302 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
303 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
304 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
305 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
306 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
308 $pdf->SetCompression(
false);
312 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
315 foreach (
$object->lines as $line) {
316 if ($line->remise_percent) {
317 $this->atleastonediscount =
true;
324 if (!empty($tplidx)) {
325 $pdf->useTemplate($tplidx);
329 $pdf->SetFont(
'',
'', $default_font_size - 1);
330 $pdf->MultiCell(0, 3,
'');
331 $pdf->SetTextColor(0, 0, 0);
333 $tab_top = 90 + $top_shift;
334 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
336 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
338 $nexY = $tab_top - 1;
341 $height_incoterms = 0;
342 if (isModEnabled(
'incoterm')) {
343 $desc_incoterms =
$object->getIncotermsForPDF();
344 if ($desc_incoterms) {
347 $pdf->SetFont(
'',
'', $default_font_size - 1);
348 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
349 $nexY = max($pdf->GetY(), $nexY);
350 $height_incoterms = $nexY - $tab_top;
353 $pdf->SetDrawColor(192, 192, 192);
354 $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');
356 $tab_top = $nexY + 6;
357 $height_incoterms += 4;
362 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
365 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
366 if (!empty($extranote)) {
370 $pagenb = $pdf->getPage();
371 if (!empty($notetoshow)) {
374 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
375 $pageposbeforenote = $pagenb;
382 $pdf->startTransaction();
384 $pdf->SetFont(
'',
'', $default_font_size - 1);
385 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
387 $pageposafternote = $pdf->getPage();
388 $posyafter = $pdf->GetY();
390 if ($pageposafternote > $pageposbeforenote) {
391 $pdf->rollbackTransaction(
true);
394 while ($pagenb < $pageposafternote) {
397 if (!empty($tplidx)) {
398 $pdf->useTemplate($tplidx);
404 $pdf->setTopMargin($tab_top_newpage);
406 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
410 $pdf->setPage($pageposbeforenote);
411 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
412 $pdf->SetFont(
'',
'', $default_font_size - 1);
413 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
414 $pageposafternote = $pdf->getPage();
416 $posyafter = $pdf->GetY();
418 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
419 $pdf->AddPage(
'',
'',
true);
422 $pdf->setPage($pageposafternote);
423 $pdf->setTopMargin($tab_top_newpage);
425 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
431 $i = $pageposbeforenote;
432 while ($i < $pageposafternote) {
436 $pdf->SetDrawColor(128, 128, 128);
438 if ($i > $pageposbeforenote) {
439 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
440 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
442 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
443 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
447 $pdf->setPageOrientation(
'', 1, 0);
454 $pdf->setPage($pageposafternote);
455 if (!empty($tplidx)) {
456 $pdf->useTemplate($tplidx);
461 $height_note = $posyafter - $tab_top_newpage;
463 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
465 $pdf->commitTransaction();
466 $posyafter = $pdf->GetY();
467 $height_note = $posyafter - $tab_top;
468 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
471 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
473 $pdf->AddPage(
'',
'',
true);
476 $pdf->setPage($pageposafternote);
477 if (!empty($tplidx)) {
478 $pdf->useTemplate($tplidx);
484 $posyafter = $tab_top_newpage;
488 $tab_height -= $height_note;
489 $tab_top = $posyafter + 6;
497 $nexY = $tab_top + $this->tabTitleHeight;
499 $pageposbeforeprintlines = $pdf->getPage();
500 $pagenb = $pageposbeforeprintlines;
503 for ($i = 0; $i < $nblines; $i++) {
505 $pdf->SetFont(
'',
'', $default_font_size - 1);
506 $pdf->SetTextColor(0, 0, 0);
509 $imglinesize = array();
510 if (!empty($realpatharray[$i])) {
514 $pdf->setTopMargin($tab_top_newpage);
515 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
516 $pageposbefore = $pdf->getPage();
518 $showpricebeforepagebreak = 1;
520 $posYAfterDescription = 0;
525 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
526 $pdf->AddPage(
'',
'',
true);
527 if (!empty($tplidx)) {
528 $pdf->useTemplate($tplidx);
530 $pdf->setPage($pageposbefore + 1);
532 $curY = $tab_top_newpage;
536 $showpricebeforepagebreak = 1;
538 $showpricebeforepagebreak = 0;
542 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
543 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
545 $posYAfterImage = $curY + $imglinesize[
'height'];
550 $showpricebeforepagebreak = 1;
553 $pdf->startTransaction();
556 $pageposafter = $pdf->getPage();
558 if ($pageposafter > $pageposbefore) {
559 $pdf->rollbackTransaction(
true);
560 $pageposafter = $pageposbefore;
561 $pdf->setPageOrientation(
'', 1, $heightforfooter);
564 $pageposafter = $pdf->getPage();
565 $posyafter = $pdf->GetY();
566 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
567 if ($i == ($nblines - 1)) {
568 $pdf->AddPage(
'',
'',
true);
569 if (!empty($tplidx)) {
570 $pdf->useTemplate($tplidx);
573 $pdf->setPage($pageposafter + 1);
579 $showpricebeforepagebreak = 1;
581 $showpricebeforepagebreak = 0;
585 $pdf->commitTransaction();
587 $posYAfterDescription = $pdf->GetY();
590 $nexY = max($pdf->GetY(), $posYAfterImage);
592 $pageposafter = $pdf->getPage();
594 $pdf->setPage($pageposbefore);
595 $pdf->setTopMargin($this->marge_haute);
596 $pdf->setPageOrientation(
'', 1, 0);
599 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
600 $pdf->setPage($pageposafter);
601 $curY = $tab_top_newpage;
604 $pdf->SetFont(
'',
'', $default_font_size - 1);
615 $nexY = max($pdf->GetY(), $nexY);
622 $nexY = max($pdf->GetY(), $nexY);
630 $nexY = max($pdf->GetY(), $nexY);
638 $nexY = max($pdf->GetY(), $nexY);
645 $nexY = max($pdf->GetY(), $nexY);
652 $nexY = max($pdf->GetY(), $nexY);
656 if (!empty(
$object->lines[$i]->array_options)) {
657 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
661 $nexY = max($pdf->GetY(), $nexY);
672 'outputlangs' => $outputlangs,
673 'hidedetails' => $hidedetails
675 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
679 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
680 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
682 $tvaligne =
$object->lines[$i]->total_tva;
685 $localtax1ligne =
$object->lines[$i]->total_localtax1;
686 $localtax2ligne =
$object->lines[$i]->total_localtax2;
687 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
688 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
689 $localtax1_type =
$object->lines[$i]->localtax1_type;
690 $localtax2_type =
$object->lines[$i]->localtax2_type;
703 $vatrate = (string)
$object->lines[$i]->tva_tx;
706 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
707 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
709 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
710 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
714 if ($localtax1_type && $localtax1ligne != 0) {
715 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
716 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
718 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
721 if ($localtax2_type && $localtax2ligne != 0) {
722 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
723 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
725 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
729 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
734 if (!isset($this->tva[$vatrate])) {
735 $this->tva[$vatrate] = 0;
737 $this->tva[$vatrate] += $tvaligne;
738 $vatcode =
$object->lines[$i]->vat_src_code;
739 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
740 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
742 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
744 if ($posYAfterImage > $posYAfterDescription) {
745 $nexY = $posYAfterImage;
750 $pdf->setPage($pageposafter);
751 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
753 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
754 $pdf->SetLineStyle(array(
'dash' => 0));
758 while ($pagenb < $pageposafter) {
759 $pdf->setPage($pagenb);
760 if ($pagenb == $pageposbeforeprintlines) {
761 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
763 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
767 $pdf->setPage($pagenb);
768 $pdf->setPageOrientation(
'', 1, 0);
772 if (!empty($tplidx)) {
773 $pdf->useTemplate($tplidx);
776 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
777 if ($pagenb == $pageposafter) {
778 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
780 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
785 if (!empty($tplidx)) {
786 $pdf->useTemplate($tplidx);
796 if ($pagenb == $pageposbeforeprintlines) {
797 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
799 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
801 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
810 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
816 if (method_exists($pdf,
'AliasNbPages')) {
817 $pdf->AliasNbPages();
822 $pdf->Output($file,
'F');
825 $hookmanager->initHooks(array(
'pdfgeneration'));
826 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
828 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
830 $this->error = $hookmanager->error;
831 $this->errors = $hookmanager->errors;
836 $this->result = array(
'fullpath' => $file);
840 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
844 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
946 global
$conf, $mysoc, $hookmanager;
952 $pdf->SetFont(
'',
'', $default_font_size - 1);
957 if ($this->page_largeur < 210) {
960 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
966 $pdf->SetFillColor(255, 255, 255);
967 $pdf->SetXY($col1x, $tab2_top);
968 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
970 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
971 $pdf->SetXY($col2x, $tab2_top);
972 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
975 $pdf->SetFillColor(248, 248, 248);
977 $this->atleastoneratenotnull = 0;
978 foreach ($this->tva as $tvakey => $tvaval) {
980 $this->atleastoneratenotnull++;
983 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
987 if (preg_match(
'/\*/', $tvakey)) {
988 $tvakey = str_replace(
'*',
'', $tvakey);
989 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
992 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
993 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
994 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
996 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
997 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1000 if (!$this->atleastoneratenotnull) {
1002 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1003 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
1005 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1006 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
1011 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1012 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1013 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1014 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
1020 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1021 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1022 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1023 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
1029 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1030 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1034 foreach ($localtax_rate as $tvakey => $tvaval) {
1039 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042 if (preg_match(
'/\*/', (
string) $tvakey)) {
1043 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1044 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1046 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1047 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1048 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1050 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1051 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1059 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1060 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1064 foreach ($localtax_rate as $tvakey => $tvaval) {
1069 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1072 if (preg_match(
'/\*/', (
string) $tvakey)) {
1073 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1074 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1076 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1077 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1078 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1080 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1081 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1089 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1090 $pdf->SetTextColor(0, 0, 60);
1091 $pdf->SetFillColor(224, 224, 224);
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1094 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1095 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1097 $pdf->SetFont(
'',
'', $default_font_size - 1);
1098 $pdf->SetTextColor(0, 0, 0);
1100 $creditnoteamount = 0;
1101 $depositsamount = 0;
1105 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1110 if ($deja_regle > 0) {
1114 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1115 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1116 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1117 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1120 $pdf->SetTextColor(0, 0, 60);
1121 $pdf->SetFillColor(224, 224, 224);
1122 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1123 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1125 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1126 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1128 $pdf->SetFont(
'',
'', $default_font_size - 1);
1129 $pdf->SetTextColor(0, 0, 0);
1132 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1134 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1136 $this->error = $hookmanager->error;
1137 $this->errors = $hookmanager->errors;
1141 return ($tab2_top + ($tab2_hl * $index));
1211 global $langs,
$conf, $mysoc;
1213 $ltrdirection =
'L';
1214 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1215 $ltrdirection =
'R';
1219 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1233 $pdf->SetTextColor(0, 0, 60);
1234 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1238 $posx = $this->page_largeur - $this->marge_droite - $w;
1239 $posy = $this->marge_haute;
1241 $pdf->SetXY($this->marge_gauche, $posy);
1245 if ($this->emetteur->logo) {
1246 $logodir =
$conf->mycompany->dir_output;
1247 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1248 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1251 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1253 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1255 if (is_readable($logo)) {
1257 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1259 $pdf->SetTextColor(200, 0, 0);
1260 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1261 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1262 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1265 $text = $this->emetteur->name;
1266 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1270 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1271 $pdf->SetXY($posx, $posy);
1272 $pdf->SetTextColor(0, 0, 60);
1273 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1274 if (
$object->status == $object::STATUS_DRAFT) {
1275 $pdf->SetTextColor(128, 0, 0);
1276 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1278 $pdf->MultiCell($w, 3, $title,
'',
'R');
1283 $pdf->SetFont(
'',
'B', $default_font_size);
1284 $pdf->SetXY($posx, $posy);
1285 $pdf->SetTextColor(0, 0, 60);
1286 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1290 $pdf->SetFont(
'',
'', $default_font_size - 1);
1294 if (!empty(
$object->project->ref)) {
1296 $pdf->SetXY($posx, $posy);
1297 $pdf->SetTextColor(0, 0, 60);
1298 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1304 if (!empty(
$object->project->ref)) {
1305 $outputlangs->load(
"projects");
1307 $pdf->SetXY($posx, $posy);
1308 $langs->load(
"projects");
1309 $pdf->SetTextColor(0, 0, 60);
1310 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1314 if (!empty(
$object->date_commande)) {
1316 $pdf->SetXY($posx, $posy);
1317 $pdf->SetTextColor(0, 0, 60);
1318 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1329 $pdf->SetTextColor(0, 0, 60);
1330 $usehourmin =
'day';
1332 $usehourmin =
'dayhour';
1334 if (!empty(
$object->delivery_date)) {
1336 $pdf->SetXY($posx - 90, $posy);
1337 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1340 if (
$object->thirdparty->code_fournisseur) {
1342 $pdf->SetXY($posx, $posy);
1343 $pdf->SetTextColor(0, 0, 60);
1344 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1349 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1350 if (count($arrayidcontact) > 0) {
1351 $usertmp =
new User($this->db);
1352 $usertmp->fetch($arrayidcontact[0]);
1354 $pdf->SetXY($posx, $posy);
1355 $pdf->SetTextColor(0, 0, 60);
1356 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1361 $pdf->SetTextColor(0, 0, 60);
1365 $current_y = $pdf->getY();
1368 if ($current_y < $pdf->getY()) {
1369 $top_shift = $pdf->getY() - $current_y;
1374 $carac_emetteur =
'';
1376 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1377 if (count($arrayidcontact) > 0) {
1378 $object->fetch_user($arrayidcontact[0]);
1379 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1380 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1382 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1386 $carac_emetteur .=
"\n";
1392 $posy = 42 + $top_shift;
1393 $posx = $this->marge_gauche;
1395 $posx = $this->page_largeur - $this->marge_droite - 80;
1400 $pdf->SetTextColor(0, 0, 0);
1401 $pdf->SetFont(
'',
'', $default_font_size - 2);
1402 $pdf->SetXY($posx, $posy - 5);
1403 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1404 $pdf->SetXY($posx, $posy);
1405 $pdf->SetFillColor(230, 230, 230);
1406 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1407 $pdf->SetTextColor(0, 0, 60);
1410 $pdf->SetXY($posx + 2, $posy + 3);
1411 $pdf->SetFont(
'',
'B', $default_font_size);
1412 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1413 $posy = $pdf->getY();
1416 $pdf->SetXY($posx + 2, $posy);
1417 $pdf->SetFont(
'',
'', $default_font_size - 1);
1418 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1423 $usecontact =
false;
1424 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1425 if (count($arrayidcontact) > 0) {
1427 $result =
$object->fetch_contact($arrayidcontact[0]);
1431 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1432 $thirdparty =
$object->contact;
1434 $thirdparty =
$object->thirdparty;
1443 if ($this->page_largeur < 210) {
1446 $posy = 42 + $top_shift;
1447 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1449 $posx = $this->marge_gauche;
1453 $pdf->SetTextColor(0, 0, 0);
1454 $pdf->SetFont(
'',
'', $default_font_size - 2);
1455 $pdf->SetXY($posx + 2, $posy - 5);
1456 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1457 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1460 $pdf->SetXY($posx + 2, $posy + 3);
1461 $pdf->SetFont(
'',
'B', $default_font_size);
1463 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1465 $posy = $pdf->getY();
1468 $pdf->SetFont(
'',
'', $default_font_size - 1);
1469 $pdf->SetXY($posx + 2, $posy);
1471 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);