30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
37require_once
'./lib/replenishment.lib.php';
40$langs->loadLangs(array(
'products',
'stocks',
'orders'));
43$hookmanager->initHooks(array(
'stockatdate'));
47$action =
GETPOST(
'action',
'aZ09');
49$mode =
GETPOST(
'mode',
'alpha');
51$ext=(GETPOSTISSET(
'output') && in_array(
GETPOST(
'output'), array(
'csv'))) ?
GETPOST(
'output') :
'';
55if (GETPOSTISSET(
'dateday') && GETPOSTISSET(
'datemonth') && GETPOSTISSET(
'dateyear')) {
60$search_ref =
GETPOST(
'search_ref',
'alphanohtml');
61$search_nom =
GETPOST(
'search_nom',
'alphanohtml');
67 $search_fk_warehouse =
GETPOST(
'search_fk_warehouse',
'array:int');
69 $search_fk_warehouse = array(
GETPOSTINT(
'search_fk_warehouse'));
73 $search_fk_warehouse = array(
GETPOSTINT(
'fk_warehouse'));
76foreach ($search_fk_warehouse as $key => $val) {
77 if ($val == -1 || empty($val)) {
78 unset($search_fk_warehouse[$key]);
82$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
83$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
85if (empty($page) || $page == -1) {
89$offset = $limit * $page;
98$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
104if ($mode ==
'future') {
105 if ($date && $date < $now) {
107 $dateIsValid =
false;
110 if ($date && $date > $now) {
111 setEventMessages($langs->trans(
"ErrorDateMustBeBeforeToday"),
null,
'errors');
112 $dateIsValid =
false;
118 $socid = $user->socid;
129if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
132 $search_fk_warehouse = array();
137$warehouseStatus = array();
145$stock_prod_warehouse = array();
146$stock_prod = array();
147if ($date && $dateIsValid) {
148 $sql =
"SELECT ps.fk_product, ps.fk_entrepot as fk_warehouse,";
149 $sql .=
" SUM(ps.reel) AS stock";
150 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps";
151 $sql .=
", ".MAIN_DB_PREFIX.
"entrepot as w";
152 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
153 $sql .=
" WHERE w.entity IN (".getEntity(
'stock').
")";
154 $sql .=
" AND w.rowid = ps.fk_entrepot AND p.rowid = ps.fk_product";
156 $sql .=
" AND w.statut IN (".$db->sanitize(implode(
',', $warehouseStatus)).
")";
158 if ($productid > 0) {
159 $sql .=
" AND ps.fk_product = ".((int) $productid);
161 if (! empty($search_fk_warehouse)) {
162 $sql .=
" AND ps.fk_entrepot IN (".$db->sanitize(implode(
",", $search_fk_warehouse)).
")";
170 $sql .=
" GROUP BY fk_product, fk_entrepot";
173 $resql = $db->query($sql);
175 $num = $db->num_rows($resql);
179 $obj = $db->fetch_object($resql);
181 $tmp_fk_product = $obj->fk_product;
182 $tmp_fk_warehouse = $obj->fk_warehouse;
183 $stock = $obj->stock;
185 $stock_prod_warehouse[$tmp_fk_product][$tmp_fk_warehouse] = $stock;
186 $stock_prod[$tmp_fk_product] = (isset($stock_prod[$tmp_fk_product]) ? $stock_prod[$tmp_fk_product] : 0) + $stock;
196} elseif ($action ==
'filter') {
197 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
201$movements_prod_warehouse = array();
202$movements_prod = array();
203$movements_prod_warehouse_nb = array();
204$movements_prod_nb = array();
205if ($date && $dateIsValid) {
206 $sql =
"SELECT sm.fk_product, sm.fk_entrepot, SUM(sm.value) AS stock, COUNT(sm.rowid) AS nbofmovement";
207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as sm";
208 $sql .=
", ".MAIN_DB_PREFIX.
"entrepot as w";
209 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
210 $sql .=
" WHERE w.entity IN (".getEntity(
'stock').
")";
211 $sql .=
" AND w.rowid = sm.fk_entrepot AND p.rowid = sm.fk_product ";
213 $sql .=
" AND w.statut IN (".$db->sanitize(implode(
',', $warehouseStatus)).
")";
215 if ($mode ==
'future') {
216 $sql .=
" AND sm.datem <= '".$db->idate($dateendofday).
"'";
218 $sql .=
" AND sm.datem >= '".$db->idate($dateendofday).
"'";
220 if ($productid > 0) {
221 $sql .=
" AND sm.fk_product = ".((int) $productid);
223 if (!empty($search_fk_warehouse)) {
224 $sql .=
" AND sm.fk_entrepot IN (".$db->sanitize(implode(
",", $search_fk_warehouse)).
")";
227 $sql .=
" AND p.ref LIKE '%".$db->escape($search_ref).
"%' ";
230 $sql .=
" AND p.label LIKE '%".$db->escape($search_nom).
"%' ";
232 $sql .=
" GROUP BY sm.fk_product, sm.fk_entrepot";
234 $resql = $db->query($sql);
237 $num = $db->num_rows($resql);
241 $obj = $db->fetch_object($resql);
242 $fk_product = $obj->fk_product;
243 $fk_entrepot = $obj->fk_entrepot;
244 $stock = $obj->stock;
245 $nbofmovement = $obj->nbofmovement;
248 $movements_prod_warehouse[$fk_product][$fk_entrepot] = $stock;
249 $movements_prod_warehouse_nb[$fk_product][$fk_entrepot] = $nbofmovement;
252 $movements_prod[$fk_product] = $stock + (array_key_exists($fk_product, $movements_prod)?$movements_prod[$fk_product]:0);
253 $movements_prod_nb[$fk_product] = $nbofmovement + (array_key_exists($fk_product, $movements_prod_nb)?$movements_prod_nb[$fk_product]:0);
271$form =
new Form($db);
277$title = $langs->trans(
'StockAtDate');
279$sql =
'SELECT p.rowid, p.ref, p.label, p.description, p.price, p.pmp,';
280$sql .=
' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
281$sql .=
' p.tms as datem, p.duration, p.tobuy, p.stock, ';
282if (!empty($search_fk_warehouse)) {
283 $sql .=
" SUM(p.pmp * ps.reel) as currentvalue, SUM(p.price * ps.reel) as sellvalue";
284 $sql .=
', SUM(ps.reel) as stock_reel';
286 $sql .=
" SUM(p.pmp * p.stock) as currentvalue, SUM(p.price * p.stock) as sellvalue";
289$parameters = array();
290$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters,
$object, $action);
291$sql .= $hookmanager->resPrint;
293$sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
294if (!empty($search_fk_warehouse)) {
295 $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)).
")";
298$parameters = array();
299$reshook = $hookmanager->executeHooks(
'printFieldListJoin', $parameters,
$object, $action);
300$sql .= $hookmanager->resPrint;
301$sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
303 $sql .=
" AND p.rowid = ".((int) $productid);
306 $sql .=
" AND p.fk_product_type = 0";
308if (!empty($canvas)) {
309 $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
318$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,';
319$sqlGroupBy .=
' p.tms, p.duration, p.tobuy, p.stock';
321$parameters = array(
'sqlGroupBy' => $sqlGroupBy);
322$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters,
$object, $action);
326 $sql .= $hookmanager->resPrint;
328 if (!empty($hookmanager->resArray[
'sqlGroupBy'])) {
329 $sqlGroupBy = $hookmanager->resArray[
'sqlGroupBy'];
336$parameters = array();
337$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
338$sql .= $hookmanager->resPrint;
340if ($sortfield ==
'stock_reel' && empty($search_fk_warehouse)) {
341 $sortfield =
'stock';
343if ($sortfield ==
'stock' && !empty($search_fk_warehouse)) {
344 $sortfield =
'stock_reel';
346$sql .= $db->order($sortfield, $sortorder);
348$nbtotalofrecords =
'';
349if ($date && $dateIsValid) {
351 $result = $db->query($sql);
352 $nbtotalofrecords = $db->num_rows($result);
353 if (($page * $limit) > $nbtotalofrecords || $ext ==
'csv') {
361 $sql .= $db->plimit($limit + 1, $offset);
362 $resql = $db->query($sql);
372 $num = $db->num_rows($resql);
377$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|';
378$helpurl .=
'ES:Módulo_Stocks';
380$stocklabel = $langs->trans(
'StockAtDate');
381if ($mode ==
'future') {
382 $stocklabel = $langs->trans(
"VirtualStockAtDate");
389 header(
"Content-Disposition: attachment; filename=stock".($date?
'-'.date(
"Y-m-d", $date):
'').
".csv");
392 print implode(
";", ($mode ==
'future') ?
393 array(
'"Product Reference"',
'"Label"',
'"Current Stock"',
'"'.$stocklabel.
'"',
'"Virtual Stock"'):
394 array(
'"Product Reference"',
'"Label"',
'"'.$stocklabel.
'"',
'"Estimated Stock Value"',
'"Estimate Sell Value"',
'"Movements"',
'"Current Stock"')).
"\r\n";
396 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_stockatdate');
400 $head[0][0] = DOL_URL_ROOT.
'/product/stock/stockatdate.php';
401 $head[0][1] = $langs->trans(
"StockAtDateInPast");
402 $head[0][2] =
'stockatdatepast';
404 $head[1][0] = DOL_URL_ROOT.
'/product/stock/stockatdate.php?mode=future';
405 $head[1][1] = $langs->trans(
"StockAtDateInFuture");
406 $head[1][2] =
'stockatdatefuture';
411 print
dol_get_fiche_head($head, ($mode ==
'future' ?
'stockatdatefuture' :
'stockatdatepast'),
'', -1,
'');
413 $desc = $langs->trans(
"StockAtDatePastDesc");
414 if ($mode ==
'future') {
415 $desc = $langs->trans(
"StockAtDateFutureDesc");
417 print
'<span class="opacitymedium">'.$desc.
'</span><br>'.
"\n";
420 print
'<form name="formFilterWarehouse" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
421 print
'<input type="hidden" name="token" value="'.newToken().
'">';
422 print
'<input type="hidden" name="action" value="filter">';
423 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
425 print
'<div class="inline-block valignmiddle" style="padding-right: 20px;">';
426 print
'<span class="fieldrequired">'.$langs->trans(
'Date').
'</span> '.$form->selectDate(($date ? $date : -1),
'date');
428 print
' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
429 print
img_picto(
'',
'product',
'class="pictofiwedwidth"').
' ';
431 print $form->select_produits($productid,
'productid',
'', 0, 0, -1, 2,
'', 0, array(), 0, $langs->trans(
'Product'), 0,
'maxwidth300', 0,
'',
null, 1);
433 if ($mode !=
'future') {
435 print
' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
436 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$langs->trans(
"Warehouse").
' :';
438 $selected = ((GETPOSTISSET(
'search_fk_warehouse') || GETPOSTISSET(
'fk_warehouse')) ? $search_fk_warehouse :
'ifonenodefault');
439 print $formproduct->selectWarehouses($selected,
'search_fk_warehouse',
'', 1, 0, 0, $langs->trans(
'Warehouse'), 0, 0,
null,
'minwidth200',
null, 1,
false,
'e.ref', 1);
444 $parameters = array();
445 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
446 if (empty($reshook)) {
447 print $hookmanager->resPrint;
450 print
'<div class="inline-block valignmiddle">';
451 print
'<input type="submit" class="button" name="valid" value="'.$langs->trans(
'Refresh').
'">';
457 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
458 $param .=
'&contextpage='.urlencode($contextpage);
460 if ($limit > 0 && $limit != $conf->liste_limit) {
461 $param .=
'&limit='.((int) $limit);
463 $param .=
'&mode='.$mode;
464 $param_warehouse =
'';
465 if (!empty($search_fk_warehouse)) {
466 foreach ($search_fk_warehouse as $val) {
467 $param_warehouse .=
'&search_fk_warehouse[]='.$val;
469 $param .= $param_warehouse;
471 if ($productid > 0) {
472 $param .=
'&productid='.(int) $productid;
475 $param .=
'&dateday='.GETPOSTINT(
'dateday');
478 $param .=
'&datemonth='.GETPOSTINT(
'datemonth');
481 $param .=
'&dateyear='.GETPOSTINT(
'dateyear');
485 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'stock', 0,
'',
'', $limit, 0, 0, 1);
487 print
'<div class="div-table-responsive">';
490 print
'<a href="stockatdate.php?output=csv&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder).
'&type='.((int) $type).
'&mode='.urlencode($mode).
491 (($productid > 0)?
"&productid=".((
int) $productid):
'').
495 (GETPOSTISSET(
'dateday')?
"&dateday=".
GETPOSTINT(
'dateday'):
'').
496 (GETPOSTISSET(
'datemonth')?
"&datemonth=".
GETPOSTINT(
'datemonth'):
'').
497 (GETPOSTISSET(
'dateyear')?
"&dateyear=".
GETPOSTINT(
'dateyear'):
'').
498 '" title="Download CSV" />';
499 print
img_picto(
'',
'download',
'class="pictofixedwidth"');
500 print
'Download CSV';
504 print
'<table class="liste centpercent">';
506 print
'<input type="hidden" name="token" value="'.newToken().
'">';
507 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
508 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
509 print
'<input type="hidden" name="type" value="'.$type.
'">';
510 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
513 print
'<tr class="liste_titre_filter">';
515 print
'<td class="liste_titre center maxwidthsearch">';
516 $searchpicto = $form->showFilterButtons(
'left');
520 print
'<td class="liste_titre"><input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'"></td>';
521 print
'<td class="liste_titre"><input class="flat" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).
'"></td>';
522 print
'<td class="liste_titre"></td>';
523 print
'<td class="liste_titre"></td>';
524 print
'<td class="liste_titre"></td>';
525 if ($mode ==
'future') {
526 print
'<td class="liste_titre"></td>';
528 print
'<td class="liste_titre"></td>';
529 print
'<td class="liste_titre"></td>';
532 $parameters = array(
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
533 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
534 print $hookmanager->resPrint;
538 print
'<td class="liste_titre center maxwidthsearch">';
539 $searchpicto = $form->showFilterButtons();
545 $fieldtosortcurrentstock =
'stock';
546 if (!empty($search_fk_warehouse)) {
547 $fieldtosortcurrentstock =
'stock_reel';
551 print
'<tr class="liste_titre">';
559 if ($mode ==
'future') {
560 print_liste_field_titre(
'CurrentStock', $_SERVER[
"PHP_SELF"], $fieldtosortcurrentstock, $param,
'',
'', $sortfield, $sortorder,
'right ');
562 print_liste_field_titre($stocklabel, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'right ',
'VirtualStockAtDateDesc');
563 print_liste_field_titre(
'VirtualStock', $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'right ',
'VirtualStockDesc');
565 print_liste_field_titre($stocklabel, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'right ');
566 $tooltiptext = $langs->trans(
"QtyAtDate").
' x '.$langs->trans(
"AverageUnitPricePMPShort").
' ('.$langs->trans(
"Currently").
')';
567 print_liste_field_titre(
"EstimatedStockValue", $_SERVER[
"PHP_SELF"],
"currentvalue",
'', $param,
'', $sortfield, $sortorder,
'right ', $tooltiptext, 1);
568 $tooltiptext = $langs->trans(
"QtyAtDate").
' x '.$langs->trans(
"SellingPrice").
' ('.$langs->trans(
"Currently").
')';
569 print_liste_field_titre(
"EstimatedStockValueSell", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'right ', $tooltiptext, 1);
570 $tooltiptext = $langs->trans(
"MovementsSinceDate");
571 print_liste_field_titre(
'', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'',
'',
'',
'right ', $tooltiptext, 1);
572 print_liste_field_titre(
'CurrentStock', $_SERVER[
"PHP_SELF"], $fieldtosortcurrentstock, $param,
'',
'', $sortfield, $sortorder,
'right ');
576 $parameters = array(
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
577 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
578 print $hookmanager->resPrint;
588$totalbuyingprice = 0;
589$totalsellingprice = 0;
590$totalcurrentstock = 0;
591$totalvirtualstock = 0;
594while ($i < ($limit ? min($num, $limit) : $num)) {
595 $objp = $db->fetch_object($resql);
598 $prod->fetch($objp->rowid);
619 if (!empty($search_fk_warehouse)) {
621 foreach ($search_fk_warehouse as $val) {
622 if (!is_numeric($currentstock)) {
625 $currentstock += empty($stock_prod_warehouse[$objp->rowid][$val]) ? 0 : $stock_prod_warehouse[$objp->rowid][$val];
632 $currentstock = empty($stock_prod[$objp->rowid]) ? 0 : $stock_prod[$objp->rowid];
638 if ($mode ==
'future') {
639 $prod->load_stock(
'warehouseopen,warehouseinternal,nobatch', 0, $dateendofday);
640 $stock = $prod->stock_theorique;
641 $prod->load_stock(
'warehouseopen,warehouseinternal,nobatch', 0);
642 $virtualstock = $prod->stock_theorique;
644 $stock = $currentstock;
646 if (!empty($search_fk_warehouse)) {
647 foreach ($search_fk_warehouse as $val) {
648 $stock -= empty($movements_prod_warehouse[$objp->rowid][$val]) ? 0 : $movements_prod_warehouse[$objp->rowid][$val];
649 $nbofmovement += empty($movements_prod_warehouse_nb[$objp->rowid][$val]) ? 0 : $movements_prod_warehouse_nb[$objp->rowid][$val];
652 $stock -= empty($movements_prod[$objp->rowid]) ? 0 : $movements_prod[$objp->rowid];
653 $nbofmovement += empty($movements_prod_nb[$objp->rowid]) ? 0 : $movements_prod_nb[$objp->rowid];
659 if ($mode ==
'future') {
660 print implode(
";", array(
662 '"'.$objp->label.
'"',
663 '"'.price2num($currentstock,
'MS').
'"',
664 '"'.price2num($stock,
'MS').
'"',
665 '"'.price2num($virtualstock,
'MS').
'"')).
"\r\n";
666 $totalvirtualstock += $virtualstock;
668 print implode(
";", array(
670 '"'.$objp->label.
'"',
672 price2num($stock * $objp->pmp,
'MT')?
'"'.price2num($stock * $objp->pmp,
'MT').
'"':
'',
673 !
getDolGlobalString(
'PRODUIT_MULTIPRICES')?
'"'.
price2num($stock * $objp->
price,
'MT').
'"':
'"'.$langs->trans(
"Variable").
'('.$langs->trans(
"OptionMULTIPRICESIsOn").
')"',
675 '"'.
price2num($currentstock,
'MS').
'"')).
"\r\n";
676 $totalbuyingprice += $stock * $objp->pmp;
677 $totalsellingprice += $stock * $objp->price;
679 $totalcurrentstock += $currentstock;
681 print
'<tr class="oddeven">';
685 print
'<td class="left"></td>';
689 print
'<td class="nowrap">'.$prod->getNomUrl(1,
'').
'</td>';
696 if ($mode ==
'future') {
698 print
'<td class="right">'.price(
price2num($currentstock,
'MS')).
'</td>';
701 print
'<td class="right"></td>';
704 print
'<td class="right">'.price(
price2num($stock,
'MS')).
'</td>';
707 print
'<td class="right">'.price(
price2num($virtualstock,
'MS')).
'</td>';
708 $totalvirtualstock += $virtualstock;
711 print
'<td class="right">'.($stock ?
price(
price2num($stock,
'MS')) : (
'<span class="opacitymedium">0</span>')).
'</td>';
714 $estimatedvalue = $stock * $objp->pmp;
715 print
'<td class="right" title="'.dolPrintHTMLForAttribute($langs->trans(
"AverageUnitPricePMPShort").
' ('.$langs->trans(
"Currently").
'): '.
price(
price2num($objp->pmp,
'MU'), 1)).
'">';
717 print
'<span class="amount">'.price(
price2num($estimatedvalue,
'MT'), 1).
'</span>';
721 $totalbuyingprice += $estimatedvalue;
725 print
'<td class="right"';
727 print
' title="'.dolPrintHTMLForAttribute($langs->trans(
"SellingPrice").
' ('.$langs->trans(
"Currently").
'): '.
price(
price2num($objp->price,
'MU'), 1));
731 print
'<span class="amount">';
732 if ($stock || (
float) ($stock * $objp->price)) {
736 $totalsellingprice += $stock * $objp->price;
738 $htmltext = $langs->trans(
"OptionMULTIPRICESIsOn");
739 print $form->textwithtooltip(
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>', $htmltext);
744 print
'<td class="right">';
745 if ($nbofmovement > 0) {
746 $url = DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.$objp->rowid;
747 if (GETPOSTISSET(
'datemonth')) {
748 $url .=
'&search_date_startday='.GETPOSTINT(
'dateday');
749 $url .=
'&search_date_startmonth='.GETPOSTINT(
'datemonth');
750 $url .=
'&search_date_startyear='.GETPOSTINT(
'dateyear');
752 if (count($search_fk_warehouse) > 1) {
755 foreach ($search_fk_warehouse as $val) {
756 $url .= ($val > 0 ?
'&search_warehouse='.((int) $val) :
'');
760 print
'<a href="'.$url.
'">';
762 print $langs->trans(
"Movements");
763 print
'<span class="tabs paddingleft"><span class="badge">'.$nbofmovement.
'</span></span>';
771 print
'<td class="right">'.($currentstock ?
price(
price2num($currentstock,
'MS')) :
'<span class="opacitymedium">0</span>').
'</td>';
773 $totalcurrentstock += $currentstock;
776 $parameters = array(
'objp'=>$objp);
777 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
778 print $hookmanager->resPrint;
782 print
'<td class="right"></td>';
791$parameters = array(
'sql'=>$sql);
792$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
794 print $hookmanager->resPrint;
798if ($mode ==
'future') {
804 ($mode ==
'future')?array(
805 '"'.$langs->trans(
"Totalforthispage").
'"',
807 $productid > 0 ?
price2num($totalcurrentstock,
'MS') :
'',
811 '"'.$langs->trans(
"Totalforthispage").
'"',
814 '"'.
price2num($totalbuyingprice,
'MT').
'"',
817 $productid > 0 ?
price2num($totalcurrentstock,
'MS') :
''));
819 if (empty($date) || !$dateIsValid) {
820 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"EnterADateCriteria").
'</span></td></tr>';
822 print
'<tr class="liste_total">';
823 print
'<td>'.$langs->trans(
"Totalforthispage").
'</td>';
825 if ($mode ==
'future') {
826 print
'<td class="right">'.price(
price2num($totalcurrentstock,
'MS')).
'</td>';
829 print
'<td class="right">'.price(
price2num($totalvirtualstock,
'MS')).
'</td>';
832 print
'<td class="right">'.price(
price2num($totalbuyingprice,
'MT')).
'</td>';
834 print
'<td class="right">'.price(
price2num($totalsellingprice,
'MT')).
'</td>';
839 print
'<td class="right">'.($productid > 0 ?
price(
price2num($totalcurrentstock,
'MS')) :
'').
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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)
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $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, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.
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.