caisse-bliss/nope/Entity/Festival.php

446 lines
8.7 KiB
PHP
Raw Permalink Normal View History

2018-04-05 15:05:04 +02:00
<?php
2023-06-20 19:14:19 +02:00
namespace App\Entity;
2018-04-05 15:05:04 +02:00
2023-06-20 19:14:19 +02:00
use App\Traits\Commentable;
2018-04-05 15:05:04 +02:00
use Doctrine\ORM\Mapping as ORM;
/**
* Festival
*
* @ORM\Table(name="festival")
2023-06-20 19:14:19 +02:00
* @ORM\Entity(repositoryClass="App\Repository\FestivalRepository")
2018-04-05 15:05:04 +02:00
*/
class Festival {
2018-04-17 16:15:24 +02:00
use Commentable;
2018-04-05 15:05:04 +02:00
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var \DateTime
*
* @ORM\Column(name="dateCreation", type="datetime")
*/
private $dateCreation;
/**
* @var \stdClass
*
2023-06-20 19:14:19 +02:00
* @ORM\OneToMany(targetEntity="App\Entity\SellRecord",mappedBy="festival", cascade={"remove"})
2018-04-05 15:05:04 +02:00
*/
private $sellRecords;
2018-04-17 15:41:00 +02:00
/**
2023-06-20 19:14:19 +02:00
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="festivals")
2018-04-17 15:41:00 +02:00
*/
private $user;
2018-08-22 16:42:21 +02:00
/**
2023-06-20 19:14:19 +02:00
* @ORM\ManyToOne(targetEntity="App\Entity\SerieFestival", inversedBy="festivals")
2018-08-22 16:42:21 +02:00
*/
private $serieFestival;
2018-04-05 15:05:04 +02:00
2018-04-17 16:15:24 +02:00
/**
* @var
* @ORM\Column(name="fond_de_caisse_avant", type="float")
*/
private $fondDeCaisseAvant;
/**
* @var
* @ORM\Column(name="fond_de_caisse_apres", type="float")
*/
private $fondDeCaisseApres;
/**
* @var
* @ORM\Column(name="chiffre_affaire", type="float")
*/
private $chiffreAffaire;
2018-04-20 10:39:44 +02:00
/**
* @ORM\Column(type="decimal", scale=2, nullable=true)
*/
private $fraisInscription;
/**
* @ORM\Column(type="decimal", scale=2, nullable=true)
*/
private $fraisHebergement;
/**
* @ORM\Column(type="decimal", scale=2, nullable=true)
*/
private $fraisTransport;
/**
* @ORM\Column(type="decimal", scale=2, nullable=true)
*/
private $fraisRepas;
2018-04-17 16:15:24 +02:00
2023-06-28 16:16:11 +02:00
#[ORM\ManyToOne(inversedBy: 'festival')]
private ?Admin $admin = null;
2018-04-19 16:26:48 +02:00
2019-06-12 15:24:13 +02:00
public function __toString() {
2023-06-28 16:16:11 +02:00
return $this->getName();
}
2019-06-12 15:24:13 +02:00
/**
2018-08-22 16:42:21 +02:00
* @return mixed
*/
public function getSerieFestival()
{
return $this->serieFestival;
}
/**
* @param mixed $serieFestival
*/
public function setSerieFestival($serieFestival)
{
$this->serieFestival = $serieFestival;
}
2018-05-24 11:57:53 +02:00
/**
* array usable by js
* @return array
*/
public function makeArray(){
2023-06-28 16:16:11 +02:00
$sellRecords = $this->getSellRecords();
$soldItems = [];
foreach ( $sellRecords as $sell_record ) {
foreach ( $sell_record->getProductsSold() as $sold ) {
if(!isset($soldItems[$sold->getProduct()->getId()])){
$soldItems[$sold->getProduct()->getId()] = 0;
}
$soldItems[$sold->getProduct()->getId()]++;
}
}
return [
'id' => $this->getId(),
'name' => $this->getName(),
'commentaire' => $this->getComment(),
'dateCreation' => $this->getDateCreation(),
'chiffreAffaire' => $this->getChiffreAffaire(),
'clientsCount' => count($this->getSellRecords()),
'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(),
'fondDeCaisseApres' => $this->getFondDeCaisseApres(),
'sold' => $soldItems,
];
}
2018-04-19 16:26:48 +02:00
public function recalculateChiffreAffaire() {
2023-06-28 16:16:11 +02:00
$sellings = $this->getSellRecords();
$newChiffreAffaire = 0;
foreach ( $sellings as $selling ) {
$newChiffreAffaire += $selling->getAmount();
}
$this->setChiffreAffaire( $newChiffreAffaire );
return $this;
}
2018-04-19 16:26:48 +02:00
2018-04-05 15:05:04 +02:00
/**
* Get id
*
* @return int
*/
public function getId() {
2023-06-28 16:16:11 +02:00
return $this->id;
}
2018-04-05 15:05:04 +02:00
/**
* Set name
*
* @param string $name
*
* @return Festival
*/
public function setName( $name ) {
2023-06-28 16:16:11 +02:00
$this->name = $name;
return $this;
}
2018-04-05 15:05:04 +02:00
/**
* Get name
*
* @return string
*/
public function getName() {
2023-06-28 16:16:11 +02:00
return $this->name;
}
2018-04-05 15:05:04 +02:00
/**
* Set dateCreation
*
* @param \DateTime $dateCreation
*
* @return Festival
*/
public function setDateCreation( $dateCreation ) {
2023-06-28 16:16:11 +02:00
$this->dateCreation = $dateCreation;
return $this;
}
2018-04-05 15:05:04 +02:00
/**
* Get dateCreation
*
* @return \DateTime
*/
public function getDateCreation() {
2023-06-28 16:16:11 +02:00
return $this->dateCreation;
}
2018-04-05 15:05:04 +02:00
/**
* Set sellRecords
*
* @param \stdClass $sellRecords
*
* @return Festival
*/
public function setSellRecords( $sellRecords ) {
2023-06-28 16:16:11 +02:00
$this->sellRecords = $sellRecords;
return $this;
}
2018-04-05 15:05:04 +02:00
/**
* Get sellRecords
*
* @return \stdClass
*/
public function getSellRecords() {
2023-06-28 16:16:11 +02:00
return $this->sellRecords;
}
2018-04-17 15:41:00 +02:00
/**
* Constructor
*/
public function __construct() {
2023-06-28 16:16:11 +02:00
$this->sellRecords = new \Doctrine\Common\Collections\ArrayCollection();
}
2018-04-17 15:41:00 +02:00
/**
* Add sellRecord
*
2023-06-20 19:14:19 +02:00
* @param \App\Entity\SellRecord $sellRecord
2018-04-17 15:41:00 +02:00
*
* @return Festival
*/
2023-06-20 19:14:19 +02:00
public function addSellRecord( \App\Entity\SellRecord $sellRecord ) {
2023-06-28 16:16:11 +02:00
$this->sellRecords[] = $sellRecord;
return $this;
}
2018-04-17 15:41:00 +02:00
/**
* Remove sellRecord
*
2023-06-20 19:14:19 +02:00
* @param \App\Entity\SellRecord $sellRecord
2018-04-17 15:41:00 +02:00
*/
2023-06-20 19:14:19 +02:00
public function removeSellRecord( \App\Entity\SellRecord $sellRecord ) {
2023-06-28 16:16:11 +02:00
$this->sellRecords->removeElement( $sellRecord );
}
2018-04-17 15:41:00 +02:00
/**
* Set user.
*
2023-06-20 19:14:19 +02:00
* @param \App\Entity\User|null $user
2018-04-17 15:41:00 +02:00
*
* @return Festival
*/
2023-06-20 19:14:19 +02:00
public function setUser( \App\Entity\User $user = null ) {
2023-06-28 16:16:11 +02:00
$this->user = $user;
return $this;
}
2018-04-17 15:41:00 +02:00
/**
* Get user.
*
2023-06-20 19:14:19 +02:00
* @return \App\Entity\User|null
2018-04-17 15:41:00 +02:00
*/
public function getUser() {
2023-06-28 16:16:11 +02:00
return $this->user;
}
2018-04-17 16:15:24 +02:00
/**
* Set fondDeCaisseAvant.
*
* @param float $fondDeCaisseAvant
*
* @return Festival
*/
public function setFondDeCaisseAvant( $fondDeCaisseAvant ) {
2023-06-28 16:16:11 +02:00
$this->fondDeCaisseAvant = $fondDeCaisseAvant;
return $this;
}
2018-04-17 16:15:24 +02:00
/**
* Get fondDeCaisseAvant.
*
* @return float
*/
public function getFondDeCaisseAvant() {
2023-06-28 16:16:11 +02:00
return $this->fondDeCaisseAvant;
}
2018-04-17 16:15:24 +02:00
/**
* Set fondDeCaisseApres.
*
* @param float $fondDeCaisseApres
*
* @return Festival
*/
public function setFondDeCaisseApres( $fondDeCaisseApres ) {
2023-06-28 16:16:11 +02:00
$this->fondDeCaisseApres = $fondDeCaisseApres;
return $this;
}
2018-04-17 16:15:24 +02:00
/**
* Get fondDeCaisseApres.
*
* @return float
*/
public function getFondDeCaisseApres() {
2023-06-28 16:16:11 +02:00
return $this->fondDeCaisseApres;
}
2018-04-17 16:15:24 +02:00
/**
* Set chiffreAffaire.
*
* @param float $chiffreAffaire
*
* @return Festival
*/
public function setChiffreAffaire( $chiffreAffaire ) {
2023-06-28 16:16:11 +02:00
$this->chiffreAffaire = $chiffreAffaire;
return $this;
}
2018-04-17 16:15:24 +02:00
/**
* Get chiffreAffaire.
*
* @return float
*/
public function getChiffreAffaire() {
2023-06-28 16:16:11 +02:00
return $this->chiffreAffaire;
}
2018-04-20 10:39:44 +02:00
/**
* Set fraisInscription.
*
* @param string|null $fraisInscription
*
* @return Festival
*/
public function setFraisInscription( $fraisInscription = null ) {
2023-06-28 16:16:11 +02:00
$this->fraisInscription = $fraisInscription;
return $this;
}
2018-04-20 10:39:44 +02:00
/**
* Get fraisInscription.
*
* @return string|null
*/
public function getFraisInscription() {
2023-06-28 16:16:11 +02:00
return $this->fraisInscription;
}
2018-04-20 10:39:44 +02:00
/**
* Set fraisHebergement.
*
* @param string|null $fraisHebergement
*
* @return Festival
*/
public function setFraisHebergement( $fraisHebergement = null ) {
2023-06-28 16:16:11 +02:00
$this->fraisHebergement = $fraisHebergement;
return $this;
}
2018-04-20 10:39:44 +02:00
/**
* Get fraisHebergement.
*
* @return string|null
*/
public function getFraisHebergement() {
2023-06-28 16:16:11 +02:00
return $this->fraisHebergement;
}
2018-04-20 10:39:44 +02:00
/**
* Set fraisTransport.
*
* @param string|null $fraisTransport
*
* @return Festival
*/
public function setFraisTransport( $fraisTransport = null ) {
2023-06-28 16:16:11 +02:00
$this->fraisTransport = $fraisTransport;
return $this;
}
2018-04-20 10:39:44 +02:00
/**
* Get fraisTransport.
*
* @return string|null
*/
public function getFraisTransport() {
2023-06-28 16:16:11 +02:00
return $this->fraisTransport;
}
2018-04-20 10:39:44 +02:00
/**
* Set fraisRepas.
*
* @param string|null $fraisRepas
*
* @return Festival
*/
public function setFraisRepas( $fraisRepas = null ) {
2023-06-28 16:16:11 +02:00
$this->fraisRepas = $fraisRepas;
return $this;
}
2018-04-20 10:39:44 +02:00
/**
* Get fraisRepas.
*
* @return string|null
*/
public function getFraisRepas() {
2023-06-28 16:16:11 +02:00
return $this->fraisRepas;
}
public function getAdmin(): ?Admin
{
return $this->admin;
}
public function setAdmin(?Admin $admin): static
{
$this->admin = $admin;
return $this;
}
2018-04-05 15:05:04 +02:00
}