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;
201 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
203 if ($obj[
'photo_vignette']) {
204 $filename = $obj[
'photo_vignette'];
206 $filename = $obj[
'photo'];
209 $filename = $obj[
'photo'];
211 $realpath = $dir.$filename;
213 $this->atleastonephoto =
true;
217 if ($realpath && $arephoto) {
218 $realpatharray[$i] = $realpath;
222 if (count($realpatharray) == 0) {
223 $this->posxpicture = $this->posxtva;
226 if ($conf->fournisseur->commande->dir_output) {
230 $amount_credit_notes_included = 0;
231 $amount_deposits_included = 0;
237 $dir = $conf->fournisseur->commande->dir_output;
238 $file = $dir.
"/SPECIMEN.pdf";
242 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
243 $file = $dir.
"/".$objectref.
".pdf";
245 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
249 if (!file_exists($dir)) {
251 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
256 if (file_exists($dir)) {
258 if (!is_object($hookmanager)) {
259 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
262 $hookmanager->initHooks(array(
'pdfgeneration'));
263 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
265 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
272 $pdf->SetAutoPageBreak(1, 0);
274 $heightforinfotot = 40;
275 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
276 $heightforfooter = $this->marge_basse + 8;
278 $heightforfooter += 6;
281 if (class_exists(
'TCPDF')) {
282 $pdf->setPrintHeader(
false);
283 $pdf->setPrintFooter(
false);
288 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
289 $tplidx = $pdf->importPage(1);
294 $pdf->SetDrawColor(128, 128, 128);
296 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
297 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
298 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
299 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
300 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
302 $pdf->SetCompression(
false);
306 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
309 foreach (
$object->lines as $line) {
310 if ($line->remise_percent) {
311 $this->atleastonediscount =
true;
318 if (!empty($tplidx)) {
319 $pdf->useTemplate($tplidx);
323 $pdf->SetFont(
'',
'', $default_font_size - 1);
324 $pdf->MultiCell(0, 3,
'');
325 $pdf->SetTextColor(0, 0, 0);
327 $tab_top = 90 + $top_shift;
328 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
330 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
332 $nexY = $tab_top - 1;
335 $height_incoterms = 0;
336 if (isModEnabled(
'incoterm')) {
337 $desc_incoterms =
$object->getIncotermsForPDF();
338 if ($desc_incoterms) {
341 $pdf->SetFont(
'',
'', $default_font_size - 1);
342 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
343 $nexY = max($pdf->GetY(), $nexY);
344 $height_incoterms = $nexY - $tab_top;
347 $pdf->SetDrawColor(192, 192, 192);
348 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
350 $tab_top = $nexY + 6;
351 $height_incoterms += 4;
356 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
359 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
360 if (!empty($extranote)) {
364 $pagenb = $pdf->getPage();
365 if (!empty($notetoshow)) {
368 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
369 $pageposbeforenote = $pagenb;
376 $pdf->startTransaction();
378 $pdf->SetFont(
'',
'', $default_font_size - 1);
379 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
381 $pageposafternote = $pdf->getPage();
382 $posyafter = $pdf->GetY();
384 if ($pageposafternote > $pageposbeforenote) {
385 $pdf->rollbackTransaction(
true);
388 while ($pagenb < $pageposafternote) {
391 if (!empty($tplidx)) {
392 $pdf->useTemplate($tplidx);
398 $pdf->setTopMargin($tab_top_newpage);
400 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
404 $pdf->setPage($pageposbeforenote);
405 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
406 $pdf->SetFont(
'',
'', $default_font_size - 1);
407 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
408 $pageposafternote = $pdf->getPage();
410 $posyafter = $pdf->GetY();
412 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
413 $pdf->AddPage(
'',
'',
true);
416 $pdf->setPage($pageposafternote);
417 $pdf->setTopMargin($tab_top_newpage);
419 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
425 $i = $pageposbeforenote;
426 while ($i < $pageposafternote) {
430 $pdf->SetDrawColor(128, 128, 128);
432 if ($i > $pageposbeforenote) {
433 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
434 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
436 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
437 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
441 $pdf->setPageOrientation(
'', 1, 0);
448 $pdf->setPage($pageposafternote);
449 if (!empty($tplidx)) {
450 $pdf->useTemplate($tplidx);
455 $height_note = $posyafter - $tab_top_newpage;
456 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
458 $pdf->commitTransaction();
459 $posyafter = $pdf->GetY();
460 $height_note = $posyafter - $tab_top;
461 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
464 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
466 $pdf->AddPage(
'',
'',
true);
469 $pdf->setPage($pageposafternote);
470 if (!empty($tplidx)) {
471 $pdf->useTemplate($tplidx);
477 $posyafter = $tab_top_newpage;
481 $tab_height = $tab_height - $height_note;
482 $tab_top = $posyafter + 6;
490 $nexY = $tab_top + $this->tabTitleHeight;
492 $pageposbeforeprintlines = $pdf->getPage();
493 $pagenb = $pageposbeforeprintlines;
496 for ($i = 0; $i < $nblines; $i++) {
498 $pdf->SetFont(
'',
'', $default_font_size - 1);
499 $pdf->SetTextColor(0, 0, 0);
502 $imglinesize = array();
503 if (!empty($realpatharray[$i])) {
507 $pdf->setTopMargin($tab_top_newpage);
508 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
509 $pageposbefore = $pdf->getPage();
511 $showpricebeforepagebreak = 1;
513 $posYAfterDescription = 0;
518 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
519 $pdf->AddPage(
'',
'',
true);
520 if (!empty($tplidx)) {
521 $pdf->useTemplate($tplidx);
523 $pdf->setPage($pageposbefore + 1);
525 $curY = $tab_top_newpage;
529 $showpricebeforepagebreak = 1;
531 $showpricebeforepagebreak = 0;
535 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
536 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
538 $posYAfterImage = $curY + $imglinesize[
'height'];
543 $showpricebeforepagebreak = 1;
546 $pdf->startTransaction();
549 $pageposafter = $pdf->getPage();
551 if ($pageposafter > $pageposbefore) {
552 $pdf->rollbackTransaction(
true);
553 $pageposafter = $pageposbefore;
554 $pdf->setPageOrientation(
'', 1, $heightforfooter);
557 $pageposafter = $pdf->getPage();
558 $posyafter = $pdf->GetY();
559 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
560 if ($i == ($nblines - 1)) {
561 $pdf->AddPage(
'',
'',
true);
562 if (!empty($tplidx)) {
563 $pdf->useTemplate($tplidx);
566 $pdf->setPage($pageposafter + 1);
572 $showpricebeforepagebreak = 1;
574 $showpricebeforepagebreak = 0;
578 $pdf->commitTransaction();
580 $posYAfterDescription = $pdf->GetY();
583 $nexY = max($pdf->GetY(), $posYAfterImage);
585 $pageposafter = $pdf->getPage();
587 $pdf->setPage($pageposbefore);
588 $pdf->setTopMargin($this->marge_haute);
589 $pdf->setPageOrientation(
'', 1, 0);
592 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
593 $pdf->setPage($pageposafter);
594 $curY = $tab_top_newpage;
597 $pdf->SetFont(
'',
'', $default_font_size - 1);
608 $nexY = max($pdf->GetY(), $nexY);
615 $nexY = max($pdf->GetY(), $nexY);
623 $nexY = max($pdf->GetY(), $nexY);
631 $nexY = max($pdf->GetY(), $nexY);
638 $nexY = max($pdf->GetY(), $nexY);
645 $nexY = max($pdf->GetY(), $nexY);
649 if (!empty(
$object->lines[$i]->array_options)) {
650 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
654 $nexY = max($pdf->GetY(), $nexY);
665 'outputlangs' => $outputlangs,
666 'hidedetails' => $hidedetails
668 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
672 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
673 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
675 $tvaligne =
$object->lines[$i]->total_tva;
678 $localtax1ligne =
$object->lines[$i]->total_localtax1;
679 $localtax2ligne =
$object->lines[$i]->total_localtax2;
680 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
681 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
682 $localtax1_type =
$object->lines[$i]->localtax1_type;
683 $localtax2_type =
$object->lines[$i]->localtax2_type;
696 $vatrate = (string)
$object->lines[$i]->tva_tx;
699 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
700 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
702 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
703 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
707 if ($localtax1_type && $localtax1ligne != 0) {
708 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
709 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
711 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
714 if ($localtax2_type && $localtax2ligne != 0) {
715 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
716 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
718 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
722 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
727 if (!isset($this->tva[$vatrate])) {
728 $this->tva[$vatrate] = 0;
730 $this->tva[$vatrate] += $tvaligne;
731 $vatcode =
$object->lines[$i]->vat_src_code;
732 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
733 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
735 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
737 if ($posYAfterImage > $posYAfterDescription) {
738 $nexY = $posYAfterImage;
743 $pdf->setPage($pageposafter);
744 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
746 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
747 $pdf->SetLineStyle(array(
'dash' => 0));
751 while ($pagenb < $pageposafter) {
752 $pdf->setPage($pagenb);
753 if ($pagenb == $pageposbeforeprintlines) {
754 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
756 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
760 $pdf->setPage($pagenb);
761 $pdf->setPageOrientation(
'', 1, 0);
765 if (!empty($tplidx)) {
766 $pdf->useTemplate($tplidx);
769 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
770 if ($pagenb == $pageposafter) {
771 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
773 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
778 if (!empty($tplidx)) {
779 $pdf->useTemplate($tplidx);
789 if ($pagenb == $pageposbeforeprintlines) {
790 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
792 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
794 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
803 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
809 if (method_exists($pdf,
'AliasNbPages')) {
810 $pdf->AliasNbPages();
815 $pdf->Output($file,
'F');
818 $hookmanager->initHooks(array(
'pdfgeneration'));
819 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
821 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
823 $this->error = $hookmanager->error;
824 $this->errors = $hookmanager->errors;
829 $this->result = array(
'fullpath' => $file);
833 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
837 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
939 global $conf, $mysoc, $hookmanager;
945 $pdf->SetFont(
'',
'', $default_font_size - 1);
950 if ($this->page_largeur < 210) {
953 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
959 $pdf->SetFillColor(255, 255, 255);
960 $pdf->SetXY($col1x, $tab2_top);
961 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
963 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
964 $pdf->SetXY($col2x, $tab2_top);
965 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
968 $pdf->SetFillColor(248, 248, 248);
970 $this->atleastoneratenotnull = 0;
971 foreach ($this->tva as $tvakey => $tvaval) {
973 $this->atleastoneratenotnull++;
976 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
980 if (preg_match(
'/\*/', $tvakey)) {
981 $tvakey = str_replace(
'*',
'', $tvakey);
982 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
985 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
986 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
987 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
989 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
990 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
993 if (!$this->atleastoneratenotnull) {
995 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
996 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
998 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
999 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
1004 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1005 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1006 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1007 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
1013 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1015 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1016 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
1022 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1023 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1027 foreach ($localtax_rate as $tvakey => $tvaval) {
1032 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1035 if (preg_match(
'/\*/', (
string) $tvakey)) {
1036 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1037 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1039 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1040 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1041 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1043 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1044 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1052 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1053 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1057 foreach ($localtax_rate as $tvakey => $tvaval) {
1062 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1065 if (preg_match(
'/\*/', (
string) $tvakey)) {
1066 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1067 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1069 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1070 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1071 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1073 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1082 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1083 $pdf->SetTextColor(0, 0, 60);
1084 $pdf->SetFillColor(224, 224, 224);
1085 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1087 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1088 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1089 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1090 $pdf->SetFont(
'',
'', $default_font_size - 1);
1091 $pdf->SetTextColor(0, 0, 0);
1093 $creditnoteamount = 0;
1094 $depositsamount = 0;
1098 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1103 if ($deja_regle > 0) {
1107 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1108 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1109 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1110 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1113 $pdf->SetTextColor(0, 0, 60);
1114 $pdf->SetFillColor(224, 224, 224);
1115 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1116 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1118 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1119 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1121 $pdf->SetFont(
'',
'', $default_font_size - 1);
1122 $pdf->SetTextColor(0, 0, 0);
1125 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1127 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1129 $this->error = $hookmanager->error;
1130 $this->errors = $hookmanager->errors;
1134 return ($tab2_top + ($tab2_hl * $index));
1205 global $langs, $conf, $mysoc;
1207 $ltrdirection =
'L';
1208 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1209 $ltrdirection =
'R';
1213 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1227 $pdf->SetTextColor(0, 0, 60);
1228 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1232 $posx = $this->page_largeur - $this->marge_droite - $w;
1233 $posy = $this->marge_haute;
1235 $pdf->SetXY($this->marge_gauche, $posy);
1239 if ($this->emetteur->logo) {
1240 $logodir = $conf->mycompany->dir_output;
1241 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1242 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1245 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1247 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1249 if (is_readable($logo)) {
1251 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1253 $pdf->SetTextColor(200, 0, 0);
1254 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1255 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1256 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1259 $text = $this->emetteur->name;
1260 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1264 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1265 $pdf->SetXY($posx, $posy);
1266 $pdf->SetTextColor(0, 0, 60);
1267 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1268 if (
$object->status == $object::STATUS_DRAFT) {
1269 $pdf->SetTextColor(128, 0, 0);
1270 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1272 $pdf->MultiCell($w, 3, $title,
'',
'R');
1277 $pdf->SetFont(
'',
'B', $default_font_size);
1278 $pdf->SetXY($posx, $posy);
1279 $pdf->SetTextColor(0, 0, 60);
1280 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1284 $pdf->SetFont(
'',
'', $default_font_size - 1);
1288 if (!empty(
$object->project->ref)) {
1290 $pdf->SetXY($posx, $posy);
1291 $pdf->SetTextColor(0, 0, 60);
1292 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1298 if (!empty(
$object->project->ref)) {
1299 $outputlangs->load(
"projects");
1301 $pdf->SetXY($posx, $posy);
1302 $langs->load(
"projects");
1303 $pdf->SetTextColor(0, 0, 60);
1304 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1308 if (!empty(
$object->date_commande)) {
1310 $pdf->SetXY($posx, $posy);
1311 $pdf->SetTextColor(0, 0, 60);
1312 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1323 $pdf->SetTextColor(0, 0, 60);
1324 $usehourmin =
'day';
1326 $usehourmin =
'dayhour';
1328 if (!empty(
$object->delivery_date)) {
1330 $pdf->SetXY($posx - 90, $posy);
1331 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1334 if (
$object->thirdparty->code_fournisseur) {
1336 $pdf->SetXY($posx, $posy);
1337 $pdf->SetTextColor(0, 0, 60);
1338 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1343 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1344 if (count($arrayidcontact) > 0) {
1345 $usertmp =
new User($this->db);
1346 $usertmp->fetch($arrayidcontact[0]);
1348 $pdf->SetXY($posx, $posy);
1349 $pdf->SetTextColor(0, 0, 60);
1350 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1355 $pdf->SetTextColor(0, 0, 60);
1359 $current_y = $pdf->getY();
1362 if ($current_y < $pdf->getY()) {
1363 $top_shift = $pdf->getY() - $current_y;
1368 $carac_emetteur =
'';
1370 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1371 if (count($arrayidcontact) > 0) {
1372 $object->fetch_user($arrayidcontact[0]);
1373 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1374 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1376 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1380 $carac_emetteur .=
"\n";
1386 $posy = 42 + $top_shift;
1387 $posx = $this->marge_gauche;
1389 $posx = $this->page_largeur - $this->marge_droite - 80;
1394 $pdf->SetTextColor(0, 0, 0);
1395 $pdf->SetFont(
'',
'', $default_font_size - 2);
1396 $pdf->SetXY($posx, $posy - 5);
1397 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1398 $pdf->SetXY($posx, $posy);
1399 $pdf->SetFillColor(230, 230, 230);
1400 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1401 $pdf->SetTextColor(0, 0, 60);
1404 $pdf->SetXY($posx + 2, $posy + 3);
1405 $pdf->SetFont(
'',
'B', $default_font_size);
1406 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1407 $posy = $pdf->getY();
1410 $pdf->SetXY($posx + 2, $posy);
1411 $pdf->SetFont(
'',
'', $default_font_size - 1);
1412 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1417 $usecontact =
false;
1418 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1419 if (count($arrayidcontact) > 0) {
1421 $result =
$object->fetch_contact($arrayidcontact[0]);
1425 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1426 $thirdparty =
$object->contact;
1428 $thirdparty =
$object->thirdparty;
1437 if ($this->page_largeur < 210) {
1440 $posy = 42 + $top_shift;
1441 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1443 $posx = $this->marge_gauche;
1447 $pdf->SetTextColor(0, 0, 0);
1448 $pdf->SetFont(
'',
'', $default_font_size - 2);
1449 $pdf->SetXY($posx + 2, $posy - 5);
1450 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1451 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1454 $pdf->SetXY($posx + 2, $posy + 3);
1455 $pdf->SetFont(
'',
'B', $default_font_size);
1457 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1459 $posy = $pdf->getY();
1462 $pdf->SetFont(
'',
'', $default_font_size - 1);
1463 $pdf->SetXY($posx + 2, $posy);
1465 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);