Commit 9c2612d0 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Recherche stricte sur l'identifiant "connectors"

 - Ajout des commentaires dans la synthèse des feuille de temps d'une personne
parent 9138bfe3
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?php
namespace Oscar\Entity\Repository;

use Doctrine\ORM\EntityRepository;

class TimesheetCommentPeriodRepository extends EntityRepository
{
    /**
     * Retourne tous les commentaires de la personne.
     *
     * @param int $personId
     * @return array
     */
    public function getCommentairesPerson( int $personId ):array {
        return $this->createQueryBuilder('c')
            ->select('c')
            ->where('c.declarer = :personId')
            ->setParameter('personId', $personId)
            ->getQuery()
            ->getResult();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ use Oscar\Utils\DateTimeUtil;

/**
 * @package Oscar\Entity
 * @ORM\Entity
 * @ORM\Entity(repositoryClass="Oscar\Entity\Repository\TimesheetCommentPeriodRepository")
 */
class TimesheetCommentPeriod
{
+37 −3
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Oscar\Service;

use Cocur\Slugify\Slugify;
use Doctrine\ORM\Exception\NotSupported;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\Query;
use Laminas\Mvc\Controller\Plugin\Url;
@@ -2648,11 +2649,40 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat
        return $datas;
    }

    /**
     * Retourne les commentaires d'une personnes sous la forme :
     * "YYYY-MM" => [
     *  "commentaires => [ "comment1", "comment2" ]
     * ]
     *
     * @param Person $person
     * @return array
     * @throws NotSupported
     */
    protected function getCommentairesPersonArray( Person $person ) :array {
        $commentaires = $this->getEntityManager()->getRepository(TimesheetCommentPeriod::class)
            ->getCommentairesPerson($person->getId());
        $out = [];

        /** @var TimesheetCommentPeriod $commentaire */
        foreach ($commentaires as $commentaire) {

            $period = DateTimeUtils::getCodePeriod($commentaire->getYear(), $commentaire->getMonth());
            if( !array_key_exists($period, $out) ) {
                $out[$period] = [];
            }
            if( strlen($commentaire->getComment()) > 0)
            $out[$period][] = $commentaire->getComment();
        }
        return $out;
    }

    /**
     * Retourne le résumé complet des déclarations d'une personne.
     *
     * @param Person $person
     * @return array
     * @throws OscarException
     */
    public function getResumePerson(Person $person)
    {
@@ -2665,6 +2695,7 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat

        $datas = [
            'owner'       => $person == $this->getOscarUserContextService()->getCurrentPerson(),
            'person_id'   => $person->getId(),
            'minDate'     => "",
            'maxDate'     => "",
            'periods'     => [],
@@ -2675,6 +2706,9 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat

        $periodsDetails = [];

        // Commentaires
        $commentaires = $this->getCommentairesPersonArray($person);

        foreach ($this->getOthersWP() as $hl) {
            $datas['horslots'][$hl['code']] = [
                'code'  => $hl['code'],
@@ -2725,7 +2759,6 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat
                            'month'                    => $month,
                            'year'                     => $year,
                            'periodDuration'           => $this->getPeriodDuration($person, $year, $month),
                            //'periodValidation'  => $this->getPeriodValidation
                            'past'                     => $period < $periodNow,
                            'current'                  => $period == $periodNow,
                            'futur'                    => $period > $periodNow,
@@ -2739,7 +2772,8 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat
                            'total_activities_details' => [],
                            'total_horslots'           => 0.0,
                            'validation_state'         => 'none',
                            'validations_id'           => []
                            'validations_id'           => [],
                            'commentaires'             => array_key_exists($period, $commentaires)?$commentaires[$period]:[],
                        ];
                    }
                    $periodsDetails[$period]['activities_id'][] = $activity->getId();
@@ -4179,7 +4213,7 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat
     * @param $period
     * @return array
     * @throws OscarException
     * @throws \Doctrine\ORM\Exception\NotSupported
     * @throws NotSupported
     */
    public function getTimesheetDatasPersonPeriod(Person $person, $period): array
    {
+2 −1
Original line number Diff line number Diff line
@@ -158,7 +158,8 @@ class OrganizationElasticSearch extends ElasticSearchEngine implements IOrganiza
                        "match" => [
                            "connectors" => [
                                "query" => $search,
                                'fuzziness' => "AUTO", // "Tolérance" aux fautes,
                                //'fuzziness' => "AUTO", // "Tolérance" aux fautes,
                                "boost" => 9
                            ]
                        ]
                    ],
+2 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
    </h1>
    <div class="timesheet-resume" id="timesheet-resume"
        <?php if( DEBUG_OSCAR ) echo ' data-debug-enabled="true"' ?>
         data-timesheetpreview="<?= $this->options()->hasTimesheetPreview() ? 'true':'false' ?>"
         data-timesheetexcel="<?= $this->options()->allowTimesheetExcel() ? 'true':'false' ?>"
         data-url="<?= $url ?>"
    ></div>
    <?= $this->Vite()->addJs('src/TimesheetPersonResume.js'); ?>
Loading