177 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
180 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
182 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
184 if (!is_object($outputlangs)) {
185 $outputlangs = $langs;
189 $outputlangs->charset_output =
'ISO-8859-1';
193 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
200 $ref =
GETPOST(
'ref',
'alpha');
202 $product_id =
GETPOST(
"product_id");
203 $action =
GETPOST(
'action',
'aZ09');
204 $cancel =
GETPOST(
'cancel',
'alpha');
205 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
210 $search_ref =
GETPOST(
'search_ref',
'alpha');
211 $search_movement =
GETPOST(
"search_movement");
212 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
213 $search_product = trim(
GETPOST(
"search_product"));
214 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
215 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
216 $search_user = trim(
GETPOST(
"search_user"));
217 $search_batch = trim(
GETPOST(
"search_batch"));
218 $search_qty = trim(
GETPOST(
"search_qty"));
219 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
"intcomma");
223 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
224 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
225 if (empty($page) || $page == -1) {
228 $offset = $limit * $page;
230 $sortfield =
"m.datem";
239 $hookmanager->initHooks(array(
'movementlist'));
243 $extrafields->fetch_name_optionals_label(
'movement');
244 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
247 $productstatic =
new Product($this->db);
248 $warehousestatic =
new Entrepot($this->db);
250 $userstatic =
new User($this->db);
251 $element =
'movement';
253 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
254 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
255 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
256 $sql .=
" m.batch, m.price,";
257 $sql .=
" m.type_mouvement,";
258 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
259 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
261 if (!empty($extrafields->attributes[$element][
'label'])) {
262 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
263 $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
267 $parameters = array();
268 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
269 $sql .= $hookmanager->resPrint;
270 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
271 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
272 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
273 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
274 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
276 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
277 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
278 $sql .=
" WHERE m.fk_product = p.rowid";
280 $sql .=
" AND m.rowid = ".((int) $msid);
282 $sql .=
" AND m.fk_entrepot = e.rowid";
283 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
285 $sql .=
" AND p.fk_product_type = 0";
288 $sql .=
" AND e.rowid = ".((int)
$id);
292 $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)).
"'";
294 $sql .=
" AND date_format(m.datem, '%m') = '".((int) $month).
"'";
296 } elseif ($year > 0) {
299 if ($idproduct > 0) {
300 $sql .=
" AND p.rowid = ".((int) $idproduct);
302 if (!empty($search_ref)) {
305 if (!empty($search_movement)) {
308 if (!empty($search_inventorycode)) {
311 if (!empty($search_product_ref)) {
314 if (!empty($search_product)) {
317 if ($search_warehouse > 0) {
318 $sql .=
" AND e.rowid = ".((int) $search_warehouse);
320 if (!empty($search_user)) {
323 if (!empty($search_batch)) {
326 if ($search_qty !=
'') {
329 if ($search_type_mouvement > 0) {
330 $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
333 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
335 $parameters = array();
336 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
337 $sql .= $hookmanager->resPrint;
338 $sql .= $this->db->order($sortfield, $sortorder);
340 $nbtotalofrecords =
'';
342 $result = $this->db->query($sql);
343 $nbtotalofrecords = $this->db->num_rows($result);
344 if (($page * $limit) > $nbtotalofrecords) {
350 if (empty($search_inventorycode)) {
351 $sql .= $this->db->plimit($limit + 1, $offset);
355 $resql = $this->db->query($sql);
356 $nbtotalofrecords = $this->db->num_rows($resql);
364 if (
$conf->stock->dir_output) {
366 $product =
new Product($this->db);
369 if ($idproduct > 0) {
370 $product->fetch($idproduct);
372 if (
$id > 0 || $ref) {
379 $num = $this->db->num_rows($resql);
384 $dir =
$conf->stock->dir_output.
"/movement";
385 $file = $dir.
"/SPECIMEN.pdf";
388 if (!empty($search_inventorycode)) {
389 $objectref .=
"_".$id.
"_".$search_inventorycode;
391 if ($search_type_mouvement) {
392 $objectref .=
"_".$search_type_mouvement;
394 $dir =
$conf->stock->dir_output.
"/movement/".$objectref;
395 $file = $dir.
"/".$objectref.
".pdf";
399 $supplierprices = $stockFournisseur->list_product_fournisseur_price(
$object->id);
400 $object->supplierprices = $supplierprices;
402 $productstatic =
new Product($this->db);
404 if (!file_exists($dir)) {
406 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
411 if (file_exists($dir)) {
413 if (!is_object($hookmanager)) {
414 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
417 $hookmanager->initHooks(array(
'pdfgeneration'));
418 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
420 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
425 $pdf->setAutoPageBreak(
true, 0);
427 $heightforinfotot = 40;
429 $heightforfooter = $this->marge_basse + 8;
431 if (class_exists(
'TCPDF')) {
432 $pdf->setPrintHeader(
false);
433 $pdf->setPrintFooter(
false);
438 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
439 $tplidx = $pdf->importPage(1);
444 $pdf->SetDrawColor(128, 128, 128);
446 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
447 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
448 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
449 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
450 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset(
$object->label));
452 $pdf->SetCompression(
false);
456 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
466 $pdf->SetFont(
'',
'', $default_font_size - 1);
467 $pdf->MultiCell(0, 3,
'');
468 $pdf->SetTextColor(0, 0, 0);
471 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
473 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
477 $nexY = $tab_top - 1;
479 $nexY = $pdf->GetY();
483 $totalvalue = $totalvaluesell = 0;
484 $arrayofuniqueproduct = array();
487 $resql = $this->db->query($sql);
489 $num = $this->db->num_rows($resql);
491 for ($i = 0; $i < $nblines; $i++) {
492 $objp = $this->db->fetch_object($resql);
496 $sql =
"SELECT label";
497 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
498 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
499 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
502 $result = $this->db->query($sql);
504 $objtp = $this->db->fetch_object($result);
505 if ($objtp->label !=
'') {
506 $objp->produit = $objtp->label;
512 $pdf->SetFont(
'',
'', $default_font_size - 1);
513 $pdf->SetTextColor(0, 0, 0);
515 $pdf->setTopMargin($tab_top_newpage);
516 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
517 $pageposbefore = $pdf->getPage();
520 $curX = $this->posxdesc - 1;
522 $showpricebeforepagebreak = 1;
524 $pdf->startTransaction();
526 $pageposafter = $pdf->getPage();
527 if ($pageposafter > $pageposbefore) {
528 $pdf->rollbackTransaction(
true);
529 $pageposafter = $pageposbefore;
531 $pdf->setPageOrientation(
'',
true, $heightforfooter);
533 $pageposafter = $pdf->getPage();
534 $posyafter = $pdf->GetY();
535 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
536 if ($i == ($nblines - 1)) {
537 $pdf->AddPage(
'',
'',
true);
538 if (!empty($tplidx)) {
539 $pdf->useTemplate($tplidx);
544 $pdf->setPage($pageposafter + 1);
551 $showpricebeforepagebreak = 1;
553 $showpricebeforepagebreak = 0;
557 $pdf->commitTransaction();
559 $posYAfterDescription = $pdf->GetY();
561 $nexY = $pdf->GetY();
562 $pageposafter = $pdf->getPage();
564 $pdf->setPage($pageposbefore);
565 $pdf->setTopMargin($this->marge_haute);
566 $pdf->setPageOrientation(
'',
true, 0);
569 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
570 $pdf->setPage($pageposafter);
571 $curY = $tab_top_newpage;
574 $pdf->SetFont(
'',
'', $default_font_size - 1);
578 $userstatic->id = $objp->fk_user_author;
579 $userstatic->login = $objp->login;
580 $userstatic->lastname = $objp->lastname;
581 $userstatic->firstname = $objp->firstname;
582 $userstatic->photo = $objp->photo;
584 $productstatic->id = $objp->rowid;
585 $productstatic->ref = $objp->product_ref;
586 $productstatic->label = $objp->produit;
587 $productstatic->type = $objp->type;
588 $productstatic->entity = $objp->entity;
589 $productstatic->status_batch = $objp->tobatch;
591 $productlot->id = $objp->lotid;
592 $productlot->batch = $objp->batch;
593 $productlot->eatby = $objp->eatby;
594 $productlot->sellby = $objp->sellby;
596 $warehousestatic->id = $objp->entrepot_id;
597 $warehousestatic->label = $objp->warehouse_ref;
598 $warehousestatic->lieu = $objp->lieu;
600 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
601 if (!empty($objp->fk_origin)) {
602 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
608 $pdf->SetXY($this->posxidref, $curY);
609 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
612 $pdf->SetXY($this->posxdatemouv, $curY);
613 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->db->jdate($objp->datem),
'dayhour'), 0,
'L');
616 $pdf->SetXY($this->posxdesc, $curY);
617 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
620 $pdf->SetXY($this->posxlabel + 0.8, $curY);
621 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
624 $pdf->SetXY($this->posxqty, $curY);
625 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
628 $pdf->SetXY($this->posxup, $curY);
629 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
632 $pdf->SetXY($this->posxunit, $curY);
633 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
634 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
637 $pricemin = $objp->price;
638 $pdf->SetXY($this->posxdiscount, $curY);
639 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R',
false);
642 $valtoshow =
price2num($objp->qty,
'MS');
643 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
644 $totalunit += $objp->qty;
646 $pdf->SetXY($this->postotalht, $curY);
647 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R',
false);
649 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
654 $pdf->setPage($pageposafter);
655 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
657 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
658 $pdf->SetLineStyle(array(
'dash' => 0));
664 while ($pagenb < $pageposafter) {
665 $pdf->setPage($pagenb);
667 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
669 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
673 $pdf->setPage($pagenb);
674 $pdf->setPageOrientation(
'',
true, 0);
678 if (!empty($tplidx)) {
679 $pdf->useTemplate($tplidx);
682 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
684 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
686 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
691 if (!empty($tplidx)) {
692 $pdf->useTemplate($tplidx);
701 $this->db->free($resql);
706 $nexY = $pdf->GetY();
710 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
711 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
712 $pdf->SetLineStyle(array(
'dash' => 0));
714 $pdf->SetFont(
'',
'B', $default_font_size - 1);
715 $pdf->SetTextColor(0, 0, 120);
718 $pdf->SetXY($this->posxidref, $curY);
719 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
722 $pdf->SetXY($this->postotalht, $curY);
723 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, (
string) $totalunit, 0,
'R',
false);
729 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
731 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
732 if (!empty($extranote)) {
744 $pdf->SetFont(
'',
'', $default_font_size - 1);
745 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
746 $nexY = $pdf->GetY();
747 $height_note = $nexY - $tab_top;
750 $pdf->SetDrawColor(192, 192, 192);
751 $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');
753 $tab_height -= $height_note;
754 $tab_top = $nexY + 6;
759 $iniY = $tab_top + 7;
760 $curY = $tab_top + 7;
761 $nexY = $tab_top + 7;
763 $tab_top = $tab_top_newpage + 21;
767 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
768 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
770 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
771 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
774 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
784 if (method_exists($pdf,
'AliasNbPages')) {
785 $pdf->AliasNbPages();
790 $pdf->Output($file,
'F');
793 $hookmanager->initHooks(array(
'pdfgeneration'));
794 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
796 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
798 $this->error = $hookmanager->error;
799 $this->errors = $hookmanager->errors;
804 $this->result = array(
'fullpath' => $file);
808 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
812 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
831 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
841 $currency = !empty($currency) ? $currency :
$conf->currency;
845 $pdf->SetTextColor(0, 0, 0);
846 $pdf->SetFont(
'',
'', $default_font_size - 2);
848 if (empty($hidetop)) {
849 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
850 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
851 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
855 $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')));
859 $pdf->SetDrawColor(128, 128, 128);
860 $pdf->SetFont(
'',
'B', $default_font_size - 3);
865 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
866 $pdf->SetDrawColor(220, 26, 26);
867 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
868 $pdf->SetLineStyle(array(
'dash' => 0));
869 $pdf->SetDrawColor(128, 128, 128);
870 $pdf->SetTextColor(0, 0, 120);
873 if (empty($hidetop)) {
875 $pdf->SetXY($this->posxidref, $tab_top + 1);
876 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
881 if (empty($hidetop)) {
882 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
883 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
888 if (empty($hidetop)) {
889 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
890 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
895 if (empty($hidetop)) {
896 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
897 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
902 if (empty($hidetop)) {
903 $pdf->SetXY($this->posxqty, $tab_top + 1);
904 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Batch"),
'',
'C');
909 if (empty($hidetop)) {
910 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
911 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"InventoryCode"),
'',
'C');
916 if (empty($hidetop)) {
917 $pdf->SetXY($this->posxunit, $tab_top + 1);
918 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"LabelMovement"),
'',
'C');
923 if (empty($hidetop)) {
924 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
925 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
930 if (empty($hidetop)) {
931 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
932 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
935 $pdf->SetDrawColor(220, 26, 26);
936 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
937 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
938 $pdf->SetLineStyle(array(
'dash' => 0));
954 global
$conf, $langs;
957 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
974 $pdf->SetTextColor(0, 0, 60);
975 $pdf->SetFont(
'',
'B', $default_font_size + 3);
977 $posy = $this->marge_haute;
978 $posx = $this->page_largeur - $this->marge_droite - 100;
980 $pdf->SetXY($this->marge_gauche, $posy);
983 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
984 if ($this->emetteur->logo) {
985 if (is_readable($logo)) {
987 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
989 $pdf->SetTextColor(200, 0, 0);
990 $pdf->SetFont(
'',
'B', $default_font_size - 2);
991 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
992 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
995 $text = $this->emetteur->name;
996 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
999 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1000 $pdf->SetXY($posx, $posy);
1001 $pdf->SetTextColor(0, 0, 60);
1002 $title = $outputlangs->transnoentities(
"Warehouse");
1003 $pdf->MultiCell(100, 3, $title,
'',
'R');
1005 $pdf->SetFont(
'',
'B', $default_font_size);
1008 $pdf->SetXY($posx, $posy);
1009 $pdf->SetTextColor(0, 0, 60);
1011 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->label),
'',
'R');
1014 $pdf->SetFont(
'',
'', $default_font_size - 1);
1015 $pdf->SetXY($posx, $posy);
1016 $pdf->SetTextColor(0, 0, 60);
1017 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
1020 $pdf->SetXY($posx - 50, $posy);
1021 $pdf->MultiCell(150, 3,
$object->lieu,
'',
'R');
1026 $pdf->SetXY($posx, $posy);
1027 $pdf->SetTextColor(0, 0, 60);
1028 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
1031 $pdf->SetXY($posx - 50, $posy);
1033 if (!empty(
$object->fk_parent) && $e->fetch(
$object->fk_parent) > 0) {
1034 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
1036 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
1040 $nexY = $pdf->GetY();
1042 $pdf->SetXY($posx, $posy);
1043 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br(
$object->description), 0, 1);
1044 $nexY = $pdf->GetY();
1046 $calcproductsunique =
$object->nb_different_products();
1047 $calcproducts =
$object->nb_products();
1050 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1051 $nexY = $pdf->GetY();
1054 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1055 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1056 $nexY = $pdf->GetY();
1059 $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);
1060 $nexY = $pdf->GetY();
1064 $sql =
"SELECT max(m.datem) as datem";
1065 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1066 $sql .=
" WHERE m.fk_entrepot = ".((int)
$object->id);
1067 $resqlbis = $this->db->query($sql);
1069 $obj = $this->db->fetch_object($resqlbis);
1070 $lastmovementdate = $this->db->jdate($obj->datem);
1072 $lastmovementdate = 0;
1076 if ($lastmovementdate) {
1079 $toWrite = $outputlangs->transnoentities(
"None");
1082 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1083 $nexY = $pdf->GetY();
1119 $current_y = $pdf->getY();
1159 $pdf->SetTextColor(0, 0, 0);