<?php
namespace App\Entity;
use App\Repository\PropositionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PropositionRepository::class)]
class Proposition
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'datetime', nullable: true)]
private $dateDemande;
#[ORM\Column(type: 'datetime', nullable: true)]
private $dateEnvoi;
#[ORM\Column(type: 'datetime', nullable: true)]
private $dateValidite;
#[ORM\Column(type: 'decimal', precision: 12, scale: 2, nullable: true)]
private $montantHT;
#[ORM\Column(type: 'text', nullable: true)]
private $remarques;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'propositions', fetch: 'EAGER', cascade: ['persist'])]
private ?User $auteur;
#[ORM\ManyToOne(targetEntity: PropositionOrigine::class, inversedBy: 'propositions', fetch: 'EAGER', cascade: ['persist'])]
private ?PropositionOrigine $origine;
#[ORM\ManyToOne(targetEntity: Affaire::class, inversedBy: 'propositions', cascade: ['persist'])]
private $affaire;
#[ORM\OneToOne(targetEntity: Facture::class, mappedBy: 'proposition', cascade: ['persist'])]
private $facture;
#[ORM\Column(type: 'integer', nullable: true)]
private $version = 1;
#[ORM\Column(type: 'boolean', nullable: true)]
private $valide;
#[ORM\ManyToOne(targetEntity: CategorieAffaire::class, inversedBy: 'affaires', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true)]
private ?CategorieAffaire $categorie = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $objet;
#[ORM\OneToMany(targetEntity: CommandeProposition::class, mappedBy: 'proposition', cascade: ['all'])]
private $commandes;
#[ORM\OneToMany(targetEntity: FactureProposition::class, mappedBy: 'proposition', cascade: ['all'])]
private $factures;
#[ORM\Column(type: 'text', nullable: true)]
private $exigences;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $avancement = "Préparation devis";
public function __construct()
{
$this->commandes = new ArrayCollection();
$this->factures = new ArrayCollection();
}
public function __toString()
{
// return "Proposition n° " . $this->getId() . ' - '. $this->getAvancement();
// return $this->getObjet() . ' - '. $this->getCategorie() . htmlentities(' <span>'.$this->getAvancement().'</span>');
// return $this->getObjet() . ' - '. $this->getCategorie();
return $this->getObjet() . ' - '. $this->getCategorie() . ' - ' . $this->getAvancement() ;
}
//
// public function getFullLabel()
// {
// return "Proposition n° " . $this->getId() . ' - '. $this->getAvancement();
//// return $this->getObjet() . ' - '. $this->getCategorie() . htmlentities(' <span>'.$this->getAvancement().'</span>');
//// return $this->getObjet() . ' - '. $this->getCategorie();
// }
public function setCommandes(?Collection $commandes): self
{
$this->commandes = $commandes;
return $this;
}
public function setFactures(?Collection $factures): self
{
$this->factures = $factures;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getDateDemande(): ?\DateTimeInterface
{
return $this->dateDemande;
}
public function setDateDemande(?\DateTimeInterface $dateDemande): self
{
$this->dateDemande = $dateDemande;
return $this;
}
public function getDateEnvoi(): ?\DateTimeInterface
{
return $this->dateEnvoi;
}
public function setDateEnvoi(?\DateTimeInterface $dateEnvoi): self
{
$this->dateEnvoi = $dateEnvoi;
return $this;
}
public function getDateValidite(): ?\DateTimeInterface
{
return $this->dateValidite;
}
public function setDateValidite(?\DateTimeInterface $dateValidite): self
{
$this->dateValidite = $dateValidite;
return $this;
}
public function getMontantHT(): ?string
{
return $this->montantHT;
}
public function setMontantHT(?string $montantHT): self
{
$this->montantHT = $montantHT;
return $this;
}
public function getRemarques(): ?string
{
return $this->remarques;
}
public function setRemarques(?string $remarques): self
{
$this->remarques = $remarques;
return $this;
}
public function getVersion(): ?int
{
return $this->version;
}
public function setVersion(?int $version): self
{
$this->version = $version;
return $this;
}
public function isValide(): ?bool
{
return $this->valide;
}
public function setValide(?bool $valide): self
{
$this->valide = $valide;
return $this;
}
public function getObjet(): ?string
{
return $this->objet;
}
public function setObjet(?string $objet): self
{
$this->objet = $objet;
return $this;
}
public function getAuteur(): ?User
{
return $this->auteur;
}
public function setAuteur(?User $auteur): self
{
$this->auteur = $auteur;
return $this;
}
public function getOrigine(): ?PropositionOrigine
{
return $this->origine;
}
public function setOrigine(?PropositionOrigine $origine): self
{
$this->origine = $origine;
return $this;
}
public function getAffaire(): ?Affaire
{
return $this->affaire;
}
public function setAffaire(?Affaire $affaire): self
{
$this->affaire = $affaire;
return $this;
}
public function getFacture(): ?Facture
{
return $this->facture;
}
public function setFacture(?Facture $facture): self
{
// unset the owning side of the relation if necessary
if ($facture === null && $this->facture !== null) {
$this->facture->setProposition(null);
}
// set the owning side of the relation if necessary
if ($facture !== null && $facture->getProposition() !== $this) {
$facture->setProposition($this);
}
$this->facture = $facture;
return $this;
}
public function getCategorie(): ?CategorieAffaire
{
return $this->categorie;
}
public function setCategorie(?CategorieAffaire $categorie): self
{
$this->categorie = $categorie;
return $this;
}
/**
* @return Collection<int, CommandeProposition>
*/
public function getCommandes(): Collection
{
return $this->commandes;
}
public function addCommande(CommandeProposition $commande): self
{
if (!$this->commandes->contains($commande)) {
$this->commandes->add($commande);
$this->commandes[] = $commande;
$commande->setProposition($this);
}
return $this;
}
public function removeCommande(CommandeProposition $commande): self
{
if ($this->commandes->removeElement($commande)) {
// set the owning side to null (unless already changed)
if ($commande->getProposition() === $this) {
$commande->setProposition(null);
}
}
return $this;
}
/**
* @return Collection<int, FactureProposition>
*/
public function getFactures(): Collection
{
return $this->factures;
}
public function addFacture(FactureProposition $facture): self
{
if (!$this->factures->contains($facture)) {
// $this->factures->add($facture);
$this->factures[] = $facture;
$facture->setProposition($this);
}
return $this;
}
public function removeFacture(FactureProposition $facture): self
{
if ($this->factures->removeElement($facture)) {
// set the owning side to null (unless already changed)
if ($facture->getProposition() === $this) {
$facture->setProposition(null);
}
}
return $this;
}
public function getExigences(): ?string
{
return $this->exigences;
}
public function setExigences(?string $exigences): self
{
$this->exigences = $exigences;
return $this;
}
/**
* @return mixed
*/
public function getAvancement()
{
return $this->avancement;
}
/**
* @param mixed $avancement
*/
public function setAvancement($avancement): void
{
$this->avancement = $avancement;
}
}