diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f90832b61b4..789c8fa88a0 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -44,6 +44,8 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'inventorycard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $listoffset = GETPOST('listoffset', 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $limit = GETPOSTINT('limit') > 0 ? GETPOSTINT('limit') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page == -1) { @@ -71,6 +73,13 @@ $object = new Inventory($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortfield) { + $sortfield = "e.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -99,7 +108,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'inclu //$result = restrictedArea($user, 'mymodule', $id); //Parameters Page -$paramwithsearch = ''; +$paramwithsearch = '&sortfield=' . urlencode($sortfield); +$paramwithsearch .= '&sortorder=' . urlencode($sortorder); if ($limit > 0 && $limit != $conf->liste_limit) { $paramwithsearch .= '&limit='.((int) $limit); } @@ -442,6 +452,11 @@ if ($object->id <= 0) { exit; } +$param = ''; +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit=' . ((int) $limit); +} + $res = $object->fetch_optionals(); @@ -577,6 +592,8 @@ print '