summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-03 20:50:29 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-03 20:50:29 +0100
commite61e527351614a53a4eab3a204c798cb328d281a (patch)
tree7ea478bfcb506ddf2dba001d2e7b8e822e4464ca
parentceebb1000db2ce8643edde2e72f202b0aeda1691 (diff)
downloadstock-e61e527351614a53a4eab3a204c798cb328d281a.tar.gz
stock-e61e527351614a53a4eab3a204c798cb328d281a.tar.bz2
stock-e61e527351614a53a4eab3a204c798cb328d281a.zip
stock: fix markReceived, add ref_start_date to load(), tidy view_movement dates
- markReceived() was passing mDb->NOW() string into BIGINT event_time; use time() - load() now includes ref_start_date correlated subquery (same as getList) - view_movement.tpl: Created → Ordered → Received order; Ordered only shown when ref_start_date is set Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--includes/classes/StockMovement.php6
-rw-r--r--templates/view_movement.tpl8
2 files changed, 11 insertions, 3 deletions
diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php
index 1338af3..9256e03 100644
--- a/includes/classes/StockMovement.php
+++ b/includes/classes/StockMovement.php
@@ -64,9 +64,13 @@ class StockMovement extends LibertyContent {
$selectSql = $joinSql = '';
$this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
+ $X = BIT_DB_PREFIX;
$sql = "SELECT lc.* $selectSql
, uue.`login` AS `modifier_user`, uue.`real_name` AS `modifier_real_name`
, uuc.`login` AS `creator_user`, uuc.`real_name` AS `creator_real_name`
+ , (SELECT FIRST 1 x.`start_date` FROM `{$X}liberty_xref` x
+ WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('REQN','TRANS','ORDER')
+ ORDER BY x.`xorder`) AS ref_start_date
FROM `".BIT_DB_PREFIX."liberty_content` lc
LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON uue.`user_id` = lc.`modifier_user_id`
LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON uuc.`user_id` = lc.`user_id`
@@ -157,7 +161,7 @@ class StockMovement extends LibertyContent {
public function markReceived(): bool {
if( !$this->isValid() ) return false;
- $now = $this->mDb->NOW();
+ $now = time();
$this->mDb->query(
"UPDATE `".BIT_DB_PREFIX."liberty_content` SET `event_time` = ? WHERE `content_id` = ?",
[ $now, $this->mContentId ]
diff --git a/templates/view_movement.tpl b/templates/view_movement.tpl
index 87c4c44..4c810b0 100644
--- a/templates/view_movement.tpl
+++ b/templates/view_movement.tpl
@@ -15,10 +15,14 @@
<dl class="dl-horizontal">
<dt>{tr}Type{/tr}</dt>
<dd>{$gContent->getDirection()|escape}</dd>
- <dt>{tr}Received{/tr}</dt>
- <dd>{if $gContent->isReceived()}{$gContent->mInfo.event_time|bit_short_date}{else}{tr}Pending{/tr}{/if}</dd>
<dt>{tr}Created{/tr}</dt>
<dd>{$gContent->mInfo.created|bit_short_datetime} {tr}by{/tr} {$gContent->mInfo.creator|escape}</dd>
+ {if $gContent->mInfo.ref_start_date}
+ <dt>{tr}Ordered{/tr}</dt>
+ <dd>{$gContent->mInfo.ref_start_date|bit_short_date}</dd>
+ {/if}
+ <dt>{tr}Received{/tr}</dt>
+ <dd>{if $gContent->isReceived()}{$gContent->mInfo.event_time|bit_short_date}{else}{tr}Pending{/tr}{/if}</dd>
{if $gContent->mInfo.last_modified neq $gContent->mInfo.created}
<dt>{tr}Modified{/tr}</dt>
<dd>{$gContent->mInfo.last_modified|bit_short_datetime} {tr}by{/tr} {$gContent->mInfo.editor|escape}</dd>