Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
- Buchung erfassen: Buchungsweg Portal (Referenz, Portalpreis, ohne Kontaktdaten), Prozess bestaetigen/Vertrag sofort/nur erfassen - Buchungsakte: Kontaktdaten eintragen (automatisch oder manuell weiter), Gast um Kontaktdaten bitten, Status von Hand aendern, Archivieren - Liste: Filter Kanal, Anreisezeitraum, Kontaktdaten fehlen; Spalten ausblendbar; Archiv - Klaerung: verstaendlichere Texte, eigenstaendige Belegung mit Kanal gilt als geklaert (Gitea #4) - Akte per Button aus Liste und Belegungsplan erreichbar - Menue: Gruppen Verwaltung (Tagesgeschaeft) und Einrichtung (Konfiguration), einfache Ansicht auf 8 Punkte Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
78 lines
2.7 KiB
PHP
78 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Bookings\Pages;
|
|
|
|
use App\Actions\ConfirmBooking;
|
|
use App\Actions\CreateReservation;
|
|
use App\Actions\RecordPortalBooking;
|
|
use App\Exceptions\ReservationException;
|
|
use App\Filament\Resources\Bookings\BookingResource;
|
|
use App\Models\Channel;
|
|
use App\Models\Property;
|
|
use App\Pricing\QuoteException;
|
|
use App\Pricing\StayRequest;
|
|
use Carbon\CarbonImmutable;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class CreateBooking extends CreateRecord
|
|
{
|
|
protected static string $resource = BookingResource::class;
|
|
|
|
protected static ?string $title = 'Buchung erfassen';
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
protected function handleRecordCreation(array $data): Model
|
|
{
|
|
try {
|
|
$property = Property::findOrFail($data['property_id']);
|
|
$stay = new StayRequest(
|
|
CarbonImmutable::parse($data['arrival']),
|
|
CarbonImmutable::parse($data['departure']),
|
|
(int) $data['guests'],
|
|
promoCode: $data['promo_code'] ?: null,
|
|
);
|
|
$guest = Arr::only($data, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']);
|
|
|
|
if (filled($data['channel_id'] ?? null)) {
|
|
$booking = app(RecordPortalBooking::class)->handle(
|
|
$property,
|
|
Channel::query()->findOrFail($data['channel_id']),
|
|
$stay,
|
|
$guest,
|
|
$data['portal_process'] ?? RecordPortalBooking::CONFIRM,
|
|
$data['portal_reference'] ?? null,
|
|
filled($data['portal_total'] ?? null) ? (int) $data['portal_total'] : null,
|
|
$data['internal_notes'] ?: null,
|
|
(bool) ($data['guest_confirmed'] ?? false),
|
|
);
|
|
|
|
return $booking;
|
|
}
|
|
|
|
$booking = app(CreateReservation::class)->handle($property, $stay, $guest, source: 'manual', sendMails: $data['send_mails']);
|
|
|
|
if ($data['confirm_immediately']) {
|
|
app(ConfirmBooking::class)->handle($booking, notifyGuest: $data['send_mails']);
|
|
}
|
|
} catch (QuoteException|ReservationException $exception) {
|
|
Notification::make()->title('Buchung nicht möglich')->body($exception->getMessage())->danger()->send();
|
|
|
|
$this->halt();
|
|
}
|
|
|
|
$booking->update(['internal_notes' => $data['internal_notes'] ?: null]);
|
|
|
|
return $booking;
|
|
}
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
return BookingResource::getUrl('view', ['record' => $this->getRecord()]);
|
|
}
|
|
}
|