summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-21 11:20:08 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-21 11:20:08 +0100
commit9a63cb32e863030d1bd7c0705e12fa83c0cf0d1f (patch)
treec120ed68052195783661430506184931fb66c64e
parentaa7304a1f1f23199a8011c2385b638653e19a687 (diff)
downloadstock-master.tar.gz
stock-master.tar.bz2
stock-master.zip
Extend KLID enrichment to assembly tab on movement viewHEADmaster
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 <noreply@anthropic.com>
-rw-r--r--includes/classes/StockMovement.php20
1 files changed, 20 insertions, 0 deletions
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 );
}
/**