summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-03 20:59:10 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-03 20:59:10 +0100
commitbd83a2fe21894707ccb49f987dff4d1c0f6121cd (patch)
treeb9f3884d1ff3893acb06a47bbb0eda77f8d4e933
parente61e527351614a53a4eab3a204c798cb328d281a (diff)
downloadstock-bd83a2fe21894707ccb49f987dff4d1c0f6121cd.tar.gz
stock-bd83a2fe21894707ccb49f987dff4d1c0f6121cd.tar.bz2
stock-bd83a2fe21894707ccb49f987dff4d1c0f6121cd.zip
stock: drop Ref column, sortable Ordered/Received, fix smartlink isort
- Remove redundant ref_key column (shown in Reference already) - Add ref_start_date sort to getList() match block (subquery-based, avoids Firebird alias restriction) - Fix isort values: smartlink appends _asc/_desc itself — passing _desc in isort was generating ref_start_date_desc_desc Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--includes/classes/StockMovement.php6
-rw-r--r--templates/list_movements.tpl8
2 files changed, 7 insertions, 7 deletions
diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php
index 9256e03..6ad7011 100644
--- a/includes/classes/StockMovement.php
+++ b/includes/classes/StockMovement.php
@@ -244,8 +244,10 @@ class StockMovement extends LibertyContent {
$sortMode = $pListHash['sort_mode'] ?? '';
$orderby = match( $sortMode ) {
- 'event_time_asc' => ' ORDER BY lc.event_time ASC',
- 'event_time_desc' => ' ORDER BY lc.event_time DESC',
+ 'event_time_asc' => ' ORDER BY lc.event_time ASC',
+ 'event_time_desc' => ' ORDER BY lc.event_time DESC',
+ 'ref_start_date_asc' => ' ORDER BY (SELECT FIRST 1 x.start_date FROM '.BIT_DB_PREFIX.'liberty_xref x WHERE x.content_id=lc.content_id AND x.item IN (\'REQN\',\'TRANS\',\'ORDER\') ORDER BY x.xorder) ASC',
+ 'ref_start_date_desc' => ' ORDER BY (SELECT FIRST 1 x.start_date FROM '.BIT_DB_PREFIX.'liberty_xref x WHERE x.content_id=lc.content_id AND x.item IN (\'REQN\',\'TRANS\',\'ORDER\') ORDER BY x.xorder) DESC',
default => !empty( $sortMode )
? ' ORDER BY '.$this->mDb->convertSortmode( $sortMode )
: ' ORDER BY lc.last_modified DESC',
diff --git a/templates/list_movements.tpl b/templates/list_movements.tpl
index bc0bc34..977b4a2 100644
--- a/templates/list_movements.tpl
+++ b/templates/list_movements.tpl
@@ -40,10 +40,9 @@
<tr>
<th>{smartlink ititle="Reference" isort="title"}</th>
<th>{tr}Type{/tr}</th>
- <th>{tr}Ref{/tr}</th>
{if $componentContentId}<th class="text-right">{tr}Qty{/tr}</th>{/if}
- <th>{tr}Ordered{/tr}</th>
- <th>{smartlink ititle="Received" isort="event_time_desc" ifile="list_movements.php" ipackage="stock"}</th>
+ <th>{smartlink ititle="Ordered" isort="ref_start_date" ifile="list_movements.php" ipackage="stock"}</th>
+ <th>{smartlink ititle="Received" isort="event_time" ifile="list_movements.php" ipackage="stock"}</th>
<th>{smartlink ititle="Date" isort="created_desc"}</th>
<th>{tr}Creator{/tr}</th>
{if $gBitUser->hasPermission('p_stock_create')}<th></th>{/if}
@@ -54,7 +53,6 @@
<tr>
<td><a href="{$mov.display_url|escape}">{$mov.title|escape}</a></td>
<td>{$mov.ref_type|escape|default:'—'}</td>
- <td>{$mov.ref_key|escape}</td>
{if $componentContentId}
<td class="text-right">{$mov.cmp_qty|string_format:"%.0f"} {$mov.cmp_qty_type|escape}</td>
{/if}
@@ -70,7 +68,7 @@
{/if}
</tr>
{foreachelse}
- <tr><td colspan="8" class="norecords">{tr}No movements found.{/tr}</td></tr>
+ <tr><td colspan="7" class="norecords">{tr}No movements found.{/tr}</td></tr>
{/foreach}
</tbody>
</table>