src/Entity/Projet.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\ProjetRepository;
  6. #[ORM\Entity(repositoryClassProjetRepository::class)]
  7. #[ORM\Table(name'`projet`')]
  8. class Projet
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\ManyToMany(targetEntityUser::class,  inversedBy"projets_assignes")]
  15.     #[ORM\JoinTable(name"projet_assignes")]
  16.     private $devAssignes;
  17.     
  18.     #[ORM\ManyToOne(targetEntityClient::class, inversedBy"projets")]
  19.     private $client;
  20.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy"projets_crees")]
  21.     private $createur;
  22.     #[ORM\ManyToMany(targetEntityContact::class,  inversedBy"projets")]
  23.     #[ORM\JoinTable(name"projet_contact")]
  24.     private $contacts;
  25.     #[ORM\ManyToMany(targetEntityUser::class,  inversedBy"projets_suivi")]
  26.     #[ORM\JoinTable(name"projet_user_suivi")]
  27.     private $suiviPar;
  28.     
  29.     #[ORM\OneToMany(targetEntityLiaisonProjetEtat::class, mappedBy"projet"cascade: ["all"])]
  30.     private $etats;
  31.     #[ORM\OneToMany(targetEntityTache::class, mappedBy"projet"cascade: ["remove"])]
  32.     private $taches;
  33.     #[ORM\Column(type'text'nullable:true)]
  34.     private $nom;
  35.     #[ORM\Column(type'boolean'nullable:true)]
  36.     private $isCache;
  37.     #[ORM\ManyToOne(targetEntityEtatProjet::class)]
  38.     #[ORM\JoinColumn(name"etatprojet_id"referencedColumnName"id")]
  39.     private $lastEtat;
  40.     #[ORM\OneToMany(targetEntityDossierTache::class, mappedBy"projet"cascade: ['all'])]
  41.     private $dossiers;
  42.     #[ORM\OneToMany(targetEntityEntreeWiki::class, mappedBy"projet"cascade: ['remove'])]
  43.     private $entreesWiki;
  44.     #[ORM\Column]
  45.     private ?bool $hasWiki null;
  46.     public function __construct() {
  47.         $this->etats = new ArrayCollection();
  48.         $this->taches = new ArrayCollection();
  49.         $this->contacts = new ArrayCollection;
  50.         $this->suiviPar = new ArrayCollection();
  51.         $this->devAssignes = new ArrayCollection();
  52.         $this->dossiers = new ArrayCollection();
  53.         $this->entreesWiki = new ArrayCollection();
  54.     }
  55.     public function getId()
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getLastEtat(){
  60.         return $this->lastEtat;
  61.     }
  62.     public function setLastEtat(EtatProjet $lastEtat null){
  63.         $this->lastEtat $lastEtat;
  64.     }
  65.     public function getIsCache(){
  66.         return $this->isCache;
  67.     }
  68.     public function setIsCache($isCache){
  69.         $this->isCache $isCache;
  70.     }
  71.     public function getCreateur(){
  72.         return $this->createur;
  73.     }
  74.     public function setCreateur(User $createur){
  75.         $this->createur $createur;
  76.     }
  77.     public function setNom($nom)
  78.     {
  79.         $this->nom $nom;
  80.         return $this;
  81.     }
  82.     public function getNom()
  83.     {
  84.         return $this->nom;
  85.     }
  86.     public function addDevAssignes(User $devAssignes)
  87.     {
  88.         $this->devAssignes $devAssignes;
  89.         return $this;
  90.     }
  91.     public function getDevAssignes()
  92.     {
  93.         return $this->devAssignes;
  94.     }
  95.     public function addSuiviPar(User $suiviPar)
  96.     {
  97.         $this->suiviPar $suiviPar;
  98.         $suiviPar->addProjetsSuivi($this);
  99.         return $this;
  100.     }
  101.     public function removeSuiviPar(User $suiviPar)
  102.     {
  103.         $this->suiviPar->remove($suiviPar);
  104.         $suiviPar->removeProjetsSuivi($this);
  105.         return $this;
  106.     }
  107.     public function getSuiviPar()
  108.     {
  109.         return $this->suiviPar;
  110.     }
  111.     public function setClient(Client $client)
  112.     {
  113.         $this->client $client;
  114.         return $this;
  115.     }
  116.     
  117.     public function getAllUsers(){
  118.         $resultat = array();
  119.         $assignes $this->getDevAssignes()->toArray();
  120.         $suivi $this->getSuiviPar()->toArray();
  121.         foreach($assignes as $u){
  122.             $resultat[] = $u;
  123.         }
  124.         if(!(empty($this->contacts))){
  125.             foreach($this->contacts as $contact){
  126.                 $resultat[] = $contact->getUser();
  127.             }
  128.         }
  129.          foreach($suivi as $u){
  130.             $resultat[] = $u;
  131.         }
  132.         return $resultat;
  133.     }
  134.     public function getClient()
  135.     {
  136.         return $this->client;
  137.     }
  138.     public function getContacts()
  139.     {
  140.         return $this->contacts;
  141.     }
  142.     public function addContacts(Contact $contact)
  143.     {
  144.         $this->contacts->add($contact);
  145.         $contacts->addProjet($this);
  146.         return $this;
  147.     }
  148.     public function removeContact(Contact $contact)
  149.     {
  150.         return $this->contacts->removeElement($contact);
  151.         $contacts->removeProjet($this);
  152.     }
  153.     public function addEtat(LiaisonProjetEtat $etat)
  154.     {
  155.         $this->etats->add($etat);
  156.         return $this;
  157.     }
  158.     public function getEtats()
  159.     {
  160.         return $this->etats;
  161.     }
  162.     public function removeTache(Tache $taches)
  163.     {
  164.         $this->taches->remove($taches);
  165.         return $this;
  166.     }
  167.     public function addTache(Tache $taches)
  168.     {
  169.         $this->taches->add($taches);
  170.         return $this;
  171.     }
  172.     public function getTaches()
  173.     {
  174.         return $this->taches;
  175.     }
  176.  
  177.     public function getTempsTotal(){
  178.         $tempsTotal 0;
  179.         foreach ($this->getTaches() as $tache) {
  180.             foreach ($tache->getChronos() as $chrono) {
  181.                 $tempsTotal += $chrono->getTemps();
  182.             }
  183.         }
  184.         $heures floor(($tempsTotal)/3600); 
  185.         $min floor((($tempsTotal)- $heures *3600)/60);
  186.         $sec floor( ((($tempsTotal)- $heures*3600)) - ($min*60) ); 
  187.         return $heures."H ".$min."min ".$sec." s";
  188.     }
  189.     public function getDossiers()
  190.     {
  191.         return $this->dossiers;
  192.     }
  193.     public function addDossier(DossierTache $dossier)
  194.     {
  195.         $this->dossiers->add($dossier);
  196.         $dossier->addProjet($this);
  197.         return $this;
  198.     }
  199.     public function removeDossier(DossierTache $dossier)
  200.     {
  201.         return $this->dossiers->remove($dossier);
  202.         $dossier->removeProjet($this);
  203.     }   
  204.     public function displayName(){
  205.         if(!empty($this->getClient())){
  206.             return $this->getClient()->getNom()." - ".$this->getNom();
  207.         }else{
  208.             return $this->getNom();
  209.         }
  210.     }
  211.     
  212.     public function getEntreesWiki()
  213.     {
  214.         return $this->entreesWiki;
  215.     }
  216.     public function addEntreeWiki(EntreeWiki $entreeWiki)
  217.     {
  218.         $this->entreesWiki->add($entreeWiki);
  219.         $entreeWiki->addProjet($this);
  220.         return $this;
  221.     }
  222.     public function removeEntreeWiki(DossierTache $entreeWiki)
  223.     {
  224.         return $this->entreesWiki->remove($entreeWiki);
  225.         $entreeWiki->removeProjet($this);
  226.     }
  227.     public function isHasWiki(): ?bool
  228.     {
  229.         return $this->hasWiki;
  230.     }
  231.     public function setHasWiki(bool $hasWiki): static
  232.     {
  233.         $this->hasWiki $hasWiki;
  234.         return $this;
  235.     }   
  236. }