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

Ajout de filtre

Ajout de données dans les documents de référencement des Projets/Activité
parent b0303577
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2927,6 +2927,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif


        $filtersOptions['activityTypes'] = $this->getActivityTypeService()->getActivityTypesTree(true);
        $filtersOptions['disciplines'] = $this->getProjectGrantSearchService()->getFilterOptionsDisciplines();
        $filtersOptions['keywords'] = $this->getProjectGrantSearchService()->getFilterOptionsKeywords();
        $filtersOptions['status'] = $this->getAdministrationConfigService()->activityStatusSelect(true, true, false);
        $filtersOptions['milestones'] = $milestonesType;
        $filtersOptions['milestonesProgressions'] = $milestonesProgressions;
@@ -2935,6 +2937,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        $filtersOptions['filters'] = $filters;
        $filtersOptions['sorts'] = $sorts;
        $filtersOptions['directions'] = $directions;
        $filtersOptions['numbers'] = $this->getProjectGrantSearchService()->getFilterOptionsActivityNumbers();

        //'activityDocumentTypes' => $this->getProjectGrantSearchService()->getFilterOptionsMilestones(),
        //'countries' => $this->getProjectGrantSearchService()->getFilterOptionsCountries(),
+9 −0
Original line number Diff line number Diff line
@@ -1781,6 +1781,15 @@ class Activity implements ResourceInterface
        return $motscles;
    }

    public function getMotsclesArrayIds()
    {
        $motscles = [];
        foreach ($this->getMotscles() as $m) {
            $motscles[] = $m->getId();
        }
        return $motscles;
    }

    /**
     * @return self
     */
+10 −0
Original line number Diff line number Diff line
@@ -1226,6 +1226,16 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
        return $disciplines;
    }

    public function getFilterOptionsKeywords(): array
    {
        /** @var ActivityMotCleRepository $repo */
        $repo = $this->getEntityManager()->getRepository(ActivityMotCle::class);

        $keywords = $repo->getAllArray();

        return $keywords;
    }

    /**
     * Liste des pays.
     * @return array
+96 −4
Original line number Diff line number Diff line
@@ -2209,6 +2209,24 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
                "field" => 'dateNegociation',
                "raw" => 'adn;;;'
            ],
            "anu" => [
                "key" => 'anu',
                "label" => $this->getOscarConfigurationService()->oscarText("Numérotation"),
                "field" => null,
                "raw" => 'anu;;;'
            ],
            "dis" => [
                "key" => 'dis',
                "label" => $this->getOscarConfigurationService()->oscarText("Disciplines"),
                "field" => null,
                "raw" => 'dis;;;'
            ],
            "key" => [
                "key" => 'key',
                "label" => $this->getOscarConfigurationService()->oscarText("Motclefs"),
                "field" => null,
                "raw" => 'key;;;'
            ],
            "as" => [
                "key" => 'as',
                "label" => $this->getOscarConfigurationService()->oscarText("Statut"),
@@ -2379,6 +2397,68 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
                        break;

                    ///////////////////////////////////////////// STATUS
                    case 'dis':
                        if( !$value1 ){
                            $error = "Aucune discipline";
                        } else {
                            if( $value2 == '1' ){
                                if (!array_key_exists('dis', $filterNotES)) {
                                    $filterNotES['dis'] = [];
                                }
                            } else {
                                if (!array_key_exists('dis', $filterES)) {
                                    $filterES['dis'] = [];
                                }
                            }

                            if( $value2 == '1' ){
                                $filterNotES['dis'][] = [
                                        'term' => [
                                            'disciplines_ids' => $value1
                                        ]
                                    ];
                            } else {
                                $filterES['dis'][] = [
                                    'term' => [
                                        'disciplines_ids' => $value1
                                    ]
                                ];

                            }
                        }
                        break;

                    case 'key':
                        if( !$value1 ){
                            $error = "Aucun mot-clef";
                        } else {
                            if( $value2 == '1' ){
                                if (!array_key_exists('keys', $filterNotES)) {
                                    $filterNotES['keys'] = [];
                                }
                            } else {
                                if (!array_key_exists('keys', $filterES)) {
                                    $filterES['keys'] = [];
                                }
                            }

                            if( $value2 == '1' ){
                                $filterNotES['keys'][] = [
                                    'term' => [
                                        'keywords_ids' => $value1
                                    ]
                                ];
                            } else {
                                $filterES['keys'][] = [
                                    'term' => [
                                        'keywords_ids' => $value1
                                    ]
                                ];

                            }
                        }
                        break;

                    case 'as':
                        if( !$value1 ){
                            $error = "Aucun status selectionné";
@@ -2422,6 +2502,18 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
                        break;

                    ///////////////////////////////////////////// PERSONNES
                    case 'anu':
                        if (!array_key_exists('anu', $filterES)) {
                            $filterES['anu'] = [];
                        }
                        if( $value2 == '' ){
                            $currentFilter = ["exists" => ["field" => "numbers.$value1"]];
                        } else {
                            $currentFilter = ["term" => ["numbers.$value1" => $value2]];
                        }
                        $filterES['anu'][] = $currentFilter;
                        break;

                    case 'ap':
                        if (!array_key_exists('ap', $filterES)) {
                            $filterES['ap'] = [];
@@ -2593,15 +2685,15 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
                    case 'orp':
                        if ($modeProject) {
                            $filterNotES[] = [
                                "exists" => [
                                ["exists" => [
                                    "field" => "activities"
                                ]
                                ]]
                            ];
                        } else {
                            $filterNotES[] = [
                                "exists" => [
                                ["exists" => [
                                    "field" => "project"
                                ]
                                ]]
                            ];
                        }
                        break;
+10 −5
Original line number Diff line number Diff line
@@ -53,7 +53,9 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear
                    'oscar' => ['type' => 'keyword'],
                    'amount' => ['type' => 'float'],
                    'keywords' => ['type' => 'keyword'],
                    'keywords_ids' => ['type' => 'keyword'],
                    'disciplines' => ['type' => 'keyword'],
                    'disciplines_ids' => ['type' => 'keyword'],
                    'financialImpact' => ['type' => 'keyword'],
                    'dateCreated' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'],
                    'dateUpdated' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'],
@@ -70,9 +72,8 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear
                    'jalons' => $mapper->getMappingMilestones(),
                    'persons' => $mapper->getMappingAffectationPerson(),
                    'organizations' => $mapper->getMappingAffectationOrganization(),
//                    'numerotation' => [ 'type' => 'text', 'analyzer, => 'french_analyzer 'analyzer' => 'french_analyzer'],
//                    'numbers' => [ 'type' => 'nested' ],

                    'numbers' => ['type' => 'flattened'],
                    'numbers_values' => ['type' => 'keyword'],
                ]
            ]
        ];
@@ -167,7 +168,9 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear
            'amount' => $activity->getAmount(),
            'financialImpact' => $activity->getFinancialImpact(),
            'disciplines' => $activity->getDisciplinesArray(),
            'disciplines_ids' => $activity->getDisciplinesIds(),
            'keywords' => $activity->getMotsclesArray(),
            'keywords_ids' => $activity->getMotsclesArrayIds(),
            'dateCreated' => $mapper->formatDateTimeNullable($activity->getDateCreated(), true),
            'dateUpdated' => $mapper->formatDateTimeNullable($activity->getDateUpdated(), true),
            'dateStart' => $mapper->formatDateTimeNullable($activity->getDateStart()),
@@ -175,6 +178,8 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear
            'dateSigned' => $mapper->formatDateTimeNullable($activity->getDateSigned()),
            'dateNegociation' => $mapper->formatDateTimeNullable($activity->getDateNegociation()),
            'dateOpened' => $mapper->formatDateTimeNullable($activity->getDateOpened()),
            'numbers' => $activity->getNumbers(),
            'numbers_values' => $activity->getNumbersValues(),
            'jalons' => $jalons,
            'project' => $project,
            'persons' => $members,
@@ -240,7 +245,7 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear
        $query["bool"]["should"][] = ["match" => ["project.description" => ["query" => $search, "fuzziness" => 1, "boost" => 3]]];

        // Champ NUMBERS
        $query["bool"]["should"][] = ["match" => ["numbers" => ["query" => $search, "fuzziness" => 1, "boost" => 5]]];
        $query["bool"]["should"][] = ["match" => ["numbers_values" => ["query" => $search, "boost" => 20]]];


        // Champ MOTSCLES
@@ -254,7 +259,7 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear
        $query["bool"]["should"][] = ["match" => ["organization.shortname" => ["query" => $search, "fuzziness" => 1]]];
        $query["bool"]["should"][] = ["match" => ["organization.longname" => ["query" => $search, "fuzziness" => 1]]];


//        echo '<pre>'; echo json_encode($query['bool']['should'], JSON_PRETTY_PRINT); die();
        return $query;
    }

Loading