resultat vote
This commit is contained in:
@ -4,6 +4,7 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Entity\Project;
|
use App\Entity\Project;
|
||||||
use App\Form\ProjectType;
|
use App\Form\ProjectType;
|
||||||
|
use App\Form\ProjectVotedType;
|
||||||
use App\Repository\ProjectRepository;
|
use App\Repository\ProjectRepository;
|
||||||
use App\Security\ProjectVoter;
|
use App\Security\ProjectVoter;
|
||||||
use Bnine\FilesBundle\Service\FileService;
|
use Bnine\FilesBundle\Service\FileService;
|
||||||
@ -121,7 +122,20 @@ class ProjectController extends AbstractController
|
|||||||
$attribute = constant(ProjectVoter::class.'::MOVE'.$status);
|
$attribute = constant(ProjectVoter::class.'::MOVE'.$status);
|
||||||
$this->denyAccessUnlessGranted($attribute, $project);
|
$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));
|
$project->setStatus(constant(Project::class.'::'.$status));
|
||||||
|
@ -6,7 +6,9 @@ use App\Entity\Project;
|
|||||||
use App\Form\Type\ProjectOptionType;
|
use App\Form\Type\ProjectOptionType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
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\SubmitType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
@ -20,6 +22,24 @@ class ProjectVotedType extends AbstractType
|
|||||||
'attr' => ['class' => 'btn btn-success no-print me-1'],
|
'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, [
|
->add('options', CollectionType::class, [
|
||||||
'entry_type' => ProjectOptionType::class,
|
'entry_type' => ProjectOptionType::class,
|
||||||
'entry_options' => ['label' => false],
|
'entry_options' => ['label' => false],
|
||||||
|
@ -51,7 +51,29 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class='card-body'>
|
<div class='card-body'>
|
||||||
{{project.summary|nl2br}}
|
{{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>
|
||||||
|
<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">
|
<div class='card-footer' style="line-height:14px">
|
||||||
<small><em>
|
<small><em>
|
||||||
{% if project.dueDate %}
|
{% if project.dueDate %}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -82,6 +82,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-8 mx-auto">
|
<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">
|
<div style="display:flex;" class="mt-3">
|
||||||
{% for option in project.options %}
|
{% for option in project.options %}
|
||||||
<div class="card" style="flex:1 1 0">
|
<div class="card" style="flex:1 1 0">
|
||||||
|
63
templates/project/vote.html.twig
Normal file
63
templates/project/vote.html.twig
Normal 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 %}
|
Reference in New Issue
Block a user