From 9a49e18e278993f998f1e826c7af5ab08be81874 Mon Sep 17 00:00:00 2001 From: fs Date: Wed, 15 Apr 2026 21:29:36 +0200 Subject: [PATCH] feat(helpdesk): redesign handover edit page sidebar - JOIN users table in findById for created/updated-by display names - Fix row mapping to handle merged JOIN results - Use product name instead of debitor name in page title - Sidebar: collapsible customer/product sections, status dropdown, audit partial with user attribution Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Repository/HandoverRepository.php | 22 +++++- .../pages/helpdesk/handovers/edit($id).php | 8 +- .../helpdesk/handovers/edit(default).phtml | 76 ++++++++++++------- 3 files changed, 73 insertions(+), 33 deletions(-) diff --git a/modules/helpdesk/lib/Module/Helpdesk/Repository/HandoverRepository.php b/modules/helpdesk/lib/Module/Helpdesk/Repository/HandoverRepository.php index 2543423..c704e28 100644 --- a/modules/helpdesk/lib/Module/Helpdesk/Repository/HandoverRepository.php +++ b/modules/helpdesk/lib/Module/Helpdesk/Repository/HandoverRepository.php @@ -41,7 +41,13 @@ class HandoverRepository } $row = DB::selectOne( - 'SELECT * FROM helpdesk_handovers WHERE id = ? AND tenant_id = ? LIMIT 1', + 'SELECT h.*,' + . ' uc.display_name AS created_by_label, uc.uuid AS created_by_uuid,' + . ' uu.display_name AS updated_by_label, uu.uuid AS updated_by_uuid' + . ' FROM helpdesk_handovers h' + . ' LEFT JOIN users uc ON uc.id = h.created_by' + . ' LEFT JOIN users uu ON uu.id = h.updated_by' + . ' WHERE h.id = ? AND h.tenant_id = ? LIMIT 1', (string) $id, (string) $tenantId ); @@ -140,8 +146,18 @@ class HandoverRepository if (!is_array($row)) { return null; } - $item = $row['helpdesk_handovers'] ?? $row; - if (!is_array($item) || !isset($item['id'])) { + + // JOIN queries return nested arrays keyed by table name — merge all sub-arrays + $item = []; + foreach ($row as $key => $value) { + if (is_array($value)) { + $item = array_merge($item, $value); + } else { + $item[$key] = $value; + } + } + + if (!isset($item['id'])) { return null; } diff --git a/modules/helpdesk/pages/helpdesk/handovers/edit($id).php b/modules/helpdesk/pages/helpdesk/handovers/edit($id).php index 9b7b8ad..2fdce52 100644 --- a/modules/helpdesk/pages/helpdesk/handovers/edit($id).php +++ b/modules/helpdesk/pages/helpdesk/handovers/edit($id).php @@ -111,8 +111,12 @@ if ($request->isMethod('POST') && $canEdit) { $validationSummaryErrors = $errorBag->toArray(); $errors = $errorBag->toFlatList(); -$displayName = trim((string) ($handover['debitor_name'] ?? '')); -$titleText = $displayName !== '' ? $displayName : (t('Handover') . ' #' . $handoverId); +$productCode = (string) ($handover['product_code'] ?? ''); +$product = app(\MintyPHP\Module\Helpdesk\Service\SoftwareProductService::class)->findByCode($productCode); +$productName = trim((string) ($product['name'] ?? '')) !== '' + ? $product['name'] + : (trim((string) ($product['bc_description'] ?? '')) !== '' ? $product['bc_description'] : $productCode); +$titleText = t('Handover') . ' ' . $productName; Buffer::set('title', $titleText); Buffer::set('style_groups', json_encode(['helpdesk'])); $breadcrumbs = [ diff --git a/modules/helpdesk/pages/helpdesk/handovers/edit(default).phtml b/modules/helpdesk/pages/helpdesk/handovers/edit(default).phtml index 7cf7dc2..5cabd7a 100644 --- a/modules/helpdesk/pages/helpdesk/handovers/edit(default).phtml +++ b/modules/helpdesk/pages/helpdesk/handovers/edit(default).phtml @@ -58,10 +58,6 @@ $readonly = !$canEdit; - 1): ?> - - - @@ -80,8 +76,8 @@ $readonly = !$canEdit;