src/Entity/Materiel.php line 12
<?php
namespace App\Entity;
use App\Repository\MaterielRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MaterielRepository::class)]
class Materiel
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $presentation = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $tarif = null;
#[ORM\Column(length: 1, nullable: true)]
private ?string $codeSC = null;
#[ORM\Column(length: 1, nullable: true)]
private ?string $codePA = null;
#[ORM\ManyToMany(targetEntity: Categorie::class, mappedBy: 'materiels')]
#[ORM\JoinTable(name:"materiel_categorie")]
private Collection $categories;
#[ORM\ManyToMany(targetEntity: Protocole::class, mappedBy: 'materiels')]
#[ORM\JoinTable(name:"protocole_materiel")]
private Collection $protocoles;
#[ORM\ManyToMany(targetEntity: self::class)]
private Collection $associes;
// #[ORM\OneToMany(mappedBy: 'materiel', targetEntity: Materielphoto::class)]
// private Collection $materielphotos;
#[ORM\Column]
private ?bool $archive = null;
#[ORM\OneToMany(mappedBy: 'materiel', targetEntity: Commentaire::class)]
private Collection $commentaires;
#[ORM\ManyToMany(targetEntity: self::class)]
#[ORM\JoinTable(name:"kitmateriels")]
private Collection $kitmateriels;
#[ORM\Column(length: 255, nullable: true)]
private ?string $reference = null;
public function __construct()
{
$this->id = 0;
$this->archive = false;
$this->categories = new ArrayCollection();
$this->associes = new ArrayCollection();
$this->protocoles = new ArrayCollection();
//$this->materielphotos = new ArrayCollection();
$this->commentaires = new ArrayCollection();
$this->kitmateriels = new ArrayCollection();
}
public function __toString(): string
{
return $this->getNom();
}
public function nomType(): string
{
$suffix = '';
if($this->codeSC == 'S'){
$suffix = ' (stérilisable)';
}
elseif($this->codeSC == 'C'){
$suffix = ' (consommable)';
}
return $this->getNom().$suffix;
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function getNom4Tri(): ?string
{
$unwanted_array = array( 'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
return strtr( $this->nom, $unwanted_array );
//return str_replace("â","a", $this->nom);
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPresentation(): ?string
{
return $this->presentation;
}
public function setPresentation(?string $presentation): self
{
$this->presentation = $presentation;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(?string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getTarif(): ?string
{
return $this->tarif;
}
public function setTarif(?string $tarif): self
{
$this->tarif = $tarif;
return $this;
}
public function getCodeSC(): ?string
{
return $this->codeSC;
}
public function setCodeSC(?string $codeSC): self
{
$this->codeSC = $codeSC;
return $this;
}
public function getCodePA(): ?string
{
return $this->codePA;
}
public function setCodePA(?string $codePA): self
{
$this->codePA = $codePA;
return $this;
}
/**
* @return Collection<int, Categorie>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Categorie $category): self
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
$category->addMateriel($this);
}
return $this;
}
public function removeCategory(Categorie $category): self
{
if ($this->categories->removeElement($category)) {
$category->removeMateriel($this);
}
return $this;
}
/**
* @return Collection<int, self>
*/
public function getAssocies(): Collection
{
return $this->associes;
}
public function addAssocy(self $assocy): self
{
if (!$this->associes->contains($assocy)) {
$this->associes->add($assocy);
}
return $this;
}
public function removeAssocy(self $assocy): self
{
$this->associes->removeElement($assocy);
return $this;
}
// /**
// * @return Collection<int, Materielphoto>
// */
// public function getMaterielphotos(): Collection
// {
// return $this->materielphotos;
// }
// public function addMaterielphoto(Materielphoto $materielphoto): self
// {
// if (!$this->materielphotos->contains($materielphoto)) {
// $this->materielphotos->add($materielphoto);
// $materielphoto->setMateriel($this);
// }
// return $this;
// }
// public function removeMaterielphoto(Materielphoto $materielphoto): self
// {
// if ($this->materielphotos->removeElement($materielphoto)) {
// // set the owning side to null (unless already changed)
// if ($materielphoto->getMateriel() === $this) {
// $materielphoto->setMateriel(null);
// }
// }
// return $this;
// }
public function isArchive(): ?bool
{
return $this->archive;
}
public function setArchive(bool $archive): self
{
$this->archive = $archive;
return $this;
}
/**
* @return Collection<int, Commentaire>
*/
public function getCommentaires(): Collection
{
return $this->commentaires;
}
public function addCommentaire(Commentaire $commentaire): self
{
if (!$this->commentaires->contains($commentaire)) {
$this->commentaires->add($commentaire);
$commentaire->setMateriel($this);
}
return $this;
}
public function removeCommentaire(Commentaire $commentaire): self
{
if ($this->commentaires->removeElement($commentaire)) {
// set the owning side to null (unless already changed)
if ($commentaire->getMateriel() === $this) {
$commentaire->setMateriel(null);
}
}
return $this;
}
/**
* @return Collection<int, Protocole>
*/
public function getProtocoles(): Collection
{
return $this->protocoles;
}
public function addProtocole(Protocole $protocole): self
{
if (!$this->protocoles->contains($protocole)) {
$this->protocoles->add($protocole);
$protocole->addMateriel($this);
}
return $this;
}
public function removeProtocole(Protocole $protocole): self
{
if ($this->protocoles->removeElement($protocole)) {
$protocole->removeMateriel($this);
}
return $this;
}
/**
* @return Collection<int, self>
*/
public function getKitmateriels(): Collection
{
return $this->kitmateriels;
}
public function addKitmateriel(self $kitmateriel): self
{
if (!$this->kitmateriels->contains($kitmateriel)) {
$this->kitmateriels->add($kitmateriel);
}
return $this;
}
public function removeKitmateriel(self $kitmateriel): self
{
$this->kitmateriels->removeElement($kitmateriel);
return $this;
}
}