138 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
141 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
143 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
145 if (!is_object($outputlangs)) {
146 $outputlangs = $langs;
150 $outputlangs->charset_output =
'ISO-8859-1';
154 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
161 $ref =
GETPOST(
'ref',
'alpha');
163 $product_id =
GETPOST(
"product_id");
164 $action =
GETPOST(
'action',
'aZ09');
165 $cancel =
GETPOST(
'cancel',
'alpha');
166 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
171 $search_ref =
GETPOST(
'search_ref',
'alpha');
172 $search_movement =
GETPOST(
"search_movement");
173 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
174 $search_product = trim(
GETPOST(
"search_product"));
175 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
176 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
177 $search_user = trim(
GETPOST(
"search_user"));
178 $search_batch = trim(
GETPOST(
"search_batch"));
179 $search_qty = trim(
GETPOST(
"search_qty"));
180 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
"intcomma");
184 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
185 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
186 if (empty($page) || $page == -1) {
189 $offset = $limit * $page;
191 $sortfield =
"m.datem";
200 $hookmanager->initHooks(array(
'movementlist'));
204 $extrafields->fetch_name_optionals_label(
'movement');
205 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
208 $productstatic =
new Product($this->db);
209 $warehousestatic =
new Entrepot($this->db);
211 $userstatic =
new User($this->db);
212 $element =
'movement';
214 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
215 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
216 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
217 $sql .=
" m.batch, m.price,";
218 $sql .=
" m.type_mouvement,";
219 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
220 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
222 if (!empty($extrafields->attributes[$element][
'label'])) {
223 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
224 $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
228 $parameters = array();
229 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
230 $sql .= $hookmanager->resPrint;
231 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
232 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
233 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
234 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
235 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
237 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
238 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
239 $sql .=
" WHERE m.fk_product = p.rowid";
241 $sql .=
" AND m.rowid = ".((int) $msid);
243 $sql .=
" AND m.fk_entrepot = e.rowid";
244 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
246 $sql .=
" AND p.fk_product_type = 0";
249 $sql .=
" AND e.rowid = ".((int) $id);
253 $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)).
"'";
255 $sql .=
" AND date_format(m.datem, '%m') = '".((int) $month).
"'";
257 } elseif ($year > 0) {
260 if ($idproduct > 0) {
261 $sql .=
" AND p.rowid = ".((int) $idproduct);
263 if (!empty($search_ref)) {
266 if (!empty($search_movement)) {
269 if (!empty($search_inventorycode)) {
272 if (!empty($search_product_ref)) {
275 if (!empty($search_product)) {
278 if ($search_warehouse > 0) {
279 $sql .=
" AND e.rowid = ".((int) $search_warehouse);
281 if (!empty($search_user)) {
284 if (!empty($search_batch)) {
287 if ($search_qty !=
'') {
290 if ($search_type_mouvement > 0) {
291 $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
294 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
296 $parameters = array();
297 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
298 $sql .= $hookmanager->resPrint;
299 $sql .= $this->db->order($sortfield, $sortorder);
301 $nbtotalofrecords =
'';
303 $result = $this->db->query($sql);
304 $nbtotalofrecords = $this->db->num_rows($result);
305 if (($page * $limit) > $nbtotalofrecords) {
311 if (empty($search_inventorycode)) {
312 $sql .= $this->db->plimit($limit + 1, $offset);
316 $resql = $this->db->query($sql);
317 $nbtotalofrecords = $this->db->num_rows($result);
325 if ($conf->stock->dir_output) {
327 $product =
new Product($this->db);
330 if ($idproduct > 0) {
331 $product->fetch($idproduct);
333 if ($id > 0 || $ref) {
334 $result =
$object->fetch($id, $ref);
340 $num = $this->db->num_rows($resql);
345 $dir = $conf->stock->dir_output.
"/movement";
346 $file = $dir.
"/SPECIMEN.pdf";
349 if (!empty($search_inventorycode)) {
350 $objectref .=
"_".$id.
"_".$search_inventorycode;
352 if ($search_type_mouvement) {
353 $objectref .=
"_".$search_type_mouvement;
355 $dir = $conf->stock->dir_output.
"/movement/".$objectref;
356 $file = $dir.
"/".$objectref.
".pdf";
360 $supplierprices = $stockFournisseur->list_product_fournisseur_price(
$object->id);
361 $object->supplierprices = $supplierprices;
363 $productstatic =
new Product($this->db);
365 if (!file_exists($dir)) {
367 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
372 if (file_exists($dir)) {
374 if (!is_object($hookmanager)) {
375 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
378 $hookmanager->initHooks(array(
'pdfgeneration'));
379 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
381 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
386 $pdf->SetAutoPageBreak(1, 0);
388 $heightforinfotot = 40;
389 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
390 $heightforfooter = $this->marge_basse + 8;
392 if (class_exists(
'TCPDF')) {
393 $pdf->setPrintHeader(
false);
394 $pdf->setPrintFooter(
false);
399 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
400 $tplidx = $pdf->importPage(1);
405 $pdf->SetDrawColor(128, 128, 128);
407 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
408 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
409 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
410 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
411 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset(
$object->label));
413 $pdf->SetCompression(
false);
417 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
422 if (!empty($tplidx)) {
423 $pdf->useTemplate($tplidx);
427 $pdf->SetFont(
'',
'', $default_font_size - 1);
428 $pdf->MultiCell(0, 3,
'');
429 $pdf->SetTextColor(0, 0, 0);
432 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
434 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
438 $nexY = $tab_top - 1;
440 $nexY = $pdf->GetY();
444 $totalvalue = $totalvaluesell = 0;
445 $arrayofuniqueproduct = array();
448 $resql = $this->db->query($sql);
450 $num = $this->db->num_rows($resql);
452 for ($i = 0; $i < $nblines; $i++) {
453 $objp = $this->db->fetch_object($resql);
457 $sql =
"SELECT label";
458 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
459 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
460 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
463 $result = $this->db->query($sql);
465 $objtp = $this->db->fetch_object($result);
466 if ($objtp->label !=
'') {
467 $objp->produit = $objtp->label;
473 $pdf->SetFont(
'',
'', $default_font_size - 1);
474 $pdf->SetTextColor(0, 0, 0);
476 $pdf->setTopMargin($tab_top_newpage);
477 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
478 $pageposbefore = $pdf->getPage();
481 $curX = $this->posxdesc - 1;
483 $showpricebeforepagebreak = 1;
485 $pdf->startTransaction();
487 $pageposafter = $pdf->getPage();
488 if ($pageposafter > $pageposbefore) {
489 $pdf->rollbackTransaction(
true);
490 $pageposafter = $pageposbefore;
492 $pdf->setPageOrientation(
'', 1, $heightforfooter);
494 $pageposafter = $pdf->getPage();
495 $posyafter = $pdf->GetY();
496 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
497 if ($i == ($nblines - 1)) {
498 $pdf->AddPage(
'',
'',
true);
499 if (!empty($tplidx)) {
500 $pdf->useTemplate($tplidx);
505 $pdf->setPage($pageposafter + 1);
512 $showpricebeforepagebreak = 1;
514 $showpricebeforepagebreak = 0;
518 $pdf->commitTransaction();
520 $posYAfterDescription = $pdf->GetY();
522 $nexY = $pdf->GetY();
523 $pageposafter = $pdf->getPage();
525 $pdf->setPage($pageposbefore);
526 $pdf->setTopMargin($this->marge_haute);
527 $pdf->setPageOrientation(
'', 1, 0);
530 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
531 $pdf->setPage($pageposafter);
532 $curY = $tab_top_newpage;
535 $pdf->SetFont(
'',
'', $default_font_size - 1);
539 $userstatic->id = $objp->fk_user_author;
540 $userstatic->login = $objp->login;
541 $userstatic->lastname = $objp->lastname;
542 $userstatic->firstname = $objp->firstname;
543 $userstatic->photo = $objp->photo;
545 $productstatic->id = $objp->rowid;
546 $productstatic->ref = $objp->product_ref;
547 $productstatic->label = $objp->produit;
548 $productstatic->type = $objp->type;
549 $productstatic->entity = $objp->entity;
550 $productstatic->status_batch = $objp->tobatch;
552 $productlot->id = $objp->lotid;
553 $productlot->batch = $objp->batch;
554 $productlot->eatby = $objp->eatby;
555 $productlot->sellby = $objp->sellby;
557 $warehousestatic->id = $objp->entrepot_id;
558 $warehousestatic->label = $objp->warehouse_ref;
559 $warehousestatic->lieu = $objp->lieu;
561 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
562 if (!empty($objp->fk_origin)) {
563 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
569 $pdf->SetXY($this->posxidref, $curY);
570 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
573 $pdf->SetXY($this->posxdatemouv, $curY);
574 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->db->jdate($objp->datem),
'dayhour'), 0,
'L');
577 $pdf->SetXY($this->posxdesc, $curY);
578 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
581 $pdf->SetXY($this->posxlabel + 0.8, $curY);
582 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
585 $pdf->SetXY($this->posxqty, $curY);
586 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
589 $pdf->SetXY($this->posxup, $curY);
590 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
593 $pdf->SetXY($this->posxunit, $curY);
594 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
595 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
598 $pricemin = $objp->price;
599 $pdf->SetXY($this->posxdiscount, $curY);
600 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R', 0);
603 $valtoshow =
price2num($objp->qty,
'MS');
604 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
605 $totalunit += $objp->qty;
607 $pdf->SetXY($this->postotalht, $curY);
608 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R', 0);
610 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
615 $pdf->setPage($pageposafter);
616 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
618 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
619 $pdf->SetLineStyle(array(
'dash' => 0));
625 while ($pagenb < $pageposafter) {
626 $pdf->setPage($pagenb);
628 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
630 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
634 $pdf->setPage($pagenb);
635 $pdf->setPageOrientation(
'', 1, 0);
639 if (!empty($tplidx)) {
640 $pdf->useTemplate($tplidx);
643 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
645 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
647 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
652 if (!empty($tplidx)) {
653 $pdf->useTemplate($tplidx);
662 $this->db->free($resql);
667 $nexY = $pdf->GetY();
671 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
672 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
673 $pdf->SetLineStyle(array(
'dash' => 0));
675 $pdf->SetFont(
'',
'B', $default_font_size - 1);
676 $pdf->SetTextColor(0, 0, 120);
679 $pdf->SetXY($this->posxidref, $curY);
680 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
683 $pdf->SetXY($this->postotalht, $curY);
684 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0,
'R', 0);
690 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
692 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
693 if (!empty($extranote)) {
705 $pdf->SetFont(
'',
'', $default_font_size - 1);
706 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
707 $nexY = $pdf->GetY();
708 $height_note = $nexY - $tab_top;
711 $pdf->SetDrawColor(192, 192, 192);
712 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
714 $tab_height = $tab_height - $height_note;
715 $tab_top = $nexY + 6;
720 $iniY = $tab_top + 7;
721 $curY = $tab_top + 7;
722 $nexY = $tab_top + 7;
724 $tab_top = $tab_top_newpage + 21;
728 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
729 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
731 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
732 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
735 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
745 if (method_exists($pdf,
'AliasNbPages')) {
746 $pdf->AliasNbPages();
751 $pdf->Output($file,
'F');
754 $hookmanager->initHooks(array(
'pdfgeneration'));
755 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
757 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
759 $this->error = $hookmanager->error;
760 $this->errors = $hookmanager->errors;
765 $this->result = array(
'fullpath' => $file);
769 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
773 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
792 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
802 $currency = !empty($currency) ? $currency : $conf->currency;
806 $pdf->SetTextColor(0, 0, 0);
807 $pdf->SetFont(
'',
'', $default_font_size - 2);
809 if (empty($hidetop)) {
810 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
811 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
812 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
816 $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')));
820 $pdf->SetDrawColor(128, 128, 128);
821 $pdf->SetFont(
'',
'B', $default_font_size - 3);
826 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
827 $pdf->SetDrawColor(220, 26, 26);
828 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
829 $pdf->SetLineStyle(array(
'dash' => 0));
830 $pdf->SetDrawColor(128, 128, 128);
831 $pdf->SetTextColor(0, 0, 120);
834 if (empty($hidetop)) {
836 $pdf->SetXY($this->posxidref, $tab_top + 1);
837 $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
842 if (empty($hidetop)) {
843 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
844 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
849 if (empty($hidetop)) {
850 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
851 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
856 if (empty($hidetop)) {
857 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
858 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
863 if (empty($hidetop)) {
864 $pdf->SetXY($this->posxqty, $tab_top + 1);
865 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Batch"),
'',
'C');
870 if (empty($hidetop)) {
871 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
872 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"Inventory Code"),
'',
'C');
877 if (empty($hidetop)) {
878 $pdf->SetXY($this->posxunit, $tab_top + 1);
879 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"Label Movement"),
'',
'C');
884 if (empty($hidetop)) {
885 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
886 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
891 if (empty($hidetop)) {
892 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
893 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
896 $pdf->SetDrawColor(220, 26, 26);
897 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
898 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
899 $pdf->SetLineStyle(array(
'dash' => 0));
915 global $conf, $langs;
918 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
923 $titlekey =
'ServiceSheet';
925 $titlekey =
'StockSheet';
935 $pdf->SetTextColor(0, 0, 60);
936 $pdf->SetFont(
'',
'B', $default_font_size + 3);
938 $posy = $this->marge_haute;
939 $posx = $this->page_largeur - $this->marge_droite - 100;
941 $pdf->SetXY($this->marge_gauche, $posy);
944 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
945 if ($this->emetteur->logo) {
946 if (is_readable($logo)) {
948 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
950 $pdf->SetTextColor(200, 0, 0);
951 $pdf->SetFont(
'',
'B', $default_font_size - 2);
952 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
953 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
956 $text = $this->emetteur->name;
957 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
960 $pdf->SetFont(
'',
'B', $default_font_size + 3);
961 $pdf->SetXY($posx, $posy);
962 $pdf->SetTextColor(0, 0, 60);
963 $title = $outputlangs->transnoentities(
"Warehouse");
964 $pdf->MultiCell(100, 3, $title,
'',
'R');
966 $pdf->SetFont(
'',
'B', $default_font_size);
969 $pdf->SetXY($posx, $posy);
970 $pdf->SetTextColor(0, 0, 60);
972 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->label),
'',
'R');
975 $pdf->SetFont(
'',
'', $default_font_size - 1);
976 $pdf->SetXY($posx, $posy);
977 $pdf->SetTextColor(0, 0, 60);
978 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
981 $pdf->SetXY($posx - 50, $posy);
982 $pdf->MultiCell(150, 3,
$object->lieu,
'',
'R');
987 $pdf->SetXY($posx, $posy);
988 $pdf->SetTextColor(0, 0, 60);
989 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
992 $pdf->SetXY($posx - 50, $posy);
994 if (!empty(
$object->fk_parent) && $e->fetch(
$object->fk_parent) > 0) {
995 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
997 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
1001 $nexY = $pdf->GetY();
1003 $pdf->SetXY($posx, $posy);
1004 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br(
$object->description), 0, 1);
1005 $nexY = $pdf->GetY();
1007 $calcproductsunique =
$object->nb_different_products();
1008 $calcproducts =
$object->nb_products();
1011 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1012 $nexY = $pdf->GetY();
1015 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1016 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1017 $nexY = $pdf->GetY();
1020 $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);
1021 $nexY = $pdf->GetY();
1025 $sql =
"SELECT max(m.datem) as datem";
1026 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1027 $sql .=
" WHERE m.fk_entrepot = ".((int)
$object->id);
1028 $resqlbis = $this->db->query($sql);
1030 $obj = $this->db->fetch_object($resqlbis);
1031 $lastmovementdate = $this->db->jdate($obj->datem);
1036 if ($lastmovementdate) {
1039 $toWrite = $outputlangs->transnoentities(
"None");
1042 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1043 $nexY = $pdf->GetY();
1080 $current_y = $pdf->getY();
1120 $pdf->SetTextColor(0, 0, 0);