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",
"sendings"));
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) > (
int) $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";
398 $productstatic =
new Product($this->db);
400 if (!file_exists($dir)) {
402 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
407 if (file_exists($dir)) {
409 if (!is_object($hookmanager)) {
410 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
413 $hookmanager->initHooks(array(
'pdfgeneration'));
414 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
416 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
421 $pdf->setAutoPageBreak(
true, 0);
423 $heightforinfotot = 40;
425 $heightforfooter = $this->marge_basse + 8;
427 if (class_exists(
'TCPDF')) {
428 $pdf->setPrintHeader(
false);
429 $pdf->setPrintFooter(
false);
434 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
435 $tplidx = $pdf->importPage(1);
440 $pdf->SetDrawColor(128, 128, 128);
442 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
443 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
444 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
445 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
446 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset(
$object->label));
448 $pdf->SetCompression(
false);
452 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
457 if (!empty($tplidx)) {
458 $pdf->useTemplate($tplidx);
462 $pdf->SetFont(
'',
'', $default_font_size - 1);
463 $pdf->MultiCell(0, 3,
'');
464 $pdf->SetTextColor(0, 0, 0);
467 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
469 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
473 $nexY = $tab_top - 1;
475 $nexY = $pdf->GetY();
479 $totalvalue = $totalvaluesell = 0;
480 $arrayofuniqueproduct = array();
483 $resql = $this->db->query($sql);
485 $num = $this->db->num_rows($resql);
487 for ($i = 0; $i < $nblines; $i++) {
488 $objp = $this->db->fetch_object($resql);
492 $sql =
"SELECT label";
493 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
494 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
495 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
498 $result = $this->db->query($sql);
500 $objtp = $this->db->fetch_object($result);
501 if ($objtp->label !=
'') {
502 $objp->produit = $objtp->label;
508 $pdf->SetFont(
'',
'', $default_font_size - 1);
509 $pdf->SetTextColor(0, 0, 0);
511 $pdf->setTopMargin($tab_top_newpage);
512 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
513 $pageposbefore = $pdf->getPage();
516 $curX = $this->posxdesc - 1;
518 $showpricebeforepagebreak = 1;
520 $pdf->startTransaction();
522 $pageposafter = $pdf->getPage();
523 if ($pageposafter > $pageposbefore) {
524 $pdf->rollbackTransaction(
true);
525 $pageposafter = $pageposbefore;
527 $pdf->setPageOrientation(
'',
true, $heightforfooter);
529 $pageposafter = $pdf->getPage();
530 $posyafter = $pdf->GetY();
531 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
532 if ($i == ($nblines - 1)) {
533 $pdf->AddPage(
'',
'',
true);
534 if (!empty($tplidx)) {
535 $pdf->useTemplate($tplidx);
540 $pdf->setPage($pageposafter + 1);
547 $showpricebeforepagebreak = 1;
549 $showpricebeforepagebreak = 0;
553 $pdf->commitTransaction();
555 $posYAfterDescription = $pdf->GetY();
557 $nexY = $pdf->GetY();
558 $pageposafter = $pdf->getPage();
560 $pdf->setPage($pageposbefore);
561 $pdf->setTopMargin($this->marge_haute);
562 $pdf->setPageOrientation(
'',
true, 0);
565 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
566 $pdf->setPage($pageposafter);
567 $curY = $tab_top_newpage;
570 $pdf->SetFont(
'',
'', $default_font_size - 1);
574 $userstatic->id = $objp->fk_user_author;
575 $userstatic->login = $objp->login;
576 $userstatic->lastname = $objp->lastname;
577 $userstatic->firstname = $objp->firstname;
578 $userstatic->photo = $objp->photo;
580 $productstatic->id = $objp->rowid;
581 $productstatic->ref = $objp->product_ref;
582 $productstatic->label = $objp->produit;
583 $productstatic->type = $objp->type;
584 $productstatic->entity = $objp->entity;
585 $productstatic->status_batch = $objp->tobatch;
587 $productlot->id = $objp->lotid;
588 $productlot->batch = $objp->batch;
589 $productlot->eatby = $objp->eatby;
590 $productlot->sellby = $objp->sellby;
592 $warehousestatic->id = $objp->entrepot_id;
593 $warehousestatic->label = $objp->warehouse_ref;
594 $warehousestatic->lieu = $objp->lieu;
596 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
597 if (!empty($objp->fk_origin)) {
598 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
604 $pdf->SetXY($this->posxidref, $curY);
605 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
608 $pdf->SetXY($this->posxdatemouv, $curY);
609 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->db->jdate($objp->datem),
'dayhour'), 0,
'L');
612 $pdf->SetXY($this->posxdesc, $curY);
613 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
616 $pdf->SetXY($this->posxlabel + 0.8, $curY);
617 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
620 $pdf->SetXY($this->posxqty, $curY);
621 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
624 $pdf->SetXY($this->posxup, $curY);
625 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
628 $pdf->SetXY($this->posxunit, $curY);
629 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
630 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
633 $pricemin = $objp->price;
634 $pdf->SetXY($this->posxdiscount, $curY);
635 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R',
false);
638 $valtoshow =
price2num($objp->qty,
'MS');
639 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
640 $totalunit += $objp->qty;
642 $pdf->SetXY($this->postotalht, $curY);
643 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R',
false);
645 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
650 $pdf->setPage($pageposafter);
651 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
653 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
654 $pdf->SetLineStyle(array(
'dash' => 0));
660 while ($pagenb < $pageposafter) {
661 $pdf->setPage($pagenb);
663 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
665 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
669 $pdf->setPage($pagenb);
670 $pdf->setPageOrientation(
'',
true, 0);
674 if (!empty($tplidx)) {
675 $pdf->useTemplate($tplidx);
678 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
680 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
682 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
687 if (!empty($tplidx)) {
688 $pdf->useTemplate($tplidx);
697 $this->db->free($resql);
702 $nexY = $pdf->GetY();
706 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
707 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
708 $pdf->SetLineStyle(array(
'dash' => 0));
710 $pdf->SetFont(
'',
'B', $default_font_size - 1);
711 $pdf->SetTextColor(0, 0, 120);
714 $pdf->SetXY($this->posxidref, $curY);
715 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
718 $pdf->SetXY($this->postotalht, $curY);
719 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, (
string) $totalunit, 0,
'R',
false);
725 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
727 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
728 if (!empty($extranote)) {
740 $pdf->SetFont(
'',
'', $default_font_size - 1);
741 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
742 $nexY = $pdf->GetY();
743 $height_note = $nexY - $tab_top;
746 $pdf->SetDrawColor(192, 192, 192);
747 $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');
749 $tab_height -= $height_note;
750 $tab_top = $nexY + 6;
755 $iniY = $tab_top + 7;
756 $curY = $tab_top + 7;
757 $nexY = $tab_top + 7;
759 $tab_top = $tab_top_newpage + 21;
763 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
764 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
766 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
767 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
770 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
780 if (method_exists($pdf,
'AliasNbPages')) {
781 $pdf->AliasNbPages();
786 $pdf->Output($file,
'F');
789 $hookmanager->initHooks(array(
'pdfgeneration'));
790 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
792 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
793 $this->warnings = $hookmanager->warnings;
795 $this->error = $hookmanager->error;
796 $this->errors = $hookmanager->errors;
803 $this->result = array(
'fullpath' => $file);
807 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
811 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
830 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
840 $currency = !empty($currency) ? $currency : $conf->currency;
844 $pdf->SetTextColor(0, 0, 0);
845 $pdf->SetFont(
'',
'', $default_font_size - 2);
847 if (empty($hidetop)) {
848 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
849 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
850 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
854 $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')));
858 $pdf->SetDrawColor(128, 128, 128);
859 $pdf->SetFont(
'',
'B', $default_font_size - 3);
864 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
865 $pdf->SetDrawColor(220, 26, 26);
866 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
867 $pdf->SetLineStyle(array(
'dash' => 0));
868 $pdf->SetDrawColor(128, 128, 128);
869 $pdf->SetTextColor(0, 0, 120);
872 if (empty($hidetop)) {
874 $pdf->SetXY($this->posxidref, $tab_top + 1);
875 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
880 if (empty($hidetop)) {
881 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
882 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
887 if (empty($hidetop)) {
888 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
889 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
894 if (empty($hidetop)) {
895 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
896 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
901 if (empty($hidetop)) {
902 $pdf->SetXY($this->posxqty, $tab_top + 1);
903 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Batch"),
'',
'C');
908 if (empty($hidetop)) {
909 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
910 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"InventoryCode"),
'',
'C');
915 if (empty($hidetop)) {
916 $pdf->SetXY($this->posxunit, $tab_top + 1);
917 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"LabelMovement"),
'',
'C');
922 if (empty($hidetop)) {
923 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
924 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
929 if (empty($hidetop)) {
930 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
931 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
934 $pdf->SetDrawColor(220, 26, 26);
935 $pdf->SetLineStyle(array(
'dash' =>
'0',
'color' => array(220, 26, 26)));
936 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
937 $pdf->SetLineStyle(array(
'dash' => 0));
953 global $conf, $langs;
956 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
973 $pdf->SetTextColor(0, 0, 60);
974 $pdf->SetFont(
'',
'B', $default_font_size + 3);
976 $posy = $this->marge_haute;
977 $posx = $this->page_largeur - $this->marge_droite - 100;
979 $pdf->SetXY($this->marge_gauche, $posy);
982 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
983 if ($this->emetteur->logo) {
984 if (is_readable($logo)) {
986 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
988 $pdf->SetTextColor(200, 0, 0);
989 $pdf->SetFont(
'',
'B', $default_font_size - 2);
990 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
991 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
994 $text = $this->emetteur->name;
995 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
998 $pdf->SetFont(
'',
'B', $default_font_size + 3);
999 $pdf->SetXY($posx, $posy);
1000 $pdf->SetTextColor(0, 0, 60);
1001 $title = $outputlangs->transnoentities(
"Warehouse");
1002 $pdf->MultiCell(100, 3, $title,
'',
'R');
1004 $pdf->SetFont(
'',
'B', $default_font_size);
1007 $pdf->SetXY($posx, $posy);
1008 $pdf->SetTextColor(0, 0, 60);
1010 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->label),
'',
'R');
1013 $pdf->SetFont(
'',
'', $default_font_size - 1);
1014 $pdf->SetXY($posx, $posy);
1015 $pdf->SetTextColor(0, 0, 60);
1016 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
1019 $pdf->SetXY($posx - 50, $posy);
1020 $pdf->MultiCell(150, 3,
$object->lieu,
'',
'R');
1025 $pdf->SetXY($posx, $posy);
1026 $pdf->SetTextColor(0, 0, 60);
1027 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
1030 $pdf->SetXY($posx - 50, $posy);
1032 if (!empty(
$object->fk_parent) && $e->fetch(
$object->fk_parent) > 0) {
1033 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
1035 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
1039 $nexY = $pdf->GetY();
1041 $pdf->SetXY($posx, $posy);
1042 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br(
$object->description), 0, 1);
1043 $nexY = $pdf->GetY();
1045 $calcproductsunique =
$object->nb_different_products();
1046 $calcproducts =
$object->nb_products();
1049 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1050 $nexY = $pdf->GetY();
1053 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1054 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1055 $nexY = $pdf->GetY();
1058 $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);
1059 $nexY = $pdf->GetY();
1063 $sql =
"SELECT max(m.datem) as datem";
1064 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1065 $sql .=
" WHERE m.fk_entrepot = ".((int)
$object->id);
1066 $resqlbis = $this->db->query($sql);
1068 $obj = $this->db->fetch_object($resqlbis);
1069 $lastmovementdate = $this->db->jdate($obj->datem);
1071 $lastmovementdate = 0;
1075 if ($lastmovementdate) {
1078 $toWrite = $outputlangs->transnoentities(
"None");
1081 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1082 $nexY = $pdf->GetY();
1118 $current_y = $pdf->getY();
1158 $pdf->SetTextColor(0, 0, 0);