Import of W&K seminar exports with preview, booking form via form generator with event-dependent field rules, notification routing, inbox with folders and CSV export for W&K. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
102 lines
3.1 KiB
PHP
102 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Mummert\ContaoWkSyncBundle\Booking;
|
|
|
|
use Contao\StringUtil;
|
|
use Mummert\ContaoWkSyncBundle\Category\CategoryKind;
|
|
|
|
/**
|
|
* Für die Anmeldung relevante Sicht auf eine Veranstaltung (tl_calendar_events).
|
|
*/
|
|
final readonly class BookingEvent
|
|
{
|
|
public const string CLOSED_AUDIENCE = 'geschlossener teilnehmerkreis';
|
|
|
|
/**
|
|
* @param array<string, mixed> $row vollständige Zeile aus tl_calendar_events
|
|
* @param list<int> $categories
|
|
*/
|
|
public function __construct(
|
|
public int $id,
|
|
public int $calendarId,
|
|
public string $title,
|
|
public string $alias,
|
|
public bool $published,
|
|
public int $startDate,
|
|
public int $endDate,
|
|
public int $startTime,
|
|
public int $endTime,
|
|
public string $location,
|
|
public string $wkId,
|
|
public string $wkState,
|
|
public string $internalNumber,
|
|
public int $eventType,
|
|
public int $placesLeft,
|
|
public int $maxPlaces,
|
|
public string $audience,
|
|
public string $organizerEmail,
|
|
public int $confirmationPage,
|
|
public int $notification,
|
|
public int $primaryCategory,
|
|
public array $categories,
|
|
public CategoryKind $kind,
|
|
public array $row,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $row
|
|
*/
|
|
public static function fromRow(array $row, CategoryKind $kind): self
|
|
{
|
|
return new self(
|
|
(int) $row['id'],
|
|
(int) $row['pid'],
|
|
(string) $row['title'],
|
|
(string) ($row['alias'] ?? ''),
|
|
(bool) ($row['published'] ?? false),
|
|
(int) ($row['startDate'] ?? 0),
|
|
(int) ($row['endDate'] ?? 0),
|
|
(int) ($row['startTime'] ?? 0),
|
|
(int) ($row['endTime'] ?? 0),
|
|
(string) ($row['location'] ?? ''),
|
|
(string) ($row['wkId'] ?? ''),
|
|
(string) ($row['wkState'] ?? ''),
|
|
(string) ($row['wkInternalEventNumber'] ?? ''),
|
|
(int) ($row['wkEventType'] ?? 0),
|
|
(int) ($row['wkPlacesLeft'] ?? 0),
|
|
(int) ($row['wkMaxPlaces'] ?? 0),
|
|
(string) ($row['wkAudience'] ?? ''),
|
|
(string) ($row['wkOrganizerEmail'] ?? ''),
|
|
(int) ($row['wkConfirmationPage'] ?? 0),
|
|
(int) ($row['wkNotification'] ?? 0),
|
|
(int) ($row['wkCategoryPrimary'] ?? 0),
|
|
array_map(intval(...), StringUtil::deserialize($row['wkCategories'] ?? null, true)),
|
|
$kind,
|
|
$row,
|
|
);
|
|
}
|
|
|
|
public function isSingleDay(): bool
|
|
{
|
|
return date('Y-m-d', $this->startDate) === date('Y-m-d', $this->endDate ?: $this->startDate);
|
|
}
|
|
|
|
public function isOnline(): bool
|
|
{
|
|
return 'online' === mb_strtolower(trim($this->location));
|
|
}
|
|
|
|
public function hasExtpNumber(): bool
|
|
{
|
|
return str_starts_with(mb_strtoupper(trim($this->internalNumber)), 'EXTP');
|
|
}
|
|
|
|
public function isClosedAudience(): bool
|
|
{
|
|
return self::CLOSED_AUDIENCE === mb_strtolower(trim($this->audience));
|
|
}
|
|
}
|