summaryrefslogtreecommitdiff
path: root/list_stock.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-14 10:49:24 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-14 10:49:24 +0100
commite8aa652c4f0d2f780171d7bbd2c351c05a1025e9 (patch)
tree2ee249d771ee88e7d3d1cc209a3048fd37161b56 /list_stock.php
parent3866f6c02cfae647d04e9123392b608e0d0aa3a6 (diff)
downloadstock-e8aa652c4f0d2f780171d7bbd2c351c05a1025e9.tar.gz
stock-e8aa652c4f0d2f780171d7bbd2c351c05a1025e9.tar.bz2
stock-e8aa652c4f0d2f780171d7bbd2c351c05a1025e9.zip
Add multi-user (kitelf) stock filtering and PBLD prebuild movement type
- list_movements/list_stock: filter by user_id (kitelf) with breadcrumb navigation; creator names in list_movements are clickable filter links - list_movements: unified part_content_id replaces separate assembly_content_id/component_content_id URL params; type-aware breadcrumb and qty column (assembly kit count vs component qty) - StockMovement::getList(): $partId/$partIsAsm collapse cmp/asm into one variable; unified part_qty/part_qty_type SELECT; PBLD added to all ref_type IN() lists and sort subqueries; lc.user_id added to SELECT - New PBLD (Prebuild) movement type: add_prebuild.php/tpl creates PBLD movements (assemblies only, BOM exploded, optional note); add_requisition retired from UI; PBLD handled in edit/view with isBuild/isPbld flags; view/edit show Build Date/Completed labels for PBLD - schema_inc.php: PBLD registered in stockmovement reference xref items - view_movement.tpl: updated to <header>/<section> pattern with kitelf breadcrumb; getDirection() explicit for PBLD Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'list_stock.php')
-rw-r--r--list_stock.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/list_stock.php b/list_stock.php
index 796161d..6ad176e 100644
--- a/list_stock.php
+++ b/list_stock.php
@@ -18,15 +18,31 @@ $assemblyContentId = isset( $_REQUEST['assembly_content_id'] ) && is_numeric( $_
? (int)$_REQUEST['assembly_content_id'] : null;
$kitCount = isset( $_REQUEST['kit_count'] ) && is_numeric( $_REQUEST['kit_count'] ) && (float)$_REQUEST['kit_count'] > 0
? (float)$_REQUEST['kit_count'] : 1;
+$filterUserId = isset( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] )
+ ? (int)$_REQUEST['user_id'] : null;
+$filterUserName = '';
+if( $filterUserId ) {
+ $uRow = $gBitDb->getRow(
+ "SELECT `login`, `real_name` FROM `".BIT_DB_PREFIX."users_users` WHERE `user_id` = ?",
+ [ $filterUserId ]
+ );
+ $filterUserName = $uRow['real_name'] ?: $uRow['login'] ?: '';
+}
$X = BIT_DB_PREFIX;
$bindVars = [];
if( $assemblyContentId ) {
- // BOM view: start from BOM items so components with no movements still appear
+ // BOM view: start from BOM items so components with no movements still appear.
+ // Bind var order must match ? positions in the SQL: user_id (in subquery SELECT) first,
+ // then assemblyContentId (in FROM JOIN), then find (in WHERE).
+ $userSubSql = '';
+ if( $filterUserId ) {
+ $userSubSql = " AND mc.`user_id` = ?";
+ $bindVars[] = $filterUserId;
+ }
$findSql = $find !== '' ? " AND UPPER(lc.`title`) LIKE ?" : '';
- if( $find !== '' ) $bindVars[] = '%'.strtoupper( $find ).'%';
$query = "SELECT lc.`content_id`, lc.`title`, lc.`data`,
bom.`item` AS qty_type,
@@ -49,7 +65,8 @@ if( $assemblyContentId ) {
AND mc.`content_type_guid` = 'stockmovement'
WHERE mx.`xref` = lc.`content_id`
AND mx.`item` = bom.`item`
- AND mx.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?') AS stock_level
+ AND mx.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?'
+ $userSubSql) AS stock_level
FROM `{$X}liberty_content` lc
INNER JOIN `{$X}liberty_xref` bom ON bom.`content_id` = ?
AND bom.`item` IN ('SGL','PRT','SHT','VOL')
@@ -58,11 +75,16 @@ if( $assemblyContentId ) {
$findSql
ORDER BY bom.`xorder`";
$bindVars[] = $assemblyContentId;
+ if( $find !== '' ) $bindVars[] = '%'.strtoupper( $find ).'%';
} else {
// General list: only components with movement history
$whereSql = '';
+ if( $filterUserId ) {
+ $whereSql .= " AND mc.`user_id` = ?";
+ $bindVars[] = $filterUserId;
+ }
if( $find !== '' ) {
- $whereSql = " AND UPPER(lc.`title`) LIKE ?";
+ $whereSql .= " AND UPPER(lc.`title`) LIKE ?";
$bindVars[] = '%'.strtoupper( $find ).'%';
}
@@ -187,5 +209,7 @@ $gBitSmarty->assign( 'find', $find );
$gBitSmarty->assign( 'showBom', (bool)$assemblyContentId );
$gBitSmarty->assign( 'showShortages', $showShortages );
$gBitSmarty->assign( 'kitCount', $kitCount );
+$gBitSmarty->assign( 'filterUserId', $filterUserId );
+$gBitSmarty->assign( 'filterUserName', $filterUserName );
$gBitSystem->display( 'bitpackage:stock/list_stock.tpl', 'Stock Levels', [ 'display_mode' => 'list' ] );