diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 47797801705..c27af71c0bc 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -89,6 +89,21 @@ if (!empty($batchnumber)) { } $cost_price = GETPOST('cost_price', 'alpha'); + +// Load variable for pagination +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + + // Security check if ($user->socid) { $socid = $user->socid;