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 $heightforinfotot = 50;
280 $heightforfooter = $this->marge_basse + 8;
282 $heightforfooter += 6;
284 $pdf->SetAutoPageBreak(1, 0);
286 if (class_exists(
'TCPDF')) {
287 $pdf->setPrintHeader(
false);
288 $pdf->setPrintFooter(
false);
293 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
294 $tplidx = $pdf->importPage(1);
299 $pdf->SetDrawColor(128, 128, 128);
301 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
302 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
303 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
304 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
305 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
307 $pdf->SetCompression(
false);
311 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
314 foreach (
$object->lines as $line) {
315 if ($line->remise_percent) {
316 $this->atleastonediscount =
true;
323 if (!empty($tplidx)) {
324 $pdf->useTemplate($tplidx);
328 $pdf->SetFont(
'',
'', $default_font_size - 1);
329 $pdf->MultiCell(0, 3,
'');
330 $pdf->SetTextColor(0, 0, 0);
332 $tab_top = 90 + $top_shift;
333 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
335 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
338 $height_incoterms = 0;
339 if (isModEnabled(
'incoterm')) {
340 $desc_incoterms =
$object->getIncotermsForPDF();
341 if ($desc_incoterms) {
344 $pdf->SetFont(
'',
'', $default_font_size - 1);
345 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
346 $nexY = $pdf->GetY();
347 $height_incoterms = $nexY - $tab_top;
350 $pdf->SetDrawColor(192, 192, 192);
351 $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');
353 $tab_top = $nexY + 6;
354 $height_incoterms += 4;
359 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
362 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
363 if (!empty($extranote)) {
367 $pagenb = $pdf->getPage();
368 if (!empty($notetoshow)) {
369 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
370 $pageposbeforenote = $pagenb;
379 $pdf->startTransaction();
381 $pdf->SetFont(
'',
'', $default_font_size - 1);
382 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
384 $pageposafternote = $pdf->getPage();
385 $posyafter = $pdf->GetY();
387 if ($pageposafternote > $pageposbeforenote) {
388 $pdf->rollbackTransaction(
true);
391 while ($pagenb < $pageposafternote) {
394 if (!empty($tplidx)) {
395 $pdf->useTemplate($tplidx);
401 $pdf->setTopMargin($tab_top_newpage);
403 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
407 $pdf->setPage($pageposbeforenote);
408 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
409 $pdf->SetFont(
'',
'', $default_font_size - 1);
410 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
411 $pageposafternote = $pdf->getPage();
413 $posyafter = $pdf->GetY();
415 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
416 $pdf->AddPage(
'',
'',
true);
419 $pdf->setPage($pageposafternote);
420 $pdf->setTopMargin($tab_top_newpage);
422 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
428 $i = $pageposbeforenote;
429 while ($i < $pageposafternote) {
433 $pdf->SetDrawColor(128, 128, 128);
435 if ($i > $pageposbeforenote) {
436 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
437 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
439 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
440 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
444 $pdf->setPageOrientation(
'', 1, 0);
451 $pdf->setPage($pageposafternote);
452 if (!empty($tplidx)) {
453 $pdf->useTemplate($tplidx);
458 $height_note = $posyafter - $tab_top_newpage;
460 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
462 $pdf->commitTransaction();
463 $posyafter = $pdf->GetY();
464 $height_note = $posyafter - $tab_top;
465 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
468 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
470 $pdf->AddPage(
'',
'',
true);
473 $pdf->setPage($pageposafternote);
474 if (!empty($tplidx)) {
475 $pdf->useTemplate($tplidx);
481 $posyafter = $tab_top_newpage;
485 $tab_height -= $height_note;
486 $tab_top = $posyafter + 6;
495 $pageposbeforeprintlines = $pdf->getPage();
496 $pagenb = $pageposbeforeprintlines;
499 if ($pagenb == $pageposbeforeprintlines) {
500 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
501 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
503 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
504 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
507 $nexY = $tab_top + $this->tabTitleHeight;
510 for ($i = 0; $i < $nblines; $i++) {
512 $pdf->SetFont(
'',
'', $default_font_size - 1);
513 $pdf->SetTextColor(0, 0, 0);
516 $imglinesize = array();
517 if (!empty($realpatharray[$i])) {
521 $pdf->setTopMargin($tab_top_newpage);
522 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
523 $pageposbefore = $pdf->getPage();
525 $showpricebeforepagebreak = 1;
527 $posYAfterDescription = 0;
532 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
533 $pdf->AddPage(
'',
'',
true);
534 if (!empty($tplidx)) {
535 $pdf->useTemplate($tplidx);
537 $pdf->setPage($pageposbefore + 1);
539 $curY = $tab_top_newpage;
543 $showpricebeforepagebreak = 1;
545 $showpricebeforepagebreak = 0;
549 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
550 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
552 $posYAfterImage = $curY + $imglinesize[
'height'];
557 $curX = $this->posxdesc - 1;
558 $showpricebeforepagebreak = 1;
561 $pdf->startTransaction();
565 $pageposafter = $pdf->getPage();
566 if ($pageposafter > $pageposbefore) {
567 $pdf->rollbackTransaction(
true);
571 $pageposafter = $pdf->getPage();
572 $posyafter = $pdf->GetY();
573 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
574 if ($i == ($nblines - 1)) {
575 $pdf->AddPage(
'',
'',
true);
576 if (!empty($tplidx)) {
577 $pdf->useTemplate($tplidx);
580 $pdf->setPage($pageposafter + 1);
586 $showpricebeforepagebreak = 1;
588 $showpricebeforepagebreak = 0;
592 $pdf->commitTransaction();
594 $posYAfterDescription = $pdf->GetY();
597 $nexY = $pdf->GetY();
598 $pageposafter = $pdf->getPage();
599 $pdf->setPage($pageposbefore);
600 $pdf->setTopMargin($this->marge_haute);
601 $pdf->setPageOrientation(
'', 1, 0);
604 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
605 $pdf->setPage($pageposafter);
606 $curY = $tab_top_newpage;
609 $pdf->SetFont(
'',
'', $default_font_size - 1);
620 $nexY = max($pdf->GetY(), $nexY);
627 $nexY = max($pdf->GetY(), $nexY);
635 $nexY = max($pdf->GetY(), $nexY);
643 $nexY = max($pdf->GetY(), $nexY);
650 $nexY = max($pdf->GetY(), $nexY);
657 $nexY = max($pdf->GetY(), $nexY);
661 if (!empty(
$object->lines[$i]->array_options)) {
662 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
666 $nexY = max($pdf->GetY(), $nexY);
677 'outputlangs' => $outputlangs,
678 'hidedetails' => $hidedetails
680 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
684 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
685 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
687 $tvaligne =
$object->lines[$i]->total_tva;
690 $localtax1ligne =
$object->lines[$i]->total_localtax1;
691 $localtax2ligne =
$object->lines[$i]->total_localtax2;
692 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
693 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
694 $localtax1_type =
$object->lines[$i]->localtax1_type;
695 $localtax2_type =
$object->lines[$i]->localtax2_type;
708 $vatrate = (string)
$object->lines[$i]->tva_tx;
711 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
712 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
714 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
715 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
719 if ($localtax1_type && $localtax1ligne != 0) {
720 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
721 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
723 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
726 if ($localtax2_type && $localtax2ligne != 0) {
727 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
728 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
730 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
734 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
739 if (!isset($this->tva[$vatrate])) {
740 $this->tva[$vatrate] = 0;
742 $this->tva[$vatrate] += $tvaligne;
743 $vatcode =
$object->lines[$i]->vat_src_code;
744 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
745 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
747 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
749 if ($posYAfterImage > $posYAfterDescription) {
750 $nexY = $posYAfterImage;
755 $pdf->setPage($pageposafter);
756 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
758 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
759 $pdf->SetLineStyle(array(
'dash' => 0));
763 while ($pagenb < $pageposafter) {
764 $pdf->setPage($pagenb);
765 if ($pagenb == $pageposbeforeprintlines) {
766 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
768 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
772 $pdf->setPage($pagenb);
773 $pdf->setPageOrientation(
'', 1, 0);
777 if (!empty($tplidx)) {
778 $pdf->useTemplate($tplidx);
781 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
782 if ($pagenb == $pageposafter) {
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);
790 if (!empty($tplidx)) {
791 $pdf->useTemplate($tplidx);
807 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
813 if (method_exists($pdf,
'AliasNbPages')) {
814 $pdf->AliasNbPages();
819 $pdf->Output($file,
'F');
822 $hookmanager->initHooks(array(
'pdfgeneration'));
823 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
825 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
827 $this->error = $hookmanager->error;
828 $this->errors = $hookmanager->errors;
833 $this->result = array(
'fullpath' => $file);
837 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
841 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
943 global
$conf, $mysoc, $hookmanager;
949 $pdf->SetFont(
'',
'', $default_font_size - 1);
954 if ($this->page_largeur < 210) {
957 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
963 $pdf->SetFillColor(255, 255, 255);
964 $pdf->SetXY($col1x, $tab2_top);
965 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
967 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
968 $pdf->SetXY($col2x, $tab2_top);
969 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
972 $pdf->SetFillColor(248, 248, 248);
974 $this->atleastoneratenotnull = 0;
975 foreach ($this->tva as $tvakey => $tvaval) {
977 $this->atleastoneratenotnull++;
980 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984 if (preg_match(
'/\*/', $tvakey)) {
985 $tvakey = str_replace(
'*',
'', $tvakey);
986 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
989 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
990 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
991 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
993 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
994 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
997 if (!$this->atleastoneratenotnull) {
999 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1000 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
1002 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1003 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
1008 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1009 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1010 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1011 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
1017 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1018 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1019 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1020 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
1026 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1027 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1031 foreach ($localtax_rate as $tvakey => $tvaval) {
1036 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1039 if (preg_match(
'/\*/', (
string) $tvakey)) {
1040 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1041 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1043 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1044 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1045 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1047 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1048 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1056 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1057 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1061 foreach ($localtax_rate as $tvakey => $tvaval) {
1066 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1069 if (preg_match(
'/\*/', (
string) $tvakey)) {
1070 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1071 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1073 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1074 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1075 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1077 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1078 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1086 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1087 $pdf->SetTextColor(0, 0, 60);
1088 $pdf->SetFillColor(224, 224, 224);
1089 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1091 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1092 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1093 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1094 $pdf->SetFont(
'',
'', $default_font_size - 1);
1095 $pdf->SetTextColor(0, 0, 0);
1097 $creditnoteamount = 0;
1098 $depositsamount = 0;
1102 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1107 if ($deja_regle > 0) {
1111 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1112 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1113 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1114 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1117 $pdf->SetTextColor(0, 0, 60);
1118 $pdf->SetFillColor(224, 224, 224);
1119 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1120 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1122 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1123 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1125 $pdf->SetFont(
'',
'', $default_font_size - 1);
1126 $pdf->SetTextColor(0, 0, 0);
1129 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1131 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1133 $this->error = $hookmanager->error;
1134 $this->errors = $hookmanager->errors;
1138 return ($tab2_top + ($tab2_hl * $index));
1208 global $langs,
$conf, $mysoc;
1210 $ltrdirection =
'L';
1211 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1212 $ltrdirection =
'R';
1216 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1230 $pdf->SetTextColor(0, 0, 60);
1231 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1235 $posx = $this->page_largeur - $this->marge_droite - $w;
1236 $posy = $this->marge_haute;
1238 $pdf->SetXY($this->marge_gauche, $posy);
1242 if ($this->emetteur->logo) {
1243 $logodir =
$conf->mycompany->dir_output;
1244 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1245 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1248 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1250 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1252 if (is_readable($logo)) {
1254 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1256 $pdf->SetTextColor(200, 0, 0);
1257 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1258 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1259 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1262 $text = $this->emetteur->name;
1263 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1267 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1268 $pdf->SetXY($posx, $posy);
1269 $pdf->SetTextColor(0, 0, 60);
1270 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1271 if (
$object->status == $object::STATUS_DRAFT) {
1272 $pdf->SetTextColor(128, 0, 0);
1273 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1275 $pdf->MultiCell($w, 3, $title,
'',
'R');
1280 $pdf->SetFont(
'',
'B', $default_font_size);
1281 $pdf->SetXY($posx, $posy);
1282 $pdf->SetTextColor(0, 0, 60);
1283 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1287 $pdf->SetFont(
'',
'', $default_font_size - 1);
1291 if (!empty(
$object->project->ref)) {
1293 $pdf->SetXY($posx, $posy);
1294 $pdf->SetTextColor(0, 0, 60);
1295 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1301 if (!empty(
$object->project->ref)) {
1302 $outputlangs->load(
"projects");
1304 $pdf->SetXY($posx, $posy);
1305 $langs->load(
"projects");
1306 $pdf->SetTextColor(0, 0, 60);
1307 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1311 if (!empty(
$object->date_commande)) {
1313 $pdf->SetXY($posx, $posy);
1314 $pdf->SetTextColor(0, 0, 60);
1315 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1326 $pdf->SetTextColor(0, 0, 60);
1327 $usehourmin =
'day';
1329 $usehourmin =
'dayhour';
1331 if (!empty(
$object->delivery_date)) {
1333 $pdf->SetXY($posx - 90, $posy);
1334 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1337 if (
$object->thirdparty->code_fournisseur) {
1339 $pdf->SetXY($posx, $posy);
1340 $pdf->SetTextColor(0, 0, 60);
1341 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1346 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1347 if (count($arrayidcontact) > 0) {
1348 $usertmp =
new User($this->db);
1349 $usertmp->fetch($arrayidcontact[0]);
1351 $pdf->SetXY($posx, $posy);
1352 $pdf->SetTextColor(0, 0, 60);
1353 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1358 $pdf->SetTextColor(0, 0, 60);
1362 $current_y = $pdf->getY();
1365 if ($current_y < $pdf->getY()) {
1366 $top_shift = $pdf->getY() - $current_y;
1371 $carac_emetteur =
'';
1373 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1374 if (count($arrayidcontact) > 0) {
1375 $object->fetch_user($arrayidcontact[0]);
1376 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1377 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1379 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1383 $carac_emetteur .=
"\n";
1389 $posy = 42 + $top_shift;
1390 $posx = $this->marge_gauche;
1392 $posx = $this->page_largeur - $this->marge_droite - 80;
1397 $pdf->SetTextColor(0, 0, 0);
1398 $pdf->SetFont(
'',
'', $default_font_size - 2);
1399 $pdf->SetXY($posx, $posy - 5);
1400 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1401 $pdf->SetXY($posx, $posy);
1402 $pdf->SetFillColor(230, 230, 230);
1403 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1404 $pdf->SetTextColor(0, 0, 60);
1407 $pdf->SetXY($posx + 2, $posy + 3);
1408 $pdf->SetFont(
'',
'B', $default_font_size);
1409 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1410 $posy = $pdf->getY();
1413 $pdf->SetXY($posx + 2, $posy);
1414 $pdf->SetFont(
'',
'', $default_font_size - 1);
1415 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1420 $usecontact =
false;
1421 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1422 if (count($arrayidcontact) > 0) {
1424 $result =
$object->fetch_contact($arrayidcontact[0]);
1428 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1429 $thirdparty =
$object->contact;
1431 $thirdparty =
$object->thirdparty;
1440 if ($this->page_largeur < 210) {
1443 $posy = 42 + $top_shift;
1444 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1446 $posx = $this->marge_gauche;
1450 $pdf->SetTextColor(0, 0, 0);
1451 $pdf->SetFont(
'',
'', $default_font_size - 2);
1452 $pdf->SetXY($posx + 2, $posy - 5);
1453 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1454 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1457 $pdf->SetXY($posx + 2, $posy + 3);
1458 $pdf->SetFont(
'',
'B', $default_font_size);
1460 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1462 $posy = $pdf->getY();
1465 $pdf->SetFont(
'',
'', $default_font_size - 1);
1466 $pdf->SetXY($posx + 2, $posy);
1468 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);