resultat vote

This commit is contained in:
2025-09-04 21:18:22 +02:00
parent 48781d086e
commit 21230d6ca5
6 changed files with 143 additions and 2 deletions

View File

@ -4,6 +4,7 @@ namespace App\Controller;
use App\Entity\Project;
use App\Form\ProjectType;
use App\Form\ProjectVotedType;
use App\Repository\ProjectRepository;
use App\Security\ProjectVoter;
use Bnine\FilesBundle\Service\FileService;
@ -121,7 +122,20 @@ class ProjectController extends AbstractController
$attribute = constant(ProjectVoter::class.'::MOVE'.$status);
$this->denyAccessUnlessGranted($attribute, $project);
if (Project::VOTED == $status) {
if ('VOTED' == $status && Project::ARCHIVED != $project->getStatus()) {
$form = $this->createForm(ProjectVotedType::class, $project);
$form->handleRequest($request);
if (!$form->isSubmitted() || !$form->isValid()) {
return $this->render('project/vote.html.twig', [
'usemenu' => true,
'usesidebar' => false,
'title' => 'Vote Projet = '.$project->getTitle(),
'routecancel' => 'app_user_project_view',
'form' => $form,
'project' => $project,
]);
}
}
$project->setStatus(constant(Project::class.'::'.$status));

View File

@ -6,7 +6,9 @@ use App\Entity\Project;
use App\Form\Type\ProjectOptionType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -20,6 +22,24 @@ class ProjectVotedType extends AbstractType
'attr' => ['class' => 'btn btn-success no-print me-1'],
])
->add('resultVote', TextareaType::class, [
'label' => 'Résultats',
'required' => true,
'attr' => [
'rows' => 7,
],
])
->add('nbVoteWhite', IntegerType::class, [
'label' => 'Votes blancs',
'required' => false,
])
->add('nbVoteNull', IntegerType::class, [
'label' => 'Votes nuls',
'required' => false,
])
->add('options', CollectionType::class, [
'entry_type' => ProjectOptionType::class,
'entry_options' => ['label' => false],

View File

@ -51,7 +51,29 @@
</div>
<div class='card-body'>
{{project.summary|nl2br}}
{% if project.status=="Voté" or project.status=="Archivé" %}
<small>
<hr>
<div class="row">
<div class="col-xs-6">
{% for option in project.options %}
{{ option.title|title }} = {{ option.nbVote }}<br>
{% endfor %}
</div>
<div class="col-xs-6">
Votes Blancs = {{ project.nbVoteWhite }}<br>
Votes Nuls = {{ project.nbVoteNull }}
</div>
</div>
<hr>
<strong>Résultat = </strong><br>
{{ project.resultVote|nl2br }}
</small>
{% endif %}
</div>
<div class='card-footer' style="line-height:14px">
<small><em>
{% if project.dueDate %}

View File

@ -1 +0,0 @@

View File

@ -82,6 +82,29 @@
</div>
<div class="col-md-8 mx-auto">
{% if project.status=="Voté" or project.status=="Archivé" %}
<div class="card mt-3">
<div class="card-header">Vote</div>
<div class="card-body">
<div class="row" style="font-size:150%">
<div class="col-md-6">
{% for option in project.options %}
{{ option.title|title }} = {{ option.nbVote }}<br>
{% endfor %}
</div>
<div class="col-md-6">
Votes Blancs = {{ project.nbVoteWhite }}<br>
Votes Nuls = {{ project.nbVoteNull }}
</div>
</div>
<hr>
<strong>Résultat = </strong><br>
{{ project.resultVote|nl2br }}
</div>
</div>
{% endif %}
<div style="display:flex;" class="mt-3">
{% for option in project.options %}
<div class="card" style="flex:1 1 0">

View File

@ -0,0 +1,63 @@
{% extends 'base.html.twig' %}
{% block title %} = {{title}}{% endblock %}
{% block body %}
<h1>{{title}}</h1>
{% include('include/error.html.twig') %}
{{ form_start(form) }}
{{ form_widget(form.submit) }}
<a href="{{ path(routecancel,{id:project.id}) }}" class="btn btn-secondary me-5">Annuler</a>
<div class="row">
<!-- Colonne VOTE -->
<div class="col-md-4 ms-auto d-flex flex-column">
<div class="card mt-3 flex-fill d-flex flex-column">
<div class="card-header">Vote</div>
<div class="card-body flex-fill">
<div class="list-group h-100">
{% for optionForm in form.options %}
<div class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">{{ optionForm.title.vars.value }}</span>
<div style="width:120px;">
{{ form_widget(optionForm.nbVote, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
</div>
{% endfor %}
<div class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">{{ form.nbVoteWhite.vars.label }}</span>
<div style="width:120px;">
{{ form_widget(form.nbVoteWhite, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
</div>
<div class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">{{ form.nbVoteNull.vars.label }}</span>
<div style="width:120px;">
{{ form_widget(form.nbVoteNull, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Colonne RESULT -->
<div class="col-md-4 me-auto d-flex flex-column">
<div class="card mt-3 flex-fill d-flex flex-column">
<div class="card-header">Résultat</div>
<div class="card-body flex-fill d-flex flex-column">
{{ form_widget(form.resultVote, { 'attr': { 'class': 'flex-fill w-100' } }) }}
</div>
</div>
</div>
</div>
<div style="display:none;">
{{ form_rest(form) }}
</div>
{{ form_end(form, { render_rest: false }) }}
{% endblock %}