1
0

feat(helpdesk): Übergabe assignment workflow

- New statuses: under_review
- New DB fields: assigned_to, assigned_by, assigned_at, due_date (migration 012)
- HandoverNotificationService: emails on assign and review-request
- HandoverService: assign(), submitForReview(), resendNotification()
- Assign page: manager selects employee + due date, resend notification
- Create wizard: manager can assign during creation (step 1)
- Edit page: "Submit for review" button for assignee, assign link for manager
- List page: open/closed tabs, non-managers see only their assigned handovers
- Email templates: handover_assigned + handover_review_requested (de/en)
- i18n keys added for de and en

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
aminovfariz
2026-06-01 14:35:03 +02:00
parent 4f38911fce
commit c32a0f8c31
26 changed files with 918 additions and 10 deletions

View File

@@ -45,10 +45,14 @@ class HandoverRepository
$row = DB::selectOne(
'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'
. ' uu.display_name AS updated_by_label, uu.uuid AS updated_by_uuid,'
. ' ua.display_name AS assigned_to_label, ua.uuid AS assigned_to_uuid, ua.email AS assigned_to_email,'
. ' ub.display_name AS assigned_by_label, ub.uuid AS assigned_by_uuid, ub.email AS assigned_by_email'
. ' FROM helpdesk_handovers h'
. ' LEFT JOIN users uc ON uc.id = h.created_by'
. ' LEFT JOIN users uu ON uu.id = h.updated_by'
. ' LEFT JOIN users ua ON ua.id = h.assigned_to'
. ' LEFT JOIN users ub ON ub.id = h.assigned_by'
. ' WHERE h.id = ? AND h.tenant_id = ? LIMIT 1',
(string) $id,
(string) $tenantId
@@ -66,11 +70,13 @@ class HandoverRepository
$search = trim((string) ($filters['search'] ?? ''));
$status = trim((string) ($filters['status'] ?? ''));
$productCode = trim((string) ($filters['product_code'] ?? ''));
$assignedTo = (int) ($filters['assigned_to'] ?? 0);
$view = trim((string) ($filters['view'] ?? ''));
[$limit, $offset] = RepoQuery::sanitizeLimitOffset($filters, 20, 1, 100, 0);
[$order, $dir] = RepoQuery::sanitizeOrder(
$filters,
['id', 'domain_url', 'debitor_name', 'product_code', 'status', 'created_at', 'created_by'],
['id', 'domain_url', 'debitor_name', 'product_code', 'status', 'created_at', 'created_by', 'assigned_at', 'due_date'],
'created_at',
'desc'
);
@@ -83,6 +89,10 @@ class HandoverRepository
if ($status !== '' && $status !== 'all') {
$where[] = 'h.status = ?';
$params[] = $status;
} elseif ($view === 'open') {
$where[] = "h.status NOT IN ('completed', 'archived')";
} elseif ($view === 'closed') {
$where[] = "h.status IN ('completed', 'archived')";
}
if ($productCode !== '') {
@@ -90,14 +100,21 @@ class HandoverRepository
$params[] = $productCode;
}
if ($assignedTo > 0) {
$where[] = 'h.assigned_to = ?';
$params[] = (string) $assignedTo;
}
$whereSql = ' WHERE ' . implode(' AND ', $where);
$total = (int) (DB::selectValue('SELECT COUNT(*) FROM helpdesk_handovers h' . $whereSql, ...$params) ?? 0);
$rows = DB::select(
'SELECT h.*, u.display_name AS created_by_name,'
. ' ua.display_name AS assigned_to_name,'
. ' sp.name AS product_name, sp.bc_description AS product_bc_description'
. ' FROM helpdesk_handovers h'
. ' LEFT JOIN users u ON u.id = h.created_by'
. ' LEFT JOIN users ua ON ua.id = h.assigned_to'
. ' LEFT JOIN helpdesk_software_products sp ON sp.code = h.product_code'
. $whereSql
. sprintf(' ORDER BY h.`%s` %s LIMIT ? OFFSET ?', $order, $dir),
@@ -146,6 +163,23 @@ class HandoverRepository
return $result !== false;
}
public function assign(int $tenantId, int $id, int $assignedTo, int $assignedBy, ?string $dueDate, int $updatedBy): bool
{
$result = DB::update(
'UPDATE helpdesk_handovers'
. ' SET assigned_to = ?, assigned_by = ?, assigned_at = NOW(), due_date = ?, updated_by = ?'
. ' WHERE id = ? AND tenant_id = ?',
(string) $assignedTo,
(string) $assignedBy,
($dueDate !== null && $dueDate !== '') ? $dueDate : null,
(string) $updatedBy,
(string) $id,
(string) $tenantId
);
return $result !== false;
}
/**
* @param list<int> $ids
*/