-
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 #3611 from MTES-MCT/feature/3590-auto-assigner-sim…
…ulator [Auto-affectation] Mettre en place un simulateur
- Loading branch information
Showing
6 changed files
with
177 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Controller\Back; | ||
|
||
use App\Entity\Territory; | ||
use App\Repository\SignalementRepository; | ||
use App\Repository\TerritoryRepository; | ||
use App\Service\Signalement\AutoAssigner; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
|
||
#[Route('/bo/auto-assigner-simulator')] | ||
class AutoAssignerSimulatorController extends AbstractController | ||
{ | ||
#[Route('/', name: 'back_auto_assigner_simulator_index')] | ||
#[IsGranted('ROLE_ADMIN')] | ||
public function index( | ||
TerritoryRepository $territoryRepository, | ||
): Response { | ||
$territories = $territoryRepository->findAllWithAutoAffectationRules(); | ||
|
||
return $this->render('back/auto-assigner-simulator/index.html.twig', ['territories' => $territories]); | ||
} | ||
|
||
#[Route('/{territory}', name: 'back_auto_assigner_simulator_territory')] | ||
#[IsGranted('ROLE_ADMIN')] | ||
public function territory( | ||
Request $request, | ||
Territory $territory, | ||
SignalementRepository $signalementRepository, | ||
AutoAssigner $autoAssigner, | ||
): Response { | ||
$results = []; | ||
$criteria = ['territory' => $territory]; | ||
$limit = $request->query->getInt('limit', 10); | ||
if ($uuid = $request->query->get('uuid')) { | ||
$criteria['uuid'] = $uuid; | ||
} | ||
$signalements = $signalementRepository->findBy($criteria, ['createdAt' => 'DESC'], $limit); | ||
foreach ($signalements as $signalement) { | ||
$assignablePartners = $autoAssigner->assign($signalement, true); | ||
$results[] = [ | ||
'signalement' => $signalement, | ||
'assignablePartners' => $assignablePartners, | ||
]; | ||
} | ||
|
||
return $this->render('back/auto-assigner-simulator/territory.html.twig', ['territory' => $territory, 'results' => $results, 'limit' => $limit, 'uuid' => $uuid]); | ||
} | ||
} |
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
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,42 @@ | ||
{% extends 'back/base_bo.html.twig' %} | ||
|
||
{% block title %}Auto Assigner Simulator ⚗️{% endblock %} | ||
|
||
{% block content %} | ||
<section class="fr-p-5v"> | ||
{% include 'back/breadcrumb_bo.html.twig' with { | ||
'level2Title': 'Outils SA', | ||
'level2Link': '', | ||
'level2Label': '', | ||
'level3Title': 'Auto Assigner Simulator ⚗️', | ||
'level3Link': '', | ||
} %} | ||
<header> | ||
<div class="fr-grid-row"> | ||
<div class="fr-col-12"> | ||
<h1 class="fr-h1 fr-mb-0"> | ||
Auto Assigner Simulator ⚗️ | ||
<br> | ||
<small>Liste des territoires ayant des règles d'auto-affectation</small> | ||
</h1> | ||
</div> | ||
</div> | ||
</header> | ||
</section> | ||
|
||
<section class="fr-col-12 fr-pt-0 fr-px-5v"> | ||
{% set tableHead %} | ||
<th scope="col">Territoire</th> | ||
{% endset %} | ||
|
||
{% set tableBody %} | ||
{% for item in territories %} | ||
<tr> | ||
<td><a href="{{path('back_auto_assigner_simulator_territory', {territory:item.id})}}">{{ item.zip}} - {{item.name}}</a></td> | ||
</tr> | ||
{% endfor %} | ||
{% endset %} | ||
|
||
{% include '_partials/back/table.html.twig' with { 'tableLabel': 'Auto Assigner Simulator ⚗️', 'tableHead': tableHead, 'tableBody': tableBody } %} | ||
</section> | ||
{% endblock %} |
62 changes: 62 additions & 0 deletions
62
templates/back/auto-assigner-simulator/territory.html.twig
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,62 @@ | ||
{% extends 'back/base_bo.html.twig' %} | ||
|
||
{% block title %}Auto Assigner Simulator ⚗️{% endblock %} | ||
|
||
{% block content %} | ||
<section class="fr-p-5v"> | ||
{% include 'back/breadcrumb_bo.html.twig' with { | ||
'level2Title': 'Outils SA', | ||
'level2Link': '', | ||
'level2Label': '', | ||
'level3Title': 'Auto Assigner Simulator ⚗️', | ||
'level3Link': path('back_auto_assigner_simulator_index'), | ||
'level3Label': 'Retour à la liste des territoires ayant des règles d\'auto-affectation', | ||
'level4Title': 'Simulation', | ||
'level4Link': '', | ||
'level4Label': '', | ||
} %} | ||
<header> | ||
<div class="fr-grid-row"> | ||
<div class="fr-col-12"> | ||
<h1 class="fr-h1 fr-mb-0"> | ||
Auto Assigner Simulator ⚗️ | ||
<br> | ||
{% if uuid %} | ||
<small>sur le signalement {{uuid}} du territoire {{territory.zip}} - {{territory.name}}</small> | ||
{% else %} | ||
<small>sur les {{limit}} derniers signalements du {{territory.zip}} - {{territory.name}}</small> | ||
{% endif %} | ||
</h1> | ||
</div> | ||
</div> | ||
</header> | ||
</section> | ||
|
||
<section class="fr-col-12 fr-pt-0 fr-px-5v"> | ||
{% set tableHead %} | ||
<th scope="col">Signalement</th> | ||
<th scope="col">Partenaires affectés</th> | ||
<th scope="col">Affectations simulées</th> | ||
{% endset %} | ||
|
||
{% set tableBody %} | ||
{% for item in results %} | ||
<tr> | ||
<td><a href="{{path('back_signalement_view', {uuid:item.signalement.uuid})}}">{{ item.signalement.reference}}</a></td> | ||
<td> | ||
{% for affectation in item.signalement.affectations %} | ||
<div class="fr-badge fr-badge--blue-ecume fr-mb-1v">{{ affectation.partner.nom }}</div> | ||
{% endfor %} | ||
</td> | ||
<td> | ||
{% for partner in item.assignablePartners %} | ||
<div class="fr-badge fr-mb-1v">{{ partner.nom }}</div> | ||
{% endfor %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
{% endset %} | ||
|
||
{% include '_partials/back/table.html.twig' with { 'tableLabel': 'Auto Assigner Simulator ⚗️', 'tableHead': tableHead, 'tableBody': tableBody } %} | ||
</section> | ||
{% endblock %} |