<?php
namespace App\Entity;
use App\Repository\MarketplaceReservationRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=MarketplaceReservationRepository::class)
*/
class MarketplaceReservation
{
const PAYMENT_STATUS_FREE = 'free';
const PAYMENT_STATUS_PENDING = 'pending';
const PAYMENT_STATUS_CANCELED = 'canceled';
const PAYMENT_STATUS_FAILED = 'failed';
const PAYMENT_STATUS_SUCCESS = 'success';
const PAYMENT_STATUS_REFUND_PENDING = 'pending_refund';
const PAYMENT_STATUS_REFUND = 'refund';
const STATUS_PENDING = 'pending'; // when the registration needs a confirmation (aka: payment most of the time)
const STATUS_PENDING_CANCELLATION = 'pending_cancellation';
const STATUS_CANCELED = 'canceled';
const STATUS_ACCEPTED = 'accepted';
const STATUS_REFUSED = 'refused';
const STATUSES = [
self::STATUS_PENDING,
self::STATUS_ACCEPTED,
self::STATUS_PENDING_CANCELLATION,
self::STATUS_CANCELED,
self::STATUS_REFUSED,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fullName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lastName;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="marketplaceReservations")
*/
private $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $adress;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateStart;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $hourStart;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $family;
/**
* @ORM\ManyToOne(targetEntity=MarketplaceCategory::class, inversedBy="marketplaceReservations")
*/
private $category;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Choice(choices=self::STATUSES)
*/
private $status = self::STATUS_PENDING;
/**
* @ORM\OneToOne(targetEntity=Event::class, inversedBy="marketplaceReservation", cascade={"persist", "remove"})
*/
private $event;
/**
* @ORM\ManyToOne(targetEntity=Workshop::class, inversedBy="marketplaceReservations")
*/
private $workshop;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $paymentAmount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $payment;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $paymentStatus;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $refundAmount;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $refundDate;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $town;
public function getId(): ?int
{
return $this->id;
}
public function getFullName(): ?string
{
return $this->fullName;
}
public function setFullName(?string $fullName): self
{
$this->fullName = $fullName;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(?string $adress): self
{
$this->adress = $adress;
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(?\DateTimeInterface $dateStart): self
{
$this->dateStart = $dateStart;
return $this;
}
public function getHourStart(): ?\DateTimeInterface
{
return $this->hourStart;
}
public function setHourStart(?\DateTimeInterface $hourStart): self
{
$this->hourStart = $hourStart;
return $this;
}
public function getFamily(): ?int
{
return $this->family;
}
public function setFamily(?int $family): self
{
$this->family = $family;
return $this;
}
public function getCategory(): ?MarketplaceCategory
{
return $this->category;
}
public function setCategory(?MarketplaceCategory $category): self
{
$this->category = $category;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getEvent(): ?Event
{
return $this->event;
}
public function setEvent(?Event $event): self
{
$this->event = $event;
return $this;
}
public function getWorkshop(): ?Workshop
{
return $this->workshop;
}
public function setWorkshop(?Workshop $workshop): self
{
$this->workshop = $workshop;
return $this;
}
public function getPaymentAmount(): ?float
{
return $this->paymentAmount;
}
public function setPaymentAmount(?float $paymentAmount): self
{
$this->paymentAmount = $paymentAmount;
return $this;
}
public function getPayment(): ?string
{
return $this->payment;
}
public function setPayment(?string $payment): self
{
$this->payment = $payment;
return $this;
}
public function getPaymentStatus(): ?string
{
return $this->paymentStatus;
}
public function setPaymentStatus(?string $paymentStatus): self
{
$this->paymentStatus = $paymentStatus;
return $this;
}
public function getRefundAmount(): ?float
{
return $this->refundAmount;
}
public function setRefundAmount(?float $refundAmount): self
{
$this->refundAmount = $refundAmount;
return $this;
}
public function getRefundDate(): ?\DateTimeInterface
{
return $this->refundDate;
}
public function setRefundDate(?\DateTimeInterface $refundDate): self
{
$this->refundDate = $refundDate;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function isPending(): Bool
{
return $this->status == self::STATUS_PENDING;
}
public function isAccepted(): Bool
{
return $this->status == self::STATUS_ACCEPTED;
}
public function isRefused(): Bool
{
return $this->status == self::STATUS_REFUSED;
}
public function isCanceled(): Bool
{
return $this->status == self::STATUS_CANCELED;
}
public function isPaid(): Bool
{
return (!empty($this->getPaymentAmount()) && $this->getPaymentStatus() == self::PAYMENT_STATUS_SUCCESS && !empty($this->getPayment()));
}
public function isRefund(): Bool
{
return (!empty($this->getPaymentAmount()) && $this->getPaymentStatus() == self::PAYMENT_STATUS_REFUND && !empty($this->getRefundAmount()));
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(?string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getTown(): ?string
{
return $this->town;
}
public function setTown(?string $town): self
{
$this->town = $town;
return $this;
}
}