diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-01 12:57:52 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-01 12:57:52 +0100 |
| commit | db935105f8dbc8582cbe4dbfb4961a836af0eb64 (patch) | |
| tree | 37a1acd7670b33c225fe6eb3935e0ac501b77266 /list_stock.php | |
| parent | dfe7e1cbea1e8503281218567e95bae819dc5dce (diff) | |
| download | stock-db935105f8dbc8582cbe4dbfb4961a836af0eb64.tar.gz stock-db935105f8dbc8582cbe4dbfb4961a836af0eb64.tar.bz2 stock-db935105f8dbc8582cbe4dbfb4961a836af0eb64.zip | |
list_stock: BOM section headers, xorder sort, drop table-striped
- Fetch MIN(bom.xorder) per row; order by it when assembly filter active
- Compute bom_group = floor(xorder/1000) in PHP, pass to template
- Template shows group header rows (matching component_order.tpl convention)
- Remove table-striped — clashes with danger row highlighting
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'list_stock.php')
| -rw-r--r-- | list_stock.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/list_stock.php b/list_stock.php index d55df91..69f1f9e 100644 --- a/list_stock.php +++ b/list_stock.php @@ -38,11 +38,13 @@ if( $find !== '' ) { $bindVars[] = '%'.strtoupper( $find ).'%'; } -$bomQtySelect = $assemblyContentId - ? ", MAX(CAST(bom.`xkey` AS DOUBLE PRECISION)) AS bom_qty" - : ", CAST(NULL AS DOUBLE PRECISION) AS bom_qty"; +$bomQtySelect = $assemblyContentId + ? ", MAX(CAST(bom.`xkey` AS DOUBLE PRECISION)) AS bom_qty, MIN(bom.`xorder`) AS bom_xorder" + : ", CAST(NULL AS DOUBLE PRECISION) AS bom_qty, CAST(NULL AS INTEGER) AS bom_xorder"; -$bomQtyGroup = $assemblyContentId ? "" : ""; +$orderBy = $assemblyContentId + ? "ORDER BY MIN(bom.`xorder`), x.`item`" + : "ORDER BY lc.`title`, x.`item`"; // Stock level per component per qty type, signed by movement direction $query = "SELECT lc.`content_id`, lc.`title`, lc.`data`, @@ -67,7 +69,7 @@ $query = "SELECT lc.`content_id`, lc.`title`, lc.`data`, WHERE lc.`content_type_guid` = 'stockcomponent' $whereSql GROUP BY lc.`content_id`, lc.`title`, lc.`data`, x.`item` - ORDER BY lc.`title`, x.`item`"; + $orderBy"; $rows = $gBitDb->query( $query, $bindVars ); @@ -76,12 +78,14 @@ $stockList = []; foreach( $rows as $row ) { $cid = $row['content_id']; if( !isset( $stockList[$cid] ) ) { + $bomXorder = $row['bom_xorder'] !== null ? (int)$row['bom_xorder'] : null; $stockList[$cid] = [ 'content_id' => $cid, 'title' => $row['title'], 'data' => $row['data'], 'part_number' => $row['part_number'], 'display_url' => STOCK_PKG_URL.'view_component.php?content_id='.$cid, + 'bom_group' => $bomXorder !== null ? (int)floor( $bomXorder / 1000 ) : null, 'stock' => [], ]; } |
