Commit 93c9fb7a authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Indicateur pour la validation dans la synthèse

parent 2efe3891
Loading
Loading
Loading
Loading
+14 −2
Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 14 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ class TimesheetController extends AbstractOscarController
        $format         = $this->params()->fromQuery('format', '');
        $period         = $this->params()->fromQuery('period', null);
        $error          = null;
        $validations = null;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Synthèse pour une activités
@@ -560,10 +561,19 @@ class TimesheetController extends AbstractOscarController
                $personsIds[] = $person->getId();
            }

            // Période
            $start  = $activity->getDateStart()->format('Y-m');
            $end    = $activity->getDateEnd()->format('Y-m');



            if( count($personsIds) == 0 ){
                return $this->getResponseInternalError(sprintf(_("Il n'y a pas de déclarants dans cette activité")));
            }

            $validations = $this->getTimesheetService()->getDatasValidationPersonsPeriod($personsIds, $start, $end);
            $datas = $this->getTimesheetService()->getDatasDeclarersSynthesis($personsIds);

            $horslots = $this->getTimesheetService()->getOthersWP();
        }

@@ -606,7 +616,8 @@ class TimesheetController extends AbstractOscarController
            'activityId' => $activity_id,
            'activity' => $activity,
            'horslot' => $horslots,
            'datas' => $datas
            'datas' => $datas,
            'validations' => $validations
        ];

        if( $format == "excel" ){
@@ -668,7 +679,8 @@ class TimesheetController extends AbstractOscarController
            'activityId' => $activity_id,
            'activity' => $activity,
            'horslot' => $horslots,
            'datas' => $datas
            'datas' => $datas,
            'validations' => $validations
        ];
    }

+15 −0
Changes for module/Oscar/src/Oscar/Entity/ValidationPeriodRepository.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ namespace Oscar\Entity;


use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMapping;
use Oscar\Exception\OscarException;

class ValidationPeriodRepository extends EntityRepository
@@ -269,6 +270,20 @@ class ValidationPeriodRepository extends EntityRepository
        return $query->setParameters($parameters)->getQuery()->getResult();
    }

    public function getDatasValidationPersonsPeriod($personsIds, $start, $end){
        // SELECT CONCAT(year, '-', month) as period, * FROM validationperiod WHERE CONCAT(year, '-', month) > '2018-8';

        $rsm = new ResultSetMapping();
        $result = $this->getEntityManager()->getConnection()->fetchAll("SELECT CONCAT(v.year, '-', v.month) as period, * 
	FROM validationperiod as v WHERE v.declarer_id IN(".implode(',', $personsIds).") AND CONCAT(v.year, '-', v.month) >= '$start' AND CONCAT(v.year, '-', v.month) <= '$end'");

        /*
    SELECT p.id as person_id, CONCAT(p.firstname, ' ', p.lastname) as displayname, to_char(t.datefrom, 'YYYY-MM') as period, t.activity_id, COALESCE(pr.acronym, t.label) as context, CASE WHEN t.activity_id > 0 THEN 'wp' ELSE 'other' END as type, SUM(EXTRACT(EPOCH from dateto - datefrom) / 3600) as duration FROM timesheet t INNER JOIN person p ON p.id = t.person_id LEFT JOIN activity a ON t.activity_id = a.id LEFT JOIN project pr ON pr.id = a.project_id WHERE p.id IN(".implode(',', $personIds).") GROUP BY p.id, period, context, activity_id ORDER BY p.lastname, period
         */

        return $result;
    }




+42 −0
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1178,6 +1178,48 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        return $this->getTimesheetRepository()->getDatasDeclarerSynthesis($personIds);
    }

    public function getDatasValidationPersonsPeriod($personsIds, $start, $end){
        $datas = [];

        $this->getLogger()->debug("Validations entre $start et $end");

        $validations = $this->getValidationPeriodRepository()->getDatasValidationPersonsPeriod($personsIds, $start,$end);

        $this->getLogger()->debug("Validations : " . count($validations));


        foreach ($validations as $validation){
            $declarerId = $validation['declarer_id'];
            $id = $validation['id'];
            $period = sprintf('%s-%s', $validation['year'], $validation['month'] < 10 ? '0'.$validation['month']:$validation['month']);
            $object = $validation['object'];
            $objectgroup = $validation['objectgroup'];
            $object_id = $validation['object_id'];
            $dateSend = $validation['datesend'];

            if(!array_key_exists($period, $datas)){
                $datas[$period] = [];
            }

            if(!array_key_exists($declarerId, $datas[$period])){
                $datas[$period][$declarerId] = [
                    'activity' => [],
                    'other' => [],
                ];
            }

            if( $objectgroup == "workpackage" ){
                $datas[$period][$declarerId]['activity'][$validation['object_id']] = $validation;
            }
            if( $objectgroup == "other" ){
                $datas[$period][$declarerId]['other'][$validation['object']] = $validation;
            }
        }

        return $datas;

    }

    public function getMonthDuration(Person $person, $year, $month)
    {
        $daysInfos = $this->getDaysPeriodInfosPerson($person, $year, $month);
+62 −11
Changes for module/Oscar/view/oscar/timesheet/synthesis-all.phtml: 62 added lines, 11 removed lines.
Original line number Diff line number Diff line
<div id="app">
    <section class="container">
        <h1>Déclaration pour <strong>[<?= $activity->getAcronym() ?>]</strong> <em><?= $activity->getLabel() ?></em></h1>


        <pre>{{ validations }}</pre>
        <h1>Déclaration pour <strong>[<?= $activity->getAcronym() ?>]</strong> <em><?= $activity->getLabel() ?></em>
        </h1>
        <div class="overlay" v-if="infosPerson">
            <div class="overlay-content" style="flex-basis: 90%; max-height: 90%">
                <h2>
@@ -17,13 +17,17 @@
                    <thead>
                    <tr>
                        <th> ~</th>
                            <th v-for="d, i in infosPerson.days"><small>{{ d.label }}</small> {{ d.i }}</th>
                        <th v-for="d, i in infosPerson.days">
                            <small>{{ d.label }}</small>
                            {{ d.i }}
                        </th>
                        <th> Total</th>
                    </tr>
                    </thead>
                    <tbody v-for="activity in organize(infosPerson).activities">
                    <tr>
                            <th :colspan="infosPerson.dayNbr + 2"><h3><i class="icon-cube"></i>{{ activity.acronym }}</h3></th>
                        <th :colspan="infosPerson.dayNbr + 2"><h3><i class="icon-cube"></i>{{ activity.acronym }}</h3>
                        </th>
                    </tr>
                    <tr v-for="workpackage in activity.workpackages">
                        <th>{{ workpackage.code }}</th>
@@ -60,7 +64,9 @@
                    <tfoot>
                    <tr>
                        <th>Total</th>
                            <th v-for="d, i in infosPerson.days" class="day" :class="{'off': d.locked }"><small>{{ d.total | formatDuration }}</small></th>
                        <th v-for="d, i in infosPerson.days" class="day" :class="{'off': d.locked }">
                            <small>{{ d.total | formatDuration }}</small>
                        </th>
                        <th>{{ infosPerson.total | formatDuration }}</th>
                    </tr>
                    </tfoot>
@@ -75,7 +81,8 @@
                <span>
                    <i class="icon-calendar"></i>
                    {{ p.label | formatPeriod }}
                    <a :href="'/feuille-de-temps/synthesisactivity?activity_id=<?= $activity->getId() ?>&format=html&period=' + p.label" class="btn btn-xs btn-primary">
                    <a :href="'/feuille-de-temps/synthesisactivity?activity_id=<?= $activity->getId() ?>&format=html&period=' + p.label"
                       class="btn btn-xs btn-primary">
                        <i class="icon-calendar"></i>
                        Feuille de temps de l'activité
                    </a>
@@ -97,7 +104,8 @@
                                Répartition mensuelle
                            </a>

                        <a :href="'/feuille-de-temps/excel?action=export&period=' +p.label +'&personid=' + l.personId" class="btn btn-xs btn-default">
                            <a :href="'/feuille-de-temps/excel?action=export&period=' +p.label +'&personid=' + l.personId"
                               class="btn btn-xs btn-default">
                                <i class="icon-file-excel"></i>
                                Feuille de temps (Excel)
                            </a>
@@ -121,11 +129,22 @@
                        <article v-for="d in l.details" class="detail row">
                            <strong v-if="d.type == 'wp'">
                                <i class="icon-cubes"></i> {{ d.context }}

                                <strong v-if="d.validation" class="cartouche default"
                                        :class="'status-' + d.validation.status">
                                    <i :class="'icon-' + d.validation.status"></i>
                                    {{ d.validation.status | statusText }}</strong>
                            </strong>
                            <em v-else>
                                <i :class="'icon-'+d.context"></i> {{ d.context | formatHorsLot }}

                                <strong v-if="d.validation" class="cartouche default"
                                        :class="'status-' + d.validation.status">
                                    <i :class="'icon-' + d.validation.status"></i>
                                    {{ d.validation.status | statusText}}</strong>
                            </em>
                            <strong>{{ d.duration | formatDuration }}</strong>

                        </article>
                        <article class="detail row">
                            <strong>
@@ -145,17 +164,21 @@
    .row {
        display: flex;
    }

    .row :last-child {
        margin-left: auto;
        text-align: right;
    }

    .period h4 {
        margin: 0;
        padding: 0;
    }

    .period > article h3 {
        display: flex;
    }

    .period > article h3 .total, .period > article h3 .main, .period > article h3 .other {
        flex: 1;
    }
@@ -168,6 +191,7 @@
    .table {
        font-size: .8em;
    }

    .day.off {
        background: #eee8d5;
    }
@@ -175,13 +199,16 @@
    .day.fill {
        background: #0b97c4;
    }

    .day.off.fill {
        background: #7f0027;
    }

    .period > article h3 .person {
        flex: 3;
        margin-left: auto;
    }

    .period .detail {
        margin: 0 1em;
        border-bottom: solid thin #fff;
@@ -217,6 +244,18 @@
            return h + ':' + (m < 10 ? '0' + m : m);
        });

        var statusList = {
            'valid': "Validé",
            'send-prj': "Validation projet",
            'send-sci': "Validation scientifique",
            'send-adm': "Validation administrative",
            'reject': "Refusé",
        };

        Vue.filter('statusText', function (status) {
            return statusList[status] ? statusList[status] : "Inconnu";
        });

        Vue.filter('formatPeriod', function (period) {
            let split = period.split('-');
            return months[split[1]] + " " + split[0];
@@ -238,6 +277,7 @@
                return {
                    pack: 'period',
                    lines: <?= json_encode($datas) ?>,
                    validations: <?= json_encode($validations) ?>,
                    activityId: <?= $activityId ?>,
                    filterPersonId: null,
                    infosPerson: null
@@ -246,7 +286,6 @@

            methods: {
                details: function (personId, period) {
                    console.log(personId, period);
                    this.$http.get('/feuille-de-temps/synthesis?person_id=' + personId + '&format=json&period=' + period).then(
                        ok => {
                            this.infosPerson = ok.data;
@@ -293,7 +332,6 @@
                    });

                    Object.keys(personDatas.days).forEach(date => {
                       console.log("DATE", date);
                        var day = personDatas.days[date];

                        if (day.declarations) {
@@ -325,7 +363,6 @@

                        }
                    });

                    return datas;
                }
            },
@@ -345,6 +382,7 @@

                        if (this.filterPersonId && this.filterPersonId != personId) return;

                        // Série de IF pour créer l'objet rangé
                        if (!output.hasOwnProperty(year)) {
                            output[year] = {
                                label: year,
@@ -372,6 +410,8 @@
                            };
                        }

                        // On renseigne le cumul des heures selon si on est
                        // sur l'activité en cours ou du hors-lot
                        if (line.activity_id == this.activityId) {
                            output[year].periods[period].persons[personId].main += duration;
                            output[year].total += duration;
@@ -380,6 +420,17 @@
                            output[year].periods[period].persons[personId].others += duration;
                        }

                        // On teste les validations disponibles pour la période
                        if (this.validations && this.validations[period] && this.validations[period][personId]) {
                            if (line.activity_id && this.validations[period][personId].activity[line.activity_id]) {
                                line.validation = this.validations[period][personId].activity[line.activity_id];
                            } else if (line.context && this.validations[period][personId].other[line.context]) {
                                line.validation = this.validations[period][personId].other[line.context];
                            } else {
                                line.validation = null;
                            }
                        }

                        output[year].periods[period].persons[personId].total += duration;
                        output[year].periods[period].persons[personId].details.push(line);
                    });