148 public function write_file(
$object, $outputlangs =
null, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
151 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
153 if (!is_object($outputlangs)) {
154 $outputlangs = $langs;
158 $outputlangs->charset_output =
'ISO-8859-1';
162 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
164 global $outputlangsbis;
165 $outputlangsbis =
null;
167 $outputlangsbis =
new Translate(
'', $conf);
169 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
172 $nblines = count(
$object->lines);
180 $realpatharray = array();
182 for ($i = 0; $i < $nblines; $i++) {
183 if (empty(
$object->lines[$i]->fk_product)) {
187 $objphoto =
new Product($this->db);
188 $objphoto->fetch(
$object->lines[$i]->fk_product);
191 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
192 $dir = $conf->product->dir_output.
'/'.$pdir;
194 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
195 $dir = $conf->product->dir_output.
'/'.$pdir;
199 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
201 if ($obj[
'photo_vignette']) {
202 $filename = $obj[
'photo_vignette'];
204 $filename = $obj[
'photo'];
207 $filename = $obj[
'photo'];
209 $realpath = $dir.$filename;
214 $realpatharray[$i] = $realpath;
218 if (count($realpatharray) == 0) {
219 $this->posxpicture = $this->posxtva;
222 if ($conf->fournisseur->commande->dir_output) {
226 $amount_credit_notes_included = 0;
227 $amount_deposits_included = 0;
233 $dir = $conf->fournisseur->commande->dir_output;
234 $file = $dir.
"/SPECIMEN.pdf";
238 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
239 $file = $dir.
"/".$objectref.
".pdf";
241 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
245 if (!file_exists($dir)) {
247 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
252 if (file_exists($dir)) {
254 if (!is_object($hookmanager)) {
255 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
258 $hookmanager->initHooks(array(
'pdfgeneration'));
259 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
261 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
263 $nblines = count(
$object->lines);
267 $heightforinfotot = 50;
268 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
269 $heightforfooter = $this->marge_basse + 8;
271 $heightforfooter += 6;
273 $pdf->SetAutoPageBreak(1, 0);
275 if (class_exists(
'TCPDF')) {
276 $pdf->setPrintHeader(
false);
277 $pdf->setPrintFooter(
false);
282 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
283 $tplidx = $pdf->importPage(1);
288 $pdf->SetDrawColor(128, 128, 128);
290 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
291 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
292 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
293 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
296 $pdf->SetCompression(
false);
300 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
303 foreach (
$object->lines as $line) {
304 if ($line->remise_percent) {
305 $this->atleastonediscount =
true;
312 if (!empty($tplidx)) {
313 $pdf->useTemplate($tplidx);
317 $pdf->SetFont(
'',
'', $default_font_size - 1);
318 $pdf->MultiCell(0, 3,
'');
319 $pdf->SetTextColor(0, 0, 0);
321 $tab_top = 90 + $top_shift;
322 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
324 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
327 if (isModEnabled(
'incoterm')) {
328 $desc_incoterms =
$object->getIncotermsForPDF();
329 if ($desc_incoterms) {
332 $pdf->SetFont(
'',
'', $default_font_size - 1);
333 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
334 $nexY = $pdf->GetY();
335 $height_incoterms = $nexY - $tab_top;
338 $pdf->SetDrawColor(192, 192, 192);
339 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
341 $tab_top = $nexY + 6;
346 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
349 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
350 if (!empty($extranote)) {
354 $pagenb = $pdf->getPage();
356 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
357 $pageposbeforenote = $pagenb;
366 $pdf->startTransaction();
368 $pdf->SetFont(
'',
'', $default_font_size - 1);
369 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
371 $pageposafternote = $pdf->getPage();
372 $posyafter = $pdf->GetY();
374 if ($pageposafternote > $pageposbeforenote) {
375 $pdf->rollbackTransaction(
true);
378 while ($pagenb < $pageposafternote) {
381 if (!empty($tplidx)) {
382 $pdf->useTemplate($tplidx);
388 $pdf->setTopMargin($tab_top_newpage);
390 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
394 $pdf->setPage($pageposbeforenote);
395 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
396 $pdf->SetFont(
'',
'', $default_font_size - 1);
397 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
398 $pageposafternote = $pdf->getPage();
400 $posyafter = $pdf->GetY();
402 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
403 $pdf->AddPage(
'',
'',
true);
406 $pdf->setPage($pageposafternote);
407 $pdf->setTopMargin($tab_top_newpage);
409 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
415 $i = $pageposbeforenote;
416 while ($i < $pageposafternote) {
420 $pdf->SetDrawColor(128, 128, 128);
422 if ($i > $pageposbeforenote) {
423 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
424 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
426 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
427 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
431 $pdf->setPageOrientation(
'', 1, 0);
438 $pdf->setPage($pageposafternote);
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
445 $height_note = $posyafter - $tab_top_newpage;
446 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
449 $pdf->commitTransaction();
450 $posyafter = $pdf->GetY();
451 $height_note = $posyafter - $tab_top;
452 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
455 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
457 $pdf->AddPage(
'',
'',
true);
460 $pdf->setPage($pageposafternote);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
468 $posyafter = $tab_top_newpage;
472 $tab_height = $tab_height - $height_note;
473 $tab_top = $posyafter + 6;
482 $pageposbeforeprintlines = $pdf->getPage();
483 $pagenb = $pageposbeforeprintlines;
486 if ($pagenb == $pageposbeforeprintlines) {
487 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
488 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
490 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
491 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
494 $nexY = $tab_top + $this->tabTitleHeight;
497 for ($i = 0; $i < $nblines; $i++) {
499 $pdf->SetFont(
'',
'', $default_font_size - 1);
500 $pdf->SetTextColor(0, 0, 0);
503 $imglinesize = array();
504 if (!empty($realpatharray[$i])) {
508 $pdf->setTopMargin($tab_top_newpage);
509 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
510 $pageposbefore = $pdf->getPage();
512 $showpricebeforepagebreak = 1;
514 $posYAfterDescription = 0;
519 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
520 $pdf->AddPage(
'',
'',
true);
521 if (!empty($tplidx)) {
522 $pdf->useTemplate($tplidx);
524 $pdf->setPage($pageposbefore + 1);
526 $curY = $tab_top_newpage;
530 $showpricebeforepagebreak = 1;
532 $showpricebeforepagebreak = 0;
536 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
537 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
539 $posYAfterImage = $curY + $imglinesize[
'height'];
543 $curX = $this->posxdesc - 1;
544 $showpricebeforepagebreak = 1;
547 $pdf->startTransaction();
550 $pageposafter = $pdf->getPage();
551 if ($pageposafter > $pageposbefore) {
552 $pdf->rollbackTransaction(
true);
556 $pageposafter = $pdf->getPage();
557 $posyafter = $pdf->GetY();
558 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
559 if ($i == ($nblines - 1)) {
560 $pdf->AddPage(
'',
'',
true);
561 if (!empty($tplidx)) {
562 $pdf->useTemplate($tplidx);
565 $pdf->setPage($pageposafter + 1);
571 $showpricebeforepagebreak = 1;
573 $showpricebeforepagebreak = 0;
577 $pdf->commitTransaction();
579 $posYAfterDescription = $pdf->GetY();
582 $nexY = $pdf->GetY();
583 $pageposafter = $pdf->getPage();
584 $pdf->setPage($pageposbefore);
585 $pdf->setTopMargin($this->marge_haute);
586 $pdf->setPageOrientation(
'', 1, 0);
589 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
590 $pdf->setPage($pageposafter);
591 $curY = $tab_top_newpage;
594 $pdf->SetFont(
'',
'', $default_font_size - 1);
600 $nexY = max($pdf->GetY(), $nexY);
607 $nexY = max($pdf->GetY(), $nexY);
615 $nexY = max($pdf->GetY(), $nexY);
623 $nexY = max($pdf->GetY(), $nexY);
630 $nexY = max($pdf->GetY(), $nexY);
637 $nexY = max($pdf->GetY(), $nexY);
641 if (!empty(
$object->lines[$i]->array_options)) {
642 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
646 $nexY = max($pdf->GetY(), $nexY);
657 'outputlangs' => $outputlangs,
658 'hidedetails' => $hidedetails
660 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
664 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
665 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
667 $tvaligne =
$object->lines[$i]->total_tva;
670 $localtax1ligne =
$object->lines[$i]->total_localtax1;
671 $localtax2ligne =
$object->lines[$i]->total_localtax2;
672 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
673 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
674 $localtax1_type =
$object->lines[$i]->localtax1_type;
675 $localtax2_type =
$object->lines[$i]->localtax2_type;
688 $vatrate = (string)
$object->lines[$i]->tva_tx;
691 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
692 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
694 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
695 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
699 if ($localtax1_type && $localtax1ligne != 0) {
700 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
701 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
703 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
706 if ($localtax2_type && $localtax2ligne != 0) {
707 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
708 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
710 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
714 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
719 if (!isset($this->tva[$vatrate])) {
720 $this->tva[$vatrate] = 0;
722 $this->tva[$vatrate] += $tvaligne;
723 $vatcode =
$object->lines[$i]->vat_src_code;
724 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
725 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
727 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
729 if ($posYAfterImage > $posYAfterDescription) {
730 $nexY = $posYAfterImage;
735 $pdf->setPage($pageposafter);
736 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
738 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
739 $pdf->SetLineStyle(array(
'dash' => 0));
743 while ($pagenb < $pageposafter) {
744 $pdf->setPage($pagenb);
745 if ($pagenb == $pageposbeforeprintlines) {
746 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
748 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
752 $pdf->setPage($pagenb);
753 $pdf->setPageOrientation(
'', 1, 0);
757 if (!empty($tplidx)) {
758 $pdf->useTemplate($tplidx);
761 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
762 if ($pagenb == $pageposafter) {
763 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
765 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
770 if (!empty($tplidx)) {
771 $pdf->useTemplate($tplidx);
787 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
793 if (method_exists($pdf,
'AliasNbPages')) {
794 $pdf->AliasNbPages();
799 $pdf->Output($file,
'F');
802 $hookmanager->initHooks(array(
'pdfgeneration'));
803 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
805 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
807 $this->error = $hookmanager->error;
808 $this->errors = $hookmanager->errors;
813 $this->result = array(
'fullpath' => $file);
817 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
821 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
923 global $conf, $mysoc, $hookmanager;
929 $pdf->SetFont(
'',
'', $default_font_size - 1);
934 if ($this->page_largeur < 210) {
937 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
943 $pdf->SetFillColor(255, 255, 255);
944 $pdf->SetXY($col1x, $tab2_top);
945 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
947 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
948 $pdf->SetXY($col2x, $tab2_top);
949 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
952 $pdf->SetFillColor(248, 248, 248);
954 $this->atleastoneratenotnull = 0;
955 foreach ($this->tva as $tvakey => $tvaval) {
957 $this->atleastoneratenotnull++;
960 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
964 if (preg_match(
'/\*/', $tvakey)) {
965 $tvakey = str_replace(
'*',
'', $tvakey);
966 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
969 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
970 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
971 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
973 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
974 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
977 if (!$this->atleastoneratenotnull) {
979 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
980 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
982 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
983 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
988 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
989 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
990 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
991 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
997 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
998 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
999 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
1006 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1007 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1011 foreach ($localtax_rate as $tvakey => $tvaval) {
1016 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1019 if (preg_match(
'/\*/', (
string) $tvakey)) {
1020 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1021 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1023 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1024 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1025 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1027 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1036 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1037 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1041 foreach ($localtax_rate as $tvakey => $tvaval) {
1046 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1049 if (preg_match(
'/\*/', (
string) $tvakey)) {
1050 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1051 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1053 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1054 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1055 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1057 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1058 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1066 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1067 $pdf->SetTextColor(0, 0, 60);
1068 $pdf->SetFillColor(224, 224, 224);
1069 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1071 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1072 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1073 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1074 $pdf->SetFont(
'',
'', $default_font_size - 1);
1075 $pdf->SetTextColor(0, 0, 0);
1077 $creditnoteamount = 0;
1078 $depositsamount = 0;
1082 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1087 if ($deja_regle > 0) {
1091 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1093 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1094 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1097 $pdf->SetTextColor(0, 0, 60);
1098 $pdf->SetFillColor(224, 224, 224);
1099 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1102 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1103 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1105 $pdf->SetFont(
'',
'', $default_font_size - 1);
1106 $pdf->SetTextColor(0, 0, 0);
1109 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index);
1111 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1113 $this->error = $hookmanager->error;
1114 $this->errors = $hookmanager->errors;
1118 return ($tab2_top + ($tab2_hl * $index));
1188 global $langs, $conf, $mysoc;
1190 $ltrdirection =
'L';
1191 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1192 $ltrdirection =
'R';
1196 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1210 $pdf->SetTextColor(0, 0, 60);
1211 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1215 $posx = $this->page_largeur - $this->marge_droite - $w;
1216 $posy = $this->marge_haute;
1218 $pdf->SetXY($this->marge_gauche, $posy);
1222 if ($this->emetteur->logo) {
1223 $logodir = $conf->mycompany->dir_output;
1224 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1225 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1228 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1230 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1232 if (is_readable($logo)) {
1234 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1236 $pdf->SetTextColor(200, 0, 0);
1237 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1238 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1239 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1242 $text = $this->emetteur->name;
1243 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1247 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1248 $pdf->SetXY($posx, $posy);
1249 $pdf->SetTextColor(0, 0, 60);
1250 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1251 if (
$object->status == $object::STATUS_DRAFT) {
1252 $pdf->SetTextColor(128, 0, 0);
1253 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1255 $pdf->MultiCell($w, 3, $title,
'',
'R');
1260 $pdf->SetFont(
'',
'B', $default_font_size);
1261 $pdf->SetXY($posx, $posy);
1262 $pdf->SetTextColor(0, 0, 60);
1263 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1267 $pdf->SetFont(
'',
'', $default_font_size - 1);
1271 if (!empty(
$object->project->ref)) {
1273 $pdf->SetXY($posx, $posy);
1274 $pdf->SetTextColor(0, 0, 60);
1275 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1281 if (!empty(
$object->project->ref)) {
1282 $outputlangs->load(
"projects");
1284 $pdf->SetXY($posx, $posy);
1285 $langs->load(
"projects");
1286 $pdf->SetTextColor(0, 0, 60);
1287 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1291 if (!empty(
$object->date_commande)) {
1293 $pdf->SetXY($posx, $posy);
1294 $pdf->SetTextColor(0, 0, 60);
1295 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1306 $pdf->SetTextColor(0, 0, 60);
1307 $usehourmin =
'day';
1309 $usehourmin =
'dayhour';
1311 if (!empty(
$object->delivery_date)) {
1313 $pdf->SetXY($posx - 90, $posy);
1314 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1317 if (
$object->thirdparty->code_fournisseur) {
1319 $pdf->SetXY($posx, $posy);
1320 $pdf->SetTextColor(0, 0, 60);
1321 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1326 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1327 if (count($arrayidcontact) > 0) {
1328 $usertmp =
new User($this->db);
1329 $usertmp->fetch($arrayidcontact[0]);
1331 $pdf->SetXY($posx, $posy);
1332 $pdf->SetTextColor(0, 0, 60);
1333 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1338 $pdf->SetTextColor(0, 0, 60);
1342 $current_y = $pdf->getY();
1345 if ($current_y < $pdf->getY()) {
1346 $top_shift = $pdf->getY() - $current_y;
1351 $carac_emetteur =
'';
1353 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1354 if (count($arrayidcontact) > 0) {
1355 $object->fetch_user($arrayidcontact[0]);
1356 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1357 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1359 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1363 $carac_emetteur .=
"\n";
1369 $posy = 42 + $top_shift;
1370 $posx = $this->marge_gauche;
1372 $posx = $this->page_largeur - $this->marge_droite - 80;
1377 $pdf->SetTextColor(0, 0, 0);
1378 $pdf->SetFont(
'',
'', $default_font_size - 2);
1379 $pdf->SetXY($posx, $posy - 5);
1380 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1381 $pdf->SetXY($posx, $posy);
1382 $pdf->SetFillColor(230, 230, 230);
1383 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1384 $pdf->SetTextColor(0, 0, 60);
1387 $pdf->SetXY($posx + 2, $posy + 3);
1388 $pdf->SetFont(
'',
'B', $default_font_size);
1389 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1390 $posy = $pdf->getY();
1393 $pdf->SetXY($posx + 2, $posy);
1394 $pdf->SetFont(
'',
'', $default_font_size - 1);
1395 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1400 $usecontact =
false;
1401 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1402 if (count($arrayidcontact) > 0) {
1404 $result =
$object->fetch_contact($arrayidcontact[0]);
1408 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1409 $thirdparty =
$object->contact;
1411 $thirdparty =
$object->thirdparty;
1420 if ($this->page_largeur < 210) {
1423 $posy = 42 + $top_shift;
1424 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1426 $posx = $this->marge_gauche;
1430 $pdf->SetTextColor(0, 0, 0);
1431 $pdf->SetFont(
'',
'', $default_font_size - 2);
1432 $pdf->SetXY($posx + 2, $posy - 5);
1433 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1434 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1437 $pdf->SetXY($posx + 2, $posy + 3);
1438 $pdf->SetFont(
'',
'B', $default_font_size);
1440 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1442 $posy = $pdf->getY();
1445 $pdf->SetFont(
'',
'', $default_font_size - 1);
1446 $pdf->SetXY($posx + 2, $posy);
1448 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);