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

Ajout des détails jour

parent 82b50509
Loading
Loading
Loading
Loading
+4 −0
Changes for module/Oscar/src/Oscar/Controller/AbstractOscarController.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -112,6 +112,10 @@ class AbstractOscarController extends AbstractActionController
        return $r;
    }

    protected function jsonOutput($datas){
        return $this->ajaxResponse($datas);
    }

    protected function getHttpResponse($code, $content = null)
    {
        $response = new Response();
+10 −1
Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1046,12 +1046,21 @@ class TimesheetController extends AbstractOscarController
    public function resumeActivityAction(){

        $activity = $this->getEntityManager()->getRepository(Activity::class)->find($this->params()->fromRoute('id'));

        $this->getOscarUserContext()->check(Privileges::ACTIVITY_TIMESHEET_VIEW, $activity);


        $format = $this->params()->fromQuery('format', null);
        $method = $this->getHttpXMethod();

        if( $this->isAjax() ){
        if( $this->isAjax() || $format == 'json' ){
            switch ($method) {
                case 'GET' :
                    $datas = $this->getTimesheetService()->getResumeActivity($activity);
                    if( $format == 'json' ){
                        return $this->jsonOutput($datas);

                    }
                    return $this->ajaxResponse($datas);
            }
        }
+16 −1
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 16 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1204,8 +1204,12 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        // Début / Fin
        $periodsList = DateTimeUtils::allperiodsBetweenTwo($activity->getDateStart()->format('Y-m'), $activity->getDateEnd()->format('Y-m'));
        foreach ($periodsList as $period) {

            $periodBounds = DateTimeUtils::periodBounds($period);

            $periods[$period] = [
                'total' => 0.0,
                'days' => $periodBounds['days'],
                'workpackages' => [],
                'persons' => []
            ];
@@ -1218,6 +1222,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                    'validation_state' => array_key_exists($validationKey, $validationsState) ? $validationsState[$validationKey] : 'none',
                    'displayname' => $person['displayname'],
                    'workpackages' => [],
                    'details' => [],
                ];
                foreach ($workPackages as $wp) {
                    $periods[$period]['persons'][$personId]['workpackages'][$wp['id']] = 0.0;
@@ -1242,14 +1247,24 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
            $wpCode     = $timesheet->getWorkpackage()->getCode();
            $wpId       = $timesheet->getWorkpackage()->getId();
            $duration   = $timesheet->getDuration();
            $day        = $timesheet->getDateFrom()->format('j');

            $total += $duration;
            $workPackages[$wpId]['total'] += $duration;
            $persons[$personId]['total'] += $duration;
            $periods[$period]['total'] += $duration;
            $periods[$period]['persons'][$personId]['total'] += $duration;

            $periods[$period]['persons'][$personId]['workpackages'][$wpId] += $duration;

            if( !array_key_exists($wpId, $periods[$period]['persons'][$personId]['details']) ){
                $periods[$period]['persons'][$personId]['details'][$wpId] = [];
            }

            if( !array_key_exists($day, $periods[$period]['persons'][$personId]['details'][$wpId]) ){
                $periods[$period]['persons'][$personId]['details'][$wpId][$day] = 0.0;
            }

            $periods[$period]['persons'][$personId]['details'][$wpId][$day] += $duration;
        }

        $datas = [