136 public function write_file(
$object, $outputlangs =
null, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
139 global $user, $langs, $conf, $hookmanager, $mysoc;
141 if (!is_object($outputlangs)) {
142 $outputlangs = $langs;
146 $outputlangs->charset_output =
'ISO-8859-1';
150 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
152 global $outputlangsbis;
153 $outputlangsbis =
null;
155 $outputlangsbis =
new Translate(
'', $conf);
157 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
164 $nblines = count(
$object->lines);
171 if ($conf->mrp->dir_output) {
175 $amount_credit_notes_included = 0;
176 $amount_deposits_included = 0;
182 $dir = $conf->mrp->dir_output;
183 $file = $dir.
"/SPECIMEN.pdf";
186 $dir = $conf->mrp->dir_output.
'/'.$objectref;
187 $file = $dir.
"/".$objectref.
".pdf";
190 if (!file_exists($dir)) {
192 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
197 if (file_exists($dir)) {
199 if (!is_object($hookmanager)) {
200 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
203 $hookmanager->initHooks(array(
'pdfgeneration'));
204 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
206 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
208 $nblines = count(
$object->lines);
212 $heightforinfotot = 50;
213 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
214 $heightforfooter = $this->marge_basse + 8;
216 $heightforfooter += 6;
218 $pdf->SetAutoPageBreak(1, 0);
220 if (class_exists(
'TCPDF')) {
221 $pdf->setPrintHeader(
false);
222 $pdf->setPrintFooter(
false);
227 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
228 $tplidx = $pdf->importPage(1);
233 $pdf->SetDrawColor(128, 128, 128);
235 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
236 $pdf->SetSubject($outputlangs->transnoentities(
"ManufacturingOrder"));
237 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
238 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
239 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
241 $pdf->SetCompression(
false);
245 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
251 if (!empty($tplidx)) {
252 $pdf->useTemplate($tplidx);
256 $pdf->SetFont(
'',
'', $default_font_size - 1);
257 $pdf->MultiCell(0, 3,
'');
258 $pdf->SetTextColor(0, 0, 0);
260 $tab_top = 90 + $top_shift;
261 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
263 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
267 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
270 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
271 if (!empty($extranote)) {
275 $pagenb = $pdf->getPage();
277 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
278 $pageposbeforenote = $pagenb;
287 $pdf->startTransaction();
289 $pdf->SetFont(
'',
'', $default_font_size - 1);
290 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
292 $pageposafternote = $pdf->getPage();
293 $posyafter = $pdf->GetY();
295 if ($pageposafternote > $pageposbeforenote) {
296 $pdf->rollbackTransaction(
true);
299 while ($pagenb < $pageposafternote) {
302 if (!empty($tplidx)) {
303 $pdf->useTemplate($tplidx);
309 $pdf->setTopMargin($tab_top_newpage);
311 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
315 $pdf->setPage($pageposbeforenote);
316 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
317 $pdf->SetFont(
'',
'', $default_font_size - 1);
318 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
319 $pageposafternote = $pdf->getPage();
321 $posyafter = $pdf->GetY();
323 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
324 $pdf->AddPage(
'',
'',
true);
327 $pdf->setPage($pageposafternote);
328 $pdf->setTopMargin($tab_top_newpage);
330 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
336 $i = $pageposbeforenote;
337 while ($i < $pageposafternote) {
340 $pdf->SetDrawColor(128, 128, 128);
342 if ($i > $pageposbeforenote) {
343 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
344 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
346 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
347 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
351 $pdf->setPageOrientation(
'', 1, 0);
358 $pdf->setPage($pageposafternote);
359 if (!empty($tplidx)) {
360 $pdf->useTemplate($tplidx);
365 $height_note = $posyafter - $tab_top_newpage;
366 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
369 $pdf->commitTransaction();
370 $posyafter = $pdf->GetY();
371 $height_note = $posyafter - $tab_top;
372 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
375 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
377 $pdf->AddPage(
'',
'',
true);
380 $pdf->setPage($pageposafternote);
381 if (!empty($tplidx)) {
382 $pdf->useTemplate($tplidx);
388 $posyafter = $tab_top_newpage;
392 $tab_height = $tab_height - $height_note;
393 $tab_top = $posyafter + 6;
398 $nexY = $tab_top + 5;
404 $pageposbeforeprintlines = $pdf->getPage();
405 $pagenb = $pageposbeforeprintlines;
407 $bom =
new BOM($this->db);
408 $bom -> fetch(
$object->fk_bom);
410 $nblines = count($bom->lines);
412 for ($i = 0; $i < $nblines; $i++) {
414 $pdf->SetFont(
'',
'', $default_font_size - 1);
415 $pdf->SetTextColor(0, 0, 0);
417 $prod =
new Product($this->db);
418 $prod->fetch($bom->lines[$i]->fk_product);
420 $pdf->setTopMargin($tab_top_newpage);
421 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
422 $pageposbefore = $pdf->getPage();
424 $showpricebeforepagebreak = 1;
426 $posYAfterDescription = 0;
429 $curX = $this->posxdesc - 1;
430 $showpricebeforepagebreak = 1;
433 $pdf->startTransaction();
437 $pageposafter = $pdf->getPage();
438 $posyafter = $pdf->GetY();
439 if ($pageposafter > $pageposbefore) {
440 $pdf->rollbackTransaction(
true);
445 $pageposafter = $pdf->getPage();
446 $posyafter = $pdf->GetY();
447 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
448 if ($i == ($nblines - 1)) {
449 $pdf->AddPage(
'',
'',
true);
450 if (!empty($tplidx)) {
451 $pdf->useTemplate($tplidx);
454 $pdf->setPage($pageposafter + 1);
459 $showpricebeforepagebreak = 1;
461 $showpricebeforepagebreak = 0;
465 $pdf->commitTransaction();
467 $posYAfterDescription = $pdf->GetY();
470 $nexY = $pdf->GetY();
471 $pageposafter = $pdf->getPage();
472 $pdf->setPage($pageposbefore);
473 $pdf->setTopMargin($this->marge_haute);
474 $pdf->setPageOrientation(
'', 1, 0);
477 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
478 $pdf->setPage($pageposafter);
479 $curY = $tab_top_newpage;
483 $pdf->startTransaction();
489 $pageposafter = $pdf->getPage();
490 $posyafter = $pdf->GetY();
491 if ($pageposafter > $pageposbefore) {
492 $pdf->rollbackTransaction(
true);
496 $pageposafter = $pdf->getPage();
497 $posyafter = $pdf->GetY();
498 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
499 if ($i == ($nblines - 1)) {
500 $pdf->AddPage(
'',
'',
true);
501 if (!empty($tplidx)) {
502 $pdf->useTemplate($tplidx);
505 $pdf->setPage($pageposafter + 1);
510 $showpricebeforepagebreak = 1;
512 $showpricebeforepagebreak = 0;
516 $pdf->commitTransaction();
518 $posYAfterDescription = max($posYAfterDescription, $pdf->GetY());
521 $nexY = max($nexY, $pdf->GetY());
522 $pageposafter = $pdf->getPage();
523 $pdf->setPage($pageposbefore);
524 $pdf->setTopMargin($this->marge_haute);
525 $pdf->setPageOrientation(
'', 1, 0);
528 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
529 $pdf->setPage($pageposafter);
530 $curY = $tab_top_newpage;
533 $pdf->SetFont(
'',
'', $default_font_size - 1);
538 $qty = $bom->lines[$i]->qty;
540 $nexY = max($pdf->GetY(), $nexY);
546 $qtytot =
$object->qty * $bom->lines[$i]->qty;
548 $nexY = max($pdf->GetY(), $nexY);
553 $array = array_filter(array($prod->length, $prod->width, $prod->height));
554 $dim = implode(
"x", $array);
556 $nexY = max($pdf->GetY(), $nexY);
562 if ($pagenb == $pageposbeforeprintlines) {
563 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
564 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
566 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
567 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
577 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
583 if (method_exists($pdf,
'AliasNbPages')) {
584 $pdf->AliasNbPages();
589 $pdf->Output($file,
'F');
592 $hookmanager->initHooks(array(
'pdfgeneration'));
593 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
595 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
597 $this->error = $hookmanager->error;
598 $this->errors = $hookmanager->errors;
603 $this->result = array(
'fullpath' => $file);
607 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
611 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
647 global $conf, $mysoc;
651 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
652 $pdf->SetFont(
'',
'B', $default_font_size - 2);
653 $pdf->SetXY($this->marge_gauche, $posy);
654 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
656 $posy = $pdf->GetY() + 4;
662 if (!empty(
$object->cond_reglement_code) ||
$object->cond_reglement) {
663 $pdf->SetFont(
'',
'B', $default_font_size - 2);
664 $pdf->SetXY($this->marge_gauche, $posy);
665 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
666 $pdf->MultiCell(80, 4, $titre, 0,
'L');
668 $pdf->SetFont(
'',
'', $default_font_size - 2);
669 $pdf->SetXY($posxval, $posy);
670 $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);
671 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
672 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
674 $posy = $pdf->GetY() + 3;
678 if (!empty(
$object->mode_reglement_code)) {
679 $pdf->SetFont(
'',
'B', $default_font_size - 2);
680 $pdf->SetXY($this->marge_gauche, $posy);
681 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
682 $pdf->MultiCell(80, 5, $titre, 0,
'L');
684 $pdf->SetFont(
'',
'', $default_font_size - 2);
685 $pdf->SetXY($posxval, $posy);
686 $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);
687 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
689 $posy = $pdf->GetY() + 2;
711 global $conf, $mysoc;
717 $pdf->SetFont(
'',
'', $default_font_size - 1);
722 if ($this->page_largeur < 210) {
725 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
731 $pdf->SetFillColor(255, 255, 255);
732 $pdf->SetXY($col1x, $tab2_top);
733 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
735 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
736 $pdf->SetXY($col2x, $tab2_top);
737 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
740 $pdf->SetFillColor(248, 248, 248);
742 $this->atleastoneratenotnull = 0;
743 foreach ($this->tva as $tvakey => $tvaval) {
745 $this->atleastoneratenotnull++;
748 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
752 if (preg_match(
'/\*/', $tvakey)) {
753 $tvakey = str_replace(
'*',
'', $tvakey);
754 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
757 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
758 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
759 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
761 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
762 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
765 if (!$this->atleastoneratenotnull) {
767 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
768 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
770 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
771 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
776 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
777 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
778 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
779 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
785 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
786 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
787 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
788 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
794 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
795 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
799 foreach ($localtax_rate as $tvakey => $tvaval) {
804 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
807 if (preg_match(
'/\*/', $tvakey)) {
808 $tvakey = str_replace(
'*',
'', $tvakey);
809 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
811 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
812 $totalvat .=
vatrate(abs((
float) $tvakey), 1).$tvacompl;
813 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
815 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
816 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
824 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
825 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
829 foreach ($localtax_rate as $tvakey => $tvaval) {
834 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
837 if (preg_match(
'/\*/', $tvakey)) {
838 $tvakey = str_replace(
'*',
'', $tvakey);
839 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
841 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
842 $totalvat .=
vatrate(abs((
float) $tvakey), 1).$tvacompl;
843 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
845 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
846 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
854 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
855 $pdf->SetTextColor(0, 0, 60);
856 $pdf->SetFillColor(224, 224, 224);
857 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
859 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
860 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
861 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
862 $pdf->SetFont(
'',
'', $default_font_size - 1);
863 $pdf->SetTextColor(0, 0, 0);
865 $creditnoteamount = 0;
870 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
875 if ($deja_regle > 0) {
879 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
880 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
881 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
882 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
885 $pdf->SetTextColor(0, 0, 60);
886 $pdf->SetFillColor(224, 224, 224);
887 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
888 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
890 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
891 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
893 $pdf->SetFont(
'',
'', $default_font_size - 1);
894 $pdf->SetTextColor(0, 0, 0);
898 return ($tab2_top + ($tab2_hl * $index));
988 global $langs, $conf, $mysoc;
991 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
996 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings",
"mrp"));
1010 $pdf->SetTextColor(0, 0, 60);
1011 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1013 $posx = $this->page_largeur - $this->marge_droite - 100;
1014 $posy = $this->marge_haute;
1017 $pdf->SetXY($this->marge_gauche, $posy);
1020 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
1021 if ($this->emetteur->logo) {
1022 if (is_readable($logo)) {
1024 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1026 $pdf->SetTextColor(200, 0, 0);
1027 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1028 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1029 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
1032 $text = $this->emetteur->name;
1033 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1036 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1037 $pdf->SetXY($posx, $posy);
1038 $pdf->SetTextColor(0, 0, 60);
1039 $title = $outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1040 $pdf->MultiCell(100, 3, $title,
'',
'R');
1045 $pdf->SetFont(
'',
'B', $default_font_size);
1046 $pdf->SetXY($posx, $posy);
1047 $pdf->SetTextColor(0, 0, 60);
1048 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1052 $pdf->SetFont(
'',
'', $default_font_size - 1);
1055 if (!empty(
$object->project->ref)) {
1057 $pdf->SetXY($posx, $posy);
1058 $pdf->SetTextColor(0, 0, 60);
1059 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1065 if (!empty(
$object->project->ref)) {
1066 $outputlangs->load(
"projects");
1068 $pdf->SetXY($posx, $posy);
1069 $langs->load(
"projects");
1070 $pdf->SetTextColor(0, 0, 60);
1071 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1075 if (!empty(
$object->date_approve)) {
1077 $pdf->SetXY($posx, $posy);
1078 $pdf->SetTextColor(0, 0, 60);
1079 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"MoDate").
" : ".
dol_print_date(
$object->date_approve,
"day",
false, $outputlangs,
true),
'',
'R');
1082 $pdf->SetXY($posx, $posy);
1083 $pdf->SetTextColor(255, 0, 0);
1084 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ToApprove"),
'',
'R');
1088 $prodToMake =
new Product($this->db);
1089 $resProdToMake = $prodToMake->fetch(
$object->fk_product);
1091 if ($resProdToMake > 0) {
1094 $pdf->SetFont(
'',
'B', $default_font_size + 1);
1095 $pdf->SetXY($posx, $posy);
1096 $pdf->SetTextColor(0, 0, 60);
1097 $pdf->MultiCell($w, 3, $prodToMake->ref,
'',
'R');
1101 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1102 $pdf->SetXY($posx, $posy);
1103 $pdf->SetTextColor(0, 0, 60);
1104 $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description),
'',
'R',
false, 1,
'',
'',
true, 0,
false,
true, 51,
'T',
true);
1105 $posy = $pdf->GetY() - 5;
1108 $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height));
1109 $dim = implode(
"x", $array);
1112 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1113 $pdf->SetXY($posx, $posy);
1114 $pdf->SetTextColor(0, 0, 60);
1115 $pdf->MultiCell($w, 3, $dim,
'',
'R');
1120 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1121 $pdf->SetXY($posx, $posy);
1122 $pdf->SetTextColor(0, 0, 60);
1123 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"QtyToProduce").
": " .$object->qty,
'',
'R');
1126 $pdf->SetTextColor(0, 0, 60);
1127 $usehourmin =
'day';
1129 $usehourmin =
'dayhour';
1131 if (!empty(
$object->delivery_date)) {
1133 $pdf->SetXY($posx - 90, $posy);
1134 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1137 if (
$object->thirdparty->code_fournisseur) {
1139 $pdf->SetXY($posx, $posy);
1140 $pdf->SetTextColor(0, 0, 60);
1141 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1146 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1147 if (count($arrayidcontact) > 0) {
1148 $usertmp =
new User($this->db);
1149 $usertmp->fetch($arrayidcontact[0]);
1151 $pdf->SetXY($posx, $posy);
1152 $pdf->SetTextColor(0, 0, 60);
1153 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1158 $pdf->SetTextColor(0, 0, 60);
1162 $current_y = $pdf->getY();
1164 if ($current_y < $pdf->getY()) {
1165 $top_shift = $pdf->getY() - $current_y;
1170 $carac_emetteur =
'';
1172 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1173 if (count($arrayidcontact) > 0) {
1174 $object->fetch_user($arrayidcontact[0]);
1175 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1176 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1178 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1182 $carac_emetteur .=
"\n";
1188 $posy = 42 + $top_shift;
1189 $posx = $this->marge_gauche;
1191 $posx = $this->page_largeur - $this->marge_droite - 80;
1196 $pdf->SetTextColor(0, 0, 0);
1197 $pdf->SetFont(
'',
'', $default_font_size - 2);
1198 $pdf->SetXY($posx, $posy - 5);
1199 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1200 $pdf->SetXY($posx, $posy);
1201 $pdf->SetFillColor(230, 230, 230);
1202 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1203 $pdf->SetTextColor(0, 0, 60);
1206 $pdf->SetXY($posx + 2, $posy + 3);
1207 $pdf->SetFont(
'',
'B', $default_font_size);
1208 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1209 $posy = $pdf->getY();
1212 $pdf->SetXY($posx + 2, $posy);
1213 $pdf->SetFont(
'',
'', $default_font_size - 1);
1214 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1219 $usecontact =
false;
1220 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1221 if (count($arrayidcontact) > 0) {
1223 $result =
$object->fetch_contact($arrayidcontact[0]);
1227 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')))) {
1228 $thirdparty =
$object->contact;
1230 $thirdparty =
$object->thirdparty;