diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-12 10:41:59 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-12 10:41:59 +0100 |
| commit | 76308cf0c9fcf20f12f14c0231601eb6fd6c120f (patch) | |
| tree | b88107d6cd7035c715b22d688b5d6f27e4b227e8 | |
| parent | 00956ec62ba579685e35d515d469c9dd2c458c8a (diff) | |
| download | stock-76308cf0c9fcf20f12f14c0231601eb6fd6c120f.tar.gz stock-76308cf0c9fcf20f12f14c0231601eb6fd6c120f.tar.bz2 stock-76308cf0c9fcf20f12f14c0231601eb6fd6c120f.zip | |
stock: hide-kitlocker filter on list_components; fix supplier name in view_xref_sup_item
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 <noreply@anthropic.com>
| -rwxr-xr-x | includes/classes/StockComponent.php | 19 | ||||
| -rw-r--r-- | list_components.php | 6 | ||||
| -rw-r--r-- | templates/list_components.tpl | 8 | ||||
| -rw-r--r-- | 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')} <a href="{$smarty.const.STOCK_PKG_URL}edit_component.php">{biticon ipackage="icons" iname="kt-add-filters" iexplain="Create Component"}</a> {/if} - {minifind prompt="Components"} + {form class="minifind" method="get" action=$smarty.server.SCRIPT_NAME} + <div class="input-prepend form-inline"> + <input class="form-control input-sm search-query" type="text" name="find" placeholder="Components" value="{$smarty.request.find|escape}" /> + <label class="checkbox-inline"><input type="checkbox" name="hide_kitlocker" value="1"{if $hideKitlocker} checked="checked"{/if} /> {tr}Hide kitlocker{/tr}</label> + <button type="submit" class="btn btn-default btn-sm">{tr}Search{/tr}</button> + </div> + {/form} </div> <h1>{tr}Components{/tr}{if $gQueryUserId} {tr}by{/tr} {displayname user_id=$gQueryUserId}{/if}</h1> </header> 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 @@ <tr class="{cycle values="even,odd"}"> <td> {if $xrefInfo.xref > 0} - <a href="{$smarty.const.CONTACT_PKG_URL}display_contact.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a> + <a href="{$smarty.const.CONTACT_PKG_URL}display_contact.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.linked_title|default:$xrefInfo.xref|escape}</a> {else} {/if} |
