src/Entity/RDV.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Contract;
  4. use App\Entity\RDVProduct;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\RDVRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. /**
  11.  * Contract
  12.  *
  13.  * @ORM\Table(name="`rdv`")
  14.  * @ORM\Entity(repositoryClass=RDVRepository::class)
  15.  * @ORM\HasLifecycleCallbacks()
  16.  */
  17. class RDV
  18. {
  19.     const STATUS_ANNULER 'cancel';
  20.     const STATUS_PLANIFIER 'plan';
  21.     const STATUS_VALIDATED 'validated';
  22.     const STATUS_FACTURER 'billing';
  23.     const STATUS_REPORTE 'postponed';
  24.     const STATUS_REPLANIFIER 'rescheduled';
  25.     const STATUS_FACTURE_ANNULER 'billing_cancel';
  26.     const STATUS_NON_PAYE 'not_paid';
  27.     /**
  28.      * @var int
  29.      * @Groups("rdv")
  30.      * @ORM\Column(name="id", type="integer", nullable=false)
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="IDENTITY")
  33.      */
  34.     private $id;
  35.     /**
  36.      * @var string|null
  37.      * @Groups("rdv")
  38.      * @ORM\Column(name="priorite", type="string", nullable=true)
  39.      */
  40.     private $priorite 1;
  41.     /**
  42.      *
  43.      * @var string|null
  44.      *
  45.      * @ORM\Column(name="validated", type="datetime", nullable=true)
  46.      */
  47.     private $validated;
  48.     /**
  49.      * @var string|null
  50.      * @Groups("rdv")
  51.      * @ORM\Column(name="status", type="string", nullable=true)
  52.      */
  53.     private $status self::STATUS_PLANIFIER;
  54.     /**
  55.      * @Groups("rdv")
  56.      * @var \DateTime|null
  57.      *
  58.      * @ORM\Column(name="`start`", type="datetime", nullable=true)
  59.      */
  60.     private $start;
  61.     /**
  62.      * @Groups("rdv")
  63.      * @var string|null
  64.      * @ORM\Column(name="`end`", type="datetime", nullable=true)
  65.      */
  66.     private $end;
  67.     /**
  68.      * @var string|null
  69.      *
  70.      * @ORM\Column(name="comment", type="text", nullable=true)
  71.      */
  72.     private $comment;
  73.     /**
  74.      * @var string|null
  75.      *
  76.      * @ORM\Column(name="comment_forfait", type="text", nullable=true)
  77.      */
  78.     private $commentForfait;
  79.     /**
  80.      * @var RDVProduct ArrayCollection
  81.      * @ORM\OneToMany(targetEntity=RDVProduct::class, mappedBy="rdv", cascade={"remove", "persist"})
  82.      */
  83.     protected $rdvProducts;
  84.     /**
  85.      * @var RDVBilling
  86.      * @ORM\OneToMany(targetEntity=Billing::class, mappedBy="RDV")
  87.      */
  88.     protected $billings;
  89.     /**
  90.      * @Groups("rdv")
  91.      * @var Intervenant
  92.      * @ORM\ManyToOne(targetEntity=Intervenant::class, inversedBy="rdv")
  93.      * @ORM\JoinColumn(name="intervenant_type", referencedColumnName="id")
  94.      */
  95.     private $intervenant;
  96.     /**
  97.      * @Groups("rdv")
  98.      * @var Contract
  99.      * @ORM\ManyToOne(targetEntity=Contract::class, inversedBy="rdvs")
  100.      * @ORM\JoinColumn(name="contract", referencedColumnName="id", onDelete="SET NULL")
  101.      */
  102.     private $contract;
  103.     /**
  104.      * @var CancelReason
  105.      *
  106.      * @ORM\ManyToOne(targetEntity=CancelReason::class)
  107.      * @ORM\JoinColumn(name="cancel_reason_id", referencedColumnName="id")
  108.      */
  109.     private $cancelReason;
  110.     /**
  111.      * @Groups("rdv")
  112.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="rdv", cascade={"persist"})
  113.      * @ORM\JoinColumn(name="client_id", referencedColumnName="id", onDelete="SET NULL")
  114.      *
  115.      */
  116.     protected $client;
  117.     /**
  118.      * @ORM\ManyToOne(targetEntity=Salon::class, inversedBy="rdvs")
  119.      * @ORM\JoinColumn(name="salon_id", referencedColumnName="id", onDelete="SET NULL")
  120.      *
  121.      */
  122.     protected $salon;
  123.     /**
  124.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="rdv")
  125.      * @ORM\JoinColumn(name="author_id", referencedColumnName="id", onDelete="SET NULL")
  126.      *
  127.      */
  128.     protected $author;
  129.     /**
  130.      * @ORM\OneToMany(targetEntity="App\Entity\RDVBilling", mappedBy="RDV")
  131.      */
  132.     private $RDVBillings;
  133.     /**
  134.      * @ORM\Column(type="string", length=255, nullable=true)
  135.      */
  136.     private $recurrence;
  137.     /**
  138.      * @ORM\Column(type="string", length=50, nullable=true)
  139.      */
  140.     private $hasAddService;
  141.     /**
  142.      * @ORM\Column(type="string", length=255, nullable=true)
  143.      */
  144.     private $orderId;
  145.     /**
  146.      * @ORM\Column(type="string", length=255, nullable=true)
  147.      */
  148.     private $paymentLink;
  149.     /**
  150.      * @ORM\Column(type="boolean", nullable=true)
  151.      */
  152.     private $isPlatform false;
  153.     /**
  154.      * @ORM\Column(type="boolean", nullable=true)
  155.      */
  156.     private $newRecurrence false;
  157.     /**
  158.      * @ORM\ManyToOne(targetEntity=Recurrence::class, inversedBy="rdvs")
  159.      */
  160.     private $recurrenceRdvs;
  161.     /**
  162.      * @ORM\Column(type="boolean", nullable=true)
  163.      */
  164.     private $chequeReception;
  165.     /**
  166.      * @ORM\Column(type="string", length=255, nullable=true)
  167.      */
  168.     private $infoCheque;
  169.     /**
  170.      * @ORM\ManyToOne(targetEntity=PromoCode::class, inversedBy="rDVs")
  171.      */
  172.     private $codePromo;
  173.     /**
  174.      * @ORM\Column(type="boolean", nullable=true)
  175.      */
  176.     private $codePromoApplied;
  177.     public function __clone()
  178.                                                  {
  179.                                                      $this->id null;
  180.                                                  }
  181.     public function __toString()
  182.                                                  {
  183.                                                      return '' $this->getId();
  184.                                                      // TODO: Implement __toString() method.
  185.                                                  }
  186.     public function __construct()
  187.                                                  {
  188.                                                      $this->rdvProducts = new ArrayCollection();
  189.                                                      $this->RDVBillings = new ArrayCollection();
  190.                                                  }
  191.     public function getId(): ?int
  192.                                                  {
  193.                                                      return $this->id;
  194.                                                  }
  195.     /**
  196.      * @return Intervenant
  197.      */
  198.     public function getIntervenant(): ?Intervenant
  199.                                                  {
  200.                                                      return $this->intervenant;
  201.                                                  }
  202.     /**
  203.      * @param Intervenant $intervenant
  204.      */
  205.     public function setIntervenant(Intervenant $intervenant): void
  206.                                                  {
  207.                                                      $this->intervenant $intervenant;
  208.                                                  }
  209.     /**
  210.      * @return Client
  211.      */
  212.     public function getClient()
  213.                                                  {
  214.                                                      return $this->client;
  215.                                                  }
  216.     /**
  217.      * @param mixed $client
  218.      */
  219.     public function setClient($client): void
  220.                                                  {
  221.                                                      $this->client $client;
  222.                                                  }
  223.     /**
  224.      * @return \DateTime|null
  225.      */
  226.     public function getStart()
  227.                                                  {
  228.                                                      return $this->start;
  229.                                                  }
  230.     /**
  231.      * @param \DateTime|null $start
  232.      */
  233.     public function setStart($start): void
  234.                                                  {
  235.                                                      $this->start $start;
  236.                                                  }
  237.     /**
  238.      * @return \DateTime|null
  239.      */
  240.     public function getEnd()
  241.                                                  {
  242.                                                      return $this->end;
  243.                                                  }
  244.     /**
  245.      * @param \DateTime|null $end
  246.      */
  247.     public function setEnd($end): void
  248.                                                  {
  249.                                                      $this->end $end;
  250.                                                  }
  251.     /**
  252.      * @return Salon|null
  253.      */
  254.     public function getSalon()
  255.                                                  {
  256.                                                      return $this->salon;
  257.                                                  }
  258.     /**
  259.      * @param mixed $salon
  260.      */
  261.     public function setSalon($salon): void
  262.                                                  {
  263.                                                      $this->salon $salon;
  264.                                                  }
  265.     /**
  266.      * @return string|null
  267.      */
  268.     public function getPriorite(): ?string
  269.                                                  {
  270.                                                      return $this->priorite;
  271.                                                  }
  272.     /**
  273.      * @param string|null $priorite
  274.      */
  275.     public function setPriorite(?string $priorite): void
  276.                                                  {
  277.                                                      $this->priorite $priorite;
  278.                                                  }
  279.     /**
  280.      * @return string|null
  281.      */
  282.     public function getStatus(): ?string
  283.                                                  {
  284.                                                      return $this->status;
  285.                                                  }
  286.     /**
  287.      * @param string|null $status
  288.      */
  289.     public function setStatus(?string $status): void
  290.                                                  {
  291.                                                      $this->status $status;
  292.                                                  }
  293.     /**
  294.      * @return string|null
  295.      */
  296.     public function getComment(): ?string
  297.                                                  {
  298.                                                      return $this->comment;
  299.                                                  }
  300.     /**
  301.      * @param string|null $comment
  302.      */
  303.     public function setComment(?string $comment): void
  304.                                                  {
  305.                                                      $this->comment $comment;
  306.                                                  }
  307.     /**
  308.      * @return RDVProduct
  309.      */
  310.     public function getRdvProducts()
  311.                                                  {
  312.                                                      return $this->rdvProducts;
  313.                                                  }
  314.     /**
  315.      * @param $rdvProducts
  316.      */
  317.     public function setRdvProducts($rdvProducts): void
  318.                                                  {
  319.                                                      $this->rdvProducts $rdvProducts;
  320.                                                  }
  321.     /**
  322.      * @return CancelReason|null
  323.      */
  324.     public function getCancelReason(): ?CancelReason
  325.                                                  {
  326.                                                      return $this->cancelReason;
  327.                                                  }
  328.     /**
  329.      * @param CancelReason $cancelReason
  330.      */
  331.     public function setCancelReason(CancelReason $cancelReason): void
  332.                                                  {
  333.                                                      $this->cancelReason $cancelReason;
  334.                                                  }
  335.     /**
  336.      * @return \DateTime|null
  337.      */
  338.     public function getValidated()
  339.                                                  {
  340.                                                      return $this->validated;
  341.                                                  }
  342.     /**
  343.      * @param string|null $validated
  344.      */
  345.     public function setValidated($validated): void
  346.                                                  {
  347.                                                      $this->validated $validated;
  348.                                                  }
  349.     /**
  350.      * @return \App\Entity\User
  351.      */
  352.     public function getAuthor()
  353.                                                  {
  354.                                                      return $this->author;
  355.                                                  }
  356.     /**
  357.      * @param mixed $author
  358.      */
  359.     public function setAuthor($author): void
  360.                                                  {
  361.                                                      $this->author $author;
  362.                                                  }
  363.     public static function getRDVLabel($value)
  364.                                                  {
  365.                   
  366.                                                      switch ($value) {
  367.                                                          case self::STATUS_ANNULER:
  368.                                                              return 'Annulé';
  369.                                                              break;
  370.                                                          case self::STATUS_PLANIFIER:
  371.                                                              return 'Planifié';
  372.                                                              break;
  373.                                                          case self::STATUS_VALIDATED:
  374.                                                              return 'Validé';
  375.                                                              break;
  376.                                                          case self::STATUS_FACTURER:
  377.                                                              return 'Facturé';
  378.                                                              break;
  379.                                                          case self::STATUS_REPORTE:
  380.                                                              return 'Reporté';
  381.                                                              break;
  382.                                                          case self::STATUS_REPLANIFIER:
  383.                                                              return 'Replanifié';
  384.                                                              break;
  385.                                                      }
  386.                                                  }
  387.     /**
  388.      * @return string|null
  389.      */
  390.     public function getCommentForfait(): ?string
  391.                                                  {
  392.                                                      return $this->commentForfait;
  393.                                                  }
  394.     /**
  395.      * @param string|null $commentForfait
  396.      */
  397.     public function setCommentForfait(?string $commentForfait): void
  398.                                                  {
  399.                                                      $this->commentForfait $commentForfait;
  400.                                                  }
  401.     /**
  402.      * @return Collection|RDVBilling[]
  403.      */
  404.     public function setRDVBillings($rdvBillings)
  405.                                                  {
  406.                                                      $this->RDVBillings $rdvBillings;
  407.                                                  }
  408.     /**
  409.      * @return Collection|RDVBilling[]
  410.      */
  411.     public function getRDVBillings(): Collection
  412.                                                  {
  413.                                                      return $this->RDVBillings;
  414.                                                  }
  415.     /**
  416.      * @return ArrayCollection
  417.      */
  418.     public function getBillings()
  419.                                                  {
  420.                                                      return $this->billings;
  421.                                                  }
  422.     /**
  423.      * @param \App\Entity\RDVProduct $billings
  424.      */
  425.     public function setBillings($billings): void
  426.                                                  {
  427.                                                      $this->billings $billings;
  428.                                                  }
  429.     /**
  430.      * @return Contract
  431.      */
  432.     public function getContract(): ?\App\Entity\Contract
  433.                                                  {
  434.                                                      return $this->contract;
  435.                                                  }
  436.     /**
  437.      * @param Contract $contract
  438.      */
  439.     public function setContract(Contract $contract): void
  440.                                                  {
  441.                                                      $this->contract $contract;
  442.                                                  }
  443.     public function addRdvProduct(\App\Entity\RDVProduct $rdvProduct): self
  444.                                                  {
  445.                                                      if (!$this->rdvProducts->contains($rdvProduct)) {
  446.                                                          $this->rdvProducts[] = $rdvProduct;
  447.                                                          $rdvProduct->setRdv($this);
  448.                                                      }
  449.                   
  450.                                                      return $this;
  451.                                                  }
  452.     public function addRDVBilling(RDVBilling $rDVBilling): self
  453.                                                  {
  454.                                                      if (!$this->RDVBillings->contains($rDVBilling)) {
  455.                                                          $this->RDVBillings[] = $rDVBilling;
  456.                                                          $rDVBilling->setRDV($this);
  457.                                                      }
  458.                   
  459.                                                      return $this;
  460.                                                  }
  461.     public function removeRDVBilling(RDVBilling $rDVBilling): self
  462.                                                  {
  463.                                                      if ($this->RDVBillings->contains($rDVBilling)) {
  464.                                                          $this->RDVBillings->removeElement($rDVBilling);
  465.                                                          // set the owning side to null (unless already changed)
  466.                                                          if ($rDVBilling->getRDV() === $this) {
  467.                                                              $rDVBilling->setRDV(null);
  468.                                                          }
  469.                                                      }
  470.                   
  471.                                                      return $this;
  472.                                                  }
  473.     public function getRecurrence(): ?string
  474.                                                  {
  475.                                                      return $this->recurrence;
  476.                                                  }
  477.     public function setRecurrence(?string $recurrence): self
  478.                                                  {
  479.                                                      $this->recurrence $recurrence;
  480.                   
  481.                                                      return $this;
  482.                                                  }
  483.     public function getHasAddService(): ?string
  484.                                                  {
  485.                                                      return $this->hasAddService;
  486.                                                  }
  487.     public function setHasAddService(?string $hasAddService): self
  488.                                                  {
  489.                                                      $this->hasAddService $hasAddService;
  490.                   
  491.                                                      return $this;
  492.                                                  }
  493.     public function getOrderId(): ?string
  494.                                                  {
  495.                                                      return $this->orderId;
  496.                                                  }
  497.     public function setOrderId(?string $orderId): self
  498.                                                  {
  499.                                                      $this->orderId $orderId;
  500.                   
  501.                                                      return $this;
  502.                                                  }
  503.     public function getPaymentLink(): ?string
  504.                                                  {
  505.                                                      return $this->paymentLink;
  506.                                                  }
  507.     public function setPaymentLink(?string $paymentLink): self
  508.                                                  {
  509.                                                      $this->paymentLink $paymentLink;
  510.                   
  511.                                                      return $this;
  512.                                                  }
  513.     public function isPlatform(): ?bool
  514.                                                  {
  515.                                                      return $this->isPlatform;
  516.                                                  }
  517.     public function setIsPlatform(?bool $isPlatform): self
  518.                                                  {
  519.                                                      $this->isPlatform $isPlatform;
  520.                   
  521.                                                      return $this;
  522.                                                  }
  523.     public function ttc(){
  524.                                                      $totalTtc 0;
  525.                                                      /** @var RDVProduct $rdvProduct */
  526.                                                      foreach ($this->rdvProducts as $rdvProduct ){
  527.                                                          /** @var Product $product */
  528.                                                          $product $rdvProduct->getProduct();
  529.                                                          $salon $this->getSalon();
  530.                                                          if($product && $salon){
  531.                                                              $totalTtc += $product->getPriceSellTTCByGrid($salon->getGridPrice() ? $salon->getGridPrice()->getId() : );
  532.                                                          }
  533.                                                      }
  534.                                                      return $totalTtc;
  535.                                                  }
  536.     public function getRecurrenceRdvs(): ?Recurrence
  537.     {
  538.         return $this->recurrenceRdvs;
  539.     }
  540.     public function setRecurrenceRdvs(?Recurrence $recurrenceRdvs): self
  541.     {
  542.         $this->recurrenceRdvs $recurrenceRdvs;
  543.         return $this;
  544.     }
  545.     /**
  546.      * @return bool
  547.      */
  548.     public function isNewRecurrence(): bool
  549.                                         {
  550.                                             return $this->newRecurrence;
  551.                                         }
  552.     /**
  553.      * @param bool $newRecurrence
  554.      */
  555.     public function setNewRecurrence(bool $newRecurrence): void
  556.                                         {
  557.                                             $this->newRecurrence $newRecurrence;
  558.                                         }
  559.     public function getChequeReception(): ?bool
  560.     {
  561.         return $this->chequeReception;
  562.     }
  563.     public function setChequeReception(?bool $chequeReception): self
  564.     {
  565.         $this->chequeReception $chequeReception;
  566.         return $this;
  567.     }
  568.     public function getInfoCheque(): ?string
  569.     {
  570.         return $this->infoCheque;
  571.     }
  572.     public function setInfoCheque(?string $infoCheque): self
  573.     {
  574.         $this->infoCheque $infoCheque;
  575.         return $this;
  576.     }
  577.     public function getCodePromo(): ?PromoCode
  578.     {
  579.         return $this->codePromo;
  580.     }
  581.     public function setCodePromo(?PromoCode $codePromo): self
  582.     {
  583.         $this->codePromo $codePromo;
  584.         return $this;
  585.     }
  586.     public function isCodePromoApplied(): ?bool
  587.     {
  588.         return $this->codePromoApplied;
  589.     }
  590.     public function setCodePromoApplied(?bool $codePromoApplied): self
  591.     {
  592.         $this->codePromoApplied $codePromoApplied;
  593.         return $this;
  594.     }
  595. }