<?php
namespace App\Entity\GestionComerciale;
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;
/**
* StatutCommande
*
* @ORM\Table("commerciale__statut_commande")
* @ORM\Entity(repositoryClass="App\Repository\GestionComerciale\StatutCommandeRepository")
* @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
* @SecuredEntity(name="Statut de commande", group="REGLAGES")
*/
class StatutCommande
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(name="document_commercial_id", type="integer")
*/
private $documentCommercial;
/**
* @ORM\OneToMany(targetEntity="App\Entity\GestionComerciale\Commande", mappedBy="statutCommande")
*/
private $commandes;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\GestionComerciale\StatutCommande")
*/
private $actionStatutCommande;
/**
* @ORM\Column(name="ordre", type="integer", nullable=true)
*/
private $ordre;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="statutCommande")
* @ORM\JoinColumn(nullable=true)
*/
private $utilisateur;
/**
* @ORM\Column(name="libelle", type="string", length=255, nullable=true)
* @Assert\NotBlank(message="Libellé obligatoire")
*/
private $libelle;
/**
* @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;
public function __construct()
{
$this->date = new Datetime();
$this->ordre = 0;
$this->commandes = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function setLibelle(?string $libelle): StatutCommande
{
$this->libelle = $libelle;
return $this;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function getLibelleNettoye(): ?string
{
return $this->nettoyage($this->libelle);
}
public function setDate(?DateTime $date): StatutCommande
{
$this->date = $date;
return $this;
}
public function getDate(): ?DateTime
{
return $this->date;
}
public function setDateMaj(?DateTime $dateMaj): StatutCommande
{
$this->dateMaj = $dateMaj;
return $this;
}
public function getDateMaj(): ?DateTime
{
return $this->dateMaj;
}
public function setDateSuppression(?DateTime $dateSuppression): StatutCommande
{
$this->dateSuppression = $dateSuppression;
return $this;
}
public function getDateSuppression(): ?DateTime
{
return $this->dateSuppression;
}
public function setUtilisateur(?Utilisateur $utilisateur): StatutCommande
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getUtilisateur(): ?Utilisateur
{
return $this->utilisateur;
}
public function addCommande(Commande $commandes): StatutCommande
{
$this->commandes[] = $commandes;
return $this;
}
public function removeCommande(Commande $commandes)
{
$this->commandes->removeElement($commandes);
}
public function getCommandes(): Collection
{
return $this->commandes;
}
public function __toString()
{
return $this->libelle;
}
public function setOrdre(?int $ordre): StatutCommande
{
$this->ordre = $ordre;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setActionStatutCommande(?StatutCommande $actionStatutCommande): StatutCommande
{
$this->actionStatutCommande = $actionStatutCommande;
return $this;
}
public function getActionStatutCommande(): ?StatutCommande
{
return $this->actionStatutCommande;
}
private function nettoyage($text)
{
$separator = "-";
$tofind = "àáâãäåòóôõöøèéêëçìíîïùúûüÿñ"; // Lettre accentuées
$replac = "aaaaaaooooooeeeeciiiiuuuuyn"; // Equivalent non accentué
//$text = strtr(strtolower($text),$tofind,$replac);
$text = strtolower($text);
$text = str_replace('é', 'e', $text);
$text = str_replace(' ', '_', $text);
/*
$text = ereg_replace("[^a-z0-9.]", $separator, $text);
while (strstr($text, $separator . $separator))
$text = str_replace($separator . $separator, $separator, $text);
if (substr($text, 0, 1) == $separator)
$text = substr($text, 1);
return(ereg_replace($separator . "$", "", $text));
*
*/
return $text;
}
public function getDocumentCommercial(): ?int
{
return $this->documentCommercial;
}
public function setDocumentCommercial(int $documentCommercial): self
{
$this->documentCommercial = $documentCommercial;
return $this;
}
}