From 76308cf0c9fcf20f12f14c0231601eb6fd6c120f Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Fri, 12 Jun 2026 10:41:59 +0100 Subject: stock: hide-kitlocker filter on list_components; fix supplier name in view_xref_sup_item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit list_components defaults to hiding kitlocker components (KLID xref present) but keeps those where the kitlocker contact is also the supplier (#SUP → SCREF='kitlocker') — parts kitlocker supplies to elves. Filter checkbox in the search form, defaults on. view_xref_sup_item: switch from xref_title (cross_ref_title = "Supplier") to linked_title (liberty_content.title of the linked contact) so the contact name appears as the link text. Co-Authored-By: Claude Sonnet 4.6 --- includes/classes/StockComponent.php | 19 +++++++++++++++++++ list_components.php | 6 ++++++ templates/list_components.tpl | 8 +++++++- templates/stockcomponent/view_xref_sup_item.tpl | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/includes/classes/StockComponent.php b/includes/classes/StockComponent.php index 37d3659..01093c9 100755 --- a/includes/classes/StockComponent.php +++ b/includes/classes/StockComponent.php @@ -193,6 +193,25 @@ class StockComponent extends StockBase { $whereSql .= " AND EXISTS (SELECT 1 FROM `".BIT_DB_PREFIX."liberty_xref` kx WHERE kx.`content_id` = lc.`content_id` AND kx.`item` = 'KLID')"; } + if( !empty( $pListHash['hide_kitlocker'] ) ) { + // Exclude components that have KLID but no #SUP linking to the kitlocker contact (SCREF='kitlocker'). + // Components where kitlocker is the supplier are kept — those are parts kitlocker supplies to elves. + $whereSql .= " AND NOT ( + EXISTS ( + SELECT 1 FROM `".BIT_DB_PREFIX."liberty_xref` kx + WHERE kx.`content_id` = lc.`content_id` AND kx.`item` = 'KLID' + ) + AND NOT EXISTS ( + SELECT 1 FROM `".BIT_DB_PREFIX."liberty_xref` sx + INNER JOIN `".BIT_DB_PREFIX."liberty_xref` scref + ON scref.`content_id` = sx.`xref` + AND scref.`item` = 'SCREF' + AND UPPER(scref.`xkey`) = 'KITLOCKER' + WHERE sx.`content_id` = lc.`content_id` AND sx.`item` = '#SUP' + ) + )"; + } + $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); $orderby = !empty( $pListHash['sort_mode'] ) diff --git a/list_components.php b/list_components.php index 035da3d..751cdcf 100644 --- a/list_components.php +++ b/list_components.php @@ -22,10 +22,16 @@ if( !empty( $_REQUEST['find'] ) ) { $_REQUEST['search'] = $_REQUEST['find']; } +// Default on — hide pure kitlocker components; show those also supplied by kitlocker to elves +if( !isset( $_REQUEST['hide_kitlocker'] ) ) { + $_REQUEST['hide_kitlocker'] = 1; +} + $componentList = $component->getList( $_REQUEST ); $component->invokeServices( 'content_list_function', $_REQUEST ); $gBitSmarty->assign( 'listInfo', $_REQUEST['listInfo'] ); $gBitSmarty->assign( 'componentList', $componentList ); +$gBitSmarty->assign( 'hideKitlocker', (bool)$_REQUEST['hide_kitlocker'] ); $gBitSmarty->assign( 'gDefaultCenter', 'bitpackage:stock/list_components.tpl' ); $gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', 'List Components', [ 'display_mode' => 'list' ] ); diff --git a/templates/list_components.tpl b/templates/list_components.tpl index f2de519..cfe596e 100644 --- a/templates/list_components.tpl +++ b/templates/list_components.tpl @@ -5,7 +5,13 @@ {if $gBitUser->hasPermission('p_stock_create')} {biticon ipackage="icons" iname="kt-add-filters" iexplain="Create Component"} {/if} - {minifind prompt="Components"} + {form class="minifind" method="get" action=$smarty.server.SCRIPT_NAME} +
+ + + +
+ {/form}

{tr}Components{/tr}{if $gQueryUserId} {tr}by{/tr} {displayname user_id=$gQueryUserId}{/if}

diff --git a/templates/stockcomponent/view_xref_sup_item.tpl b/templates/stockcomponent/view_xref_sup_item.tpl index 811c077..44ed3ca 100644 --- a/templates/stockcomponent/view_xref_sup_item.tpl +++ b/templates/stockcomponent/view_xref_sup_item.tpl @@ -2,7 +2,7 @@ {if $xrefInfo.xref > 0} - {$xrefInfo.xref_title|default:$xrefInfo.xref|escape} + {$xrefInfo.linked_title|default:$xrefInfo.xref|escape} {else}   {/if} -- cgit v1.3