summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-16 08:39:59 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-16 08:39:59 +0100
commit894b67457d9272b3726790fa103332bf250d2a4b (patch)
treeb5bf8901693be98094bbb375e708ac1058a3771a
parent660e448b34944e9cad136a30dbb31a081c4fc153 (diff)
downloadstock-894b67457d9272b3726790fa103332bf250d2a4b.tar.gz
stock-894b67457d9272b3726790fa103332bf250d2a4b.tar.bz2
stock-894b67457d9272b3726790fa103332bf250d2a4b.zip
Fix ref_key not loading on edit; restrict movement type to ORDER/TRANS
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 <noreply@anthropic.com>
-rw-r--r--edit_movement.php1
-rw-r--r--includes/classes/StockMovement.php3
2 files changed, 4 insertions, 0 deletions
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