Files
awo-hamburg-intranet/module/tasks/service/ApprovalService.php
Moritz Weinmann 743476f64a Module tasks + knowledgecenter_update aus Kundenprojekt übernehmen (bereinigt)
Beide Module wurden aus einem anderen Kundenprojekt kopiert und bereinigt:

Knowledgecenter:
- Bild-Cache (1.985 Dateien) geleert, Ordnerstruktur mit .gitkeep behalten
- Files-Gallery-Lizenzschlüssel entfernt (config.php)
- Kundenspezifische Kategorien gelöscht: Teil I/II/III QM-Struktur,
  nummerierte QM-Kapitel, Gremien (Präsidium/Finanzausschuss/Landesausschuss),
  Sitzungsservice-Serie, Protokoll-Abteilungen, Testeinträge
- 56 generische Kategorien bleiben (Downloads, Onboarding, Personalthemen …)

Tasks:
- Alle Betriebsdaten gelöscht (114 Tasks, 914 Submissions, 579 Assignments)
- Task-Definitionen und Verlinkungen geleert
- Kategoriestruktur bleibt (Allgemein, IT, Personal, Buchhaltung …)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 09:20:02 +02:00

65 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
class ApprovalService
{
private TaskSubmissionRepository $submissionRepo;
private TaskAssignmentRepository $assignmentRepo;
private CompletionService $completionService;
public function __construct(
TaskSubmissionRepository $submissionRepo,
TaskAssignmentRepository $assignmentRepo,
CompletionService $completionService
) {
$this->submissionRepo = $submissionRepo;
$this->assignmentRepo = $assignmentRepo;
$this->completionService = $completionService;
}
public function approveSubmission(int $submissionId, int $adminContactId, string $note): void
{
$submission = $this->submissionRepo->findById($submissionId);
if ($submission === null) {
throw new RuntimeException('Submission nicht gefunden');
}
if ((string) $submission['status'] !== 'awaiting_approval') {
throw new RuntimeException('Submission ist nicht im Status awaiting_approval');
}
TaskCertDb::beginTransaction();
try {
$this->submissionRepo->review($submissionId, 'approved', $adminContactId, $note);
TaskCertDb::commit();
} catch (Throwable $throwable) {
TaskCertDb::rollback();
throw $throwable;
}
$this->completionService->refreshAssignmentAfterReview((int) $submission['assignment_id'], $submissionId);
}
public function rejectSubmission(int $submissionId, int $adminContactId, string $note): void
{
$submission = $this->submissionRepo->findById($submissionId);
if ($submission === null) {
throw new RuntimeException('Submission nicht gefunden');
}
if ((string) $submission['status'] !== 'awaiting_approval') {
throw new RuntimeException('Submission ist nicht im Status awaiting_approval');
}
TaskCertDb::beginTransaction();
try {
$this->submissionRepo->review($submissionId, 'rejected', $adminContactId, $note);
$this->assignmentRepo->updateStatus((int) $submission['assignment_id'], 'rejected', null);
TaskCertDb::commit();
} catch (Throwable $throwable) {
TaskCertDb::rollback();
throw $throwable;
}
}
}