-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2408 from MTES-MCT/feature/2117-refonte-liste-sig…
…nalement [BO - Liste signalement][Back] Gestion liste et filtre existants signalements sous format JSON
- Loading branch information
Showing
16 changed files
with
441 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240402090719 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Update some signalements with is_allocataire from 0 or 1 to Oui or Non'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql( | ||
'UPDATE signalement SET is_allocataire = 0 WHERE is_allocataire LIKE :allocataire_non', | ||
['allocataire_non' => 'Non'] | ||
); | ||
|
||
$this->addSql( | ||
'UPDATE signalement SET is_allocataire = 1 WHERE is_allocataire LIKE :allocataire_oui', | ||
['allocataire_oui' => 'Oui'] | ||
); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use App\Entity\Enum\ProfileDeclarant; | ||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240402091719 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Update profile declarant to legacy signalement'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql( | ||
'UPDATE signalement SET profile_declarant = :profile_locataire WHERE created_from_id IS NULL AND is_not_occupant = 0', | ||
['profile_locataire' => ProfileDeclarant::LOCATAIRE->value] | ||
); | ||
|
||
$this->addSql( | ||
'UPDATE signalement SET profile_declarant = :profile_tiers_pro WHERE created_from_id IS NULL AND is_not_occupant = 1 AND lien_declarant_occupant IN (\'PROFESSIONNEL\', \'pro\', \'assistante sociale\', \'curatrice\')', | ||
['profile_tiers_pro' => ProfileDeclarant::TIERS_PRO->value] | ||
); | ||
|
||
$this->addSql( | ||
'UPDATE signalement SET profile_declarant = :profile_tiers_particulier WHERE created_from_id IS NULL AND is_not_occupant = 1 AND lien_declarant_occupant NOT IN (\'PROFESSIONNEL\', \'pro\', \'assistante sociale\', \'curatrice\')', | ||
['profile_tiers_particulier' => ProfileDeclarant::TIERS_PARTICULIER->value] | ||
); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
<?php | ||
|
||
namespace App\Dto\Request\Signalement; | ||
|
||
use App\Entity\Enum\SignalementStatus; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class SignalementSearchQuery | ||
{ | ||
public const MAX_LIST_PAGINATION = 25; | ||
|
||
public function __construct( | ||
private readonly ?string $territory = null, | ||
private readonly ?string $searchTerms = null, | ||
#[Assert\Choice(['nouveau', 'en cours', 'ferme', 'refuse'])] | ||
private readonly ?string $status = null, | ||
private readonly ?string $commune = null, | ||
private readonly ?array $etiquettes = null, | ||
#[Assert\Date(message: 'La date de début n\'est pas une date valide')] | ||
private readonly ?string $dateDepotDebut = null, | ||
#[Assert\Date(message: 'La date de fin n\'est pas une date valide')] | ||
private readonly ?string $dateDepotFin = null, | ||
private readonly ?array $partenaires = null, | ||
#[Assert\Choice(['Non planifiée', 'Planifiée', 'Conclusion à renseigner', 'Terminée'])] | ||
private readonly ?string $visiteStatus = null, | ||
private readonly ?string $typeDernierSuivi = null, | ||
private readonly ?string $statusAffectations = null, | ||
#[Assert\GreaterThanOrEqual(0)] | ||
private readonly ?float $criticiteScoreMin = null, | ||
#[Assert\LessThanOrEqual(100)] | ||
private readonly ?float $criticiteScoreMax = null, | ||
#[Assert\Choice(['locataire', 'bailleur_occupant', 'tiers_particulier', 'tiers_pro', 'service_secours', 'bailleur'])] | ||
private readonly ?string $typeDeclarant = null, | ||
#[Assert\Choice(['privee', 'public'])] | ||
private readonly ?string $natureParc = null, | ||
#[Assert\Choice(['caf', 'msa', 'non', 'oui'])] | ||
private readonly ?string $allocataire = null, | ||
private readonly ?bool $enfantsM6 = null, | ||
private readonly ?string $situation = null, | ||
private readonly ?int $page = 1, | ||
#[Assert\Choice(['reference', 'nomOccupant', 'createdAt'])] | ||
private readonly string $sortBy = 'reference', | ||
private readonly string $orderBy = 'DESC', | ||
) { | ||
} | ||
|
||
public function getTerritory(): ?string | ||
{ | ||
return $this->territory; | ||
} | ||
|
||
public function getSearchTerms(): ?string | ||
{ | ||
return $this->searchTerms; | ||
} | ||
|
||
public function getStatus(): ?string | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function getCommune(): ?string | ||
{ | ||
return $this->commune; | ||
} | ||
|
||
public function getEtiquettes(): ?array | ||
{ | ||
return $this->etiquettes; | ||
} | ||
|
||
public function getDateDepotDebut(): ?string | ||
{ | ||
return $this->dateDepotDebut; | ||
} | ||
|
||
public function getDateDepotFin(): ?string | ||
{ | ||
return $this->dateDepotFin; | ||
} | ||
|
||
public function getPartenaires(): ?array | ||
{ | ||
return $this->partenaires; | ||
} | ||
|
||
public function getVisiteStatus(): ?string | ||
{ | ||
return $this->visiteStatus; | ||
} | ||
|
||
public function getTypeDernierSuivi(): ?string | ||
{ | ||
return $this->typeDernierSuivi; | ||
} | ||
|
||
public function getStatusAffectations(): ?string | ||
{ | ||
return $this->statusAffectations; | ||
} | ||
|
||
public function getCriticiteScoreMin(): ?float | ||
{ | ||
return $this->criticiteScoreMin; | ||
} | ||
|
||
public function getCriticiteScoreMax(): ?float | ||
{ | ||
return $this->criticiteScoreMax; | ||
} | ||
|
||
public function getTypeDeclarant(): ?string | ||
{ | ||
return !empty($this->typeDeclarant) ? strtoupper($this->typeDeclarant) : null; | ||
} | ||
|
||
public function getNatureParc(): ?string | ||
{ | ||
return $this->natureParc; | ||
} | ||
|
||
public function getAllocataire(): ?string | ||
{ | ||
return !empty($this->allocataire) ? strtoupper($this->allocataire) : null; | ||
} | ||
|
||
public function getEnfantsM6(): ?bool | ||
{ | ||
return $this->enfantsM6; | ||
} | ||
|
||
public function getSituation(): ?string | ||
{ | ||
return $this->situation; | ||
} | ||
|
||
public function getPage(): ?int | ||
{ | ||
return $this->page; | ||
} | ||
|
||
public function getSortBy(): string | ||
{ | ||
return $this->sortBy; | ||
} | ||
|
||
public function getOrderBy(): string | ||
{ | ||
return $this->orderBy; | ||
} | ||
|
||
public function getFilters(): array | ||
{ | ||
$filters = []; | ||
$filters['searchterms'] = $this->getSearchTerms() ?? null; | ||
$filters['territories'] = $this->getTerritory() ?? null; | ||
$filters['statuses'] = null !== $this->getStatus() | ||
? [SignalementStatus::mapFilterStatus($this->getStatus())] | ||
: null; | ||
$filters['cities'] = null !== $this->getCommune() ? [$this->getCommune()] : null; | ||
$filters['partners'] = $this->getPartenaires() ?? null; | ||
$filters['allocs'] = null !== $this->getAllocataire() ? [$this->getAllocataire()] : null; | ||
$filters['housetypes'] = null !== $this->getNatureParc() ? ['public' === $this->getNatureParc()] : null; | ||
$filters['enfantsM6'] = null !== $this->getEnfantsM6() ? [$this->getEnfantsM6()] : null; | ||
$filters['visites'] = null !== $this->getVisiteStatus() ? [$this->getVisiteStatus()] : null; | ||
if (null !== $this->getCriticiteScoreMin() || null !== $this->getCriticiteScoreMax()) { | ||
$filters['scores'] = [ | ||
'on' => $this->getCriticiteScoreMin() ?? 0, | ||
'off' => $this->getCriticiteScoreMax() ?? 100, | ||
]; | ||
} | ||
if (null !== $this->getDateDepotDebut() && null !== $this->getDateDepotFin()) { | ||
$filters['dates'] = [ | ||
'on' => $this->getDateDepotDebut(), | ||
'off' => $this->getDateDepotFin(), | ||
]; | ||
} | ||
$filters['tags'] = $this->getEtiquettes() ?? null; | ||
$filters['typeDeclarant'] = $this->getTypeDeclarant(); | ||
$filters['page'] = $this->getPage() ?? 1; | ||
$filters['maxItemsPerPage'] = self::MAX_LIST_PAGINATION; | ||
$filters['sortBy'] = $this->getSortBy() ?? 'reference'; | ||
$filters['orderBy'] = $this->getOrderBy() ?? 'DESC'; | ||
|
||
return array_filter($filters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.