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

- Ajout du filtre sur le Type

- Création d'un index de recherche pour les projets
- Refonte du mapping
- UI vue projet OK
parent 73aafb8b
Loading
Loading
Loading
Loading
Loading
+266 −269
Original line number Diff line number Diff line
@@ -249,8 +249,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        $fullaccess = false; // $this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_INDEX);
        if ($fullaccess) {
            $restricted_ids = false;
        }
        else {
        } else {
            $restricted_ids = array_unique($this->getActivityService()->getActivitiesIdsPerson($person));
        }

@@ -334,11 +333,9 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_REQUEST_MANAGE)) {
            $spot = "global";
        }
        elseif (count($organizations)) {
        } elseif (count($organizations)) {
            $spot = "organizations";
        }
        else {
        } else {
            throw new UnAuthorizedException("Vous n'avez pas l'autorisation d'accéder à ces informations");
        }

@@ -377,25 +374,21 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $statusTxt = $this->params()->fromQuery('status', '');
                        if (trim($statusTxt) == '') {
                            $status = [];
                        }
                        else {
                        } else {
                            $status = explode(',', $statusTxt);
                        }

                        if (count($status) == 0) {
                            $activityRequest = [];
                        }
                        else {
                        } else {
                            if ($spot == 'global') {
                                $activityRequests = $demandeActiviteRepository->getAll($status);
                            }
                            elseif ($spot == 'organizations') {
                            } elseif ($spot == 'organizations') {
                                $activityRequests = $demandeActiviteRepository->getAllForOrganizations(
                                    $organizations,
                                    $status
                                );
                            }
                            else {
                            } else {
                                return $this->getResponseBadRequest('Mauvais contexte !');
                            }
                        }
@@ -449,11 +442,9 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                $personData,
                                $organisationData
                            );
                        }
                        elseif ($action == "reject") {
                        } elseif ($action == "reject") {
                            $activityRequestService->reject($request, $this->getCurrentPerson());
                        }
                        else {
                        } else {
                            return $this->getResponseBadRequest("Impossible de résoudre l'action '$action'.");
                        }

@@ -528,8 +519,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                header('Content-type: ' . $filetype);
                echo $content;
                die();
            }
            else {
            } else {
                $files = $demande->getFiles();
                $newFiles = [];
                foreach ($files as $file) {
@@ -539,8 +529,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                'paths.document_request'
                            ) . '/' . $file['file']
                        );
                    }
                    else {
                    } else {
                        $newFiles[] = $file;
                    }
                }
@@ -569,8 +558,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $statusTxt = $this->params()->fromQuery('status', '');
                        if (trim($statusTxt) == '') {
                            $status = [];
                        }
                        else {
                        } else {
                            $status = explode(',', $statusTxt);
                        }

@@ -623,8 +611,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        // Création ou Mise à jour
                        if ($datas['id']) {
                            $activityRequest = $activityRequestService->getActivityRequest($datas['id']);
                        }
                        else {
                        } else {
                            $activityRequest = new ActivityRequest();
                            $this->getEntityManager()->persist($activityRequest);
                        }
@@ -637,21 +624,18 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                            $organization = $this->getEntityManager()->getRepository(Organization::class)->find(
                                $datas['organisation_id']
                            );
                        }
                        else {
                        } else {
                            $organization = null;
                        }

                        if ($datas['dateStart'] && $datas['dateStart'] != "null") {
                            $datas['dateStart'] = new \DateTime($datas['dateStart']);
                        }
                        else {
                        } else {
                            $datas['dateStart'] = null;
                        }
                        if ($datas['dateEnd'] && $datas['dateEnd'] != "null") {
                            $datas['dateEnd'] = new \DateTime($datas['dateEnd']);
                        }
                        else {
                        } else {
                            $datas['dateEnd'] = null;
                        }

@@ -672,8 +656,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                            'size' => $size,
                                            'file' => $filepathname
                                        ];
                                    }
                                    else {
                                    } else {
                                        throw new OscarException(
                                            "Impossible de téléverser votre fichier $name." . error_get_last()
                                        );
@@ -800,8 +783,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        foreach ($documentDatas as $key => $value) {
            if (is_array($value)) {
            }
            else {
            } else {
                $templateProcessor->setValue($key, htmlspecialchars($value, ENT_COMPAT | ENT_HTML401, NULL, false));
            }
        }
@@ -1122,8 +1104,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

            if (!$project) {
                $this->redirect()->toRoute('contract/advancedsearch');
            }
            else {
            } else {
                $this->getEntityManager()->refresh($project);

                return $this->redirect()->toRoute(
@@ -1145,8 +1126,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        // Récupération des Id des activités
        if ($request->isPost()) {
            $paramID = $this->params()->fromPost('ids', '');
        }
        else {
        } else {
            $paramID = $this->params()->fromQuery('ids', '');
        }

@@ -1162,8 +1142,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
            );
            if ($this->getOrganizationPerimeter()) {
                $organizations = $this->getOrganizationPerimeter();
            }
            else {
            } else {
                throw new UnAuthorizedException('Droits insuffisants');
            }
        }
@@ -1231,8 +1210,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
            if (!$paramID) {
                return $this->getResponseBadRequest();
            }
        }
        else {
        } else {
            return $this->getResponseUnauthorized();
        };

@@ -1253,8 +1231,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        if ($format == "xls") {
            $downloader->downloadCSVToExcel($csvPath);
        }
        else {
        } else {
            $downloader->downloadCSV($csvPath);
        }
        die();
@@ -1408,8 +1385,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        if ($projectId) {
            $project = $this->getProjectService()->getProject($projectId);
            $this->getOscarUserContextService()->check(Privileges::PROJECT_ACTIVITY_ADD, $project);
        }
        else {
        } else {
            $project = null;
        }

@@ -1438,8 +1414,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                    }
                }
                $rolesOrganizations[''] = $this->oscarText('Pas de rôle pour cette organisation');
            }
            else {
            } else {
                return $this->getResponseInternalError("Données incohérentes");
            }
        }
@@ -1641,8 +1616,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        'contractdocument/process',
                        ['id' => $doc->getId()]
                    );
                }
                else {
                } else {
                    $manageProcess = null;
                }
            }
@@ -1686,12 +1660,10 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $docAdded['urlPerson'] = false;
                    }
                    $privateTab ["documents"] [] = $docAdded;
                }
                else {
                } else {
                    $unclassifiedTab ["documents"] [] = $docAdded;
                }
            }
            else {
            } else {
                if (!array_key_exists($doc->getTabDocument()->getId(), $arrayTabs)) {
                    continue;
                }
@@ -1835,8 +1807,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        ),
                    ];
                    return $this->jsonOutput($datas);
                }
                elseif ($this->isAjax() || $this->getRequest()->getQuery('f') === 'json') {
                } elseif ($this->isAjax() || $this->getRequest()->getQuery('f') === 'json') {
                    try {
                        $perimeter = $this->getRequest()->getQuery('p', null);
                        $datas = [
@@ -1852,8 +1823,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $this->getLoggerService()->error($e->getMessage());
                        return $this->jsonError("Impossible de charger l'activité '$id'");
                    }
                }
                else {
                } else {
                    return [
                        'activity' => $entity
                    ];
@@ -2061,8 +2031,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                    }
                }
            }
        }
        elseif ($method == 'POST') {
        } elseif ($method == 'POST') {
            $masses = $_POST['masses'];
            $previsionnals = $_POST['previsionnel'];

@@ -2086,8 +2055,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $out[$compte][$year]->setYear($year);
                        $out[$compte][$year]->setActivity($entity);
                        $out[$compte][$year]->setAccount($compte);
                    }
                    else {
                    } else {
                        if (array_key_exists($compte, $out) && array_key_exists($year, $out[$compte])) {
                            $this->getEntityManager()->remove($out[$compte][$year]);
                        }
@@ -2390,8 +2358,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
            $view->setTemplate('/oscar/project/project-selector.phtml');

            return $view;
        }
        else {
        } else {
            throw new Exception(sprintf("L'activité n'existe pas"));
        }
    }
@@ -2452,8 +2419,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $context = "activity";
                $contextKey = $activityPerson->getActivity()->getOscarNum();
                $idEnroller = $activityPerson->getActivity()->getId();
            }
            else {
            } else {
                $urlDelete = $deletableA ? $this->url()->fromRoute(
                    'personproject/delete',
                    ['idenroll' => $activityPerson->getId()]
@@ -2564,8 +2530,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $roleprincipal = false;
                $rolelabel = "Rôle inconnu";
                $role = null;
            }
            else {
            } else {
                $roleId = $activityOrganization->getRoleObj()->getId();
                $roleprincipal = $activityOrganization->getRoleObj()->isPrincipal();
                $rolelabel = $activityOrganization->getRoleObj()->getRoleId();
@@ -2579,8 +2544,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $deletable = $deletableA;
                $context = "activity";
                $contextKey = $activityOrganization->getActivity()->getOscarNum();
            }
            else {
            } else {
                $editable = $editableP;
                $deletable = $deletableP;
                $context = "project";
@@ -2778,7 +2742,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

    public function advancedSearch2Action(): array|ViewModel
    {
        if( $this->isAjax() || $this->params()->fromQuery('f') === 'json' ){

        if ($this->isAjax() || $this->params()->fromQuery('format') === 'json') {
            $datas = [];
            $params = [
                'q' => $this->params()->fromQuery('q', ''),
@@ -2786,11 +2751,43 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                'rbp' => $this->params()->fromQuery('rbp', 20),
                'sort' => $this->params()->fromQuery('sort', 'hit'),
                'direction' => $this->params()->fromQuery('direction', 'ASC'),
                'filters' => $this->params()->fromQuery('f', []),
                'project' => $this->params()->fromQuery('project') == '1' ?? '0',
            ];

            $response = new JsonModel($this->getProjectGrantService()->search2($params));
            return $response;
        }
        return [];


        // Type de filtre
        $filters = [
            "at" => [
                "key" => 'at',
                "label" => $this->oscarText("Type"),
                "raw" => 'at;;0'
            ],
            "ap" => [
                "key" => 'ap',
                "label" => $this->oscarText("Personne"),
                "raw" => 'ap;;'
            ],
            "ao" => [
                "key" => 'ao',
                "label" => $this->oscarText("Organisation"),
                "raw" => 'ao;;'
            ]
        ];
        // Données pour la vue
        $filtersOptions = [
            'activityTypes' => $this->getActivityTypeService()->getActivityTypesTree(true),
            'activityDocumentTypes' => $this->getProjectGrantSearchService()->getFilterOptionsMilestones(),
            'filters' => $filters,
        ];
        return [
            'filtersOptions' => $filtersOptions,
            'urlShow' => $this->url()->fromRoute('contract/show', ['id' => ''])
        ];
    }

    /**
+35 −34
Original line number Diff line number Diff line
@@ -1094,10 +1094,6 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
            }
            $activities = $json;
        }
        /** @var OrganizationRoleRepository $ror */
        $ror = $this->getEntityManager()->getRepository(OrganizationRole::class);

        $rolesOrganization = $ror->getRolesAndUsageWithCountInLabel();
//        var_dump($rolesOrganization);
//        die();

@@ -1122,7 +1118,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
            'sortDirection'          => $params['sortDirection'],
            'sortIgnoreNull'         => $params['sortIgnoreNull'],
            // Valeurs pour les champs de formulaire
            'rolesOrganizations'     => $rolesOrganization,
            'rolesOrganizations'     => $this->getFilterOptionsOrganizationRoles(),
            'statuts'                => $this->getAdministrationConfigService()
                ->activityStatusSelect(true, true, true),
            'tags'                   => $this->getFilterOptionsTags(),
@@ -1172,7 +1168,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Retourne la liste des comptes (Plan comptable) utilisés dans les dépenses.
     * @return array
     */
    private function getFilterOptionsAccountsUsed(): array
    public function getFilterOptionsAccountsUsed(): array
    {
        return $this->getSpentService()->getAccountsInfosUsed()->getAccounts();
    }
@@ -1181,7 +1177,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Retourne la liste des numérotations personnalisées dans les activités.
     * @return array
     */
    private function getFilterOptionsActivityNumbers(): array
    public function getFilterOptionsActivityNumbers(): array
    {
        return $this->getOscarConfigurationService()->getNumerotationKeys();
    }
@@ -1190,7 +1186,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Liste des types de document.
     * @return array
     */
    private function getFilterOptionsDocumentTypes(): array
    public function getFilterOptionsDocumentTypes(): array
    {
        $types = [];
        foreach ($this->getProjectGrantService()->getDocumentTypes() as $type) {
@@ -1203,7 +1199,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Liste des types d'activités.
     * @return array
     */
    private function getFilterOptionsActivityTypes(): array
    public function getFilterOptionsActivityTypes(): array
    {
        return $this->getProjectGrantService()->getActivityTypes(true);
    }
@@ -1213,7 +1209,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Liste des disciplines.
     * @return array
     */
    private function getFilterOptionsDisciplines(): array
    public function getFilterOptionsDisciplines(): array
    {
        /** @var DisciplineRepository $disciplineRepository */
        $disciplineRepository = $this->getEntityManager()->getRepository(Discipline::class);
@@ -1230,7 +1226,7 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Liste des pays.
     * @return array
     */
    private function getFilterOptionsCountries(): array
    public function getFilterOptionsCountries(): array
    {
        return $this->getProjectGrantService()->getOrganizationService()->getCountriesList();
    }
@@ -1239,33 +1235,17 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
     * Liste des types d'organisations.
     * @return array
     */
    private function getFilterOptionsOrganizationTypes(): array
    public function getFilterOptionsOrganizationTypes(): array
    {
        return $this->getProjectGrantService()->getOrganizationService()->getOrganizationTypesSelect();
    }

    private function getFilterOptionsFieldCSV(): array
    public function getFilterOptionsFieldCSV(): array
    {
        return $this->getProjectGrantService()->getFieldsCSV();
    }

    /**
     * Correspondance entre les filtres de date et les champs.
     * @return string[]
     */
    public function getFiltersDateMatch(): array
    {
        // Correspondance des champs de type date
        return [
            'add' => self::SORT_DATE_START,
            'adc' => self::SORT_DATE_CREATED,
            'adf' => self::SORT_DATE_END,
            'adm' => self::SORT_DATE_UPDATED,
            'adn' => self::SORT_DATE_NEGOCIATION,
            'ads' => self::SORT_DATE_SIGNED,
            'adp' => self::SORT_DATE_OPENED,
        ];
    }


    /**
     * Retourne les options de tri disponibles (Champs).
@@ -1304,10 +1284,31 @@ class ProjectGrantSearchService implements UseEntityManager, UsePersonService, U
        return $this->getProjectGrantService()->getOrganizationService();
    }

    private function getFilterOptionsTags()
    /**
     * Correspondance entre les filtres de date et les champs.
     * @return string[]
     */
    public function getFiltersDateMatch(): array
    {
        // Correspondance des champs de type date
        return [
            'add' => self::SORT_DATE_START,
            'adc' => self::SORT_DATE_CREATED,
            'adf' => self::SORT_DATE_END,
            'adm' => self::SORT_DATE_UPDATED,
            'adn' => self::SORT_DATE_NEGOCIATION,
            'ads' => self::SORT_DATE_SIGNED,
            'adp' => self::SORT_DATE_OPENED,
        ];
    }

    public function getFilterOptionsTags()
    {
        return $this->getEntityManager()->getRepository(ActivityMotCle::class)->getAllArray();
    }

    public function getFilterOptionsOrganizationRoles()
    {
        /** @var ActivityMotCleRepository $repo */
        $repo = $this->getEntityManager()->getRepository(ActivityMotCle::class);
        return $repo->getAllArray();
        return $this->getEntityManager()->getRepository(OrganizationRole::class)->getRolesAndUsageWithCountInLabel();
    }
}
+196 −42

File changed.

Preview size limit exceeded, changes collapsed.

+124 −109

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ abstract class ElasticSearchEngine

    private string $searchVariant;

    public array $staticDatas = [];

    /**
     * @param array $hosts
     * @param Logger $logger
@@ -336,7 +338,6 @@ abstract class ElasticSearchEngine
        if( $date ) {
            $format = 'Y-m-d'.($withTime ? ' H:i:s' : '');
            $value = $date->format($format);
            error_log("$format >>> $value");
            return $value;
        }
        return null;
Loading