summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-12 16:13:36 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-12 16:13:36 +0100
commit77483b34115f0f6f71cfdea3069c4aca1bb30a7e (patch)
tree3db4e34133c7a6888a03b373b326c3cd2d095ece /includes
parent76308cf0c9fcf20f12f14c0231601eb6fd6c120f (diff)
downloadstock-77483b34115f0f6f71cfdea3069c4aca1bb30a7e.tar.gz
stock-77483b34115f0f6f71cfdea3069c4aca1bb30a7e.tar.bz2
stock-77483b34115f0f6f71cfdea3069c4aca1bb30a7e.zip
stock: BOM view uses linked_title/linked_data; loadXrefInfo only enriches part_size
Component title and description in BOM view templates (view_xref_bom_item, view_xref_bomprt_item, print_bom) now use linked_title/linked_data from the lc_linked JOIN in loadContent() — same pattern as the supplier name fix. StockAssembly::loadXrefInfo() drops the title/data enrichment loop (now redundant) and only queries for part_size/part_size_ext from the PRT xref. array_column replaced with array_map to reliably call ArrayAccess offsetGet on LibertyXref objects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/classes/StockAssembly.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/includes/classes/StockAssembly.php b/includes/classes/StockAssembly.php
index 4fe4bdc..c072c41 100755
--- a/includes/classes/StockAssembly.php
+++ b/includes/classes/StockAssembly.php
@@ -107,10 +107,14 @@ class StockAssembly extends StockBase {
$bomGroup = $this->mXrefInfo->mGroups['quantity'] ?? null;
if( !$bomGroup || empty( $bomGroup->mXrefs ) ) return;
usort( $bomGroup->mXrefs, fn($a,$b) => ( $a['xorder'] <=> $b['xorder'] ) ?: strcmp( $a['item'], $b['item'] ) );
- $componentIds = array_values( array_unique( array_filter( array_column( $bomGroup->mXrefs, 'xref' ) ) ) );
+ // title and data come from linked_title/linked_data (lc_linked JOIN in loadContent)
+ // only need a separate query for part_size/part_size_ext from the PRT xref
+ $componentIds = array_values( array_unique( array_filter(
+ array_map( fn($r) => $r['xref'], $bomGroup->mXrefs )
+ ) ) );
if( !$componentIds ) return;
$components = $this->mDb->getAssoc(
- "SELECT lc.`content_id`, lc.`title`, lc.`data`, pck.`xkey` AS `part_size`, pck.`xkey_ext` AS `part_size_ext`
+ "SELECT lc.`content_id`, pck.`xkey` AS `part_size`, pck.`xkey_ext` AS `part_size_ext`
FROM `".BIT_DB_PREFIX."liberty_content` lc
LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` pck ON pck.`content_id` = lc.`content_id` AND pck.`item` = 'PRT'
WHERE lc.`content_id` IN (".implode( ',', array_fill( 0, count( $componentIds ), '?' ) ).")",
@@ -118,8 +122,6 @@ class StockAssembly extends StockBase {
);
foreach( $bomGroup->mXrefs as &$row ) {
if( !empty( $row['xref'] ) && isset( $components[$row['xref']] ) ) {
- $row['xref_title'] = $components[$row['xref']]['title'];
- $row['xref_data'] = $components[$row['xref']]['data'];
$row['part_size'] = $components[$row['xref']]['part_size'];
$row['part_size_ext'] = $components[$row['xref']]['part_size_ext'];
}