diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-27 20:20:04 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-27 20:20:04 +0100 |
| commit | db468dcfc4cbd961d422a66283d1832dd1c01b71 (patch) | |
| tree | 2347dc221bcb3005b3778ed4c4be12d832abe12d /includes | |
| parent | a848cd4505432151802a4d956fc72e79fcd8e9f2 (diff) | |
| download | stock-db468dcfc4cbd961d422a66283d1832dd1c01b71.tar.gz stock-db468dcfc4cbd961d422a66283d1832dd1c01b71.tar.bz2 stock-db468dcfc4cbd961d422a66283d1832dd1c01b71.zip | |
Add component management to assembly edit; edit button on view
edit.php: add/remove/CSV-upload handlers for stock_assembly_component_map;
lock non-editors out via existing verifyUpdatePermission.
StockAssembly: add getComponentMapList() for lightweight flat component data.
edit_assembly.tpl: components section with sortable table, single-add form,
and CSV bulk upload (mirrors movement edit pattern).
view_assembly.tpl: edit button for p_stock_update users; pass allow_edit=false
to xref tabs so edit/delete buttons are suppressed on view page.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/classes/StockAssembly.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/includes/classes/StockAssembly.php b/includes/classes/StockAssembly.php index f0cd5f3..3d11e64 100755 --- a/includes/classes/StockAssembly.php +++ b/includes/classes/StockAssembly.php @@ -495,6 +495,31 @@ class StockAssembly extends StockBase { return count($this->mErrors) == 0; } + public function getComponentMapList( string $pSortMode = 'item_position_asc' ): array { + $ret = []; + if( $this->verifyId( $this->mContentId ) ) { + $orderby = match( $pSortMode ) { + 'title_asc' => 'lc.`title` ASC', + 'title_desc' => 'lc.`title` DESC', + 'item_position_desc' => 'fgim.`item_position` DESC, fgim.`item_content_id` DESC', + default => 'fgim.`item_position` ASC, fgim.`item_content_id` ASC', + }; + if( $rows = $this->mDb->query( + "SELECT fgim.`item_content_id`, fgim.`item_position`, lc.`title` + FROM `".BIT_DB_PREFIX."stock_assembly_component_map` fgim + INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = fgim.`item_content_id`) + WHERE fgim.`assembly_content_id` = ? + ORDER BY $orderby", + [ $this->mContentId ] + ) ) { + foreach( $rows as $row ) { + $ret[$row['item_content_id']] = $row; + } + } + } + return $ret; + } + public function removeItem( $pContentId ) { $ret = false; if( $this->isValid() && @$this->verifyId( $pContentId ) ) { |
