Commit d399fbab authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

UP : Le montant cumulé des montants des activités est affiché dans la fiche projet

parent 418e9f25
Loading
Loading
Loading
Loading
Loading
+31 −48
Changes for module/Oscar/src/Oscar/Entity/Project.php: 31 added lines, 48 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ namespace Oscar\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Oscar\Utils\StringUtils;
use phpDocumentor\Reflection\Types\Integer;
use Zend\Form\Annotation;
use Zend\Permissions\Acl\Resource\ResourceInterface;
use ZendTest\Code\Annotation\TestAsset\DoctrineAnnotation;
@@ -106,13 +107,6 @@ class Project implements ResourceInterface
     */
    protected $partners;

//    /**
//     * Discipline
//     * @var Discipline
//     * @ORM\ManyToOne(targetEntity="Discipline")
//     */
//    protected $discipline;

    /**
     * Discipline
     * @var Discipline
@@ -128,7 +122,6 @@ class Project implements ResourceInterface
        $this->grants = new ArrayCollection();
        $this->members = new ArrayCollection();
        $this->partners = new ArrayCollection();
//        $this->disciplines = new ArrayCollection();
    }


@@ -172,35 +165,17 @@ class Project implements ResourceInterface
        return $end;
    }

//    /**
//     * @param Discipline $discipline
//     * @return $this
//     */
//    public function addDiscipline(Discipline $discipline)
//    {
//        if( !$this->disciplines->contains($discipline) ){
//            $this->disciplines->add($discipline);
//        }
//        return $this;
//    }
//
//    /**
//     * @param Discipline $discipline
//     * @return $this
//     */
//    public function removeDiscipline(Discipline $discipline)
//    {
//        $this->disciplines->removeElement($discipline);
//        return $this;
//    }
//
//    /**
//     * @return ArrayCollection|Discipline
//     */
//    public function getDisciplines()
//    {
//        return $this->disciplines;
//    }
    public function getAmount() :?float
    {
        if( $this->getActivities()->count() == 0 ){
            return null;
        }
        $amount = 0.0;
        foreach ($this->getActivities() as $activity) {
            $amount += $activity->getAmount();
        }
        return $amount;
    }

    /**
     * @param \Oscar\Entity\ProjectMember $projectMember
@@ -276,7 +251,6 @@ class Project implements ResourceInterface
    }



    /**
     * Test si l'organisation est présente dans le projet, avec le role si l'
     * argument $role est spécifié.
@@ -313,13 +287,17 @@ class Project implements ResourceInterface

    private function getPartnersByType($type, $deep = false)
    {
        $needed = in_array($type,
            $this->_partnersSpecialsTypes) ? $type : 'non-special';
        $needed = in_array(
            $type,
            $this->_partnersSpecialsTypes
        ) ? $type : 'non-special';
        if ($this->_partnersByType === null) {
            $this->_partnersByType = array();
            foreach ($this->partners as $partner) {
                $key = !in_array($partner->getRole(),
                    $this->_partnersSpecialsTypes) ? 'non-special' : $partner->getRole();
                $key = !in_array(
                    $partner->getRole(),
                    $this->_partnersSpecialsTypes
                ) ? 'non-special' : $partner->getRole();
                if (!isset($this->_partnersByType[$key])) {
                    $this->_partnersByType[$key] = array();
                }
@@ -375,7 +353,8 @@ class Project implements ResourceInterface
        return $persons;
    }

    public function getPersonsDeep(){
    public function getPersonsDeep()
    {
        $persons = [];
        foreach ($this->getMembers(true) as $member) {
            $persons[] = $member;
@@ -390,7 +369,8 @@ class Project implements ResourceInterface
        return $persons;
    }

    public function getOrganizations( $deep = false ){
    public function getOrganizations($deep = false)
    {
        $organisations = [];
        foreach ($this->getPartners(true) as $partner) {
            $organisations[] = $partner;
@@ -406,7 +386,8 @@ class Project implements ResourceInterface
        return $organisations;
    }

    public function getOrganisationsDeep(){
    public function getOrganisationsDeep()
    {
        return $this->getOrganizations(true);
    }

@@ -769,23 +750,26 @@ class Project implements ResourceInterface


    private $_pfi;

    public function getPFI()
    {
        if ($this->_pfi === null) {
            $this->_pfi = [];
            /** @var Activity $activity */
            foreach ($this->getActivities() as $activity) {
                if( $activity->getCodeEOTP() )
                if ($activity->getCodeEOTP()) {
                    $this->_pfi[] = $activity->getCodeEOTP();
                }
            }
        }
        return implode(', ', array_unique($this->_pfi));
    }

    /**
     * @return Activity[]
     */
    public function getActivities(){
    public function getActivities()
    {
        return $this->getGrants();
    }

@@ -808,7 +792,6 @@ class Project implements ResourceInterface
    }



    public function toJson()
    {
        return json_encode($this->toArray());
+5 −0
Changes for module/Oscar/view/oscar/project/show.phtml: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -50,6 +50,11 @@ h2.tv-serie-label { border-bottom: none; }
                    </abbr>
                <?php endif; ?>
                <?= $project->getLabel() ?>

                <div class="budget montant">
                    <small><em>Montant</em></small><br>
                    <strong><?= $this->currency($project->getAmount()) ?></strong>
                </div>
            </h1>
        </header>