144 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
147 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
149 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
151 if (!is_object($outputlangs)) {
152 $outputlangs = $langs;
156 $outputlangs->charset_output =
'ISO-8859-1';
160 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
167 $ref =
GETPOST(
'ref',
'alpha');
169 $product_id =
GETPOST(
"product_id");
170 $action =
GETPOST(
'action',
'aZ09');
171 $cancel =
GETPOST(
'cancel',
'alpha');
172 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
177 $search_ref =
GETPOST(
'search_ref',
'alpha');
178 $search_movement =
GETPOST(
"search_movement");
179 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
180 $search_product = trim(
GETPOST(
"search_product"));
181 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
182 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
183 $search_user = trim(
GETPOST(
"search_user"));
184 $search_batch = trim(
GETPOST(
"search_batch"));
185 $search_qty = trim(
GETPOST(
"search_qty"));
186 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
"intcomma");
190 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
191 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
192 if (empty($page) || $page == -1) {
195 $offset = $limit * $page;
197 $sortfield =
"m.datem";
206 $hookmanager->initHooks(array(
'movementlist'));
210 $extrafields->fetch_name_optionals_label(
'movement');
211 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
214 $productstatic =
new Product($this->db);
215 $warehousestatic =
new Entrepot($this->db);
217 $userstatic =
new User($this->db);
218 $element =
'movement';
220 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
221 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
222 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
223 $sql .=
" m.batch, m.price,";
224 $sql .=
" m.type_mouvement,";
225 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
226 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
228 if (!empty($extrafields->attributes[$element][
'label'])) {
229 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
230 $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
234 $parameters = array();
235 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
236 $sql .= $hookmanager->resPrint;
237 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
238 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
239 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
240 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
241 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
243 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
244 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
245 $sql .=
" WHERE m.fk_product = p.rowid";
247 $sql .=
" AND m.rowid = ".((int) $msid);
249 $sql .=
" AND m.fk_entrepot = e.rowid";
250 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
252 $sql .=
" AND p.fk_product_type = 0";
255 $sql .=
" AND e.rowid = ".((int)
$id);
259 $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)).
"'";
261 $sql .=
" AND date_format(m.datem, '%m') = '".((int) $month).
"'";
263 } elseif ($year > 0) {
266 if ($idproduct > 0) {
267 $sql .=
" AND p.rowid = ".((int) $idproduct);
269 if (!empty($search_ref)) {
272 if (!empty($search_movement)) {
275 if (!empty($search_inventorycode)) {
278 if (!empty($search_product_ref)) {
281 if (!empty($search_product)) {
284 if ($search_warehouse > 0) {
285 $sql .=
" AND e.rowid = ".((int) $search_warehouse);
287 if (!empty($search_user)) {
290 if (!empty($search_batch)) {
293 if ($search_qty !=
'') {
296 if ($search_type_mouvement > 0) {
297 $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
300 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
302 $parameters = array();
303 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
304 $sql .= $hookmanager->resPrint;
305 $sql .= $this->db->order($sortfield, $sortorder);
307 $nbtotalofrecords =
'';
309 $result = $this->db->query($sql);
310 $nbtotalofrecords = $this->db->num_rows($result);
311 if (($page * $limit) > $nbtotalofrecords) {
317 if (empty($search_inventorycode)) {
318 $sql .= $this->db->plimit($limit + 1, $offset);
322 $resql = $this->db->query($sql);
323 $nbtotalofrecords = $this->db->num_rows($result);
331 if ($conf->stock->dir_output) {
333 $product =
new Product($this->db);
336 if ($idproduct > 0) {
337 $product->fetch($idproduct);
339 if (
$id > 0 || $ref) {
346 $num = $this->db->num_rows($resql);
351 $dir = $conf->stock->dir_output.
"/movement";
352 $file = $dir.
"/SPECIMEN.pdf";
355 if (!empty($search_inventorycode)) {
356 $objectref .=
"_".$id.
"_".$search_inventorycode;
358 if ($search_type_mouvement) {
359 $objectref .=
"_".$search_type_mouvement;
361 $dir = $conf->stock->dir_output.
"/movement/".$objectref;
362 $file = $dir.
"/".$objectref.
".pdf";
366 $supplierprices = $stockFournisseur->list_product_fournisseur_price(
$object->id);
367 $object->supplierprices = $supplierprices;
369 $productstatic =
new Product($this->db);
371 if (!file_exists($dir)) {
373 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
378 if (file_exists($dir)) {
380 if (!is_object($hookmanager)) {
381 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
384 $hookmanager->initHooks(array(
'pdfgeneration'));
385 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
387 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
392 $pdf->SetAutoPageBreak(1, 0);
394 $heightforinfotot = 40;
396 $heightforfooter = $this->marge_basse + 8;
398 if (class_exists(
'TCPDF')) {
399 $pdf->setPrintHeader(
false);
400 $pdf->setPrintFooter(
false);
405 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
406 $tplidx = $pdf->importPage(1);
411 $pdf->SetDrawColor(128, 128, 128);
413 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
414 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
415 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
416 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
417 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset(
$object->label));
419 $pdf->SetCompression(
false);
423 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
428 if (!empty($tplidx)) {
429 $pdf->useTemplate($tplidx);
433 $pdf->SetFont(
'',
'', $default_font_size - 1);
434 $pdf->MultiCell(0, 3,
'');
435 $pdf->SetTextColor(0, 0, 0);
438 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
440 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
444 $nexY = $tab_top - 1;
446 $nexY = $pdf->GetY();
450 $totalvalue = $totalvaluesell = 0;
451 $arrayofuniqueproduct = array();
454 $resql = $this->db->query($sql);
456 $num = $this->db->num_rows($resql);
458 for ($i = 0; $i < $nblines; $i++) {
459 $objp = $this->db->fetch_object($resql);
463 $sql =
"SELECT label";
464 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
465 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
466 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
469 $result = $this->db->query($sql);
471 $objtp = $this->db->fetch_object($result);
472 if ($objtp->label !=
'') {
473 $objp->produit = $objtp->label;
479 $pdf->SetFont(
'',
'', $default_font_size - 1);
480 $pdf->SetTextColor(0, 0, 0);
482 $pdf->setTopMargin($tab_top_newpage);
483 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
484 $pageposbefore = $pdf->getPage();
487 $curX = $this->posxdesc - 1;
489 $showpricebeforepagebreak = 1;
491 $pdf->startTransaction();
493 $pageposafter = $pdf->getPage();
494 if ($pageposafter > $pageposbefore) {
495 $pdf->rollbackTransaction(
true);
496 $pageposafter = $pageposbefore;
498 $pdf->setPageOrientation(
'', 1, $heightforfooter);
500 $pageposafter = $pdf->getPage();
501 $posyafter = $pdf->GetY();
502 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
503 if ($i == ($nblines - 1)) {
504 $pdf->AddPage(
'',
'',
true);
505 if (!empty($tplidx)) {
506 $pdf->useTemplate($tplidx);
511 $pdf->setPage($pageposafter + 1);
518 $showpricebeforepagebreak = 1;
520 $showpricebeforepagebreak = 0;
524 $pdf->commitTransaction();
526 $posYAfterDescription = $pdf->GetY();
528 $nexY = $pdf->GetY();
529 $pageposafter = $pdf->getPage();
531 $pdf->setPage($pageposbefore);
532 $pdf->setTopMargin($this->marge_haute);
533 $pdf->setPageOrientation(
'', 1, 0);
536 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
537 $pdf->setPage($pageposafter);
538 $curY = $tab_top_newpage;
541 $pdf->SetFont(
'',
'', $default_font_size - 1);
545 $userstatic->id = $objp->fk_user_author;
546 $userstatic->login = $objp->login;
547 $userstatic->lastname = $objp->lastname;
548 $userstatic->firstname = $objp->firstname;
549 $userstatic->photo = $objp->photo;
551 $productstatic->id = $objp->rowid;
552 $productstatic->ref = $objp->product_ref;
553 $productstatic->label = $objp->produit;
554 $productstatic->type = $objp->type;
555 $productstatic->entity = $objp->entity;
556 $productstatic->status_batch = $objp->tobatch;
558 $productlot->id = $objp->lotid;
559 $productlot->batch = $objp->batch;
560 $productlot->eatby = $objp->eatby;
561 $productlot->sellby = $objp->sellby;
563 $warehousestatic->id = $objp->entrepot_id;
564 $warehousestatic->label = $objp->warehouse_ref;
565 $warehousestatic->lieu = $objp->lieu;
567 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
568 if (!empty($objp->fk_origin)) {
569 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
575 $pdf->SetXY($this->posxidref, $curY);
576 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
579 $pdf->SetXY($this->posxdatemouv, $curY);
580 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->db->jdate($objp->datem),
'dayhour'), 0,
'L');
583 $pdf->SetXY($this->posxdesc, $curY);
584 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
587 $pdf->SetXY($this->posxlabel + 0.8, $curY);
588 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
591 $pdf->SetXY($this->posxqty, $curY);
592 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
595 $pdf->SetXY($this->posxup, $curY);
596 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
599 $pdf->SetXY($this->posxunit, $curY);
600 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
601 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
604 $pricemin = $objp->price;
605 $pdf->SetXY($this->posxdiscount, $curY);
606 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R', 0);
609 $valtoshow =
price2num($objp->qty,
'MS');
610 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
611 $totalunit += $objp->qty;
613 $pdf->SetXY($this->postotalht, $curY);
614 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R', 0);
616 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
621 $pdf->setPage($pageposafter);
622 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
624 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
625 $pdf->SetLineStyle(array(
'dash' => 0));
631 while ($pagenb < $pageposafter) {
632 $pdf->setPage($pagenb);
634 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
636 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
640 $pdf->setPage($pagenb);
641 $pdf->setPageOrientation(
'', 1, 0);
645 if (!empty($tplidx)) {
646 $pdf->useTemplate($tplidx);
649 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
651 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
653 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
658 if (!empty($tplidx)) {
659 $pdf->useTemplate($tplidx);
668 $this->db->free($resql);
673 $nexY = $pdf->GetY();
677 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
678 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
679 $pdf->SetLineStyle(array(
'dash' => 0));
681 $pdf->SetFont(
'',
'B', $default_font_size - 1);
682 $pdf->SetTextColor(0, 0, 120);
685 $pdf->SetXY($this->posxidref, $curY);
686 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
689 $pdf->SetXY($this->postotalht, $curY);
690 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0,
'R', 0);
696 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
698 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
699 if (!empty($extranote)) {
711 $pdf->SetFont(
'',
'', $default_font_size - 1);
712 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
713 $nexY = $pdf->GetY();
714 $height_note = $nexY - $tab_top;
717 $pdf->SetDrawColor(192, 192, 192);
718 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
720 $tab_height -= $height_note;
721 $tab_top = $nexY + 6;
726 $iniY = $tab_top + 7;
727 $curY = $tab_top + 7;
728 $nexY = $tab_top + 7;
730 $tab_top = $tab_top_newpage + 21;
734 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
735 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
737 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
738 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
741 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
751 if (method_exists($pdf,
'AliasNbPages')) {
752 $pdf->AliasNbPages();
757 $pdf->Output($file,
'F');
760 $hookmanager->initHooks(array(
'pdfgeneration'));
761 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
763 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
765 $this->error = $hookmanager->error;
766 $this->errors = $hookmanager->errors;
771 $this->result = array(
'fullpath' => $file);
775 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
779 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
798 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
808 $currency = !empty($currency) ? $currency : $conf->currency;
812 $pdf->SetTextColor(0, 0, 0);
813 $pdf->SetFont(
'',
'', $default_font_size - 2);
815 if (empty($hidetop)) {
816 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
817 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
818 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
822 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
826 $pdf->SetDrawColor(128, 128, 128);
827 $pdf->SetFont(
'',
'B', $default_font_size - 3);
832 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
833 $pdf->SetDrawColor(220, 26, 26);
834 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
835 $pdf->SetLineStyle(array(
'dash' => 0));
836 $pdf->SetDrawColor(128, 128, 128);
837 $pdf->SetTextColor(0, 0, 120);
840 if (empty($hidetop)) {
842 $pdf->SetXY($this->posxidref, $tab_top + 1);
843 $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
848 if (empty($hidetop)) {
849 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
850 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
855 if (empty($hidetop)) {
856 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
857 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
862 if (empty($hidetop)) {
863 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
864 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
869 if (empty($hidetop)) {
870 $pdf->SetXY($this->posxqty, $tab_top + 1);
871 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Batch"),
'',
'C');
876 if (empty($hidetop)) {
877 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
878 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"Inventory Code"),
'',
'C');
883 if (empty($hidetop)) {
884 $pdf->SetXY($this->posxunit, $tab_top + 1);
885 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"Label Movement"),
'',
'C');
890 if (empty($hidetop)) {
891 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
892 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
897 if (empty($hidetop)) {
898 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
899 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
902 $pdf->SetDrawColor(220, 26, 26);
903 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
904 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
905 $pdf->SetLineStyle(array(
'dash' => 0));
921 global $conf, $langs;
924 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
941 $pdf->SetTextColor(0, 0, 60);
942 $pdf->SetFont(
'',
'B', $default_font_size + 3);
944 $posy = $this->marge_haute;
945 $posx = $this->page_largeur - $this->marge_droite - 100;
947 $pdf->SetXY($this->marge_gauche, $posy);
950 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
951 if ($this->emetteur->logo) {
952 if (is_readable($logo)) {
954 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
956 $pdf->SetTextColor(200, 0, 0);
957 $pdf->SetFont(
'',
'B', $default_font_size - 2);
958 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
959 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
962 $text = $this->emetteur->name;
963 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
966 $pdf->SetFont(
'',
'B', $default_font_size + 3);
967 $pdf->SetXY($posx, $posy);
968 $pdf->SetTextColor(0, 0, 60);
969 $title = $outputlangs->transnoentities(
"Warehouse");
970 $pdf->MultiCell(100, 3, $title,
'',
'R');
972 $pdf->SetFont(
'',
'B', $default_font_size);
975 $pdf->SetXY($posx, $posy);
976 $pdf->SetTextColor(0, 0, 60);
978 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->label),
'',
'R');
981 $pdf->SetFont(
'',
'', $default_font_size - 1);
982 $pdf->SetXY($posx, $posy);
983 $pdf->SetTextColor(0, 0, 60);
984 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
987 $pdf->SetXY($posx - 50, $posy);
988 $pdf->MultiCell(150, 3,
$object->lieu,
'',
'R');
993 $pdf->SetXY($posx, $posy);
994 $pdf->SetTextColor(0, 0, 60);
995 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
998 $pdf->SetXY($posx - 50, $posy);
1000 if (!empty(
$object->fk_parent) && $e->fetch(
$object->fk_parent) > 0) {
1001 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
1003 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
1007 $nexY = $pdf->GetY();
1009 $pdf->SetXY($posx, $posy);
1010 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br(
$object->description), 0, 1);
1011 $nexY = $pdf->GetY();
1013 $calcproductsunique =
$object->nb_different_products();
1014 $calcproducts =
$object->nb_products();
1017 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1018 $nexY = $pdf->GetY();
1021 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1022 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1023 $nexY = $pdf->GetY();
1026 $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);
1027 $nexY = $pdf->GetY();
1031 $sql =
"SELECT max(m.datem) as datem";
1032 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1033 $sql .=
" WHERE m.fk_entrepot = ".((int)
$object->id);
1034 $resqlbis = $this->db->query($sql);
1036 $obj = $this->db->fetch_object($resqlbis);
1037 $lastmovementdate = $this->db->jdate($obj->datem);
1042 if ($lastmovementdate) {
1045 $toWrite = $outputlangs->transnoentities(
"None");
1048 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1049 $nexY = $pdf->GetY();
1086 $current_y = $pdf->getY();
1126 $pdf->SetTextColor(0, 0, 0);