32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
39require_once
'./lib/replenishment.lib.php';
50$langs->loadLangs(array(
'products',
'stocks',
'orders'));
53$hookmanager->initHooks(array(
'stockatdate'));
57$action =
GETPOST(
'action',
'aZ09');
59$mode =
GETPOST(
'mode',
'alpha');
61$ext = (GETPOSTISSET(
'output') && in_array(
GETPOST(
'output'), array(
'csv'))) ?
GETPOST(
'output') :
'';
65if (GETPOSTISSET(
'dateday') && GETPOSTISSET(
'datemonth') && GETPOSTISSET(
'dateyear')) {
70$search_ref =
GETPOST(
'search_ref',
'alphanohtml');
71$search_nom =
GETPOST(
'search_nom',
'alphanohtml');
77 $search_fk_warehouse =
GETPOST(
'search_fk_warehouse',
'array:int');
79 $search_fk_warehouse = array(
GETPOSTINT(
'search_fk_warehouse'));
83 $search_fk_warehouse = array(
GETPOSTINT(
'fk_warehouse'));
86foreach ($search_fk_warehouse as $key => $val) {
87 if ($val == -1 || empty($val)) {
88 unset($search_fk_warehouse[$key]);
92$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
93$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
95if (empty($page) || $page == -1) {
99$offset = $limit * $page;
101 $sortfield =
'p.ref';
107$parameters = array();
108$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
114if ($mode ==
'future') {
115 if ($date && $date < $now) {
117 $dateIsValid =
false;
120 if ($date && $date > $now) {
121 setEventMessages($langs->trans(
"ErrorDateMustBeBeforeToday"),
null,
'errors');
122 $dateIsValid =
false;
128 $socid = $user->socid;
139if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
142 $search_fk_warehouse = array();
147$warehouseStatus = array();
155$stock_prod_warehouse = array();
156$stock_prod = array();
157if ($date && $dateIsValid) {
158 $sql =
"SELECT ps.fk_product, ps.fk_entrepot as fk_warehouse,";
159 $sql .=
" SUM(ps.reel) AS stock";
160 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps";
161 $sql .=
", ".MAIN_DB_PREFIX.
"entrepot as w";
162 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
163 $sql .=
" WHERE w.entity IN (".getEntity(
'stock').
")";
164 $sql .=
" AND w.rowid = ps.fk_entrepot AND p.rowid = ps.fk_product";
166 $sql .=
" AND w.statut IN (".$db->sanitize(implode(
',', $warehouseStatus)).
")";
168 if ($productid > 0) {
169 $sql .=
" AND ps.fk_product = ".((int) $productid);
171 if (! empty($search_fk_warehouse)) {
172 $sql .=
" AND ps.fk_entrepot IN (".$db->sanitize(implode(
",", $search_fk_warehouse)).
")";
180 $sql .=
" GROUP BY fk_product, fk_entrepot";
183 $resql = $db->query($sql);
185 $num = $db->num_rows($resql);
189 $obj = $db->fetch_object($resql);
191 $tmp_fk_product = $obj->fk_product;
192 $tmp_fk_warehouse = $obj->fk_warehouse;
193 $stock = $obj->stock;
195 $stock_prod_warehouse[$tmp_fk_product][$tmp_fk_warehouse] = $stock;
196 $stock_prod[$tmp_fk_product] = (isset($stock_prod[$tmp_fk_product]) ? $stock_prod[$tmp_fk_product] : 0) + $stock;
207} elseif ($action ==
'filter') {
208 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
212$movements_prod_warehouse = array();
213$movements_prod = array();
214$movements_prod_warehouse_nb = array();
215$movements_prod_nb = array();
216if ($date && $dateIsValid) {
217 $sql =
"SELECT sm.fk_product, sm.fk_entrepot, SUM(sm.value) AS stock, COUNT(sm.rowid) AS nbofmovement";
218 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as sm";
219 $sql .=
", ".MAIN_DB_PREFIX.
"entrepot as w";
220 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
221 $sql .=
" WHERE w.entity IN (".getEntity(
'stock').
")";
222 $sql .=
" AND w.rowid = sm.fk_entrepot AND p.rowid = sm.fk_product ";
224 $sql .=
" AND w.statut IN (".$db->sanitize(implode(
',', $warehouseStatus)).
")";
226 if ($mode ==
'future') {
227 $sql .=
" AND sm.datem <= '".$db->idate($dateendofday).
"'";
229 $sql .=
" AND sm.datem >= '".$db->idate($dateendofday).
"'";
231 if ($productid > 0) {
232 $sql .=
" AND sm.fk_product = ".((int) $productid);
234 if (!empty($search_fk_warehouse)) {
235 $sql .=
" AND sm.fk_entrepot IN (".$db->sanitize(implode(
",", $search_fk_warehouse)).
")";
238 $sql .=
" AND p.ref LIKE '%".$db->escape($search_ref).
"%' ";
241 $sql .=
" AND p.label LIKE '%".$db->escape($search_nom).
"%' ";
243 $sql .=
" GROUP BY sm.fk_product, sm.fk_entrepot";
245 $resql = $db->query($sql);
248 $num = $db->num_rows($resql);
252 $obj = $db->fetch_object($resql);
253 $fk_product = $obj->fk_product;
254 $fk_entrepot = $obj->fk_entrepot;
255 $stock = $obj->stock;
256 $nbofmovement = $obj->nbofmovement;
259 $movements_prod_warehouse[$fk_product][$fk_entrepot] = $stock;
260 $movements_prod_warehouse_nb[$fk_product][$fk_entrepot] = $nbofmovement;
263 $movements_prod[$fk_product] = $stock + (array_key_exists($fk_product, $movements_prod) ? $movements_prod[$fk_product] : 0);
264 $movements_prod_nb[$fk_product] = $nbofmovement + (array_key_exists($fk_product, $movements_prod_nb) ? $movements_prod_nb[$fk_product] : 0);
283$form =
new Form($db);
289$title = $langs->trans(
'StockAtDate');
291$sql =
'SELECT p.rowid, p.ref, p.label, p.description, p.price, p.pmp,';
292$sql .=
' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
293$sql .=
' p.tms as datem, p.duration, p.tobuy, p.stock, ';
294if (!empty($search_fk_warehouse)) {
295 $sql .=
" SUM(p.pmp * ps.reel) as currentvalue, SUM(p.price * ps.reel) as sellvalue";
296 $sql .=
', SUM(ps.reel) as stock_reel';
298 $sql .=
" SUM(p.pmp * p.stock) as currentvalue, SUM(p.price * p.stock) as sellvalue";
301$parameters = array();
302$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters,
$object, $action);
303$sql .= $hookmanager->resPrint;
305$sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
306if (!empty($search_fk_warehouse)) {
307 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot IN ('.$db->sanitize(implode(
",", $search_fk_warehouse)).
")";
310$parameters = array();
311$reshook = $hookmanager->executeHooks(
'printFieldListJoin', $parameters,
$object, $action);
312$sql .= $hookmanager->resPrint;
313$sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
315 $sql .=
" AND p.rowid = ".((int) $productid);
318 $sql .=
" AND p.fk_product_type = 0";
320if (!empty($canvas)) {
321 $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
330$sqlGroupBy =
' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.pmp, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
331$sqlGroupBy .=
' p.tms, p.duration, p.tobuy, p.stock';
333$parameters = array(
'sqlGroupBy' => $sqlGroupBy);
334$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters,
$object, $action);
338 $sql .= $hookmanager->resPrint;
340 if (!empty($hookmanager->resArray[
'sqlGroupBy'])) {
341 $sqlGroupBy = $hookmanager->resArray[
'sqlGroupBy'];
348$parameters = array();
349$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
350$sql .= $hookmanager->resPrint;
352if ($sortfield ==
'stock_reel' && empty($search_fk_warehouse)) {
353 $sortfield =
'stock';
355if ($sortfield ==
'stock' && !empty($search_fk_warehouse)) {
356 $sortfield =
'stock_reel';
358$sql .= $db->order($sortfield, $sortorder);
360$nbtotalofrecords =
'';
361if ($date && $dateIsValid) {
363 $result = $db->query($sql);
364 $nbtotalofrecords = $db->num_rows($result);
365 if (($page * $limit) > $nbtotalofrecords || $ext ==
'csv') {
373 $sql .= $db->plimit($limit + 1, $offset);
374 $resql = $db->query($sql);
384 $num = $db->num_rows($resql);
389$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|';
390$helpurl .=
'ES:Módulo_Stocks';
392$stocklabel = $langs->trans(
'StockAtDate');
393if ($mode ==
'future') {
394 $stocklabel = $langs->trans(
"VirtualStockAtDate");
401 header(
"Content-Disposition: attachment; filename=stock".($date ?
'-'.date(
"Y-m-d", $date) :
'').
".csv");
404 print implode(
";", ($mode ==
'future') ?
405 array(
'"Product Reference"',
'"Label"',
'"Current Stock"',
'"'.$stocklabel.
'"',
'"Virtual Stock"') :
406 array(
'"Product Reference"',
'"Label"',
'"'.$stocklabel.
'"',
'"Estimated Stock Value"',
'"Estimate Sell Value"',
'"Movements"',
'"Current Stock"')).
"\r\n";
408 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_stockatdate');
412 $head[0][0] = DOL_URL_ROOT.
'/product/stock/stockatdate.php';
413 $head[0][1] = $langs->trans(
"StockAtDateInPast");
414 $head[0][2] =
'stockatdatepast';
416 $head[1][0] = DOL_URL_ROOT.
'/product/stock/stockatdate.php?mode=future';
417 $head[1][1] = $langs->trans(
"StockAtDateInFuture");
418 $head[1][2] =
'stockatdatefuture';
423 print
dol_get_fiche_head($head, ($mode ==
'future' ?
'stockatdatefuture' :
'stockatdatepast'),
'', -1,
'');
425 $desc = $langs->trans(
"StockAtDatePastDesc");
426 if ($mode ==
'future') {
427 $desc = $langs->trans(
"StockAtDateFutureDesc");
429 print
'<span class="opacitymedium">'.$desc.
'</span><br>'.
"\n";
432 print
'<form name="formFilterWarehouse" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
433 print
'<input type="hidden" name="token" value="'.newToken().
'">';
434 print
'<input type="hidden" name="action" value="filter">';
435 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
437 print
'<div class="inline-block valignmiddle" style="padding-right: 20px;">';
438 print
'<span class="fieldrequired">'.$langs->trans(
'Date').
'</span> '.$form->selectDate(($date ? $date : -1),
'date');
440 print
' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
441 print
img_picto(
'',
'product',
'class="pictofixedwidth"').
' ';
443 print $form->select_produits($productid,
'productid',
'', 0, 0, -1, 2,
'', 0, array(), 0, $langs->trans(
'Product'), 0,
'maxwidth300', 0,
'',
null, 1);
445 if ($mode !=
'future') {
447 print
' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
448 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$langs->trans(
"Warehouse").
' :';
450 $selected = ((GETPOSTISSET(
'search_fk_warehouse') || GETPOSTISSET(
'fk_warehouse')) ? $search_fk_warehouse :
'ifonenodefault');
451 print $formproduct->selectWarehouses($selected,
'search_fk_warehouse',
'', 1, 0, 0, $langs->trans(
'Warehouse'), 0, 0, array(),
'minwidth200', array(), 1,
false,
'e.ref', 1);
456 $parameters = array();
457 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
458 if (empty($reshook)) {
459 print $hookmanager->resPrint;
462 print
'<div class="inline-block valignmiddle">';
463 print
'<input type="submit" class="button" name="valid" value="'.$langs->trans(
'Refresh').
'">';
469 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
470 $param .=
'&contextpage='.urlencode($contextpage);
472 if ($limit > 0 && $limit !=
$conf->liste_limit) {
473 $param .=
'&limit='.((int) $limit);
475 $param .=
'&mode='.$mode;
476 $param_warehouse =
'';
477 if (!empty($search_fk_warehouse)) {
478 foreach ($search_fk_warehouse as $val) {
479 $param_warehouse .=
'&search_fk_warehouse[]='.$val;
481 $param .= $param_warehouse;
483 if ($productid > 0) {
484 $param .=
'&productid='.(int) $productid;
487 $param .=
'&dateday='.GETPOSTINT(
'dateday');
490 $param .=
'&datemonth='.GETPOSTINT(
'datemonth');
493 $param .=
'&dateyear='.GETPOSTINT(
'dateyear');
497 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'stock', 0,
'',
'', $limit, 0, 0, 1);
499 print
'<div class="div-table-responsive">';
502 print
'<a href="stockatdate.php?output=csv&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder).
'&type='.((int) $type).
'&mode='.urlencode($mode).
503 (($productid > 0) ?
"&productid=".((
int) $productid) :
'').
507 (GETPOSTISSET(
'dateday') ?
"&dateday=".
GETPOSTINT(
'dateday') :
'').
508 (GETPOSTISSET(
'datemonth') ?
"&datemonth=".
GETPOSTINT(
'datemonth') :
'').
509 (GETPOSTISSET(
'dateyear') ?
"&dateyear=".
GETPOSTINT(
'dateyear') :
'').
510 '" title="Download CSV" />';
511 print
img_picto(
'',
'download',
'class="pictofixedwidth"');
512 print
'Download CSV';
516 print
'<table class="liste centpercent">';
518 print
'<input type="hidden" name="token" value="'.newToken().
'">';
519 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
520 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
521 print
'<input type="hidden" name="type" value="'.$type.
'">';
522 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
525 print
'<tr class="liste_titre_filter">';
527 print
'<td class="liste_titre center maxwidthsearch">';
528 $searchpicto = $form->showFilterButtons(
'left');
532 print
'<td class="liste_titre"><input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'"></td>';
533 print
'<td class="liste_titre"><input class="flat" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).
'"></td>';
534 print
'<td class="liste_titre"></td>';
535 print
'<td class="liste_titre"></td>';
536 print
'<td class="liste_titre"></td>';
537 if ($mode ==
'future') {
538 print
'<td class="liste_titre"></td>';
540 print
'<td class="liste_titre"></td>';
541 print
'<td class="liste_titre"></td>';
544 $parameters = array(
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
545 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
546 print $hookmanager->resPrint;
550 print
'<td class="liste_titre center maxwidthsearch">';
551 $searchpicto = $form->showFilterButtons();
557 $fieldtosortcurrentstock =
'stock';
558 if (!empty($search_fk_warehouse)) {
559 $fieldtosortcurrentstock =
'stock_reel';
563 print
'<tr class="liste_titre">';
571 if ($mode ==
'future') {
572 print_liste_field_titre(
'CurrentStock', $_SERVER[
"PHP_SELF"], $fieldtosortcurrentstock,
'', $param,
'', $sortfield, $sortorder,
'right ');
574 print_liste_field_titre($stocklabel, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ',
'VirtualStockAtDateDesc');
575 print_liste_field_titre(
'VirtualStock', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ',
'VirtualStockDesc');
577 print_liste_field_titre($stocklabel, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
578 $tooltiptext = $langs->trans(
"QtyAtDate").
' x '.$langs->trans(
"AverageUnitPricePMPShort").
' ('.$langs->trans(
"Currently").
')';
579 print_liste_field_titre(
"EstimatedStockValue", $_SERVER[
"PHP_SELF"],
"currentvalue",
'', $param,
'', $sortfield, $sortorder,
'right ', $tooltiptext, 1);
580 $tooltiptext = $langs->trans(
"QtyAtDate").
' x '.$langs->trans(
"SellingPrice").
' ('.$langs->trans(
"Currently").
')';
581 print_liste_field_titre(
"EstimatedStockValueSell", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'right ', $tooltiptext, 1);
582 $tooltiptext = $langs->trans(
"MovementsSinceDate");
583 print_liste_field_titre(
"Movements", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'',
'',
'',
'right ', $tooltiptext, 1);
584 print_liste_field_titre(
'CurrentStock', $_SERVER[
"PHP_SELF"], $fieldtosortcurrentstock,
'', $param,
'', $sortfield, $sortorder,
'right ');
588 $parameters = array(
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
589 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
590 print $hookmanager->resPrint;
600$totalbuyingprice = 0;
601$totalsellingprice = 0;
602$totalcurrentstock = 0;
603$totalvirtualstock = 0;
606while ($i < ($limit ? min($num, $limit) : $num)) {
611 $objp = $db->fetch_object($resql);
614 $prod->fetch($objp->rowid);
635 if (!empty($search_fk_warehouse)) {
637 foreach ($search_fk_warehouse as $val) {
638 if (!is_numeric($currentstock)) {
641 $currentstock += empty($stock_prod_warehouse[$objp->rowid][$val]) ? 0 : $stock_prod_warehouse[$objp->rowid][$val];
648 $currentstock = empty($stock_prod[$objp->rowid]) ? 0 : $stock_prod[$objp->rowid];
656 if ($mode ==
'future') {
657 $prod->load_stock(
'warehouseopen,warehouseinternal,nobatch', 0, $dateendofday);
658 $stock = $prod->stock_theorique;
659 $prod->load_stock(
'warehouseopen,warehouseinternal,nobatch', 0);
660 $virtualstock = $prod->stock_theorique;
662 $stock = $currentstock;
663 if (!empty($search_fk_warehouse)) {
664 foreach ($search_fk_warehouse as $val) {
665 $stock -= empty($movements_prod_warehouse[$objp->rowid][$val]) ? 0 : $movements_prod_warehouse[$objp->rowid][$val];
666 $nbofmovement += empty($movements_prod_warehouse_nb[$objp->rowid][$val]) ? 0 : $movements_prod_warehouse_nb[$objp->rowid][$val];
669 $stock -= empty($movements_prod[$objp->rowid]) ? 0 : $movements_prod[$objp->rowid];
670 $nbofmovement += empty($movements_prod_nb[$objp->rowid]) ? 0 : $movements_prod_nb[$objp->rowid];
676 if ($mode ==
'future') {
677 print implode(
";", array(
679 '"'.$objp->label.
'"',
680 '"'.price2num($currentstock,
'MS').
'"',
681 '"'.price2num($stock,
'MS').
'"',
682 '"'.price2num($virtualstock,
'MS').
'"')).
"\r\n";
683 $totalvirtualstock += $virtualstock;
685 print implode(
";", array(
687 '"'.$objp->label.
'"',
689 price2num($stock * $objp->pmp,
'MT') ?
'"'.price2num($stock * $objp->pmp,
'MT').
'"' :
'',
690 !
getDolGlobalString(
'PRODUIT_MULTIPRICES') ?
'"'.
price2num($stock * $objp->
price,
'MT').
'"' :
'"'.$langs->trans(
"Variable").
'('.$langs->trans(
"OptionMULTIPRICESIsOn").
')"',
692 '"'.
price2num($currentstock,
'MS').
'"')).
"\r\n";
693 $totalbuyingprice += $stock * $objp->pmp;
694 $totalsellingprice += $stock * $objp->price;
696 $totalcurrentstock += $currentstock;
698 print
'<tr class="oddeven">';
702 print
'<td class="left"></td>';
706 print
'<td class="nowrap">'.$prod->getNomUrl(1,
'').
'</td>';
713 if ($mode ==
'future') {
715 print
'<td class="right">'.price(
price2num($currentstock,
'MS')).
'</td>';
718 print
'<td class="right"></td>';
721 print
'<td class="right">'.price(
price2num($stock,
'MS')).
'</td>';
724 print
'<td class="right">'.price(
price2num($virtualstock,
'MS')).
'</td>';
725 $totalvirtualstock += $virtualstock;
728 print
'<td class="right">'.($stock ?
price(
price2num($stock,
'MS')) : (
'<span class="opacitymedium">0</span>')).
'</td>';
731 $estimatedvalue = $stock * $objp->pmp;
732 print
'<td class="right" title="'.dolPrintHTMLForAttribute($langs->trans(
"AverageUnitPricePMPShort").
' ('.$langs->trans(
"Currently").
'): '.
price(
price2num($objp->pmp,
'MU'), 1)).
'">';
734 print
'<span class="amount">'.price(
price2num($estimatedvalue,
'MT'), 1).
'</span>';
738 $totalbuyingprice += $estimatedvalue;
742 print
'<td class="right"';
744 print
' title="'.dolPrintHTMLForAttribute($langs->trans(
"SellingPrice").
' ('.$langs->trans(
"Currently").
'): '.
price(
price2num($objp->price,
'MU'), 1));
748 print
'<span class="amount">';
749 if ($stock || (
float) ($stock * $objp->price)) {
753 $totalsellingprice += $stock * $objp->price;
755 $htmltext = $langs->trans(
"OptionMULTIPRICESIsOn");
756 print $form->textwithtooltip(
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>', $htmltext);
761 print
'<td class="right">';
762 if ($nbofmovement > 0) {
763 $url = DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.$objp->rowid;
764 if (GETPOSTISSET(
'datemonth')) {
765 $url .=
'&search_date_startday='.GETPOSTINT(
'dateday');
766 $url .=
'&search_date_startmonth='.GETPOSTINT(
'datemonth');
767 $url .=
'&search_date_startyear='.GETPOSTINT(
'dateyear');
769 if (count($search_fk_warehouse) > 1) {
772 foreach ($search_fk_warehouse as $val) {
773 $url .= ($val > 0 ?
'&search_warehouse='.((int) $val) :
'');
777 print
'<a href="'.$url.
'">';
779 print $langs->trans(
"Movements");
780 print
'<span class="tabs paddingleft"><span class="badge">'.$nbofmovement.
'</span></span>';
788 print
'<td class="right">'.($currentstock ?
price(
price2num($currentstock,
'MS')) :
'<span class="opacitymedium">0</span>').
'</td>';
790 $totalcurrentstock += $currentstock;
793 $parameters = array(
'objp' => $objp);
794 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
795 print $hookmanager->resPrint;
799 print
'<td class="right"></td>';
808$parameters = array(
'sql' => $sql);
809$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
811 print $hookmanager->resPrint;
815if ($mode ==
'future') {
822 ($mode ==
'future') ? array(
823 '"'.$langs->trans(
"Totalforthispage").
'"',
825 $productid > 0 ?
price2num($totalcurrentstock,
'MS') :
'',
829 '"'.$langs->trans(
"Totalforthispage").
'"',
832 '"'.
price2num($totalbuyingprice,
'MT').
'"',
835 $productid > 0 ?
price2num($totalcurrentstock,
'MS') :
'')
838 if (empty($date) || !$dateIsValid) {
839 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"EnterADateCriteria").
'</span></td></tr>';
841 print
'<tr class="liste_total">';
842 print
'<td>'.$langs->trans(
"Totalforthispage").
'</td>';
844 if ($mode ==
'future') {
845 print
'<td class="right">'.price(
price2num($totalcurrentstock,
'MS')).
'</td>';
848 print
'<td class="right">'.price(
price2num($totalvirtualstock,
'MS')).
'</td>';
851 print
'<td class="right">'.price(
price2num($totalbuyingprice,
'MT')).
'</td>';
853 print
'<td class="right">'.price(
price2num($totalsellingprice,
'MT')).
'</td>';
858 print
'<td class="right">'.($productid > 0 ?
price(
price2num($totalcurrentstock,
'MS')) :
'').
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
const STATUS_OPEN_INTERNAL
Warehouse open and only operations for stock transfers/corrections allowed (not for customer shipping...
const STATUS_OPEN_ALL
Warehouse open and any operations are allowed (customer shipping, supplier dispatch,...
Class to manage products or services.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.