143 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
146 global $user, $langs,
$conf, $hookmanager, $mysoc;
148 if (!is_object($outputlangs)) {
149 $outputlangs = $langs;
153 $outputlangs->charset_output =
'ISO-8859-1';
157 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
159 global $outputlangsbis;
160 $outputlangsbis =
null;
164 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
171 $nblines = count(
$object->lines);
178 if (
$conf->mrp->dir_output) {
182 $amount_credit_notes_included = 0;
183 $amount_deposits_included = 0;
189 $dir =
$conf->mrp->dir_output;
190 $file = $dir.
"/SPECIMEN.pdf";
193 $dir =
$conf->mrp->dir_output.
'/'.$objectref;
194 $file = $dir.
"/".$objectref.
".pdf";
197 if (!file_exists($dir)) {
199 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
204 if (file_exists($dir)) {
206 if (!is_object($hookmanager)) {
207 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
210 $hookmanager->initHooks(array(
'pdfgeneration'));
211 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
213 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
215 $nblines = count(
$object->lines);
219 $heightforinfotot = 50;
221 $heightforfooter = $this->marge_basse + 8;
223 $heightforfooter += 6;
225 $pdf->SetAutoPageBreak(1, 0);
227 if (class_exists(
'TCPDF')) {
228 $pdf->setPrintHeader(
false);
229 $pdf->setPrintFooter(
false);
234 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
235 $tplidx = $pdf->importPage(1);
240 $pdf->SetDrawColor(128, 128, 128);
242 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
243 $pdf->SetSubject($outputlangs->transnoentities(
"ManufacturingOrder"));
244 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
245 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
248 $pdf->SetCompression(
false);
252 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
258 if (!empty($tplidx)) {
259 $pdf->useTemplate($tplidx);
263 $pdf->SetFont(
'',
'', $default_font_size - 1);
264 $pdf->MultiCell(0, 3,
'');
265 $pdf->SetTextColor(0, 0, 0);
267 $tab_top = 90 + $top_shift;
268 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
270 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
274 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
277 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
278 if (!empty($extranote)) {
282 $pagenb = $pdf->getPage();
284 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
285 $pageposbeforenote = $pagenb;
294 $pdf->startTransaction();
296 $pdf->SetFont(
'',
'', $default_font_size - 1);
297 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
299 $pageposafternote = $pdf->getPage();
300 $posyafter = $pdf->GetY();
302 if ($pageposafternote > $pageposbeforenote) {
303 $pdf->rollbackTransaction(
true);
306 while ($pagenb < $pageposafternote) {
309 if (!empty($tplidx)) {
310 $pdf->useTemplate($tplidx);
316 $pdf->setTopMargin($tab_top_newpage);
318 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
322 $pdf->setPage($pageposbeforenote);
323 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
324 $pdf->SetFont(
'',
'', $default_font_size - 1);
325 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
326 $pageposafternote = $pdf->getPage();
328 $posyafter = $pdf->GetY();
330 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
331 $pdf->AddPage(
'',
'',
true);
334 $pdf->setPage($pageposafternote);
335 $pdf->setTopMargin($tab_top_newpage);
337 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
343 $i = $pageposbeforenote;
344 while ($i < $pageposafternote) {
347 $pdf->SetDrawColor(128, 128, 128);
349 if ($i > $pageposbeforenote) {
350 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
351 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
353 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
354 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
358 $pdf->setPageOrientation(
'', 1, 0);
365 $pdf->setPage($pageposafternote);
366 if (!empty($tplidx)) {
367 $pdf->useTemplate($tplidx);
372 $height_note = $posyafter - $tab_top_newpage;
373 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
376 $pdf->commitTransaction();
377 $posyafter = $pdf->GetY();
378 $height_note = $posyafter - $tab_top;
379 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
382 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
384 $pdf->AddPage(
'',
'',
true);
387 $pdf->setPage($pageposafternote);
388 if (!empty($tplidx)) {
389 $pdf->useTemplate($tplidx);
395 $posyafter = $tab_top_newpage;
399 $tab_height -= $height_note;
400 $tab_top = $posyafter + 6;
405 $nexY = $tab_top + 5;
411 $pageposbeforeprintlines = $pdf->getPage();
412 $pagenb = $pageposbeforeprintlines;
414 $bom =
new BOM($this->db);
415 $bom -> fetch(
$object->fk_bom);
417 $nblines = count($bom->lines);
419 for ($i = 0; $i < $nblines; $i++) {
421 $pdf->SetFont(
'',
'', $default_font_size - 1);
422 $pdf->SetTextColor(0, 0, 0);
424 $prod =
new Product($this->db);
425 $prod->fetch($bom->lines[$i]->fk_product);
427 $pdf->setTopMargin($tab_top_newpage);
428 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
429 $pageposbefore = $pdf->getPage();
431 $showpricebeforepagebreak = 1;
433 $posYAfterDescription = 0;
436 $curX = $this->posxdesc - 1;
437 $showpricebeforepagebreak = 1;
440 $pdf->startTransaction();
444 $pageposafter = $pdf->getPage();
445 $posyafter = $pdf->GetY();
446 if ($pageposafter > $pageposbefore) {
447 $pdf->rollbackTransaction(
true);
452 $pageposafter = $pdf->getPage();
453 $posyafter = $pdf->GetY();
454 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
455 if ($i == ($nblines - 1)) {
456 $pdf->AddPage(
'',
'',
true);
457 if (!empty($tplidx)) {
458 $pdf->useTemplate($tplidx);
461 $pdf->setPage($pageposafter + 1);
466 $showpricebeforepagebreak = 1;
468 $showpricebeforepagebreak = 0;
472 $pdf->commitTransaction();
474 $posYAfterDescription = $pdf->GetY();
477 $nexY = $pdf->GetY();
478 $pageposafter = $pdf->getPage();
479 $pdf->setPage($pageposbefore);
480 $pdf->setTopMargin($this->marge_haute);
481 $pdf->setPageOrientation(
'', 1, 0);
484 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
485 $pdf->setPage($pageposafter);
486 $curY = $tab_top_newpage;
490 $pdf->startTransaction();
496 $pageposafter = $pdf->getPage();
497 $posyafter = $pdf->GetY();
498 if ($pageposafter > $pageposbefore) {
499 $pdf->rollbackTransaction(
true);
503 $pageposafter = $pdf->getPage();
504 $posyafter = $pdf->GetY();
505 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
506 if ($i == ($nblines - 1)) {
507 $pdf->AddPage(
'',
'',
true);
508 if (!empty($tplidx)) {
509 $pdf->useTemplate($tplidx);
512 $pdf->setPage($pageposafter + 1);
517 $showpricebeforepagebreak = 1;
519 $showpricebeforepagebreak = 0;
523 $pdf->commitTransaction();
525 $posYAfterDescription = max($posYAfterDescription, $pdf->GetY());
528 $nexY = max($nexY, $pdf->GetY());
529 $pageposafter = $pdf->getPage();
530 $pdf->setPage($pageposbefore);
531 $pdf->setTopMargin($this->marge_haute);
532 $pdf->setPageOrientation(
'', 1, 0);
535 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
536 $pdf->setPage($pageposafter);
537 $curY = $tab_top_newpage;
540 $pdf->SetFont(
'',
'', $default_font_size - 1);
545 $qty = $bom->lines[$i]->qty;
547 $nexY = max($pdf->GetY(), $nexY);
553 $qtytot =
$object->qty * $bom->lines[$i]->qty;
555 $nexY = max($pdf->GetY(), $nexY);
560 $array = array_filter(array($prod->length, $prod->width, $prod->height));
561 $dim = implode(
"x", $array);
563 $nexY = max($pdf->GetY(), $nexY);
569 if ($pagenb == $pageposbeforeprintlines) {
570 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
571 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
573 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
574 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
584 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
590 if (method_exists($pdf,
'AliasNbPages')) {
591 $pdf->AliasNbPages();
596 $pdf->Output($file,
'F');
599 $hookmanager->initHooks(array(
'pdfgeneration'));
600 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
602 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
604 $this->error = $hookmanager->error;
605 $this->errors = $hookmanager->errors;
610 $this->result = array(
'fullpath' => $file);
614 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
618 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
654 global
$conf, $mysoc;
658 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
659 $pdf->SetFont(
'',
'B', $default_font_size - 2);
660 $pdf->SetXY($this->marge_gauche, $posy);
661 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
663 $posy = $pdf->GetY() + 4;
669 if (!empty(
$object->cond_reglement_code) ||
$object->cond_reglement) {
670 $pdf->SetFont(
'',
'B', $default_font_size - 2);
671 $pdf->SetXY($this->marge_gauche, $posy);
672 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
673 $pdf->MultiCell(80, 4, $titre, 0,
'L');
675 $pdf->SetFont(
'',
'', $default_font_size - 2);
676 $pdf->SetXY($posxval, $posy);
677 $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);
678 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
679 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
681 $posy = $pdf->GetY() + 3;
685 if (!empty(
$object->mode_reglement_code)) {
686 $pdf->SetFont(
'',
'B', $default_font_size - 2);
687 $pdf->SetXY($this->marge_gauche, $posy);
688 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
689 $pdf->MultiCell(80, 5, $titre, 0,
'L');
691 $pdf->SetFont(
'',
'', $default_font_size - 2);
692 $pdf->SetXY($posxval, $posy);
693 $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);
694 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
696 $posy = $pdf->GetY() + 2;
718 global
$conf, $mysoc;
724 $pdf->SetFont(
'',
'', $default_font_size - 1);
729 if ($this->page_largeur < 210) {
732 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
738 $pdf->SetFillColor(255, 255, 255);
739 $pdf->SetXY($col1x, $tab2_top);
740 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
742 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
743 $pdf->SetXY($col2x, $tab2_top);
744 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
747 $pdf->SetFillColor(248, 248, 248);
749 $this->atleastoneratenotnull = 0;
750 foreach ($this->tva as $tvakey => $tvaval) {
752 $this->atleastoneratenotnull++;
755 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
759 if (preg_match(
'/\*/', $tvakey)) {
760 $tvakey = str_replace(
'*',
'', $tvakey);
761 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
764 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
765 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
766 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
768 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
769 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
772 if (!$this->atleastoneratenotnull) {
774 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
775 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
777 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
778 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
783 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
784 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
785 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
786 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
792 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
793 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
794 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
795 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
801 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
802 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
806 foreach ($localtax_rate as $tvakey => $tvaval) {
811 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
814 if (preg_match(
'/\*/', $tvakey)) {
815 $tvakey = str_replace(
'*',
'', $tvakey);
816 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
818 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
819 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
820 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
822 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
823 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
831 foreach ($this->localtax2 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(
"TotalLT2", $mysoc->country_code).
' ';
849 $totalvat .=
vatrate((
string) abs((
float) $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,
'R', 1);
861 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
862 $pdf->SetTextColor(0, 0, 60);
863 $pdf->SetFillColor(224, 224, 224);
864 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
866 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
867 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
868 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
869 $pdf->SetFont(
'',
'', $default_font_size - 1);
870 $pdf->SetTextColor(0, 0, 0);
872 $creditnoteamount = 0;
877 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
882 if ($deja_regle > 0) {
886 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
887 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
888 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
889 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
892 $pdf->SetTextColor(0, 0, 60);
893 $pdf->SetFillColor(224, 224, 224);
894 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
895 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
897 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
898 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
900 $pdf->SetFont(
'',
'', $default_font_size - 1);
901 $pdf->SetTextColor(0, 0, 0);
905 return ($tab2_top + ($tab2_hl * $index));
995 global $langs,
$conf, $mysoc;
998 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1003 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings",
"mrp"));
1017 $pdf->SetTextColor(0, 0, 60);
1018 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1020 $posx = $this->page_largeur - $this->marge_droite - 100;
1021 $posy = $this->marge_haute;
1024 $pdf->SetXY($this->marge_gauche, $posy);
1027 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
1028 if ($this->emetteur->logo) {
1029 if (is_readable($logo)) {
1031 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1033 $pdf->SetTextColor(200, 0, 0);
1034 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1035 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1036 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
1039 $text = $this->emetteur->name;
1040 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1043 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1044 $pdf->SetXY($posx, $posy);
1045 $pdf->SetTextColor(0, 0, 60);
1046 $title = $outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1047 $pdf->MultiCell(100, 3, $title,
'',
'R');
1052 $pdf->SetFont(
'',
'B', $default_font_size);
1053 $pdf->SetXY($posx, $posy);
1054 $pdf->SetTextColor(0, 0, 60);
1055 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1059 $pdf->SetFont(
'',
'', $default_font_size - 1);
1062 if (!empty(
$object->project->ref)) {
1064 $pdf->SetXY($posx, $posy);
1065 $pdf->SetTextColor(0, 0, 60);
1066 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1072 if (!empty(
$object->project->ref)) {
1073 $outputlangs->load(
"projects");
1075 $pdf->SetXY($posx, $posy);
1076 $langs->load(
"projects");
1077 $pdf->SetTextColor(0, 0, 60);
1078 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1082 if (!empty(
$object->date_start_planned)) {
1084 $pdf->SetXY($posx, $posy);
1085 $pdf->SetTextColor(0, 0, 60);
1086 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"MoDate").
" : ".
dol_print_date(
$object->date_start_planned,
"day",
false, $outputlangs,
true),
'',
'R');
1089 $pdf->SetXY($posx, $posy);
1090 $pdf->SetTextColor(255, 0, 0);
1091 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ToApprove"),
'',
'R');
1095 $prodToMake =
new Product($this->db);
1096 $resProdToMake = $prodToMake->fetch(
$object->fk_product);
1098 if ($resProdToMake > 0) {
1101 $pdf->SetFont(
'',
'B', $default_font_size + 1);
1102 $pdf->SetXY($posx, $posy);
1103 $pdf->SetTextColor(0, 0, 60);
1104 $pdf->MultiCell($w, 3, $prodToMake->ref,
'',
'R');
1108 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1109 $pdf->SetXY($posx, $posy);
1110 $pdf->SetTextColor(0, 0, 60);
1111 $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description),
'',
'R',
false, 1,
'',
'',
true, 0,
false,
true, 51,
'T',
true);
1112 $posy = $pdf->GetY() - 5;
1115 $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height));
1116 $dim = implode(
"x", $array);
1119 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1120 $pdf->SetXY($posx, $posy);
1121 $pdf->SetTextColor(0, 0, 60);
1122 $pdf->MultiCell($w, 3, $dim,
'',
'R');
1127 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1128 $pdf->SetXY($posx, $posy);
1129 $pdf->SetTextColor(0, 0, 60);
1130 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"QtyToProduce").
": " .$object->qty,
'',
'R');
1133 $pdf->SetTextColor(0, 0, 60);
1134 $usehourmin =
'day';
1136 $usehourmin =
'dayhour';
1138 if (!empty(
$object->delivery_date)) {
1140 $pdf->SetXY($posx - 90, $posy);
1141 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1144 if (
$object->thirdparty->code_fournisseur) {
1146 $pdf->SetXY($posx, $posy);
1147 $pdf->SetTextColor(0, 0, 60);
1148 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1153 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1154 if (count($arrayidcontact) > 0) {
1155 $usertmp =
new User($this->db);
1156 $usertmp->fetch($arrayidcontact[0]);
1158 $pdf->SetXY($posx, $posy);
1159 $pdf->SetTextColor(0, 0, 60);
1160 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1165 $pdf->SetTextColor(0, 0, 60);
1169 $current_y = $pdf->getY();
1171 if ($current_y < $pdf->getY()) {
1172 $top_shift = $pdf->getY() - $current_y;
1177 $carac_emetteur =
'';
1179 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1180 if (count($arrayidcontact) > 0) {
1181 $object->fetch_user($arrayidcontact[0]);
1182 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1183 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1185 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1189 $carac_emetteur .=
"\n";
1195 $posy = 42 + $top_shift;
1196 $posx = $this->marge_gauche;
1198 $posx = $this->page_largeur - $this->marge_droite - 80;
1203 $pdf->SetTextColor(0, 0, 0);
1204 $pdf->SetFont(
'',
'', $default_font_size - 2);
1205 $pdf->SetXY($posx, $posy - 5);
1206 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1207 $pdf->SetXY($posx, $posy);
1208 $pdf->SetFillColor(230, 230, 230);
1209 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1210 $pdf->SetTextColor(0, 0, 60);
1213 $pdf->SetXY($posx + 2, $posy + 3);
1214 $pdf->SetFont(
'',
'B', $default_font_size);
1215 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1216 $posy = $pdf->getY();
1219 $pdf->SetXY($posx + 2, $posy);
1220 $pdf->SetFont(
'',
'', $default_font_size - 1);
1221 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1226 $usecontact =
false;
1227 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1228 if (count($arrayidcontact) > 0) {
1230 $result =
$object->fetch_contact($arrayidcontact[0]);
1234 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')))) {
1235 $thirdparty =
$object->contact;
1237 $thirdparty =
$object->thirdparty;