Sprache bei Mail; hinzufügen Spendenverordnung
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Mail\PreApplicationMail;
|
|||||||
use App\Models\ChaosEvents;
|
use App\Models\ChaosEvents;
|
||||||
use App\Models\PreApplications;
|
use App\Models\PreApplications;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -14,6 +15,20 @@ use Nette\Utils\Random;
|
|||||||
|
|
||||||
class PreApplicationController extends Controller
|
class PreApplicationController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private function generateReferenceNumber($eventId, $passportType, $firstName){
|
||||||
|
$reference_number = null;
|
||||||
|
|
||||||
|
$ce = ChaosEvents::find($eventId);
|
||||||
|
$free_reference_number = false;
|
||||||
|
$counter = 1;
|
||||||
|
while(!$free_reference_number){
|
||||||
|
$reference_number = $ce->shortname . strtoupper($passportType) . '-' . strtoupper($firstName[0]) . Carbon::now()->format('ymd') . sprintf("%04d", $counter++);
|
||||||
|
$free_reference_number = !PreApplications::where('reference_number', $reference_number)->exists();
|
||||||
|
}
|
||||||
|
return $reference_number;
|
||||||
|
}
|
||||||
|
|
||||||
public function send(Request $request){
|
public function send(Request $request){
|
||||||
$event = $request->input('district_region');
|
$event = $request->input('district_region');
|
||||||
|
|
||||||
@@ -53,20 +68,13 @@ class PreApplicationController extends Controller
|
|||||||
//Log::debug('fn: ' . var_export($fn, true) . ' ln: ' . var_export($ln, true) . ' loc: ' . var_export($loc, true) . '');
|
//Log::debug('fn: ' . var_export($fn, true) . ' ln: ' . var_export($ln, true) . ' loc: ' . var_export($loc, true) . '');
|
||||||
|
|
||||||
if($fn && $ln && $loc){
|
if($fn && $ln && $loc){
|
||||||
|
|
||||||
$free_reference_number = false;
|
|
||||||
while(!$free_reference_number){
|
|
||||||
$reference_number = $ce->shortname . '-' . strtoupper($passport_type) . '-' . Random::generate(4, "0-9") . '-' . Random::generate(4, "0-9") . '-' . Random::generate(4, "0-9");
|
|
||||||
$free_reference_number = !PreApplications::where('reference_number', $reference_number)->exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$pa = new PreApplications();
|
$pa = new PreApplications();
|
||||||
$pa->first_name = $first_name;
|
$pa->first_name = $first_name;
|
||||||
$pa->last_name = $last_name;
|
$pa->last_name = $last_name;
|
||||||
$pa->location = $location;
|
$pa->location = $location;
|
||||||
$pa->passport_type = $passport_type;
|
$pa->passport_type = $passport_type;
|
||||||
$pa->reference_number = $reference_number;
|
$pa->reference_number = $this->generateReferenceNumber($event, $passport_type, $first_name);
|
||||||
$pa->event_id = $event;
|
$pa->event_id = $event;
|
||||||
$pa->email = $email;
|
$pa->email = $email;
|
||||||
$pa->save();
|
$pa->save();
|
||||||
@@ -101,13 +109,7 @@ class PreApplicationController extends Controller
|
|||||||
$pa->event_id = $request->input('district_region');
|
$pa->event_id = $request->input('district_region');
|
||||||
$pa->email = $request->input('mail');
|
$pa->email = $request->input('mail');
|
||||||
|
|
||||||
$ce = ChaosEvents::find($pa->event_id);
|
$pa->reference_number = $this->generateReferenceNumber($request->input('district_region'), $request->input('passport_type'), $request->input('first_name'));
|
||||||
$free_reference_number = false;
|
|
||||||
while(!$free_reference_number){
|
|
||||||
$reference_number = $ce->shortname . '-' . strtoupper($pa->passport_type) . '-' . Random::generate(4, "0-9") . '-' . Random::generate(4, "0-9") . '-' . Random::generate(4, "0-9");
|
|
||||||
$free_reference_number = !PreApplications::where('reference_number', $reference_number)->exists();
|
|
||||||
}
|
|
||||||
$pa->reference_number = $reference_number;
|
|
||||||
|
|
||||||
$pa->save();
|
$pa->save();
|
||||||
return ["messageStatus" => "success", "errorMessage" => ""];
|
return ["messageStatus" => "success", "errorMessage" => ""];
|
||||||
|
|||||||
@@ -9,19 +9,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
class WebsiteController extends Controller
|
class WebsiteController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->setLang($_COOKIE['lang'] ?? 'de');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setLang($lang)
|
|
||||||
{
|
|
||||||
if (!in_array($lang, ['de', 'en'])) {
|
|
||||||
$lang = 'de';
|
|
||||||
}
|
|
||||||
|
|
||||||
App::setLocale($lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
|
|||||||
28
app/Http/Middleware/SetLocale.php
Normal file
28
app/Http/Middleware/SetLocale.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class SetLocale
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
$lang = $request->cookie('lang', 'de');
|
||||||
|
if (!in_array($lang, ['de', 'en'])) {
|
||||||
|
$lang = 'de';
|
||||||
|
}
|
||||||
|
|
||||||
|
App::setLocale($lang);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ class PreApplicationMail extends Mailable
|
|||||||
public function __construct(protected App\Models\PreApplications $pa, protected string $lang = 'de')
|
public function __construct(protected App\Models\PreApplications $pa, protected string $lang = 'de')
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
$this->locale($this->lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +40,6 @@ class PreApplicationMail extends Mailable
|
|||||||
*/
|
*/
|
||||||
public function content(): Content
|
public function content(): Content
|
||||||
{
|
{
|
||||||
App::setLocale($this->lang);
|
|
||||||
return new Content(
|
return new Content(
|
||||||
view: 'mail.preapplication',
|
view: 'mail.preapplication',
|
||||||
with: ['pa' => $this->pa],
|
with: ['pa' => $this->pa],
|
||||||
@@ -53,13 +53,21 @@ class PreApplicationMail extends Mailable
|
|||||||
*/
|
*/
|
||||||
public function attachments(): array
|
public function attachments(): array
|
||||||
{
|
{
|
||||||
$lang = match (App::getLocale()) {
|
$langFb = match ($this->locale) {
|
||||||
'de' => 'dk',
|
'de' => 'dk',
|
||||||
'en' => 'ek',
|
'en' => 'ek',
|
||||||
default => 'dk',
|
default => 'dk',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$langDonation = match ($this->locale) {
|
||||||
|
'de' => '',
|
||||||
|
'en' => '_en',
|
||||||
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Attachment::fromPath(public_path('Dokumente/c3gov_fb5' . $lang . '.pdf'))
|
Attachment::fromPath(public_path('Dokumente/c3gov_fb5' . $langFb . '.pdf'))
|
||||||
|
->withMime('application/pdf'),
|
||||||
|
Attachment::fromPath(public_path('Dokumente/C3GovSpGV' . $langDonation . '.pdf'))
|
||||||
->withMime('application/pdf'),
|
->withMime('application/pdf'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
health: '/up',
|
health: '/up',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
//
|
$middleware->append(\App\Http\Middleware\SetLocale::class);
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions): void {
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -48,6 +48,11 @@
|
|||||||
"Composer\\Config::disableProcessTimeout",
|
"Composer\\Config::disableProcessTimeout",
|
||||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||||
],
|
],
|
||||||
|
"dev-bind": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve --host=0.0.0.0\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||||
|
],
|
||||||
|
|
||||||
"test": [
|
"test": [
|
||||||
"@php artisan config:clear --ansi",
|
"@php artisan config:clear --ansi",
|
||||||
"@php artisan test"
|
"@php artisan test"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ return [
|
|||||||
'body1' => "Hallo,<br /><br />Ihr Vorantrag wurde erfolgreich eingereicht.<br />Ihre Bearbeitungsnummer lautet: ",
|
'body1' => "Hallo,<br /><br />Ihr Vorantrag wurde erfolgreich eingereicht.<br />Ihre Bearbeitungsnummer lautet: ",
|
||||||
'body2' => "<br /><br />Folgende Daten wurden übermittelt:<br />",
|
'body2' => "<br /><br />Folgende Daten wurden übermittelt:<br />",
|
||||||
'body3' => "<br /><br />Bitte heben Sie diese E-Mail unbedingt auf.<br />Wenn möglich, drucken Sie das Formblatt 5, welches sich im E-Mail-Anhang befindet, aus. Tragen Sie Ihre Bearbeitungsnummer ein und bringen Sie es bei Abholung mit.",
|
'body3' => "<br /><br />Bitte heben Sie diese E-Mail unbedingt auf.<br />Wenn möglich, drucken Sie das Formblatt 5, welches sich im E-Mail-Anhang befindet, aus. Tragen Sie Ihre Bearbeitungsnummer ein und bringen Sie es bei Abholung mit.",
|
||||||
|
'body4' => "<br /><br />Wir bitten ebenfalls um die Beachtung der Spendengebührenverordnung, welche sich ebenfalls im Anhang befindet.",
|
||||||
'signature' => "Mit freundlichen Grüßen,<br /><br /><br />Ihr C3Gov - Ihr Amt in der Bezirksregion CCC"
|
'signature' => "Mit freundlichen Grüßen,<br /><br /><br />Ihr C3Gov - Ihr Amt in der Bezirksregion CCC"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ return [
|
|||||||
'body1' => "Hello,<br /><br />Your preliminary application has been successfully submitted.<br />Your reference number is:",
|
'body1' => "Hello,<br /><br />Your preliminary application has been successfully submitted.<br />Your reference number is:",
|
||||||
'body2' => "<br /><br />The following data has been submitted:<br />",
|
'body2' => "<br /><br />The following data has been submitted:<br />",
|
||||||
'body3' => "<br /><br />Please keep this email for your records. <br />If possible, print out form 5, which is attached to the email. Fill in your reference number and bring it with you when you pick up your hacker passport.",
|
'body3' => "<br /><br />Please keep this email for your records. <br />If possible, print out form 5, which is attached to the email. Fill in your reference number and bring it with you when you pick up your hacker passport.",
|
||||||
|
'body4' => "<br /><br />We also ask you to observe the donation regulation, which is also attached.",
|
||||||
'signature' => "Sincerely,<br /><br /><br />Your C3Gov – Your office in the CCC district region"
|
'signature' => "Sincerely,<br /><br /><br />Your C3Gov – Your office in the CCC district region"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -4,5 +4,7 @@
|
|||||||
{{ __('app.preapplication.firstname') }}: {{ $pa->first_name }}<br />
|
{{ __('app.preapplication.firstname') }}: {{ $pa->first_name }}<br />
|
||||||
{{ __('app.preapplication.lastname') }}: {{ $pa->last_name }}<br />
|
{{ __('app.preapplication.lastname') }}: {{ $pa->last_name }}<br />
|
||||||
{{ __('app.preapplication.location') }}: {{ $pa->location }}<br />
|
{{ __('app.preapplication.location') }}: {{ $pa->location }}<br />
|
||||||
{!! __('mail.preapplication.body3') !!}<br /><br />
|
{!! __('mail.preapplication.body3') !!}
|
||||||
|
{!! __('mail.preapplication.body4') !!}
|
||||||
|
<br /><br />
|
||||||
{!! __('mail.preapplication.signature') !!}
|
{!! __('mail.preapplication.signature') !!}
|
||||||
|
|||||||
Reference in New Issue
Block a user