summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-12 10:41:59 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-12 10:41:59 +0100
commit76308cf0c9fcf20f12f14c0231601eb6fd6c120f (patch)
treeb88107d6cd7035c715b22d688b5d6f27e4b227e8 /includes
parent00956ec62ba579685e35d515d469c9dd2c458c8a (diff)
downloadstock-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>
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/classes/StockComponent.php19
1 files changed, 19 insertions, 0 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'] )