From db468dcfc4cbd961d422a66283d1832dd1c01b71 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Wed, 27 May 2026 20:20:04 +0100 Subject: 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 --- includes/classes/StockAssembly.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'includes') 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 ) ) { -- cgit v1.3