<?php
namespace App\Entity;
use App\Repository\ContratRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ContratRepository::class)
*/
class Contrat
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $duree;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $valeur;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=true)
*/
private $collaborateur;
/**
* @ORM\ManyToOne(targetEntity=Entreprise::class, inversedBy="contrats")
* @ORM\JoinColumn(nullable=false)
*/
private $entreprise;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pdl;
/**
* @ORM\Column(type="float", nullable=true, options={"default" : 0})
*/
private $car = 0;
/**
* @ORM\Column(type="float", nullable=true, options={"default" : 0})
*/
private $prix_moyen = 0;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fournisseur;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_debut;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $date_fin;
public function getId(): ?int
{
return $this->id;
}
public function getDuree(): ?int
{
if ($this->date_debut && $this->date_fin) {
$interval = $this->date_debut->diff($this->date_fin);
return $interval->y * 12 + $interval->m;
}
return $this->duree;
}
public function setDuree(?int $duree): self
{
$this->duree = $duree;
return $this;
}
public function getValeur(): ?float
{
if ($this->car === null || $this->prix_moyen === null) {
return null;
}
return $this->car * $this->prix_moyen;
}
public function setValeur(?float $valeur): self
{
$this->valeur = $valeur;
return $this;
}
public function getCollaborateur(): ?User
{
return $this->collaborateur;
}
public function setCollaborateur(?User $collaborateur): self
{
$this->collaborateur = $collaborateur;
return $this;
}
public function getEntreprise(): ?Entreprise
{
return $this->entreprise;
}
public function setEntreprise(?Entreprise $entreprise): self
{
$this->entreprise = $entreprise;
return $this;
}
public function getPdl(): ?string
{
return $this->pdl;
}
public function setPdl(?string $pdl): self
{
$this->pdl = $pdl;
return $this;
}
public function getCar(): ?float
{
return $this->car;
}
public function setCar(?float $car): self
{
$this->car = $car ?? 0;
return $this;
}
public function getPrixMoyen(): ?float
{
return $this->prix_moyen;
}
public function setPrixMoyen(?float $prix_moyen): self
{
$this->prix_moyen = $prix_moyen ?? 0;
return $this;
}
public function getFournisseur(): ?string
{
return $this->fournisseur;
}
public function setFournisseur(?string $fournisseur): self
{
$this->fournisseur = $fournisseur;
return $this;
}
public function getDateDebut(): ?\DateTimeInterface
{
return $this->date_debut;
}
public function setDateDebut(?\DateTimeInterface $date_debut): self
{
$this->date_debut = $date_debut;
return $this;
}
public function getDateFin(): ?\DateTimeInterface
{
return $this->date_fin;
}
public function setDateFin(?\DateTimeInterface $date_fin): self
{
$this->date_fin = $date_fin;
return $this;
}
}