136 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
139 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
141 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
143 if (!is_object($outputlangs)) {
144 $outputlangs = $langs;
148 $outputlangs->charset_output =
'ISO-8859-1';
152 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
159 $ref =
GETPOST(
'ref',
'alpha');
160 $msid =
GETPOST(
'msid',
'int');
161 $product_id =
GETPOST(
"product_id");
162 $action =
GETPOST(
'action',
'aZ09');
163 $cancel =
GETPOST(
'cancel',
'alpha');
164 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
166 $idproduct =
GETPOST(
'idproduct',
'int');
169 $search_ref =
GETPOST(
'search_ref',
'alpha');
170 $search_movement =
GETPOST(
"search_movement");
171 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
172 $search_product = trim(
GETPOST(
"search_product"));
173 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
174 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
175 $search_user = trim(
GETPOST(
"search_user"));
176 $search_batch = trim(
GETPOST(
"search_batch"));
177 $search_qty = trim(
GETPOST(
"search_qty"));
178 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
180 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
181 $page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
182 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
183 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
184 if (empty($page) || $page == -1) {
187 $offset = $limit * $page;
189 $sortfield =
"m.datem";
195 $pdluoid =
GETPOST(
'pdluoid',
'int');
198 $hookmanager->initHooks(array(
'movementlist'));
202 $extrafields->fetch_name_optionals_label(
'movement');
203 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
206 $productstatic =
new Product($this->db);
207 $warehousestatic =
new Entrepot($this->db);
209 $userstatic =
new User($this->db);
210 $element =
'movement';
212 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
213 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
214 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
215 $sql .=
" m.batch, m.price,";
216 $sql .=
" m.type_mouvement,";
217 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
218 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
220 if (!empty($extrafields->attributes[$element][
'label'])) {
221 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
222 $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
226 $parameters = array();
227 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
228 $sql .= $hookmanager->resPrint;
229 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
230 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
231 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
232 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
233 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
235 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
236 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
237 $sql .=
" WHERE m.fk_product = p.rowid";
239 $sql .=
" AND m.rowid = ".((int) $msid);
241 $sql .=
" AND m.fk_entrepot = e.rowid";
242 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
244 $sql .=
" AND p.fk_product_type = 0";
247 $sql .=
" AND e.rowid = ".((int) $id);
251 $sql .=
" AND m.datem BETWEEN '".$this->db->idate(
dol_get_first_day($year, $month,
false)).
"' AND '".$this->db->idate(
dol_get_last_day($year, $month,
false)).
"'";
253 $sql .=
" AND date_format(m.datem, '%m') = '".((int) $month).
"'";
255 } elseif ($year > 0) {
258 if ($idproduct > 0) {
259 $sql .=
" AND p.rowid = ".((int) $idproduct);
261 if (!empty($search_ref)) {
264 if (!empty($search_movement)) {
267 if (!empty($search_inventorycode)) {
270 if (!empty($search_product_ref)) {
273 if (!empty($search_product)) {
276 if ($search_warehouse > 0) {
277 $sql .=
" AND e.rowid = ".((int) $search_warehouse);
279 if (!empty($search_user)) {
282 if (!empty($search_batch)) {
285 if ($search_qty !=
'') {
288 if ($search_type_mouvement > 0) {
289 $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
292 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
294 $parameters = array();
295 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
296 $sql .= $hookmanager->resPrint;
297 $sql .= $this->db->order($sortfield, $sortorder);
299 $nbtotalofrecords =
'';
301 $result = $this->db->query($sql);
302 $nbtotalofrecords = $this->db->num_rows($result);
303 if (($page * $limit) > $nbtotalofrecords) {
309 if (empty($search_inventorycode)) {
310 $sql .= $this->db->plimit($limit + 1, $offset);
314 $resql = $this->db->query($sql);
315 $nbtotalofrecords = $this->db->num_rows($result);
323 if ($conf->stock->dir_output) {
325 $product =
new Product($this->db);
328 if ($idproduct > 0) {
329 $product->fetch($idproduct);
331 if ($id > 0 || $ref) {
332 $result = $object->fetch($id, $ref);
338 $num = $this->db->num_rows($resql);
342 if ($object->specimen) {
343 $dir = $conf->stock->dir_output.
"/movement";
344 $file = $dir.
"/SPECIMEN.pdf";
347 if (!empty($search_inventorycode)) {
348 $objectref .=
"_".$id.
"_".$search_inventorycode;
350 if ($search_type_mouvement) {
351 $objectref .=
"_".$search_type_mouvement;
353 $dir = $conf->stock->dir_output.
"/movement/".$objectref;
354 $file = $dir.
"/".$objectref.
".pdf";
358 $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
359 $object->supplierprices = $supplierprices;
361 $productstatic =
new Product($this->db);
363 if (!file_exists($dir)) {
365 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
370 if (file_exists($dir)) {
372 if (!is_object($hookmanager)) {
373 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
376 $hookmanager->initHooks(array(
'pdfgeneration'));
377 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
379 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
384 $pdf->SetAutoPageBreak(1, 0);
386 $heightforinfotot = 40;
387 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
388 $heightforfooter = $this->marge_basse + 8;
390 if (class_exists(
'TCPDF')) {
391 $pdf->setPrintHeader(
false);
392 $pdf->setPrintFooter(
false);
397 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
398 $tplidx = $pdf->importPage(1);
403 $pdf->SetDrawColor(128, 128, 128);
405 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
406 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
407 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
408 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
409 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset($object->label));
411 $pdf->SetCompression(
false);
414 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
419 if (!empty($tplidx)) {
420 $pdf->useTemplate($tplidx);
423 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
424 $pdf->SetFont(
'',
'', $default_font_size - 1);
425 $pdf->MultiCell(0, 3,
'');
426 $pdf->SetTextColor(0, 0, 0);
429 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
431 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
435 $nexY = $tab_top - 1;
437 $nexY = $pdf->GetY();
441 $totalvalue = $totalvaluesell = 0;
442 $arrayofuniqueproduct = array();
445 $resql = $this->db->query($sql);
447 $num = $this->db->num_rows($resql);
450 for ($i = 0; $i < $nblines; $i++) {
451 $objp = $this->db->fetch_object($resql);
455 $sql =
"SELECT label";
456 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
457 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
458 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
461 $result = $this->db->query($sql);
463 $objtp = $this->db->fetch_object($result);
464 if ($objtp->label !=
'') {
465 $objp->produit = $objtp->label;
471 $pdf->SetFont(
'',
'', $default_font_size - 1);
472 $pdf->SetTextColor(0, 0, 0);
474 $pdf->setTopMargin($tab_top_newpage);
475 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
476 $pageposbefore = $pdf->getPage();
479 $curX = $this->posxdesc - 1;
481 $showpricebeforepagebreak = 1;
483 $pdf->startTransaction();
484 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
485 $pageposafter = $pdf->getPage();
486 if ($pageposafter > $pageposbefore) {
487 $pdf->rollbackTransaction(
true);
488 $pageposafter = $pageposbefore;
490 $pdf->setPageOrientation(
'', 1, $heightforfooter);
491 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
492 $pageposafter = $pdf->getPage();
493 $posyafter = $pdf->GetY();
494 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
495 if ($i == ($nblines - 1)) {
496 $pdf->AddPage(
'',
'',
true);
497 if (!empty($tplidx)) {
498 $pdf->useTemplate($tplidx);
501 $this->
_pagehead($pdf, $object, 0, $outputlangs);
503 $pdf->setPage($pageposafter + 1);
510 $showpricebeforepagebreak = 1;
512 $showpricebeforepagebreak = 0;
516 $pdf->commitTransaction();
518 $posYAfterDescription = $pdf->GetY();
520 $nexY = $pdf->GetY();
521 $pageposafter = $pdf->getPage();
523 $pdf->setPage($pageposbefore);
524 $pdf->setTopMargin($this->marge_haute);
525 $pdf->setPageOrientation(
'', 1, 0);
528 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
529 $pdf->setPage($pageposafter);
530 $curY = $tab_top_newpage;
533 $pdf->SetFont(
'',
'', $default_font_size - 1);
537 $userstatic->id = $objp->fk_user_author;
538 $userstatic->login = $objp->login;
539 $userstatic->lastname = $objp->lastname;
540 $userstatic->firstname = $objp->firstname;
541 $userstatic->photo = $objp->photo;
543 $productstatic->id = $objp->rowid;
544 $productstatic->ref = $objp->product_ref;
545 $productstatic->label = $objp->produit;
546 $productstatic->type = $objp->type;
547 $productstatic->entity = $objp->entity;
548 $productstatic->status_batch = $objp->tobatch;
550 $productlot->id = $objp->lotid;
551 $productlot->batch = $objp->batch;
552 $productlot->eatby = $objp->eatby;
553 $productlot->sellby = $objp->sellby;
555 $warehousestatic->id = $objp->entrepot_id;
556 $warehousestatic->label = $objp->warehouse_ref;
557 $warehousestatic->lieu = $objp->lieu;
559 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
560 if (!empty($objp->fk_origin)) {
561 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
567 $pdf->SetXY($this->posxidref, $curY);
568 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
571 $pdf->SetXY($this->posxdatemouv, $curY);
572 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->db->jdate($objp->datem),
'dayhour'), 0,
'L');
575 $pdf->SetXY($this->posxdesc, $curY);
576 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
579 $pdf->SetXY($this->posxlabel + 0.8, $curY);
580 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
583 $pdf->SetXY($this->posxqty, $curY);
584 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
587 $pdf->SetXY($this->posxup, $curY);
588 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
591 $pdf->SetXY($this->posxunit, $curY);
592 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
593 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
596 $pricemin = $objp->price;
597 $pdf->SetXY($this->posxdiscount, $curY);
598 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R', 0);
601 $valtoshow =
price2num($objp->qty,
'MS');
602 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
603 $totalunit += $objp->qty;
605 $pdf->SetXY($this->postotalht, $curY);
606 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R', 0);
608 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
613 $pdf->setPage($pageposafter);
614 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
616 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
617 $pdf->SetLineStyle(array(
'dash'=>0));
623 while ($pagenb < $pageposafter) {
624 $pdf->setPage($pagenb);
626 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
628 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
630 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
632 $pdf->setPage($pagenb);
633 $pdf->setPageOrientation(
'', 1, 0);
635 $this->
_pagehead($pdf, $object, 0, $outputlangs);
637 if (!empty($tplidx)) {
638 $pdf->useTemplate($tplidx);
641 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
643 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
645 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
647 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
650 if (!empty($tplidx)) {
651 $pdf->useTemplate($tplidx);
655 $this->
_pagehead($pdf, $object, 0, $outputlangs);
660 $this->db->free($resql);
665 $nexY = $pdf->GetY();
669 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
670 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
671 $pdf->SetLineStyle(array(
'dash'=>0));
673 $pdf->SetFont(
'',
'B', $default_font_size - 1);
674 $pdf->SetTextColor(0, 0, 120);
677 $pdf->SetXY($this->posxidref, $curY);
678 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
681 $pdf->SetXY($this->postotalht, $curY);
682 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0,
'R', 0);
688 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
690 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
691 if (!empty($extranote)) {
703 $pdf->SetFont(
'',
'', $default_font_size - 1);
704 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
705 $nexY = $pdf->GetY();
706 $height_note = $nexY - $tab_top;
709 $pdf->SetDrawColor(192, 192, 192);
710 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
712 $tab_height = $tab_height - $height_note;
713 $tab_top = $nexY + 6;
718 $iniY = $tab_top + 7;
719 $curY = $tab_top + 7;
720 $nexY = $tab_top + 7;
722 $tab_top = $tab_top_newpage + 21;
726 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
727 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
729 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
730 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
733 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
742 $this->
_pagefoot($pdf, $object, $outputlangs);
743 if (method_exists($pdf,
'AliasNbPages')) {
744 $pdf->AliasNbPages();
749 $pdf->Output($file,
'F');
752 $hookmanager->initHooks(array(
'pdfgeneration'));
753 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
755 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
757 $this->error = $hookmanager->error;
758 $this->errors = $hookmanager->errors;
763 $this->result = array(
'fullpath'=>$file);
767 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
771 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
790 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
800 $currency = !empty($currency) ? $currency : $conf->currency;
804 $pdf->SetTextColor(0, 0, 0);
805 $pdf->SetFont(
'',
'', $default_font_size - 2);
807 if (empty($hidetop)) {
808 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
809 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
810 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
814 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
818 $pdf->SetDrawColor(128, 128, 128);
819 $pdf->SetFont(
'',
'B', $default_font_size - 3);
824 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
825 $pdf->SetDrawColor(220, 26, 26);
826 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
827 $pdf->SetLineStyle(array(
'dash'=>0));
828 $pdf->SetDrawColor(128, 128, 128);
829 $pdf->SetTextColor(0, 0, 120);
832 if (empty($hidetop)) {
834 $pdf->SetXY($this->posxidref, $tab_top + 1);
835 $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
840 if (empty($hidetop)) {
841 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
842 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
847 if (empty($hidetop)) {
848 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
849 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
854 if (empty($hidetop)) {
855 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
856 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
861 if (empty($hidetop)) {
862 $pdf->SetXY($this->posxqty, $tab_top + 1);
863 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Lot/Série"),
'',
'C');
868 if (empty($hidetop)) {
869 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
870 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"Inventory Code"),
'',
'C');
875 if (empty($hidetop)) {
876 $pdf->SetXY($this->posxunit, $tab_top + 1);
877 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"Label Mouvement"),
'',
'C');
882 if (empty($hidetop)) {
883 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
884 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
889 if (empty($hidetop)) {
890 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
891 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
894 $pdf->SetDrawColor(220, 26, 26);
895 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
896 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
897 $pdf->SetLineStyle(array(
'dash'=>0));
911 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"")
913 global $conf, $langs, $db, $hookmanager;
916 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
920 if ($object->type == 1) {
921 $titlekey =
'ServiceSheet';
923 $titlekey =
'StockSheet';
933 $pdf->SetTextColor(0, 0, 60);
934 $pdf->SetFont(
'',
'B', $default_font_size + 3);
936 $posy = $this->marge_haute;
937 $posx = $this->page_largeur - $this->marge_droite - 100;
939 $pdf->SetXY($this->marge_gauche, $posy);
942 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
943 if ($this->emetteur->logo) {
944 if (is_readable($logo)) {
946 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
948 $pdf->SetTextColor(200, 0, 0);
949 $pdf->SetFont(
'',
'B', $default_font_size - 2);
950 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
951 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
954 $text = $this->emetteur->name;
955 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
958 $pdf->SetFont(
'',
'B', $default_font_size + 3);
959 $pdf->SetXY($posx, $posy);
960 $pdf->SetTextColor(0, 0, 60);
961 $title = $outputlangs->transnoentities(
"Warehouse");
962 $pdf->MultiCell(100, 3, $title,
'',
'R');
964 $pdf->SetFont(
'',
'B', $default_font_size);
967 $pdf->SetXY($posx, $posy);
968 $pdf->SetTextColor(0, 0, 60);
970 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->label),
'',
'R');
973 $pdf->SetFont(
'',
'', $default_font_size - 1);
974 $pdf->SetXY($posx, $posy);
975 $pdf->SetTextColor(0, 0, 60);
976 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
979 $pdf->SetXY($posx - 50, $posy);
980 $pdf->MultiCell(150, 3, $object->lieu,
'',
'R');
985 $pdf->SetXY($posx, $posy);
986 $pdf->SetTextColor(0, 0, 60);
987 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
990 $pdf->SetXY($posx - 50, $posy);
992 if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) {
993 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
995 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
999 $nexY = $pdf->GetY();
1001 $pdf->SetXY($posx, $posy);
1002 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br($object->description), 0, 1);
1003 $nexY = $pdf->GetY();
1005 $calcproductsunique = $object->nb_different_products();
1006 $calcproducts = $object->nb_products();
1009 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1010 $nexY = $pdf->GetY();
1013 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1014 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1015 $nexY = $pdf->GetY();
1018 $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);
1019 $nexY = $pdf->GetY();
1023 $sql =
"SELECT max(m.datem) as datem";
1024 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1025 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
1026 $resqlbis = $this->db->query($sql);
1028 $obj = $this->db->fetch_object($resqlbis);
1029 $lastmovementdate = $this->db->jdate($obj->datem);
1034 if ($lastmovementdate) {
1037 $toWrite = $outputlangs->transnoentities(
"None");
1040 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1041 $nexY = $pdf->GetY();
1078 $current_y = $pdf->getY();
1118 $pdf->SetTextColor(0, 0, 0);