From 3866f6c02cfae647d04e9123392b608e0d0aa3a6 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Fri, 12 Jun 2026 17:38:28 +0100 Subject: stock: movement xref views use linked_title/linked_data; bomprt tidy; floaticon form fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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
(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 --- includes/classes/StockMovement.php | 34 ++++++++--------------- templates/list_components.tpl | 18 ++++++++---- templates/list_movements.tpl | 2 +- templates/stockassembly/view_xref_bomprt_item.tpl | 7 +---- templates/stockmovement/view_xref_bom_item.tpl | 4 +-- templates/stockmovement/view_xref_bomprt_item.tpl | 11 ++------ 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}
-
+
{if $gBitUser->hasPermission('p_stock_create')} {biticon ipackage="icons" iname="kt-add-filters" iexplain="Create Component"} {/if} - {form class="minifind" method="get" action=$smarty.server.SCRIPT_NAME} -
- - + +
+
+ +
+
+ +
- {/form} +

{tr}Components{/tr}{if $gQueryUserId} {tr}by{/tr} {displayname user_id=$gQueryUserId}{/if}

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}
-
+
{if $gBitUser->hasPermission('p_stock_create')} {biticon ipackage="icons" iname="list-add" iexplain="Add Requisition"} 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} {$xrefInfo.linked_data|escape} - {$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if} + {$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{/if} {$xrefInfo.xkey_ext|escape} {if $xrefAllowEdit} {$xrefInfo.start_date|bit_short_date} @@ -25,9 +25,4 @@ {/if} -{if $xrefInfo.data} - - {$xrefInfo.data|escape} - -{/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 @@ {if $xrefInfo.xref > 0} - {$xrefInfo.xref_title|default:$xrefInfo.xref|escape} + {$xrefInfo.linked_title|default:$xrefInfo.xref|escape} {else}   {/if} - {$xrefInfo.xref_data|escape} + {$xrefInfo.linked_data|escape} {$xrefInfo.xkey|escape} {$xrefInfo.xkey_ext|escape} {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 @@ {if $xrefInfo.xref > 0} - {$xrefInfo.xref_title|default:$xrefInfo.xref|escape} + {$xrefInfo.linked_title|default:$xrefInfo.xref|escape} {else}   {/if} - {$xrefInfo.xref_data|escape} - {$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if} + {$xrefInfo.linked_data|escape} + {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} {$xrefInfo.xkey_ext|escape} {if $xrefAllowEdit} {$xrefInfo.start_date|bit_short_date} @@ -25,9 +25,4 @@ {/if} -{if $xrefInfo.data} - - {$xrefInfo.data|escape} - -{/if} {/strip} -- cgit v1.3