<?php
namespace App\Entity\GestionComerciale;
use App\Entity\Clients\Client;
use App\Entity\Utilisateur\Utilisateur;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use App\Annotations\SecuredEntity;
/**
* Devis
*
* @ORM\Table("commerciale__devis")
* @ORM\Entity(repositoryClass="App\Repository\GestionComerciale\DevisRepository")
* @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
* @SecuredEntity(name="Devis", group="VENTES")
*/
class Devis
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="devis")
* @ORM\JoinColumn(nullable=true)
*/
private $utilisateur;
/**
* @ORM\Column(name="date", type="datetime", nullable=true)
*/
private $date;
/**
* @ORM\Column(name="dateMaj", type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $dateMaj;
/**
* @ORM\Column(name="dateSuppression", type="datetime", nullable=true)
*/
private $dateSuppression;
/**
* @ORM\Column(name="reference", type="string", length=255, nullable=true)
*/
private $reference;
/**
* @ORM\Column(name="reference_client", type="string", length=255, nullable=true)
*/
private $referenceClient;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Clients\Client", inversedBy="devis")
* @ORM\JoinColumn(nullable=true)
*/
private $client;
/**
* @ORM\Column(name="client_nom", type="string", length=255, nullable=true)
*/
private $nom;
/**
* @ORM\Column(name="client_prenom", type="string", length=255, nullable=true)
*/
private $prenom;
/**
* @ORM\Column(name="telephone", type="string", length=255, nullable=true)
*/
private $telephone;
/**
* @var float
*
* @ORM\Column(name="nb_pieces", type="float", nullable=true)
*/
private $nbPieces;
/**
* @var float
*
* @ORM\Column(name="prix_ht", type="float", nullable=true)
*/
private $prixHT;
/**
* @var float
*
* @ORM\Column(name="prix_ttc", type="float", nullable=true)
*/
private $prixTTC;
/**
* @ORM\OneToMany(targetEntity="ArticleCommande", mappedBy="devis", cascade={"persist"})
*/
protected $articlesCommande;
public function __construct()
{
$this->date = new Datetime();
$this->articlesCommande = new ArrayCollection();
/*
$this->nbPieces = 2;
$this->prixHT= 10;
$this->prixTTC = 12;
*
*/
}
public function __toString()
{
return $this->name;
}
public function getId(): int
{
return $this->id;
}
public function setDate(?DateTime $date): Devis
{
$this->date = $date;
return $this;
}
public function getDate(): ?DateTime
{
return $this->date;
}
public function setDateMaj(?DateTime $dateMaj): Devis
{
$this->dateMaj = $dateMaj;
return $this;
}
public function getDateMaj(): ?DateTime
{
return $this->dateMaj;
}
public function setDateSuppression(?DateTime $dateSuppression): Devis
{
$this->dateSuppression = $dateSuppression;
return $this;
}
public function getDateSuppression(): ?DateTime
{
return $this->dateSuppression;
}
public function setReference(?string $reference): Devis
{
$this->reference = $reference;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setUtilisateur(?Utilisateur $utilisateur): Devis
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getUtilisateur(): ?Utilisateur
{
return $this->utilisateur;
}
public function setName($name): Devis
{
$this->name = $name;
return $this;
}
public function getName(): string
{
return $this->name;
}
public function setTelephone(?string $telephone): Devis
{
$this->telephone = $telephone;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setReferenceClient(?string $referenceClient): Devis
{
$this->referenceClient = $referenceClient;
return $this;
}
public function getReferenceClient(): ?string
{
return $this->referenceClient;
}
public function getPrixTTC(): float
{
$total = 0;
if (count($this->getArticlesCommande())>0)
foreach ($this->getArticlesCommande() as $articleCommande )
{
$total += $articleCommande->getTotalTTC();
}
return $total;
//return $this->prixTTC;
}
public function getPrixHT(): float
{
$total = 0;
if (count($this->getArticlesCommande())>0)
foreach ($this->getArticlesCommande() as $articleCommande )
{
$total += $articleCommande->getTotalHt();
}
return $total;
//return $this->prixHT;
}
public function getNbPieces(): float
{
$total = 0;
if (count($this->getArticlesCommande())>0)
foreach ($this->getArticlesCommande() as $articleCommande )
{
$total += $articleCommande->getQuantite();
}
return $total;
//return $this->nbPieces;
}
public function addArticlesCommande(ArticleCommande $articlesCommande): Devis
{
$this->articlesCommande[] = $articlesCommande;
$articlesCommande->setDevis($this);
return $this;
}
public function removeArticlesCommande(ArticleCommande $articlesCommande)
{
$this->articlesCommande->removeElement($articlesCommande);
}
public function getArticlesCommande(): Collection
{
return $this->articlesCommande;
}
public function setNom(?string $nom): Devis
{
$this->nom = $nom;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setPrenom(?string $prenom): Devis
{
$this->prenom = $prenom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setClient(?Client $client): Devis
{
$this->client = $client;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setNbPieces(?float $nbPieces): Devis
{
$this->nbPieces = $nbPieces;
return $this;
}
public function setPrixHT(?float $prixHT): Devis
{
$this->prixHT = $prixHT;
return $this;
}
public function setPrixTTC(?float $prixTTC): Devis
{
$this->prixTTC = $prixTTC;
return $this;
}
}