summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-12 17:38:28 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-12 17:38:28 +0100
commit3866f6c02cfae647d04e9123392b608e0d0aa3a6 (patch)
treed1ad20d3ed8221d777ec11d50e87b907a49b1dfd
parent77483b34115f0f6f71cfdea3069c4aca1bb30a7e (diff)
downloadstock-3866f6c02cfae647d04e9123392b608e0d0aa3a6.tar.gz
stock-3866f6c02cfae647d04e9123392b608e0d0aa3a6.tar.bz2
stock-3866f6c02cfae647d04e9123392b608e0d0aa3a6.zip
stock: movement xref views use linked_title/linked_data; bomprt tidy; floaticon form fixes
StockMovement::loadXrefInfo() — drop xref_title/xref_data enrichment (now from lc_linked JOIN); restore part_size/part_size_ext query; use array_map not array_column. stockmovement view_xref_bom_item/bomprt_item — switch to linked_title/linked_data. Movement bomprt qty: round(xkey/part_size, 3) of part_size (pieces-needed fraction). Both bomprt templates: drop notes row; drop part_size_ext (PRT = integer parts, not VOL). list_components: plain <form> (GET needs no CSRF), form-inline + form-group structure, hidden-print on floaticon; hide-kitlocker checkbox properly spaced. list_movements: hidden-print on floaticon div. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--includes/classes/StockMovement.php34
-rw-r--r--templates/list_components.tpl18
-rw-r--r--templates/list_movements.tpl2
-rw-r--r--templates/stockassembly/view_xref_bomprt_item.tpl7
-rw-r--r--templates/stockmovement/view_xref_bom_item.tpl4
-rw-r--r--templates/stockmovement/view_xref_bomprt_item.tpl11
6 files changed, 30 insertions, 46 deletions
diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php
index e867460..57e8146 100644
--- a/includes/classes/StockMovement.php
+++ b/includes/classes/StockMovement.php
@@ -173,41 +173,29 @@ class StockMovement extends LibertyContent {
}
/**
- * Load xref groups then enrich the 'quantity' group — resolves each component
- * content_id to xref_title and xref_data (component description).
+ * Enrich the quantity group with part_size/part_size_ext from the PRT xref.
+ * linked_title and linked_data come from the lc_linked JOIN in loadContent().
*/
public function loadXrefInfo(): void {
parent::loadXrefInfo();
if( empty( $this->mXrefInfo ) ) return;
$bomGroup = $this->mXrefInfo->mGroups['quantity'] ?? null;
if( !$bomGroup || empty( $bomGroup->mXrefs ) ) return;
- $componentIds = array_values( array_unique( array_filter( array_column( $bomGroup->mXrefs, 'xref' ) ) ) );
+ $componentIds = array_values( array_unique( array_filter(
+ array_map( fn($r) => $r['xref'], $bomGroup->mXrefs )
+ ) ) );
if( !$componentIds ) return;
$components = $this->mDb->getAssoc(
- "SELECT lc.`content_id`, lc.`title`, lc.`data` FROM `".BIT_DB_PREFIX."liberty_content` lc WHERE lc.`content_id` IN (".implode( ',', array_fill( 0, count( $componentIds ), '?' ) ).")",
+ "SELECT lc.`content_id`, pck.`xkey` AS `part_size`, pck.`xkey_ext` AS `part_size_ext`
+ FROM `".BIT_DB_PREFIX."liberty_content` lc
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` pck ON pck.`content_id` = lc.`content_id` AND pck.`item` = 'PRT'
+ WHERE lc.`content_id` IN (".implode( ',', array_fill( 0, count( $componentIds ), '?' ) ).")",
$componentIds
);
foreach( $bomGroup->mXrefs as &$row ) {
if( !empty( $row['xref'] ) && isset( $components[$row['xref']] ) ) {
- $row['xref_title'] = $components[$row['xref']]['title'];
- $row['xref_data'] = $components[$row['xref']]['data'];
- }
- }
- unset( $row );
-
- $assemblyGroup = $this->mXrefInfo->mGroups['assembly'] ?? null;
- if( !$assemblyGroup || empty( $assemblyGroup->mXrefs ) ) return;
- $assemblyIds = array_values( array_unique( array_filter( array_column( $assemblyGroup->mXrefs, 'xref' ) ) ) );
- if( !$assemblyIds ) return;
- $assemblies = $this->mDb->getAssoc(
- "SELECT lc.`content_id`, lc.`title`, lc.`data` FROM `".BIT_DB_PREFIX."liberty_content` lc
- WHERE lc.`content_id` IN (".implode( ',', array_fill( 0, count( $assemblyIds ), '?' ) ).")",
- $assemblyIds
- );
- foreach( $assemblyGroup->mXrefs as &$row ) {
- if( !empty( $row['xref'] ) && isset( $assemblies[$row['xref']] ) ) {
- $row['linked_title'] = $assemblies[$row['xref']]['title'];
- $row['linked_desc'] = $assemblies[$row['xref']]['data'];
+ $row['part_size'] = $components[$row['xref']]['part_size'];
+ $row['part_size_ext'] = $components[$row['xref']]['part_size_ext'];
}
}
unset( $row );
diff --git a/templates/list_components.tpl b/templates/list_components.tpl
index cfe596e..f27d3b3 100644
--- a/templates/list_components.tpl
+++ b/templates/list_components.tpl
@@ -1,17 +1,23 @@
{strip}
<div class="listing stock">
<header>
- <div class="floaticon">
+ <div class="floaticon hidden-print">
{if $gBitUser->hasPermission('p_stock_create')}
<a href="{$smarty.const.STOCK_PKG_URL}edit_component.php">{biticon ipackage="icons" iname="kt-add-filters" iexplain="Create Component"}</a>
{/if}
- {form class="minifind" method="get" action=$smarty.server.SCRIPT_NAME}
- <div class="input-prepend form-inline">
- <input class="form-control input-sm search-query" type="text" name="find" placeholder="Components" value="{$smarty.request.find|escape}" />
- <label class="checkbox-inline"><input type="checkbox" name="hide_kitlocker" value="1"{if $hideKitlocker} checked="checked"{/if} /> {tr}Hide kitlocker{/tr}</label>
+ <form class="minifind" action="{$smarty.const.STOCK_PKG_URL}list_components.php" method="get">
+ <div class="form-inline">
+ <div class="form-group">
+ <input class="form-control input-sm" type="text" name="find" placeholder="{tr}Components{/tr}" value="{$smarty.request.find|escape}" />
+ </div>
+ <div class="form-group">
+ <label class="checkbox-inline">
+ <input type="checkbox" name="hide_kitlocker" value="1"{if $hideKitlocker} checked="checked"{/if} /> {tr}Hide kitlocker{/tr}
+ </label>
+ </div>
<button type="submit" class="btn btn-default btn-sm">{tr}Search{/tr}</button>
</div>
- {/form}
+ </form>
</div>
<h1>{tr}Components{/tr}{if $gQueryUserId} {tr}by{/tr} {displayname user_id=$gQueryUserId}{/if}</h1>
</header>
diff --git a/templates/list_movements.tpl b/templates/list_movements.tpl
index a383e00..442f29d 100644
--- a/templates/list_movements.tpl
+++ b/templates/list_movements.tpl
@@ -1,7 +1,7 @@
{strip}
<div class="listing stock">
<header>
- <div class="floaticon">
+ <div class="floaticon hidden-print">
<button type="button" class="btn btn-link" onclick="window.print()">{biticon ipackage="icons" iname="document-print" iexplain="Print"}</button>
{if $gBitUser->hasPermission('p_stock_create')}
<a href="{$smarty.const.STOCK_PKG_URL}add_requisition.php">{biticon ipackage="icons" iname="list-add" iexplain="Add Requisition"}</a>
diff --git a/templates/stockassembly/view_xref_bomprt_item.tpl b/templates/stockassembly/view_xref_bomprt_item.tpl
index c066678..ba668a5 100644
--- a/templates/stockassembly/view_xref_bomprt_item.tpl
+++ b/templates/stockassembly/view_xref_bomprt_item.tpl
@@ -8,7 +8,7 @@
{/if}
</td>
<td>{$xrefInfo.linked_data|escape}</td>
- <td>{$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if}</td>
+ <td>{$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{/if}</td>
<td>{$xrefInfo.xkey_ext|escape}</td>
{if $xrefAllowEdit}
<td>{$xrefInfo.start_date|bit_short_date}</td>
@@ -25,9 +25,4 @@
</td>
{/if}
</tr>
-{if $xrefInfo.data}
-<tr>
- <td colspan="{if $xrefAllowEdit}7{else}4{/if}" class="xref-note">{$xrefInfo.data|escape}</td>
-</tr>
-{/if}
{/strip}
diff --git a/templates/stockmovement/view_xref_bom_item.tpl b/templates/stockmovement/view_xref_bom_item.tpl
index 1ed0a95..6dfd627 100644
--- a/templates/stockmovement/view_xref_bom_item.tpl
+++ b/templates/stockmovement/view_xref_bom_item.tpl
@@ -2,12 +2,12 @@
<tr class="{cycle values="even,odd"}">
<td>
{if $xrefInfo.xref > 0}
- <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a>
+ <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.linked_title|default:$xrefInfo.xref|escape}</a>
{else}
&nbsp;
{/if}
</td>
- <td>{$xrefInfo.xref_data|escape}</td>
+ <td>{$xrefInfo.linked_data|escape}</td>
<td>{$xrefInfo.xkey|escape}</td>
<td>{$xrefInfo.xkey_ext|escape}</td>
{if $xrefAllowEdit}
diff --git a/templates/stockmovement/view_xref_bomprt_item.tpl b/templates/stockmovement/view_xref_bomprt_item.tpl
index 002ae89..9cb997c 100644
--- a/templates/stockmovement/view_xref_bomprt_item.tpl
+++ b/templates/stockmovement/view_xref_bomprt_item.tpl
@@ -2,13 +2,13 @@
<tr class="{cycle values="even,odd"}">
<td>
{if $xrefInfo.xref > 0}
- <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a>
+ <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.linked_title|default:$xrefInfo.xref|escape}</a>
{else}
&nbsp;
{/if}
</td>
- <td>{$xrefInfo.xref_data|escape}</td>
- <td>{$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if}</td>
+ <td>{$xrefInfo.linked_data|escape}</td>
+ <td>{if $xrefInfo.part_size}{math equation="round(x/y,3)" x=$xrefInfo.xkey y=$xrefInfo.part_size} of {$xrefInfo.part_size|escape}{else}{$xrefInfo.xkey|escape}{/if}</td>
<td>{$xrefInfo.xkey_ext|escape}</td>
{if $xrefAllowEdit}
<td>{$xrefInfo.start_date|bit_short_date}</td>
@@ -25,9 +25,4 @@
</td>
{/if}
</tr>
-{if $xrefInfo.data}
-<tr>
- <td colspan="{if $xrefAllowEdit}7{else}4{/if}" class="xref-note">{$xrefInfo.data|escape}</td>
-</tr>
-{/if}
{/strip}