From 45d46f25ef3aebc1df2b30f9d46161171689f4e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Apr 2024 13:33:15 +0200 Subject: [PATCH] Merge index page of warehouse with product index page --- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/langs/en_US/stocks.lang | 1 + htdocs/product/index.php | 82 +++++++++++++++++++++++-- htdocs/product/stock/massstockmove.php | 2 +- htdocs/product/stock/movement_list.php | 8 +-- 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 09062838e0d..41f73e38718 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -137,7 +137,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("propal")', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?mainmenu=products&id=all&leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->hasRight("service","lire")', '', 2, 5, __ENTITY__); -- Product - Stocks -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/stock/index.php?mainmenu=products&leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3101__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/card.php?mainmenu=products&action=create', 'MenuNewWarehouse', 1, 'stocks', '$user->rights->stock->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3102__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/list.php?mainmenu=products', 'List', 1, 'stocks', '$user->rights->stock->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/movement_list.php?mainmenu=products', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f62b0ee28f7..8d108688cf5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2121,7 +2121,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme // Warehouse if (isModEnabled('stock')) { $langs->load("stocks"); - $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->hasRight('stock', 'lire'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'stock', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/product/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->hasRight('stock', 'lire'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'stock', 'class="paddingright pictofixedwidth"')); $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->hasRight('stock', 'creer')); $newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->hasRight('stock', 'lire')); $newmenu->add("/product/stock/movement_list.php", $langs->trans("Movements"), 1, $user->hasRight('stock', 'mouvement', 'lire')); diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 7740eb8d647..53dd40b82af 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -334,3 +334,4 @@ InternalWarehouse=Internal warehouse ExternalWarehouse=External warehouse QtyCurrentlyKnownInStock=The quantity the system think you have in stock. As long as the inventory is not closed, this is a realtime value and it may change if you continue to make stock movement during the inventory (not recommended). QtyInStockWhenInventoryWasValidated=The quantity the system think you had in stock when the inventory was validated (before the stock correction) +LatestModifiedWarehouses=Latest %s modified warehouses diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 4f77dc909ba..02ffb3632f2 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -85,6 +85,9 @@ $max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); * View */ +$producttmp = new Product($db); +$warehouse = new Entrepot($db); + $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl = ''; @@ -444,12 +447,75 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("pr } } +$latestwarehouse = ''; +if (isModEnabled('stock')) { + $sql = "SELECT e.rowid, e.ref as label, e.lieu, e.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; + $sql .= " WHERE e.statut in (".Entrepot::STATUS_CLOSED.",".Entrepot::STATUS_OPEN_ALL.")"; + $sql .= " AND e.entity IN (".getEntity('stock').")"; + $sql .= $db->order('e.tms', 'DESC'); + $sql .= $db->plimit($max + 1, 0); + + $result = $db->query($sql); + + if ($result) { + $num = $db->num_rows($result); + + $latestwarehouse .= '
'; + $latestwarehouse .= ''; + $latestwarehouse .= ''; + $latestwarehouse .= ''; + $latestwarehouse .= ''; + + $i = 0; + if ($num) { + while ($i < min($max, $num)) { + $objp = $db->fetch_object($result); + + $warehouse->id = $objp->rowid; + $warehouse->statut = $objp->status; + $warehouse->label = $objp->label; + $warehouse->lieu = $objp->lieu; + + $latestwarehouse .= ''; + $latestwarehouse .= ''."\n"; + $latestwarehouse .= ''; + $latestwarehouse .= "\n"; + $i++; + } + $db->free($result); + } else { + $latestwarehouse .= ''; + } + /*if ($num > $max) { + $latestwarehouse .= ''; + }*/ + + $latestwarehouse .= "
'; + $latestwarehouse .= $langs->trans("LatestModifiedWarehouses", $max); + //$latestwarehouse .= ''; + // TODO: "search_status" on "/product/stock/list.php" currently only accept a single integer value + //print ''; + //$latestwarehouse .= ''.$num.''; + $latestwarehouse .= ''; + $latestwarehouse .= ''; + $latestwarehouse .= img_picto($langs->trans("FullList"), 'stock'); + $latestwarehouse .= ''; + $latestwarehouse .= '
'; + $latestwarehouse .= $warehouse->getNomUrl(1); + $latestwarehouse .= ''; + $latestwarehouse .= $warehouse->getLibStatut(5); + $latestwarehouse .= '
'.$langs->trans("None").'
'.$langs->trans("More").'...
"; + $latestwarehouse .= '
'; + $latestwarehouse .= '
'; + } else { + dol_print_error($db); + } +} + $latestmovement = ''; if (isModEnabled('product')) { - $producttmp = new Product($db); - $warehouse = new Entrepot($db); - // Latest movements $sql = "SELECT p.rowid, p.label as produit, p.tobatch, p.tosell, p.tobuy,"; $sql .= " e.ref as warehouse_ref, e.rowid as warehouse_id, e.ref as warehouse_label, e.lieu, e.statut as warehouse_status,"; @@ -527,10 +593,16 @@ if (isModEnabled('product')) { $latestmovement .= $warehouse->getNomUrl(1); $latestmovement .= "\n"; $latestmovement .= ''; + if ($objp->qty < 0) { + $latestmovement .= ''; + } if ($objp->qty > 0) { + $latestmovement .= ''; $latestmovement .= '+'; } - $latestmovement .= $objp->qty.''; + $latestmovement .= $objp->qty; + $latestmovement .= ''; + $latestmovement .= ''; $latestmovement .= "\n"; $i++; } @@ -538,6 +610,7 @@ if (isModEnabled('product')) { $latestmovement .= ""; $latestmovement .= ''; + $latestmovement .= '
'; } else { dol_print_error($db); } @@ -575,6 +648,7 @@ $boxlist .= "\n"; $boxlist .= '
'; $boxlist .= $lastmodified; +$boxlist .= $latestwarehouse; $boxlist .= $latestmovement; $boxlist .= $resultboxes['boxlistb']; $boxlist .= '
'."\n"; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 8963040b36e..77c23f943c4 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -308,7 +308,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $db->commit(); setEventMessages($langs->trans("StockMovementRecorded"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/index.php'); // Redirect to avoid pb when using back + header("Location: ".DOL_URL_ROOT.'/product/stock/list.php'); // Redirect to avoid pb when using back exit; } else { $db->rollback(); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 34c08a3186f..99305884287 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -64,8 +64,8 @@ $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hier $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $msid = GETPOSTINT('msid'); -$idproduct = GETPOSTINT('idproduct'); -$product_id = GETPOSTINT("product_id"); +$idproduct = GETPOST('idproduct', 'intcomma'); +$product_id = GETPOST("product_id", 'intcomma'); $show_files = GETPOSTINT('show_files'); $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -86,8 +86,8 @@ $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); -$search_type_mouvement = GETPOSTINT('search_type_mouvement'); -$search_fk_project = GETPOSTINT("search_fk_project"); +$search_type_mouvement = GETPOST('search_type_mouvement'); +$search_fk_project = GETPOST("search_fk_project"); $type = GETPOSTINT("type");