<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Itinerary;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryFormValidator;
use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryFormDestinationValidator;
use Croisiland\CommonBundle\Entity\Company\Company;
use Croisiland\CommonBundle\Entity\Cruise\Cruise;
use Croisiland\CommonBundle\Entity\Traits\IncludedExcludedTrait;
use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
use Croisiland\CommonBundle\Repository\Itinerary\ItineraryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=ItineraryRepository::class)
*
* @ItineraryFormValidator(groups={"itinerary_form_validator"})
* @ItineraryFormDestinationValidator(groups={"itinerary_form_destination_validator"})
*
* @UniqueEntity(
* fields={"code"},
* errorPath="code",
* message="itinerary.code.unique_constraint",
* ignoreNull=true
* )
*/
class Itinerary implements ItineraryInterface
{
use IsActiveTrait;
use LifecycleUserIdentifierTrait;
use IncludedExcludedTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $name = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $packageId = null;
// TODO Supprimer Year, si inutilisée originellement dans l'entité flatfile liée a l'itinéraire dans le CMS
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $year = null;
// TODO Supprimer fromPrice, si inutilisée originellement dans l'entité flatfile liée a l'itinéraire dans le CMS
/**
* @ORM\Column(type="float", nullable=true)
*/
private ?float $fromPrice = null;
// TODO Supprimer ItineraryLength: aucune référence trouvée, et en doublon avec numberOfDays, et numberOfNights
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $itineraryLength = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $code = null;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private ?string $largeCode = null;
/**
* @ORM\Column(type="string", length=1020, nullable=true)
*/
private ?string $originalName = null;
/**
* @ORM\Column(type="string", length=510, nullable=true)
*/
private ?string $generatedName = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $marketingName = null;
/**
* @ORM\Column(type="string", length=510, nullable=true)
*/
private ?string $subTitle = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $fluvialDescription = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $numberOfDays = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $numberOfNights = null;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $hasGroupDiscount = false;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $erpHistoryUpToDate = false;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $roundTrip = false;
/**
* @var Collection<int, ItinerarySegment>
*
* @ORM\OneToMany(targetEntity=ItinerarySegment::class, mappedBy="itinerary", orphanRemoval=true, cascade={"persist","remove"})
*
* @ORM\OrderBy({"segmentOrder" = "ASC"})
*/
private Collection $itinerarySegments;
/**
* @ORM\ManyToOne(targetEntity=DestinationMain::class, inversedBy="itineraries")
*/
private ?DestinationMain $destination = null;
/**
* @var Collection<int, ItinerarySecondaryDestination>
*
* @ORM\OneToMany(targetEntity=ItinerarySecondaryDestination::class, mappedBy="itinerary", orphanRemoval=true, cascade={"persist","remove"})
*
* @ORM\OrderBy({"position" = "ASC"})
*/
private Collection $secondaryDestinations;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="originatedItineraries")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Company $originCompany = null;
/**
* @var Collection<int, Cruise>
*
* @ORM\OneToMany(targetEntity=Cruise::class, mappedBy="itinerary")
*
* @ORM\OrderBy({"departureDate" = "ASC"})
*/
private Collection $cruises;
/**
* @ORM\OneToOne(targetEntity=ItineraryComputed::class, mappedBy="itinerary")
*/
private ?ItineraryComputed $computed = null;
/**
* @var Collection<int, ItineraryActivity>
*
* @ORM\OneToMany(targetEntity=ItineraryActivity::class, mappedBy="itinerary", orphanRemoval=true, cascade={"persist","remove"})
*
* @ORM\OrderBy({"listOrder" = "ASC"})
*/
private Collection $itineraryActivities;
/**
* @var Collection<int, ItineraryConsistencyReport>
*
* @ORM\OneToMany(targetEntity="Croisiland\CommonBundle\Entity\Itinerary\ItineraryConsistencyReport", fetch="LAZY", mappedBy="itinerary", cascade={"persist"}, orphanRemoval=true)
* @ORM\OrderBy({"createdAt" = "DESC"})
*/
private Collection $consistencyReports;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $consistencyScore = null;
public function __construct()
{
$this->itinerarySegments = new ArrayCollection();
$this->secondaryDestinations = new ArrayCollection();
$this->cruises = new ArrayCollection();
$this->itineraryActivities = new ArrayCollection();
$this->consistencyReports = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): Itinerary
{
$this->id = $id;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPackageId(): ?string
{
return $this->packageId;
}
public function setPackageId(?string $packageId): self
{
$this->packageId = $packageId;
return $this;
}
public function getYear(): ?int
{
return $this->year;
}
public function setYear(?int $year): self
{
$this->year = $year;
return $this;
}
public function getFromPrice(): ?float
{
return $this->fromPrice;
}
public function setFromPrice(?float $fromPrice): self
{
$this->fromPrice = $fromPrice;
return $this;
}
public function getItineraryLength(): ?int
{
return $this->itineraryLength;
}
public function setItineraryLength(?int $itineraryLength): self
{
$this->itineraryLength = $itineraryLength;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): Itinerary
{
$this->code = $code;
return $this;
}
public function getLargeCode(): ?string
{
return $this->largeCode;
}
public function setLargeCode(?string $largeCode): Itinerary
{
$this->largeCode = $largeCode;
return $this;
}
public function getOriginalName(): ?string
{
return $this->originalName;
}
public function setOriginalName(?string $originalName): Itinerary
{
$this->originalName = $originalName;
return $this;
}
public function getGeneratedName(): ?string
{
return $this->generatedName;
}
public function setGeneratedName(?string $generatedName): Itinerary
{
$this->generatedName = $generatedName;
return $this;
}
public function getMarketingName(): ?string
{
return $this->marketingName;
}
public function setMarketingName(?string $marketingName): Itinerary
{
$this->marketingName = $marketingName;
return $this;
}
public function getSubTitle(): ?string
{
return $this->subTitle;
}
public function setSubTitle(?string $subTitle): Itinerary
{
$this->subTitle = $subTitle;
return $this;
}
public function getFluvialDescription(): ?string
{
return $this->fluvialDescription;
}
public function setFluvialDescription(?string $fluvialDescription): Itinerary
{
$this->fluvialDescription = $fluvialDescription;
return $this;
}
public function getNumberOfDays(): ?int
{
return $this->numberOfDays;
}
public function setNumberOfDays(?int $numberOfDays): Itinerary
{
$this->numberOfDays = $numberOfDays;
return $this;
}
public function getNumberOfNights(): ?int
{
return $this->numberOfNights;
}
public function setNumberOfNights(?int $numberOfNights): Itinerary
{
$this->numberOfNights = $numberOfNights;
return $this;
}
public function isHasGroupDiscount(): bool
{
return $this->hasGroupDiscount;
}
public function setHasGroupDiscount(bool $hasGroupDiscount): Itinerary
{
$this->hasGroupDiscount = $hasGroupDiscount;
return $this;
}
public function isErpHistoryUpToDate(): bool
{
return $this->erpHistoryUpToDate;
}
public function setErpHistoryUpToDate(bool $erpHistoryUpToDate): Itinerary
{
$this->erpHistoryUpToDate = $erpHistoryUpToDate;
return $this;
}
public function isRoundTrip(): bool
{
return $this->roundTrip;
}
public function setRoundTrip(bool $roundTrip): Itinerary
{
$this->roundTrip = $roundTrip;
return $this;
}
/**
* @return Collection<int, ItinerarySegment> <p>Ordered by SegmentOrder</p>
*/
public function getItinerarySegments(): Collection
{
return $this->itinerarySegments;
}
public function addItinerarySegment(ItinerarySegment $itinerarySegment): self
{
if ($this->itinerarySegments->contains($itinerarySegment)) {
return $this;
}
$itinerarySegment->setItinerary($this);
$this->itinerarySegments[] = $itinerarySegment;
return $this;
}
public function removeItinerarySegment(ItinerarySegment $itinerarySegment): self
{
if ($this->itinerarySegments->removeElement($itinerarySegment)) {
// set the owning side to null (unless already changed)
if ($itinerarySegment->getItinerary() === $this) {
$itinerarySegment->setItinerary(null);
}
}
return $this;
}
public function getDestination(): ?DestinationMain
{
return $this->destination;
}
public function setDestination(?DestinationMain $destination): self
{
$this->destination = $destination;
return $this;
}
/**
* @return Collection<int, ItinerarySecondaryDestination>
*/
public function getSecondaryDestinations(): Collection
{
return $this->secondaryDestinations;
}
public function addSecondaryDestination(ItinerarySecondaryDestination $secondaryDestination): self
{
if ($this->secondaryDestinations->contains($secondaryDestination)) {
return $this;
}
$secondaryDestination->setItinerary($this);
$this->secondaryDestinations[] = $secondaryDestination;
return $this;
}
public function removeSecondaryDestination(ItinerarySecondaryDestination $secondaryDestination): self
{
if ($this->secondaryDestinations->removeElement($secondaryDestination)) {
// set the owning side to null (unless already changed)
if ($secondaryDestination->getItinerary() === $this) {
$secondaryDestination->setItinerary(null);
}
}
return $this;
}
/**
* @return Collection<int, Cruise>
*/
public function getCruises(): Collection
{
return $this->cruises;
}
public function addCruise(Cruise $cruise): self
{
if (!$this->cruises->contains($cruise)) {
$this->cruises[] = $cruise;
$cruise->setItinerary($this);
}
return $this;
}
public function removeCruise(Cruise $cruise): self
{
if ($this->cruises->removeElement($cruise)) {
// set the owning side to null (unless already changed)
if ($cruise->getItinerary() === $this) {
$cruise->setItinerary(null);
}
}
return $this;
}
public function getOriginCompany(): ?Company
{
return $this->originCompany;
}
public function setOriginCompany(?Company $originCompany): self
{
$this->originCompany = $originCompany;
return $this;
}
public function getItineraryComputed(): ?ItineraryComputed
{
return $this->computed;
}
public function setItineraryComputed(?ItineraryComputed $computed): void
{
$this->computed = $computed;
}
/**
* @return Collection<int, ItineraryActivity> <p>Ordered by ListOrder</p>
*/
public function getItineraryActivities(): Collection
{
return $this->itineraryActivities;
}
public function addItineraryActivity(ItineraryActivity $itineraryActivity): self
{
if ($this->itineraryActivities->contains($itineraryActivity)) {
return $this;
}
$itineraryActivity->setItinerary($this);
$this->itineraryActivities[] = $itineraryActivity;
return $this;
}
public function removeItineraryActivity(ItineraryActivity $itineraryActivity): self
{
if ($this->itineraryActivities->removeElement($itineraryActivity)) {
// set the owning side to null (unless already changed)
if ($itineraryActivity->getItinerary() === $this) {
$itineraryActivity->setItinerary(null);
}
}
return $this;
}
public function getConsistencyReports(): Collection
{
return $this->consistencyReports;
}
public function addConsistencyReport(ItineraryConsistencyReport $report): self
{
if (!$this->consistencyReports->contains($report)) {
$this->consistencyReports[] = $report;
$report->setItinerary($this);
}
return $this;
}
public function removeConsistencyReport(ItineraryConsistencyReport $report): self
{
if ($this->consistencyReports->removeElement($report)) {
if ($report->getItinerary() === $this) {
$report->setItinerary(null);
}
}
return $this;
}
public function getConsistencyScore(): ?int
{
return $this->consistencyScore;
}
public function setConsistencyScore(?int $consistencyScore): self
{
$this->consistencyScore = $consistencyScore;
return $this;
}
}