summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-15 11:53:20 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-15 11:53:20 +0100
commit0b7b199e6f60efc7fb29e8c0f0515ae6562b27c4 (patch)
treeb3d8bb6c29b15855de1d514b88e9a7822a613072
parent68d6d45635a040a5004581afc5ae78db729175d7 (diff)
downloadstock-0b7b199e6f60efc7fb29e8c0f0515ae6562b27c4.tar.gz
stock-0b7b199e6f60efc7fb29e8c0f0515ae6562b27c4.tar.bz2
stock-0b7b199e6f60efc7fb29e8c0f0515ae6562b27c4.zip
Link prebuild count in user_galleries to its PBLD movement record
Add prebuild_content_id to StockAssembly::getList() (most recent PBLD movement for the assembly owner) and link both the Prebuilt label and count in user_galleries.tpl to view_movement.php?content_id=. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-xincludes/classes/StockAssembly.php7
-rwxr-xr-xtemplates/user_galleries.tpl10
2 files changed, 15 insertions, 2 deletions
diff --git a/includes/classes/StockAssembly.php b/includes/classes/StockAssembly.php
index 10a59d7..db017f7 100755
--- a/includes/classes/StockAssembly.php
+++ b/includes/classes/StockAssembly.php
@@ -1007,6 +1007,13 @@ class StockAssembly extends StockBase {
AND mc.`content_type_guid` = 'stockmovement' AND mc.`user_id` = lc.`user_id`
INNER JOIN `{$X}liberty_xref` xpbld ON xpbld.`content_id` = xasm.`content_id` AND xpbld.`item` = 'PBLD'
WHERE xasm.`item` = 'ASSEMBLY' AND xasm.`xref` = lc.`content_id`) AS `prebuild_count`";
+ $selectSql .= ", (SELECT FIRST 1 xpbld.`content_id`
+ FROM `{$X}liberty_xref` xasm
+ INNER JOIN `{$X}liberty_content` mc ON mc.`content_id` = xasm.`content_id`
+ AND mc.`content_type_guid` = 'stockmovement' AND mc.`user_id` = lc.`user_id`
+ INNER JOIN `{$X}liberty_xref` xpbld ON xpbld.`content_id` = xasm.`content_id` AND xpbld.`item` = 'PBLD'
+ WHERE xasm.`item` = 'ASSEMBLY' AND xasm.`xref` = lc.`content_id`
+ ORDER BY mc.`created` DESC) AS `prebuild_content_id`";
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` = ?)";
diff --git a/templates/user_galleries.tpl b/templates/user_galleries.tpl
index bda5520..8813e23 100755
--- a/templates/user_galleries.tpl
+++ b/templates/user_galleries.tpl
@@ -37,8 +37,14 @@
<dl class="dl-horizontal small" style="margin-bottom:0">
<dt>{tr}Components{/tr}</dt>
<dd>{$gal.component_count}</dd>
- <dt>{tr}Prebuilt{/tr}</dt>
- <dd>{$gal.prebuild_count|string_format:"%.0f"}</dd>
+ {if $gal.prebuild_content_id}
+ {assign var=pbldUrl value="`$smarty.const.STOCK_PKG_URL`view_movement.php?content_id=`$gal.prebuild_content_id`"}
+ <dt><a href="{$pbldUrl}">{tr}Prebuilt{/tr}</a></dt>
+ <dd><a href="{$pbldUrl}">{$gal.prebuild_count|string_format:"%.0f"}</a></dd>
+ {else}
+ <dt>{tr}Prebuilt{/tr}</dt>
+ <dd>{$gal.prebuild_count|string_format:"%.0f"}</dd>
+ {/if}
</dl>
</div>
</div>