<?php
namespace App\Entity\Projets;
use App\Entity\Utilisateur\Contact;
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 Doctrine\ORM\Mapping\Index;
/**
* Tache
*
* @ORM\Table(name="projet__tache")
* @ORM\Entity(repositoryClass="App\Repository\Projets\TacheRepository")
* @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
* @ORM\HasLifecycleCallbacks()
*/
class Tache
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="notes")
* @ORM\JoinColumn(nullable=true)
*/
private $utilisateur;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Notes\Note", mappedBy="tache")
*/
private $interventions;
/**
* @ORM\Column(name="date", type="datetime", nullable=true)
*/
private $date;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projets\Projet", inversedBy="taches")
* @ORM\JoinColumn(nullable=true)
*/
private $projet;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projets\Reference")
* @ORM\JoinColumn(nullable=true)
* @Assert\NotBlank(message="Référence obligatoire")
*/
private $reference;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projets\Etat")
* @ORM\JoinColumn(nullable=true)
* @Assert\NotBlank(message="Etat obligatoire")
*/
private $etat;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projets\Priorite")
* @ORM\JoinColumn(nullable=true)
* @Assert\NotBlank(message="Priorité obligatoire")
*/
private $priorite;
/**
* @ORM\Column(name="date_supression", type="datetime", nullable=true)
*/
private $dateSuppression;
/**
* @ORM\Column(name="date_mail", type="datetime", nullable=true)
*/
private $dateMail;
/**
* @ORM\Column(name="date_debut_prevue", type="datetime", nullable=true)
*/
private $dateDebutPrevue;
/**
* @ORM\Column(name="date_debut_recalee", type="datetime", nullable=true)
*/
private $dateDebutRecalee;
/**
* @ORM\Column(name="date_debut_reelle", type="datetime", nullable=true)
*/
private $dateDebutReelle;
/**
* @ORM\Column(name="date_fin_prevue", type="datetime", nullable=true)
*/
private $dateFinPrevue;
/**
* @ORM\Column(name="date_fin_recalee", type="datetime", nullable=true)
*/
private $dateFinRecalee;
/**
* @ORM\Column(name="date_fin_reelle", type="datetime", nullable=true)
*/
private $dateFinReelle;
/**
* @ORM\Column(name="dateMaj", type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $dateMaj;
/**
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(name="pourcentage", type="float", nullable=true)
*/
private $pourcentage;
/**
* @ORM\Column(name="nbHeuresAlloues", type="float", nullable=true)
*/
private $nbHeuresAlloues;
/**
* @ORM\Column(name="nbHeuresRealisees", type="float", nullable=true)
*/
private $nbHeuresRealisees;
/**
* @ORM\Column(name="budget_a_depenser", type="float", nullable=true)
*/
private $budgetAdepenser;
/**
* @ORM\Column(name="budget_depense", type="float", nullable=true)
*/
private $budgetDepense;
/**
* @ORM\Column(name="differenceHeure", type="float", nullable=true)
*/
private $differenceHeure;
/**
* @ORM\Column(name="libelle", type="string", length=255, nullable=true)
* @Assert\NotBlank(message="Libellé obligatoire")
*/
private $libelle;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur")
* @ORM\JoinColumn(nullable=true)
*/
private $rapporteurInterne;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Contact")
* @ORM\JoinColumn(nullable=true)
*/
private $rapporteurExterne;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur")
* @ORM\JoinColumn(nullable=true)
*/
private $responsableInterne;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Contact")
* @ORM\JoinColumn(nullable=true)
*/
private $responsableExterne;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projets\Tache",inversedBy="enfants")
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Projets\Tache", mappedBy="parent")
*/
private $enfants;
/**
* @ORM\Column(name="id_import", type="string",length=255, nullable=true)
*/
private $idImport;
public function __construct()
{
$this->libelle = "Nouvelle tâche";
$this->date = new Datetime();
$this->pourcentage = 0;
$this->nbHeuresRealisees = 0;
$this->nbHeuresAlloues = 0;
$this->budgetAdepenser = 0;
$this->budgetDepense = 0;
$this->dateMail = new Datetime();
$this->dateDebutPrevue = new Datetime();
$this->dateDebutRecalee = new Datetime();
$this->enfants = new ArrayCollection();
$this->interventions = new ArrayCollection();
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function setDateDebutReelleAuto()
{
//dump('PreUpdate');
$dates = [];
$interventions = $this->getInterventions();
if(count($interventions)>0)
foreach ($interventions as $intervention){
$dateTmp = $intervention->getDateDebut();
if(is_object($dateTmp)){
$dates[] = $dateTmp;
}
}
if(count($dates)>0) $this->dateDebutReelle = min($dates);
}
public function getId(): int
{
return $this->id;
}
public function setDate(?DateTime $date): Tache
{
$this->date = $date;
return $this;
}
public function getDate(): ?DateTime
{
return $this->date;
}
public function setDateMaj(?DateTime $dateMaj): Tache
{
$this->dateMaj = $dateMaj;
return $this;
}
public function getDateMaj(): ?DateTime
{
return $this->dateMaj;
}
public function setDescription(?string $description): Tache
{
$this->description = $description;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setPourcentage(?float $pourcentage): Tache
{
$this->pourcentage = $pourcentage;
return $this;
}
public function getPourcentage(): ?float
{
return $this->pourcentage;
}
public function setNbHeuresAlloues(?float $nbHeuresAlloues): Tache
{
$this->nbHeuresAlloues = $nbHeuresAlloues;
return $this;
}
public function getNbHeuresAlloues(): ?float
{
return $this->nbHeuresAlloues;
}
public function setNbHeuresRealisees(?float $nbHeuresRealisees): Tache
{
$this->nbHeuresRealisees = $nbHeuresRealisees;
return $this;
}
public function getNbHeuresRealisees(): ?float
{
return $this->nbHeuresRealisees;
}
public function setDifferenceHeure(?float $differenceHeure): Tache
{
$this->differenceHeure = $differenceHeure;
return $this;
}
public function getDifferenceHeure(): ?float
{
return $this->differenceHeure;
}
public function setLibelle(?string $libelle): Tache
{
$this->libelle = $libelle;
return $this;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setDateSuppression(?DateTime $dateSuppression): Tache
{
$this->dateSuppression = $dateSuppression;
return $this;
}
public function getDateSuppression(): ?DateTime
{
return $this->dateSuppression;
}
public function setProjet(?Projet $projet): Tache
{
$this->projet = $projet;
return $this;
}
public function getProjet(): ?Projet
{
return $this->projet;
}
public function setReference(?Reference $reference): Tache
{
$this->reference = $reference;
return $this;
}
public function getReference(): ?Reference
{
return $this->reference;
}
public function setEtat(?Etat $etat): Tache
{
$this->etat = $etat;
return $this;
}
public function getEtat(): ?Etat
{
return $this->etat;
}
public function setPriorite(?Priorite $priorite): Tache
{
$this->priorite = $priorite;
return $this;
}
public function getPriorite(): ?Priorite
{
return $this->priorite;
}
public function setRapporteurInterne(?Utilisateur $rapporteurInterne): Tache
{
$this->rapporteurInterne = $rapporteurInterne;
return $this;
}
public function getRapporteurInterne(): ?Utilisateur
{
return $this->rapporteurInterne;
}
public function setRapporteurExterne(?Contact $rapporteurExterne): Tache
{
$this->rapporteurExterne = $rapporteurExterne;
return $this;
}
public function getRapporteurExterne(): ?Contact
{
return $this->rapporteurExterne;
}
public function setResponsableInterne(?Utilisateur $responsableInterne): Tache
{
$this->responsableInterne = $responsableInterne;
return $this;
}
public function getResponsableInterne(): ?Utilisateur
{
return $this->responsableInterne;
}
public function setResponsableExterne(?Contact $responsableExterne): Tache
{
$this->responsableExterne = $responsableExterne;
return $this;
}
public function getResponsableExterne(): ?Contact
{
return $this->responsableExterne;
}
public function setDateMail(?DateTime $dateMail): Tache
{
$this->dateMail = $dateMail;
return $this;
}
public function getDateMail(): ?DateTime
{
return $this->dateMail;
}
public function setDateLivraisonEstime(DateTime $dateLivraisonEstime): Tache
{
$this->dateLivraisonEstime = $dateLivraisonEstime;
return $this;
}
public function getDateLivraisonEstime(): DateTime
{
return $this->dateLivraisonEstime;
}
public function setDateLivraisonRelle(DateTime $dateLivraisonRelle): Tache
{
$this->dateLivraisonRelle = $dateLivraisonRelle;
return $this;
}
public function getDateLivraisonRelle(): DateTime
{
return $this->dateLivraisonRelle;
}
public function setUtilisateur(?Utilisateur $utilisateur): Tache
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getUtilisateur(): ?Utilisateur
{
return $this->utilisateur;
}
public function __toString()
{
return $this->libelle;
}
public function addIntervention(\App\Entity\Notes\Note $intervention): Tache
{
$this->interventions[] = $intervention;
return $this;
}
public function removeIntervention(\App\Entity\Notes\Note $intervention)
{
$this->interventions->removeElement($intervention);
}
public function getInterventions(): Collection
{
return $this->interventions;
}
public function setParent(?Tache $parent): Tache
{
$this->parent = $parent;
return $this;
}
public function getParent(): ?Tache
{
return $this->parent;
}
public function addEnfant(Intervention $enfant): Tache
{
$this->enfants[] = $enfant;
return $this;
}
public function removeEnfant(Intervention $enfant)
{
$this->enfants->removeElement($enfant);
}
public function getEnfants()
{
return $this->enfants;
}
public function setDateDebutPrevue(?DateTime $dateDebutPrevue): Tache
{
$this->dateDebutPrevue = $dateDebutPrevue;
return $this;
}
public function getDateDebutPrevue(): ?DateTime
{
return $this->dateDebutPrevue;
}
public function setDateDebutRecalee(?DateTime $dateDebutRecalee): Tache
{
$this->dateDebutRecalee = $dateDebutRecalee;
return $this;
}
public function getDateDebutRecalee(): ?DateTime
{
return $this->dateDebutRecalee;
}
public function setDateDebutReelle(?DateTime $dateDebutReelle): Tache
{
$this->dateDebutReelle = $dateDebutReelle;
return $this;
}
public function getDateDebutReelle(): ?DateTime
{
return $this->dateDebutReelle;
}
public function setDateFinPrevue(?DateTime $dateFinPrevue): Tache
{
$this->dateFinPrevue = $dateFinPrevue;
return $this;
}
public function getDateFinPrevue(): ?DateTime
{
return $this->dateFinPrevue;
}
public function setDateFinRecalee(?DateTime $dateFinRecalee): Tache
{
$this->dateFinRecalee = $dateFinRecalee;
return $this;
}
public function getDateFinRecalee(): ?DateTime
{
return $this->dateFinRecalee;
}
public function setBudgetAdepenser(?float $budgetAdepenser): Tache
{
$this->budgetAdepenser = $budgetAdepenser;
return $this;
}
public function getBudgetAdepenser(): ?float
{
return $this->budgetAdepenser;
}
public function setBudgetDepense(?float $budgetDepense): Tache
{
$this->budgetDepense = $budgetDepense;
return $this;
}
public function getBudgetDepense(): ?float
{
return $this->budgetDepense;
}
public function setDateFinReelle(?DateTime $dateFinReelle): Tache
{
$this->dateFinReelle = $dateFinReelle;
return $this;
}
public function getDateFinReelle(): ?DateTime
{
return $this->dateFinReelle;
}
public function getDuration(){
$dateDebut = $this->dateDebutPrevue;
if(is_object($this->dateDebutRecalee)) $dateDebut = $this->dateDebutRecalee;
$dateFin = $this->dateFinPrevue;
if(is_object($this->dateFinRecalee)) $dateFin = $this->dateFinRecalee;
if(is_object($dateDebut) && is_object($dateFin)){
$diff = $dateDebut->diff($dateFin);
//print_r($diff);
return (($diff->format('%a')* 24) + $diff->format('%h') + ( $diff->format('%i') / 60));
}
return $this->nbHeuresAlloues;
}
public function setIdImport(?string $idImport): Tache
{
$this->idImport = $idImport;
return $this;
}
public function getIdImport(): ?string
{
return $this->idImport;
}
}