Commit ae70dcd5 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout des affectations

parent 81ffa22e
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Octopus\Entity\Db;

// TODO prendre les overwrites, normalisés, phonétiques
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;

class Individu {
    /** @var integer */
@@ -45,6 +46,15 @@ class Individu {
    /** @var DateTime */
    private $dateModification;

    /** @var ArrayCollection */
    private $affectations;

    public function __construct()
    {
        $this->affectations = new ArrayCollection();
    }


    /**
     * @return int
     */
@@ -197,10 +207,24 @@ class Individu {
        return $this->dateModification;
    }

    /**
     * @param boolean $active
     * @return IndividuAffectation[]
     */
    public function getAffectations($active = false) {
        $affectations = $this->affectations->toArray();

        if ($active) {
            $affectations = array_filter($affectations, function(IndividuAffectation $a) { return ($a->getDateFin() === null);});
        }
        return $affectations;
    }

    public function __toString()
    {
        $texte  = $this->getPrenom(). " " . $this->getNomUsage();
        return $texte;
    }


}
 No newline at end of file
+101 −0
Original line number Diff line number Diff line
<?php

namespace Octopus\Entity\Db;

use DateTime;

class IndividuAffectation {

    /** @var integer */
    private $id;
    /** @var Individu */
    private $individu;
    /** @var Structure */
    private $structure;
    /** @var StructureType */
    private $type;
    /** @var Source */
    private $source;
    /** @var DateTime */
    private $dateDebut;
    /** @var DateTime */
    private $dateFin;
    /** @var integer */
    private $idOrig;
    /** @var boolean */
    private $principal;

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return Individu
     */
    public function getIndividu()
    {
        return $this->individu;
    }

    /**
     * @return Structure
     */
    public function getStructure()
    {
        return $this->structure;
    }

    /**
     * @return StructureType
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @return Source
     */
    public function getSource()
    {
        return $this->source;
    }

    /**
     * @return DateTime
     */
    public function getDateDebut()
    {
        return $this->dateDebut;
    }

    /**
     * @return DateTime
     */
    public function getDateFin()
    {
        return $this->dateFin;
    }

    /**
     * @return int
     */
    public function getIdOrig()
    {
        return $this->idOrig;
    }

    /**
     * @return bool
     */
    public function isPrincipal()
    {
        return $this->principal;
    }


}
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -32,5 +32,7 @@
        <field name="emailPersonnelle"     type="string"   length="255"      column="EMAIL_PERSO"              nullable="false"/>
        <field name="dateModification"     type="date"                       column="D_MODIF"                  nullable="false"/>

        <one-to-many target-entity="Octopus\Entity\Db\IndividuAffectation" mapped-by="individu" field="affectations"/>

    </entity>
</doctrine-mapping>
 No newline at end of file
+32 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Octopus\Entity\Db\IndividuAffectation" table="INDIVIDU_AFFECTATION">

        <id name="id" type="integer" column="ID">
            <generator strategy="IDENTITY"/>
        </id>

        <many-to-one target-entity="Octopus\Entity\Db\Individu" field="individu">
            <join-column name="INDIVIDU_ID" referenced-column-name="C_INDIVIDU_CHAINE" />
        </many-to-one>

        <many-to-one target-entity="Octopus\Entity\Db\Structure" field="structure">
            <join-column name="STRUCTURE_ID" referenced-column-name="ID" />
        </many-to-one>

        <many-to-one target-entity="Octopus\Entity\Db\StructureType" field="type">
            <join-column name="TYPE_ID" referenced-column-name="ID" />
        </many-to-one>

        <many-to-one target-entity="Octopus\Entity\Db\Source" field="source">
            <join-column name="SOURCE_ID" referenced-column-name="C_SOURCE" />
        </many-to-one>

        <field name="dateDebut"     column="DATE_DEBUT"    type="datetime"   nullable="false"/>
        <field name="dateFin"       column="DATE_FIN"      type="datetime"   nullable="true"/>
        <field name="idOrig"        column="ID_ORIG"       type="integer"    nullable="false"/>
        <field name="principal"     column="T_PRINCIPALE"  type="boolean"    nullable="false"/>


    </entity>
</doctrine-mapping>
 No newline at end of file
+6 −6
Original line number Diff line number Diff line
@@ -65,11 +65,11 @@ class Source {
    public function __toString()
    {
        switch ($this->cSource) {
            case 'OCTO' :  return '<span class="badge" style="background-color: darkred;">'. $this->getLibelleLong() .'</span>';
            case 'HARP' :  return '<span class="badge" style="background-color: hotpink;">'. $this->getLibelleLong() .'</span>';
            case 'APO'  :  return '<span class="badge" style="background-color: royalblue;">'. $this->getLibelleLong() .'</span>';
            case 'FCA'  :  return '<span class="badge" style="background-color: cadetblue;">'. $this->getLibelleLong() .'</span>';
            case 'INV'  :  return '<span class="badge" style="background-color: darkgreen;">'. $this->getLibelleLong() .'</span>';
            case self::SOURCE_OCTO      :  return '<span class="badge" style="background-color: darkred;">'. $this->getLibelleLong() .'</span>';
            case self::SOURCE_HARPEGE   :  return '<span class="badge" style="background-color: hotpink;">'. $this->getLibelleLong() .'</span>';
            case self::SOURCE_APOGEE    :  return '<span class="badge" style="background-color: royalblue;">'. $this->getLibelleLong() .'</span>';
            case self::SOURCE_FCA       :  return '<span class="badge" style="background-color: cadetblue;">'. $this->getLibelleLong() .'</span>';
            case self::SOURCE_INV       :  return '<span class="badge" style="background-color: darkgreen;">'. $this->getLibelleLong() .'</span>';
            default                     :  return '<span class="badge" style="background-color: gray;">'. $this->getLibelleLong() .'</span>';
        }
    }
Loading