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

Ajout des commentaires à la synthèse mensuelle

parent de3d507a
Loading
Loading
Loading
Loading
+8 −1
Changes for module/Oscar/src/Oscar/Controller/PersonController.php: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -376,6 +376,13 @@ class PersonController extends AbstractOscarController
        $orderBy = $this->params()->fromQuery('orderby', 'lastname');
        $leader = $this->params()->fromQuery('leader', '');
        $format = $this->params()->fromQuery('format', '');
        $size = $this->params()->fromQuery('l', 'n');

        $limit = 50;
        if($size == 'm'){
            $limit = 20;
        }

        $datas = [];
        $error = null;

@@ -398,7 +405,7 @@ class PersonController extends AbstractOscarController
                'filter_roles' => $filterRoles,
                'order_by' => $orderBy,
                'leader' => $leader
            ]);
            ], $limit);
        } catch (BadRequest400Exception $e){
            $error = "Expression de recherche incorrecte.";
            throw $e;
+1 −16
Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 1 added line, 16 removed lines.
Original line number Diff line number Diff line
@@ -494,7 +494,6 @@ class TimesheetController extends AbstractOscarController

    public function synthesisActivityPeriodAction()
    {

        // Données reçues
        $activity_id = $this->params()->fromQuery('activity_id', null);
        $format = $this->params()->fromQuery('format', '');
@@ -502,6 +501,7 @@ class TimesheetController extends AbstractOscarController
        $error = null;

        $output = $this->getTimesheetService()->getSynthesisActivityPeriod($activity_id, $period);

        if( $format == 'json' ){
            return $this->jsonOutput($output);
        }
@@ -1916,21 +1916,6 @@ class TimesheetController extends AbstractOscarController
                    if( $action == 'resend' ){
                        $timesheetService->reSendPeriod($year, $month, $currentPerson);
                        return $this->getResponseOk();
//
//                        $periodId = $this->params()->fromPost('period_id');
//                        /** @var ValidationPeriod $period */
//                        $period = $this->getEntityManager()->getRepository(ValidationPeriod::class)->find($periodId);
//                        if( $period->getDeclarer() == $currentPerson ){
//                            try {
//                                $timesheetService->verificationPeriod($currentPerson, $period->getYear(), $period->getMonth());
//                                $timesheetService->reSendValidation($period, $comments);
//                                return $this->getResponseOk();
//                            } catch (\Exception $e ){
//                                return $this->getResponseInternalError(sprintf('Impossible de réenvoyer la déclaration : %s', $e->getMessage()));
//                            }
//                        } else {
//                            return $this->getResponseUnauthorized("Cette déclaration n'est pas la votre.");
//                        }
                    }

                    $datas = json_decode($this->params()->fromPost('datas'));
+10 −1
Changes for module/Oscar/src/Oscar/Formatter/TimesheetActivityPeriodFormatter.php: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -595,10 +595,19 @@ class TimesheetActivityPeriodFormatter
        $widthComment = floor(($fullWidth - 2)/4)*2;

        foreach ($datas['foo'] as $person=>$line) {

            $comment = "";

            if( array_key_exists($person, $datas['comments']) ){
                foreach ($datas['comments'][$person] as $key=>$content) {
                    $comment .= $content['comment']."\n";
                }
            }

            $this->getActiveSheet()->getRowDimension($this->getCurrentLine())->setRowHeight(60);
            $this->drawCell("", 0, true );
            $this->drawCell($person, $widthPerson, true, 'personComment');
            $this->drawCell("...", $widthComment, true, 'comment');
            $this->drawCell($comment, $widthComment, true, 'comment');

            $this->nextLine();
            $this->getActiveSheet()->getRowDimension($this->getCurrentLine())->setRowHeight(4);
+0 −6
Changes for module/Oscar/src/Oscar/Service/PersonService.php: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -749,19 +749,13 @@ class PersonService implements ServiceLocatorAwareInterface, EntityManagerAwareI
                    } else {
                        $filters['ids'] = $ids;
                    }
//                    $query->where('p.id IN(:ids)')->setParameter('ids', $ids);


                } catch( \Exception $e ){
                    $this->getLoggerService()->warn(sprintf("Méthode de recherche des personnes non-disponible : %s", $e->getMessage()));

                    // Ancienne méthode
                    $searchR = str_replace('*', '%', $search);
                    $query->where('lower(p.firstname) LIKE :search OR lower(p.lastname) LIKE :search OR lower(p.email) LIKE :search OR LOWER(CONCAT(CONCAT(p.firstname, \' \'), p.lastname)) LIKE :search OR LOWER(CONCAT(CONCAT(p.lastname, \' \'), p.firstname)) LIKE :search')
                        ->setParameter('search', '%' . strtolower($searchR) . '%');

                }

            }
        }

+69 −23
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 69 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -1233,6 +1233,15 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        return $total;
    }


    /**
     * Production/structuration des données de synthèse MENSUELLE avec une activité de référence.
     *
     * @param $idActivity
     * @param $period
     * @return array
     * @throws \Exception
     */
    public function getSynthesisActivityPeriod($idActivity, $period){
        $output = [
            'activity' => null,
@@ -1247,30 +1256,24 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa

        $totaux = [
            // Totaux Lots
            'wps' => [

            ],

            'wps' => [],
            // Total des heures pour l'activités de référence
            'totalMain' => 0.0,

            // Totaux autres projets
            'ce' => [

            ],
            'ce' => [],
            'totalCe' => 0.0,

            // Totaux hors-lots
            'others' => [

            ],
            'others' => [],

            // Total groupes
            'groups' => [

            ],
            'groups' => [],

            // Total
            'total'     => 0.0
            'total'     => 0.0,

            'comments' => []
        ];


@@ -1307,6 +1310,29 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        // Données des déclarants pour la période
        $datas = $this->getTimesheetRepository()->getPersonPeriodSynthesis($personIds, $period);


        $validations = $this->getValidationsPeriodPersons($personIds, $period);

        $comments = [];

        /** @var ValidationPeriod $validation */
        foreach ($validations as $validation){
            $declarerKey = (string)$validation->getDeclarer();
            $key = $validation->getObjectId();
            if( $key < 1) {
                $key = $validation->getObject();
            }

            if( !array_key_exists($declarerKey, $comments) ){
                $comments[(string)$validation->getDeclarer()] = [];
            }

            $comments[$declarerKey][$key] = [
                'comment'   => $validation->getComment(),
                'status'    => $validation->getStatus()
            ];
        }

        // Parse préabable pour obtenir la liste des autres projets dans lesquel les déclarants sont identifiés
        foreach ($datas as $d){
            if( $d['activity_id'] && $d['activity_id'] != $idActivity ){
@@ -1318,6 +1344,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
            }
        }



        foreach ($others as $key=>$other) {

            $totaux['others'][$key] = 0.0;
@@ -1426,12 +1454,11 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        $output['others'] = $others;
        $output['othersGroups'] = $othersGroups;
        $output['ces'] = $ceStr;
       // $output['datas'] = $datas;
        $output['totaux'] = $totaux;
        $output['wps'] = $lots;
        $output['comments'] = $comments;
        $output['activity'] = $activity->toArray();


        return $output;
    }

@@ -2767,19 +2794,40 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
            $this->_cacheValidationsPeriodPerson[$key] = $datas;
        }
        return $this->_cacheValidationsPeriodPerson[$key];
    }

    /**
     * @param $personIds
     * @param $period
     * @return ValidationPeriod[]
     * @throws OscarException
     */
    public function getValidationsPeriodPersons($personIds, $period){

        // extraction de la période
        $periodDatas = DateTimeUtils::extractPeriodDatasFromString($period);
        $month = $periodDatas['month'];
        $year = $periodDatas['year'];


        $validationsQuery = $this->getEntityManager()->getRepository(ValidationPeriod::class)->createQueryBuilder('v')
            ->where('v.declarer IN(:personIds) AND v.month = :month AND v.year = :year')
            ->setParameters([
                'personIds' => $personIds,
                'month' => $month,
                'year' => $year,
            ]);

        $validations = $validationsQuery->getQuery()->getResult();

        return $validations;
    }

    public function getValidationHorsLotByReferent(Person $referent)
    {

        $validations = [];

        if ($referent) {

            $subordinates = $this->getServiceLocator()->get('PersonService')->getSubordinates($referent);


            if (count($subordinates))
                $validations = $this->getEntityManager()->getRepository(ValidationPeriod::class)->createQueryBuilder('vp')
                    ->where('vp.declarer IN(:persons)')
@@ -2787,8 +2835,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                    ->getQuery()
                    ->getResult();
        }


        return $validations;
    }

Loading