From 8566070da24cd53845c64cdf2cd2104c847e450c Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Wed, 10 Jun 2026 09:16:33 +0100 Subject: stock: add kitlocker gallery — view_kitlocker.php, stock_fixed_grid_inc.tpl, view_xref_kitlocker_group.tpl; stgrp getList filter; stgrp template field set to kitlocker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- admin/schema_inc.php | 2 +- includes/classes/StockAssembly.php | 5 +++ templates/stock_fixed_grid_inc.tpl | 64 +++++++++++++++------------------ templates/view_xref_kitlocker_group.tpl | 18 ++++++++++ view_kitlocker.php | 31 ++++++++++++++++ 5 files changed, 84 insertions(+), 36 deletions(-) create mode 100644 templates/view_xref_kitlocker_group.tpl create mode 100644 view_kitlocker.php diff --git a/admin/schema_inc.php b/admin/schema_inc.php index edf8463..d43bb76 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -88,7 +88,7 @@ $xrefItems = []; // ── 'stock' package-level groups — shared across stockassembly and stockcomponent ── // sort_order=1: stgrp (group tags, multi-valued KLGnn items) // sort_order=3: supplier (replaces per-type duplicates) -$xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`,`template`) VALUES ('stgrp', 'stock','Stock Groups', 1,3,'','')"; +$xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`,`template`) VALUES ('stgrp', 'stock','Stock Groups', 1,3,'','kitlocker')"; $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`,`template`) VALUES ('supplier', 'stock','Supplier', 3,3,'','sup')"; // KLG01–KLG28 — Kitlocker group tags (multiple=0 per item; multiple items per record = multi-group tagging) diff --git a/includes/classes/StockAssembly.php b/includes/classes/StockAssembly.php index 5765031..4fe4bdc 100755 --- a/includes/classes/StockAssembly.php +++ b/includes/classes/StockAssembly.php @@ -996,6 +996,11 @@ class StockAssembly extends StockBase { } $selectSql .= ", (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."stock_assembly_map` sacmc WHERE sacmc.`assembly_content_id` = lc.`content_id`) AS `child_count`"; + if( !empty( $pListHash['stgrp'] ) ) { + $whereSql .= " AND EXISTS (SELECT 1 FROM `".BIT_DB_PREFIX."liberty_xref` sx WHERE sx.`content_id` = lc.`content_id` AND sx.`item` = ?)"; + $bindVars[] = $pListHash['stgrp']; + } + // Putting in the below hack because mssql cannot select distinct on a text blob column. $selectSql .= $gBitDbType == 'mssql' ? " ,CAST(lc.`data` AS VARCHAR(250)) as `data` " : " ,lc.`data` "; diff --git a/templates/stock_fixed_grid_inc.tpl b/templates/stock_fixed_grid_inc.tpl index d6f0ba0..af84ab8 100755 --- a/templates/stock_fixed_grid_inc.tpl +++ b/templates/stock_fixed_grid_inc.tpl @@ -1,39 +1,33 @@ {strip} -{include file="bitpackage:stock/assembly_nav.tpl"} -
-
- {include file="bitpackage:stock/assembly_icons_inc.tpl"} -

{$gContent->getTitle()|escape}

-
+
+
+
+
+

{tr}Kitlocker{/tr}

+
-
- {formfeedback success=$stockSuccess error=$stockErrors warning=$stockWarnings} - - {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$gContent->mInfo} - {if $gContent->mInfo.data} -

{$gContent->mInfo.data|escape}

- {/if} - - - {counter assign="itemCount" start="0" print=false} - {foreach from=$gContent->mItems item=galItem key=itemContentId} - {if $itemCount % 4 == 0}{/if} - - {counter name=itemCount} - {if $itemCount % 4 == 0}{/if} - {/foreach} - {if $itemCount % 4 != 0}{/if} -
- {box class="box {$galItem->mInfo.content_type_guid}"} -

{$galItem->mInfo.title|escape}

- {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$galItem->mInfo type=mini} - {if $gBitSystem->isFeatureActive('stock_gallery_list_image_descriptions')} -

{$galItem->mInfo.data|escape}

+
+
+ {foreach $stgrpItems as $item} +
+
+ + {if $item.data} +
+ {$item.data|escape} +
{/if} - {/box} -
- - {pagination content_id=$gContent->mContentId} -
-
+ +
+ + {foreachelse} +

{tr}No kitlocker groups defined.{/tr}

+ {/foreach} + + + {/strip} diff --git a/templates/view_xref_kitlocker_group.tpl b/templates/view_xref_kitlocker_group.tpl new file mode 100644 index 0000000..94a67ec --- /dev/null +++ b/templates/view_xref_kitlocker_group.tpl @@ -0,0 +1,18 @@ +{assign var=xrefAllowEdit value=$allow_edit|default:false} +{assign var=isHistory value=($xrefGroup->mXGroup eq 'history')} +{strip} + +{/strip} diff --git a/view_kitlocker.php b/view_kitlocker.php new file mode 100644 index 0000000..2523337 --- /dev/null +++ b/view_kitlocker.php @@ -0,0 +1,31 @@ +verifyPackage( 'stock' ); + +global $gBitSystem, $gBitSmarty, $gBitDb; + +$stgrpItems = $gBitDb->getAll( + "SELECT xi.`item`, xi.`cross_ref_title`, xi.`data`, + (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref` x + INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.`content_id` = x.`content_id` + WHERE x.`item` = xi.`item` + AND lc.`content_type_guid` IN ('stockassembly','stockcomponent')) AS item_count + FROM `".BIT_DB_PREFIX."liberty_xref_item` xi + WHERE xi.`x_group` = 'stgrp' AND xi.`content_type_guid` = 'stock' + ORDER BY xi.`item`" +); + +$gBitSmarty->assign( 'stgrpItems', $stgrpItems ); + +$gBitSystem->setBrowserTitle( KernelTools::tra( 'Kitlocker' ) ); +$gBitSystem->display( 'bitpackage:stock/stock_fixed_grid_inc.tpl', null, [ 'display_mode' => 'display' ] ); -- cgit v1.3