32 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mrp/modules_mo.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
64 public $update_main_doc_field;
75 public $version =
'dolibarr';
85 global $langs, $mysoc;
88 $langs->loadLangs(array(
"main",
"bills",
"mrp"));
91 $this->
name =
"vinci";
92 $this->
description = $langs->trans(
'DocumentModelStandardPDF');
93 $this->update_main_doc_field = 1;
98 $this->page_largeur = $formatarray[
'width'];
99 $this->page_hauteur = $formatarray[
'height'];
100 $this->format = array($this->page_largeur, $this->page_hauteur);
106 $this->option_logo = 1;
107 $this->option_multilang = 1;
108 $this->option_escompte = 0;
109 $this->option_credit_note = 0;
110 $this->option_freetext = 1;
111 $this->option_draft_watermark = 1;
114 $this->emetteur = $mysoc;
115 if (empty($this->emetteur->country_code)) {
116 $this->emetteur->country_code = substr($langs->defaultlang, -2);
120 $this->posxdesc = $this->marge_gauche + 1;
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);
172 $realpatharray = array();
174 if ($conf->mrp->dir_output) {
178 $amount_credit_notes_included = 0;
179 $amount_deposits_included = 0;
185 $dir = $conf->mrp->dir_output;
186 $file = $dir.
"/SPECIMEN.pdf";
189 $dir = $conf->mrp->dir_output.
'/'.$objectref;
190 $file = $dir.
"/".$objectref.
".pdf";
193 if (!file_exists($dir)) {
195 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
200 if (file_exists($dir)) {
202 if (!is_object($hookmanager)) {
203 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
206 $hookmanager->initHooks(array(
'pdfgeneration'));
207 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
209 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
211 $nblines = count(
$object->lines);
215 $heightforinfotot = 50;
216 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
217 $heightforfooter = $this->marge_basse + 8;
219 $heightforfooter += 6;
221 $pdf->SetAutoPageBreak(1, 0);
223 if (class_exists(
'TCPDF')) {
224 $pdf->setPrintHeader(
false);
225 $pdf->setPrintFooter(
false);
230 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
231 $tplidx = $pdf->importPage(1);
236 $pdf->SetDrawColor(128, 128, 128);
238 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
239 $pdf->SetSubject($outputlangs->transnoentities(
"ManufacturingOrder"));
240 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
241 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
242 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
244 $pdf->SetCompression(
false);
248 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
254 if (!empty($tplidx)) {
255 $pdf->useTemplate($tplidx);
259 $pdf->SetFont(
'',
'', $default_font_size - 1);
260 $pdf->MultiCell(0, 3,
'');
261 $pdf->SetTextColor(0, 0, 0);
263 $tab_top = 90 + $top_shift;
264 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
266 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
270 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
273 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
274 if (!empty($extranote)) {
278 $pagenb = $pdf->getPage();
280 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
281 $pageposbeforenote = $pagenb;
290 $pdf->startTransaction();
292 $pdf->SetFont(
'',
'', $default_font_size - 1);
293 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
295 $pageposafternote = $pdf->getPage();
296 $posyafter = $pdf->GetY();
298 if ($pageposafternote > $pageposbeforenote) {
299 $pdf->rollbackTransaction(
true);
302 while ($pagenb < $pageposafternote) {
305 if (!empty($tplidx)) {
306 $pdf->useTemplate($tplidx);
312 $pdf->setTopMargin($tab_top_newpage);
314 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
318 $pdf->setPage($pageposbeforenote);
319 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
320 $pdf->SetFont(
'',
'', $default_font_size - 1);
321 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
322 $pageposafternote = $pdf->getPage();
324 $posyafter = $pdf->GetY();
326 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
327 $pdf->AddPage(
'',
'',
true);
330 $pdf->setPage($pageposafternote);
331 $pdf->setTopMargin($tab_top_newpage);
333 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
339 $i = $pageposbeforenote;
340 while ($i < $pageposafternote) {
344 $pdf->SetDrawColor(128, 128, 128);
346 if ($i > $pageposbeforenote) {
347 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
348 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
350 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
351 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
355 $pdf->setPageOrientation(
'', 1, 0);
362 $pdf->setPage($pageposafternote);
363 if (!empty($tplidx)) {
364 $pdf->useTemplate($tplidx);
369 $height_note = $posyafter - $tab_top_newpage;
370 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
373 $pdf->commitTransaction();
374 $posyafter = $pdf->GetY();
375 $height_note = $posyafter - $tab_top;
376 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
379 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
381 $pdf->AddPage(
'',
'',
true);
384 $pdf->setPage($pageposafternote);
385 if (!empty($tplidx)) {
386 $pdf->useTemplate($tplidx);
392 $posyafter = $tab_top_newpage;
396 $tab_height = $tab_height - $height_note;
397 $tab_top = $posyafter + 6;
402 $nexY = $tab_top + 5;
408 $pageposbeforeprintlines = $pdf->getPage();
409 $pagenb = $pageposbeforeprintlines;
411 $bom =
new BOM($this->db);
412 $bom -> fetch(
$object->fk_bom);
414 $nblines = count($bom->lines);
416 for ($i = 0; $i < $nblines; $i++) {
418 $pdf->SetFont(
'',
'', $default_font_size - 1);
419 $pdf->SetTextColor(0, 0, 0);
421 $prod =
new Product($this->db);
422 $prod->fetch($bom->lines[$i]->fk_product);
425 $imglinesize = array();
426 if (!empty($realpatharray[$i])) {
430 $pdf->setTopMargin($tab_top_newpage);
431 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
432 $pageposbefore = $pdf->getPage();
434 $showpricebeforepagebreak = 1;
436 $posYAfterDescription = 0;
439 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
440 $pdf->AddPage(
'',
'',
true);
441 if (!empty($tplidx)) {
442 $pdf->useTemplate($tplidx);
447 $pdf->setPage($pageposbefore + 1);
449 $curY = $tab_top_newpage;
453 $showpricebeforepagebreak = 1;
455 $showpricebeforepagebreak = 0;
459 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
460 $curX = $this->posxpicture - 1;
461 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
463 $posYAfterImage = $curY + $imglinesize[
'height'];
466 $curX = $this->posxdesc - 1;
467 $showpricebeforepagebreak = 1;
470 $pdf->startTransaction();
474 $pageposafter = $pdf->getPage();
475 $posyafter = $pdf->GetY();
476 if ($pageposafter > $pageposbefore) {
477 $pdf->rollbackTransaction(
true);
482 $pageposafter = $pdf->getPage();
483 $posyafter = $pdf->GetY();
484 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
485 if ($i == ($nblines - 1)) {
486 $pdf->AddPage(
'',
'',
true);
487 if (!empty($tplidx)) {
488 $pdf->useTemplate($tplidx);
491 $pdf->setPage($pageposafter + 1);
496 $showpricebeforepagebreak = 1;
498 $showpricebeforepagebreak = 0;
502 $pdf->commitTransaction();
504 $posYAfterDescription = $pdf->GetY();
507 $nexY = $pdf->GetY();
508 $pageposafter = $pdf->getPage();
509 $pdf->setPage($pageposbefore);
510 $pdf->setTopMargin($this->marge_haute);
511 $pdf->setPageOrientation(
'', 1, 0);
514 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
515 $pdf->setPage($pageposafter);
516 $curY = $tab_top_newpage;
520 $pdf->startTransaction();
526 $pageposafter = $pdf->getPage();
527 $posyafter = $pdf->GetY();
528 if ($pageposafter > $pageposbefore) {
529 $pdf->rollbackTransaction(
true);
533 $pageposafter = $pdf->getPage();
534 $posyafter = $pdf->GetY();
535 } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
536 if ($i == ($nblines - 1)) {
537 $pdf->AddPage(
'',
'',
true);
538 if (!empty($tplidx)) {
539 $pdf->useTemplate($tplidx);
542 $pdf->setPage($pageposafter + 1);
547 $showpricebeforepagebreak = 1;
549 $showpricebeforepagebreak = 0;
553 $pdf->commitTransaction();
555 $posYAfterDescription = max($posYAfterDescription, $pdf->GetY());
558 $nexY = max($nexY, $pdf->GetY());
559 $pageposafter = $pdf->getPage();
560 $pdf->setPage($pageposbefore);
561 $pdf->setTopMargin($this->marge_haute);
562 $pdf->setPageOrientation(
'', 1, 0);
565 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
566 $pdf->setPage($pageposafter);
567 $curY = $tab_top_newpage;
570 $pdf->SetFont(
'',
'', $default_font_size - 1);
575 $qty = $bom->lines[$i]->qty;
577 $nexY = max($pdf->GetY(), $nexY);
583 $qtytot =
$object->qty * $bom->lines[$i]->qty;
585 $nexY = max($pdf->GetY(), $nexY);
590 $array = array_filter(array($prod->length, $prod->width, $prod->height));
591 $dim = implode(
"x", $array);
593 $nexY = max($pdf->GetY(), $nexY);
601 if ($pagenb == $pageposbeforeprintlines) {
602 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
603 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
605 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
606 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
616 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
622 if (method_exists($pdf,
'AliasNbPages')) {
623 $pdf->AliasNbPages();
628 $pdf->Output($file,
'F');
631 $hookmanager->initHooks(array(
'pdfgeneration'));
632 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
634 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
636 $this->error = $hookmanager->error;
637 $this->errors = $hookmanager->errors;
642 $this->result = array(
'fullpath' => $file);
646 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
650 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
686 global $conf, $mysoc;
690 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
691 $pdf->SetFont(
'',
'B', $default_font_size - 2);
692 $pdf->SetXY($this->marge_gauche, $posy);
693 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
695 $posy = $pdf->GetY() + 4;
701 if (!empty(
$object->cond_reglement_code) ||
$object->cond_reglement) {
702 $pdf->SetFont(
'',
'B', $default_font_size - 2);
703 $pdf->SetXY($this->marge_gauche, $posy);
704 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
705 $pdf->MultiCell(80, 4, $titre, 0,
'L');
707 $pdf->SetFont(
'',
'', $default_font_size - 2);
708 $pdf->SetXY($posxval, $posy);
709 $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);
710 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
711 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
713 $posy = $pdf->GetY() + 3;
717 if (!empty(
$object->mode_reglement_code)) {
718 $pdf->SetFont(
'',
'B', $default_font_size - 2);
719 $pdf->SetXY($this->marge_gauche, $posy);
720 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
721 $pdf->MultiCell(80, 5, $titre, 0,
'L');
723 $pdf->SetFont(
'',
'', $default_font_size - 2);
724 $pdf->SetXY($posxval, $posy);
725 $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);
726 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
728 $posy = $pdf->GetY() + 2;
750 global $conf, $mysoc;
756 $pdf->SetFont(
'',
'', $default_font_size - 1);
761 if ($this->page_largeur < 210) {
764 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
770 $pdf->SetFillColor(255, 255, 255);
771 $pdf->SetXY($col1x, $tab2_top);
772 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
775 $pdf->SetXY($col2x, $tab2_top);
776 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
779 $pdf->SetFillColor(248, 248, 248);
781 $this->atleastoneratenotnull = 0;
782 foreach ($this->tva as $tvakey => $tvaval) {
784 $this->atleastoneratenotnull++;
787 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
791 if (preg_match(
'/\*/', $tvakey)) {
792 $tvakey = str_replace(
'*',
'', $tvakey);
793 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
796 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
797 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
798 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
800 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
801 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
804 if (!$this->atleastoneratenotnull) {
806 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
807 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
809 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
810 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
815 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
816 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
817 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
818 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
824 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
825 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
826 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
827 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
833 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
834 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
838 foreach ($localtax_rate as $tvakey => $tvaval) {
843 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
846 if (preg_match(
'/\*/', $tvakey)) {
847 $tvakey = str_replace(
'*',
'', $tvakey);
848 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
850 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
851 $totalvat .=
vatrate(abs((
float) $tvakey), 1).$tvacompl;
852 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
854 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
855 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
863 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
864 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
868 foreach ($localtax_rate as $tvakey => $tvaval) {
873 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
876 if (preg_match(
'/\*/', $tvakey)) {
877 $tvakey = str_replace(
'*',
'', $tvakey);
878 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
880 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
881 $totalvat .=
vatrate(abs((
float) $tvakey), 1).$tvacompl;
882 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
884 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
885 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
893 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
894 $pdf->SetTextColor(0, 0, 60);
895 $pdf->SetFillColor(224, 224, 224);
896 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
899 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
900 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
901 $pdf->SetFont(
'',
'', $default_font_size - 1);
902 $pdf->SetTextColor(0, 0, 0);
904 $creditnoteamount = 0;
909 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
914 if ($deja_regle > 0) {
918 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
919 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
920 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
921 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
924 $pdf->SetTextColor(0, 0, 60);
925 $pdf->SetFillColor(224, 224, 224);
926 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
927 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
929 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
930 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
932 $pdf->SetFont(
'',
'', $default_font_size - 1);
933 $pdf->SetTextColor(0, 0, 0);
937 return ($tab2_top + ($tab2_hl * $index));
954 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
964 $currency = !empty($currency) ? $currency : $conf->currency;
968 $pdf->SetTextColor(0, 0, 0);
969 $pdf->SetFont(
'',
'', $default_font_size - 2);
971 if (empty($hidetop)) {
974 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($title) + 3), $tab_top - 4);
975 $pdf->MultiCell(($pdf->GetStringWidth($title) + 3), 2, $title);
979 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
983 $pdf->SetDrawColor(128, 128, 128);
984 $pdf->SetFont(
'',
'', $default_font_size - 1);
987 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
989 foreach ($this->cols as $colKey => $colDef) {
995 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
998 if (!empty($colDef[
'border-left'])) {
999 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1002 if (empty($hidetop) && array_key_exists(
'title', $colDef) && array_key_exists(
'width', $colDef)) {
1003 $pdf->SetXY($colDef[
'xStartPos'] + $colDef[
'title'][
'padding'][3], $tab_top + $colDef[
'title'][
'padding'][0]);
1005 $textWidth = $colDef[
'width'] - $colDef[
'title'][
'padding'][3] - $colDef[
'title'][
'padding'][1];
1006 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $colDef[
'title'][
'align']);
1010 if (empty($hidetop)) {
1011 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1027 global $langs, $conf, $mysoc;
1029 $ltrdirection =
'L';
1030 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1031 $ltrdirection =
'R';
1035 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings",
"mrp"));
1049 $pdf->SetTextColor(0, 0, 60);
1050 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1052 $posx = $this->page_largeur - $this->marge_droite - 100;
1053 $posy = $this->marge_haute;
1056 $pdf->SetXY($this->marge_gauche, $posy);
1059 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
1060 if ($this->emetteur->logo) {
1061 if (is_readable($logo)) {
1063 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1065 $pdf->SetTextColor(200, 0, 0);
1066 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1067 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1068 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
1071 $text = $this->emetteur->name;
1072 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1075 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1076 $pdf->SetXY($posx, $posy);
1077 $pdf->SetTextColor(0, 0, 60);
1078 $title = $outputlangs->transnoentities(
"ManufacturingOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1079 $pdf->MultiCell(100, 3, $title,
'',
'R');
1084 $pdf->SetFont(
'',
'B', $default_font_size);
1085 $pdf->SetXY($posx, $posy);
1086 $pdf->SetTextColor(0, 0, 60);
1087 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1091 $pdf->SetFont(
'',
'', $default_font_size - 1);
1094 if (!empty(
$object->project->ref)) {
1096 $pdf->SetXY($posx, $posy);
1097 $pdf->SetTextColor(0, 0, 60);
1098 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1104 if (!empty(
$object->project->ref)) {
1105 $outputlangs->load(
"projects");
1107 $pdf->SetXY($posx, $posy);
1108 $langs->load(
"projects");
1109 $pdf->SetTextColor(0, 0, 60);
1110 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1114 if (!empty(
$object->date_approve)) {
1116 $pdf->SetXY($posx, $posy);
1117 $pdf->SetTextColor(0, 0, 60);
1118 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"MoDate").
" : ".
dol_print_date(
$object->date_approve,
"day",
false, $outputlangs,
true),
'',
'R');
1121 $pdf->SetXY($posx, $posy);
1122 $pdf->SetTextColor(255, 0, 0);
1123 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ToApprove"),
'',
'R');
1127 $prodToMake =
new Product($this->db);
1128 $resProdToMake = $prodToMake->fetch(
$object->fk_product);
1130 if ($resProdToMake > 0) {
1133 $pdf->SetFont(
'',
'B', $default_font_size + 1);
1134 $pdf->SetXY($posx, $posy);
1135 $pdf->SetTextColor(0, 0, 60);
1136 $pdf->MultiCell($w, 3, $prodToMake->ref,
'',
'R');
1140 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1141 $pdf->SetXY($posx, $posy);
1142 $pdf->SetTextColor(0, 0, 60);
1143 $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description),
'',
'R',
false, 1,
'',
'',
true, 0,
false,
true, 51,
'T',
true);
1144 $posy = $pdf->GetY() - 5;
1147 $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height));
1148 $dim = implode(
"x", $array);
1151 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1152 $pdf->SetXY($posx, $posy);
1153 $pdf->SetTextColor(0, 0, 60);
1154 $pdf->MultiCell($w, 3, $dim,
'',
'R');
1159 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1160 $pdf->SetXY($posx, $posy);
1161 $pdf->SetTextColor(0, 0, 60);
1162 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"QtyToProduce").
": " .$object->qty,
'',
'R');
1165 $pdf->SetTextColor(0, 0, 60);
1166 $usehourmin =
'day';
1168 $usehourmin =
'dayhour';
1170 if (!empty(
$object->delivery_date)) {
1172 $pdf->SetXY($posx - 90, $posy);
1173 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1176 if (
$object->thirdparty->code_fournisseur) {
1178 $pdf->SetXY($posx, $posy);
1179 $pdf->SetTextColor(0, 0, 60);
1180 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1185 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1186 if (count($arrayidcontact) > 0) {
1187 $usertmp =
new User($this->db);
1188 $usertmp->fetch($arrayidcontact[0]);
1190 $pdf->SetXY($posx, $posy);
1191 $pdf->SetTextColor(0, 0, 60);
1192 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1197 $pdf->SetTextColor(0, 0, 60);
1201 $current_y = $pdf->getY();
1203 if ($current_y < $pdf->getY()) {
1204 $top_shift = $pdf->getY() - $current_y;
1209 $carac_emetteur =
'';
1211 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1212 if (count($arrayidcontact) > 0) {
1213 $object->fetch_user($arrayidcontact[0]);
1214 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1215 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1217 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1221 $carac_emetteur .=
"\n";
1227 $posy = 42 + $top_shift;
1228 $posx = $this->marge_gauche;
1230 $posx = $this->page_largeur - $this->marge_droite - 80;
1235 $pdf->SetTextColor(0, 0, 0);
1236 $pdf->SetFont(
'',
'', $default_font_size - 2);
1237 $pdf->SetXY($posx, $posy - 5);
1238 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1239 $pdf->SetXY($posx, $posy);
1240 $pdf->SetFillColor(230, 230, 230);
1241 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1242 $pdf->SetTextColor(0, 0, 60);
1245 $pdf->SetXY($posx + 2, $posy + 3);
1246 $pdf->SetFont(
'',
'B', $default_font_size);
1247 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1248 $posy = $pdf->getY();
1251 $pdf->SetXY($posx + 2, $posy);
1252 $pdf->SetFont(
'',
'', $default_font_size - 1);
1253 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1258 $usecontact =
false;
1259 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1260 if (count($arrayidcontact) > 0) {
1262 $result =
$object->fetch_contact($arrayidcontact[0]);
1266 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')))) {
1267 $thirdparty =
$object->contact;
1269 $thirdparty =
$object->thirdparty;
1322 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1323 return pdf_pagefoot($pdf, $outputlangs,
'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur,
$object, $showdetails, $hidefreetext);
1339 global $conf, $hookmanager;
1342 $this->defaultContentsFieldsStyle = array(
1344 'padding' => array(1, 0.5, 1, 0.5),
1348 $this->defaultTitlesFieldsStyle = array(
1350 'padding' => array(0.5, 0, 0.5, 0),
1371 $this->cols[
'code'] = array(
1378 'border-left' =>
true,
1382 $this->cols[
'desc'] = array(
1387 'textkey' =>
'Designation',
1391 'padding' => array(0.5, 1, 0.5, 1.5),
1393 'border-left' =>
true,
1396 'padding' => array(1, 0.5, 1, 1.5),
1401 $this->cols[
'photo'] = array(
1406 'textkey' =>
'Photo',
1410 'padding' => array(0, 0, 0, 0),
1412 'border-left' =>
false,
1416 $this->cols[
'photo'][
'status'] =
true;
1420 $this->cols[
'dim'] = array(
1425 'textkey' =>
'Dimensions'
1427 'border-left' =>
true,
1431 $this->cols[
'qty'] = array(
1438 'border-left' =>
true,
1442 $this->cols[
'qtytot'] = array(
1447 'textkey' =>
'QtyTot'
1449 'border-left' =>
true,
1454 $line = reset(
$object->lines);
1458 $parameters = array(
1460 'outputlangs' => $outputlangs,
1461 'hidedetails' => $hidedetails,
1462 'hidedesc' => $hidedesc,
1463 'hideref' => $hideref
1466 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1469 } elseif (empty($reshook)) {
1471 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1473 $this->cols = $hookmanager->resArray;
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Parent class for mos models.
Class to manage products or services.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate the manufacturing orders with the vinci model.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
__construct($db)
Constructor.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
write_file($object, $outputlangs=null, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.