diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-02 18:42:47 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-02 18:42:47 +0100 |
| commit | 390f1533a283a584048ecc2a17a110d818af69ea (patch) | |
| tree | 519ad46fdb326baabda589cc51356fe1e3e87aad /includes | |
| parent | ce688ca66d15bd445c8ff0da099e5ec4eb22230f (diff) | |
| download | stock-390f1533a283a584048ecc2a17a110d818af69ea.tar.gz stock-390f1533a283a584048ecc2a17a110d818af69ea.tar.bz2 stock-390f1533a283a584048ecc2a17a110d818af69ea.zip | |
Component movement history: filter list_movements by component_content_id
StockMovement::getList() joins xcmp when component_content_id is set,
adding cmp_qty/cmp_qty_type columns per row.
list_movements.php looks up component title; template shows it in the
header, adds a Qty column, and provides a back link.
view_component Stock tab now links to filtered movement list.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/classes/StockMovement.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php index ebcbf4e..9118ccd 100644 --- a/includes/classes/StockMovement.php +++ b/includes/classes/StockMovement.php @@ -222,6 +222,11 @@ class StockMovement extends LibertyContent { $joinSql .= " INNER JOIN `".BIT_DB_PREFIX."liberty_xref` xasm ON xasm.`content_id` = lc.`content_id` AND xasm.`item` = 'ASSEMBLY' AND xasm.`xref` = ?"; $bindVars[] = (int)$pListHash['assembly_content_id']; } + if( $this->verifyId( $pListHash['component_content_id'] ?? 0 ) ) { + $joinSql .= " INNER JOIN `".BIT_DB_PREFIX."liberty_xref` xcmp ON xcmp.`content_id` = lc.`content_id` + AND xcmp.`item` IN ('SGL','PCK','SHT','VOL') AND xcmp.`xref` = ?"; + $bindVars[] = (int)$pListHash['component_content_id']; + } if( $this->verifyId( $pListHash['user_id'] ?? 0 ) ) { $whereSql .= " AND lc.`user_id` = ?"; $bindVars[] = (int)$pListHash['user_id']; @@ -242,6 +247,10 @@ class StockMovement extends LibertyContent { } $X = BIT_DB_PREFIX; + $cmpQtySelect = $this->verifyId( $pListHash['component_content_id'] ?? 0 ) + ? ", xcmp.`item` AS cmp_qty_type, CAST(xcmp.`xkey` AS DOUBLE PRECISION) AS cmp_qty" + : ", CAST(NULL AS VARCHAR(4)) AS cmp_qty_type, CAST(NULL AS DOUBLE PRECISION) AS cmp_qty"; + $query = "SELECT lc.`content_id`, lc.`title`, lc.`created`, lc.`last_modified`, lc.`event_time`, uu.`login`, uu.`real_name`, (SELECT FIRST 1 x.`item` FROM `{$X}liberty_xref` x @@ -250,6 +259,7 @@ class StockMovement extends LibertyContent { (SELECT FIRST 1 x.`xkey` 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_key + $cmpQtySelect $selectSql FROM `{$X}liberty_content` lc INNER JOIN `{$X}users_users` uu ON uu.`user_id` = lc.`user_id` |
