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

Vue de synthèse pour les heures mensuels centrées sur un projet de recherche...

Vue de synthèse pour les heures mensuels centrées sur un projet de recherche (Données OK), MeP HTML en cours, excel à faire
parent 4ef5c7e1
Loading
Loading
Loading
Loading
+9 −0
Changes for databases_maintenance/requete-synthese-mois-activites.sql: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
SELECT 
	person_id,
	workpackage_id,
	label,
	comment,
	EXTRACT(EPOCH from dateto - datefrom) / 3600 as duration,
	to_char(datefrom, 'YYYY-MM') as period 
	
FROM timesheet WHERE to_char(datefrom, 'YYYY-MM') = '2017-12'
 No newline at end of file
+2 −1
Changes for module/Oscar/config/module.config.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ return array(
                        'declarant', 'declarantAPI', 'validationActivity',
                        'validationActivity2', 'validationHWPPerson', 'validatePersonPeriod',
                        'importIcal', 'declarations', 'resumeActivity',
                        'resolveInvalidLabels', 'syntheseActivity', 'synthesisAll'
                        'resolveInvalidLabels', 'syntheseActivity', 'synthesisAll', 'synthesisActivityPeriod'
                    ],
                    'roles' => ['user']
                ],
@@ -962,6 +962,7 @@ return array(
            'dater' => DateRenderer::class,
            'unAllowed' => \Oscar\View\Helpers\UnAllowed::class,
            'hasAccess' => \Oscar\View\Helpers\Access::class,
            'duration' => \Oscar\View\Helpers\Duration::class,
            'moment' => \Oscar\View\Helpers\Moment::class,
            'activity' => \Oscar\View\Helpers\ActivityHtml::class,
            'strEmpty' => \Oscar\View\Helpers\StrEmpty::class,
+8 −0
Changes for module/Oscar/config/routes.yml: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -80,6 +80,14 @@ timesheet:
    may_terminate: false

    child_routes:
        synthesisactivity:
            type: segment
            options:
                route: /synthesisactivity
                defaults:
                    action: synthesisActivityPeriod


        synthesis:
            type: segment
            options:
+18 −0
Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -491,6 +491,24 @@ class TimesheetController extends AbstractOscarController
        ];
    }

    public function synthesisActivityPeriodAction()
    {

        // Données reçues
        $activity_id = $this->params()->fromQuery('activity_id', null);
        $format = $this->params()->fromQuery('format', '');
        $period = $this->params()->fromQuery('period', null);
        $error = null;

        $output = $this->getTimesheetService()->getSynthesisActivityPeriod($activity_id, $period);
        if( $format == 'html' ){
            return $output;
        }
        else {
            return $this->jsonOutput($output);
        }
    }

    /**
     * Centralisation de la consultation des feuilles de temps d'une personne / activité
     * Selon les critères envoyés.
+38 −0
Changes for module/Oscar/src/Oscar/Entity/TimesheetRepository.php: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,4 +47,42 @@ class TimesheetRepository extends EntityRepository {

        return $result;
    }

    public function getPersonPeriodSynthesis($personIds, $period){
        if( count($personIds) == 0 ){
            throw new \Exception("Aucune personne");
        }

        if( !$period ){
            throw new \Exception("Période manquante");
        }

        $query = "SELECT 
            CONCAT(pr.firstname, ' ', pr.lastname) as person, 
            p.acronym acronym,
            t.person_id,
            t.label,
            COALESCE(w.code, t.label) as itemkey,
            t.activity_id,
            t.workpackage_id,
            EXTRACT(EPOCH from dateto - datefrom) / 3600 as duration,
            to_char(t.datefrom, 'YYYY-MM') as period, 
            t.activity_id
        FROM timesheet t 
        LEFT JOIN workpackage w ON w.id = workpackage_id 
        LEFT JOIN activity a ON a.id = t.activity_id 
        LEFT JOIN project p ON p.id = a.project_id 
        LEFT JOIN person pr ON t.person_id = pr.id
        WHERE 
        
            person_id IN(".implode(',',$personIds).")
            AND
            to_char(t.datefrom, 'YYYY-MM')  = '$period'
            ;";

        $rsm = new ResultSetMapping();
        $result = $this->getEntityManager()->getConnection()->fetchAll($query);

        return $result;
    }
}
 No newline at end of file
Loading