diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index c84c6ed12d2..0e570d8f5e9 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5349,7 +5349,7 @@ class Form
if ($usecalendar == "eldy")
{
// Zone de saisie manuelle de la date
- $retstring .= 'trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= '>';
@@ -5402,7 +5402,7 @@ class Form
// Zone de saisie manuelle de la date
$retstring .= '
';
- $retstring .= 'trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= '>';
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index 08846d35907..49362619f0d 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -231,4 +231,5 @@ StockIsRequiredToChooseWhichLotToUse=Stock is required to choose which lot to us
ForceTo=Force to
AlwaysShowFullArbo=Display full tree of warehouse on popup of warehouse links (Warning: This may decrease dramatically performances)
StockAtDatePastDesc=You can view here the stock (real stock) at a given date in the past
-StockAtDateFutureDesc=You can view here the stock (virtual stock) at a given date in future
\ No newline at end of file
+StockAtDateFutureDesc=You can view here the stock (virtual stock) at a given date in future
+CurrentStock=Current stock
\ No newline at end of file
diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php
index cef50715598..f3482e22098 100644
--- a/htdocs/product/stock/stockatdate.php
+++ b/htdocs/product/stock/stockatdate.php
@@ -102,19 +102,23 @@ if ($conf->global->ENTREPOT_EXTRA_STATUS) {
$stock_prod_warehouse = array();
$stock_prod = array();
if ($date) { // Avoid heavy sql if mandatory date is not defined
- $sql = "SELECT sm.fk_product, sm.fk_entrepot as fk_warehouse,";
- $sql .= " SUM(sm.value) AS stock";
- $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as sm";
+ $sql = "SELECT ps.fk_product, ps.fk_entrepot as fk_warehouse,";
+ $sql .= " SUM(ps.reel) AS stock";
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql .= ", ".MAIN_DB_PREFIX."entrepot as w";
$sql .= " WHERE w.entity IN (".getEntity('stock').")";
//$sql .= " AND p.entity IN (".getEntity('product').")";
- $sql .= " AND w.rowid = sm.fk_entrepot";
- if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) {
+ $sql .= " AND w.rowid = ps.fk_entrepot";
+ if (! empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) {
$sql .= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")";
}
+ if ($productid > 0) {
+ $sql .= " AND ps.fk_product = ".$productid;
+ }
$sql .= " GROUP BY fk_product, fk_entrepot";
- $resql = $db->query($sql);
+ //print $sql;
+ $resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@@ -155,28 +159,36 @@ $num = 0;
$title = $langs->trans('StockAtDate');
$sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,';
-$sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type,';
-$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock,';
-$sql .= ' p.desiredstock, p.seuil_stock_alerte';
+$sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
+$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock';
+if ($fk_warehouse > 0) {
+ $sql .= ', SUM(ps.reel) as stock_reel';
+}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
+if ($fk_warehouse > 0) {
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '.$fk_warehouse;
+}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
-if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
- $sql .= " AND p.fk_product_type = 0";
-}
if ($productid > 0) {
$sql .= " AND p.rowid = ".$productid;
}
+if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $sql .= " AND p.fk_product_type = 0";
+}
if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"';
-
+if ($fk_warehouse > 0) {
+ $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
+ $sql .= ' p.tms, p.duration, p.tobuy, p.stock';
+}
/*
if ($usevirtualstock)
{
@@ -289,8 +301,7 @@ if ($date) { // We avoid a heavy sql if mandatory parameter date not yet defined
}
$i = 0;
-
-
+//print $sql;
$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|';
$helpurl .= 'ES:Módulo_Stocks';
@@ -317,7 +328,7 @@ if ($mode == 'future') $desc = $langs->trans("StockAtDateFutureDesc");
print ''.$desc.' '."\n";
print ' '."\n";
-print '