135 public function write_file($object, $outputlangs =
'', $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
138 global $user, $langs, $conf, $hookmanager, $mysoc;
140 if (!is_object($outputlangs)) {
141 $outputlangs = $langs;
145 $outputlangs->charset_output =
'ISO-8859-1';
149 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
151 global $outputlangsbis;
152 $outputlangsbis =
null;
153 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
154 $outputlangsbis =
new Translate(
'', $conf);
155 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
156 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
159 if (!isset($object->lines) || !is_array($object->lines)) {
160 $object->lines = array();
163 $nblines = count($object->lines);
167 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
171 $realpatharray = array();
173 if ($conf->mrp->dir_output) {
174 $object->fetch_thirdparty();
177 $amount_credit_notes_included = 0;
178 $amount_deposits_included = 0;
183 if ($object->specimen) {
184 $dir = $conf->mrp->dir_output;
185 $file = $dir.
"/SPECIMEN.pdf";
188 $dir = $conf->mrp->dir_output.
'/'.$objectref;
189 $file = $dir.
"/".$objectref.
".pdf";
192 if (!file_exists($dir)) {
194 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
199 if (file_exists($dir)) {
201 if (!is_object($hookmanager)) {
202 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
205 $hookmanager->initHooks(array(
'pdfgeneration'));
206 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
208 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
210 $nblines = count($object->lines);
214 $heightforinfotot = 50;
215 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
216 $heightforfooter = $this->marge_basse + 8;
218 $heightforfooter += 6;
220 $pdf->SetAutoPageBreak(1, 0);
222 if (class_exists(
'TCPDF')) {
223 $pdf->setPrintHeader(
false);
224 $pdf->setPrintFooter(
false);
229 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
230 $tplidx = $pdf->importPage(1);
235 $pdf->SetDrawColor(128, 128, 128);
237 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
238 $pdf->SetSubject($outputlangs->transnoentities(
"Mo"));
239 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
240 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
241 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Mo").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
243 $pdf->SetCompression(
false);
246 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
252 if (!empty($tplidx)) {
253 $pdf->useTemplate($tplidx);
256 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
257 $pdf->SetFont(
'',
'', $default_font_size - 1);
258 $pdf->MultiCell(0, 3,
'');
259 $pdf->SetTextColor(0, 0, 0);
261 $tab_top = 90 + $top_shift;
262 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
264 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
268 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
271 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
272 if (!empty($extranote)) {
276 $pagenb = $pdf->getPage();
278 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
279 $pageposbeforenote = $pagenb;
288 $pdf->startTransaction();
290 $pdf->SetFont(
'',
'', $default_font_size - 1);
291 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
293 $pageposafternote = $pdf->getPage();
294 $posyafter = $pdf->GetY();
296 if ($pageposafternote > $pageposbeforenote) {
297 $pdf->rollbackTransaction(
true);
300 while ($pagenb < $pageposafternote) {
303 if (!empty($tplidx)) {
304 $pdf->useTemplate($tplidx);
307 $this->
_pagehead($pdf, $object, 0, $outputlangs);
310 $pdf->setTopMargin($tab_top_newpage);
312 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
316 $pdf->setPage($pageposbeforenote);
317 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
318 $pdf->SetFont(
'',
'', $default_font_size - 1);
319 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
320 $pageposafternote = $pdf->getPage();
322 $posyafter = $pdf->GetY();
324 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
325 $pdf->AddPage(
'',
'',
true);
328 $pdf->setPage($pageposafternote);
329 $pdf->setTopMargin($tab_top_newpage);
331 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
337 $i = $pageposbeforenote;
338 while ($i < $pageposafternote) {
342 $pdf->SetDrawColor(128, 128, 128);
344 if ($i > $pageposbeforenote) {
345 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
346 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
348 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
349 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
353 $pdf->setPageOrientation(
'', 1, 0);
354 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
360 $pdf->setPage($pageposafternote);
361 if (!empty($tplidx)) {
362 $pdf->useTemplate($tplidx);
365 $this->
_pagehead($pdf, $object, 0, $outputlangs);
367 $height_note = $posyafter - $tab_top_newpage;
368 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
371 $pdf->commitTransaction();
372 $posyafter = $pdf->GetY();
373 $height_note = $posyafter - $tab_top;
374 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
377 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
379 $pdf->AddPage(
'',
'',
true);
382 $pdf->setPage($pageposafternote);
383 if (!empty($tplidx)) {
384 $pdf->useTemplate($tplidx);
387 $this->
_pagehead($pdf, $object, 0, $outputlangs);
390 $posyafter = $tab_top_newpage;
394 $tab_height = $tab_height - $height_note;
395 $tab_top = $posyafter + 6;
400 $nexY = $tab_top + 5;
406 $pageposbeforeprintlines = $pdf->getPage();
407 $pagenb = $pageposbeforeprintlines;
409 $bom =
new BOM($this->db);
410 $bom -> fetch($object->fk_bom);
412 $nblines = count($bom->lines);
414 for ($i = 0; $i < $nblines; $i++) {
416 $pdf->SetFont(
'',
'', $default_font_size - 1);
417 $pdf->SetTextColor(0, 0, 0);
419 $prod =
new Product($this->db);
420 $prod->fetch($bom->lines[$i]->fk_product);
423 $imglinesize = array();
424 if (!empty($realpatharray[$i])) {
428 $pdf->setTopMargin($tab_top_newpage);
429 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
430 $pageposbefore = $pdf->getPage();
432 $showpricebeforepagebreak = 1;
434 $posYAfterDescription = 0;
437 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
438 $pdf->AddPage(
'',
'',
true);
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
443 $this->
_pagehead($pdf, $object, 0, $outputlangs);
445 $pdf->setPage($pageposbefore + 1);
447 $curY = $tab_top_newpage;
451 $showpricebeforepagebreak = 1;
453 $showpricebeforepagebreak = 0;
457 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
458 $curX = $this->posxpicture - 1;
459 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
461 $posYAfterImage = $curY + $imglinesize[
'height'];
464 $curX = $this->posxdesc - 1;
465 $showpricebeforepagebreak = 1;
468 $pdf->startTransaction();
472 $pageposafter = $pdf->getPage();
473 $posyafter = $pdf->GetY();
474 if ($pageposafter > $pageposbefore) {
475 $pdf->rollbackTransaction(
true);
480 $pageposafter = $pdf->getPage();
481 $posyafter = $pdf->GetY();
482 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
483 if ($i == ($nblines - 1)) {
484 $pdf->AddPage(
'',
'',
true);
485 if (!empty($tplidx)) {
486 $pdf->useTemplate($tplidx);
489 $pdf->setPage($pageposafter + 1);
494 $showpricebeforepagebreak = 1;
496 $showpricebeforepagebreak = 0;
500 $pdf->commitTransaction();
502 $posYAfterDescription = $pdf->GetY();
505 $nexY = $pdf->GetY();
506 $pageposafter = $pdf->getPage();
507 $pdf->setPage($pageposbefore);
508 $pdf->setTopMargin($this->marge_haute);
509 $pdf->setPageOrientation(
'', 1, 0);
512 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
513 $pdf->setPage($pageposafter);
514 $curY = $tab_top_newpage;
518 $pdf->startTransaction();
524 $pageposafter = $pdf->getPage();
525 $posyafter = $pdf->GetY();
526 if ($pageposafter > $pageposbefore) {
527 $pdf->rollbackTransaction(
true);
531 $pageposafter = $pdf->getPage();
532 $posyafter = $pdf->GetY();
533 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
534 if ($i == ($nblines - 1)) {
535 $pdf->AddPage(
'',
'',
true);
536 if (!empty($tplidx)) {
537 $pdf->useTemplate($tplidx);
540 $pdf->setPage($pageposafter + 1);
545 $showpricebeforepagebreak = 1;
547 $showpricebeforepagebreak = 0;
551 $pdf->commitTransaction();
553 $posYAfterDescription = max($posYAfterDescription, $pdf->GetY());
556 $nexY = max($nexY, $pdf->GetY());
557 $pageposafter = $pdf->getPage();
558 $pdf->setPage($pageposbefore);
559 $pdf->setTopMargin($this->marge_haute);
560 $pdf->setPageOrientation(
'', 1, 0);
563 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
564 $pdf->setPage($pageposafter);
565 $curY = $tab_top_newpage;
568 $pdf->SetFont(
'',
'', $default_font_size - 1);
573 $qty = $bom->lines[$i]->qty;
575 $nexY = max($pdf->GetY(), $nexY);
581 $qtytot = $object->qty * $bom->lines[$i]->qty;
583 $nexY = max($pdf->GetY(), $nexY);
588 $array = array_filter(array($prod->length, $prod->width, $prod->height));
589 $dim = implode(
"x", $array);
591 $nexY = max($pdf->GetY(), $nexY);
599 if ($pagenb == $pageposbeforeprintlines) {
600 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
601 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
603 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
604 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
608 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
614 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
619 $this->
_pagefoot($pdf, $object, $outputlangs);
620 if (method_exists($pdf,
'AliasNbPages')) {
621 $pdf->AliasNbPages();
626 $pdf->Output($file,
'F');
629 $hookmanager->initHooks(array(
'pdfgeneration'));
630 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
632 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
634 $this->error = $hookmanager->error;
635 $this->errors = $hookmanager->errors;
640 $this->result = array(
'fullpath'=>$file);
644 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
648 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
684 global $conf, $mysoc;
688 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
689 $pdf->SetFont(
'',
'B', $default_font_size - 2);
690 $pdf->SetXY($this->marge_gauche, $posy);
691 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
693 $posy = $pdf->GetY() + 4;
699 if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
700 $pdf->SetFont(
'',
'B', $default_font_size - 2);
701 $pdf->SetXY($this->marge_gauche, $posy);
702 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
703 $pdf->MultiCell(80, 4, $titre, 0,
'L');
705 $pdf->SetFont(
'',
'', $default_font_size - 2);
706 $pdf->SetXY($posxval, $posy);
707 $lib_condition_paiement = ($outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) !=
'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
708 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
709 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
711 $posy = $pdf->GetY() + 3;
715 if (!empty($object->mode_reglement_code)) {
716 $pdf->SetFont(
'',
'B', $default_font_size - 2);
717 $pdf->SetXY($this->marge_gauche, $posy);
718 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
719 $pdf->MultiCell(80, 5, $titre, 0,
'L');
721 $pdf->SetFont(
'',
'', $default_font_size - 2);
722 $pdf->SetXY($posxval, $posy);
723 $lib_mode_reg = $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) !=
'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
724 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
726 $posy = $pdf->GetY() + 2;
745 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
748 global $conf, $mysoc;
754 $pdf->SetFont(
'',
'', $default_font_size - 1);
759 if ($this->page_largeur < 210) {
762 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
768 $pdf->SetFillColor(255, 255, 255);
769 $pdf->SetXY($col1x, $tab2_top);
770 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
772 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
773 $pdf->SetXY($col2x, $tab2_top);
774 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0,
'R', 1);
777 $pdf->SetFillColor(248, 248, 248);
779 $this->atleastoneratenotnull = 0;
780 foreach ($this->tva as $tvakey => $tvaval) {
782 $this->atleastoneratenotnull++;
785 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
789 if (preg_match(
'/\*/', $tvakey)) {
790 $tvakey = str_replace(
'*',
'', $tvakey);
791 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
794 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
795 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
796 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
798 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
799 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
802 if (!$this->atleastoneratenotnull) {
804 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
805 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
807 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
808 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_tva), 0,
'R', 1);
811 if (
getDolGlobalString(
'FACTURE_LOCAL_TAX1_OPTION') ==
'localtax1on' && $object->total_localtax1 > 0) {
813 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
814 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
815 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
816 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax1), $useborder,
'R', 1);
820 if (
getDolGlobalString(
'FACTURE_LOCAL_TAX2_OPTION') ==
'localtax2on' && $object->total_localtax2 > 0) {
822 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
823 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
824 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
825 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax2), $useborder,
'R', 1);
831 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
832 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
836 foreach ($localtax_rate as $tvakey => $tvaval) {
841 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
844 if (preg_match(
'/\*/', $tvakey)) {
845 $tvakey = str_replace(
'*',
'', $tvakey);
846 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
848 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
849 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
850 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
852 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
853 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
861 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
862 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
866 foreach ($localtax_rate as $tvakey => $tvaval) {
871 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
874 if (preg_match(
'/\*/', $tvakey)) {
875 $tvakey = str_replace(
'*',
'', $tvakey);
876 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
878 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
879 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
880 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
882 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
883 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
891 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
892 $pdf->SetTextColor(0, 0, 60);
893 $pdf->SetFillColor(224, 224, 224);
894 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
896 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
897 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
898 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
899 $pdf->SetFont(
'',
'', $default_font_size - 1);
900 $pdf->SetTextColor(0, 0, 0);
902 $creditnoteamount = 0;
907 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
908 if (!empty($object->paye)) {
912 if ($deja_regle > 0) {
916 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
917 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
918 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
919 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
922 $pdf->SetTextColor(0, 0, 60);
923 $pdf->SetFillColor(224, 224, 224);
924 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
927 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
928 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
930 $pdf->SetFont(
'',
'', $default_font_size - 1);
931 $pdf->SetTextColor(0, 0, 0);
935 return ($tab2_top + ($tab2_hl * $index));
1023 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1025 global $langs, $conf, $mysoc;
1027 $ltrdirection =
'L';
1028 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1029 $ltrdirection =
'R';
1033 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1047 $pdf->SetTextColor(0, 0, 60);
1048 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1050 $posx = $this->page_largeur - $this->marge_droite - 100;
1051 $posy = $this->marge_haute;
1054 $pdf->SetXY($this->marge_gauche, $posy);
1057 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
1058 if ($this->emetteur->logo) {
1059 if (is_readable($logo)) {
1061 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1063 $pdf->SetTextColor(200, 0, 0);
1064 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1065 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1066 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
1069 $text = $this->emetteur->name;
1070 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1073 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1074 $pdf->SetXY($posx, $posy);
1075 $pdf->SetTextColor(0, 0, 60);
1076 $title = $outputlangs->transnoentities(
"Mo").
" ".$outputlangs->convToOutputCharset($object->ref);
1077 $pdf->MultiCell(100, 3, $title,
'',
'R');
1080 if ($object->ref_supplier) {
1082 $pdf->SetFont(
'',
'B', $default_font_size);
1083 $pdf->SetXY($posx, $posy);
1084 $pdf->SetTextColor(0, 0, 60);
1085 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset($object->ref_supplier),
'',
'R');
1089 $pdf->SetFont(
'',
'', $default_font_size - 1);
1091 $object->fetch_projet();
1092 if (!empty($object->project->ref)) {
1094 $pdf->SetXY($posx, $posy);
1095 $pdf->SetTextColor(0, 0, 60);
1096 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1101 $object->fetch_projet();
1102 if (!empty($object->project->ref)) {
1103 $outputlangs->load(
"projects");
1105 $pdf->SetXY($posx, $posy);
1106 $langs->load(
"projects");
1107 $pdf->SetTextColor(0, 0, 60);
1108 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1112 if (!empty($object->date_approve)) {
1114 $pdf->SetXY($posx, $posy);
1115 $pdf->SetTextColor(0, 0, 60);
1116 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"MoDate").
" : ".
dol_print_date($object->date_approve,
"day",
false, $outputlangs,
true),
'',
'R');
1119 $pdf->SetXY($posx, $posy);
1120 $pdf->SetTextColor(255, 0, 0);
1121 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ToApprove"),
'',
'R');
1125 $prodToMake =
new Product($this->db);
1126 $resProdToMake = $prodToMake->fetch($object->fk_product);
1128 if ($resProdToMake > 0) {
1131 $pdf->SetFont(
'',
'B', $default_font_size + 1);
1132 $pdf->SetXY($posx, $posy);
1133 $pdf->SetTextColor(0, 0, 60);
1134 $pdf->MultiCell($w, 3, $prodToMake->ref,
'',
'R');
1138 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1139 $pdf->SetXY($posx, $posy);
1140 $pdf->SetTextColor(0, 0, 60);
1141 $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description),
'',
'R',
false, 1,
'',
'',
true, 0,
false,
true, 51,
'T',
true);
1142 $posy = $pdf->GetY() - 5;
1145 $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height));
1146 $dim = implode(
"x", $array);
1149 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1150 $pdf->SetXY($posx, $posy);
1151 $pdf->SetTextColor(0, 0, 60);
1152 $pdf->MultiCell($w, 3, $dim,
'',
'R');
1157 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1158 $pdf->SetXY($posx, $posy);
1159 $pdf->SetTextColor(0, 0, 60);
1160 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"QtyToProduce").
": " .$object->qty,
'',
'R');
1163 $pdf->SetTextColor(0, 0, 60);
1164 $usehourmin =
'day';
1166 $usehourmin =
'dayhour';
1168 if (!empty($object->delivery_date)) {
1170 $pdf->SetXY($posx - 90, $posy);
1171 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1174 if ($object->thirdparty->code_fournisseur) {
1176 $pdf->SetXY($posx, $posy);
1177 $pdf->SetTextColor(0, 0, 60);
1178 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1183 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1184 if (count($arrayidcontact) > 0) {
1185 $usertmp =
new User($this->db);
1186 $usertmp->fetch($arrayidcontact[0]);
1188 $pdf->SetXY($posx, $posy);
1189 $pdf->SetTextColor(0, 0, 60);
1190 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1195 $pdf->SetTextColor(0, 0, 60);
1199 $current_y = $pdf->getY();
1200 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1201 if ($current_y < $pdf->getY()) {
1202 $top_shift = $pdf->getY() - $current_y;
1207 $carac_emetteur =
'';
1209 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1210 if (count($arrayidcontact) > 0) {
1211 $object->fetch_user($arrayidcontact[0]);
1212 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1213 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1215 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1217 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1219 $carac_emetteur .=
"\n";
1222 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1225 $posy = 42 + $top_shift;
1226 $posx = $this->marge_gauche;
1228 $posx = $this->page_largeur - $this->marge_droite - 80;
1233 $pdf->SetTextColor(0, 0, 0);
1234 $pdf->SetFont(
'',
'', $default_font_size - 2);
1235 $pdf->SetXY($posx, $posy - 5);
1236 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1237 $pdf->SetXY($posx, $posy);
1238 $pdf->SetFillColor(230, 230, 230);
1239 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1240 $pdf->SetTextColor(0, 0, 60);
1243 $pdf->SetXY($posx + 2, $posy + 3);
1244 $pdf->SetFont(
'',
'B', $default_font_size);
1245 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1246 $posy = $pdf->getY();
1249 $pdf->SetXY($posx + 2, $posy);
1250 $pdf->SetFont(
'',
'', $default_font_size - 1);
1251 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1256 $usecontact =
false;
1257 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1258 if (count($arrayidcontact) > 0) {
1260 $result = $object->fetch_contact($arrayidcontact[0]);
1264 if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1265 $thirdparty = $object->contact;
1267 $thirdparty = $object->thirdparty;