<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\BFInscriptionRepository")
*/
class BFInscription
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFTournoi", inversedBy="inscriptions")
* @ORM\JoinColumn(nullable=false)
*/
private $tournoi;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFInscriptionUser", inversedBy="inscriptions1")
* @ORM\JoinColumn(nullable=false)
*/
private $inscriptionuser1;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFInscriptionUser", inversedBy="inscriptions2")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $inscriptionuser2;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFInscriptionUser", inversedBy="inscription3")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $inscriptionuser3;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFInscriptionUser", inversedBy="inscriptions4")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $inscriptionuser4;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFInscriptionUser", inversedBy="inscriptions5")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $inscriptionuser5;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFInscriptionUser", inversedBy="inscriptions6")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $inscriptionuser6;
/**
* @ORM\Column(type="datetime")
*/
private $creationdate;
/**
* @ORM\Column(type="datetime")
*/
private $updatedate;
public function __construct()
{
$this->inscriptionuser1= new BFInscriptionUser();
}
public function getId(): ?int
{
return $this->id;
}
public function getTournoi(): ?BFTournoi
{
return $this->tournoi;
}
public function setTournoi(?BFTournoi $tournoi): self
{
$this->tournoi = $tournoi;
return $this;
}
public function getInscriptionuser1(): ?BFInscriptionUser
{
return $this->inscriptionuser1;
}
public function setInscriptionuser1(?BFInscriptionUser $inscriptionuser1): self
{
$this->inscriptionuser1 = $inscriptionuser1;
return $this;
}
public function getInscriptionuser2(): ?BFInscriptionUser
{
return $this->inscriptionuser2;
}
public function setInscriptionuser2(?BFInscriptionUser $inscriptionuser2): self
{
$this->inscriptionuser2 = $inscriptionuser2;
return $this;
}
public function getInscriptionuser3(): ?BFInscriptionUser
{
return $this->inscriptionuser3;
}
public function setInscriptionuser3(?BFInscriptionUser $inscriptionuser3): self
{
$this->inscriptionuser3 = $inscriptionuser3;
return $this;
}
public function getInscriptionuser4(): ?BFInscriptionUser
{
return $this->inscriptionuser4;
}
public function setInscriptionuser4(?BFInscriptionUser $inscriptionuser4): self
{
$this->inscriptionuser4 = $inscriptionuser4;
return $this;
}
public function getInscriptionuser5(): ?BFInscriptionUser
{
return $this->inscriptionuser5;
}
public function setInscriptionuser5(?BFInscriptionUser $inscriptionuser5): self
{
$this->inscriptionuser5 = $inscriptionuser5;
return $this;
}
public function getInscriptionuser6(): ?BFInscriptionUser
{
return $this->inscriptionuser6;
}
public function setInscriptionuser6(?BFInscriptionUser $inscriptionuser6): self
{
$this->inscriptionuser6 = $inscriptionuser6;
return $this;
}
public function getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
public function getUpdatedate(): ?\DateTimeInterface
{
return $this->updatedate;
}
public function setUpdatedate(\DateTimeInterface $updatedate): self
{
$this->updatedate = $updatedate;
return $this;
}
public function getAllInscriptionUser()
{
$inscriptionusers = new ArrayCollection();
if($this->inscriptionuser1!=null)
$inscriptionusers->add($this->inscriptionuser1);
if($this->inscriptionuser2!=null)
$inscriptionusers->add($this->inscriptionuser2);
if($this->inscriptionuser3!=null)
$inscriptionusers->add($this->inscriptionuser3);
if($this->inscriptionuser4!=null)
$inscriptionusers->add($this->inscriptionuser4);
if($this->inscriptionuser5!=null)
$inscriptionusers->add($this->inscriptionuser5);
if($this->inscriptionuser6!=null)
$inscriptionusers->add($this->inscriptionuser6);
return $inscriptionusers;
}
public function ReplaceInscriptionUser(BFInscriptionUser $oldone, BFInscriptionUser $newone)
{
if($this->inscriptionuser1==$oldone)
{
$this->inscriptionuser1=$newone;
return true;
}
if($this->inscriptionuser2==$oldone)
{
$this->inscriptionuser2=$newone;
return true;
}
if($this->inscriptionuser3==$oldone)
{
$this->inscriptionuser3=$newone;
return true;
}
if($this->inscriptionuser4==$oldone)
{
$this->inscriptionuser4=$newone;
return true;
}
if($this->inscriptionuser5==$oldone)
{
$this->inscriptionuser5=$newone;
return true;
}
if($this->inscriptionuser6==$oldone)
{
$this->inscriptionuser6=$newone;
return true;
}
}
public function UpdateDates()
{
if($this->creationdate==null)
$this->creationdate = new \DateTime();
$this->updatedate = new \DateTime();
}
public function InitializePair()
{
$this->inscriptionuser2= new BFInscriptionUser();
}
public function InitializeTeam()
{
$this->inscriptionuser2= new BFInscriptionUser();
$this->inscriptionuser3= new BFInscriptionUser();
$this->inscriptionuser4= new BFInscriptionUser();
$this->inscriptionuser5= new BFInscriptionUser();
$this->inscriptionuser6= new BFInscriptionUser();
}
public static function sorting($a,$b)
{
$tournoia = $a->getTournoi();
$tournoib = $b->getTournoi();
if($tournoia->getStartdate()<$tournoib->getStartdate())
return -1;
else if($tournoia->getStartdate()==$tournoib->getStartdate()
&& $tournoia->getEnddate()<$tournoib->getEnddate())
return -1;
else if($tournoia->getStartdate()==$tournoib->getStartdate()
&& $tournoia->getEnddate()==$tournoib->getEnddate())
return 0;
else
return 1;
}
}