summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-10 09:16:33 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-10 09:16:33 +0100
commit8566070da24cd53845c64cdf2cd2104c847e450c (patch)
tree8348a496fe32a74713fad9f3850c40d90be7d6a4
parent0582e0b40f3440e8ec4c95c99501019e6933e20b (diff)
downloadstock-8566070da24cd53845c64cdf2cd2104c847e450c.tar.gz
stock-8566070da24cd53845c64cdf2cd2104c847e450c.tar.bz2
stock-8566070da24cd53845c64cdf2cd2104c847e450c.zip
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
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-xadmin/schema_inc.php2
-rwxr-xr-xincludes/classes/StockAssembly.php5
-rwxr-xr-xtemplates/stock_fixed_grid_inc.tpl64
-rw-r--r--templates/view_xref_kitlocker_group.tpl18
-rw-r--r--view_kitlocker.php31
5 files changed, 84 insertions, 36 deletions
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"}
-<div class="display stock container">
- <div class="header col-xs-12">
- {include file="bitpackage:stock/assembly_icons_inc.tpl"}
- <h1>{$gContent->getTitle()|escape}</h1>
- </div>
+<div class="listing stock">
+ <header>
+ <div class="floaticon">
+ </div>
+ <h1>{tr}Kitlocker{/tr}</h1>
+ </header>
- <div class="body">
- {formfeedback success=$stockSuccess error=$stockErrors warning=$stockWarnings}
-
- {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$gContent->mInfo}
- {if $gContent->mInfo.data}
- <p>{$gContent->mInfo.data|escape}</p>
- {/if}
-
- <table class="thumbnailblock">
- {counter assign="itemCount" start="0" print=false}
- {foreach from=$gContent->mItems item=galItem key=itemContentId}
- {if $itemCount % 4 == 0}<tr>{/if}
- <td style="width:25%; vertical-align:top;">
- {box class="box {$galItem->mInfo.content_type_guid}"}
- <h4><a href="{$galItem->getDisplayUrl()|escape}">{$galItem->mInfo.title|escape}</a></h4>
- {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$galItem->mInfo type=mini}
- {if $gBitSystem->isFeatureActive('stock_gallery_list_image_descriptions')}
- <p>{$galItem->mInfo.data|escape}</p>
+ <section class="body">
+ <div class="row">
+ {foreach $stgrpItems as $item}
+ <div class="col-md-4 col-sm-6 col-xs-12">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <a href="{$smarty.const.STOCK_PKG_URL}list_assemblies.php?stgrp={$item.item|escape:'url'}">{$item.cross_ref_title|escape}</a>
+ </div>
+ {if $item.data}
+ <div class="panel-body">
+ {$item.data|escape}
+ </div>
{/if}
- {/box}
- </td>
- {counter name=itemCount}
- {if $itemCount % 4 == 0}</tr>{/if}
- {/foreach}
- {if $itemCount % 4 != 0}</tr>{/if}
- </table>
-
- {pagination content_id=$gContent->mContentId}
- </div><!-- end .body -->
-</div><!-- end .stock -->
+ <div class="panel-footer">
+ {tr}Count{/tr}: {$item.item_count}
+ </div>
+ </div>
+ </div>
+ {foreachelse}
+ <div class="col-xs-12"><p class="norecords">{tr}No kitlocker groups defined.{/tr}</p></div>
+ {/foreach}
+ </div>
+ </section>
+</div>
{/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}
+<div class="row stock-group-gallery">
+ {foreach $xrefGroup->mXrefs as $xrefInfo}
+ <div class="col-md-4 col-sm-6 col-xs-12">
+ <div class="panel panel-default">
+ <div class="panel-body">
+ <strong>{$xrefInfo.xref_title|escape}</strong>
+ <small class="text-muted pull-right">{$xrefInfo.item|escape}</small>
+ </div>
+ </div>
+ </div>
+ {foreachelse}
+ <div class="col-xs-12"><p class="norecords">{tr}No stock groups assigned.{/tr}</p></div>
+ {/foreach}
+</div>
+{/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 @@
+<?php
+/**
+ * Kitlocker group gallery — shows all stgrp items as a browsable grid.
+ * @package stock
+ */
+
+namespace Bitweaver\Stock;
+
+use Bitweaver\KernelTools;
+
+require_once '../kernel/includes/setup_inc.php';
+
+$gBitSystem->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' ] );