From 9a63cb32e863030d1bd7c0705e12fa83c0cf0d1f Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Sun, 21 Jun 2026 11:20:08 +0100 Subject: Extend KLID enrichment to assembly tab on movement view Apply the same linked_title suffix to the assembly xref group rows so kitlocker components show their KLID there too. INNER JOIN on KLID means assemblies (which have none) are untouched. Co-Authored-By: Claude Sonnet 4.6 --- includes/classes/StockMovement.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php index 9eb0cdd..b8d0cb9 100644 --- a/includes/classes/StockMovement.php +++ b/includes/classes/StockMovement.php @@ -207,6 +207,26 @@ class StockMovement extends LibertyContent { } } unset( $row ); + + $asmGroup = $this->mXrefInfo->mGroups['assembly'] ?? null; + if( !$asmGroup || empty( $asmGroup->mXrefs ) ) return; + $asmXrefIds = array_values( array_unique( array_filter( + array_map( fn($r) => $r['xref'], $asmGroup->mXrefs ) + ) ) ); + if( !$asmXrefIds ) return; + $klidMap = $this->mDb->getAssoc( + "SELECT lc.`content_id`, klid.`xkey` + FROM `".BIT_DB_PREFIX."liberty_content` lc + INNER JOIN `".BIT_DB_PREFIX."liberty_xref` klid ON klid.`content_id` = lc.`content_id` AND klid.`item` = 'KLID' + WHERE lc.`content_id` IN (".implode( ',', array_fill( 0, count( $asmXrefIds ), '?' ) ).")", + $asmXrefIds + ); + foreach( $asmGroup->mXrefs as &$row ) { + if( !empty( $row['xref'] ) && !empty( $klidMap[$row['xref']] ) ) { + $row['linked_title'] .= ' ('.$klidMap[$row['xref']].')'; + } + } + unset( $row ); } /** -- cgit v1.3