<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Cruise;
use Crea\ParameterBundle\Entity\Parameter;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Croisiland\CommonBundle\Annotation\Cruise\CruiseFormValidator;
use Croisiland\CommonBundle\Entity\Itinerary\Itinerary;
use Croisiland\CommonBundle\Entity\Offer\OfferCruise;
use Croisiland\CommonBundle\Entity\Price\Price;
use Croisiland\CommonBundle\Entity\Ship\Ship;
use Croisiland\CommonBundle\Entity\Traits\IncludedExcludedTrait;
use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
use Croisiland\CommonBundle\Entity\Traits\IsVisibleTrait;
use Croisiland\CommonBundle\Entity\Traits\ModuleOrderTrait;
use Croisiland\CommonBundle\Repository\Cruise\CruiseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @CruiseFormValidator(groups="cruise_form_validator")
*
* @ORM\Entity(repositoryClass=CruiseRepository::class)
*
* @ORM\Table(
* indexes={
*
* @ORM\Index(name="idx_cruise_itinerary_departure_date", fields={"itinerary", "departureDate"})
* }
* )
*/
class Cruise implements CruiseInterface
{
// TODO: propriétés à vérifier
// private ?string $paymentsWithoutCharge = null;
use IsActiveTrait;
use IsVisibleTrait;
use LifecycleUserIdentifierTrait;
use ModuleOrderTrait;
use IncludedExcludedTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $name = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $code = null;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $crush = false;
/**
* @Gedmo\Slug(fields={"name"}, updatable=false)
*
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private ?string $slug = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $flatFileDescription = null;
/**
* todo: vérifier si nullable=true est nécessaire et valeur par défaut.
*
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $flatFileImmediateConfirm = null;
/**
* @ORM\ManyToOne(targetEntity=Ship::class, inversedBy="cruises")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Ship $ship = null;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $manuallyCreated = false;
/**
* @ORM\Column(type="date")
*/
private ?\DateTimeInterface $departureDate = null;
/**
* @ORM\Column(type="date")
*/
private ?\DateTimeInterface $arrivalDate = null;
/**
* @var Collection<int, Price>
*
* @ORM\OneToMany(targetEntity=Price::class, mappedBy="cruise", orphanRemoval=true)
*/
private Collection $prices;
/**
* @ORM\ManyToOne(targetEntity=Price::class)
*
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private ?Price $bestPrice = null;
/**
* @ORM\ManyToOne(targetEntity=Price::class)
*
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private ?Price $bestPriceWithFlight = null;
/**
* @ORM\ManyToOne(targetEntity=Price::class)
*
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private ?Price $bestGroupPrice = null;
/**
* @ORM\ManyToOne(targetEntity=Price::class)
*
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private ?Price $bestGroupPriceWithFlight = null;
/**
* @ORM\ManyToOne(targetEntity=Itinerary::class, inversedBy="cruises")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Itinerary $itinerary = null;
/**
* @var Collection<int, TagCruise>
*
* @ORM\OneToMany(targetEntity=TagCruise::class, mappedBy="cruise", orphanRemoval=true, cascade={"persist"})
* @ORM\OrderBy({"listOrder" = "ASC"})
*/
private Collection $tagCruises;
/**
* @var Collection<int, OfferCruise>
*
* @ORM\OneToMany(targetEntity=OfferCruise::class, mappedBy="cruise", orphanRemoval=true, cascade={"persist"})
*/
private Collection $offerCruises;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $isErpItineraryHistoryUpToDate = false;
/**
* @ORM\ManyToOne(targetEntity=Parameter::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?Parameter $origin = null;
public function __construct()
{
$this->prices = new ArrayCollection();
$this->tagCruises = new ArrayCollection();
$this->offerCruises = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function isCrush(): ?bool
{
return $this->crush;
}
public function setCrush(bool $crush): self
{
$this->crush = $crush;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getFlatFileDescription(): ?string
{
return $this->flatFileDescription;
}
public function setFlatFileDescription(string $flatFileDescription): self
{
$this->flatFileDescription = $flatFileDescription;
return $this;
}
public function isFlatFileImmediateConfirm(): ?bool
{
return $this->flatFileImmediateConfirm;
}
public function setFlatFileImmediateConfirm(?bool $flatFileImmediateConfirm): self
{
$this->flatFileImmediateConfirm = $flatFileImmediateConfirm;
return $this;
}
public function getShip(): ?Ship
{
return $this->ship;
}
public function setShip(?Ship $ship): self
{
$this->ship = $ship;
return $this;
}
public function isManuallyCreated(): ?bool
{
return $this->manuallyCreated;
}
public function setManuallyCreated(bool $manuallyCreated): self
{
$this->manuallyCreated = $manuallyCreated;
return $this;
}
public function getDepartureDate(): ?\DateTimeInterface
{
return $this->departureDate;
}
public function setDepartureDate(?\DateTimeInterface $departureDate): self
{
$this->departureDate = $departureDate;
return $this;
}
public function getArrivalDate(): ?\DateTimeInterface
{
return $this->arrivalDate;
}
public function setArrivalDate(?\DateTimeInterface $arrivalDate): self
{
$this->arrivalDate = $arrivalDate;
return $this;
}
/**
* @return Collection<int, Price>
*/
public function getPrices(): Collection
{
return $this->prices;
}
public function addPrice(Price $price): self
{
if (!$this->prices->contains($price)) {
$this->prices[] = $price;
$price->setCruise($this);
}
return $this;
}
public function removePrice(Price $price): self
{
if ($this->prices->removeElement($price)) {
// set the owning side to null (unless already changed)
if ($price->getCruise() === $this) {
$price->setCruise(null);
}
}
return $this;
}
public function getBestPrice(): ?Price
{
return $this->bestPrice;
}
public function setBestPrice(?Price $bestPrice): self
{
$this->bestPrice = $bestPrice;
return $this;
}
public function getBestPriceWithFlight(): ?Price
{
return $this->bestPriceWithFlight;
}
public function setBestPriceWithFlight(?Price $bestPriceWithFlight): self
{
$this->bestPriceWithFlight = $bestPriceWithFlight;
return $this;
}
public function getBestGroupPrice(): ?Price
{
return $this->bestGroupPrice;
}
public function setBestGroupPrice(?Price $bestGroupPrice): self
{
$this->bestGroupPrice = $bestGroupPrice;
return $this;
}
public function getBestGroupPriceWithFlight(): ?Price
{
return $this->bestGroupPriceWithFlight;
}
public function setBestGroupPriceWithFlight(?Price $bestGroupPriceWithFlight): self
{
$this->bestGroupPriceWithFlight = $bestGroupPriceWithFlight;
return $this;
}
/**
* @return Collection<int, TagCruise>
*/
public function getTagCruises(): Collection
{
return $this->tagCruises;
}
public function addTagCruise(TagCruise $tagCruise): self
{
if (!$this->tagCruises->contains($tagCruise)) {
$this->tagCruises[] = $tagCruise;
$tagCruise->setCruise($this);
}
return $this;
}
public function removeTagCruise(TagCruise $tagCruise): self
{
if ($this->tagCruises->removeElement($tagCruise)) {
// set the owning side to null (unless already changed)
if ($tagCruise->getCruise() === $this) {
$tagCruise->setCruise(null);
}
}
return $this;
}
/**
* @return Collection<int, OfferCruise>
*/
public function getOfferCruises(): Collection
{
return $this->offerCruises;
}
public function addOfferCruise(OfferCruise $offerCruise): self
{
if (!$this->offerCruises->contains($offerCruise)) {
$this->offerCruises[] = $offerCruise;
$offerCruise->setCruise($this);
}
return $this;
}
public function removeOfferCruise(OfferCruise $offerCruise): self
{
if ($this->offerCruises->removeElement($offerCruise)) {
// set the owning side to null (unless already changed)
if ($offerCruise->getCruise() === $this) {
$offerCruise->setCruise(null);
}
}
return $this;
}
public function getItinerary(): ?Itinerary
{
return $this->itinerary;
}
public function setItinerary(?Itinerary $itinerary): self
{
$this->itinerary = $itinerary;
return $this;
}
public function isErpItineraryHistoryUpToDate(): bool
{
return $this->isErpItineraryHistoryUpToDate;
}
public function setIsErpItineraryHistoryUpToDate(bool $isErpItineraryHistoryUpToDate): self
{
$this->isErpItineraryHistoryUpToDate = $isErpItineraryHistoryUpToDate;
return $this;
}
/**
* @return Parameter|null
*/
public function getOrigin(): ?Parameter
{
return $this->origin;
}
/**
* @param Parameter|null $origin
* @return Cruise
*/
public function setOrigin(?Parameter $origin): Cruise
{
$this->origin = $origin;
return $this;
}
}