src/Entity/Membre.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MembreRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=MembreRepository::class)
  9.  */
  10. class Membre
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=Federation::class, inversedBy="membres")
  20.      */
  21.     private $federation;
  22.     /**
  23.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="membre", cascade={"persist", "remove"})
  24.      */
  25.     private $user;
  26.     /**
  27.      * @ORM\Column(type="date", nullable=true)
  28.      */
  29.     private $adhesion;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $photo;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=Cotisation::class, mappedBy="membre")
  36.      */
  37.     private $cotisations;
  38.     /**
  39.      * @ORM\Column(type="boolean", nullable=true)
  40.      */
  41.     private $cadre;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=Transaction::class, mappedBy="membre")
  44.      */
  45.     private $transactions;
  46.     /**
  47.      * @ORM\Column(type="boolean", nullable=true)
  48.      */
  49.     private $carte;
  50.     private $dette;
  51.     public function __construct()
  52.     {
  53.         $this->cotisations = new ArrayCollection();
  54.         $this->transactions = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getFederation(): ?Federation
  61.     {
  62.         return $this->federation;
  63.     }
  64.     public function setFederation(?Federation $federation): self
  65.     {
  66.         $this->federation $federation;
  67.         return $this;
  68.     }
  69.     public function getUser(): ?User
  70.     {
  71.         return $this->user;
  72.     }
  73.     public function setUser(?User $user): self
  74.     {
  75.         $this->user $user;
  76.         return $this;
  77.     }
  78.     public function getAdhesion(): ?\DateTimeInterface
  79.     {
  80.         return $this->adhesion;
  81.     }
  82.     public function setAdhesion(?\DateTimeInterface $adhesion): self
  83.     {
  84.         $this->adhesion $adhesion;
  85.         return $this;
  86.     }
  87.     public function getPhoto(): ?string
  88.     {
  89.         return $this->photo;
  90.     }
  91.     public function setPhoto(?string $photo): self
  92.     {
  93.         $this->photo $photo;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection<int, Cotisation>
  98.      */
  99.     public function getCotisations(): Collection
  100.     {
  101.         return $this->cotisations;
  102.     }
  103.     public function addCotisation(Cotisation $cotisation): self
  104.     {
  105.         if (!$this->cotisations->contains($cotisation)) {
  106.             $this->cotisations[] = $cotisation;
  107.             $cotisation->setMembre($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeCotisation(Cotisation $cotisation): self
  112.     {
  113.         if ($this->cotisations->removeElement($cotisation)) {
  114.             // set the owning side to null (unless already changed)
  115.             if ($cotisation->getMembre() === $this) {
  116.                 $cotisation->setMembre(null);
  117.             }
  118.         }
  119.         return $this;
  120.     }
  121.     public function setDette($cotisations){
  122.         $montant 0;
  123.         foreach($cotisations as $cotisation){
  124.             $montant += $cotisation->getMontant();
  125.         }
  126.         $date1 $this->getAdhesion();
  127.         $date1F '2023-01-01';
  128.         $date2 =  date("Y/m/d");
  129.         $ts1 strtotime($date1F);
  130.         $ts2 strtotime($date2);
  131.         $year1 date('Y'$ts1);
  132.         $year2 date('Y'$ts2);
  133.         $month1 date('m'$ts1);
  134.         $month2 date('m'$ts2);
  135.         $diff = (($year2 $year1) * 12) + ($month2 $month1);
  136.         if($this->cadre == true){
  137.             $dette $diff 10000;
  138.         }else{
  139.             $dette $diff 2000;
  140.         }
  141.         
  142.         $this->dette $dette $montant;
  143.     }
  144.     
  145.     public function getDette(): ?int
  146.     {
  147.         $this->setDette($this->cotisations);
  148.         return $this->dette;
  149.     }
  150.     public function getCadre(): ?bool
  151.     {
  152.         return $this->cadre;
  153.     }
  154.     public function setCadre(?bool $cadre): self
  155.     {
  156.         $this->cadre $cadre;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, Transaction>
  161.      */
  162.     public function getTransactions(): Collection
  163.     {
  164.         return $this->transactions;
  165.     }
  166.     public function addTransaction(Transaction $transaction): self
  167.     {
  168.         if (!$this->transactions->contains($transaction)) {
  169.             $this->transactions[] = $transaction;
  170.             $transaction->setMembre($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeTransaction(Transaction $transaction): self
  175.     {
  176.         if ($this->transactions->removeElement($transaction)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($transaction->getMembre() === $this) {
  179.                 $transaction->setMembre(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     public function getCarte(): ?bool
  185.     {
  186.         return $this->carte;
  187.     }
  188.     public function setCarte(?bool $carte): self
  189.     {
  190.         $this->carte $carte;
  191.         return $this;
  192.     }
  193. }