Portal-Synchronisation: unser System führt

- Connector-System (app/Channels, config/channels.php) mit iCal-Connector, robustem Parser und Export-Feed je Portal (ohne eigene Belegungen, ohne Gästedaten)
- Abgleich alle 5 Min. mit Protokoll, Echo-Erkennung, Konflikt-Mail bei möglicher Doppelbuchung
- Überwachung: Störungs-Mail, Status-Endpunkt /health/sync für n8n
- Portal-Aufgaben für Sofortbuchungsportale (FeWo-direkt): automatisch aus Buchungen/Sperren/anderen Portalen, Mail + Erinnerung, Abhaken im Admin
- Optionaler signierter Automatisierungs-Webhook mit Rückmeldung
- Herkunftsmessung: Abfrage im Formular + UTM-Parameter
- Portal-Analyse: AGB-Prüfung Automatisierung, Umsetzungsbeschreibung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 11:13:55 +02:00
1 parent a8e72715ab
commit 0b7205e050
55 files changed
+2290 -3

No files matched your search

@@ -6,6 +6,7 @@
use App\Filament\Resources\Properties\Pages\EditProperty;
use App\Filament\Resources\Properties\Pages\ListProperties;
use App\Filament\Resources\Properties\RelationManagers\BlockedPeriodsRelationManager;
use App\Filament\Resources\Properties\RelationManagers\ChannelsRelationManager;
use App\Filament\Resources\Properties\RelationManagers\ExtrasRelationManager;
use App\Filament\Resources\Properties\RelationManagers\SeasonsRelationManager;
use App\Filament\Resources\Properties\RelationManagers\SpecialOffersRelationManager;
@@ -50,6 +51,7 @@ public static function getRelations(): array
SpecialOffersRelationManager::class,
ExtrasRelationManager::class,
BlockedPeriodsRelationManager::class,
ChannelsRelationManager::class,
];
}
@@ -0,0 +1,155 @@
<?php
namespace App\Filament\Resources\Properties\RelationManagers;
use App\Actions\SyncChannel;
use App\Channels\ChannelRegistry;
use App\Models\Channel;
use App\Models\ChannelSyncLog;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Infolists\Components\RepeatableEntry;
use Filament\Infolists\Components\RepeatableEntry\TableColumn;
use Filament\Infolists\Components\TextEntry;
use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class ChannelsRelationManager extends RelationManager
{
protected static string $relationship = 'channels';
protected static ?string $title = 'Portale & Kanäle';
protected static ?string $modelLabel = 'Portal';
protected static ?string $pluralModelLabel = 'Portale';
public function form(Schema $schema): Schema
{
$registry = app(ChannelRegistry::class);
return $schema
->columns(2)
->components([
TextInput::make('name')
->label('Name')
->placeholder('z. B. FeWo-direkt')
->required()
->maxLength(100),
Select::make('connector')
->label('Anbindung')
->options($registry->options())
->default('ical')
->live()
->required(),
Group::make()
->columnSpanFull()
->schema(fn (Get $get): array => filled($get('connector')) ? $registry->connectors()[$get('connector')]::settingsSchema() : []),
TextEntry::make('export_url')
->label('Unsere Kalender-Adresse für dieses Portal')
->helperText('Diese Adresse im Portal unter „Kalender importieren“ eintragen. Sie enthält alle Belegungen außer denen dieses Portals.')
->state(fn (?Channel $record): ?string => $record?->exportUrl())
->copyable()
->visible(fn (?Channel $record): bool => $record !== null)
->columnSpanFull(),
Toggle::make('requires_manual_blocking')
->label('Zusätzlich von Hand sperren (Sofortbuchung)')
->helperText('Bei jeder Belegung über andere Wege entsteht eine Aufgabe „Im Portal sperren“ – für Portale, die unseren Kalender zu selten abholen.')
->live()
->columnSpanFull(),
TextInput::make('manage_url')
->label('Link zum Kalender im Vermieterbereich')
->url()
->maxLength(2048)
->visible(fn (Get $get): bool => (bool) $get('requires_manual_blocking'))
->columnSpanFull(),
Toggle::make('is_active')
->label('Aktiv')
->default(true),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->description('Unser System ist führend: Belegungen der Portale werden alle 5 Minuten eingelesen, jedes Portal erhält einen eigenen Kalender mit allen übrigen Belegungen.')
->columns([
TextColumn::make('name')->label('Portal')->weight('medium'),
TextColumn::make('status')
->label('Status')
->badge()
->state(fn (Channel $record): string => match (true) {
! $record->is_active => 'Inaktiv',
! $record->importsOccupations() => 'Nur Export',
$record->last_error !== null => 'Fehler',
$record->isStale() => 'Veraltet',
default => 'OK',
})
->color(fn (string $state): string => match ($state) {
'OK' => 'success',
'Fehler', 'Veraltet' => 'danger',
default => 'gray',
})
->tooltip(fn (Channel $record): ?string => $record->last_error),
TextColumn::make('last_success_at')->label('Letzter Abgleich')->since()->placeholder('–'),
TextColumn::make('requires_manual_blocking')
->label('Handpflege')
->formatStateUsing(fn (bool $state): string => $state ? 'ja' : '–'),
])
->headerActions([
CreateAction::make(),
])
->recordActions([
Action::make('sync')
->label('Jetzt abgleichen')
->icon(Heroicon::OutlinedArrowPath)
->visible(fn (Channel $record): bool => $record->importsOccupations())
->action(function (Channel $record, SyncChannel $syncChannel): void {
$log = $syncChannel->handle($record);
$log->successful
? Notification::make()->title("{$log->events} Belegungen eingelesen")->body("Neu: {$log->added}, geändert: {$log->changed}, entfernt: {$log->removed}, Konflikte: {$log->conflicts}")->success()->send()
: Notification::make()->title('Abgleich fehlgeschlagen')->body($log->message)->danger()->send();
}),
Action::make('logs')
->label('Protokoll')
->icon(Heroicon::OutlinedListBullet)
->color('gray')
->modalSubmitAction(false)
->modalCancelActionLabel('Schließen')
->schema([
RepeatableEntry::make('recentLogs')
->hiddenLabel()
->state(fn (Channel $record): array => $record->syncLogs()->limit(30)->get()->map(fn (ChannelSyncLog $log): array => [
'time' => $log->created_at->format('d.m. H:i'),
'result' => $log->successful ? "✓ {$log->events} Belegungen (+{$log->added} ~{$log->changed} -{$log->removed})" : '✗ '.$log->message,
'conflicts' => $log->conflicts ?: '',
])->all())
->table([
TableColumn::make('Zeit'),
TableColumn::make('Ergebnis'),
TableColumn::make('Konflikte'),
])
->schema([
TextEntry::make('time'),
TextEntry::make('result'),
TextEntry::make('conflicts'),
]),
]),
EditAction::make(),
DeleteAction::make(),
]);
}
}