Add single course and breakdance to registration for other pricing

This commit is contained in:
Artur Savitskiy 2024-09-02 01:37:42 +02:00
parent 3ef38eab77
commit 4bba68fc6d
9 changed files with 90 additions and 68 deletions

View File

@ -1,43 +0,0 @@
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: GET, POST");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
require_once('../../utils/config.php');
require_once('../../utils/db.php');
require_once('../../utils/strings.php');
require_once('../../utils/tools.php');
require_once('../../libs/fpdf/fpdf.php'); // DON'T TRY TO MOVE THIS INSIDE REGISTRATION.PHP, THIS FUCKS UP CORS
require_once('../../libs/registration/registration.php');
#$authorization = $_SERVER["HTTP_AUTHORIZATION"];
#if(strcmp($authorization, INTERNAL_API_KEY) !== 0) {
# echo 'STOP TRYING TO STEAL MY DATA!';
# exit;
#}
$connection = connect();
$export = "";
$querystr = "SELECT * FROM li_registrations WHERE imported=0";
$result = mysqli_query($connection, $querystr);
if($result->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());
?>

View File

@ -47,6 +47,8 @@
$bic = escape($connection, $_POST["bic"]); $bic = escape($connection, $_POST["bic"]);
$bank = escape($connection, $_POST["bank"]); $bank = escape($connection, $_POST["bank"]);
$contracttype = intval($_POST["contractType"]);
$applicationconsent = $_POST["applicationConsent"] === "true"; $applicationconsent = $_POST["applicationConsent"] === "true";
$datachangeconsent = $_POST["dataChangeConsent"] === "true"; $datachangeconsent = $_POST["dataChangeConsent"] === "true";
$privacypolicyconsent = $_POST["privacyPolicyConsent"] === "true"; $privacypolicyconsent = $_POST["privacyPolicyConsent"] === "true";
@ -65,19 +67,19 @@
$querystr = "UPDATE li_registrations SET firstname='${firstname}', lastname='${lastname}', birthday='${birthday}', $querystr = "UPDATE li_registrations SET firstname='${firstname}', lastname='${lastname}', birthday='${birthday}',
gender=${gender}, street='${street}', house=${house}, gender=${gender}, street='${street}', house=${house},
zip='${zip}', city='${city}', phone='${phone}', email='${email}', 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}, applicationconsent=${applicationconsent}, datachangeconsent=${datachangeconsent}, privacypolicyconsent=${privacypolicyconsent},
directdebitconsent=${directdebitconsent}, returndebitconsent=${returndebitconsent}, datastorageconsent=${datastorageconsent}, directdebitconsent=${directdebitconsent}, returndebitconsent=${returndebitconsent}, datastorageconsent=${datastorageconsent},
multimediaconsent=${multimediaconsent}, multimediaconsent=${multimediaconsent},
WHERE rid=${rid}"; WHERE rid=${rid}";
} else { } else {
$querystr = "INSERT INTO li_registrations (firstname, lastname, birthday, gender, street, house, zip, city, phone, email, $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, applicationconsent, datachangeconsent, privacypolicyconsent, directdebitconsent,
returndebitconsent, datastorageconsent, multimediaconsent, registrationfrom) returndebitconsent, datastorageconsent, multimediaconsent, registrationfrom)
VALUES('{$firstname}', '{$lastname}', '{$birthday}', {$gender}, '{$street}', {$house}, '{$zip}', '{$city}', '{$phone}', '{$email}', VALUES('{$firstname}', '{$lastname}', '{$birthday}', {$gender}, '{$street}', {$house}, '{$zip}', '{$city}', '{$phone}', '{$email}',
'{$accountholder}', '{$iban}', '{$bic}', '{$bank}', '{$accountholder}', '{$iban}', '{$bic}', '{$bank}', ${contracttype},
{$applicationconsent}, {$datachangeconsent}, {$privacypolicyconsent}, {$directdebitconsent}, {$applicationconsent}, {$datachangeconsent}, {$privacypolicyconsent}, {$directdebitconsent},
{$returndebitconsent}, {$datastorageconsent}, {$multimediaconsent}, '{$registrationfrom}')"; {$returndebitconsent}, {$datastorageconsent}, {$multimediaconsent}, '{$registrationfrom}')";
} }
@ -103,8 +105,9 @@
'iban' => $iban, 'iban' => $iban,
'bic' => $bic, 'bic' => $bic,
'bank' => $bank, 'bank' => $bank,
'contracttype' => $contracttype,
'registrationFrom' => $formattedRegistrationFrom->format('d.m.Y'), '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", 'pdfname' => "{$currentDate->format('Y-m-d')}-lidance-registrierung.pdf",
'pdfcontent' => '' 'pdfcontent' => ''
]; ];

View File

@ -29,9 +29,9 @@ function CourseEdit($connection, $cid)
$return .= '<input id="cid" type="hidden" value="' . $cid . '" />'; $return .= '<input id="cid" type="hidden" value="' . $cid . '" />';
$return .= '<div class="leftcol">Gruppenname</div><div class="rightcol"><input id="cname" type="text" value="' . $name . '" /></div>'; $return .= '<div class="leftcol">Gruppenname</div><div class="rightcol"><input id="cname" type="text" value="' . $name . '" /></div>';
$return .= '<div class="leftcol">Tanzstil</div><div class="rightcol"><input id="cdescr" type="text" value="' . $descr . '" /></div>'; $return .= '<div class="leftcol">Alter</div><div class="rightcol"><input id="cdescr" type="text" value="' . $descr . '" /></div>';
$return .= '<div class="leftcol">Level</div><div class="rightcol"><input id="clevel" type="text" value="' . $level . '" /></div>'; $return .= '<div class="leftcol">Level</div><div class="rightcol"><input id="clevel" type="text" value="' . $level . '" /></div>';
$return .= '<div class="leftcol">Alter</div><div class="rightcol"><input id="cdiffname" type="text" value="' . $diffname . '" /></div>'; $return .= '<div class="leftcol">Tanzstil</div><div class="rightcol"><input id="cdiffname" type="text" value="' . $diffname . '" /></div>';
$return .= '<div class="leftcol">Link</div><div class="rightcol"><input id="clink" type="text" value="' . $link . '" /></div>'; $return .= '<div class="leftcol">Link</div><div class="rightcol"><input id="clink" type="text" value="' . $link . '" /></div>';
$return .= '<div class="leftcol">Farbe</div><div class="rightcol"><input id="ccolor" type="text" value="' . $color . '" /></div>'; $return .= '<div class="leftcol">Farbe</div><div class="rightcol"><input id="ccolor" type="text" value="' . $color . '" /></div>';

View File

@ -15,7 +15,7 @@ class PDF extends FPDF
// Title // Title
$this->SetTextColor(65,28,204); $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 // Logo
$this->Image('logo.jpg',168,6,30); $this->Image('logo.jpg',168,6,30);
@ -41,9 +41,9 @@ class PDF extends FPDF
$this->SetTextColor(65,28,204); $this->SetTextColor(65,28,204);
// Contact info // 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->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');
} }
} }
@ -131,6 +131,11 @@ function getRegistrationPdf($data) {
$pdf->SetFont('Arial','',12); $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($leftmargin);
$pdf->Cell($leftcolumnwidth, $columnheight, 'Beginn ab: ' , 0, 0); $pdf->Cell($leftcolumnwidth, $columnheight, 'Beginn ab: ' , 0, 0);
$pdf->Cell($fillcolumnwidth, $columnheight, $data->registrationFrom, 0, 1); $pdf->Cell($fillcolumnwidth, $columnheight, $data->registrationFrom, 0, 1);
@ -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() { function getRegistrationDate() {
$today = new DateTime(); $today = new DateTime();
$currentYear = $today->format('Y'); $currentYear = $today->format('Y');
@ -163,10 +184,10 @@ function getRegistrationDate() {
} }
} }
function getRegistrationPrice($input) { function getRegistrationPrice($input_birthday, $input_contracttype) {
// Convert input to DateTime object // Convert input to DateTime object
try { try {
$birthdate = new DateTime($input); $birthdate = new DateTime($input_birthday);
} catch (Exception $e) { } catch (Exception $e) {
return 0; // Return 0 if the birthdate is invalid return 0; // Return 0 if the birthdate is invalid
} }
@ -180,12 +201,20 @@ function getRegistrationPrice($input) {
$age--; $age--;
} }
if ($age >= 4 && $age <= 6) { if ($input_contracttype === 2) {
return 37;
} elseif ($age >= 7 && $age <= 17) {
return 40; 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; return 50;
} elseif ($age >= 18) {
return 60;
} else { } else {
return 0; return 0;
} }
@ -215,7 +244,7 @@ function sendRegistrationMail($data) {
function sendConfirmationMail($data) { function sendConfirmationMail($data) {
$to = "{$data->email}"; // addresses to email pdf to $to = "{$data->email}"; // addresses to email pdf to
$from = REGISTRATION_FROM; // address message is sent from $from = REGISTRATION_FROM; // address message is sent from
$subject = utf8_encode("Registrierungsbestätigung!"); // email subject $subject = "Registrierungsbestätigung!"; // email subject
$body = "<h3>Herzlich willkommen bei Li-Dance!</h3>" . $body = "<h3>Herzlich willkommen bei Li-Dance!</h3>" .
"<p>Hallo {$data->firstname} {$data->lastname}!</p>" . "<p>Hallo {$data->firstname} {$data->lastname}!</p>" .
"<p>Sie haben sich nun bei der Tanz- und Sportschule Li-Dance registriert. Im Anhang finden Sie Ihre Registrierungsbest&auml;tigung.</p>". "<p>Sie haben sich nun bei der Tanz- und Sportschule Li-Dance registriert. Im Anhang finden Sie Ihre Registrierungsbest&auml;tigung.</p>".

View File

@ -84,6 +84,14 @@
<div class="flexContainerColumn whitebox big"> <div class="flexContainerColumn whitebox big">
<p>Sie melden sich zum {{registrationDate | date:'dd.MM.yyyy' }} an</p> <p>Sie melden sich zum {{registrationDate | date:'dd.MM.yyyy' }} an</p>
</div> </div>
<div class="flexContainerColumn whitebox big">
<mat-label>Welche Vertragsart wünschen Sie?</mat-label>
<mat-radio-group formControlName="contractType" aria-label="Welche Vertragsart wünschen Sie">
<div><mat-radio-button [disabled]="age < 7" value="1"><strong>Flatrate</strong> - 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.</mat-radio-button></div>
<div><mat-radio-button [disabled]="(age > 6 && age < 18) || age <= 0" value="2"><strong>Einzelkurs</strong> - 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.</mat-radio-button></div>
<div><mat-radio-button [disabled]="age < 8" value="3"><strong>Breakdance</strong> - der Teilnehmer besucht nur den Breakdance-Kurs, 1x die Woche, hierfür gibt es besondere Konditionen. Ab 8J. möglich.</mat-radio-button></div>
</mat-radio-group>
</div>
<div class="flexContainerColumn whitebox"> <div class="flexContainerColumn whitebox">
<mat-checkbox formControlName="applicationConsent" required><span [innerHTML]="infoTextAufnahme"></span></mat-checkbox> <mat-checkbox formControlName="applicationConsent" required><span [innerHTML]="infoTextAufnahme"></span></mat-checkbox>
<br style="margin-bottom: 20px;"> <br style="margin-bottom: 20px;">

View File

@ -66,6 +66,11 @@
p { p {
text-align: center; text-align: center;
} }
.mdc-label {
font-size: 1.9em;
line-height: 1.9em;
}
} }
.message { .message {

View File

@ -89,6 +89,7 @@ export class RegistrationWizardComponent implements OnInit {
phone: ['', [Validators.required, Validators.pattern(/^(\+?\d{1,3})?[ ]*\d{9,}$/)]], phone: ['', [Validators.required, Validators.pattern(/^(\+?\d{1,3})?[ ]*\d{9,}$/)]],
gender: ['', Validators.required], gender: ['', Validators.required],
email: ['', [Validators.required, Validators.email]], email: ['', [Validators.required, Validators.email]],
contractType: ['', Validators.required],
applicationConsent: ['', Validators.required], applicationConsent: ['', Validators.required],
dataChangeConsent: ['', Validators.required], dataChangeConsent: ['', Validators.required],
privacyPolicyConsent: ['', Validators.required], privacyPolicyConsent: ['', Validators.required],
@ -131,6 +132,29 @@ export class RegistrationWizardComponent implements OnInit {
} }
get registrationPrice(): number { 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 currentDate = new Date();
const birthdate = this.firstFormGroup.get('birthday')?.value ? this.firstFormGroup.get('birthday')?.value.toDate() : '' ; const birthdate = this.firstFormGroup.get('birthday')?.value ? this.firstFormGroup.get('birthday')?.value.toDate() : '' ;
@ -146,15 +170,7 @@ export class RegistrationWizardComponent implements OnInit {
age--; age--;
} }
if (age >= 4 && age <= 6) { return age;
return 37;
} else if (age >= 7 && age <= 17) {
return 40;
} else if (age >= 18) {
return 50;
} else {
return 0;
}
} }
capitalizeFirstTwoLetters() { capitalizeFirstTwoLetters() {
@ -184,6 +200,8 @@ export class RegistrationWizardComponent implements OnInit {
phone: this.removeWhiteSpace(this.firstFormGroup.get('phone')?.value), phone: this.removeWhiteSpace(this.firstFormGroup.get('phone')?.value),
email: this.firstFormGroup.get('email')?.value, email: this.firstFormGroup.get('email')?.value,
contractType: this.firstFormGroup.get('contractType')?.value,
applicationConsent: this.firstFormGroup.get('applicationConsent')?.value, applicationConsent: this.firstFormGroup.get('applicationConsent')?.value,
dataChangeConsent: this.firstFormGroup.get('dataChangeConsent')?.value, dataChangeConsent: this.firstFormGroup.get('dataChangeConsent')?.value,
privacyPolicyConsent: this.firstFormGroup.get('privacyPolicyConsent')?.value, privacyPolicyConsent: this.firstFormGroup.get('privacyPolicyConsent')?.value,

View File

@ -21,4 +21,5 @@ export interface StudentRegistration {
returnDebitConsent: boolean; returnDebitConsent: boolean;
dataStorageConsent: boolean; dataStorageConsent: boolean;
multimediaConsent: boolean; multimediaConsent: boolean;
contractType: number;
} }

View File

@ -36,6 +36,7 @@ export class RegistrationsService {
`iban=${encodeURIComponent(registration.iban)}&` + `iban=${encodeURIComponent(registration.iban)}&` +
`bic=${encodeURIComponent(registration.bic)}&` + `bic=${encodeURIComponent(registration.bic)}&` +
`bank=${encodeURIComponent(registration.bank)}&` + `bank=${encodeURIComponent(registration.bank)}&` +
`contractType=${encodeURIComponent(registration.contractType)}&` +
`applicationConsent=${encodeURIComponent(registration.applicationConsent)}&` + `applicationConsent=${encodeURIComponent(registration.applicationConsent)}&` +
`dataChangeConsent=${encodeURIComponent(registration.dataChangeConsent)}&` + `dataChangeConsent=${encodeURIComponent(registration.dataChangeConsent)}&` +
`privacyPolicyConsent=${encodeURIComponent(registration.privacyPolicyConsent)}&` + `privacyPolicyConsent=${encodeURIComponent(registration.privacyPolicyConsent)}&` +