<?php
namespace App\Entity\Booking;
use App\Entity\Address\AddressUser;
use App\Entity\Article\Service;
use App\Entity\Course\Plan;
use App\Entity\Payment\Payment;
use App\Entity\User;
use App\Repository\Booking\BookingRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=BookingRepository::class)
* @ORM\Table(name="`booking`")
*/
class Booking
{
public const STATE_IN_PROGRESS = 'in_progress';
public const STATE_AWAITING_PAYMENT = 'awaiting_payment';
public const STATE_COMPLETED = 'completed';
public const STATE_FULFILLED = 'fulfilled';
public const STATE_CANCELLED = 'cancelled';
public const STATE_REJECTED = 'rejected';
public const STATE_FAILED = 'failed';
public $states = array(
self::STATE_IN_PROGRESS => 'admin.booking.states.in_progress',
self::STATE_FULFILLED => 'admin.booking.states.fulfilled',
self::STATE_CANCELLED => 'admin.booking.states.cancelled',
self::STATE_REJECTED => 'admin.booking.states.rejected',
self::STATE_FAILED => 'admin.booking.states.failed'
);
public $checkoutStates = array(
self::STATE_IN_PROGRESS => 'admin.booking.states.in_progress',
self::STATE_COMPLETED => 'admin.booking.states.completed',
self::STATE_CANCELLED => 'admin.booking.states.cancelled',
self::STATE_REJECTED => 'admin.booking.states.rejected',
);
public $paymentStates = array(
Payment::STATE_NEW => 'New',
Payment::STATE_AWAITING_PAYMENT => 'Awaiting payment',
Payment::STATE_COMPLETED => 'admin.booking.states.completed',
Payment::STATE_FAILED => 'admin.booking.states.failed'
);
public $classes = array(
self::STATE_IN_PROGRESS => 'warning',
self::STATE_AWAITING_PAYMENT => 'info',
self::STATE_COMPLETED => 'success',
self::STATE_FULFILLED => 'primary',
self::STATE_CANCELLED => 'default',
self::STATE_REJECTED => 'danger',
self::STATE_FAILED => 'danger'
);
public $paymentClasses = array(
Payment::STATE_NEW => 'info',
Payment::STATE_AWAITING_PAYMENT => 'warning',
Payment::STATE_COMPLETED => 'success',
Payment::STATE_FAILED => 'danger'
);
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $number;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $type = 'horse';
/**
* @ORM\Column(type="text", nullable=true)
*/
private $notes;
/**
* @ORM\Column(type="string", length=255)
*/
private $state;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $duration;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $reservationDate;
/**
* @ORM\Column(type="integer")
*/
private $adults = 1;
/**
* @ORM\Column(type="integer")
*/
private $childrens = 0;
/**
* @ORM\Column(type="string", length=255)
*/
private $checkoutState;
/**
* @ORM\Column(type="string", length=255)
*/
private $paymentState;
/**
* @ORM\Column(type="integer")
*/
private $total;
/**
* @ORM\Column(type="integer")
*/
private $itemsTotal;
/**
* @ORM\Column(type="integer")
*/
private $dicountsTotal;
/**
* @ORM\Column(type="integer")
*/
private $taxesTotal;
/**
* @ORM\Column(type="string", length=5)
*/
private $currencyCode;
/**
* @ORM\Column(type="string", length=255)
*/
private $localeCode;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $checkoutCompletedAt;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=AddressUser::class, inversedBy="billingBookings", cascade={"persist"})
*/
private $billingAddress;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="bookings", cascade={"persist", "remove"})
*/
private $customer;
/**
* @ORM\OneToOne(targetEntity=Payment::class, mappedBy="checkout", cascade={"persist", "remove"})
*/
private $payment;
/**
* @ORM\Column(type="string", length=255)
*/
private $location = 'agafay';
/**
* @ORM\ManyToOne(targetEntity=Plan::class, inversedBy="bookings")
*/
private $plan;
/**
* @ORM\ManyToOne(targetEntity=Service::class, inversedBy="bookings")
*/
private $service;
public function __construct()
{
$this->total = 0;
$this->itemsTotal = 0;
$this->taxesTotal = 0;
$this->dicountsTotal = 0;
$this->currencyCode = 'MAD';
$this->state = self::STATE_IN_PROGRESS;
$this->checkoutState = self::STATE_IN_PROGRESS;
$this->paymentState = Payment::STATE_NEW;
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
}
public function __toString(): string
{
return '#' . $this->id;
}
public function getId(): ?int
{
return $this->id;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(string $number): self
{
$this->number = $number;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
public function getState(): ?string
{
return $this->state;
}
public function setState(string $state): self
{
$this->state = $state;
return $this;
}
public function getDuration(): ?int
{
return $this->duration;
}
public function setDuration(?int $duration): self
{
$this->duration = $duration;
return $this;
}
public function getReservationDate(): ?\DateTimeInterface
{
return $this->reservationDate;
}
public function setReservationDate(?\DateTimeInterface $reservationDate): self
{
$this->reservationDate = $reservationDate;
return $this;
}
public function getAdults(): ?int
{
return $this->adults;
}
public function setAdults(int $adults): self
{
$this->adults = $adults;
return $this;
}
public function getChildrens(): ?int
{
return $this->childrens;
}
public function setChildrens(int $childrens): self
{
$this->childrens = $childrens;
return $this;
}
public function getCheckoutState(): ?string
{
return $this->checkoutState;
}
public function setCheckoutState(string $checkoutState): self
{
$this->checkoutState = $checkoutState;
return $this;
}
public function getPaymentState(): ?string
{
return $this->paymentState;
}
public function setPaymentState(string $paymentState): self
{
$this->paymentState = $paymentState;
return $this;
}
public function getTotal(): ?int
{
return $this->total;
}
public function setTotal(int $total): self
{
$this->total = $total;
return $this;
}
public function getItemsTotal(): ?int
{
return $this->itemsTotal;
}
public function setItemsTotal(int $itemsTotal): self
{
$this->itemsTotal = $itemsTotal;
return $this;
}
public function getDicountsTotal(): ?int
{
return $this->dicountsTotal;
}
public function setDicountsTotal(int $dicountsTotal): self
{
$this->dicountsTotal = $dicountsTotal;
return $this;
}
public function getTaxesTotal(): int
{
return $this->taxesTotal;
}
public function setTaxesTotal(int $taxesTotal): self
{
$this->taxesTotal = $taxesTotal;
return $this;
}
public function getCurrencyCode(): ?string
{
return $this->currencyCode;
}
public function setCurrencyCode(string $currencyCode): self
{
$this->currencyCode = $currencyCode;
return $this;
}
public function getLocaleCode(): ?string
{
return $this->localeCode;
}
public function setLocaleCode(string $localeCode): self
{
$this->localeCode = $localeCode;
return $this;
}
public function getCheckoutCompletedAt(): ?\DateTimeInterface
{
return $this->checkoutCompletedAt;
}
public function setCheckoutCompletedAt(?\DateTimeInterface $checkoutCompletedAt): self
{
$this->checkoutCompletedAt = $checkoutCompletedAt;
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 getBillingAddress(): ?AddressUser
{
return $this->billingAddress;
}
public function setBillingAddress(?AddressUser $billingAddress): self
{
$this->billingAddress = $billingAddress;
return $this;
}
public function getCustomer(): ?User
{
return $this->customer;
}
public function setCustomer(?User $customer): self
{
$this->customer = $customer;
return $this;
}
public function getStatus($state)
{
return $this->states[$state] ?? $this->checkoutStates[$state];
}
public function getPaymentStatus($state)
{
return $this->paymentStates[$state];
}
public function getPayment(): ?Payment
{
return $this->payment;
}
public function setPayment(?Payment $payment): self
{
// unset the owning side of the relation if necessary
if ($payment === null && $this->payment !== null) {
$this->payment->setCheckout(null);
}
// set the owning side of the relation if necessary
if ($payment !== null && $payment->getCheckout() !== $this) {
$payment->setCheckout($this);
}
$this->payment = $payment;
return $this;
}
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(string $location): self
{
$this->location = $location;
return $this;
}
public function getPlan(): ?Plan
{
return $this->plan;
}
public function setPlan(?Plan $plan): self
{
$this->plan = $plan;
return $this;
}
public function getService(): ?Service
{
return $this->service;
}
public function setService(?Service $service): self
{
$this->service = $service;
return $this;
}
}