diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-12 16:13:36 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-12 16:13:36 +0100 |
| commit | 77483b34115f0f6f71cfdea3069c4aca1bb30a7e (patch) | |
| tree | 3db4e34133c7a6888a03b373b326c3cd2d095ece | |
| parent | 76308cf0c9fcf20f12f14c0231601eb6fd6c120f (diff) | |
| download | stock-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>
| -rwxr-xr-x | includes/classes/StockAssembly.php | 10 | ||||
| -rw-r--r-- | templates/print_bom.tpl | 4 | ||||
| -rw-r--r-- | templates/stockassembly/view_xref_bom_item.tpl | 4 | ||||
| -rw-r--r-- | templates/stockassembly/view_xref_bomprt_item.tpl | 4 |
4 files changed, 12 insertions, 10 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']; } diff --git a/templates/print_bom.tpl b/templates/print_bom.tpl index ece3cac..a98f4c1 100644 --- a/templates/print_bom.tpl +++ b/templates/print_bom.tpl @@ -34,12 +34,12 @@ <td>{$posInGroup}</td> <td> {if $row.xref > 0} - <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$row.xref|escape}">{$row.xref_title|default:$row.xref|escape}</a> + <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$row.xref|escape}">{$row.linked_title|default:$row.xref|escape}</a> {else} {/if} </td> - <td>{$row.xref_data|escape}</td> + <td>{$row.linked_data|escape}</td> <td> {$row.xkey|escape} {if $row.item eq 'PRT' && $row.part_size} of {$row.part_size|escape}{if $row.part_size_ext} {$row.part_size_ext|escape}{/if}{/if} diff --git a/templates/stockassembly/view_xref_bom_item.tpl b/templates/stockassembly/view_xref_bom_item.tpl index 1ed0a95..6dfd627 100644 --- a/templates/stockassembly/view_xref_bom_item.tpl +++ b/templates/stockassembly/view_xref_bom_item.tpl @@ -2,12 +2,12 @@ <tr class="{cycle values="even,odd"}"> <td> {if $xrefInfo.xref > 0} - <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a> + <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.linked_title|default:$xrefInfo.xref|escape}</a> {else} {/if} </td> - <td>{$xrefInfo.xref_data|escape}</td> + <td>{$xrefInfo.linked_data|escape}</td> <td>{$xrefInfo.xkey|escape}</td> <td>{$xrefInfo.xkey_ext|escape}</td> {if $xrefAllowEdit} diff --git a/templates/stockassembly/view_xref_bomprt_item.tpl b/templates/stockassembly/view_xref_bomprt_item.tpl index 002ae89..c066678 100644 --- a/templates/stockassembly/view_xref_bomprt_item.tpl +++ b/templates/stockassembly/view_xref_bomprt_item.tpl @@ -2,12 +2,12 @@ <tr class="{cycle values="even,odd"}"> <td> {if $xrefInfo.xref > 0} - <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a> + <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.linked_title|default:$xrefInfo.xref|escape}</a> {else} {/if} </td> - <td>{$xrefInfo.xref_data|escape}</td> + <td>{$xrefInfo.linked_data|escape}</td> <td>{$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if}</td> <td>{$xrefInfo.xkey_ext|escape}</td> {if $xrefAllowEdit} |
