Mitgliedsanträge mit Unterschrift und Admin-Ansicht
This commit is contained in:
parent
675d7bbcba
commit
9355bd3ada
11 changed files with 554 additions and 36 deletions
|
|
@ -941,3 +941,47 @@ body .datepicker-title {
|
|||
body .datepicker-footer {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
/* Unterschriftenfeld für den Mitgliedsantrag */
|
||||
.signature-pad {
|
||||
padding: .6rem;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: .5rem;
|
||||
}
|
||||
|
||||
.signature-pad canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 160px;
|
||||
background: #fff;
|
||||
border: 1px dashed #94a3b8;
|
||||
border-radius: .35rem;
|
||||
cursor: crosshair;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.signature-pad-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: .75rem;
|
||||
margin-top: .45rem;
|
||||
}
|
||||
|
||||
.signature-pad-hint {
|
||||
color: #64748b;
|
||||
font-size: .78rem;
|
||||
}
|
||||
|
||||
/* Unterschriften in der Admin-Antragsansicht */
|
||||
.signature-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 620px;
|
||||
height: auto;
|
||||
padding: .4rem;
|
||||
background: #fff;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: .5rem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Auth;
|
||||
use App\Models\MembershipApplication;
|
||||
use App\Models\Page;
|
||||
|
||||
class AdminController
|
||||
|
|
@ -47,14 +48,31 @@ class AdminController
|
|||
redirect('/');
|
||||
}
|
||||
|
||||
public function applications(): void
|
||||
{
|
||||
view('admin.applications', [
|
||||
'applications' => MembershipApplication::latest(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function application(string $id): void
|
||||
{
|
||||
$application = MembershipApplication::find((int) $id);
|
||||
|
||||
if ($application === null) {
|
||||
http_response_code(404);
|
||||
exit('Antrag nicht gefunden.');
|
||||
}
|
||||
|
||||
view('admin.application', ['application' => $application]);
|
||||
}
|
||||
|
||||
public function editHome(): void
|
||||
{
|
||||
$page = Page::byName('home');
|
||||
|
||||
view('admin.edit_home', ['content' => $page->content ?? '']);
|
||||
}
|
||||
|
||||
public function storeHome(): void
|
||||
} public function storeHome(): void
|
||||
{
|
||||
validate(['pagecontent' => 'required']);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,21 @@ class HomeController
|
|||
'iban' => 'required',
|
||||
]);
|
||||
|
||||
$signature1 = $this->decodeSignature((string) input('unterschrift_1'));
|
||||
$signature2 = $this->decodeSignature((string) input('unterschrift_2'));
|
||||
|
||||
if ($signature1 === null) {
|
||||
$_SESSION['_errors']['unterschrift_1'][] = 'Bitte unterschreiben Sie den Antrag.';
|
||||
$_SESSION['_old'] = $this->oldApplicationInput();
|
||||
back();
|
||||
}
|
||||
|
||||
if ($signature2 === null) {
|
||||
$_SESSION['_errors']['unterschrift_2'][] = 'Bitte unterschreiben Sie das SEPA-Lastschriftmandat.';
|
||||
$_SESSION['_old'] = $this->oldApplicationInput();
|
||||
back();
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
$nachname = (string) input('nachname');
|
||||
|
|
@ -73,7 +88,6 @@ class HomeController
|
|||
$motorrad = (string) input('motorrad');
|
||||
$aufnahmeAb = (string) input('aufnahme_ab');
|
||||
$ortDatum1 = (string) input('ort_datum_1');
|
||||
$unterschrift1 = (string) input('unterschrift_1');
|
||||
$mandatsref = (string) input('mandatsreferenz');
|
||||
$glaeubigerId = (string) input('glaeubiger_id');
|
||||
$kontoinhaber = (string) input('kontoinhaber');
|
||||
|
|
@ -81,32 +95,62 @@ class HomeController
|
|||
$bic = (string) input('bic');
|
||||
$iban = (string) input('iban');
|
||||
$ortDatum2 = (string) input('ort_datum_2');
|
||||
$unterschrift2 = (string) input('unterschrift_2');
|
||||
|
||||
MembershipApplication::create([
|
||||
'user_id' => $user?->id,
|
||||
'nachname' => $nachname,
|
||||
'vorname' => $vorname,
|
||||
'strasse' => $strasse,
|
||||
'plz_ort' => $plzOrt,
|
||||
'telefon' => $telefon,
|
||||
'email' => $email,
|
||||
'geburtsdatum' => $geburtsdatum,
|
||||
'motorrad' => $motorrad,
|
||||
'aufnahme_ab' => $aufnahmeAb,
|
||||
'ort_datum_1' => $ortDatum1,
|
||||
'unterschrift_1' => $unterschrift1,
|
||||
'mandatsreferenz' => $mandatsref,
|
||||
'glaeubiger_id' => $glaeubigerId,
|
||||
'kontoinhaber' => $kontoinhaber,
|
||||
'kreditinstitut' => $kreditinstitut,
|
||||
'bic' => $bic,
|
||||
'iban' => $iban,
|
||||
'ort_datum_2' => $ortDatum2,
|
||||
'unterschrift_2' => $unterschrift2,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$token = bin2hex(random_bytes(12));
|
||||
$file1 = $this->saveSignatureFile($signature1, $token, 1);
|
||||
$file2 = $this->saveSignatureFile($signature2, $token, 2);
|
||||
|
||||
if ($file1 === null || $file2 === null) {
|
||||
$this->deleteSignatureFiles(array_filter([$file1, $file2]));
|
||||
app_log('error', 'Mitgliedsantrag: Unterschrift konnte nicht gespeichert werden');
|
||||
flash_set('error', 'Die Unterschrift konnte nicht gespeichert werden. Bitte den Administrator informieren.');
|
||||
$_SESSION['_old'] = $this->oldApplicationInput();
|
||||
redirect('/mitgliedsantrag');
|
||||
}
|
||||
|
||||
try {
|
||||
$application = MembershipApplication::create([
|
||||
'user_id' => $user?->id,
|
||||
'nachname' => $nachname,
|
||||
'vorname' => $vorname,
|
||||
'strasse' => $strasse,
|
||||
'plz_ort' => $plzOrt,
|
||||
'telefon' => $telefon,
|
||||
'email' => $email,
|
||||
'geburtsdatum' => $geburtsdatum,
|
||||
'motorrad' => $motorrad,
|
||||
'aufnahme_ab' => $aufnahmeAb,
|
||||
'ort_datum_1' => $ortDatum1,
|
||||
'unterschrift_1' => $file1,
|
||||
'mandatsreferenz' => $mandatsref,
|
||||
'glaeubiger_id' => $glaeubigerId,
|
||||
'kontoinhaber' => $kontoinhaber,
|
||||
'kreditinstitut' => $kreditinstitut,
|
||||
'bic' => $bic,
|
||||
'iban' => $iban,
|
||||
'ort_datum_2' => $ortDatum2,
|
||||
'unterschrift_2' => $file2,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
$this->deleteSignatureFiles([$file1, $file2]);
|
||||
app_log('error', 'Mitgliedsantrag konnte nicht gespeichert werden', [
|
||||
'exception' => $e::class,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
flash_set('error', 'Der Antrag konnte nicht gespeichert werden. Bitte den Administrator informieren.');
|
||||
$_SESSION['_old'] = $this->oldApplicationInput();
|
||||
redirect('/mitgliedsantrag');
|
||||
}
|
||||
|
||||
$baseUrl = rtrim((string) config('app.url'), '/');
|
||||
|
||||
if ($baseUrl === '' || str_contains($baseUrl, 'localhost')) {
|
||||
$baseUrl = 'https://motorrad-ig.de';
|
||||
}
|
||||
|
||||
$adminUrl = $baseUrl . '/admin/antraege/' . $application->id;
|
||||
|
||||
$body = "Neuer Mitgliedsantrag über die Website\n"
|
||||
. "========================================\n\n"
|
||||
|
|
@ -121,7 +165,7 @@ class HomeController
|
|||
. " Motorrad: " . $motorrad . "\n"
|
||||
. " Aufnahme ab: " . $aufnahmeAb . "\n"
|
||||
. " Ort / Datum: " . $ortDatum1 . "\n"
|
||||
. " Unterschrift: " . $unterschrift1 . "\n\n"
|
||||
. " Unterschrift: digital erfasst\n\n"
|
||||
. "SEPA-Lastschriftmandat\n"
|
||||
. " Mandatsreferenz: " . $mandatsref . "\n"
|
||||
. " Gläubiger-ID: " . $glaeubigerId . "\n"
|
||||
|
|
@ -130,7 +174,9 @@ class HomeController
|
|||
. " BIC: " . $bic . "\n"
|
||||
. " IBAN: " . $iban . "\n"
|
||||
. " Ort / Datum: " . $ortDatum2 . "\n"
|
||||
. " Unterschrift: " . $unterschrift2 . "\n";
|
||||
. " Unterschrift: digital erfasst\n\n"
|
||||
. "Antrag im Admin-Bereich ansehen:\n"
|
||||
. " " . $adminUrl . "\n";
|
||||
|
||||
send_mail(
|
||||
(string) config('app.membership_notify_email'),
|
||||
|
|
@ -140,8 +186,80 @@ class HomeController
|
|||
$email
|
||||
);
|
||||
|
||||
app_log('info', 'Mitgliedsantrag gespeichert', [
|
||||
'application_id' => $application->id,
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
$_SESSION['_flash']['status'] = 'Vielen Dank! Dein Mitgliedsantrag wurde gespeichert.';
|
||||
|
||||
redirect('/mitgliedsantrag');
|
||||
}
|
||||
|
||||
/** Dekodiert eine Signatur aus dem Canvas (PNG-Data-URL). */
|
||||
private function decodeSignature(string $dataUrl): ?string
|
||||
{
|
||||
if (!preg_match('#^data:image/png;base64,([A-Za-z0-9+/=\s]+)$#', $dataUrl, $matches)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$binary = base64_decode(preg_replace('/\s+/', '', $matches[1]), true);
|
||||
|
||||
if ($binary === false || strlen($binary) < 100 || strlen($binary) > 2_000_000) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$image = @imagecreatefromstring($binary);
|
||||
|
||||
if (!$image instanceof \GdImage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
|
||||
if ($width < 20 || $height < 10 || $width > 3000 || $height > 1500) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $binary;
|
||||
}
|
||||
|
||||
private function saveSignatureFile(string $binary, string $token, int $index): ?string
|
||||
{
|
||||
$dir = storage_path('img_storage/mitgliedsantrag');
|
||||
|
||||
if (!is_dir($dir) && !@mkdir($dir, 0775, true) && !is_dir($dir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_writable($dir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$filename = $token . '_' . $index . '.png';
|
||||
|
||||
if (@file_put_contents($dir . '/' . $filename, $binary) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
private function deleteSignatureFiles(array $files): void
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
if (is_string($file) && $file !== '') {
|
||||
@unlink(storage_path('img_storage/mitgliedsantrag/' . $file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function oldApplicationInput(): array
|
||||
{
|
||||
$old = $_POST;
|
||||
unset($old['_token'], $old['unterschrift_1'], $old['unterschrift_2']);
|
||||
|
||||
return $old;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class ImageController
|
|||
* Zugriffsregeln pro Bildkategorie:
|
||||
* tour-<id> nur Teilnehmer der Tour und Admins
|
||||
* tour-<id>-DELETED nur Admins (Papierkorb)
|
||||
* mitgliedsantrag nur Admins (Unterschriften)
|
||||
* user, pdf Mitglieder und Admins (wie bisher)
|
||||
*/
|
||||
private function canAccessCategory(string $category, ?User $user): bool
|
||||
|
|
@ -55,6 +56,10 @@ class ImageController
|
|||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
if ($category === 'mitgliedsantrag') {
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
if (preg_match('/^tour-(\d+)$/', $category, $matches) === 1) {
|
||||
return Booking::canAccessTourGallery((int) $matches[1], $user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,14 @@ use App\Core\Model;
|
|||
class MembershipApplication extends Model
|
||||
{
|
||||
protected static string $table = 'membership_applications';
|
||||
|
||||
/** Alle Anträge, neueste zuerst. */
|
||||
public static function latest(): array
|
||||
{
|
||||
$rows = db()->fetchAll(
|
||||
'SELECT * FROM `membership_applications` ORDER BY created_at DESC, id DESC'
|
||||
);
|
||||
|
||||
return array_map(fn(array $row) => static::fromRow($row), $rows);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -483,7 +483,15 @@ function validate(array $rules): array
|
|||
]);
|
||||
|
||||
$_SESSION['_errors'] = $errors;
|
||||
$_SESSION['_old'] = $_POST;
|
||||
|
||||
$old = $_POST;
|
||||
|
||||
// Keine Passwörter, Tokens oder Signaturdaten in der Session ablegen.
|
||||
foreach (['password', 'password_confirmation', '_token', 'unterschrift_1', 'unterschrift_2'] as $sensitive) {
|
||||
unset($old[$sensitive]);
|
||||
}
|
||||
|
||||
$_SESSION['_old'] = $old;
|
||||
back();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ $router->get('/admin/upload_tourplan', [AdminController::class, 'uploadTourplan'
|
|||
$router->post('/admin/store_tourplan', [AdminController::class, 'storeTourplan'], 'ADMIN');
|
||||
$router->get('/admin/upload_mitgliedsantrag', [AdminController::class, 'uploadMitgliedsantrag'], 'ADMIN');
|
||||
$router->post('/admin/store_mitgliedsantrag', [AdminController::class, 'storeMitgliedsantrag'], 'ADMIN');
|
||||
$router->get('/admin/antraege', [AdminController::class, 'applications'], 'ADMIN');
|
||||
$router->get('/admin/antraege/{id}', [AdminController::class, 'application'], 'ADMIN');
|
||||
$router->get('/admin/edit_home', [AdminController::class, 'editHome'], 'ADMIN');
|
||||
$router->get('/admin/edit_activities', [AdminController::class, 'editActivities'], 'ADMIN');
|
||||
$router->post('/admin/store_home', [AdminController::class, 'storeHome'], 'ADMIN');
|
||||
|
|
|
|||
96
motorradig/views/admin/application.php
Normal file
96
motorradig/views/admin/application.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
$signatureUrl = function (?string $file): ?string {
|
||||
if (!$file || !is_file(storage_path('img_storage/mitgliedsantrag/' . $file))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return '/img_storage/mitgliedsantrag/' . rawurlencode($file);
|
||||
};
|
||||
|
||||
$signature1 = $signatureUrl($application->unterschrift_1);
|
||||
$signature2 = $signatureUrl($application->unterschrift_2);
|
||||
?>
|
||||
|
||||
<div class="container text-light mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-11">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<div>
|
||||
<h1 class="mb-0">Antrag</h1>
|
||||
<p class="text-muted mb-0">
|
||||
<?= e(trim($application->vorname . ' ' . $application->nachname)) ?>
|
||||
· Eingang:
|
||||
<?= e($application->created_at ? date('d.m.Y H:i', strtotime($application->created_at)) : '') ?>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin/antraege" class="btn btn-sm btn-outline-light">Zurück</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-light" onclick="window.print();">Drucken</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card text-dark">
|
||||
<div class="card-body">
|
||||
<h5 class="border-bottom border-danger pb-1 mb-3">Persönliche Angaben</h5>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered mb-4">
|
||||
<tbody>
|
||||
<tr><th style="width:220px;">Nachname</th><td><?= e($application->nachname) ?></td></tr>
|
||||
<tr><th>Vorname</th><td><?= e($application->vorname) ?></td></tr>
|
||||
<tr><th>Straße, Nr.</th><td><?= e($application->strasse) ?></td></tr>
|
||||
<tr><th>PLZ, Ort</th><td><?= e($application->plz_ort) ?></td></tr>
|
||||
<tr><th>Telefon / Mobile / Fax</th><td><?= e($application->telefon) ?></td></tr>
|
||||
<tr><th>E-Mail</th><td><?= e($application->email) ?></td></tr>
|
||||
<tr><th>Geburtsdatum</th><td><?= e(german_date($application->geburtsdatum)) ?></td></tr>
|
||||
<tr><th>Motorrad</th><td><?= e($application->motorrad) ?></td></tr>
|
||||
<tr><th>Aufnahme ab</th><td><?= e(german_date($application->aufnahme_ab)) ?></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h5 class="border-bottom border-danger pb-1 mb-3">Unterschrift Mitgliedsantrag</h5>
|
||||
|
||||
<p class="mb-1"><strong>Ort / Datum:</strong> <?= e($application->ort_datum_1) ?></p>
|
||||
|
||||
<?php if ($signature1 !== null): ?>
|
||||
<a href="<?= e($signature1) ?>" data-lightbox="antrag-<?= e($application->id) ?>" data-title="Unterschrift Mitgliedsantrag">
|
||||
<img src="<?= e($signature1) ?>" alt="Unterschrift Mitgliedsantrag" class="signature-image">
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<p class="text-danger">Keine Unterschrift gespeichert.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h5 class="border-bottom border-danger pb-1 mb-3 mt-4">SEPA-Lastschriftmandat</h5>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered mb-4">
|
||||
<tbody>
|
||||
<tr><th style="width:220px;">Mandatsreferenz</th><td><?= e($application->mandatsreferenz) ?></td></tr>
|
||||
<tr><th>Gläubiger-ID</th><td><?= e($application->glaeubiger_id) ?></td></tr>
|
||||
<tr><th>Kontoinhaber</th><td><?= e($application->kontoinhaber) ?></td></tr>
|
||||
<tr><th>Kreditinstitut</th><td><?= e($application->kreditinstitut) ?></td></tr>
|
||||
<tr><th>BIC</th><td><?= e($application->bic) ?></td></tr>
|
||||
<tr><th>IBAN</th><td><?= e($application->iban) ?></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p class="mb-1"><strong>Ort / Datum:</strong> <?= e($application->ort_datum_2) ?></p>
|
||||
|
||||
<?php if ($signature2 !== null): ?>
|
||||
<a href="<?= e($signature2) ?>" data-lightbox="antrag-<?= e($application->id) ?>" data-title="Unterschrift SEPA-Lastschriftmandat">
|
||||
<img src="<?= e($signature2) ?>" alt="Unterschrift SEPA-Lastschriftmandat" class="signature-image">
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<p class="text-danger">Keine Unterschrift gespeichert.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="text-muted small mt-4 mb-0">
|
||||
Antrags-ID: <?= e($application->id) ?> · Die Unterschriften sind ausschließlich für Admins sichtbar.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
57
motorradig/views/admin/applications.php
Normal file
57
motorradig/views/admin/applications.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php $count = count($applications); ?>
|
||||
|
||||
<div class="container text-light mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-11">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h1 class="mb-0">Anträge</h1>
|
||||
<a href="/" class="btn btn-sm btn-outline-light">Zur Startseite</a>
|
||||
</div>
|
||||
|
||||
<div class="card text-dark">
|
||||
<div class="card-body">
|
||||
<p class="text-muted mb-3">
|
||||
<?= $count === 1 ? '1 eingereichter Antrag' : $count . ' eingereichte Anträge' ?>
|
||||
</p>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-sm align-middle mb-0">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th scope="col">Eingang</th>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">E-Mail</th>
|
||||
<th scope="col">Telefon</th>
|
||||
<th scope="col" class="text-right">Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($applications === []): ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-muted">Es sind noch keine Anträge eingegangen.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($applications as $application): ?>
|
||||
<tr>
|
||||
<td class="text-nowrap">
|
||||
<?= e($application->created_at ? date('d.m.Y H:i', strtotime($application->created_at)) : '') ?>
|
||||
</td>
|
||||
<td><?= e(trim($application->vorname . ' ' . $application->nachname)) ?></td>
|
||||
<td><?= e($application->email) ?></td>
|
||||
<td><?= e($application->telefon) ?></td>
|
||||
<td class="text-right">
|
||||
<a href="/admin/antraege/<?= e($application->id) ?>" class="btn btn-sm btn-primary">
|
||||
Ansehen
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -101,6 +101,7 @@
|
|||
<a class="dropdown-item" href="/admin/edit_activities">Seite: Aktivitäten bearbeiten</a>
|
||||
<a class="dropdown-item" href="/admin/upload_tourplan">Tourenplan(pdf) hochladen</a>
|
||||
<a class="dropdown-item" href="/admin/upload_mitgliedsantrag">Mitgliedsantrag(pdf) hochladen</a>
|
||||
<a class="dropdown-item" href="/admin/antraege">Anträge</a>
|
||||
<form action="/delete_guests" method="POST" style="margin:0;">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit" class="dropdown-item" style="width:100%;text-align:left;border:0;background:none;">Gast Mitglieder löschen</button>
|
||||
|
|
|
|||
|
|
@ -108,8 +108,16 @@
|
|||
<input id="ort_datum_1" name="ort_datum_1" class="form-control" value="<?= e(old('ort_datum_1')) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="unterschrift_1">Unterschrift</label>
|
||||
<input id="unterschrift_1" name="unterschrift_1" class="form-control" value="<?= e(old('unterschrift_1')) ?>">
|
||||
<label>Unterschrift</label>
|
||||
<div class="signature-pad" data-signature-pad>
|
||||
<canvas aria-label="Unterschrift Mitgliedsantrag"></canvas>
|
||||
<input type="hidden" name="unterschrift_1" value="">
|
||||
<div class="signature-pad-actions">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-clear-signature>Löschen</button>
|
||||
<span class="signature-pad-hint">Mit Maus oder Finger unterschreiben</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (error('unterschrift_1')): ?><span class="text-danger small"><?= e(error('unterschrift_1')) ?></span><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -162,8 +170,16 @@
|
|||
<input id="ort_datum_2" name="ort_datum_2" class="form-control" value="<?= e(old('ort_datum_2')) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="unterschrift_2">Unterschrift</label>
|
||||
<input id="unterschrift_2" name="unterschrift_2" class="form-control" value="<?= e(old('unterschrift_2')) ?>">
|
||||
<label>Unterschrift</label>
|
||||
<div class="signature-pad" data-signature-pad>
|
||||
<canvas aria-label="Unterschrift SEPA-Lastschriftmandat"></canvas>
|
||||
<input type="hidden" name="unterschrift_2" value="">
|
||||
<div class="signature-pad-actions">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-clear-signature>Löschen</button>
|
||||
<span class="signature-pad-hint">Mit Maus oder Finger unterschreiben</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (error('unterschrift_2')): ?><span class="text-danger small"><?= e(error('unterschrift_2')) ?></span><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -174,3 +190,146 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
function initSignaturePad(pad) {
|
||||
const canvas = pad.querySelector('canvas');
|
||||
const input = pad.querySelector('input[type="hidden"]');
|
||||
const clearButton = pad.querySelector('[data-clear-signature]');
|
||||
|
||||
if (!canvas || !input) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
let drawing = false;
|
||||
let dirty = false;
|
||||
let lastPoint = null;
|
||||
|
||||
function resetCanvas() {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const width = Math.max(280, Math.round(rect.width));
|
||||
const height = 160;
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
|
||||
canvas.width = Math.round(width * dpr);
|
||||
canvas.height = Math.round(height * dpr);
|
||||
canvas.style.height = height + 'px';
|
||||
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
ctx.lineWidth = 2;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.strokeStyle = '#111827';
|
||||
|
||||
dirty = false;
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
function getPoint(event) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
|
||||
return {
|
||||
x: event.clientX - rect.left,
|
||||
y: event.clientY - rect.top
|
||||
};
|
||||
}
|
||||
|
||||
function updateInput() {
|
||||
if (dirty) {
|
||||
input.value = canvas.toDataURL('image/png');
|
||||
}
|
||||
}
|
||||
|
||||
function drawDot(point) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(point.x, point.y, ctx.lineWidth / 2, 0, Math.PI * 2);
|
||||
ctx.fillStyle = ctx.strokeStyle;
|
||||
ctx.fill();
|
||||
dirty = true;
|
||||
updateInput();
|
||||
}
|
||||
|
||||
function start(event) {
|
||||
event.preventDefault();
|
||||
drawing = true;
|
||||
lastPoint = getPoint(event);
|
||||
|
||||
try {
|
||||
canvas.setPointerCapture(event.pointerId);
|
||||
} catch (e) {
|
||||
// Nicht kritisch.
|
||||
}
|
||||
|
||||
drawDot(lastPoint);
|
||||
}
|
||||
|
||||
function move(event) {
|
||||
if (!drawing || lastPoint === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
const point = getPoint(event);
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(lastPoint.x, lastPoint.y);
|
||||
ctx.lineTo(point.x, point.y);
|
||||
ctx.stroke();
|
||||
|
||||
lastPoint = point;
|
||||
dirty = true;
|
||||
updateInput();
|
||||
}
|
||||
|
||||
function end(event) {
|
||||
if (!drawing) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawing = false;
|
||||
lastPoint = null;
|
||||
updateInput();
|
||||
}
|
||||
|
||||
canvas.addEventListener('pointerdown', start);
|
||||
canvas.addEventListener('pointermove', move);
|
||||
canvas.addEventListener('pointerup', end);
|
||||
canvas.addEventListener('pointercancel', end);
|
||||
canvas.addEventListener('pointerleave', function (event) {
|
||||
if (drawing) {
|
||||
end(event);
|
||||
}
|
||||
});
|
||||
|
||||
if (clearButton) {
|
||||
clearButton.addEventListener('click', resetCanvas);
|
||||
}
|
||||
|
||||
resetCanvas();
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-signature-pad]').forEach(initSignaturePad);
|
||||
|
||||
const form = document.querySelector('form[action="/mitgliedsantrag"]');
|
||||
if (form) {
|
||||
form.addEventListener('submit', function (event) {
|
||||
let missing = false;
|
||||
|
||||
form.querySelectorAll('[data-signature-pad] input[type="hidden"]').forEach(function (input) {
|
||||
if (!input.value) {
|
||||
missing = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (missing) {
|
||||
event.preventDefault();
|
||||
alert('Bitte beide Unterschriften leisten.');
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue