143 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
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(
true, 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->getAnonymisableFullName($outputlangs)));
246 $key_word=$outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"ManufacturingOrder");
247 if (isset(
$object->thirdparty->name) &&
$object->thirdparty->name !==
"") {
248 $key_word.=
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name);
250 $pdf->SetKeyWords($key_word);
252 $pdf->SetCompression(
false);
256 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
262 if (!empty($tplidx)) {
263 $pdf->useTemplate($tplidx);
267 $pdf->SetFont(
'',
'', $default_font_size - 1);
268 $pdf->MultiCell(0, 3,
'');
269 $pdf->SetTextColor(0, 0, 0);
271 $tab_top = 90 + $top_shift;
272 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
274 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
278 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
281 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
282 if (!empty($extranote)) {
286 $pagenb = $pdf->getPage();
288 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
289 $pageposbeforenote = $pagenb;
298 $pdf->startTransaction();
300 $pdf->SetFont(
'',
'', $default_font_size - 1);
301 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
303 $pageposafternote = $pdf->getPage();
304 $posyafter = $pdf->GetY();
306 if ($pageposafternote > $pageposbeforenote) {
307 $pdf->rollbackTransaction(
true);
310 while ($pagenb < $pageposafternote) {
313 if (!empty($tplidx)) {
314 $pdf->useTemplate($tplidx);
320 $pdf->setTopMargin($tab_top_newpage);
322 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
326 $pdf->setPage($pageposbeforenote);
327 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
328 $pdf->SetFont(
'',
'', $default_font_size - 1);
329 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
330 $pageposafternote = $pdf->getPage();
332 $posyafter = $pdf->GetY();
334 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
335 $pdf->AddPage(
'',
'',
true);
338 $pdf->setPage($pageposafternote);
339 $pdf->setTopMargin($tab_top_newpage);
341 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
347 $i = $pageposbeforenote;
348 while ($i < $pageposafternote) {
351 $pdf->SetDrawColor(128, 128, 128);
353 if ($i > $pageposbeforenote) {
354 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
355 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
357 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
358 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
362 $pdf->setPageOrientation(
'',
true, 0);
369 $pdf->setPage($pageposafternote);
370 if (!empty($tplidx)) {
371 $pdf->useTemplate($tplidx);
376 $height_note = $posyafter - $tab_top_newpage;
377 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
380 $pdf->commitTransaction();
381 $posyafter = $pdf->GetY();
382 $height_note = $posyafter - $tab_top;
383 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
386 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
388 $pdf->AddPage(
'',
'',
true);
391 $pdf->setPage($pageposafternote);
392 if (!empty($tplidx)) {
393 $pdf->useTemplate($tplidx);
399 $posyafter = $tab_top_newpage;
403 $tab_height -= $height_note;
404 $tab_top = $posyafter + 6;
409 $nexY = $tab_top + 5;
415 $pageposbeforeprintlines = $pdf->getPage();
416 $pagenb = $pageposbeforeprintlines;
418 $bom =
new BOM($this->db);
419 $bom -> fetch(
$object->fk_bom);
421 $nblines = count($bom->lines);
423 for ($i = 0; $i < $nblines; $i++) {
425 $pdf->SetFont(
'',
'', $default_font_size - 1);
426 $pdf->SetTextColor(0, 0, 0);
429 $prod->fetch($bom->lines[$i]->fk_product);
431 $pdf->setTopMargin($tab_top_newpage);
432 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
433 $pageposbefore = $pdf->getPage();
435 $showpricebeforepagebreak = 1;
437 $posYAfterDescription = 0;
440 $curX = $this->posxdesc - 1;
441 $showpricebeforepagebreak = 1;
444 $pdf->startTransaction();
448 $pageposafter = $pdf->getPage();
449 $posyafter = $pdf->GetY();
450 if ($pageposafter > $pageposbefore) {
451 $pdf->rollbackTransaction(
true);
456 $pageposafter = $pdf->getPage();
457 $posyafter = $pdf->GetY();
458 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
459 if ($i == ($nblines - 1)) {
460 $pdf->AddPage(
'',
'',
true);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
465 $pdf->setPage($pageposafter + 1);
470 $showpricebeforepagebreak = 1;
472 $showpricebeforepagebreak = 0;
476 $pdf->commitTransaction();
478 $posYAfterDescription = $pdf->GetY();
481 $nexY = $pdf->GetY();
482 $pageposafter = $pdf->getPage();
483 $pdf->setPage($pageposbefore);
484 $pdf->setTopMargin($this->marge_haute);
485 $pdf->setPageOrientation(
'',
true, 0);
488 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
489 $pdf->setPage($pageposafter);
490 $curY = $tab_top_newpage;
494 $pdf->startTransaction();
500 $pageposafter = $pdf->getPage();
501 $posyafter = $pdf->GetY();
502 if ($pageposafter > $pageposbefore) {
503 $pdf->rollbackTransaction(
true);
507 $pageposafter = $pdf->getPage();
508 $posyafter = $pdf->GetY();
509 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
510 if ($i == ($nblines - 1)) {
511 $pdf->AddPage(
'',
'',
true);
512 if (!empty($tplidx)) {
513 $pdf->useTemplate($tplidx);
516 $pdf->setPage($pageposafter + 1);
521 $showpricebeforepagebreak = 1;
523 $showpricebeforepagebreak = 0;
527 $pdf->commitTransaction();
529 $posYAfterDescription = max($posYAfterDescription, $pdf->GetY());
532 $nexY = max($nexY, $pdf->GetY());
533 $pageposafter = $pdf->getPage();
534 $pdf->setPage($pageposbefore);
535 $pdf->setTopMargin($this->marge_haute);
536 $pdf->setPageOrientation(
'',
true, 0);
539 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
540 $pdf->setPage($pageposafter);
541 $curY = $tab_top_newpage;
544 $pdf->SetFont(
'',
'', $default_font_size - 1);
549 $qty = $bom->lines[$i]->qty;
551 $nexY = max($pdf->GetY(), $nexY);
557 $qtytot =
$object->qty * $bom->lines[$i]->qty;
559 $nexY = max($pdf->GetY(), $nexY);
564 $array = array_filter(array(
$prod->length,
$prod->width,
$prod->height));
565 $dim = implode(
"x", $array);
567 $nexY = max($pdf->GetY(), $nexY);
573 if ($pagenb == $pageposbeforeprintlines) {
574 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
575 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
577 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
578 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
588 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
594 if (method_exists($pdf,
'AliasNbPages')) {
595 $pdf->AliasNbPages();
600 $pdf->Output($file,
'F');
603 $hookmanager->initHooks(array(
'pdfgeneration'));
604 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
606 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
607 $this->warnings = $hookmanager->warnings;
609 $this->error = $hookmanager->error;
610 $this->errors = $hookmanager->errors;
617 $this->result = array(
'fullpath' => $file);
621 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
625 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
665 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
666 $pdf->SetFont(
'',
'B', $default_font_size - 2);
667 $pdf->SetXY($this->marge_gauche, $posy);
668 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
670 $posy = $pdf->GetY() + 4;
676 if (!empty(
$object->cond_reglement_code) ||
$object->cond_reglement) {
677 $pdf->SetFont(
'',
'B', $default_font_size - 2);
678 $pdf->SetXY($this->marge_gauche, $posy);
679 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
680 $pdf->MultiCell(80, 4, $titre, 0,
'L');
682 $pdf->SetFont(
'',
'', $default_font_size - 2);
683 $pdf->SetXY($posxval, $posy);
684 $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);
685 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
686 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
688 $posy = $pdf->GetY() + 3;
692 if (!empty(
$object->mode_reglement_code)) {
693 $pdf->SetFont(
'',
'B', $default_font_size - 2);
694 $pdf->SetXY($this->marge_gauche, $posy);
695 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
696 $pdf->MultiCell(80, 5, $titre, 0,
'L');
698 $pdf->SetFont(
'',
'', $default_font_size - 2);
699 $pdf->SetXY($posxval, $posy);
700 $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);
701 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
703 $posy = $pdf->GetY() + 2;
731 $pdf->SetFont(
'',
'', $default_font_size - 1);
736 if ($this->page_largeur < 210) {
739 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
745 $pdf->SetFillColor(255, 255, 255);
746 $pdf->SetXY($col1x, $tab2_top);
747 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
750 $pdf->SetXY($col2x, $tab2_top);
751 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R',
true);
754 $pdf->SetFillColor(248, 248, 248);
756 $this->atleastoneratenotnull = 0;
757 foreach ($this->tva as $tvakey => $tvaval) {
759 $this->atleastoneratenotnull++;
762 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
766 if (preg_match(
'/\*/', $tvakey)) {
767 $tvakey = str_replace(
'*',
'', $tvakey);
768 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
771 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
772 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
773 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
775 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
776 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
779 if (!$this->atleastoneratenotnull) {
781 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
782 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code), 0,
'L',
true);
784 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
785 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R',
true);
790 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
791 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code), 0,
'L',
true);
792 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
793 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R',
true);
799 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
800 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code), 0,
'L',
true);
801 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
802 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R',
true);
808 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
809 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
813 foreach ($localtax_rate as $tvakey => $tvaval) {
818 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
821 if (preg_match(
'/\*/', $tvakey)) {
822 $tvakey = str_replace(
'*',
'', $tvakey);
823 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
825 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
826 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
827 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
829 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
830 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
838 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
839 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
843 foreach ($localtax_rate as $tvakey => $tvaval) {
848 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
851 if (preg_match(
'/\*/', $tvakey)) {
852 $tvakey = str_replace(
'*',
'', $tvakey);
853 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
855 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
856 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
857 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
859 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
860 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
868 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
869 $pdf->SetTextColor(0, 0, 60);
870 $pdf->SetFillColor(224, 224, 224);
871 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
874 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
875 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R',
true);
876 $pdf->SetFont(
'',
'', $default_font_size - 1);
877 $pdf->SetTextColor(0, 0, 0);
879 $creditnoteamount = 0;
884 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
889 if ($deja_regle > 0) {
893 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
894 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
895 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
896 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R',
false);
899 $pdf->SetTextColor(0, 0, 60);
900 $pdf->SetFillColor(224, 224, 224);
901 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
902 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
904 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
905 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R',
true);
907 $pdf->SetFont(
'',
'', $default_font_size - 1);
908 $pdf->SetTextColor(0, 0, 0);
912 return ($tab2_top + ($tab2_hl * $index));
1004 $ltrdirection =
'L';
1005 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1006 $ltrdirection =
'R';
1010 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings",
"mrp"));
1024 $pdf->SetTextColor(0, 0, 60);
1025 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1027 $posx = $this->page_largeur - $this->marge_droite - 100;
1028 $posy = $this->marge_haute;
1031 $pdf->SetXY($this->marge_gauche, $posy);
1034 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
1035 if ($this->emetteur->logo) {
1036 if (is_readable($logo)) {
1038 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1040 $pdf->SetTextColor(200, 0, 0);
1041 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1042 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1043 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
1046 $text = $this->emetteur->name;
1047 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1050 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1051 $pdf->SetXY($posx, $posy);
1052 $pdf->SetTextColor(0, 0, 60);
1053 $title = $outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1054 $pdf->MultiCell(100, 3, $title,
'',
'R');
1059 $pdf->SetFont(
'',
'B', $default_font_size);
1060 $pdf->SetXY($posx, $posy);
1061 $pdf->SetTextColor(0, 0, 60);
1062 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1066 $pdf->SetFont(
'',
'', $default_font_size - 1);
1069 if (!empty(
$object->project->ref)) {
1071 $pdf->SetXY($posx, $posy);
1072 $pdf->SetTextColor(0, 0, 60);
1073 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1079 if (!empty(
$object->project->ref)) {
1080 $outputlangs->load(
"projects");
1082 $pdf->SetXY($posx, $posy);
1083 $langs->load(
"projects");
1084 $pdf->SetTextColor(0, 0, 60);
1085 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1089 if (!empty(
$object->date_start_planned)) {
1091 $pdf->SetXY($posx, $posy);
1092 $pdf->SetTextColor(0, 0, 60);
1093 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"MoDate").
" : ".
dol_print_date(
$object->date_start_planned,
"day",
false, $outputlangs,
true),
'',
'R');
1096 $pdf->SetXY($posx, $posy);
1097 $pdf->SetTextColor(255, 0, 0);
1098 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ToApprove"),
'',
'R');
1102 $prodToMake =
new Product($this->db);
1103 $resProdToMake = $prodToMake->fetch((
int)
$object->fk_product);
1105 if ($resProdToMake > 0) {
1108 $pdf->SetFont(
'',
'B', $default_font_size + 1);
1109 $pdf->SetXY($posx, $posy);
1110 $pdf->SetTextColor(0, 0, 60);
1111 $pdf->MultiCell($w, 3, $prodToMake->ref,
'',
'R');
1115 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1116 $pdf->SetXY($posx, $posy);
1117 $pdf->SetTextColor(0, 0, 60);
1118 $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description),
'',
'R',
false, 1,
null,
null,
true, 0,
false,
true, 51,
'T',
true);
1119 $posy = $pdf->GetY() - 5;
1122 $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height));
1123 $dim = implode(
"x", $array);
1126 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1127 $pdf->SetXY($posx, $posy);
1128 $pdf->SetTextColor(0, 0, 60);
1129 $pdf->MultiCell($w, 3, $dim,
'',
'R');
1134 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1135 $pdf->SetXY($posx, $posy);
1136 $pdf->SetTextColor(0, 0, 60);
1137 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"QtyToProduce").
": " .$object->qty,
'',
'R');
1140 $pdf->SetTextColor(0, 0, 60);
1141 $usehourmin =
'day';
1143 $usehourmin =
'dayhour';
1145 if (!empty(
$object->delivery_date)) {
1147 $pdf->SetXY($posx - 90, $posy);
1148 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1151 if (isset(
$object->thirdparty->code_fournisseur)) {
1153 $pdf->SetXY($posx, $posy);
1154 $pdf->SetTextColor(0, 0, 60);
1155 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_fournisseur),
'',
'R');
1160 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1161 if (count($arrayidcontact) > 0) {
1162 $usertmp =
new User($this->db);
1163 $usertmp->fetch($arrayidcontact[0]);
1165 $pdf->SetXY($posx, $posy);
1166 $pdf->SetTextColor(0, 0, 60);
1167 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1172 $pdf->SetTextColor(0, 0, 60);
1176 $current_y = $pdf->getY();
1178 if ($current_y < $pdf->getY()) {
1179 $top_shift = $pdf->getY() - $current_y;
1184 $carac_emetteur =
'';
1186 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1187 if (count($arrayidcontact) > 0) {
1188 $object->fetch_user($arrayidcontact[0]);
1189 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1190 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1192 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1196 $carac_emetteur .=
"\n";
1202 $posy = 42 + $top_shift;
1203 $posx = $this->marge_gauche;
1205 $posx = $this->page_largeur - $this->marge_droite - 80;
1210 $pdf->SetTextColor(0, 0, 0);
1211 $pdf->SetFont(
'',
'', $default_font_size - 2);
1212 $pdf->SetXY($posx, $posy - 5);
1213 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1214 $pdf->SetXY($posx, $posy);
1215 $pdf->SetFillColor(230, 230, 230);
1216 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1217 $pdf->SetTextColor(0, 0, 60);
1220 $pdf->SetXY($posx + 2, $posy + 3);
1221 $pdf->SetFont(
'',
'B', $default_font_size);
1222 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1223 $posy = $pdf->getY();
1226 $pdf->SetXY($posx + 2, $posy);
1227 $pdf->SetFont(
'',
'', $default_font_size - 1);
1228 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1233 $usecontact =
false;
1234 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1235 if (count($arrayidcontact) > 0) {
1237 $result =
$object->fetch_contact($arrayidcontact[0]);
1241 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')))) {
1242 $thirdparty =
$object->contact;
1244 $thirdparty =
$object->thirdparty;