270 lines
8.9 KiB
PHP
270 lines
8.9 KiB
PHP
|
<?php
|
|||
|
require_once('../../utils/config.php');
|
|||
|
|
|||
|
class PDF extends FPDF
|
|||
|
{
|
|||
|
// Page header
|
|||
|
function Header()
|
|||
|
{
|
|||
|
// Logo
|
|||
|
$this->Image( 'logo.jpg',12,6,30);
|
|||
|
// Arial bold 15
|
|||
|
$this->SetFont('Arial','B',16);
|
|||
|
// Move to the right
|
|||
|
$this->Cell(72);
|
|||
|
|
|||
|
// Title
|
|||
|
$this->SetTextColor(65,28,204);
|
|||
|
$this->Cell(50,10,'Anmeldebest<73>tigung',0,0,'C');
|
|||
|
|
|||
|
// Logo
|
|||
|
$this->Image('logo.jpg',168,6,30);
|
|||
|
|
|||
|
// Deco
|
|||
|
$this->Image('header.png',16,45);
|
|||
|
|
|||
|
// Line break
|
|||
|
$this->Ln(42);
|
|||
|
}
|
|||
|
|
|||
|
// Page footer
|
|||
|
function Footer()
|
|||
|
{
|
|||
|
// Position at 1.5 cm from bottom
|
|||
|
$this->SetY(-17);
|
|||
|
|
|||
|
// Deco
|
|||
|
$this->Image('footer.png',41,275);
|
|||
|
|
|||
|
// Arial 8
|
|||
|
$this->SetFont('Arial','',8);
|
|||
|
$this->SetTextColor(65,28,204);
|
|||
|
|
|||
|
// Contact info
|
|||
|
$this->Cell(0,5,'Li-Dance Tanz- und Sportschule <20> Inh. Lydia Kolepp <20> Dieselstrasse 10 <20> 61231 Bad Nauheim',0,1,'C');
|
|||
|
$this->Ln(1);
|
|||
|
$this->Cell(0,5,'Telefon: 060 32 / 78 48 644 <20> Email: info@li-dance.com <20> Web: www.li-dance.com',0,1,'C');
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function getRegistrationPdf($data) {
|
|||
|
|
|||
|
$totalmargin = 32;
|
|||
|
$leftmargin = $totalmargin + 10;
|
|||
|
$leftcolumnwidth = 40;
|
|||
|
$fillcolumnwidth = 0;
|
|||
|
$columnheight = 10;
|
|||
|
|
|||
|
// Instanciation of inherited class
|
|||
|
$pdf = new PDF();
|
|||
|
$pdf->AliasNbPages();
|
|||
|
$pdf->AddPage();
|
|||
|
|
|||
|
$pdf->SetFont('Arial','B', 14);
|
|||
|
$pdf->Cell($totalmargin);
|
|||
|
$pdf->Cell($fillcolumnwidth,$columnheight,'Ihre Daten',0,1);
|
|||
|
$pdf->Ln(5);
|
|||
|
|
|||
|
$pdf->SetFont('Arial','',12);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Vorname: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->firstname , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Nachname: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->lastname , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Geburtsdatum: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->birthdate , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Geschlecht: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->gender , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Adresse: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->street . ' ' . $data->house . ', ' . $data->zip . ' ' . $data->city , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Telefon: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->phone , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'E-Mail: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->email , 0, 1);
|
|||
|
|
|||
|
$pdf->Ln(10);
|
|||
|
|
|||
|
$pdf->SetFont('Arial','B', 14);
|
|||
|
$pdf->Cell($totalmargin);
|
|||
|
$pdf->Cell($fillcolumnwidth,$columnheight,'Ihre Bankdaten',0,1);
|
|||
|
|
|||
|
$pdf->Ln(5);
|
|||
|
|
|||
|
$pdf->SetFont('Arial','',12);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Kontoinhaber: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->accountholder , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'IBAN: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->iban , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'BIC: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->bic , 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Bank: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->bank , 0, 1);
|
|||
|
|
|||
|
$pdf->Ln(10);
|
|||
|
|
|||
|
$pdf->SetFont('Arial','B', 14);
|
|||
|
$pdf->Cell($totalmargin);
|
|||
|
$pdf->Cell($fillcolumnwidth,$columnheight,'Ihre Mitgliedschaft:' , 0, 1);
|
|||
|
|
|||
|
$pdf->Ln(5);
|
|||
|
|
|||
|
$pdf->SetFont('Arial','',12);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Beginn ab: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->registrationFrom, 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Monatsbeitrag: ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, $data->rate, 0, 1);
|
|||
|
|
|||
|
$pdf->Cell($leftmargin);
|
|||
|
$pdf->Cell($leftcolumnwidth, $columnheight, 'Anmeldung (einm.): ' , 0, 0);
|
|||
|
$pdf->Cell($fillcolumnwidth, $columnheight, "15,00" . chr(128) , 0, 1);
|
|||
|
|
|||
|
return $pdf->Output('S');
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
function getRegistrationDate() {
|
|||
|
$today = new DateTime();
|
|||
|
$currentYear = $today->format('Y');
|
|||
|
$currentMonth = $today->format('m');
|
|||
|
$currentDate = $today->format('d');
|
|||
|
|
|||
|
if ($currentDate === 1) {
|
|||
|
return new DateTime("$currentYear-$currentMonth-01"); // Today is the 1st of the month.
|
|||
|
} elseif ($currentDate <= 20) {
|
|||
|
return new DateTime("$currentYear-$currentMonth-15"); // Return the 15th of the current month.
|
|||
|
} else {
|
|||
|
$nextMonth = $today->modify('first day of next month'); // Advance to the first day of the next month.
|
|||
|
return $nextMonth;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function getRegistrationPrice($input) {
|
|||
|
// Convert input to DateTime object
|
|||
|
try {
|
|||
|
$birthdate = new DateTime($input);
|
|||
|
} catch (Exception $e) {
|
|||
|
return 0; // Return 0 if the birthdate is invalid
|
|||
|
}
|
|||
|
|
|||
|
$currentDate = new DateTime();
|
|||
|
$monthDifference = $currentDate->format('m') - $birthdate->format('m');
|
|||
|
$age = $currentDate->format('Y') - $birthdate->format('Y');
|
|||
|
|
|||
|
// Adjust age if the birthdate hasn't occurred yet this year
|
|||
|
if ($monthDifference < 0 || ($monthDifference == 0 && $currentDate->format('d') < $birthdate->format('d'))) {
|
|||
|
$age--;
|
|||
|
}
|
|||
|
|
|||
|
if ($age >= 4 && $age <= 6) {
|
|||
|
return 37;
|
|||
|
} elseif ($age >= 7 && $age <= 17) {
|
|||
|
return 40;
|
|||
|
} elseif ($age >= 18) {
|
|||
|
return 50;
|
|||
|
} else {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
function sendRegistrationMail($data) {
|
|||
|
|
|||
|
$to = REGISTRATION_MAIL;
|
|||
|
$title = 'Neue Anmeldung bei Li-Dance';
|
|||
|
$message = "
|
|||
|
<html><head><title>Neue Anmeldung bei Li-Dance</title></head><body>
|
|||
|
<p>{$data->firstname} {$data->lastname} aus {$data->city} hat sich angemeldet.</p>
|
|||
|
<p>Btte bearbeite diese m<EFBFBD>glichst schnell: <a href='" . REGISTRATION_URL . "'>Zur Anmeldung</a></p>
|
|||
|
</body></html>";
|
|||
|
|
|||
|
$header[] = 'MIME-Version: 1.0';
|
|||
|
$header[] = 'Content-type: text/html; charset=iso-8859-1';
|
|||
|
$header[] = 'To: ' . REGISTRATION_MAIL;
|
|||
|
$header[] = 'From: ' . REGISTRATION_FROM;
|
|||
|
$header[] = 'X-Mailer: PHP/' . phpversion();
|
|||
|
|
|||
|
mb_send_mail($to, $title, $message, implode("\r\n", $header));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
function sendConfirmationMail($data) {
|
|||
|
$to = "{$data->email}"; // addresses to email pdf to
|
|||
|
$from = REGISTRATION_FROM; // address message is sent from
|
|||
|
$subject = utf8_encode("Registrierungsbest<EFBFBD>tigung!"); // email subject
|
|||
|
$body = "<h3>Herzlich willkommen bei Li-Dance!</h3>" .
|
|||
|
"<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ätigung.</p>".
|
|||
|
"<br/>" .
|
|||
|
"<p>Wenn Sie sich nicht registrieren wollten, melden Sie sich bitte unverzüglich bei uns, wir werden das Problem dann gemeinsam mit Ihnen klären.</p>" .
|
|||
|
"<p><i>Dies ist eine automatisch generierte E-Mail</i></p>" .
|
|||
|
"<br/><br/>" .
|
|||
|
"<p>Tanz- und Sportschule Li-Dance" .
|
|||
|
"<br/>Inh. Lydia Kolepp" .
|
|||
|
"<br/>Dieselstr. 10" .
|
|||
|
"<br/>61231 Bad Nauheim" .
|
|||
|
"<br/>Tel. 06032 7848644" .
|
|||
|
"<br/>Mail <a href='mailto:info@li-dance.de'>info@li-dance.de</a></p>"; // email body
|
|||
|
$pdfLocation = $data->pdfcontent; // file location
|
|||
|
$pdfName = $data->pdfname; // pdf file name recipient will get
|
|||
|
$filetype = "application/pdf"; // type
|
|||
|
|
|||
|
// create headers and mime boundry
|
|||
|
$eol = PHP_EOL;
|
|||
|
$semi_rand = md5(time());
|
|||
|
|
|||
|
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
|
|||
|
$headers = "From: $from$eol" .
|
|||
|
"MIME-Version: 1.0$eol" .
|
|||
|
"Content-Type: multipart/mixed;$eol" .
|
|||
|
" boundary=\"$mime_boundary\"";
|
|||
|
|
|||
|
// add html message body
|
|||
|
$message = "--$mime_boundary$eol" .
|
|||
|
"Content-Type: text/html; charset=\"iso-8859-1\"$eol" .
|
|||
|
"Content-Transfer-Encoding: 7bit$eol$eol" .
|
|||
|
$body . $eol;
|
|||
|
|
|||
|
// fetch pdf
|
|||
|
$pdf = chunk_split(base64_encode($data->pdfcontent));
|
|||
|
|
|||
|
// attach pdf to email
|
|||
|
$message .= "--$mime_boundary$eol" .
|
|||
|
"Content-Type: $filetype;$eol" .
|
|||
|
" name=\"$pdfName\"$eol" .
|
|||
|
"Content-Disposition: attachment;$eol" .
|
|||
|
" filename=\"$pdfName\"$eol" .
|
|||
|
"Content-Transfer-Encoding: base64$eol$eol" .
|
|||
|
$pdf . $eol .
|
|||
|
"--$mime_boundary--";
|
|||
|
|
|||
|
// Send the email
|
|||
|
return mail($to, $subject, $message, $headers);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
?>
|