src/Entity/Projets/Tache.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Projets;
  3. use App\Entity\Utilisateur\Contact;
  4. use App\Entity\Utilisateur\Utilisateur;
  5. use DateTime;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Doctrine\ORM\Mapping\Index;
  12. /**
  13.  * Tache
  14.  *
  15.  * @ORM\Table(name="projet__tache")
  16.  * @ORM\Entity(repositoryClass="App\Repository\Projets\TacheRepository")
  17.  * @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
  18.  * @ORM\HasLifecycleCallbacks()
  19.  */
  20. class Tache
  21. {
  22.     /**
  23.      * @ORM\Column(name="id", type="integer")
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="notes")
  30.      * @ORM\JoinColumn(nullable=true)
  31.      */
  32.     private $utilisateur;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity="App\Entity\Notes\Note", mappedBy="tache")
  35.      */
  36.     private $interventions;
  37.     /**
  38.      * @ORM\Column(name="date", type="datetime", nullable=true)
  39.      */
  40.     private $date;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\Projets\Projet", inversedBy="taches")
  43.      * @ORM\JoinColumn(nullable=true)
  44.      */
  45.     private $projet;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity="App\Entity\Projets\Reference")
  48.      * @ORM\JoinColumn(nullable=true)
  49.      * @Assert\NotBlank(message="Référence obligatoire")
  50.      */
  51.     private $reference;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity="App\Entity\Projets\Etat")
  54.      * @ORM\JoinColumn(nullable=true)
  55.      * @Assert\NotBlank(message="Etat obligatoire")
  56.      */
  57.     private $etat;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity="App\Entity\Projets\Priorite")
  60.      * @ORM\JoinColumn(nullable=true)
  61.      * @Assert\NotBlank(message="Priorité obligatoire")
  62.      */
  63.     private $priorite;
  64.     /**
  65.      * @ORM\Column(name="date_supression", type="datetime", nullable=true)
  66.      */
  67.     private $dateSuppression;
  68.     /**
  69.      * @ORM\Column(name="date_mail", type="datetime", nullable=true)
  70.      */
  71.     private $dateMail;
  72.     /**
  73.      * @ORM\Column(name="date_debut_prevue", type="datetime", nullable=true)
  74.      */
  75.     private $dateDebutPrevue;
  76.     /**
  77.      * @ORM\Column(name="date_debut_recalee", type="datetime", nullable=true)
  78.      */
  79.     private $dateDebutRecalee;
  80.     /**
  81.      * @ORM\Column(name="date_debut_reelle", type="datetime", nullable=true)
  82.      */
  83.     private $dateDebutReelle;
  84.     /**
  85.      * @ORM\Column(name="date_fin_prevue", type="datetime", nullable=true)
  86.      */
  87.     private $dateFinPrevue;
  88.     /**
  89.      * @ORM\Column(name="date_fin_recalee", type="datetime", nullable=true)
  90.      */
  91.     private $dateFinRecalee;
  92.     /**
  93.      * @ORM\Column(name="date_fin_reelle", type="datetime", nullable=true)
  94.      */
  95.     private $dateFinReelle;
  96.     /**
  97.      * @ORM\Column(name="dateMaj", type="datetime", nullable=true)
  98.      * @Gedmo\Timestampable(on="update")
  99.      */
  100.     private $dateMaj;
  101.     /**
  102.      * @ORM\Column(name="description", type="text", nullable=true)
  103.      */
  104.     private $description;
  105.     /**
  106.      * @ORM\Column(name="pourcentage", type="float", nullable=true)
  107.      */
  108.     private $pourcentage;
  109.     /**
  110.      * @ORM\Column(name="nbHeuresAlloues", type="float", nullable=true)
  111.      */
  112.     private $nbHeuresAlloues;
  113.     /**
  114.      * @ORM\Column(name="nbHeuresRealisees", type="float", nullable=true)
  115.      */
  116.     private $nbHeuresRealisees;
  117.     /**
  118.      * @ORM\Column(name="budget_a_depenser", type="float", nullable=true)
  119.      */
  120.     private $budgetAdepenser;
  121.     /**
  122.      * @ORM\Column(name="budget_depense", type="float", nullable=true)
  123.      */
  124.     private $budgetDepense;
  125.     /**
  126.      * @ORM\Column(name="differenceHeure", type="float", nullable=true)
  127.      */
  128.     private $differenceHeure;
  129.     /**
  130.      * @ORM\Column(name="libelle", type="string", length=255, nullable=true)
  131.      * @Assert\NotBlank(message="Libellé obligatoire")
  132.      */
  133.     private $libelle;
  134.     /**
  135.      * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur")
  136.      * @ORM\JoinColumn(nullable=true)
  137.      */
  138.     private $rapporteurInterne;
  139.     /**
  140.      * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Contact")
  141.      * @ORM\JoinColumn(nullable=true)
  142.      */
  143.     private $rapporteurExterne;
  144.     /**
  145.      * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur")
  146.      * @ORM\JoinColumn(nullable=true)
  147.      */
  148.     private $responsableInterne;
  149.     /**
  150.      * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Contact")
  151.      * @ORM\JoinColumn(nullable=true)
  152.      */
  153.     private $responsableExterne;
  154.     /**
  155.      * @ORM\ManyToOne(targetEntity="App\Entity\Projets\Tache",inversedBy="enfants")
  156.      * @ORM\JoinColumn(nullable=true)
  157.      */
  158.     private $parent;
  159.     /**
  160.      * @ORM\OneToMany(targetEntity="App\Entity\Projets\Tache", mappedBy="parent")
  161.      */
  162.     private $enfants;
  163.     /**
  164.      * @ORM\Column(name="id_import", type="string",length=255, nullable=true)
  165.      */
  166.     private $idImport;
  167.     public function __construct()
  168.     {
  169.         $this->libelle              "Nouvelle tâche";
  170.         $this->date                 = new Datetime();
  171.         $this->pourcentage          0;
  172.         $this->nbHeuresRealisees    0;
  173.         $this->nbHeuresAlloues      0;
  174.         $this->budgetAdepenser      0;
  175.         $this->budgetDepense        0;
  176.         $this->dateMail             = new Datetime();
  177.         $this->dateDebutPrevue      = new Datetime();
  178.         $this->dateDebutRecalee     = new Datetime();
  179.         $this->enfants              = new ArrayCollection();
  180.         $this->interventions        = new ArrayCollection();
  181.     }
  182.     /**
  183.      * @ORM\PrePersist
  184.      * @ORM\PreUpdate
  185.      */
  186.     public function setDateDebutReelleAuto()
  187.     {
  188.         //dump('PreUpdate');
  189.         $dates = [];
  190.         $interventions $this->getInterventions();
  191.         if(count($interventions)>0)
  192.             foreach ($interventions as $intervention){
  193.                 $dateTmp $intervention->getDateDebut();
  194.                 if(is_object($dateTmp)){
  195.                     $dates[] = $dateTmp;
  196.                 }
  197.             }
  198.         if(count($dates)>0$this->dateDebutReelle min($dates);
  199.     }
  200.     public function getId(): int
  201.     {
  202.         return $this->id;
  203.     }
  204.     public function setDate(?DateTime $date): Tache
  205.     {
  206.         $this->date $date;
  207.         return $this;
  208.     }
  209.     public function getDate(): ?DateTime
  210.     {
  211.         return $this->date;
  212.     }
  213.     public function setDateMaj(?DateTime $dateMaj): Tache
  214.     {
  215.         $this->dateMaj $dateMaj;
  216.         return $this;
  217.     }
  218.     public function getDateMaj(): ?DateTime
  219.     {
  220.         return $this->dateMaj;
  221.     }
  222.     public function setDescription(?string $description): Tache
  223.     {
  224.         $this->description $description;
  225.         return $this;
  226.     }
  227.     public function getDescription(): ?string
  228.     {
  229.         return $this->description;
  230.     }
  231.     public function setPourcentage(?float $pourcentage): Tache
  232.     {
  233.         $this->pourcentage $pourcentage;
  234.         return $this;
  235.     }
  236.     public function getPourcentage(): ?float
  237.     {
  238.         return $this->pourcentage;
  239.     }
  240.     public function setNbHeuresAlloues(?float $nbHeuresAlloues): Tache
  241.     {
  242.         $this->nbHeuresAlloues $nbHeuresAlloues;
  243.         return $this;
  244.     }
  245.     public function getNbHeuresAlloues(): ?float
  246.     {
  247.         return $this->nbHeuresAlloues;
  248.     }
  249.     public function setNbHeuresRealisees(?float $nbHeuresRealisees): Tache
  250.     {
  251.         $this->nbHeuresRealisees $nbHeuresRealisees;
  252.         return $this;
  253.     }
  254.     public function getNbHeuresRealisees(): ?float
  255.     {
  256.         return $this->nbHeuresRealisees;
  257.     }
  258.     public function setDifferenceHeure(?float $differenceHeure): Tache
  259.     {
  260.         $this->differenceHeure $differenceHeure;
  261.         return $this;
  262.     }
  263.     public function getDifferenceHeure(): ?float
  264.     {
  265.         return $this->differenceHeure;
  266.     }
  267.     public function setLibelle(?string $libelle): Tache
  268.     {
  269.         $this->libelle $libelle;
  270.         return $this;
  271.     }
  272.     public function getLibelle(): ?string
  273.     {
  274.         return $this->libelle;
  275.     }
  276.     public function setDateSuppression(?DateTime $dateSuppression): Tache
  277.     {
  278.         $this->dateSuppression $dateSuppression;
  279.         return $this;
  280.     }
  281.     public function getDateSuppression(): ?DateTime
  282.     {
  283.         return $this->dateSuppression;
  284.     }
  285.     public function setProjet(?Projet $projet): Tache
  286.     {
  287.         $this->projet $projet;
  288.         return $this;
  289.     }
  290.     public function getProjet(): ?Projet
  291.     {
  292.         return $this->projet;
  293.     }
  294.     public function setReference(?Reference $reference): Tache
  295.     {
  296.         $this->reference $reference;
  297.         return $this;
  298.     }
  299.     public function getReference(): ?Reference
  300.     {
  301.         return $this->reference;
  302.     }
  303.     public function setEtat(?Etat $etat): Tache
  304.     {
  305.         $this->etat $etat;
  306.         return $this;
  307.     }
  308.     public function getEtat(): ?Etat
  309.     {
  310.         return $this->etat;
  311.     }
  312.     public function setPriorite(?Priorite $priorite): Tache
  313.     {
  314.         $this->priorite $priorite;
  315.         return $this;
  316.     }
  317.     public function getPriorite(): ?Priorite
  318.     {
  319.         return $this->priorite;
  320.     }
  321.     public function setRapporteurInterne(?Utilisateur $rapporteurInterne): Tache
  322.     {
  323.         $this->rapporteurInterne $rapporteurInterne;
  324.         return $this;
  325.     }
  326.     public function getRapporteurInterne(): ?Utilisateur
  327.     {
  328.         return $this->rapporteurInterne;
  329.     }
  330.     public function setRapporteurExterne(?Contact $rapporteurExterne): Tache
  331.     {
  332.         $this->rapporteurExterne $rapporteurExterne;
  333.         return $this;
  334.     }
  335.     public function getRapporteurExterne(): ?Contact
  336.     {
  337.         return $this->rapporteurExterne;
  338.     }
  339.     public function setResponsableInterne(?Utilisateur $responsableInterne): Tache
  340.     {
  341.         $this->responsableInterne $responsableInterne;
  342.         return $this;
  343.     }
  344.     public function getResponsableInterne(): ?Utilisateur
  345.     {
  346.         return $this->responsableInterne;
  347.     }
  348.     public function setResponsableExterne(?Contact $responsableExterne): Tache
  349.     {
  350.         $this->responsableExterne $responsableExterne;
  351.         return $this;
  352.     }
  353.     public function getResponsableExterne(): ?Contact
  354.     {
  355.         return $this->responsableExterne;
  356.     }
  357.     public function setDateMail(?DateTime $dateMail): Tache
  358.     {
  359.         $this->dateMail $dateMail;
  360.         return $this;
  361.     }
  362.     public function getDateMail(): ?DateTime
  363.     {
  364.         return $this->dateMail;
  365.     }
  366.     public function setDateLivraisonEstime(DateTime $dateLivraisonEstime): Tache
  367.     {
  368.         $this->dateLivraisonEstime $dateLivraisonEstime;
  369.         return $this;
  370.     }
  371.     public function getDateLivraisonEstime(): DateTime
  372.     {
  373.         return $this->dateLivraisonEstime;
  374.     }
  375.     public function setDateLivraisonRelle(DateTime $dateLivraisonRelle): Tache
  376.     {
  377.         $this->dateLivraisonRelle $dateLivraisonRelle;
  378.         return $this;
  379.     }
  380.     public function getDateLivraisonRelle(): DateTime
  381.     {
  382.         return $this->dateLivraisonRelle;
  383.     }
  384.     public function setUtilisateur(?Utilisateur $utilisateur): Tache
  385.     {
  386.         $this->utilisateur $utilisateur;
  387.         return $this;
  388.     }
  389.     public function getUtilisateur(): ?Utilisateur
  390.     {
  391.         return $this->utilisateur;
  392.     }
  393.     public function __toString()
  394.     {
  395.         return $this->libelle;
  396.     }
  397.     public function addIntervention(\App\Entity\Notes\Note $intervention): Tache
  398.     {
  399.         $this->interventions[] = $intervention;
  400.         return $this;
  401.     }
  402.     public function removeIntervention(\App\Entity\Notes\Note $intervention)
  403.     {
  404.         $this->interventions->removeElement($intervention);
  405.     }
  406.     public function getInterventions(): Collection
  407.     {
  408.         return $this->interventions;
  409.     }
  410.     public function setParent(?Tache $parent): Tache
  411.     {
  412.         $this->parent $parent;
  413.         return $this;
  414.     }
  415.     public function getParent(): ?Tache
  416.     {
  417.         return $this->parent;
  418.     }
  419.     public function addEnfant(Intervention $enfant): Tache
  420.     {
  421.         $this->enfants[] = $enfant;
  422.         return $this;
  423.     }
  424.     public function removeEnfant(Intervention $enfant)
  425.     {
  426.         $this->enfants->removeElement($enfant);
  427.     }
  428.     public function getEnfants()
  429.     {
  430.         return $this->enfants;
  431.     }
  432.     public function setDateDebutPrevue(?DateTime $dateDebutPrevue): Tache
  433.     {
  434.         $this->dateDebutPrevue $dateDebutPrevue;
  435.         return $this;
  436.     }
  437.     public function getDateDebutPrevue(): ?DateTime
  438.     {
  439.         return $this->dateDebutPrevue;
  440.     }
  441.     public function setDateDebutRecalee(?DateTime $dateDebutRecalee): Tache
  442.     {
  443.         $this->dateDebutRecalee $dateDebutRecalee;
  444.         return $this;
  445.     }
  446.     public function getDateDebutRecalee(): ?DateTime
  447.     {
  448.         return $this->dateDebutRecalee;
  449.     }
  450.     public function setDateDebutReelle(?DateTime $dateDebutReelle): Tache
  451.     {
  452.         $this->dateDebutReelle $dateDebutReelle;
  453.         return $this;
  454.     }
  455.     public function getDateDebutReelle(): ?DateTime
  456.     {
  457.         return $this->dateDebutReelle;
  458.     }
  459.     public function setDateFinPrevue(?DateTime $dateFinPrevue): Tache
  460.     {
  461.         $this->dateFinPrevue $dateFinPrevue;
  462.         return $this;
  463.     }
  464.     public function getDateFinPrevue(): ?DateTime
  465.     {
  466.         return $this->dateFinPrevue;
  467.     }
  468.     public function setDateFinRecalee(?DateTime $dateFinRecalee): Tache
  469.     {
  470.         $this->dateFinRecalee $dateFinRecalee;
  471.         return $this;
  472.     }
  473.     public function getDateFinRecalee(): ?DateTime
  474.     {
  475.         return $this->dateFinRecalee;
  476.     }
  477.     public function setBudgetAdepenser(?float $budgetAdepenser): Tache
  478.     {
  479.         $this->budgetAdepenser $budgetAdepenser;
  480.         return $this;
  481.     }
  482.     public function getBudgetAdepenser(): ?float
  483.     {
  484.         return $this->budgetAdepenser;
  485.     }
  486.     public function setBudgetDepense(?float $budgetDepense): Tache
  487.     {
  488.         $this->budgetDepense $budgetDepense;
  489.         return $this;
  490.     }
  491.     public function getBudgetDepense(): ?float
  492.     {
  493.         return $this->budgetDepense;
  494.     }
  495.     public function setDateFinReelle(?DateTime $dateFinReelle): Tache
  496.     {
  497.         $this->dateFinReelle $dateFinReelle;
  498.         return $this;
  499.     }
  500.     public function getDateFinReelle(): ?DateTime
  501.     {
  502.         return $this->dateFinReelle;
  503.     }
  504.     public function getDuration(){
  505.         $dateDebut $this->dateDebutPrevue;
  506.         if(is_object($this->dateDebutRecalee)) $dateDebut $this->dateDebutRecalee;
  507.         $dateFin $this->dateFinPrevue;
  508.         if(is_object($this->dateFinRecalee)) $dateFin $this->dateFinRecalee;
  509.         if(is_object($dateDebut) && is_object($dateFin)){
  510.             $diff $dateDebut->diff($dateFin);
  511.             //print_r($diff);
  512.             return (($diff->format('%a')* 24) + $diff->format('%h') + ( $diff->format('%i') / 60));
  513.         }
  514.         return $this->nbHeuresAlloues;
  515.     }
  516.     public function setIdImport(?string $idImport): Tache
  517.     {
  518.         $this->idImport $idImport;
  519.         return $this;
  520.     }
  521.     public function getIdImport(): ?string
  522.     {
  523.         return $this->idImport;
  524.     }
  525. }