27 require_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
28 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
65 public $phpmin = array(7, 0);
71 public $version =
'dolibarr';
89 public $tabTitleHeight;
99 global $conf, $langs, $mysoc;
102 $langs->loadLangs(array(
"main",
"companies"));
105 $this->
name =
"standard";
106 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
111 $this->page_largeur = $formatarray[
'width'];
112 $this->page_hauteur = $formatarray[
'height'];
113 $this->format = array($this->page_largeur, $this->page_hauteur);
119 $this->option_logo = 1;
120 $this->option_codestockservice = 0;
121 $this->option_multilang = 1;
122 $this->option_freetext = 0;
125 $this->emetteur = $mysoc;
126 if (!$this->emetteur->country_code) {
127 $this->emetteur->country_code = substr($langs->defaultlang, -2);
132 $this->posxdesc = $this->marge_gauche + 1;
133 $this->posxlabel = $this->posxdesc + $this->wref;
137 $this->posxunit = 135;
138 $this->posxdiscount = 155;
139 $this->postotalht = 175;
141 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
142 $this->posxtva = $this->posxup;
144 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
145 if ($this->page_largeur < 210) {
146 $this->posxpicture -= 20;
147 $this->posxtva -= 20;
149 $this->posxqty -= 20;
150 $this->posxunit -= 20;
151 $this->posxdiscount -= 20;
152 $this->postotalht -= 20;
155 $this->tabTitleHeight = 11;
171 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
174 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
176 if (!is_object($outputlangs)) {
177 $outputlangs = $langs;
180 if (!empty($conf->global->MAIN_USE_FPDF)) {
181 $outputlangs->charset_output =
'ISO-8859-1';
185 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
187 if ($conf->stock->dir_output) {
189 if ($object->specimen) {
190 $dir = $conf->stock->dir_output;
191 $file = $dir.
"/SPECIMEN.pdf";
194 $dir = $conf->stock->dir_output.
"/".$objectref;
195 $file = $dir.
"/".$objectref.
".pdf";
199 $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
200 $object->supplierprices = $supplierprices;
204 if (!file_exists($dir)) {
206 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
211 if (file_exists($dir)) {
213 if (!is_object($hookmanager)) {
214 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
217 $hookmanager->initHooks(array(
'pdfgeneration'));
218 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
220 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
225 $pdf->SetAutoPageBreak(1, 0);
227 $heightforinfotot = 40;
228 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
229 $heightforfooter = $this->marge_basse + 8;
230 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
231 $heightforfooter += 6;
234 if (class_exists(
'TCPDF')) {
235 $pdf->setPrintHeader(
false);
236 $pdf->setPrintFooter(
false);
240 if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
241 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
242 $tplidx = $pdf->importPage(1);
247 $pdf->SetDrawColor(128, 128, 128);
249 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
250 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
251 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
252 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
253 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset($object->label));
255 $pdf->SetCompression(
false);
258 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
263 if (!empty($tplidx)) {
264 $pdf->useTemplate($tplidx);
267 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
268 $pdf->SetFont(
'',
'', $default_font_size - 1);
269 $pdf->MultiCell(0, 3,
'');
270 $pdf->SetTextColor(0, 0, 0);
272 $tab_top = 65 + $top_shift;
273 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
275 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
281 $totalvalue = $totalvaluesell = 0;
283 $sortfield =
'p.ref';
286 $sql =
"SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,";
287 $sql .=
" ps.reel as value";
288 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
289 $sql .=
" WHERE ps.fk_product = p.rowid";
290 $sql .=
" AND ps.reel <> 0";
291 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
292 $sql .= $this->
db->order($sortfield, $sortorder);
295 $resql = $this->
db->query(
$sql);
297 $num = $this->
db->num_rows($resql);
301 $nexY = $tab_top + $this->tabTitleHeight;
303 for ($i = 0; $i < $nblines; $i++) {
306 $objp = $this->
db->fetch_object($resql);
310 $sql =
"SELECT label";
311 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
312 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
313 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
316 $result = $this->
db->query(
$sql);
318 $objtp = $this->
db->fetch_object($result);
319 if ($objtp->label !=
'') {
320 $objp->produit = $objtp->label;
325 $pdf->SetFont(
'',
'', $default_font_size - 1);
326 $pdf->SetTextColor(0, 0, 0);
328 $pdf->setTopMargin($tab_top_newpage);
329 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
330 $pageposbefore = $pdf->getPage();
333 $curX = $this->posxdesc - 1;
335 $showpricebeforepagebreak = 1;
337 $pdf->startTransaction();
338 $pdf->writeHTMLCell($this->wref, 3, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1,
false,
true,
'J',
true);
340 $pageposafter = $pdf->getPage();
341 if ($pageposafter > $pageposbefore) {
342 $pdf->rollbackTransaction(
true);
343 $pageposafter = $pageposbefore;
345 $pdf->setPageOrientation(
'', 1, $heightforfooter);
346 $pdf->writeHTMLCell($this->wref, 4, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1,
false,
true,
'J',
true);
348 $pageposafter = $pdf->getPage();
349 $posyafter = $pdf->GetY();
350 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
351 if ($i == ($nblines - 1)) {
352 $pdf->AddPage(
'',
'',
true);
353 if (!empty($tplidx)) {
354 $pdf->useTemplate($tplidx);
357 $this->
_pagehead($pdf, $object, 0, $outputlangs);
359 $pdf->setPage($pageposafter + 1);
365 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
366 $showpricebeforepagebreak = 1;
368 $showpricebeforepagebreak = 0;
373 $pdf->commitTransaction();
375 $posYAfterDescription = $pdf->GetY();
377 $nexY = $pdf->GetY();
378 $pageposafter = $pdf->getPage();
380 $pdf->setPage($pageposbefore);
381 $pdf->setTopMargin($this->marge_haute);
382 $pdf->setPageOrientation(
'', 1, 0);
385 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
386 $pdf->setPage($pageposafter);
387 $curY = $tab_top_newpage;
390 $pdf->SetFont(
'',
'', $default_font_size - 1);
392 $productstatic->id = $objp->rowid;
393 $productstatic->ref = $objp->ref;
394 $productstatic->label = $objp->produit;
395 $productstatic->type = $objp->type;
396 $productstatic->entity = $objp->entity;
397 $productstatic->status_batch = $objp->tobatch;
404 $pdf->SetXY($this->posxlabel + 0.8, $curY);
405 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 3,
dol_trunc($productstatic->label, 24), 0,
'L');
408 $valtoshow =
price2num($objp->value,
'MS');
409 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
411 $pdf->SetXY($this->posxqty, $curY);
412 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $towrite, 0,
'R');
415 $totalunit += $objp->value;
417 $pdf->SetXY($this->posxup, $curY);
418 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3,
price(
price2num($objp->ppmp,
'MU'), 0, $outputlangs), 0,
'R');
421 $pdf->SetXY($this->posxunit, $curY);
422 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3,
price(
price2num($objp->ppmp * $objp->value,
'MT'), 0, $outputlangs), 0,
'R');
423 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
426 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
427 $pricemin = $objp->price;
428 $pdf->SetXY($this->posxdiscount, $curY);
429 $pdf->MultiCell($this->postotalht - $this->posxdiscount, 3,
price(
price2num($pricemin,
'MU'), 0, $outputlangs), 0,
'R', 0);
432 $pdf->SetXY($this->postotalht, $curY);
433 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3,
price(
price2num($pricemin * $objp->value,
'MT'), 0, $outputlangs), 0,
'R', 0);
435 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
438 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
439 $pdf->setPage($pageposafter);
440 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
442 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
443 $pdf->SetLineStyle(array(
'dash'=>0));
449 while ($pagenb < $pageposafter) {
450 $pdf->setPage($pagenb);
452 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
454 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
456 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
458 $pdf->setPage($pagenb);
459 $pdf->setPageOrientation(
'', 1, 0);
461 $this->
_pagehead($pdf, $object, 0, $outputlangs);
463 if (!empty($tplidx)) {
464 $pdf->useTemplate($tplidx);
467 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
469 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
471 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
473 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
476 if (!empty($tplidx)) {
477 $pdf->useTemplate($tplidx);
481 $this->
_pagehead($pdf, $object, 0, $outputlangs);
486 $this->
db->free($resql);
496 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(200, 200, 200)));
497 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
498 $pdf->SetLineStyle(array(
'dash'=>0));
500 $pdf->SetFont(
'',
'B', $default_font_size - 1);
501 $pdf->SetTextColor(0, 0, 0);
504 $pdf->SetXY($this->posxdesc, $curY);
505 $pdf->MultiCell($this->wref, 3, $langs->trans(
"Total"), 0,
'L');
508 $valtoshow =
price2num($totalunit,
'MS');
509 $towrite = empty($valtoshow) ?
'0' : $valtoshow;
511 $pdf->SetXY($this->posxqty, $curY);
512 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $towrite, 0,
'R');
515 $pdf->SetXY($this->posxunit, $curY);
516 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3,
price(
price2num($totalvalue,
'MT'), 0, $outputlangs), 0,
'R');
519 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
521 $pdf->SetXY($this->postotalht, $curY);
522 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3,
price(
price2num($totalvaluesell,
'MT'), 0, $outputlangs), 0,
'R', 0);
530 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
540 $pdf->SetFont(
'',
'', $default_font_size - 1);
541 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
542 $nexY = $pdf->GetY();
543 $height_note = $nexY - $tab_top;
546 $pdf->SetDrawColor(192, 192, 192);
547 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
549 $tab_height = $tab_height - $height_note;
550 $tab_top = $nexY + 6;
563 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 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;
570 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
579 $this->
_pagefoot($pdf, $object, $outputlangs);
580 if (method_exists($pdf,
'AliasNbPages')) {
581 $pdf->AliasNbPages();
586 $pdf->Output($file,
'F');
589 $hookmanager->initHooks(array(
'pdfgeneration'));
590 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
592 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
594 $this->error = $hookmanager->error;
595 $this->errors = $hookmanager->errors;
600 $this->result = array(
'fullpath'=>$file);
604 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
608 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
627 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
637 $currency = !empty($currency) ? $currency : $conf->currency;
641 $pdf->SetTextColor(0, 0, 0);
642 $pdf->SetFont(
'',
'', $default_font_size - 2);
644 if (empty($hidetop)) {
645 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
646 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
647 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
650 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
651 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
655 $pdf->SetDrawColor(128, 128, 128);
657 $pdf->SetFont(
'',
'B', $default_font_size - 3);
660 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);
662 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(200, 200, 200)));
663 $pdf->SetDrawColor(200, 200, 200);
664 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
665 $pdf->SetLineStyle(array(
'dash'=>0));
666 $pdf->SetDrawColor(128, 128, 128);
667 $pdf->SetTextColor(0, 0, 0);
670 if (empty($hidetop)) {
671 $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
672 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
673 $pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
676 $pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
677 if (empty($hidetop)) {
678 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
679 $pdf->MultiCell($this->posxqty - $this->posxlabel - 1, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
682 $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
683 if (empty($hidetop)) {
684 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
685 $pdf->MultiCell($this->posxup - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Units"),
'',
'C');
688 $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
689 if (empty($hidetop)) {
690 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
691 $pdf->MultiCell($this->posxunit - $this->posxup - 1, 2, $outputlangs->transnoentities(
"AverageUnitPricePMPShort"),
'',
'C');
694 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
695 if (empty($hidetop)) {
696 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
697 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"EstimatedStockValueShort"),
'',
'C');
700 $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
701 if (empty($hidetop)) {
702 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
703 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"SellPriceMin"),
'',
'C');
706 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
707 if (empty($hidetop)) {
708 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
709 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"EstimatedStockValueSellShort"),
'',
'C');
712 if (empty($hidetop)) {
713 $pdf->SetDrawColor(200, 200, 200);
714 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(200, 200, 200)));
715 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
716 $pdf->SetLineStyle(array(
'dash' => 0));
731 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"")
733 global $conf, $langs, $db, $hookmanager;
736 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
740 if ($object->type == 1) {
741 $titlekey =
'ServiceSheet';
743 $titlekey =
'StockSheet';
749 if ($object->statut == 0 && (!empty($conf->global->STOCK_DRAFT_WATERMARK))) {
750 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->STOCK_DRAFT_WATERMARK);
753 $pdf->SetTextColor(0, 0, 60);
754 $pdf->SetFont(
'',
'B', $default_font_size + 3);
756 $posy = $this->marge_haute;
757 $posx = $this->page_largeur - $this->marge_droite - 100;
759 $pdf->SetXY($this->marge_gauche, $posy);
763 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
764 if ($this->emetteur->logo) {
765 if (is_readable($logo)) {
767 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
769 $pdf->SetTextColor(200, 0, 0);
770 $pdf->SetFont(
'',
'B', $default_font_size - 2);
771 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
772 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
775 $text = $this->emetteur->name;
776 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
779 $yafterleft = $pdf->GetY() + $height;
781 $pdf->SetFont(
'',
'B', $default_font_size + 3);
782 $pdf->SetXY($posx, $posy);
783 $pdf->SetTextColor(0, 0, 60);
785 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Warehouse").
' '.$outputlangs->convToOutputCharset($object->label),
'',
'R');
788 $pdf->SetFont(
'',
'', $default_font_size - 1);
789 $pdf->SetXY($posx, $posy);
790 $pdf->SetTextColor(0, 0, 60);
791 if (!empty($object->lieu)) {
792 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Label").
' : '.$object->lieu,
'',
'R');
797 $pdf->SetXY($posx, $posy);
798 $pdf->SetTextColor(0, 0, 60);
802 $hasparent = (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0);
805 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
808 $pdf->SetXY($posx - 50, $posy);
809 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
812 $yafterright = $pdf->GetY();
815 $nbpage = $pdf->getPage();
817 $nexY = max($yafterleft, $yafterright);
819 $pdf->SetXY($posx, $posy);
820 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br($object->description), 0, 1);
821 $nexY = $pdf->GetY();
823 $calcproductsunique = $object->nb_different_products();
824 $calcproducts = $object->nb_products();
827 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
828 $nexY = $pdf->GetY();
831 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
832 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
833 $nexY = $pdf->GetY();
836 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"EstimatedStockValueShort").
' : </b>'.
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
837 $nexY = $pdf->GetY();
840 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Date").
' : </b>'.
dol_print_date(
dol_now(),
'dayhour'), 0, 1);
841 $nexY = $pdf->GetY();
844 $sql =
"SELECT max(m.datem) as datem";
845 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
846 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
847 $resqlbis = $this->
db->query(
$sql);
849 $obj = $this->
db->fetch_object($resqlbis);
850 $lastmovementdate = $this->
db->jdate($obj->datem);
855 if ($lastmovementdate) {
858 $toWrite = $outputlangs->transnoentities(
"None");
861 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
863 $nexY = $pdf->GetY();
869 $current_y = $pdf->getY();
870 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
871 if ($current_y < $pdf->getY()) {
872 $top_shift = $pdf->getY() - $current_y;
875 $pdf->SetTextColor(0, 0, 0);
890 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
892 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
893 return pdf_pagefoot($pdf, $outputlangs,
'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);