diff --git a/backend/api/registrations/export.php b/backend/api/registrations/export.php new file mode 100644 index 0000000..529d1ac --- /dev/null +++ b/backend/api/registrations/export.php @@ -0,0 +1,43 @@ +num_rows !== 0) { + while ($row = mysqli_fetch_object($result)) { + $reference = "LD" . substr(strtoupper(umlaute_as_e($row->firstname)),0,1) . strtoupper(umlaute_as_e($row->lastname)); + $price = getRegistrationPrice($row->birthday); + $address = $row->street . ' ' . $row->house . ';' . $row->zip . ' ' . $row->city; + $gender = $row->gender == 0 ? 'm' : ($row->gender == 1 ? 'w' : 'd'); + $formattedRegistrationFrom = (new DateTime($row->registrationfrom))->format('d.m.Y'); + $formattedBirthday = (new DateTime($row->birthday))->format('d.m.Y'); + $export .= "{$row->lastname};{$row->firstname};{$row->iban};;{$row->bic};;{$row->bank};{$row->accountholder};{$reference};1;\t{$formattedRegistrationFrom};{$price}; ; ;\t{$row->phone};{$row->email};{$address};\t{$formattedBirthday};{$gender}\n"; + } + } + + mysqli_free_result($result); + + header('Content-Type: charset=utf-8'); + header('Content-Disposition: attachment; filename="li-dance-export.csv";'); + echo chr(239) . chr(187) . chr(191) . mb_convert_encoding($export, 'UTF-8', mb_list_encodings()); +?> \ No newline at end of file diff --git a/backend/utils/tools.php b/backend/utils/tools.php index b557fae..5b20ef2 100644 --- a/backend/utils/tools.php +++ b/backend/utils/tools.php @@ -11,6 +11,17 @@ function umlaute($string) { return $string; } +function umlaute_as_e($string) { + $string = str_replace("ä", "ae", $string); + $string = str_replace("ü", "ue", $string); + $string = str_replace("ö", "oe", $string); + $string = str_replace("Ä", "Ae", $string); + $string = str_replace("Ü", "Ue", $string); + $string = str_replace("Ö", "Oe", $string); + + return $string; +} + function gender($num) { switch ($num) { diff --git a/frontend/src/app/components/registrations/registration-list/registration-list.component.html b/frontend/src/app/components/registrations/registration-list/registration-list.component.html index 2f9d2e2..3d4940b 100644 --- a/frontend/src/app/components/registrations/registration-list/registration-list.component.html +++ b/frontend/src/app/components/registrations/registration-list/registration-list.component.html @@ -33,7 +33,10 @@ - delete + + delete + login +