Compare commits
41 Commits
7c656afce8
...
9d41cdb010
Author | SHA1 | Date |
---|---|---|
|
9d41cdb010 | |
|
e429d7de76 | |
|
52a6491488 | |
|
9628ba34d2 | |
|
5361c3930f | |
|
e97d39abd7 | |
|
419b4227eb | |
|
63b57f3da7 | |
|
0ea3f4adce | |
|
363c4360b8 | |
|
3182dc7edd | |
|
7346c2da47 | |
|
95a466ff22 | |
|
e047b9a4f2 | |
|
0311787eec | |
|
fba42fa1d8 | |
|
fe50cf129f | |
|
27f805700e | |
|
f33a23ecc3 | |
|
103e13966f | |
|
b2117cdecf | |
|
177b661d50 | |
|
1c0a2361d6 | |
|
4ed6375202 | |
|
f9c4e32ba2 | |
|
1780e3bce8 | |
|
bf4cfdf7fd | |
|
057002b8e8 | |
|
99731fd08f | |
|
919041d2cf | |
|
47b5abc0f1 | |
|
ea79290435 | |
|
4f21dfceee | |
|
196b81a82d | |
|
83d721c1ca | |
|
027a159a1c | |
|
da8dd12dad | |
|
a482e16739 | |
|
010ad80793 | |
|
741a4a24b7 | |
|
4ecf2f4483 |
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es2021": true
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:vue/vue3-recommended",
|
|
||||||
"prettier"
|
|
||||||
],
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": "latest",
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"vue"
|
|
||||||
],
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.vue"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"vue/multi-word-component-names": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ use App\Actions\DbMaintainAction;
|
||||||
use App\Form\Actions\PreventionRememberAction;
|
use App\Form\Actions\PreventionRememberAction;
|
||||||
use App\Initialize\InitializeMembers;
|
use App\Initialize\InitializeMembers;
|
||||||
use App\Invoice\Actions\InvoiceSendAction;
|
use App\Invoice\Actions\InvoiceSendAction;
|
||||||
|
use App\Prevention\Actions\YearlyRememberAction;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ class Kernel extends ConsoleKernel
|
||||||
InitializeMembers::class,
|
InitializeMembers::class,
|
||||||
DbMaintainAction::class,
|
DbMaintainAction::class,
|
||||||
PreventionRememberAction::class,
|
PreventionRememberAction::class,
|
||||||
|
YearlyRememberAction::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +36,7 @@ class Kernel extends ConsoleKernel
|
||||||
$schedule->command(InitializeMembers::class)->dailyAt('03:00');
|
$schedule->command(InitializeMembers::class)->dailyAt('03:00');
|
||||||
$schedule->command(PreventionRememberAction::class)->dailyAt('11:00');
|
$schedule->command(PreventionRememberAction::class)->dailyAt('11:00');
|
||||||
$schedule->command(InvoiceSendAction::class)->dailyAt('10:00');
|
$schedule->command(InvoiceSendAction::class)->dailyAt('10:00');
|
||||||
|
$schedule->command(YearlyRememberAction::class)->dailyAt('09:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,18 +13,18 @@ class PreventionRememberAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
public string $commandSignature = 'prevention:remember';
|
public string $commandSignature = 'prevention:remember-forms';
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$query = Participant::whereHas(
|
$query = Participant::whereHas(
|
||||||
'form',
|
'form',
|
||||||
fn ($form) => $form
|
fn($form) => $form
|
||||||
->where('needs_prevention', true)
|
->where('needs_prevention', true)
|
||||||
->where('from', '>=', now())
|
->where('from', '>=', now())
|
||||||
)
|
)
|
||||||
->where(
|
->where(
|
||||||
fn ($q) => $q
|
fn($q) => $q
|
||||||
->where('last_remembered_at', '<=', now()->subWeeks(2))
|
->where('last_remembered_at', '<=', now()->subWeeks(2))
|
||||||
->orWhereNull('last_remembered_at')
|
->orWhereNull('last_remembered_at')
|
||||||
);
|
);
|
||||||
|
@ -33,7 +33,7 @@ class PreventionRememberAction
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($participant->getFields()->getMailRecipient() === null || count($participant->preventions()) === 0) {
|
if ($participant->getFields()->getMailRecipient() === null || $participant->preventions()->count() === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class PreventionRememberAction
|
||||||
->placeholder('formname', $participant->form->name)
|
->placeholder('formname', $participant->form->name)
|
||||||
->append($participant->form->prevention_text);
|
->append($participant->form->prevention_text);
|
||||||
|
|
||||||
Mail::send(new PreventionRememberMail($participant, $body));
|
Mail::send(new PreventionRememberMail($participant, $body, $participant->preventions()));
|
||||||
|
|
||||||
$participant->update(['last_remembered_at' => now()]);
|
$participant->update(['last_remembered_at' => now()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Laravel\Scout\Searchable;
|
use Laravel\Scout\Searchable;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
@ -81,20 +82,15 @@ class Participant extends Model implements Preventable
|
||||||
Mail::to($this->getMailRecipient())->queue(new ConfirmRegistrationMail($this));
|
Mail::to($this->getMailRecipient())->queue(new ConfirmRegistrationMail($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preventableLayout(): string
|
|
||||||
{
|
|
||||||
return 'mail.prevention.prevention-remember-participant';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function preventions(): array
|
public function preventions(): Collection
|
||||||
{
|
{
|
||||||
return $this->member?->preventions($this->form->from) ?: [];
|
return $this->member?->preventions($this->form->from) ?: collect([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMailRecipient(): stdClass
|
public function getMailRecipient(): ?stdClass
|
||||||
{
|
{
|
||||||
return $this->getFields()->getMailRecipient();
|
return $this->getFields()->getMailRecipient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,7 @@ class EditorData extends Data implements Editorable
|
||||||
public string $version,
|
public string $version,
|
||||||
public array $blocks,
|
public array $blocks,
|
||||||
public int $time
|
public int $time
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
public function placeholder(string $search, string $replacement): self
|
public function placeholder(string $search, string $replacement): self
|
||||||
{
|
{
|
||||||
|
@ -30,7 +29,12 @@ class EditorData extends Data implements Editorable
|
||||||
*/
|
*/
|
||||||
public function hasAll(array $wanted): bool
|
public function hasAll(array $wanted): bool
|
||||||
{
|
{
|
||||||
return collect($wanted)->first(fn ($search) => !str(json_encode($this->blocks))->contains($search)) === null;
|
return collect($wanted)->doesntContain(fn($search) => !str(json_encode($this->blocks))->contains($search));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasNot(string $should): bool
|
||||||
|
{
|
||||||
|
return !str(json_encode($this->blocks))->contains($should);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function default(): self
|
public static function default(): self
|
||||||
|
@ -65,7 +69,7 @@ class EditorData extends Data implements Editorable
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'data' => [
|
'data' => [
|
||||||
'style' => 'unordered',
|
'style' => 'unordered',
|
||||||
'items' => collect($replacements)->map(fn ($replacement) => [
|
'items' => collect($replacements)->map(fn($replacement) => [
|
||||||
'content' => $replacement,
|
'content' => $replacement,
|
||||||
'items' => [],
|
'items' => [],
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -48,8 +48,7 @@ class FilterScope extends ScoutFilter
|
||||||
public ?bool $hasBirthday = null,
|
public ?bool $hasBirthday = null,
|
||||||
public ?bool $hasSvk = null,
|
public ?bool $hasSvk = null,
|
||||||
public ?bool $hasVk = null,
|
public ?bool $hasVk = null,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $options
|
* @param array<string, mixed> $options
|
||||||
|
@ -110,20 +109,20 @@ class FilterScope extends ScoutFilter
|
||||||
}
|
}
|
||||||
if ($this->subactivityIds && $this->activityIds) {
|
if ($this->subactivityIds && $this->activityIds) {
|
||||||
$combinations = $this->combinations($this->activityIds, $this->subactivityIds)
|
$combinations = $this->combinations($this->activityIds, $this->subactivityIds)
|
||||||
->map(fn ($combination) => implode('|', $combination))
|
->map(fn($combination) => implode('|', $combination))
|
||||||
->map(fn ($combination) => str($combination)->wrap('"'));
|
->map(fn($combination) => str($combination)->wrap('"'));
|
||||||
$filter->push($this->inExpression('memberships.both', $combinations));
|
$filter->push($this->inExpression('memberships.both', $combinations));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->memberships as $membership) {
|
foreach ($this->memberships as $membership) {
|
||||||
$filter->push($this->inExpression('memberships.with_group', $this->possibleValuesForMembership($membership)->map(fn ($value) => str($value)->wrap('"'))));
|
$filter->push($this->inExpression('memberships.with_group', $this->possibleValuesForMembership($membership)->map(fn($value) => str($value)->wrap('"'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->exclude)) {
|
if (count($this->exclude)) {
|
||||||
$filter->push($this->notInExpression('id', $this->exclude));
|
$filter->push($this->notInExpression('id', $this->exclude));
|
||||||
}
|
}
|
||||||
|
|
||||||
$andFilter = $filter->map(fn ($expression) => "($expression)")->implode(' AND ');
|
$andFilter = $filter->map(fn($expression) => "($expression)")->implode(' AND ');
|
||||||
|
|
||||||
$options['filter'] = $this->implode(collect([$andFilter])->push($this->inExpression('id', $this->include)), 'OR');
|
$options['filter'] = $this->implode(collect([$andFilter])->push($this->inExpression('id', $this->include)), 'OR');
|
||||||
$options['sort'] = ['lastname:asc', 'firstname:asc'];
|
$options['sort'] = ['lastname:asc', 'firstname:asc'];
|
||||||
|
@ -137,7 +136,7 @@ class FilterScope extends ScoutFilter
|
||||||
*/
|
*/
|
||||||
protected function implode(Collection $values, string $between): string
|
protected function implode(Collection $values, string $between): string
|
||||||
{
|
{
|
||||||
return $values->filter(fn ($expression) => $expression)->implode(" {$between} ");
|
return $values->filter(fn($expression) => $expression)->implode(" {$between} ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +176,7 @@ class FilterScope extends ScoutFilter
|
||||||
$membership['activity_ids'] = count($membership['activity_ids']) === 0 ? Activity::pluck('id')->toArray() : $membership['activity_ids'];
|
$membership['activity_ids'] = count($membership['activity_ids']) === 0 ? Activity::pluck('id')->toArray() : $membership['activity_ids'];
|
||||||
$membership['subactivity_ids'] = count($membership['subactivity_ids']) === 0 ? Subactivity::pluck('id')->toArray() : $membership['subactivity_ids'];
|
$membership['subactivity_ids'] = count($membership['subactivity_ids']) === 0 ? Subactivity::pluck('id')->toArray() : $membership['subactivity_ids'];
|
||||||
return $this->combinations($membership['group_ids'], $membership['activity_ids'], $membership['subactivity_ids'])
|
return $this->combinations($membership['group_ids'], $membership['activity_ids'], $membership['subactivity_ids'])
|
||||||
->map(fn ($combination) => collect($combination)->implode('|'));
|
->map(fn($combination) => collect($combination)->implode('|'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,7 +190,7 @@ class FilterScope extends ScoutFilter
|
||||||
|
|
||||||
if (!count($otherParts)) {
|
if (!count($otherParts)) {
|
||||||
/** @var Collection<int, Collection<int, int>> */
|
/** @var Collection<int, Collection<int, int>> */
|
||||||
return collect($firstPart)->map(fn ($p) => [$p]);
|
return collect($firstPart)->map(fn($p) => [$p]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Collection<int, mixed> */
|
/** @var Collection<int, mixed> */
|
||||||
|
|
|
@ -13,6 +13,8 @@ use App\Nami\HasNamiField;
|
||||||
use App\Nationality;
|
use App\Nationality;
|
||||||
use App\Payment\Subscription;
|
use App\Payment\Subscription;
|
||||||
use App\Pdf\Sender;
|
use App\Pdf\Sender;
|
||||||
|
use App\Prevention\Contracts\Preventable;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
use App\Region;
|
use App\Region;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
@ -35,12 +37,14 @@ use Zoomyboy\Phone\HasPhoneNumbers;
|
||||||
use App\Prevention\Enums\Prevention;
|
use App\Prevention\Enums\Prevention;
|
||||||
use Database\Factories\Member\MemberFactory;
|
use Database\Factories\Member\MemberFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $subscription_name
|
* @property string $subscription_name
|
||||||
* @property int $pending_payment
|
* @property int $pending_payment
|
||||||
*/
|
*/
|
||||||
class Member extends Model implements Geolocatable
|
class Member extends Model implements Geolocatable, Preventable
|
||||||
{
|
{
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
|
@ -191,7 +195,25 @@ class Member extends Model implements Geolocatable
|
||||||
|
|
||||||
protected function getAusstand(): int
|
protected function getAusstand(): int
|
||||||
{
|
{
|
||||||
return (int) $this->invoicePositions()->whereHas('invoice', fn ($query) => $query->whereNeedsPayment())->sum('price');
|
return (int) $this->invoicePositions()->whereHas('invoice', fn($query) => $query->whereNeedsPayment())->sum('price');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMailRecipient(): ?stdClass
|
||||||
|
{
|
||||||
|
if (!$this->fullname) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->email) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) ['name' => $this->fullname, 'email' => $this->email];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preventableSubject(): string
|
||||||
|
{
|
||||||
|
return 'Nachweise erforderlich';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------- Relations ----------------------------------
|
// ---------------------------------- Relations ----------------------------------
|
||||||
|
@ -339,7 +361,7 @@ class Member extends Model implements Geolocatable
|
||||||
return $query->addSelect([
|
return $query->addSelect([
|
||||||
'pending_payment' => InvoicePosition::selectRaw('SUM(price)')
|
'pending_payment' => InvoicePosition::selectRaw('SUM(price)')
|
||||||
->whereColumn('invoice_positions.member_id', 'members.id')
|
->whereColumn('invoice_positions.member_id', 'members.id')
|
||||||
->whereHas('invoice', fn ($query) => $query->whereNeedsPayment()),
|
->whereHas('invoice', fn($query) => $query->whereNeedsPayment()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +372,7 @@ class Member extends Model implements Geolocatable
|
||||||
*/
|
*/
|
||||||
public function scopeWhereHasPendingPayment(Builder $query): Builder
|
public function scopeWhereHasPendingPayment(Builder $query): Builder
|
||||||
{
|
{
|
||||||
return $query->whereHas('invoicePositions', fn ($q) => $q->whereHas('invoice', fn ($q) => $q->whereNeedsPayment()));
|
return $query->whereHas('invoicePositions', fn($q) => $q->whereHas('invoice', fn($q) => $q->whereNeedsPayment()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,32 +386,47 @@ class Member extends Model implements Geolocatable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, Prevention>
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function preventions(?Carbon $date = null): array
|
public function preventions(?Carbon $date = null): Collection
|
||||||
{
|
{
|
||||||
$date = $date ?: now();
|
$date = $date ?: now();
|
||||||
|
|
||||||
/** @var array<int, Prevention> */
|
/** @var Collection<int, PreventionData> */
|
||||||
$preventions = [];
|
$preventions = collect([]);
|
||||||
|
|
||||||
if ($this->efz === null || $this->efz->diffInYears($date) >= 5) {
|
if ($this->efz === null || $this->efz->diffInYears($date) >= 5) {
|
||||||
$preventions[] = Prevention::EFZ;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::EFZ,
|
||||||
|
'expires' => $this->efz === null ? now() : $this->efz->addYears(5)
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->has_vk) {
|
if (!$this->has_vk) {
|
||||||
$preventions[] = Prevention::VK;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::VK,
|
||||||
|
'expires' => now(),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->more_ps_at === null) {
|
if ($this->more_ps_at === null) {
|
||||||
if ($this->ps_at === null) {
|
if ($this->ps_at === null) {
|
||||||
$preventions[] = Prevention::PS;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::PS,
|
||||||
|
'expires' => now(),
|
||||||
|
]));
|
||||||
} else if ($this->ps_at->diffInYears($date) >= 5) {
|
} else if ($this->ps_at->diffInYears($date) >= 5) {
|
||||||
$preventions[] = Prevention::MOREPS;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::MOREPS,
|
||||||
|
'expires' => $this->ps_at->addYears(5),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->more_ps_at === null || $this->more_ps_at->diffInYears($date) >= 5) {
|
if ($this->more_ps_at === null || $this->more_ps_at->diffInYears($date) >= 5) {
|
||||||
$preventions[] = Prevention::MOREPS;
|
$preventions->push(PreventionData::from([
|
||||||
|
'type' => Prevention::MOREPS,
|
||||||
|
'expires' => $this->more_ps_at->addYears(5),
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +536,7 @@ class Member extends Model implements Geolocatable
|
||||||
'name' => $this->fullname,
|
'name' => $this->fullname,
|
||||||
'address' => $this->address,
|
'address' => $this->address,
|
||||||
'zipLocation' => $this->zip . ' ' . $this->location,
|
'zipLocation' => $this->zip . ' ' . $this->location,
|
||||||
'mglnr' => Lazy::create(fn () => 'Mglnr.: ' . $this->nami_id),
|
'mglnr' => Lazy::create(fn() => 'Mglnr.: ' . $this->nami_id),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +545,7 @@ class Member extends Model implements Geolocatable
|
||||||
*/
|
*/
|
||||||
public static function forSelect(): array
|
public static function forSelect(): array
|
||||||
{
|
{
|
||||||
return static::select(['id', 'firstname', 'lastname'])->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname])->toArray();
|
return static::select(['id', 'firstname', 'lastname'])->get()->map(fn($member) => ['id' => $member->id, 'name' => $member->fullname])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------- Geolocation --------------------------------
|
// -------------------------------- Geolocation --------------------------------
|
||||||
|
@ -567,7 +604,7 @@ class Member extends Model implements Geolocatable
|
||||||
'age_group_icon' => $this->ageGroupMemberships->first()?->subactivity->slug,
|
'age_group_icon' => $this->ageGroupMemberships->first()?->subactivity->slug,
|
||||||
'is_leader' => $this->leaderMemberships()->count() > 0,
|
'is_leader' => $this->leaderMemberships()->count() > 0,
|
||||||
'memberships' => $this->memberships()->active()->get()
|
'memberships' => $this->memberships()->active()->get()
|
||||||
->map(fn ($membership) => [...$membership->only('activity_id', 'subactivity_id'), 'both' => $membership->activity_id . '|' . $membership->subactivity_id, 'with_group' => $membership->group_id . '|' . $membership->activity_id . '|' . $membership->subactivity_id]),
|
->map(fn($membership) => [...$membership->only('activity_id', 'subactivity_id'), 'both' => $membership->activity_id . '|' . $membership->subactivity_id, 'with_group' => $membership->group_id . '|' . $membership->activity_id . '|' . $membership->subactivity_id]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,11 +133,11 @@ class MemberResource extends JsonResource
|
||||||
}
|
}
|
||||||
|
|
||||||
$activities = Activity::with('subactivities')->get();
|
$activities = Activity::with('subactivities')->get();
|
||||||
$createActivities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get();
|
$createActivities = Activity::remote()->with(['subactivities' => fn($q) => $q->remote()])->get();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'filterActivities' => Activity::where('is_filterable', true)->pluck('name', 'id'),
|
'filterActivities' => Activity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'filterSubactivities' => Subactivity::where('is_filterable', true)->pluck('name', 'id'),
|
'filterSubactivities' => Subactivity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'formActivities' => $activities->pluck('name', 'id'),
|
'formActivities' => $activities->pluck('name', 'id'),
|
||||||
'formSubactivities' => $activities->map(function (Activity $activity) {
|
'formSubactivities' => $activities->map(function (Activity $activity) {
|
||||||
return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id];
|
return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id];
|
||||||
|
@ -155,7 +155,7 @@ class MemberResource extends JsonResource
|
||||||
'genders' => Gender::pluck('name', 'id'),
|
'genders' => Gender::pluck('name', 'id'),
|
||||||
'billKinds' => BillKind::forSelect(),
|
'billKinds' => BillKind::forSelect(),
|
||||||
'nationalities' => Nationality::pluck('name', 'id'),
|
'nationalities' => Nationality::pluck('name', 'id'),
|
||||||
'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]),
|
'members' => Member::ordered()->get()->map(fn($member) => ['id' => $member->id, 'name' => $member->fullname]),
|
||||||
'links' => [
|
'links' => [
|
||||||
'index' => route('member.index'),
|
'index' => route('member.index'),
|
||||||
'create' => route('member.create'),
|
'create' => route('member.create'),
|
||||||
|
@ -210,6 +210,14 @@ class MemberResource extends JsonResource
|
||||||
'multiply_pv' => false,
|
'multiply_pv' => false,
|
||||||
'multiply_more_pv' => false,
|
'multiply_more_pv' => false,
|
||||||
'keepdata' => false,
|
'keepdata' => false,
|
||||||
|
'bank_account' => [
|
||||||
|
'iban' => '',
|
||||||
|
'bic' => '',
|
||||||
|
'blz' => '',
|
||||||
|
'bank_name' => '',
|
||||||
|
'person' => '',
|
||||||
|
'account_number' => '',
|
||||||
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Prevention\Actions;
|
namespace App\Prevention\Actions;
|
||||||
|
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
@ -13,7 +14,10 @@ class SettingApiAction
|
||||||
public function handle(): JsonResponse
|
public function handle(): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => app(PreventionSettings::class)->toArray(),
|
'data' => app(PreventionSettings::class)->toFrontend(),
|
||||||
|
'meta' => [
|
||||||
|
'preventAgainsts' => Prevention::values(),
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Prevention\Actions;
|
||||||
|
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
use App\Lib\Events\Succeeded;
|
use App\Lib\Events\Succeeded;
|
||||||
|
use App\Member\FilterScope;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
@ -19,6 +20,10 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'formmail' => 'array',
|
'formmail' => 'array',
|
||||||
|
'yearlymail' => 'array',
|
||||||
|
'weeks' => 'required|numeric|gte:0',
|
||||||
|
'freshRememberInterval' => 'required|numeric|gte:0',
|
||||||
|
'active' => 'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +31,12 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
$settings = app(PreventionSettings::class);
|
$settings = app(PreventionSettings::class);
|
||||||
$settings->formmail = EditorData::from($request->formmail);
|
$settings->formmail = EditorData::from($request->formmail);
|
||||||
|
$settings->yearlymail = EditorData::from($request->yearlymail);
|
||||||
|
$settings->weeks = $request->weeks;
|
||||||
|
$settings->freshRememberInterval = $request->freshRememberInterval;
|
||||||
|
$settings->active = $request->active;
|
||||||
|
$settings->yearlyMemberFilter = FilterScope::from($request->yearlyMemberFilter);
|
||||||
|
$settings->preventAgainst = $request->preventAgainst;
|
||||||
$settings->save();
|
$settings->save();
|
||||||
|
|
||||||
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Actions;
|
||||||
|
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
|
use App\Prevention\Mails\YearlyMail;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class YearlyRememberAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public string $commandSignature = 'prevention:remember-yearly';
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$settings = app(PreventionSettings::class);
|
||||||
|
$expireDate = now()->addWeeks($settings->weeks);
|
||||||
|
|
||||||
|
if (!$settings->active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
||||||
|
// @todo add this check to FilterScope
|
||||||
|
if ($member->getMailRecipient() === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$noticePreventions = $member->preventions($expireDate)
|
||||||
|
->filter(fn($prevention) => $prevention->expiresAt($expireDate))
|
||||||
|
->filter(fn($p) => $p->appliesToSettings($settings));
|
||||||
|
|
||||||
|
if ($noticePreventions->count() === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mail::send($this->createMail($member, $noticePreventions));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
||||||
|
// @todo add this check to FilterScope
|
||||||
|
if ($member->getMailRecipient() === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$preventions = $member->preventions()
|
||||||
|
->filter(fn($prevention) => $prevention->expiresAt(now()))
|
||||||
|
->filter(fn($p) => $p->appliesToSettings($settings));
|
||||||
|
|
||||||
|
if ($preventions->count() === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache::remember(
|
||||||
|
'prevention-' . $member->id,
|
||||||
|
(int) now()->diffInSeconds(now()->addWeeks($settings->freshRememberInterval)),
|
||||||
|
function () use ($member, $preventions) {
|
||||||
|
Mail::send($this->createMail($member, $preventions));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection<int, PreventionData> $preventions
|
||||||
|
*/
|
||||||
|
protected function createMail(Member $member, Collection $preventions): YearlyMail
|
||||||
|
{
|
||||||
|
$body = app(PreventionSettings::class)->refresh()->yearlymail;
|
||||||
|
return new YearlyMail($member, $body, $preventions);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
namespace App\Prevention\Contracts;
|
namespace App\Prevention\Contracts;
|
||||||
|
|
||||||
use App\Prevention\Enums\Prevention;
|
use App\Prevention\Data\PreventionData;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
interface Preventable
|
interface Preventable
|
||||||
{
|
{
|
||||||
|
|
||||||
public function preventableLayout(): string;
|
|
||||||
public function preventableSubject(): string;
|
public function preventableSubject(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, Prevention>
|
* @return Collection<int, PreventionData>
|
||||||
*/
|
*/
|
||||||
public function preventions(): array;
|
public function preventions(): Collection;
|
||||||
|
|
||||||
public function getMailRecipient(): stdClass;
|
public function getMailRecipient(): ?stdClass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Data;
|
||||||
|
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
|
use App\Prevention\PreventionSettings;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
|
||||||
|
class PreventionData extends Data
|
||||||
|
{
|
||||||
|
public function __construct(public Prevention $type, public Carbon $expires) {}
|
||||||
|
|
||||||
|
public function expiresAt(Carbon $date): bool
|
||||||
|
{
|
||||||
|
return $this->expires->isSameDay($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function text(): string
|
||||||
|
{
|
||||||
|
return str($this->type->text())->when(
|
||||||
|
!$this->expiresAt(now()),
|
||||||
|
fn($str) => $str->append(' (fällig am ' . $this->expires->format('d.m.Y') . ')')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function appliesToSettings(PreventionSettings $settings): bool
|
||||||
|
{
|
||||||
|
return in_array($this->type->name, $settings->preventAgainst);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
namespace App\Prevention\Enums;
|
namespace App\Prevention\Enums;
|
||||||
|
|
||||||
use App\Member\Member;
|
use App\Prevention\Data\PreventionData;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
enum Prevention
|
enum Prevention
|
||||||
|
@ -39,15 +38,26 @@ enum Prevention
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, self> $preventions
|
* @param Collection<int, PreventionData> $preventions
|
||||||
* @return Collection<int, array{letter: string, value: bool, tooltip: string}>
|
* @return Collection<int, array{letter: string, value: bool, tooltip: string}>
|
||||||
*/
|
*/
|
||||||
public static function items(array $preventions): Collection
|
public static function items(Collection $preventions): Collection
|
||||||
{
|
{
|
||||||
return collect(static::cases())->map(fn ($case) => [
|
return collect(static::cases())->map(fn($case) => [
|
||||||
'letter' => $case->letter(),
|
'letter' => $case->letter(),
|
||||||
'value' => !in_array($case, $preventions),
|
'value' => $preventions->pluck('type')->doesntContain($case),
|
||||||
'tooltip' => $case->tooltip(!in_array($case, $preventions)),
|
'tooltip' => $case->tooltip($preventions->pluck('type')->doesntContain($case)),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function values(): array
|
||||||
|
{
|
||||||
|
return collect(static::cases())->map(fn($case) => [
|
||||||
|
'id' => $case->name,
|
||||||
|
'name' => $case->text(),
|
||||||
|
])->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ namespace App\Prevention\Mails;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
use App\Prevention\Contracts\Preventable;
|
use App\Prevention\Contracts\Preventable;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Attachment;
|
use Illuminate\Mail\Attachment;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Mail\Mailables\Content;
|
use Illuminate\Mail\Mailables\Content;
|
||||||
use Illuminate\Mail\Mailables\Envelope;
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class PreventionRememberMail extends Mailable
|
class PreventionRememberMail extends Mailable
|
||||||
{
|
{
|
||||||
|
@ -20,12 +22,13 @@ class PreventionRememberMail extends Mailable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
|
* @param Collection<int, PreventionData> $preventions
|
||||||
*/
|
*/
|
||||||
public function __construct(public Preventable $preventable, public EditorData $bodyText)
|
public function __construct(public Preventable $preventable, public EditorData $bodyText, public Collection $preventions)
|
||||||
{
|
{
|
||||||
$this->settings = app(InvoiceSettings::class);
|
$this->settings = app(InvoiceSettings::class);
|
||||||
$this->bodyText = $this->bodyText
|
$this->bodyText = $this->bodyText
|
||||||
->replaceWithList('wanted', collect($preventable->preventions())->map(fn ($prevention) => $prevention->text())->toArray());
|
->replaceWithList('wanted', $preventions->map(fn($prevention) => $prevention->text())->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +51,7 @@ class PreventionRememberMail extends Mailable
|
||||||
public function content()
|
public function content()
|
||||||
{
|
{
|
||||||
return new Content(
|
return new Content(
|
||||||
markdown: $this->preventable->preventableLayout(),
|
markdown: 'mail.prevention.prevention-remember-participant',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Prevention\Mails;
|
||||||
|
|
||||||
|
use App\Invoice\InvoiceSettings;
|
||||||
|
use App\Lib\Editor\EditorData;
|
||||||
|
use App\Prevention\Contracts\Preventable;
|
||||||
|
use App\Prevention\Data\PreventionData;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Attachment;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class YearlyMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public InvoiceSettings $settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
* @param Collection<int, PreventionData> $preventions
|
||||||
|
*/
|
||||||
|
public function __construct(public Preventable $preventable, public EditorData $bodyText, public Collection $preventions)
|
||||||
|
{
|
||||||
|
$this->settings = app(InvoiceSettings::class);
|
||||||
|
$this->bodyText = $this->bodyText
|
||||||
|
->replaceWithList('wanted', $preventions->map(fn($prevention) => $prevention->text())->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Envelope
|
||||||
|
*/
|
||||||
|
public function envelope()
|
||||||
|
{
|
||||||
|
return (new Envelope(
|
||||||
|
subject: $this->preventable->preventableSubject(),
|
||||||
|
))->to($this->preventable->getMailRecipient()->email, $this->preventable->getMailRecipient()->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Content
|
||||||
|
*/
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
markdown: 'mail.prevention.prevention-remember-participant',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,12 +3,23 @@
|
||||||
namespace App\Prevention;
|
namespace App\Prevention;
|
||||||
|
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
|
use App\Member\FilterScope;
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class PreventionSettings extends LocalSettings
|
class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public EditorData $formmail;
|
public EditorData $formmail;
|
||||||
|
public EditorData $yearlymail;
|
||||||
|
public int $weeks;
|
||||||
|
public int $freshRememberInterval;
|
||||||
|
public bool $active;
|
||||||
|
public FilterScope $yearlyMemberFilter;
|
||||||
|
/**
|
||||||
|
* @var array<int, string>
|
||||||
|
* @todo Create collection cast to Collection of enums
|
||||||
|
*/
|
||||||
|
public array $preventAgainst;
|
||||||
|
|
||||||
public static function group(): string
|
public static function group(): string
|
||||||
{
|
{
|
||||||
|
@ -27,4 +38,17 @@ class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo return int value here and handle this in vue with a number field that only expects integers
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toFrontend(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
...$this->toArray(),
|
||||||
|
'weeks' => (string) $this->weeks,
|
||||||
|
'freshRememberInterval' => (string) $this->freshRememberInterval,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,5 @@ sudo mysql adrema < db.tmp
|
||||||
rm db.tmp
|
rm db.tmp
|
||||||
|
|
||||||
echo 'app(\App\Form\FormSettings::class)->fill(["registerUrl" => "http://stammsilva.test/anmeldung/{slug}/register", "clearCacheUrl" => "http://stammsilva.test/adrema/clear-cache"])->save();' | php artisan tinker
|
echo 'app(\App\Form\FormSettings::class)->fill(["registerUrl" => "http://stammsilva.test/anmeldung/{slug}/register", "clearCacheUrl" => "http://stammsilva.test/adrema/clear-cache"])->save();' | php artisan tinker
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -119,7 +119,7 @@ return [
|
||||||
|
|
||||||
'options' => [
|
'options' => [
|
||||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
|
||||||
],
|
],
|
||||||
|
|
||||||
'default' => [
|
'default' => [
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Member\FilterScope;
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
|
||||||
|
return new class extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->migrator->add('prevention.yearlymail', ['time' => 1, 'blocks' => [], 'version' => '1.0']);
|
||||||
|
$this->migrator->add('prevention.weeks', 8);
|
||||||
|
$this->migrator->add('prevention.freshRememberInterval', 12);
|
||||||
|
$this->migrator->add('prevention.active', false);
|
||||||
|
$this->migrator->add('prevention.yearlyMemberFilter', FilterScope::from([])->toArray());
|
||||||
|
$this->migrator->add('prevention.preventAgainst', []);
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,43 @@
|
||||||
|
import eslint from '@eslint/js';
|
||||||
|
import eslintPluginVue from 'eslint-plugin-vue';
|
||||||
|
import typescriptEslint from 'typescript-eslint';
|
||||||
|
import globals from 'globals';
|
||||||
|
|
||||||
|
export default typescriptEslint.config(
|
||||||
|
{ ignores: ['*.d.ts', '**/coverage', '**/dist'] },
|
||||||
|
{
|
||||||
|
extends: [
|
||||||
|
eslint.configs.recommended,
|
||||||
|
...typescriptEslint.configs.recommended,
|
||||||
|
...eslintPluginVue.configs['flat/recommended'],
|
||||||
|
],
|
||||||
|
files: ['**/*.{ts,vue}'],
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: 'module',
|
||||||
|
globals: globals.browser,
|
||||||
|
parserOptions: {
|
||||||
|
parser: typescriptEslint.parser,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'indent': ['error', 4],
|
||||||
|
'vue/html-indent': ['error', 4],
|
||||||
|
'linebreak-style': ['error', 'unix'],
|
||||||
|
'quotes': ['error', 'single'],
|
||||||
|
'semi': ['error', 'always'],
|
||||||
|
'vue/no-reserved-component-names': 'off',
|
||||||
|
'vue/multi-word-component-names': 'off',
|
||||||
|
'vue/max-attributes-per-line': 'off',
|
||||||
|
'vue/singleline-html-element-content-newline': 'off',
|
||||||
|
"vue/first-attribute-linebreak": ["error", {
|
||||||
|
"singleline": "beside",
|
||||||
|
"multiline": "beside"
|
||||||
|
}],
|
||||||
|
'vue/no-undef-properties': ['error', {
|
||||||
|
'ignores': ['/^\\$/']
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,9 +16,6 @@
|
||||||
"autoprefixer": "^10.4.17",
|
"autoprefixer": "^10.4.17",
|
||||||
"axios": "^1.6.6",
|
"axios": "^1.6.6",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"eslint": "^8.56.0",
|
|
||||||
"eslint-config-prettier": "^8.10.0",
|
|
||||||
"eslint-plugin-vue": "^8.7.1",
|
|
||||||
"postcss": "^8.4.33",
|
"postcss": "^8.4.33",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"vue-axios": "^3.5.2"
|
"vue-axios": "^3.5.2"
|
||||||
|
@ -34,6 +31,8 @@
|
||||||
"@vitejs/plugin-vue": "^4.6.2",
|
"@vitejs/plugin-vue": "^4.6.2",
|
||||||
"change-case": "^4.1.2",
|
"change-case": "^4.1.2",
|
||||||
"editorjs-alert": "^1.1.3",
|
"editorjs-alert": "^1.1.3",
|
||||||
|
"eslint": "^9.28.0",
|
||||||
|
"eslint-plugin-vue": "^10.2.0",
|
||||||
"floating-vue": "^2.0.0",
|
"floating-vue": "^2.0.0",
|
||||||
"laravel-echo": "^1.15.3",
|
"laravel-echo": "^1.15.3",
|
||||||
"laravel-vite-plugin": "^0.7.8",
|
"laravel-vite-plugin": "^0.7.8",
|
||||||
|
@ -41,9 +40,9 @@
|
||||||
"merge": "^2.1.1",
|
"merge": "^2.1.1",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"postcss-import": "^14.1.0",
|
"postcss-import": "^14.1.0",
|
||||||
"prettier": "^2.8.8",
|
|
||||||
"pusher-js": "^8.3.0",
|
"pusher-js": "^8.3.0",
|
||||||
"svg-sprite": "^2.0.2",
|
"svg-sprite": "^2.0.2",
|
||||||
|
"typescript-eslint": "^8.34.0",
|
||||||
"vite": "^4.5.2",
|
"vite": "^4.5.2",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-toastification": "^2.0.0-rc.5",
|
"vue-toastification": "^2.0.0-rc.5",
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<label class="flex flex-col group" :for="id" :class="sizeClass(size)">
|
||||||
|
<f-label v-if="label" :required="false" :value="label"></f-label>
|
||||||
|
<div class="relative flex-none flex">
|
||||||
|
<ui-icon-button :class="[fieldHeight, fieldAppearance, paddingX]" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
||||||
|
<f-hint v-if="hint" :value="hint"></f-hint>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<ui-filter-sidebar v-model="visible">
|
||||||
|
<member-filter-fields :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" />
|
||||||
|
</ui-filter-sidebar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {ref} from 'vue';
|
||||||
|
import useFieldSize from '../../composables/useFieldSize';
|
||||||
|
import MemberFilterFields from '../../views/member/MemberFilterFields.vue';
|
||||||
|
|
||||||
|
const {sizeClass, fieldHeight, fieldAppearance, paddingX} = useFieldSize();
|
||||||
|
|
||||||
|
const visible = ref(false);
|
||||||
|
|
||||||
|
defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
type: String,
|
||||||
|
default: () => 'base',
|
||||||
|
},
|
||||||
|
hint: {
|
||||||
|
type: String,
|
||||||
|
default: () => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,47 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<ui-popup v-if="visible === true" heading="Filtern" @close="visible = false">
|
<ui-filter-sidebar v-model="visible">
|
||||||
<div class="grid gap-3 md:grid-cols-2">
|
<slot name="fields"></slot>
|
||||||
<slot name="fields"></slot>
|
</ui-filter-sidebar>
|
||||||
</div>
|
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3">
|
||||||
</ui-popup>
|
|
||||||
<div class="px-6 py-2 border-b border-gray-600" :class="visibleDesktopBlock">
|
|
||||||
<div class="flex items-end space-x-3">
|
|
||||||
<slot name="buttons"></slot>
|
|
||||||
<ui-icon-button v-if="filterable" icon="filter" @click="filterVisible = !filterVisible">Filtern</ui-icon-button>
|
|
||||||
</div>
|
|
||||||
<ui-box v-if="filterVisible" class="mt-3">
|
|
||||||
<div class="grid grid-cols-4 gap-3 items-end">
|
|
||||||
<slot name="fields"></slot>
|
|
||||||
<ui-icon-button class="col-start-1" icon="close" @click="filterVisible = false">Schließen</ui-icon-button>
|
|
||||||
</div>
|
|
||||||
</ui-box>
|
|
||||||
</div>
|
|
||||||
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleMobile">
|
|
||||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-end space-y-1 sm:space-y-0 sm:space-x-3">
|
<div class="flex flex-col sm:flex-row items-stretch sm:items-end space-y-1 sm:space-y-0 sm:space-x-3">
|
||||||
<slot name="buttons"></slot>
|
<slot name="buttons"></slot>
|
||||||
<ui-icon-button v-if="filterable" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
<ui-icon-button v-if="!!$slots.fields" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {defineProps, ref} from 'vue';
|
import {ref} from 'vue';
|
||||||
import useBreakpoints from '../../composables/useBreakpoints.js';
|
|
||||||
|
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
|
|
||||||
const filterVisible = ref(false);
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
breakpoint: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
filterable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: () => true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {visibleDesktopBlock, visibleMobile} = useBreakpoints(props);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<template>
|
||||||
|
<ui-sidebar :max="0" v-if="modelValue === true" @close="$emit('update:modelValue', false)">
|
||||||
|
<page-header title="Filter" @close="$emit('update:modelValue', false)"> </page-header>
|
||||||
|
<div class="grid gap-3 p-6">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</ui-sidebar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="fixed shadow-2xl bg-gray-600 right-0 top-0 h-full flex flex-col group is-bright" :class="widths[max]">
|
||||||
class="fixed w-full w-[80vw] max-w-[40rem] shadow-2xl bg-gray-600 right-0 top-0 h-full flex flex-col group is-bright">
|
|
||||||
<suspense>
|
<suspense>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
|
||||||
|
@ -18,4 +17,20 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
defineEmits(['close']);
|
defineEmits(['close']);
|
||||||
|
|
||||||
|
const widths = {
|
||||||
|
40: 'w-full w-[80vw] max-w-[40rem]',
|
||||||
|
30: 'w-full w-[80vw] max-w-[30rem]',
|
||||||
|
20: 'w-full w-[80vw] max-w-[20rem]',
|
||||||
|
10: 'w-full w-[80vw] max-w-[10rem]',
|
||||||
|
0: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
max: {
|
||||||
|
default: () => 40,
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex-none w-maxc flex flex-col justify-between border-b-2 group-[.is-popup]:border-zinc-500 mb-3">
|
<div class="flex-none w-maxc flex flex-col justify-between border-b-2 border-gray-500 group-[.is-popup]:border-zinc-500 mb-3">
|
||||||
<div class="flex space-x-1 px-2">
|
<div class="flex space-x-1 px-2">
|
||||||
<a v-for="(item, index) in entries" :key="index" href="#" class="rounded-t-lg py-1 px-3 text-zinc-300"
|
<a
|
||||||
:class="index === modelValue ? `group-[.is-popup]:bg-zinc-600` : ''" @click.prevent="openMenu(index)"
|
v-for="(item, index) in entries"
|
||||||
v-text="item.title"></a>
|
:key="index"
|
||||||
|
href="#"
|
||||||
|
class="rounded-t-lg py-1 px-3 text-zinc-300"
|
||||||
|
:class="index === modelValue ? `bg-gray-700 group-[.is-popup]:bg-zinc-600` : ''"
|
||||||
|
@click.prevent="openMenu(index)"
|
||||||
|
v-text="item.title"
|
||||||
|
></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -11,9 +17,18 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
modelValue: {},
|
modelValue: {
|
||||||
entries: {},
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
entries: {
|
||||||
|
required: true,
|
||||||
|
validator: function (entries) {
|
||||||
|
return entries.filter((e) => e.title === undefined || typeof e.title !== 'string' || e.title.length === 0).length === 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
emits: ['update:modelValue'],
|
||||||
methods: {
|
methods: {
|
||||||
openMenu(index) {
|
openMenu(index) {
|
||||||
this.$emit('update:modelValue', index);
|
this.$emit('update:modelValue', index);
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
import {computed} from 'vue';
|
|
||||||
|
|
||||||
export default function (props) {
|
|
||||||
const visibleMobile = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'flex sm:hidden',
|
|
||||||
md: 'flex md:hidden',
|
|
||||||
lg: 'flex lg:hidden',
|
|
||||||
xl: 'flex xl:hidden',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
const visibleDesktop = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'hidden sm:flex',
|
|
||||||
md: 'hidden md:flex',
|
|
||||||
lg: 'hidden lg:flex',
|
|
||||||
xl: 'hidden xl:flex',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
const visibleMobileBlock = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'block sm:hidden',
|
|
||||||
md: 'block md:hidden',
|
|
||||||
lg: 'block lg:hidden',
|
|
||||||
xl: 'block xl:hidden',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
const visibleDesktopBlock = computed(() => {
|
|
||||||
return {
|
|
||||||
sm: 'hidden sm:block',
|
|
||||||
md: 'hidden md:block',
|
|
||||||
lg: 'hidden lg:block',
|
|
||||||
xl: 'hidden xl:block',
|
|
||||||
}[props.breakpoint];
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
visibleMobile,
|
|
||||||
visibleDesktop,
|
|
||||||
visibleDesktopBlock,
|
|
||||||
visibleMobileBlock,
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -56,6 +56,11 @@ export function useIndex(props, siteName) {
|
||||||
reload(true);
|
reload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setFilterObject(o) {
|
||||||
|
inner.filter.value = o;
|
||||||
|
reload(true);
|
||||||
|
}
|
||||||
|
|
||||||
startListener();
|
startListener();
|
||||||
onBeforeUnmount(() => stopListener());
|
onBeforeUnmount(() => stopListener());
|
||||||
|
|
||||||
|
@ -70,6 +75,8 @@ export function useIndex(props, siteName) {
|
||||||
toFilterString,
|
toFilterString,
|
||||||
reloadPage,
|
reloadPage,
|
||||||
axios,
|
axios,
|
||||||
|
filter: inner.filter,
|
||||||
|
setFilterObject,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@
|
||||||
<conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form>
|
<conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
|
|
||||||
<page-filter breakpoint="xl" :filterable="false">
|
<page-filter>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||||
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" name="past" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
|
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" name="past" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
<page-filter breakpoint="lg">
|
<page-filter>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" v-model="innerFilter.search" name="search" label="Suchen" size="sm"></f-text>
|
<f-text id="search" v-model="innerFilter.search" name="search" label="Suchen" size="sm"></f-text>
|
||||||
<ui-icon-button icon="plus" @click="editing = {participant: null, preview: JSON.stringify(meta.form_config)}">Hinzufügen</ui-icon-button>
|
<ui-icon-button icon="plus" @click="editing = {participant: null, preview: JSON.stringify(meta.form_config)}">Hinzufügen</ui-icon-button>
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
<page-filter breakpoint="xl" :filterable="false">
|
<page-filter>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||||
<f-multipleselect
|
<f-multipleselect
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<f-switch v-show="hasModule('bill')" id="ausstand" name="ausstand" label="Nur Ausstände" size="sm" v-model="filter.ausstand"></f-switch>
|
||||||
|
<f-select id="has_vk" name="has_vk" label="Verhaltenskodex unterschrieben" size="sm" :options="meta.boolean_filter" v-model="filter.has_vk"></f-select>
|
||||||
|
<f-select id="has_svk" name="has_svk" label="SVK unterschrieben" size="sm" :options="meta.boolean_filter" v-model="filter.has_svk"></f-select>
|
||||||
|
<f-multipleselect id="group_ids" :options="meta.groups" label="Gruppierungen" size="sm" v-model="filter.group_ids"></f-multipleselect>
|
||||||
|
<f-select v-show="hasModule('bill')" id="billKinds" name="billKinds" :options="meta.billKinds" label="Rechnung" size="sm" v-model="filter.bill_kind"></f-select>
|
||||||
|
|
||||||
|
<div class="mt-5">
|
||||||
|
<f-checkboxes-label>nach Mitgliedschaften</f-checkboxes-label>
|
||||||
|
<button class="btn btn-primary label mt-2" @click.prevent="filter.memberships = [...filter.memberships, {...meta.default_membership_filter}]">
|
||||||
|
<ui-sprite class="w-3 h-3 xl:mr-2" src="plus"></ui-sprite>
|
||||||
|
<span class="hidden xl:inline">Hinzufügen</span>
|
||||||
|
</button>
|
||||||
|
<template v-for="(filter, index) in filter.memberships" :key="index">
|
||||||
|
<f-multipleselect :id="`group_ids-multiple-${index}`" class="mt-4" v-model="filter.group_ids" :options="meta.groups" label="Gruppierung" size="sm"></f-multipleselect>
|
||||||
|
<f-multipleselect :id="`activity_ids-multiple-${index}`" v-model="filter.activity_ids" :options="meta.filterActivities" label="Tätigkeiten" size="sm"></f-multipleselect>
|
||||||
|
<f-multipleselect :id="`subactivity_ids-multiple-${index}`" v-model="filter.subactivity_ids" :options="meta.filterSubactivities" label="Untertätigkeiten" size="sm"></f-multipleselect>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {inject, ref, watch} from 'vue';
|
||||||
|
|
||||||
|
const axios = inject('axios');
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const metaResponse = await axios.post('/api/member/search', {});
|
||||||
|
const meta = ref(metaResponse.data.meta);
|
||||||
|
|
||||||
|
const filter = ref({...props.modelValue});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
filter,
|
||||||
|
function (newValue) {
|
||||||
|
emit('update:modelValue', newValue);
|
||||||
|
},
|
||||||
|
{deep: true}
|
||||||
|
);
|
||||||
|
</script>
|
|
@ -18,7 +18,14 @@
|
||||||
label="Untertätigkeit"
|
label="Untertätigkeit"
|
||||||
@update:modelValue="setSubactivityId(single, $event)"
|
@update:modelValue="setSubactivityId(single, $event)"
|
||||||
></f-select>
|
></f-select>
|
||||||
<f-switch v-if="displayPromisedAt" id="has_promise" :model-value="single.promised_at !== null" label="Hat Versprechen" @update:modelValue="setPromisedAtSwitch(single, $event)"></f-switch>
|
<f-switch
|
||||||
|
v-if="displayPromisedAt"
|
||||||
|
id="has_promise"
|
||||||
|
name="has_promise"
|
||||||
|
:model-value="single.promised_at !== null"
|
||||||
|
label="Hat Versprechen"
|
||||||
|
@update:modelValue="setPromisedAtSwitch(single, $event)"
|
||||||
|
></f-switch>
|
||||||
<f-text v-show="displayPromisedAt && single.promised_at !== null" id="promised_at" v-model="single.promised_at" type="date" label="Versprechensdatum" size="sm"></f-text>
|
<f-text v-show="displayPromisedAt && single.promised_at !== null" id="promised_at" v-model="single.promised_at" type="date" label="Versprechensdatum" size="sm"></f-text>
|
||||||
<button type="submit" class="btn btn-primary">Absenden</button>
|
<button type="submit" class="btn btn-primary">Absenden</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -17,80 +17,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ui-popup>
|
</ui-popup>
|
||||||
<ui-popup v-if="membershipFilters !== null" heading="Nach Mitgliedschaften filtern" full @close="membershipFilters = null">
|
<page-filter>
|
||||||
<button class="btn btn-primary label mt-2" @click.prevent="membershipFilters.push({...meta.default_membership_filter})">
|
|
||||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="plus"></ui-sprite>
|
|
||||||
<span class="hidden xl:inline">Hinzufügen</span>
|
|
||||||
</button>
|
|
||||||
<div v-for="(filter, index) in membershipFilters" :key="index" class="flex space-x-2 mt-2">
|
|
||||||
<f-multipleselect :id="`group_ids-multiple-${index}`" v-model="filter.group_ids" :options="meta.groups" label="Gruppierung" size="sm"></f-multipleselect>
|
|
||||||
<f-multipleselect :id="`activity_ids-multiple-${index}`" v-model="filter.activity_ids" :options="meta.filterActivities" label="Tätigkeiten" size="sm"></f-multipleselect>
|
|
||||||
<f-multipleselect :id="`subactivity_ids-multiple-${index}`" v-model="filter.subactivity_ids" :options="meta.filterSubactivities" label="Untertätigkeiten" size="sm"></f-multipleselect>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
class="btn btn-primary label mt-3"
|
|
||||||
@click.prevent="
|
|
||||||
setFilter('memberships', membershipFilters);
|
|
||||||
membershipFilters = null;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<span class="hidden xl:inline">Anwenden</span>
|
|
||||||
</button>
|
|
||||||
</ui-popup>
|
|
||||||
<page-filter breakpoint="xl">
|
|
||||||
<template #fields>
|
<template #fields>
|
||||||
<f-switch
|
<member-filter-fields :model-value="filter" @update:model-value="setFilterObject($event)" />
|
||||||
v-show="hasModule('bill')"
|
|
||||||
id="ausstand"
|
|
||||||
name="ausstand"
|
|
||||||
:model-value="getFilter('ausstand')"
|
|
||||||
label="Nur Ausstände"
|
|
||||||
size="sm"
|
|
||||||
@update:model-value="setFilter('ausstand', $event)"
|
|
||||||
></f-switch>
|
|
||||||
<f-select
|
|
||||||
id="has_vk"
|
|
||||||
name="has_vk"
|
|
||||||
:model-value="getFilter('has_vk')"
|
|
||||||
label="Verhaltenskodex unterschrieben"
|
|
||||||
size="sm"
|
|
||||||
:options="meta.boolean_filter"
|
|
||||||
@update:model-value="setFilter('has_vk', $event)"
|
|
||||||
></f-select>
|
|
||||||
<f-select
|
|
||||||
id="has_svk"
|
|
||||||
name="has_svk"
|
|
||||||
:model-value="getFilter('has_svk')"
|
|
||||||
label="SVK unterschrieben"
|
|
||||||
size="sm"
|
|
||||||
:options="meta.boolean_filter"
|
|
||||||
@update:model-value="setFilter('has_svk', $event)"
|
|
||||||
></f-select>
|
|
||||||
<f-multipleselect
|
|
||||||
id="group_ids"
|
|
||||||
:options="meta.groups"
|
|
||||||
:model-value="getFilter('group_ids')"
|
|
||||||
label="Gruppierungen"
|
|
||||||
size="sm"
|
|
||||||
@update:model-value="setFilter('group_ids', $event)"
|
|
||||||
></f-multipleselect>
|
|
||||||
<f-select
|
|
||||||
v-show="hasModule('bill')"
|
|
||||||
id="billKinds"
|
|
||||||
name="billKinds"
|
|
||||||
:options="meta.billKinds"
|
|
||||||
:model-value="getFilter('bill_kind')"
|
|
||||||
label="Rechnung"
|
|
||||||
size="sm"
|
|
||||||
@update:model-value="setFilter('bill_kind', $event)"
|
|
||||||
></f-select>
|
|
||||||
<button class="btn btn-primary label mr-2" @click.prevent="membershipFilters = getFilter('memberships')">
|
|
||||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="filter"></ui-sprite>
|
|
||||||
<span class="hidden xl:inline">Mitgliedschaften</span>
|
|
||||||
</button>
|
|
||||||
</template>
|
</template>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
<f-text id="search" :model-value="filter.search" label="Suchen …" size="sm" @update:model-value="setFilterObject({...filter, search: $event})"></f-text>
|
||||||
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
|
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
|
||||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
|
<ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
|
||||||
<span class="hidden xl:inline">Exportieren</span>
|
<span class="hidden xl:inline">Exportieren</span>
|
||||||
|
@ -161,21 +93,21 @@
|
||||||
</page-layout>
|
</page-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js" setup>
|
<script setup>
|
||||||
import MemberInvoicePositions from './MemberInvoicePositions.vue';
|
import MemberInvoicePositions from './MemberInvoicePositions.vue';
|
||||||
import MemberMemberships from './MemberMemberships.vue';
|
import MemberMemberships from './MemberMemberships.vue';
|
||||||
import MemberCourses from './MemberCourses.vue';
|
import MemberCourses from './MemberCourses.vue';
|
||||||
import Tags from './Tags.vue';
|
import Tags from './Tags.vue';
|
||||||
import Actions from './index/Actions.vue';
|
import Actions from './index/Actions.vue';
|
||||||
import { indexProps, useIndex } from '../../composables/useIndex.js';
|
import {indexProps, useIndex} from '../../composables/useIndex.js';
|
||||||
import { ref, defineProps } from 'vue';
|
import {ref, defineProps} from 'vue';
|
||||||
|
import MemberFilterFields from './MemberFilterFields.vue';
|
||||||
|
|
||||||
const single = ref(null);
|
const single = ref(null);
|
||||||
const deleting = ref(null);
|
const deleting = ref(null);
|
||||||
const membershipFilters = ref(null);
|
|
||||||
|
|
||||||
const props = defineProps(indexProps);
|
const props = defineProps(indexProps);
|
||||||
var { router, data, meta, getFilter, setFilter, filterString, reloadPage } = useIndex(props.data, 'member');
|
var {router, data, meta, filter, setFilterObject, filterString, reloadPage} = useIndex(props.data, 'member');
|
||||||
|
|
||||||
function exportMembers() {
|
function exportMembers() {
|
||||||
window.open(`/member-export?filter=${filterString.value}`);
|
window.open(`/member-export?filter=${filterString.value}`);
|
||||||
|
@ -183,7 +115,7 @@ function exportMembers() {
|
||||||
|
|
||||||
async function remove(member) {
|
async function remove(member) {
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
deleting.value = { resolve, reject, member };
|
deleting.value = {resolve, reject, member};
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
router.delete(`/member/${member.id}`);
|
router.delete(`/member/${member.id}`);
|
||||||
|
|
|
@ -3,13 +3,25 @@
|
||||||
<template #right>
|
<template #right>
|
||||||
<f-save-button form="preventionform"></f-save-button>
|
<f-save-button form="preventionform"></f-save-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<setting-layout v-if="loaded">
|
<setting-layout v-if="loaded">
|
||||||
<form id="preventionform" class="grow p-6" @submit.prevent="submit">
|
<form id="preventionform" class="grow p-6" @submit.prevent="submit">
|
||||||
<div class="col-span-full text-gray-100 mb-3">
|
<div class="col-span-full text-gray-100 mb-3">
|
||||||
<p class="text-sm">Hier kannst du Einstellungen zu Prävention setzen.</p>
|
<p class="text-sm">Hier kannst du Einstellungen zu Prävention setzen.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid gap-4 mt-2">
|
<ui-tabs v-model="active" class="mt-2" :entries="tabs"></ui-tabs>
|
||||||
<f-editor id="frommail" v-model="data.formmail" label="E-Mail für Veranstaltungs-TN"></f-editor>
|
<div v-if="active === 0">
|
||||||
|
<f-editor v-if="active === 0" id="formmail" v-model="data.formmail" label="E-Mail für Veranstaltungs-TN"></f-editor>
|
||||||
|
</div>
|
||||||
|
<div v-if="active === 1" class="grid gap-6">
|
||||||
|
<f-switch id="active" v-model="data.active" name="active" label="Regelmäßig an Präventionsunterlagen erinnern"></f-switch>
|
||||||
|
<div class="flex gap-6">
|
||||||
|
<f-text id="weeks" v-model="data.weeks" label="Vor Ablauf X Wochen vorher erinnern" type="number" />
|
||||||
|
<f-text id="fresh_remember_interval" v-model="data.freshRememberInterval" label="Bei Ablauf alle X Wochen erinnern" type="number" />
|
||||||
|
</div>
|
||||||
|
<f-editor v-if="active === 1" id="yearlymail" v-model="data.yearlymail" label="Jährliche Präventions-Erinnerung"></f-editor>
|
||||||
|
<f-member-filter id="yearly_member_filter" v-model="data.yearlyMemberFilter" label="nur für folgende Mitglieder erlauben" />
|
||||||
|
<f-multipleselect id="prevent_against" v-model="data.preventAgainst" :options="meta.preventAgainsts" label="An diese Dokumente erinnern" size="sm"></f-multipleselect>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</setting-layout>
|
</setting-layout>
|
||||||
|
@ -21,7 +33,13 @@ import { ref } from 'vue';
|
||||||
import { useApiIndex } from '../../composables/useApiIndex.js';
|
import { useApiIndex } from '../../composables/useApiIndex.js';
|
||||||
import SettingLayout from '../setting/Layout.vue';
|
import SettingLayout from '../setting/Layout.vue';
|
||||||
|
|
||||||
const { axios, data, reload } = useApiIndex('/api/prevention', 'prevention');
|
const tabs = [
|
||||||
|
{ title: 'für Veranstaltungen' },
|
||||||
|
{ title: 'Jährlich' },
|
||||||
|
];
|
||||||
|
const active = ref(0);
|
||||||
|
|
||||||
|
const { axios, data, meta, reload } = useApiIndex('/api/prevention', 'prevention');
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@component('mail::message')
|
@component('mail::message')
|
||||||
# Hallo {{ $preventable->member->fullname }},
|
# Hallo {{ $preventable->getMailRecipient()->name }},
|
||||||
|
|
||||||
<x-mail-view::editor :content="$bodyText->toArray()['blocks']"></x-mail-view::editor>
|
<x-mail-view::editor :content="$bodyText->toArray()['blocks']"></x-mail-view::editor>
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,8 @@ class IndexTest extends EndToEndTestCase
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->get('/member')
|
$this->get('/member')
|
||||||
->assertInertiaPath("data.meta.formSubactivities.{$activity->id}.{$subactivity->id}", 'Biber')
|
->assertInertiaPath("data.meta.formSubactivities.{$activity->id}.{$subactivity->id}", 'Biber')
|
||||||
->assertInertiaPath("data.meta.filterSubactivities.{$subactivity->id}", 'Biber')
|
->assertInertiaPath("data.meta.filterSubactivities.0.name", 'Biber')
|
||||||
|
->assertInertiaPath("data.meta.filterSubactivities.0.id", $activity->id)
|
||||||
->assertInertiaPath("data.meta.formActivities.{$activity->id}", '€ Mitglied');
|
->assertInertiaPath("data.meta.formActivities.{$activity->id}", '€ Mitglied');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Feature\Member;
|
namespace Tests\EndToEnd\Member;
|
||||||
|
|
||||||
use App\Prevention\Enums\Prevention;
|
use App\Prevention\Enums\Prevention;
|
||||||
use App\Form\Actions\PreventionRememberAction;
|
use App\Form\Actions\PreventionRememberAction;
|
||||||
|
@ -10,20 +10,26 @@ use App\Form\Models\Form;
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use App\Lib\Editor\Condition;
|
use App\Lib\Editor\Condition;
|
||||||
|
use App\Member\FilterScope;
|
||||||
use App\Prevention\Mails\PreventionRememberMail;
|
use App\Prevention\Mails\PreventionRememberMail;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
|
use App\Prevention\Actions\YearlyRememberAction;
|
||||||
|
use App\Prevention\Mails\YearlyMail;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Generator;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use Tests\EndToEndTestCase;
|
||||||
use Tests\Lib\CreatesFormFields;
|
use Tests\Lib\CreatesFormFields;
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
use Tests\RequestFactories\EditorRequestFactory;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
uses(DatabaseTransactions::class);
|
uses(DatabaseTransactions::class);
|
||||||
uses(CreatesFormFields::class);
|
uses(CreatesFormFields::class);
|
||||||
|
uses(EndToEndTestCase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
app(PreventionSettings::class)->fill(['preventAgainst' => array_column(Prevention::values(), 'id'), 'active' => true])->save();
|
||||||
|
});
|
||||||
|
|
||||||
function createForm(): Form
|
function createForm(): Form
|
||||||
{
|
{
|
||||||
|
@ -43,7 +49,17 @@ function createParticipant(Form $form): Participant
|
||||||
])->for(Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling')))->create();
|
])->for(Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling')))->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createMember(array $attributes): Member
|
||||||
|
{
|
||||||
|
return Member::factory()->defaults()->has(Membership::factory()->inLocal('€ LeiterIn', 'Wölfling'))->create($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
dataset('attributes', fn() => [
|
dataset('attributes', fn() => [
|
||||||
|
[
|
||||||
|
['has_vk' => false, 'efz' => null, 'ps_at' => null],
|
||||||
|
[Prevention::EFZ, Prevention::VK, Prevention::PS]
|
||||||
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
['has_vk' => true, 'efz' => null, 'ps_at' => now()],
|
||||||
[Prevention::EFZ]
|
[Prevention::EFZ]
|
||||||
|
@ -174,7 +190,7 @@ it('testItDoesntRememberWhenParticipantDoesntHaveMember', function () {
|
||||||
$this->assertNull($participant->fresh()->last_remembered_at);
|
$this->assertNull($participant->fresh()->last_remembered_at);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItRemembersNonLeaders', function () {
|
it('doesnt remember non leaders', function () {
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
$form = createForm();
|
$form = createForm();
|
||||||
$participant = createParticipant($form);
|
$participant = createParticipant($form);
|
||||||
|
@ -186,7 +202,7 @@ it('testItRemembersNonLeaders', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('testItRemembersMember', function ($attrs, $preventions) {
|
it('remembers event participant', function ($attrs, $preventions) {
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
$form = createForm();
|
$form = createForm();
|
||||||
$participant = createParticipant($form);
|
$participant = createParticipant($form);
|
||||||
|
@ -195,7 +211,7 @@ it('testItRemembersMember', function ($attrs, $preventions) {
|
||||||
PreventionRememberAction::run();
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
if (count($preventions)) {
|
if (count($preventions)) {
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->preventable->preventions() === $preventions);
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->preventable->preventions()->pluck('type')->toArray() === $preventions);
|
||||||
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
$this->assertNotNull($participant->fresh()->last_remembered_at);
|
||||||
} else {
|
} else {
|
||||||
Mail::assertNotSent(PreventionRememberMail::class);
|
Mail::assertNotSent(PreventionRememberMail::class);
|
||||||
|
@ -203,6 +219,64 @@ it('testItRemembersMember', function ($attrs, $preventions) {
|
||||||
}
|
}
|
||||||
})->with('attributes');
|
})->with('attributes');
|
||||||
|
|
||||||
|
it('sets due date in mail when not now', function () {
|
||||||
|
Mail::fake();
|
||||||
|
$form = createForm();
|
||||||
|
$form->update(['from' => now()->addMonths(8)]);
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
$participant->member->update(['efz' => now()->subYears(5)->addMonth(), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
PreventionRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->preventable->preventions()->first()->expires->isSameDay(now()->addMonth()));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('notices a few weeks before', function ($date, bool $shouldSend) {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill(['weeks' => 2])->save();
|
||||||
|
createMember(['efz' => $date, 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
$shouldSend
|
||||||
|
? Mail::assertSent(YearlyMail::class, fn($mail) => $mail->preventions->first()->expires->isSameDay(now()->addWeeks(2)))
|
||||||
|
: Mail::assertNotSent(YearlyMail::class);
|
||||||
|
})->with([
|
||||||
|
[fn() => now()->subYears(5)->addWeeks(2), true],
|
||||||
|
[fn() => now()->subYears(5)->addWeeks(2)->addDay(), false],
|
||||||
|
[fn() => now()->subYears(5)->addWeeks(2)->subDay(), false],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('remembers members yearly', function ($date, $shouldSend) {
|
||||||
|
Mail::fake();
|
||||||
|
createMember(['efz' => $date, 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
$shouldSend
|
||||||
|
? Mail::assertSent(YearlyMail::class, fn($mail) => $mail->preventions->first()->expires->isSameDay(now()))
|
||||||
|
: Mail::assertNotSent(YearlyMail::class);
|
||||||
|
})->with([
|
||||||
|
[fn() => now()->subYears(5), true],
|
||||||
|
[fn() => now()->subYears(5)->addDay(), false],
|
||||||
|
[fn() => now()->subYears(5)->subDay(), false],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('remembers yearly only once', function () {
|
||||||
|
Mail::fake();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSentCount(1);
|
||||||
|
Mail::assertSent(YearlyMail::class, fn($mail) => $mail->preventions->first()->expires->isSameDay(now()));
|
||||||
|
});
|
||||||
|
|
||||||
it('testItDoesntRememberParticipantThatHasNoMail', function () {
|
it('testItDoesntRememberParticipantThatHasNoMail', function () {
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
$form = createForm();
|
$form = createForm();
|
||||||
|
@ -214,14 +288,49 @@ it('testItDoesntRememberParticipantThatHasNoMail', function () {
|
||||||
Mail::assertNotSent(PreventionRememberMail::class);
|
Mail::assertNotSent(PreventionRememberMail::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItRendersMail', function () {
|
it('doesnt remember when prevent against doesnt match', function () {
|
||||||
InvoiceSettings::fake(['from_long' => 'Stamm Beispiel']);
|
Mail::fake();
|
||||||
$form = createForm();
|
app(PreventionSettings::class)->fill(['preventAgainst' => []])->save();
|
||||||
$participant = createParticipant($form);
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
(new PreventionRememberMail($participant, app(PreventionSettings::class)->formmail))
|
|
||||||
->assertSeeInText($participant->member->firstname)
|
sleep(2);
|
||||||
->assertSeeInText($participant->member->lastname)
|
YearlyRememberAction::run();
|
||||||
->assertSeeInText('Stamm Beispiel');
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt send yearly mail when member has no mail', function () {
|
||||||
|
Mail::fake();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true, 'email' => '', 'email_parents' => '']);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt send yearly mail when yearly sending is deactivated', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill(['active' => false])->save();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt send yearly mail when member doesnt match', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'yearlyMemberFilter' => FilterScope::from(['search' => 'Lorem Ipsum']),
|
||||||
|
])->save();
|
||||||
|
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true, 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertNotSent(YearlyMail::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItRendersSetttingMail', function () {
|
it('testItRendersSetttingMail', function () {
|
||||||
|
@ -237,7 +346,7 @@ it('testItRendersSetttingMail', function () {
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll([
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll([
|
||||||
'lorem lala ' . $form->name,
|
'lorem lala ' . $form->name,
|
||||||
'erweitertes'
|
'erweitertes'
|
||||||
]));
|
]) && $mail->bodyText->hasNot(now()->format('d.m.Y')));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItAppendsTextOfForm', function () {
|
it('testItAppendsTextOfForm', function () {
|
||||||
|
@ -273,10 +382,64 @@ it('testItDoesntAppendTextTwice', function () {
|
||||||
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll(['oberhausen']) && !$mail->bodyText->hasAll(['siegburg']));
|
Mail::assertSent(PreventionRememberMail::class, fn($mail) => $mail->bodyText->hasAll(['oberhausen']) && !$mail->bodyText->hasAll(['siegburg']));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItDisplaysBodyTextInMail', function () {
|
/* ----------------------------------------- Mail contents ----------------------------------------- */
|
||||||
|
it('displays body text in prevention remember mail', function () {
|
||||||
$form = createForm();
|
$form = createForm();
|
||||||
$participant = createParticipant($form);
|
$participant = createParticipant($form);
|
||||||
|
|
||||||
$mail = new PreventionRememberMail($participant, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData());
|
$mail = new PreventionRememberMail($participant, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData(), collect([]));
|
||||||
$mail->assertSeeInText('ggtt');
|
$mail->assertSeeInText('ggtt');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders prevention mail for events with group name', function () {
|
||||||
|
InvoiceSettings::fake(['from_long' => 'Stamm Beispiel']);
|
||||||
|
$form = createForm();
|
||||||
|
$participant = createParticipant($form);
|
||||||
|
(new PreventionRememberMail($participant, app(PreventionSettings::class)->formmail, collect([])))
|
||||||
|
->assertSeeInText('Max')
|
||||||
|
->assertSeeInText('Muster')
|
||||||
|
->assertSeeInText('Stamm Beispiel');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders yearly mail', function () {
|
||||||
|
InvoiceSettings::fake(['from_long' => 'Stamm Beispiel']);
|
||||||
|
$member = createMember([]);
|
||||||
|
$mail = new YearlyMail($member, EditorRequestFactory::new()->paragraphs(['ggtt'])->toData(), collect([]));
|
||||||
|
$mail
|
||||||
|
->assertSeeInText('ggtt')
|
||||||
|
->assertSeeInText('Stamm Beispiel');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders setting of yearly mail', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'yearlymail' => EditorRequestFactory::new()->paragraphs(["{wanted}", "bbb"])->toData()
|
||||||
|
])->save();
|
||||||
|
$member = createMember((['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]));
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(
|
||||||
|
YearlyMail::class,
|
||||||
|
fn($mail) => $mail->bodyText->hasAll(['erweitertes', 'bbb'])
|
||||||
|
&& $mail->bodyText->hasNot(now()->format('d.m.Y'))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders expires at date for preventions', function () {
|
||||||
|
Mail::fake();
|
||||||
|
app(PreventionSettings::class)->fill([
|
||||||
|
'yearlymail' => EditorRequestFactory::new()->paragraphs(["{wanted}"])->toData(),
|
||||||
|
'weeks' => 4,
|
||||||
|
])->save();
|
||||||
|
createMember((['efz' => now()->subYears(5)->addWeeks(4), 'ps_at' => now(), 'has_vk' => true]));
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
YearlyRememberAction::run();
|
||||||
|
|
||||||
|
Mail::assertSent(YearlyMail::class, fn($mail) => $mail->bodyText->hasAll([
|
||||||
|
'erweitertes',
|
||||||
|
'am ' . now()->addWeeks(4)->format('d.m.Y'),
|
||||||
|
]) && $mail->bodyText->hasNot(now()->format('d.m.Y')));
|
||||||
|
});
|
|
@ -41,6 +41,11 @@ class MemberIndexTest extends EndToEndTestCase
|
||||||
$this->callFilter('member.index', [])->assertInertiaPath('data.meta.default.country_id', Country::firstWhere('name', 'Deutschland')->id);
|
$this->callFilter('member.index', [])->assertInertiaPath('data.meta.default.country_id', Country::firstWhere('name', 'Deutschland')->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItGetsDefaultBankAccount(): void
|
||||||
|
{
|
||||||
|
$this->callFilter('member.index', [])->assertInertiaPath('data.meta.default.bank_account.bic', '');
|
||||||
|
}
|
||||||
|
|
||||||
public function testItHandlesAddress(): void
|
public function testItHandlesAddress(): void
|
||||||
{
|
{
|
||||||
Member::factory()->defaults()->create(['address' => '']);
|
Member::factory()->defaults()->create(['address' => '']);
|
||||||
|
|
|
@ -2,39 +2,73 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Prevention;
|
namespace Tests\Feature\Prevention;
|
||||||
|
|
||||||
|
use App\Member\FilterScope;
|
||||||
|
use App\Prevention\Enums\Prevention;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
use Tests\RequestFactories\EditorRequestFactory;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class SettingTest extends TestCase
|
uses(DatabaseTransactions::class);
|
||||||
{
|
|
||||||
|
|
||||||
use DatabaseTransactions;
|
it('testItOpensSettingsPage', function () {
|
||||||
|
test()->withoutExceptionHandling();
|
||||||
|
test()->login()->loginNami();
|
||||||
|
|
||||||
public function testItOpensSettingsPage(): void
|
test()->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
||||||
{
|
});
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$this->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
it('receives settings', function () {
|
||||||
}
|
test()->login()->loginNami();
|
||||||
|
|
||||||
public function testItReceivesSettings(): void
|
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
||||||
{
|
$yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->toData();
|
||||||
$this->login()->loginNami();
|
app(PreventionSettings::class)->fill([
|
||||||
|
'formmail' => $text,
|
||||||
|
'yearlymail' => $yearlyMail,
|
||||||
|
'weeks' => 9,
|
||||||
|
'freshRememberInterval' => 11,
|
||||||
|
'active' => true,
|
||||||
|
'preventAgainst' => [Prevention::MOREPS->name],
|
||||||
|
'yearlyMemberFilter' => FilterScope::from([
|
||||||
|
'memberships' => [['group_ids' => [33]]],
|
||||||
|
'search' => 'searchstring',
|
||||||
|
]),
|
||||||
|
])->save();
|
||||||
|
|
||||||
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
test()->get('/api/prevention')
|
||||||
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
|
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum')
|
||||||
|
->assertJsonPath('data.yearlymail.blocks.0.data.text', 'lala dd')
|
||||||
|
->assertJsonPath('data.weeks', '9')
|
||||||
|
->assertJsonPath('data.active', true)
|
||||||
|
->assertJsonPath('data.freshRememberInterval', '11')
|
||||||
|
->assertJsonPath('data.yearlyMemberFilter.search', 'searchstring')
|
||||||
|
->assertJsonPath('data.yearlyMemberFilter.memberships.0.group_ids.0', 33)
|
||||||
|
->assertJsonPath('data.preventAgainst', ['MOREPS'])
|
||||||
|
->assertJsonPath('meta.preventAgainsts.0.name', 'erweitertes Führungszeugnis')
|
||||||
|
->assertJsonPath('meta.preventAgainsts.0.id', 'EFZ');
|
||||||
|
});
|
||||||
|
|
||||||
$this->get('/api/prevention')
|
it('testItStoresSettings', function () {
|
||||||
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum');
|
test()->login()->loginNami();
|
||||||
}
|
|
||||||
|
|
||||||
public function testItStoresSettings(): void
|
test()->post('/api/prevention', [
|
||||||
{
|
'formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create(),
|
||||||
$this->login()->loginNami();
|
'yearlymail' => EditorRequestFactory::new()->text(50, 'lala dd')->create(),
|
||||||
|
'weeks' => 9,
|
||||||
$this->post('/api/prevention', ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])->assertOk();
|
'freshRememberInterval' => 11,
|
||||||
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
'active' => true,
|
||||||
}
|
'preventAgainst' => ['EFZ'],
|
||||||
}
|
'yearlyMemberFilter' => [
|
||||||
|
'memberships' => [['group_ids' => 33]],
|
||||||
|
'search' => 'searchstring',
|
||||||
|
],
|
||||||
|
])->assertOk();
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->yearlymail->hasAll(['lala dd']));
|
||||||
|
test()->assertEquals(9, app(PreventionSettings::class)->weeks);
|
||||||
|
test()->assertEquals(11, app(PreventionSettings::class)->freshRememberInterval);
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->active);
|
||||||
|
test()->assertEquals([['group_ids' => 33]], app(PreventionSettings::class)->yearlyMemberFilter->memberships);
|
||||||
|
test()->assertEquals('searchstring', app(PreventionSettings::class)->yearlyMemberFilter->search);
|
||||||
|
test()->assertEquals('EFZ', app(PreventionSettings::class)->preventAgainst[0]);
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
// Most non-library projects don't need to emit declarations.
|
||||||
|
// So we add this option by default to make the config more friendly to most users.
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
// As long as you are using a build tool, we recommend you to author and ship in ES modules.
|
||||||
|
// Even if you are targeting Node.js, because
|
||||||
|
// - `CommonJS` is too outdated
|
||||||
|
// - the ecosystem hasn't fully caught up with `Node16`/`NodeNext`
|
||||||
|
// This recommendation includes environments like Vitest, Vite Config File, Vite SSR, etc.
|
||||||
|
"module": "ESNext",
|
||||||
|
|
||||||
|
// We expect users to use bundlers.
|
||||||
|
// So here we enable some resolution features that are only available in bundlers.
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
// Even files without `import` or `export` are treated as modules.
|
||||||
|
// It helps to avoid mysterious errors such as `Cannot redeclare block-scoped variable 'name`.
|
||||||
|
// https://www.totaltypescript.com/cannot-redeclare-block-scoped-variable#solution-3-your-module-isnt-a-module
|
||||||
|
"moduleDetection": "force",
|
||||||
|
|
||||||
|
// Required in Vue projects
|
||||||
|
"jsx": "preserve",
|
||||||
|
"jsxImportSource": "vue",
|
||||||
|
|
||||||
|
// `"noImplicitThis": true` is part of `strict`
|
||||||
|
// Added again here in case some users decide to disable `strict`.
|
||||||
|
// This enables stricter inference for data properties on `this`.
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"strict": true,
|
||||||
|
|
||||||
|
// <https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#verbatimmodulesyntax>
|
||||||
|
// Any imports or exports without a type modifier are left around. This is important for `<script setup>`.
|
||||||
|
// Anything that uses the type modifier is dropped entirely.
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
|
||||||
|
// A few notes:
|
||||||
|
// - Vue 3 supports ES2016+
|
||||||
|
// - For Vite, the actual compilation target is determined by the
|
||||||
|
// `build.target` option in the Vite config.
|
||||||
|
// So don't change the `target` field here. It has to be
|
||||||
|
// at least `ES2020` for dynamic `import()`s and `import.meta` to work correctly.
|
||||||
|
// - If you are not using Vite, feel free to overwrite the `target` field.
|
||||||
|
"target": "ESNext",
|
||||||
|
// For spec compliance.
|
||||||
|
// `true` by default if the `target` is `ES2020` or higher.
|
||||||
|
// Explicitly set it to `true` here in case some users want to overwrite the `target`.
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
|
||||||
|
// Recommended
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
// See <https://github.com/vuejs/vue-cli/pull/5688>
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"types": ["vite/client"]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue