summaryrefslogtreecommitdiff
path: root/list_stock.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-19 14:36:40 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-19 14:36:40 +0100
commit8faef82f3ad9eafa081e74a84cb68d80d4a44c2c (patch)
treeb8fd2230827677752d4e2eecdfa1b7bc7b6325ff /list_stock.php
parent4bec6ebb34f8a811483f732fba93aa66839495b3 (diff)
downloadstock-8faef82f3ad9eafa081e74a84cb68d80d4a44c2c.tar.gz
stock-8faef82f3ad9eafa081e74a84cb68d80d4a44c2c.tar.bz2
stock-8faef82f3ad9eafa081e74a84cb68d80d4a44c2c.zip
Add pagination to list_stock.php, default 20 records per page
General list only (BOM view is assembly-bounded). Full result set is fetched and grouped in PHP first so shortages filter and CSV export see all rows; array_slice applies the page window after CSV exits. Extra URL params (user_id, find, shortages) are threaded into listInfo for the pagination links. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'list_stock.php')
-rw-r--r--list_stock.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/list_stock.php b/list_stock.php
index 3de65e4..850b024 100644
--- a/list_stock.php
+++ b/list_stock.php
@@ -6,6 +6,8 @@
namespace Bitweaver\Stock;
+use Bitweaver\BitBase;
+
require_once '../kernel/includes/setup_inc.php';
global $gBitSystem, $gBitSmarty, $gBitDb;
@@ -31,6 +33,16 @@ if( $filterUserId ) {
$X = BIT_DB_PREFIX;
+$listHash = $_REQUEST;
+if( !$assemblyContentId ) {
+ if( empty( $listHash['max_records'] ) ) {
+ $listHash['max_records'] = 20;
+ }
+ BitBase::prepGetList( $listHash );
+}
+$maxRecords = $listHash['max_records'] ?? 20;
+$offset = $listHash['offset'] ?? 0;
+
$bindVars = [];
if( $assemblyContentId ) {
@@ -203,6 +215,17 @@ if( $showShortages && isset( $_REQUEST['format'] ) && $_REQUEST['format'] === 'c
exit;
}
+if( !$assemblyContentId ) {
+ $listHash['cant'] = count( $stockList );
+ $stockList = array_slice( $stockList, $offset, $maxRecords, true );
+ $listHash['page_records'] = count( $stockList );
+ if( $filterUserId ) $listHash['listInfo']['parameters']['user_id'] = $filterUserId;
+ if( $find !== '' ) $listHash['listInfo']['parameters']['find'] = $find;
+ if( $showShortages ) $listHash['listInfo']['parameters']['shortages'] = 1;
+ BitBase::postGetList( $listHash );
+ $gBitSmarty->assign( 'listInfo', $listHash['listInfo'] );
+}
+
$gBitSmarty->assign( 'stockList', $stockList );
$gBitSmarty->assign( 'assemblyListJson', $assemblyListJson );
$gBitSmarty->assign( 'assemblyContentId', $assemblyContentId );