From 4bba68fc6d15549511d621ee55589513810b72d7 Mon Sep 17 00:00:00 2001 From: Artur Savitskiy Date: Mon, 2 Sep 2024 01:37:42 +0200 Subject: [PATCH] Add single course and breakdance to registration for other pricing --- backend/api/registrations/export.php | 43 ---------------- backend/api/registrations/set.php | 11 +++-- backend/course.php | 4 +- backend/libs/registration/registration.php | 49 +++++++++++++++---- .../registration-wizard.component.html | 8 +++ .../registration-wizard.component.scss | 5 ++ .../registration-wizard.component.ts | 36 ++++++++++---- .../src/app/models/student-registration.ts | 1 + .../registrations/registrations.service.ts | 1 + 9 files changed, 90 insertions(+), 68 deletions(-) delete mode 100644 backend/api/registrations/export.php diff --git a/backend/api/registrations/export.php b/backend/api/registrations/export.php deleted file mode 100644 index 529d1ac..0000000 --- a/backend/api/registrations/export.php +++ /dev/null @@ -1,43 +0,0 @@ -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/api/registrations/set.php b/backend/api/registrations/set.php index 62d3e94..84fbec4 100644 --- a/backend/api/registrations/set.php +++ b/backend/api/registrations/set.php @@ -46,6 +46,8 @@ $iban = escape($connection, $_POST["iban"]); $bic = escape($connection, $_POST["bic"]); $bank = escape($connection, $_POST["bank"]); + + $contracttype = intval($_POST["contractType"]); $applicationconsent = $_POST["applicationConsent"] === "true"; $datachangeconsent = $_POST["dataChangeConsent"] === "true"; @@ -65,19 +67,19 @@ $querystr = "UPDATE li_registrations SET firstname='${firstname}', lastname='${lastname}', birthday='${birthday}', gender=${gender}, street='${street}', house=${house}, zip='${zip}', city='${city}', phone='${phone}', email='${email}', - accountholder='${accountHolder}', iban='${iban}', bic='${bic}', bank='${bank}', + accountholder='${accountHolder}', iban='${iban}', bic='${bic}', bank='${bank}', contracttype=${contracttype}, applicationconsent=${applicationconsent}, datachangeconsent=${datachangeconsent}, privacypolicyconsent=${privacypolicyconsent}, directdebitconsent=${directdebitconsent}, returndebitconsent=${returndebitconsent}, datastorageconsent=${datastorageconsent}, multimediaconsent=${multimediaconsent}, WHERE rid=${rid}"; } else { $querystr = "INSERT INTO li_registrations (firstname, lastname, birthday, gender, street, house, zip, city, phone, email, - accountholder, iban, bic, bank, + accountholder, iban, bic, bank, contracttype, applicationconsent, datachangeconsent, privacypolicyconsent, directdebitconsent, returndebitconsent, datastorageconsent, multimediaconsent, registrationfrom) VALUES('{$firstname}', '{$lastname}', '{$birthday}', {$gender}, '{$street}', {$house}, '{$zip}', '{$city}', '{$phone}', '{$email}', - '{$accountholder}', '{$iban}', '{$bic}', '{$bank}', + '{$accountholder}', '{$iban}', '{$bic}', '{$bank}', ${contracttype}, {$applicationconsent}, {$datachangeconsent}, {$privacypolicyconsent}, {$directdebitconsent}, {$returndebitconsent}, {$datastorageconsent}, {$multimediaconsent}, '{$registrationfrom}')"; } @@ -103,8 +105,9 @@ 'iban' => $iban, 'bic' => $bic, 'bank' => $bank, + 'contracttype' => $contracttype, 'registrationFrom' => $formattedRegistrationFrom->format('d.m.Y'), - 'rate' => getRegistrationPrice($birthday) . ',00' . chr(128), + 'rate' => getRegistrationPrice($birthday, $contracttype) . ',00' . chr(128), 'pdfname' => "{$currentDate->format('Y-m-d')}-lidance-registrierung.pdf", 'pdfcontent' => '' ]; diff --git a/backend/course.php b/backend/course.php index 9689c30..8c31370 100644 --- a/backend/course.php +++ b/backend/course.php @@ -29,9 +29,9 @@ function CourseEdit($connection, $cid) $return .= ''; $return .= '
Gruppenname
'; - $return .= '
Tanzstil
'; + $return .= '
Alter
'; $return .= '
Level
'; - $return .= '
Alter
'; + $return .= '
Tanzstil
'; $return .= '
Link
'; $return .= '
Farbe
'; diff --git a/backend/libs/registration/registration.php b/backend/libs/registration/registration.php index dab577d..155b981 100644 --- a/backend/libs/registration/registration.php +++ b/backend/libs/registration/registration.php @@ -15,7 +15,7 @@ class PDF extends FPDF // Title $this->SetTextColor(65,28,204); - $this->Cell(50,10,'Anmeldebestätigung',0,0,'C'); + $this->Cell(50,10, utf8_decode('Anmeldebestätigung'),0,0,'C'); // Logo $this->Image('logo.jpg',168,6,30); @@ -41,9 +41,9 @@ class PDF extends FPDF $this->SetTextColor(65,28,204); // Contact info - $this->Cell(0,5,'Li-Dance Tanz- und Sportschule • Inh. Lydia Kolepp • Dieselstrasse 10 • 61231 Bad Nauheim',0,1,'C'); + $this->Cell(0,5, utf8_decode('Li-Dance Tanz- und Sportschule | Inh. Lydia Kolepp | Dieselstrasse 10 | 61231 Bad Nauheim'),0,1,'C'); $this->Ln(1); - $this->Cell(0,5,'Telefon: 060 32 / 78 48 644 • Email: info@li-dance.com • Web: www.li-dance.com',0,1,'C'); + $this->Cell(0,5,'Telefon: 060 32 / 78 48 644 | Email: info@li-dance.com | Web: www.li-dance.com',0,1,'C'); } } @@ -130,6 +130,11 @@ function getRegistrationPdf($data) { $pdf->Ln(5); $pdf->SetFont('Arial','',12); + + $pdf->Cell($leftmargin); + $pdf->Cell($leftcolumnwidth, $columnheight, 'Vertragsart: ' , 0, 0); + $pdf->Cell($fillcolumnwidth, $columnheight, getRegistrationType($data->contracttype), 0, 1); + $pdf->Cell($leftmargin); $pdf->Cell($leftcolumnwidth, $columnheight, 'Beginn ab: ' , 0, 0); @@ -147,6 +152,22 @@ function getRegistrationPdf($data) { } +function getRegistrationType($contracttype) { + if ($contracttype === 1) { + return 'Flatrate'; + } + + if ($contracttype === 2) { + return 'Einzelkurs'; + } + + if ($contracttype === 3) { + return 'Breakdance'; + } + + return 'Unbekannt'; +} + function getRegistrationDate() { $today = new DateTime(); $currentYear = $today->format('Y'); @@ -163,10 +184,10 @@ function getRegistrationDate() { } } -function getRegistrationPrice($input) { +function getRegistrationPrice($input_birthday, $input_contracttype) { // Convert input to DateTime object try { - $birthdate = new DateTime($input); + $birthdate = new DateTime($input_birthday); } catch (Exception $e) { return 0; // Return 0 if the birthdate is invalid } @@ -180,12 +201,20 @@ function getRegistrationPrice($input) { $age--; } - if ($age >= 4 && $age <= 6) { - return 37; - } elseif ($age >= 7 && $age <= 17) { + if ($input_contracttype === 2) { return 40; - } elseif ($age >= 18) { + } + + if ($input_contracttype === 3) { + return 45; + } + + if ($age >= 4 && $age <= 6) { + return 40; + } elseif ($age >= 7 && $age <= 17) { return 50; + } elseif ($age >= 18) { + return 60; } else { return 0; } @@ -215,7 +244,7 @@ function sendRegistrationMail($data) { function sendConfirmationMail($data) { $to = "{$data->email}"; // addresses to email pdf to $from = REGISTRATION_FROM; // address message is sent from - $subject = utf8_encode("Registrierungsbestätigung!"); // email subject + $subject = "Registrierungsbestätigung!"; // email subject $body = "

Herzlich willkommen bei Li-Dance!

" . "

Hallo {$data->firstname} {$data->lastname}!

" . "

Sie haben sich nun bei der Tanz- und Sportschule Li-Dance registriert. Im Anhang finden Sie Ihre Registrierungsbestätigung.

". diff --git a/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.html b/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.html index 2508557..502f7a9 100644 --- a/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.html +++ b/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.html @@ -84,6 +84,14 @@

Sie melden sich zum {{registrationDate | date:'dd.MM.yyyy' }} an

+
+ Welche Vertragsart wünschen Sie? + +
Flatrate - der Teilnehmer darf jede für seine Altersgruppe passende Unterrichtsstunde besuchen. Eine Begrenzung in der vom Teilnehmer besuchten Anzahl der Unterrichtsstunden pro Woche besteht nicht. Für Kinder bis 7J. nicht möglich.
+
Einzelkurs - der Teilnehmer besucht genau einen festgelegten Kurs, der 1x pro Woche stattfindet. Für Kinder bis 6J. und für den Erwachsenen-Kurs ist nur diese Option möglich.
+
Breakdance - der Teilnehmer besucht nur den Breakdance-Kurs, 1x die Woche, hierfür gibt es besondere Konditionen. Ab 8J. möglich.
+
+

diff --git a/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.scss b/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.scss index e04f96f..8654571 100644 --- a/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.scss +++ b/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.scss @@ -66,6 +66,11 @@ p { text-align: center; } + + .mdc-label { + font-size: 1.9em; + line-height: 1.9em; + } } .message { diff --git a/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.ts b/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.ts index 4780eca..8562450 100644 --- a/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.ts +++ b/frontend/src/app/components/registrations/registration-wizard/registration-wizard.component.ts @@ -89,6 +89,7 @@ export class RegistrationWizardComponent implements OnInit { phone: ['', [Validators.required, Validators.pattern(/^(\+?\d{1,3})?[ ]*\d{9,}$/)]], gender: ['', Validators.required], email: ['', [Validators.required, Validators.email]], + contractType: ['', Validators.required], applicationConsent: ['', Validators.required], dataChangeConsent: ['', Validators.required], privacyPolicyConsent: ['', Validators.required], @@ -131,6 +132,29 @@ export class RegistrationWizardComponent implements OnInit { } get registrationPrice(): number { + const age = this.age; + const contractType = this.firstFormGroup.get('contractType')?.value ? Number(this.firstFormGroup.get('contractType')?.value) : 0; + + switch(contractType) + { + case 2: + return 40; + case 3: + return 45; + default: + if (age >= 4 && age <= 6) { + return 40; + } else if (age >= 7 && age <= 17) { + return 50; + } else if (age >= 18) { + return 60; + } else { + return 0; + } + } + } + + get age(): number { const currentDate = new Date(); const birthdate = this.firstFormGroup.get('birthday')?.value ? this.firstFormGroup.get('birthday')?.value.toDate() : '' ; @@ -146,15 +170,7 @@ export class RegistrationWizardComponent implements OnInit { age--; } - if (age >= 4 && age <= 6) { - return 37; - } else if (age >= 7 && age <= 17) { - return 40; - } else if (age >= 18) { - return 50; - } else { - return 0; - } + return age; } capitalizeFirstTwoLetters() { @@ -184,6 +200,8 @@ export class RegistrationWizardComponent implements OnInit { phone: this.removeWhiteSpace(this.firstFormGroup.get('phone')?.value), email: this.firstFormGroup.get('email')?.value, + contractType: this.firstFormGroup.get('contractType')?.value, + applicationConsent: this.firstFormGroup.get('applicationConsent')?.value, dataChangeConsent: this.firstFormGroup.get('dataChangeConsent')?.value, privacyPolicyConsent: this.firstFormGroup.get('privacyPolicyConsent')?.value, diff --git a/frontend/src/app/models/student-registration.ts b/frontend/src/app/models/student-registration.ts index 74dcc25..454c9d7 100644 --- a/frontend/src/app/models/student-registration.ts +++ b/frontend/src/app/models/student-registration.ts @@ -21,4 +21,5 @@ export interface StudentRegistration { returnDebitConsent: boolean; dataStorageConsent: boolean; multimediaConsent: boolean; + contractType: number; } diff --git a/frontend/src/app/services/registrations/registrations.service.ts b/frontend/src/app/services/registrations/registrations.service.ts index 701c03c..2d70803 100644 --- a/frontend/src/app/services/registrations/registrations.service.ts +++ b/frontend/src/app/services/registrations/registrations.service.ts @@ -36,6 +36,7 @@ export class RegistrationsService { `iban=${encodeURIComponent(registration.iban)}&` + `bic=${encodeURIComponent(registration.bic)}&` + `bank=${encodeURIComponent(registration.bank)}&` + + `contractType=${encodeURIComponent(registration.contractType)}&` + `applicationConsent=${encodeURIComponent(registration.applicationConsent)}&` + `dataChangeConsent=${encodeURIComponent(registration.dataChangeConsent)}&` + `privacyPolicyConsent=${encodeURIComponent(registration.privacyPolicyConsent)}&` +