fix(helpdesk): always load tenant users, not only when schema has user-select

Schema snapshot on existing handovers may predate the field type change,
so the conditional check was false and tenantUsers was empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
aminovfariz
2026-06-08 11:57:02 +02:00
parent 40b94fa891
commit e3dfdef76f
2 changed files with 20 additions and 28 deletions

View File

@@ -230,10 +230,7 @@ if ($step === $protocolStep) {
? $product['name']
: (string) ($product['bc_description'] ?? $wizardData['product_code']);
// Load tenant users for user-select schema fields
$hasUserSelectField = !empty(array_filter($schemaFields, fn($f) => ($f['type'] ?? '') === 'user-select'));
$tenantUsers = [];
if ($hasUserSelectField) {
// Load tenant users — always available for user-select schema fields
$rows = DB::select(
'SELECT u.id, u.display_name, u.email'
. ' FROM users u'
@@ -243,7 +240,6 @@ if ($step === $protocolStep) {
(string) $currentTenantId
);
$tenantUsers = is_array($rows) ? $rows : [];
}
if ($request->isMethod('POST')) {
if (!Session::checkCsrfToken()) {

View File

@@ -205,20 +205,16 @@ if ($request->isMethod('POST') && $canEdit) {
$validationSummaryErrors = $errorBag->toArray();
$errors = $errorBag->toFlatList();
// Load tenant users for user-select schema fields
$hasUserSelectField = !empty(array_filter($schemaFields, fn($f) => ($f['type'] ?? '') === 'user-select'));
$tenantUsers = [];
if ($hasUserSelectField) {
$rows = DB::select(
// Load tenant users — always available for user-select schema fields
$rows = DB::select(
'SELECT u.id, u.display_name, u.email'
. ' FROM users u'
. ' JOIN user_tenants ut ON ut.user_id = u.id'
. ' WHERE ut.tenant_id = ? AND u.active = 1'
. ' ORDER BY u.display_name ASC',
(string) $tenantId
);
$tenantUsers = is_array($rows) ? $rows : [];
}
);
$tenantUsers = is_array($rows) ? $rows : [];
// Load revision data
$revisions = $revisionService->listByHandover($tenantId, $handoverId);