Commit f5499870 authored by Stéphane Bouvry's avatar Stéphane Bouvry
Browse files

Ajout d'une méthode qui calcule la durée attendue d'une période en fonction de la personn

parent 3e0f34cf
Loading
Loading
Loading
Loading
+22
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -936,6 +936,27 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa

    }

    private $_cache_getPeriodDuration = [];

    public function getPeriodDuration( $person, $year, $month){
        $key = sprintf('%s_%s-%s', $person->getId(), $year, $month);
        if( !array_key_exists($key, $this->_cache_getPeriodDuration) ){
            $periodInfos = $this->getDaysPeriodInfosPerson($person, $year, $month);
            $totalPeriod = 0.0;
            foreach ($periodInfos as $day) {
                $totalPeriod += $day['dayLength'];
            }
            $this->_cache_getPeriodDuration = $totalPeriod;
        }
        return $this->_cache_getPeriodDuration = $totalPeriod;
    }

    /**
     * Retourne le résumé complet des déclarations d'une personne.
     *
     * @param Person $person
     * @return array
     */
    public function getResumePerson( Person $person ){
        $declarantInActivities = $this->getActivitiesWithDeclarant($person);

@@ -1000,6 +1021,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                            'period'            => $period,
                            'month'             => $month,
                            'year'              => $year,
                            'periodDuration'    => $this->getPeriodDuration($person, $year, $month),
                            'past'              => $period < $periodNow,
                            'current'           => $period == $periodNow,
                            'futur'             => $period > $periodNow,