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

Lors de la visualisation, Oscar charge des paramètres horaires des procédure...

Lors de la visualisation, Oscar charge des paramètres horaires des procédure de validation de la période si elles existent
parent ff168614
Loading
Loading
Loading
Loading
−4
Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -1440,14 +1440,11 @@ class TimesheetController extends AbstractOscarController
        $method = $this->getHttpXMethod();

        // Durée d'un jour "normal"


        $today = new \DateTime();
        $year = (int)$this->params()->fromQuery('year', $today->format('Y'));
        $month = (int)$this->params()->fromQuery('month', $today->format('m'));
        $period = sprintf('%s-%s', $year, $month);


        /** @var Person $currentPerson */
        $currentPerson = $this->getCurrentPerson();

@@ -1500,7 +1497,6 @@ class TimesheetController extends AbstractOscarController
                        return $this->getResponseInternalError("Déclaration invalide : " . $e->getMessage());
                    }


                    try {
                        $from = new \DateTime($datas->from);
                        $to = new \DateTime($datas->to);
+21 −6
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 21 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -941,13 +941,31 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        $weekendAllowed = $this->getOscarConfig()->getConfiguration('declarationsWeekend') == false;
        $daysDetails = $this->getDayLengthPerson($person);

        $declarations = $this->getEntityManager()->getRepository(ValidationPeriod::class)
            ->createQueryBuilder('d')
            ->where('d.year = :year AND d.month = :month AND d.declarer = :person')
            ->getQuery()
            ->setParameters([
                'year' => $year,
                'month' => $month,
                'person' => $person,
            ])
            ->getResult()
        ;
        if( count($declarations) ){
            $daysDetails = json_decode($declarations[0]->getSchedule(), JSON_OBJECT_AS_ARRAY);
        }

       // var_dump($daysDetails); die();

        for ($i = $decaleDay; $i < $nbr + $decaleDay; $i++) {
            $day = $i - $decaleDay + 1;
            $dayIndex = ($i % 7);
            $duration = $this->getDayDuration($person, $dayIndex + 1);
            $maxlength = $this->getDayMaxLengthPerson($person, $dayIndex + 1);
            $minlength = $this->getDayMinLengthPerson($person, $dayIndex + 1);
            $dayOfWeek = $dayIndex +1;

            $duration = $daysDetails['days'][$dayOfWeek];
            $maxlength = $daysDetails['max'];
            $minlength = $daysDetails['min'];


            $close = false;
@@ -1380,9 +1398,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        }
        $periodMax = sprintf('%s-%s', $todayYear, $todayMonth);

        $this->getLogger()->debug("Période suivante " . $periodMax);


        $daysInfosPerson = $this->getDaysPeriodInfosPerson($person, $year, $month);
        $daysInfos = [];
        foreach ($daysInfosPerson as $dayNum => $data) {