summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-10 09:28:51 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-10 09:28:51 +0100
commit2a0ea930de9d59e29bf4ddeb1585e61061109d7d (patch)
treed6d2d74e84d62e38cf3969c4d016a4365e7e61af
parent8566070da24cd53845c64cdf2cd2104c847e450c (diff)
downloadstock-2a0ea930de9d59e29bf4ddeb1585e61061109d7d.tar.gz
stock-2a0ea930de9d59e29bf4ddeb1585e61061109d7d.tar.bz2
stock-2a0ea930de9d59e29bf4ddeb1585e61061109d7d.zip
stock: add list_kitlocker.php — combined assembly/component kitlocker list with stgrp filter; gallery links to list_kitlocker; breadcrumb back link in header
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--list_kitlocker.php55
-rw-r--r--templates/list_kitlocker.tpl43
-rwxr-xr-xtemplates/stock_fixed_grid_inc.tpl2
3 files changed, 99 insertions, 1 deletions
diff --git a/list_kitlocker.php b/list_kitlocker.php
new file mode 100644
index 0000000..7598c53
--- /dev/null
+++ b/list_kitlocker.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Combined kitlocker listing — assemblies and components filtered by stgrp tag.
+ * @package stock
+ */
+
+namespace Bitweaver\Stock;
+
+use Bitweaver\KernelTools;
+
+require_once '../kernel/includes/setup_inc.php';
+
+$gBitSystem->verifyPackage( 'stock' );
+
+global $gBitSystem, $gBitSmarty, $gBitDb;
+
+$stgrp = !empty( $_REQUEST['stgrp'] ) ? trim( $_REQUEST['stgrp'] ) : null;
+
+$X = BIT_DB_PREFIX;
+$bindVars = [];
+$whereSql = "AND lc.`content_type_guid` IN ('stockassembly','stockcomponent')";
+
+if( $stgrp ) {
+ $whereSql .= " AND EXISTS (SELECT 1 FROM `{$X}liberty_xref` sx WHERE sx.`content_id` = lc.`content_id` AND sx.`item` = ?)";
+ $bindVars[] = $stgrp;
+ $groupTitle = $gBitDb->getOne(
+ "SELECT `cross_ref_title` FROM `{$X}liberty_xref_item` WHERE `item` = ? AND `x_group` = 'stgrp'",
+ [ $stgrp ]
+ );
+} else {
+ $whereSql .= " AND EXISTS (SELECT 1 FROM `{$X}liberty_xref` sx
+ INNER JOIN `{$X}liberty_xref_item` xi ON xi.`item` = sx.`item` AND xi.`x_group` = 'stgrp'
+ WHERE sx.`content_id` = lc.`content_id`)";
+ $groupTitle = null;
+}
+
+$items = $gBitDb->getAll(
+ "SELECT lc.`content_id`, lc.`title`, lc.`data`, lc.`content_type_guid`,
+ (SELECT FIRST 1 x.`xkey` FROM `{$X}liberty_xref` x
+ WHERE x.`content_id` = lc.`content_id` AND x.`item` = 'KLID') AS klid,
+ (SELECT FIRST 1 x.`xkey` FROM `{$X}liberty_xref` x
+ WHERE x.`content_id` = lc.`content_id` AND x.`item` = 'KLPR') AS klpr
+ FROM `{$X}liberty_content` lc
+ WHERE 1=1 $whereSql
+ ORDER BY lc.`title`",
+ $bindVars
+);
+
+$gBitSmarty->assign( 'kitlockerItems', $items );
+$gBitSmarty->assign( 'stgrp', $stgrp );
+$gBitSmarty->assign( 'groupTitle', $groupTitle );
+
+$pageTitle = $groupTitle ?: KernelTools::tra( 'Kitlocker' );
+$gBitSystem->setBrowserTitle( $pageTitle );
+$gBitSystem->display( 'bitpackage:stock/list_kitlocker.tpl', null, [ 'display_mode' => 'list' ] );
diff --git a/templates/list_kitlocker.tpl b/templates/list_kitlocker.tpl
new file mode 100644
index 0000000..c7e1c44
--- /dev/null
+++ b/templates/list_kitlocker.tpl
@@ -0,0 +1,43 @@
+{strip}
+<div class="listing stock">
+ <header>
+ <div class="floaticon">
+ </div>
+ <h1>{if $groupTitle}{$groupTitle|escape}{else}{tr}Kitlocker{/tr}{/if}</h1>
+ {if $stgrp}<small><a href="{$smarty.const.STOCK_PKG_URL}view_kitlocker.php">&lsaquo; {tr}Kitlocker{/tr}</a></small>{/if}
+ </header>
+
+ <section class="body">
+
+ <table class="table table-striped table-hover">
+ <thead>
+ <tr>
+ <th>{tr}Name{/tr}</th>
+ <th>{tr}Type{/tr}</th>
+ <th>{tr}KLID{/tr}</th>
+ <th>{tr}Price{/tr}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach $kitlockerItems as $item}
+ <tr>
+ <td>
+ {if $item.content_type_guid eq 'stockassembly'}
+ <a href="{$smarty.const.STOCK_PKG_URL}view_assembly.php?content_id={$item.content_id}">{$item.title|escape}</a>
+ {else}
+ <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$item.content_id}">{$item.title|escape}</a>
+ {/if}
+ {if $item.data}<br/><small class="text-muted">{$item.data|truncate:120|escape}</small>{/if}
+ </td>
+ <td>{if $item.content_type_guid eq 'stockassembly'}{tr}Assembly{/tr}{else}{tr}Component{/tr}{/if}</td>
+ <td>{$item.klid|escape}</td>
+ <td>{$item.klpr|escape}</td>
+ </tr>
+ {foreachelse}
+ <tr><td colspan="4" class="norecords">{tr}No kitlocker items found.{/tr}</td></tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </section>
+</div>
+{/strip}
diff --git a/templates/stock_fixed_grid_inc.tpl b/templates/stock_fixed_grid_inc.tpl
index af84ab8..f4c3aae 100755
--- a/templates/stock_fixed_grid_inc.tpl
+++ b/templates/stock_fixed_grid_inc.tpl
@@ -12,7 +12,7 @@
<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>
+ <a href="{$smarty.const.STOCK_PKG_URL}list_kitlocker.php?stgrp={$item.item|escape:'url'}">{$item.cross_ref_title|escape}</a>
</div>
{if $item.data}
<div class="panel-body">