diff --git a/htdocs/install/mysql/tables/llx_inventorydet.sql b/htdocs/install/mysql/tables/llx_inventorydet.sql
index 1a2b63a9252..c70a2909882 100644
--- a/htdocs/install/mysql/tables/llx_inventorydet.sql
+++ b/htdocs/install/mysql/tables/llx_inventorydet.sql
@@ -26,8 +26,8 @@ fk_inventory integer DEFAULT 0,
fk_warehouse integer DEFAULT 0,
fk_product integer DEFAULT 0,
batch varchar(30) DEFAULT NULL, -- Lot or serial number
-qty_view double DEFAULT NULL, -- must be filled once regulation is done
-qty_stock double DEFAULT NULL, -- can be filled during draft edition
+qty_stock double DEFAULT NULL, -- The targeted value. can be filled during draft edition
+qty_view double DEFAULT NULL, -- must be filled once regulation is done
qty_regulated double DEFAULT NULL -- must be filled once regulation is done
)
ENGINE=InnoDB;
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index fb3806cc0ef..9856649b834 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -193,6 +193,7 @@ TheoricalQty=Theorique qty
TheoricalValue=Theorique qty
LastPA=Last BP
CurrentPA=Curent BP
+RecordedQty=Recorded Qty
RealQty=Real Qty
RealValue=Real Value
RegulatedQty=Regulated Qty
diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php
index 305c586d82c..0c913834738 100644
--- a/htdocs/product/inventory/card.php
+++ b/htdocs/product/inventory/card.php
@@ -302,7 +302,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '
';
print '
';
print '
';
- print '
'."\n";
+ print ''."\n";
// Common attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php
index 6ba88667e12..f1a2db542c1 100644
--- a/htdocs/product/inventory/class/inventory.class.php
+++ b/htdocs/product/inventory/class/inventory.class.php
@@ -124,6 +124,11 @@ class Inventory extends CommonObject
*/
public $fk_warehouse;
+ /**
+ * @var int ID
+ */
+ public $fk_product;
+
public $date_inventory;
public $title;
diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php
index daf35ad7f95..646b5d0bc6e 100644
--- a/htdocs/product/inventory/inventory.php
+++ b/htdocs/product/inventory/inventory.php
@@ -242,7 +242,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
print '
';
print '
';
- print '
'."\n";
+ print ''."\n";
// Common attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
@@ -295,7 +295,112 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print ''."\n";
}
- include DOL_DOCUMENT_ROOT.'/product/inventory/tpl/inventory.tpl.php';
+
+ print '';
+ print '
';
+ print '
';
+
+ //print load_fiche_titre($langs->trans('Consumption'), '', '');
+
+ print '
';
+ print '
';
+
+ print '';
+ print '| '.$langs->trans("Warehouse").' | ';
+ print ''.$langs->trans("Product").' | ';
+ if ($conf->productbatch->enabled) {
+ print '';
+ print $langs->trans("Batch");
+ print ' | ';
+ }
+ print ''.$langs->trans("RecordedQty").' | ';
+ print ''.$langs->trans("RealQty").' | ';
+ print '';
+ print ' | ';
+ print '
';
+
+
+ $sql = 'SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'entrepot as e';
+ $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
+ $sql .= ' AND ps.fk_product = p.rowid AND ps.fk_entrepot = e.rowid';
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
+ if ($object->fk_product > 0) $sql .= ' AND ps.fk_product = '.$object->fk_product;
+ if ($object->fk_warehouse > 0) $sql .= ' AND ps.fk_entrepot = '.$object->fk_warehouse;
+
+ $cacheOfProducts = array();
+ $cacheOfWarehouses = array();
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+
+ $i = 0;
+ $totalarray = array();
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ if (is_object($cacheOfWarehouses[$obj->fk_warehouse])) {
+ $warehouse_static = $cacheOfWarehouses[$obj->fk_warehouse];
+ } else {
+ $warehouse_static = new Entrepot($db);
+ $warehouse_static->fetch($obj->fk_warehouse);
+
+ $cacheOfWarehouses[$warehouse_static->id] = $warehouse_static;
+ }
+
+ if (is_object($cacheOfProducts[$obj->fk_product])) {
+ $product_static = $cacheOfProducts[$obj->fk_product];
+ } else {
+ $product_static = new Product($db);
+ $product_static->fetch($obj->fk_product);
+
+ $option = 'nobatch';
+ $option .= ',novirtual';
+ $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock()
+
+ $cacheOfProducts[$product_static->id] = $product_static;
+ }
+
+ print '';
+ print '| ';
+ print $warehouse_static->getNomUrl(1);
+ print ' | ';
+ print '';
+ print $product_static->getNomUrl(1);
+ print ' | ';
+
+ if ($conf->productbatch->enabled) {
+ print '';
+ print '';
+ print ' | ';
+ }
+
+ print '';
+ print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
+
+ print '
';
+
+ $i++;
+ }
+ } else {
+ dol_print_error($db);
+ }
+
+ print '
';
+ print '
';
+
+ print '
';
+ print '
';
}
// End of page
diff --git a/htdocs/product/inventory/tpl/inventory.tpl.php b/htdocs/product/inventory/tpl/inventory.tpl.php
deleted file mode 100644
index 992557505db..00000000000
--- a/htdocs/product/inventory/tpl/inventory.tpl.php
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-TODO...
-