From f0c31481332ad098a2adec08a9055c54fc3bd807 Mon Sep 17 00:00:00 2001 From: Lung Date: Wed, 27 Nov 2024 16:53:17 +0100 Subject: [PATCH] fixed adding contingent to patrol and troop participants --- src/Export/ExportService.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Export/ExportService.php b/src/Export/ExportService.php index 4acc92c3..b53484c2 100755 --- a/src/Export/ExportService.php +++ b/src/Export/ExportService.php @@ -7,6 +7,7 @@ use kissj\Event\Event; use kissj\Orm\Order; use kissj\Participant\Ist\Ist; +use kissj\Participant\Participant; use kissj\Participant\ParticipantRepository; use kissj\Participant\ParticipantRole; use kissj\Participant\Patrol\PatrolLeader; @@ -66,7 +67,7 @@ public function healthDataToCSV(Event $event, User $adminUser): array (string)$participant->id, // 0 $participant->role?->value ?? '', $participant->user?->status->value ?? '', - $this->translator->trans($participant->contingent ?? ''), + $this->getContingentTranslated($participant), $participant->firstName ?? '', $participant->lastName ?? '', // 5 $participant->gender ?? '', @@ -124,7 +125,7 @@ public function paidContactDataToCSV(Event $event, User $adminUser): array $participant instanceof TroopLeader => (string)$participant->getTroopParticipantsCount(), default => '', }, - $this->translator->trans($participant->contingent ?? ''), + $this->getContingentTranslated($participant), $participant->nickname ?? '', $participant->firstName ?? '', // 5 $participant->lastName ?? '', @@ -252,7 +253,7 @@ public function allRegistrationDataToCSV(Event $event, User $adminUser): array $participant->user?->event->readableName ?? '', $participant->role?->value ?? '', $participant->user?->status->value ?? '', - $this->translator->trans($participant->contingent ?? ''), + $this->getContingentTranslated($participant), $participant->firstName ?? '', // 5 $participant->lastName ?? '', $participant->nickname ?? '', @@ -273,7 +274,7 @@ public function allRegistrationDataToCSV(Event $event, User $adminUser): array $participant->foodPreferences ?? '', $participant->idNumber ?? '', $participant->scarf ?? '', - $this->translator->trans($participant->swimming ?? ''), //25 + $this->translator->trans($participant->swimming ?? ''), // 25 $this->translator->trans($participant->getTshirtSize() ?? '') . ' - ' . $this->translator->trans($participant->getTshirtShape() ?? ''), $participant->arrivalDate !== null ? $participant->arrivalDate->format('d. m. Y') : '', @@ -294,4 +295,18 @@ public function allRegistrationDataToCSV(Event $event, User $adminUser): array return $rows; } + + public function getContingentTranslated(Participant $participant): string + { + $contingent = $participant->contingent; + if ($contingent === null) { + if ($participant instanceof PatrolParticipant) { + $contingent = $participant->patrolLeader->contingent; + } elseif ($participant instanceof TroopParticipant) { + $contingent = $participant->troopLeader?->contingent; + } + } + + return $this->translator->trans($contingent ?? ''); + } }