Skip to content

Commit

Permalink
fixed adding contingent to patrol and troop participants
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Nov 27, 2024
1 parent 5e6b46a commit f0c3148
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/Export/ExportService.php
Original file line number Diff line number Diff line change
@@ -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 ?? '');
}
}

0 comments on commit f0c3148

Please sign in to comment.