From 894b67457d9272b3726790fa103332bf250d2a4b Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Tue, 16 Jun 2026 08:39:59 +0100 Subject: Fix ref_key not loading on edit; restrict movement type to ORDER/TRANS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ref_key (xkey) subquery to StockMovement::load() — it was present in getList() but missing from load(), so the field always appeared blank on edit. Filter edit_movement.php refTypes query to ORDER and TRANS only; REQN and PBLD are created via their own dedicated entry points. Co-Authored-By: Claude Sonnet 4.6 --- edit_movement.php | 1 + includes/classes/StockMovement.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/edit_movement.php b/edit_movement.php index defc9f4..588065b 100644 --- a/edit_movement.php +++ b/edit_movement.php @@ -29,6 +29,7 @@ $refTypes = $gBitDb->getAssoc( FROM `".BIT_DB_PREFIX."liberty_xref_item` xi JOIN `".BIT_DB_PREFIX."liberty_xref_group` xg ON xg.`x_group` = xi.`x_group` AND xg.`content_type_guid` = xi.`content_type_guid` WHERE xi.`content_type_guid` = '".STOCKMOVEMENT_CONTENT_TYPE_GUID."' AND xi.`x_group` = 'reference' + AND xi.`item` IN ('ORDER','TRANS') ORDER BY xi.`item`" ); diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php index 178944d..a735607 100644 --- a/includes/classes/StockMovement.php +++ b/includes/classes/StockMovement.php @@ -109,6 +109,9 @@ class StockMovement extends LibertyContent { , (SELECT FIRST 1 x.`item` FROM `{$X}liberty_xref` x WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('REQN','TRANS','ORDER','PBLD') ORDER BY x.`xorder`) AS ref_type + , (SELECT FIRST 1 x.`xkey` FROM `{$X}liberty_xref` x + WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('REQN','TRANS','ORDER','PBLD') + ORDER BY x.`xorder`) AS ref_key , (SELECT FIRST 1 x.`data` FROM `{$X}liberty_xref` x WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('REQN','TRANS','ORDER','PBLD') ORDER BY x.`xorder`) AS ref_from_data -- cgit v1.3