Skip to content

Commit

Permalink
Merge pull request #2582 from MTES-MCT/bugfix/2576-prevent-draft-to-m…
Browse files Browse the repository at this point in the history
…ulti-signalements

[FO - Signalement] Multiple création de signalement
  • Loading branch information
hmeneuvrier committed May 23, 2024
2 parents 579a146 + f1e2e91 commit ff6b995
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ export default defineComponent({
}
},
makeNewSignalement () {
if (formStore.alreadyExists.uuidDraft !== null && (
formStore.alreadyExists.type === 'draft' || formStore.alreadyExists.type === 'signalement'
)) {
if (formStore.alreadyExists.uuidDraft !== null && (formStore.alreadyExists.type === 'draft' || formStore.alreadyExists.type === 'signalement')){
requests.archiveDraft(formStore.alreadyExists.uuidDraft, this.saveAndContinue)
} else if(formStore.alreadyExists.type === 'signalement'){
this.saveAndContinue()
}
},
saveAndContinue () {
Expand Down
6 changes: 5 additions & 1 deletion src/Manager/SignalementDraftManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public function update(
->setProfileDeclarant(ProfileDeclarant::from(strtoupper($signalementDraftRequest->getProfil())));

if (self::LAST_STEP === $signalementDraftRequest->getCurrentStep()) {
$signalement = $this->dispatchSignalementDraftCompleted($signalementDraft);
if (SignalementDraftStatus::EN_SIGNALEMENT === $signalementDraft->getStatus()) {
$signalement = $signalementDraft->getSignalements()->first();
} else {
$signalement = $this->dispatchSignalementDraftCompleted($signalementDraft);
}
}
$this->save($signalementDraft);

Expand Down
5 changes: 3 additions & 2 deletions src/Repository/SignalementRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -1192,11 +1192,11 @@ public function findAllForEmailAndAddress(
bool $isTiersDeclarant = true
): array {
$qb = $this->createQueryBuilder('s');
/*if ($isTiersDeclarant) {
if ($isTiersDeclarant) {
$qb->andWhere('s.mailDeclarant = :email')->setParameter('email', $email);
} else {
$qb->andWhere('s.mailOccupant = :email')->setParameter('email', $email);
}*/
}
$qb->andWhere('LOWER(s.adresseOccupant) = :address')->setParameter('address', strtolower($address))
->andWhere('s.cpOccupant = :zipcode')->setParameter('zipcode', $zipcode)
->andWhere('LOWER(s.villeOccupant) = :city')->setParameter('city', strtolower($city))
Expand All @@ -1214,6 +1214,7 @@ public function findAllForEmailAndAddress(
$qb->addOrderBy('s.createdAt', 'DESC');
} else {
$qb->addOrderBy('s.lastSuiviAt', 'DESC');
$qb->setMaxResults(1);
}

return $qb->getQuery()->getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ and signalement.profileDeclarant is not same as enum('App\\Entity\\Enum\\Profile
<div class="fr-col-10 fr-col-md-11 fr-h5 fr-disorder-overview-title">Le logement</div>
</div>
{% set zone = 'batiment' %}
{% for situation,criteres in infoDesordres['criticitesArranged'][enum('App\\Entity\\Enum\\DesordreCritereZone').LOGEMENT.name] %}
{% for situation,criteres in infoDesordres['criticitesArranged'][enum('App\\Entity\\Enum\\DesordreCritereZone').BATIMENT.name] %}
{% include 'front/_partials/_desordre-v2.html.twig' %}
{% endfor %}
{% endif %}
Expand Down

0 comments on commit ff6b995

Please sign in to comment.