<?php
namespace App\Entity;
use App\Entity\Contract;
use App\Entity\RDVProduct;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\RDVRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* Contract
*
* @ORM\Table(name="`rdv`")
* @ORM\Entity(repositoryClass=RDVRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class RDV
{
const STATUS_ANNULER = 'cancel';
const STATUS_PLANIFIER = 'plan';
const STATUS_VALIDATED = 'validated';
const STATUS_FACTURER = 'billing';
const STATUS_REPORTE = 'postponed';
const STATUS_REPLANIFIER = 'rescheduled';
const STATUS_FACTURE_ANNULER = 'billing_cancel';
const STATUS_NON_PAYE = 'not_paid';
/**
* @var int
* @Groups("rdv")
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string|null
* @Groups("rdv")
* @ORM\Column(name="priorite", type="string", nullable=true)
*/
private $priorite = 1;
/**
*
* @var string|null
*
* @ORM\Column(name="validated", type="datetime", nullable=true)
*/
private $validated;
/**
* @var string|null
* @Groups("rdv")
* @ORM\Column(name="status", type="string", nullable=true)
*/
private $status = self::STATUS_PLANIFIER;
/**
* @Groups("rdv")
* @var \DateTime|null
*
* @ORM\Column(name="`start`", type="datetime", nullable=true)
*/
private $start;
/**
* @Groups("rdv")
* @var string|null
* @ORM\Column(name="`end`", type="datetime", nullable=true)
*/
private $end;
/**
* @var string|null
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @var string|null
*
* @ORM\Column(name="comment_forfait", type="text", nullable=true)
*/
private $commentForfait;
/**
* @var RDVProduct ArrayCollection
* @ORM\OneToMany(targetEntity=RDVProduct::class, mappedBy="rdv", cascade={"remove", "persist"})
*/
protected $rdvProducts;
/**
* @var RDVBilling
* @ORM\OneToMany(targetEntity=Billing::class, mappedBy="RDV")
*/
protected $billings;
/**
* @Groups("rdv")
* @var Intervenant
* @ORM\ManyToOne(targetEntity=Intervenant::class, inversedBy="rdv")
* @ORM\JoinColumn(name="intervenant_type", referencedColumnName="id")
*/
private $intervenant;
/**
* @Groups("rdv")
* @var Contract
* @ORM\ManyToOne(targetEntity=Contract::class, inversedBy="rdvs")
* @ORM\JoinColumn(name="contract", referencedColumnName="id", onDelete="SET NULL")
*/
private $contract;
/**
* @var CancelReason
*
* @ORM\ManyToOne(targetEntity=CancelReason::class)
* @ORM\JoinColumn(name="cancel_reason_id", referencedColumnName="id")
*/
private $cancelReason;
/**
* @Groups("rdv")
* @ORM\ManyToOne(targetEntity=Client::class, inversedBy="rdv", cascade={"persist"})
* @ORM\JoinColumn(name="client_id", referencedColumnName="id", onDelete="SET NULL")
*
*/
protected $client;
/**
* @ORM\ManyToOne(targetEntity=Salon::class, inversedBy="rdvs")
* @ORM\JoinColumn(name="salon_id", referencedColumnName="id", onDelete="SET NULL")
*
*/
protected $salon;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="rdv")
* @ORM\JoinColumn(name="author_id", referencedColumnName="id", onDelete="SET NULL")
*
*/
protected $author;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RDVBilling", mappedBy="RDV")
*/
private $RDVBillings;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $recurrence;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $hasAddService;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $orderId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $paymentLink;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isPlatform = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $newRecurrence = false;
/**
* @ORM\ManyToOne(targetEntity=Recurrence::class, inversedBy="rdvs")
*/
private $recurrenceRdvs;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $chequeReception;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $infoCheque;
/**
* @ORM\ManyToOne(targetEntity=PromoCode::class, inversedBy="rDVs")
*/
private $codePromo;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $codePromoApplied;
public function __clone()
{
$this->id = null;
}
public function __toString()
{
return '' . $this->getId();
// TODO: Implement __toString() method.
}
public function __construct()
{
$this->rdvProducts = new ArrayCollection();
$this->RDVBillings = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Intervenant
*/
public function getIntervenant(): ?Intervenant
{
return $this->intervenant;
}
/**
* @param Intervenant $intervenant
*/
public function setIntervenant(Intervenant $intervenant): void
{
$this->intervenant = $intervenant;
}
/**
* @return Client
*/
public function getClient()
{
return $this->client;
}
/**
* @param mixed $client
*/
public function setClient($client): void
{
$this->client = $client;
}
/**
* @return \DateTime|null
*/
public function getStart()
{
return $this->start;
}
/**
* @param \DateTime|null $start
*/
public function setStart($start): void
{
$this->start = $start;
}
/**
* @return \DateTime|null
*/
public function getEnd()
{
return $this->end;
}
/**
* @param \DateTime|null $end
*/
public function setEnd($end): void
{
$this->end = $end;
}
/**
* @return Salon|null
*/
public function getSalon()
{
return $this->salon;
}
/**
* @param mixed $salon
*/
public function setSalon($salon): void
{
$this->salon = $salon;
}
/**
* @return string|null
*/
public function getPriorite(): ?string
{
return $this->priorite;
}
/**
* @param string|null $priorite
*/
public function setPriorite(?string $priorite): void
{
$this->priorite = $priorite;
}
/**
* @return string|null
*/
public function getStatus(): ?string
{
return $this->status;
}
/**
* @param string|null $status
*/
public function setStatus(?string $status): void
{
$this->status = $status;
}
/**
* @return string|null
*/
public function getComment(): ?string
{
return $this->comment;
}
/**
* @param string|null $comment
*/
public function setComment(?string $comment): void
{
$this->comment = $comment;
}
/**
* @return RDVProduct
*/
public function getRdvProducts()
{
return $this->rdvProducts;
}
/**
* @param $rdvProducts
*/
public function setRdvProducts($rdvProducts): void
{
$this->rdvProducts = $rdvProducts;
}
/**
* @return CancelReason|null
*/
public function getCancelReason(): ?CancelReason
{
return $this->cancelReason;
}
/**
* @param CancelReason $cancelReason
*/
public function setCancelReason(CancelReason $cancelReason): void
{
$this->cancelReason = $cancelReason;
}
/**
* @return \DateTime|null
*/
public function getValidated()
{
return $this->validated;
}
/**
* @param string|null $validated
*/
public function setValidated($validated): void
{
$this->validated = $validated;
}
/**
* @return \App\Entity\User
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param mixed $author
*/
public function setAuthor($author): void
{
$this->author = $author;
}
public static function getRDVLabel($value)
{
switch ($value) {
case self::STATUS_ANNULER:
return 'Annulé';
break;
case self::STATUS_PLANIFIER:
return 'Planifié';
break;
case self::STATUS_VALIDATED:
return 'Validé';
break;
case self::STATUS_FACTURER:
return 'Facturé';
break;
case self::STATUS_REPORTE:
return 'Reporté';
break;
case self::STATUS_REPLANIFIER:
return 'Replanifié';
break;
}
}
/**
* @return string|null
*/
public function getCommentForfait(): ?string
{
return $this->commentForfait;
}
/**
* @param string|null $commentForfait
*/
public function setCommentForfait(?string $commentForfait): void
{
$this->commentForfait = $commentForfait;
}
/**
* @return Collection|RDVBilling[]
*/
public function setRDVBillings($rdvBillings)
{
$this->RDVBillings = $rdvBillings;
}
/**
* @return Collection|RDVBilling[]
*/
public function getRDVBillings(): Collection
{
return $this->RDVBillings;
}
/**
* @return ArrayCollection
*/
public function getBillings()
{
return $this->billings;
}
/**
* @param \App\Entity\RDVProduct $billings
*/
public function setBillings($billings): void
{
$this->billings = $billings;
}
/**
* @return Contract
*/
public function getContract(): ?\App\Entity\Contract
{
return $this->contract;
}
/**
* @param Contract $contract
*/
public function setContract(Contract $contract): void
{
$this->contract = $contract;
}
public function addRdvProduct(\App\Entity\RDVProduct $rdvProduct): self
{
if (!$this->rdvProducts->contains($rdvProduct)) {
$this->rdvProducts[] = $rdvProduct;
$rdvProduct->setRdv($this);
}
return $this;
}
public function addRDVBilling(RDVBilling $rDVBilling): self
{
if (!$this->RDVBillings->contains($rDVBilling)) {
$this->RDVBillings[] = $rDVBilling;
$rDVBilling->setRDV($this);
}
return $this;
}
public function removeRDVBilling(RDVBilling $rDVBilling): self
{
if ($this->RDVBillings->contains($rDVBilling)) {
$this->RDVBillings->removeElement($rDVBilling);
// set the owning side to null (unless already changed)
if ($rDVBilling->getRDV() === $this) {
$rDVBilling->setRDV(null);
}
}
return $this;
}
public function getRecurrence(): ?string
{
return $this->recurrence;
}
public function setRecurrence(?string $recurrence): self
{
$this->recurrence = $recurrence;
return $this;
}
public function getHasAddService(): ?string
{
return $this->hasAddService;
}
public function setHasAddService(?string $hasAddService): self
{
$this->hasAddService = $hasAddService;
return $this;
}
public function getOrderId(): ?string
{
return $this->orderId;
}
public function setOrderId(?string $orderId): self
{
$this->orderId = $orderId;
return $this;
}
public function getPaymentLink(): ?string
{
return $this->paymentLink;
}
public function setPaymentLink(?string $paymentLink): self
{
$this->paymentLink = $paymentLink;
return $this;
}
public function isPlatform(): ?bool
{
return $this->isPlatform;
}
public function setIsPlatform(?bool $isPlatform): self
{
$this->isPlatform = $isPlatform;
return $this;
}
public function ttc(){
$totalTtc = 0;
/** @var RDVProduct $rdvProduct */
foreach ($this->rdvProducts as $rdvProduct ){
/** @var Product $product */
$product = $rdvProduct->getProduct();
$salon = $this->getSalon();
if($product && $salon){
$totalTtc += $product->getPriceSellTTCByGrid($salon->getGridPrice() ? $salon->getGridPrice()->getId() : 1 );
}
}
return $totalTtc;
}
public function getRecurrenceRdvs(): ?Recurrence
{
return $this->recurrenceRdvs;
}
public function setRecurrenceRdvs(?Recurrence $recurrenceRdvs): self
{
$this->recurrenceRdvs = $recurrenceRdvs;
return $this;
}
/**
* @return bool
*/
public function isNewRecurrence(): bool
{
return $this->newRecurrence;
}
/**
* @param bool $newRecurrence
*/
public function setNewRecurrence(bool $newRecurrence): void
{
$this->newRecurrence = $newRecurrence;
}
public function getChequeReception(): ?bool
{
return $this->chequeReception;
}
public function setChequeReception(?bool $chequeReception): self
{
$this->chequeReception = $chequeReception;
return $this;
}
public function getInfoCheque(): ?string
{
return $this->infoCheque;
}
public function setInfoCheque(?string $infoCheque): self
{
$this->infoCheque = $infoCheque;
return $this;
}
public function getCodePromo(): ?PromoCode
{
return $this->codePromo;
}
public function setCodePromo(?PromoCode $codePromo): self
{
$this->codePromo = $codePromo;
return $this;
}
public function isCodePromoApplied(): ?bool
{
return $this->codePromoApplied;
}
public function setCodePromoApplied(?bool $codePromoApplied): self
{
$this->codePromoApplied = $codePromoApplied;
return $this;
}
}