';
- print '';
- print ''.$langs->trans("Warehouse").' ';
- print ''.$langs->trans("Product").' ';
+print ' ';
+print ''.$langs->trans("Warehouse").' ';
+print ''.$langs->trans("Product").' ';
+if (isModEnabled('productbatch')) {
+ print '';
+ print $langs->trans("Batch");
+ print ' ';
+}
+print ''.$langs->trans("ExpectedQty").' ';
+if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
+ print ''.$langs->trans('PMPExpected').' ';
+ print ''.$langs->trans('ExpectedValuation').' ';
+ print ''.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).' ';
+ print ''.$langs->trans('PMPReal').' ';
+ print ''.$langs->trans('RealValuation').' ';
+} else {
+ print '';
+ print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp"));
+ print ' ';
+}
+if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
+ // Actions or link to stock movement
+ print '';
+ print ' ';
+} else {
+ // Actions or link to stock movement
+ print '';
+ //print $langs->trans("StockMovement");
+ print ' ';
+}
+print ' ';
+
+// Line to add a new line in inventory
+if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
+ print '';
+ print '';
+ print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? GETPOST('fk_warehouse', 'int') : $object->fk_warehouse), 'fk_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth300');
+ print ' ';
+ print '';
+ print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300');
+ print ' ';
if (isModEnabled('productbatch')) {
print '';
- print $langs->trans("Batch");
+ print ' ';
print ' ';
}
- print ''.$langs->trans("ExpectedQty").' ';
+ print ' ';
if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
- print ''.$langs->trans('PMPExpected').' ';
- print ''.$langs->trans('ExpectedValuation').' ';
- print ''.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).' ';
- print ''.$langs->trans('PMPReal').' ';
- print ''.$langs->trans('RealValuation').' ';
+ print '';
+ print ' ';
+ print '';
+ print ' ';
+ print '';
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print '';
+ print ' ';
} else {
print '';
- print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp"));
- print ' ';
- }
- if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
- // Actions or link to stock movement
- print '';
- print ' ';
- } else {
- // Actions or link to stock movement
- print '';
- //print $langs->trans("StockMovement");
+ print ' ';
print ' ';
}
+ // Actions
+ print '';
+ print ' ';
+ print ' ';
print ' ';
+}
- // Line to add a new line in inventory
- if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
- print '';
- print '';
- print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? GETPOST('fk_warehouse', 'int') : $object->fk_warehouse), 'fk_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth300');
+// Request to show lines of inventory (prefilled after start/validate step)
+$sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,';
+$sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected';
+$sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id';
+$sql .= ' WHERE id.fk_inventory = '.((int) $object->id);
+$sql .= $db->order('id.rowid', 'ASC');
+$sql .= $db->plimit($limit, $offset);
+
+$cacheOfProducts = array();
+$cacheOfWarehouses = array();
+
+//$sql = '';
+$resql = $db->query($sql);
+if ($resql) {
+ $num = $db->num_rows($resql);
+
+ if (!empty($limit != 0) || $num > $limit || $page) {
+ print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '', $limit);
+ }
+
+ $i = 0;
+ $hasinput = false;
+ $totalarray = array();
+ while ($i < $num) {
+ $obj = $db->fetch_object($resql);
+
+ if (isset($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;
+ }
+
+ // Load real stock we have now
+ $option = '';
+ if (isset($cacheOfProducts[$obj->fk_product])) {
+ $product_static = $cacheOfProducts[$obj->fk_product];
+ } else {
+ $product_static = new Product($db);
+ $result = $product_static->fetch($obj->fk_product, '', '', '', 1, 1, 1);
+
+ //$option = 'nobatch';
+ $option .= ',novirtual';
+ $product_static->load_stock($option); // Load stock_reel + stock_warehouse.
+
+ $cacheOfProducts[$product_static->id] = $product_static;
+ }
+
+ print ' ';
+ print '';
+ print $warehouse_static->getNomUrl(1);
print ' ';
- print '';
- print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300');
+ print ' ';
+ print $product_static->getNomUrl(1).' - '.$product_static->label;
print ' ';
+
if (isModEnabled('productbatch')) {
- print '';
- print ' ';
+ print ' ';
+ $batch_static = new Productlot($db);
+ $res = $batch_static->fetch(0, $product_static->id, $obj->batch);
+ if ($res) {
+ print $batch_static->getNomUrl(1);
+ } else {
+ print dol_escape_htmltag($obj->batch);
+ }
print ' ';
}
- print ' ';
- if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
- print '';
- print ' ';
- print '';
- print ' ';
- print '';
- print ' ';
- print ' ';
- print '';
- print ' ';
+
+ // Expected quantity = Quantity in stock when we start inventory
+ print '';
+ $valuetoshow = $obj->qty_stock;
+ // For inventory not yet close, we overwrite with the real value in stock now
+ if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
+ if (isModEnabled('productbatch') && $product_static->hasbatch()) {
+ $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty;
+ } else {
+ $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real;
+ }
+ }
+ print price2num($valuetoshow, 'MS');
+ print ' ';
+ print ' ';
+
+ // Real quantity
+ if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
+ $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view;
+
+ //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) {
+ if ($qty_view != '') {
+ $hasinput = true;
+ }
+
+ if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
+ //PMP Expected
+ if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
+ else $pmp_expected = $product_static->pmp;
+ $pmp_valuation = $pmp_expected * $valuetoshow;
+ print '';
+ print price($pmp_expected);
+ print ' ';
+ print ' ';
+ print '';
+ print price($pmp_valuation);
+ print ' ';
+
+ print '';
+ print '';
+ print img_picto('', 'eraser', 'class="opacitymedium"');
+ print ' ';
+ print ' ';
+ print ' ';
+
+ //PMP Real
+ print '';
+
+
+ if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
+ else $pmp_real = $product_static->pmp;
+ $pmp_valuation_real = $pmp_real * $qty_view;
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print ' ';
+
+ $totalExpectedValuation += $pmp_valuation;
+ $totalRealValuation += $pmp_valuation_real;
+ } else {
+ print '';
+ print '';
+ print img_picto('', 'eraser', 'class="opacitymedium"');
+ print ' ';
+ print ' ';
+ print ' ';
+ }
+
+ // Picto delete line
print '';
+ print ''.img_delete().' ';
+ $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view;
+ print ' ';
print ' ';
} else {
- print '';
- print ' ';
- print ' ';
- }
- // Actions
- print '';
- print ' ';
- print ' ';
- print ' ';
- }
-
- // Request to show lines of inventory (prefilled after start/validate step)
- $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,';
- $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id';
- $sql .= ' WHERE id.fk_inventory = '.((int) $object->id);
- $sql .= $db->order('id.rowid', 'ASC');
- $sql .= $db->plimit($limit, $offset);
-
- $cacheOfProducts = array();
- $cacheOfWarehouses = array();
-
- //$sql = '';
- $resql = $db->query($sql);
- if ($resql) {
- $num = $db->num_rows($resql);
-
- if (!empty($limit != 0) || $num > $limit || $page) {
- print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '', $limit);
- }
-
- $i = 0;
- $hasinput = false;
- $totalarray = array();
- while ($i < $num) {
- $obj = $db->fetch_object($resql);
-
- if (isset($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;
- }
-
- // Load real stock we have now
- $option = '';
- if (isset($cacheOfProducts[$obj->fk_product])) {
- $product_static = $cacheOfProducts[$obj->fk_product];
- } else {
- $product_static = new Product($db);
- $result = $product_static->fetch($obj->fk_product, '', '', '', 1, 1, 1);
-
- //$option = 'nobatch';
- $option .= ',novirtual';
- $product_static->load_stock($option); // Load stock_reel + stock_warehouse.
-
- $cacheOfProducts[$product_static->id] = $product_static;
- }
-
- print '';
- print '';
- print $warehouse_static->getNomUrl(1);
- print ' ';
- print '';
- print $product_static->getNomUrl(1).' - '.$product_static->label;
- print ' ';
-
- if (isModEnabled('productbatch')) {
- print '';
- $batch_static = new Productlot($db);
- $res = $batch_static->fetch(0, $product_static->id, $obj->batch);
- if ($res) {
- print $batch_static->getNomUrl(1);
- } else {
- print dol_escape_htmltag($obj->batch);
- }
- print ' ';
- }
-
- // Expected quantity = Quantity in stock when we start inventory
- print '';
- $valuetoshow = $obj->qty_stock;
- // For inventory not yet close, we overwrite with the real value in stock now
- if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
- if (isModEnabled('productbatch') && $product_static->hasbatch()) {
- $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty;
- } else {
- $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real;
- }
- }
- print price2num($valuetoshow, 'MS');
- print ' ';
- print ' ';
-
- // Real quantity
- if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
- $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view;
-
- //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) {
- if ($qty_view != '') {
- $hasinput = true;
- }
-
- if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
- //PMP Expected
- if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
- else $pmp_expected = $product_static->pmp;
- $pmp_valuation = $pmp_expected * $valuetoshow;
- print '';
- print price($pmp_expected);
- print ' ';
- print ' ';
- print '';
- print price($pmp_valuation);
- print ' ';
-
- print '';
- print '';
- print img_picto('', 'eraser', 'class="opacitymedium"');
- print ' ';
- print ' ';
- print ' ';
-
- //PMP Real
- print '';
-
-
- if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
- else $pmp_real = $product_static->pmp;
- $pmp_valuation_real = $pmp_real * $qty_view;
- print ' ';
- print ' ';
- print '';
- print ' ';
- print ' ';
-
- $totalExpectedValuation += $pmp_valuation;
- $totalRealValuation += $pmp_valuation_real;
- } else {
- print '';
- print '';
- print img_picto('', 'eraser', 'class="opacitymedium"');
- print ' ';
- print ' ';
- print ' ';
- }
-
- // Picto delete line
+ if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
+ //PMP Expected
+ if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
+ else $pmp_expected = $product_static->pmp;
+ $pmp_valuation = $pmp_expected * $valuetoshow;
print '';
- print ''.img_delete().' ';
- $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view;
- print ' ';
+ print price($pmp_expected);
print ' ';
+ print '';
+ print price($pmp_valuation);
+ print ' ';
+
+ print '';
+ print $obj->qty_view; // qty found
+ print ' ';
+
+ //PMP Real
+ print '';
+ if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
+ else $pmp_real = $product_static->pmp;
+ $pmp_valuation_real = $pmp_real * $obj->qty_view;
+ print price($pmp_real);
+ print ' ';
+ print '';
+ print price($pmp_valuation_real);
+ print ' ';
+ print '';
+
+ $totalExpectedValuation += $pmp_valuation;
+ $totalRealValuation += $pmp_valuation_real;
} else {
- if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
- //PMP Expected
- if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
- else $pmp_expected = $product_static->pmp;
- $pmp_valuation = $pmp_expected * $valuetoshow;
- print ' ';
- print price($pmp_expected);
- print ' ';
- print '';
- print price($pmp_valuation);
- print ' ';
-
- print '';
- print $obj->qty_view; // qty found
- print ' ';
-
- //PMP Real
- print '';
- if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
- else $pmp_real = $product_static->pmp;
- $pmp_valuation_real = $pmp_real * $obj->qty_view;
- print price($pmp_real);
- print ' ';
- print '';
- print price($pmp_valuation_real);
- print ' ';
- print '';
-
- $totalExpectedValuation += $pmp_valuation;
- $totalRealValuation += $pmp_valuation_real;
- } else {
- print ' ';
- print $obj->qty_view; // qty found
- print ' ';
- }
- if ($obj->fk_movement > 0) {
- $stockmovment = new MouvementStock($db);
- $stockmovment->fetch($obj->fk_movement);
- print $stockmovment->getNomUrl(1, 'movements');
- }
+ print '';
+ print $obj->qty_view; // qty found
print ' ';
}
- print ' ';
-
- $i++;
+ if ($obj->fk_movement > 0) {
+ $stockmovment = new MouvementStock($db);
+ $stockmovment->fetch($obj->fk_movement);
+ print $stockmovment->getNomUrl(1, 'movements');
+ }
+ print '';
}
- } else {
- dol_print_error($db);
- }
- if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
- print '';
- print ''.$langs->trans("Total").' ';
- print ''.price($totalExpectedValuation).' ';
- print ''.price($totalRealValuation).' ';
- print ' ';
print ' ';
+
+ $i++;
}
- print '
';
+} else {
+ dol_print_error($db);
+}
+if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
+ print '