diff --git a/application/YoshiKan/Application/Command/Import/FixEmail/FixEmailHandler.php b/application/YoshiKan/Application/Command/Import/FixEmail/FixEmailHandler.php
new file mode 100644
index 0000000..dc1301c
--- /dev/null
+++ b/application/YoshiKan/Application/Command/Import/FixEmail/FixEmailHandler.php
@@ -0,0 +1,85 @@
+subscriptionRepository->getAll();
+
+ /** @var Subscription $subscription */
+ foreach ($allSubscriptions as $subscription) {
+ $filteredEmail = str_replace(' ', '', $subscription->getContactEmail());
+ $filteredEmail = str_replace(';', '.', $filteredEmail);
+ $filteredEmail = str_replace('?', '.', $filteredEmail);
+ $filteredEmail = str_replace('²', '@', $filteredEmail);
+ $filteredEmail = strtolower($filteredEmail);
+
+ $subscription->setContactEmail($filteredEmail);
+ $this->subscriptionRepository->save($subscription);
+ $this->entityManager->flush();
+
+ echo '
'.$subscription->getContactFirstname().' '.$subscription->getContactLastname().' -> '.$subscription->getContactEmail();
+ ob_flush();
+ flush();
+ }
+
+ return true;
+ }
+
+ public function fixMembers(): bool
+ {
+ $allMembers = $this->memberRepository->getAll();
+
+ foreach ($allMembers as $member) {
+ $filteredEmail = str_replace(' ', '', $member->getContactEmail());
+ $filteredEmail = str_replace(';', '.', $filteredEmail);
+ $filteredEmail = str_replace('?', '.', $filteredEmail);
+ $filteredEmail = str_replace('²', '@', $filteredEmail);
+ $filteredEmail = strtolower($filteredEmail);
+
+ if ('' === $filteredEmail) {
+ $filteredEmail = 'judo.yoshikan@gmail.com';
+ }
+
+ $member->setContactInformation(
+ contactFirstname: $member->getContactFirstname(),
+ contactLastname: $member->getContactLastname(),
+ contactEmail: $filteredEmail,
+ contactPhone: $member->getContactPhone()
+ );
+ $this->memberRepository->save($member);
+ $this->entityManager->flush();
+
+ echo '
'.$member->getFirstname().' '.$member->getLastname().' -> '.$member->getContactEmail();
+ ob_flush();
+ flush();
+ }
+
+ return true;
+ }
+}
diff --git a/application/YoshiKan/Application/Command/Import/ImportActiveMember/ImportActiveMembersHandler.php b/application/YoshiKan/Application/Command/Import/ImportActiveMember/ImportActiveMembersHandler.php
index 62cd3c7..65d1462 100644
--- a/application/YoshiKan/Application/Command/Import/ImportActiveMember/ImportActiveMembersHandler.php
+++ b/application/YoshiKan/Application/Command/Import/ImportActiveMember/ImportActiveMembersHandler.php
@@ -66,17 +66,22 @@ public function import(): bool
$dto = new \stdClass();
$dto->firstName = (string) $worksheet->getCellByColumnAndRow(2, $row)->getValue();
- $dto->lastName = mb_strtoupper($worksheet->getCellByColumnAndRow(1, $row)->getValue());
+ $dto->lastName = mb_strtoupper((string) $worksheet->getCellByColumnAndRow(1, $row)->getValue());
$dto->dateOfBirth = Date::excelToDateTimeObject($worksheet->getCellByColumnAndRow(4, $row)->getValue())->format(\DateTimeInterface::ATOM);
$dto->nationalNumber = (string) $worksheet->getCellByColumnAndRow(5, $row)->getValue();
$dto->street = (string) $worksheet->getCellByColumnAndRow(3, $row)->getValue();
- $dto->city = $worksheet->getCellByColumnAndRow(6, $row)->getValue();
+ $dto->city = (string) $worksheet->getCellByColumnAndRow(6, $row)->getValue();
$dto->postalCode = (string) $worksheet->getCellByColumnAndRow(7, $row)->getValue();
$dto->contactPhone = (string) $worksheet->getCellByColumnAndRow(8, $row)->getValue();
- $dto->contactEmail = (string) $worksheet->getCellByColumnAndRow(9, $row)->getValue();
+
+ $contactEmail = 'judo.yoshikan@gmail.com';
+ if ('' !== (string) $worksheet->getCellByColumnAndRow(9, $row)->getValue()) {
+ $contactEmail = (string) $worksheet->getCellByColumnAndRow(9, $row)->getValue();
+ }
+ $dto->contactEmail = $contactEmail;
$dto->gender = Gender::X;
- $dto->location = $this->locationRepository->getById(LocationMapping::getLocationId($worksheet->getCellByColumnAndRow(26, $row)->getValue()));
- $dto->grade = $this->gradeRepository->getById(GradeMapping::getGradeId($worksheet->getCellByColumnAndRow(25, $row)->getValue()));
+ $dto->location = $this->locationRepository->getById(LocationMapping::getLocationId((string) $worksheet->getCellByColumnAndRow(26, $row)->getValue()));
+ $dto->grade = $this->gradeRepository->getById(GradeMapping::getGradeId((string) $worksheet->getCellByColumnAndRow(25, $row)->getValue()));
$dto->sporta = (bool) $worksheet->getCellByColumnAndRow(23, $row)->getValue();
$dto->jv = (bool) $worksheet->getCellByColumnAndRow(24, $row)->getValue();
if ($dto->sporta) {
diff --git a/application/YoshiKan/Domain/Model/Member/MemberRepository.php b/application/YoshiKan/Domain/Model/Member/MemberRepository.php
index bca7f85..4895773 100644
--- a/application/YoshiKan/Domain/Model/Member/MemberRepository.php
+++ b/application/YoshiKan/Domain/Model/Member/MemberRepository.php
@@ -61,4 +61,9 @@ public function getActiveMembersByFederationAndLocation(Federation $federation,
* @return Member[]
*/
public function getActiveMembersByLocation(Location $location): array;
+
+ /**
+ * @return Member[]
+ */
+ public function getAll(): array;
}
diff --git a/application/YoshiKan/Domain/Model/Member/Subscription.php b/application/YoshiKan/Domain/Model/Member/Subscription.php
index bfeda15..04b934f 100644
--- a/application/YoshiKan/Domain/Model/Member/Subscription.php
+++ b/application/YoshiKan/Domain/Model/Member/Subscription.php
@@ -396,6 +396,11 @@ public function setNewMemberFields(
$this->addressCity = $addressCity;
}
+ public function setContactEmail(string $contactEmail): void
+ {
+ $this->contactEmail = $contactEmail;
+ }
+
public function fullChange(
string $contactFirstname,
string $contactLastname,
diff --git a/application/YoshiKan/Infrastructure/Database/Member/MemberRepository.php b/application/YoshiKan/Infrastructure/Database/Member/MemberRepository.php
index af5d418..3ed399c 100644
--- a/application/YoshiKan/Infrastructure/Database/Member/MemberRepository.php
+++ b/application/YoshiKan/Infrastructure/Database/Member/MemberRepository.php
@@ -214,4 +214,15 @@ public function getActiveMembersByLocation(Location $location): array
return $q->getQuery()->getResult();
}
+
+ /**
+ * @return Member[]
+ */
+ public function getAll(): array
+ {
+ $q = $this->createQueryBuilder('t')->andWhere('0 = 0');
+ $q->addOrderBy('t.id', 'DESC');
+
+ return $q->getQuery()->getResult();
+ }
}
diff --git a/application/YoshiKan/Infrastructure/Templates/pdf/subscription_detail.html.twig b/application/YoshiKan/Infrastructure/Templates/pdf/subscription_detail.html.twig
index 3150dce..102043b 100644
--- a/application/YoshiKan/Infrastructure/Templates/pdf/subscription_detail.html.twig
+++ b/application/YoshiKan/Infrastructure/Templates/pdf/subscription_detail.html.twig
@@ -70,7 +70,8 @@