summaryrefslogtreecommitdiff
path: root/includes
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 /includes
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>
Diffstat (limited to 'includes')
-rw-r--r--includes/classes/StockMovement.php34
1 files changed, 11 insertions, 23 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 );