Erinnerungsabstand und taegliche/woechentliche Zusammenfassung einstellbar
System > Betrieb > Benachrichtigungen: offene Meldungen (Doppelbuchungen im Postfach, Portal-Aufgaben) nur einmal oder alle 1/2/3/7 Tage erneut senden; Tages- und/oder Wochenuebersicht mit waehlbarer Uhrzeit, Wochentag und Inhalt (Postfach, Anfragen, Neues, An-/Abreisen, Zahlungen, Portale, Bewertungen). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
70a39315e2
commit
1c757f7429
20 files changed
+842
-22
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Actions\SendDigests;
|
||||
use App\Enums\DigestSection;
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
@@ -11,10 +13,12 @@
|
||||
use App\Tenancy\TenantFeatures;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
@@ -30,7 +34,7 @@
|
||||
/**
|
||||
* Operating data of the landlord: operating mode (test mode sends every e-mail to one test recipient only;
|
||||
* live delivers to the real recipients), the addresses of the internal communication, the landlord's own
|
||||
* address and bank details, and the periods. Administrators only.
|
||||
* address and bank details, reminders and summaries, and the periods. Administrators only.
|
||||
*/
|
||||
class Operations extends Page
|
||||
{
|
||||
@@ -53,6 +57,11 @@ class Operations extends Page
|
||||
'channel_task_reminder_after_minutes' => 'Erinnerung an Portal-Aufgaben nach (Minuten)',
|
||||
];
|
||||
|
||||
/** Choices for repeating open findings (days => label). */
|
||||
public const REMINDER_INTERVALS = [0 => 'Nur einmal', 1 => 'Täglich', 2 => 'Alle 2 Tage', 3 => 'Alle 3 Tage', 7 => 'Wöchentlich'];
|
||||
|
||||
public const WEEKDAYS = [1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag', 7 => 'Sonntag'];
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPower;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'System';
|
||||
@@ -99,6 +108,13 @@ public function mount(): void
|
||||
'mailbox_password' => $tenant->mailbox_password,
|
||||
'mailbox_encryption' => $tenant->mailbox_encryption,
|
||||
'mailbox_folder' => $tenant->mailbox_folder,
|
||||
'reminder_interval_days' => $tenant->reminder_interval_days,
|
||||
'digest_daily' => $tenant->digest_daily,
|
||||
'digest_weekly' => $tenant->digest_weekly,
|
||||
'digest_weekday' => $tenant->digest_weekday,
|
||||
'digest_hour' => $tenant->digest_hour,
|
||||
'digest_sections' => array_map(fn (DigestSection $section): string => $section->value, DigestSection::chosen($tenant->digest_sections)),
|
||||
'digest_when_empty' => $tenant->digest_when_empty,
|
||||
...$this->periodValues($tenant),
|
||||
]);
|
||||
}
|
||||
@@ -181,6 +197,43 @@ public function form(Schema $schema): Schema
|
||||
->maxLength(255)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Benachrichtigungen')
|
||||
->description('Wie oft offene Meldungen wiederholt werden und welche Zusammenfassungen Sie per E-Mail erhalten. Empfänger sind die Adressen unter „Benachrichtigungen an“.')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('reminder_interval_days')
|
||||
->label('Offene Meldungen erneut senden')
|
||||
->helperText('Gilt für mögliche Doppelbuchungen (solange sie im Postfach ungelesen sind und weiter bestehen) und offene Portal-Aufgaben.')
|
||||
->options(self::REMINDER_INTERVALS)
|
||||
->selectablePlaceholder(false)
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Toggle::make('digest_daily')->label('Tägliche Zusammenfassung'),
|
||||
Toggle::make('digest_weekly')->label('Wöchentliche Zusammenfassung')->live(),
|
||||
Select::make('digest_hour')
|
||||
->label('Versand ab')
|
||||
->options(collect(range(5, 21))->mapWithKeys(fn (int $hour): array => [$hour => sprintf('%02d:00 Uhr', $hour)])->all())
|
||||
->selectablePlaceholder(false)
|
||||
->required(),
|
||||
Select::make('digest_weekday')
|
||||
->label('Wochentag der Wochenübersicht')
|
||||
->helperText('An diesem Tag kommt nur die Wochenübersicht, nicht zusätzlich die tägliche.')
|
||||
->options(self::WEEKDAYS)
|
||||
->selectablePlaceholder(false)
|
||||
->visible(fn (Get $get): bool => (bool) $get('digest_weekly'))
|
||||
->required(),
|
||||
CheckboxList::make('digest_sections')
|
||||
->label('Inhalt der Zusammenfassung')
|
||||
->options(DigestSection::class)
|
||||
->descriptions(collect(DigestSection::cases())->mapWithKeys(fn (DigestSection $section): array => [$section->value => $section->getDescription()])->all())
|
||||
->columns(2)
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Toggle::make('digest_when_empty')
|
||||
->label('Auch senden, wenn nichts ansteht')
|
||||
->helperText('Sonst entfällt die Zusammenfassung an Tagen ohne offene Punkte.')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Portal-Postfach')
|
||||
->description('Aus diesem Postfach werden die Buchungsmails der Portale gelesen, damit ein Termin sofort gesperrt wird. Leerer Server = ausgeschaltet. Das Passwort liegt verschlüsselt in der Datenbank.')
|
||||
->columns(2)
|
||||
@@ -215,6 +268,29 @@ public function content(Schema $schema): Schema
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('sendDigest')
|
||||
->label('Zusammenfassung jetzt senden')
|
||||
->icon(Heroicon::OutlinedPaperAirplane)
|
||||
->color('gray')
|
||||
->modalDescription('Schickt die Zusammenfassung mit den gespeicherten Einstellungen sofort an die Benachrichtigungsadressen – auch wenn nichts ansteht. Der reguläre Versand bleibt unverändert.')
|
||||
->schema([
|
||||
Radio::make('weekly')
|
||||
->label('Welche?')
|
||||
->options([0 => 'Tagesübersicht', 1 => 'Wochenübersicht'])
|
||||
->default(0)
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
app(SendDigests::class)->send($this->tenant(), (bool) $data['weekly'], force: true);
|
||||
|
||||
Notification::make()->title('Zusammenfassung gesendet')->body(Settings::isLive() ? null : 'Testbetrieb: Sie geht an die Testadresse.')->success()->send();
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
@@ -243,6 +319,13 @@ public function save(): void
|
||||
'mailbox_password' => $data['mailbox_password'] ?? null,
|
||||
'mailbox_encryption' => $data['mailbox_encryption'] ?? null,
|
||||
'mailbox_folder' => $data['mailbox_folder'] ?? null,
|
||||
'reminder_interval_days' => (int) $data['reminder_interval_days'],
|
||||
'digest_daily' => (bool) $data['digest_daily'],
|
||||
'digest_weekly' => (bool) $data['digest_weekly'],
|
||||
'digest_weekday' => (int) ($data['digest_weekday'] ?? $tenant->digest_weekday),
|
||||
'digest_hour' => (int) $data['digest_hour'],
|
||||
'digest_sections' => count($data['digest_sections']) === count(DigestSection::cases()) ? null : array_values($data['digest_sections']),
|
||||
'digest_when_empty' => (bool) $data['digest_when_empty'],
|
||||
...array_map(fn (mixed $value): ?int => filled($value) ? (int) $value : null, $this->periodInput($data)),
|
||||
]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user