165 lines
3.7 KiB
PHP
165 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\BookingEditDraftRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: BookingEditDraftRepository::class)]
|
|
#[ORM\Table(name: 'booking_edit_draft')]
|
|
#[ORM\UniqueConstraint(name: 'user_booking_unique', columns: ['user_id', 'booking_id'])]
|
|
#[ORM\Index(name: 'IDX_DRAFT_TRAVEL_DATE', columns: ['travel_date'])]
|
|
class BookingEditDraft
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column(type: 'integer')]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
|
private User $user;
|
|
|
|
/**
|
|
* Internal database ID (BPN XML: idbuchung).
|
|
*/
|
|
#[ORM\Column(type: 'integer')]
|
|
private int $bookingId;
|
|
|
|
/**
|
|
* User-facing transaction number (BPN XML: vorgang).
|
|
*/
|
|
#[ORM\Column(type: 'integer', nullable: true)]
|
|
private ?int $bookingNumber = null;
|
|
|
|
#[ORM\Column(type: 'date_immutable')]
|
|
private \DateTimeImmutable $travelDate;
|
|
|
|
/**
|
|
* BusProNet travel date ID (termin idbuspro) for loading travel data.
|
|
*/
|
|
#[ORM\Column(type: 'integer', nullable: true)]
|
|
private ?int $dateId = null;
|
|
|
|
/**
|
|
* BusProNet hotel ID for loading travel data.
|
|
*/
|
|
#[ORM\Column(type: 'integer', nullable: true)]
|
|
private ?int $hotelId = null;
|
|
|
|
#[ORM\Column(type: 'json')]
|
|
private array $formData = [];
|
|
|
|
#[ORM\Column(type: 'datetime_immutable')]
|
|
private \DateTimeImmutable $createdAt;
|
|
|
|
#[ORM\Column(type: 'datetime_immutable')]
|
|
private \DateTimeImmutable $updatedAt;
|
|
|
|
public function __construct(User $user, int $bookingId, \DateTimeImmutable $travelDate, array $formData)
|
|
{
|
|
$this->user = $user;
|
|
$this->bookingId = $bookingId;
|
|
$this->travelDate = $travelDate;
|
|
$this->formData = $formData;
|
|
$this->createdAt = new \DateTimeImmutable();
|
|
$this->updatedAt = new \DateTimeImmutable();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUser(): User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function getBookingId(): int
|
|
{
|
|
return $this->bookingId;
|
|
}
|
|
|
|
public function getBookingNumber(): ?int
|
|
{
|
|
return $this->bookingNumber;
|
|
}
|
|
|
|
public function setBookingNumber(?int $bookingNumber): static
|
|
{
|
|
$this->bookingNumber = $bookingNumber;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTravelDate(): \DateTimeImmutable
|
|
{
|
|
return $this->travelDate;
|
|
}
|
|
|
|
public function setTravelDate(\DateTimeImmutable $travelDate): static
|
|
{
|
|
$this->travelDate = $travelDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDateId(): ?int
|
|
{
|
|
return $this->dateId;
|
|
}
|
|
|
|
public function setDateId(?int $dateId): static
|
|
{
|
|
$this->dateId = $dateId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getHotelId(): ?int
|
|
{
|
|
return $this->hotelId;
|
|
}
|
|
|
|
public function setHotelId(?int $hotelId): static
|
|
{
|
|
$this->hotelId = $hotelId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Checks if the draft has the required travel IDs for export functionality.
|
|
*/
|
|
public function hasExportData(): bool
|
|
{
|
|
return null !== $this->dateId && null !== $this->hotelId;
|
|
}
|
|
|
|
public function getFormData(): array
|
|
{
|
|
return $this->formData;
|
|
}
|
|
|
|
public function setFormData(array $formData): static
|
|
{
|
|
$this->formData = $formData;
|
|
$this->updatedAt = new \DateTimeImmutable();
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): \DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function getUpdatedAt(): \DateTimeImmutable
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
}
|