paheko-module-votes/result.html
2024-05-22 14:25:30 +02:00

60 lines
1.8 KiB
HTML

{{:admin_header title="Résultats du vote"}}
{{if $_GET.id}}
{{#load assign="scrutin" id=$_GET.id|intval}}{{/load}}
<fieldset class"vote">
<legend>Question</legend>
<p class="vote-question">{{$scrutin.question}}</p>
{{:assign var=ids_oui value=[]}}
{{:assign var=ids_non value=[]}}
{{:assign var=ids_blancs value=[]}}
{{#users id=$scrutin.votes|keys}}
{{* On teste la condition de vote*}}
{{:assign var=vote from="scrutin.votes.%s"|args:$id}}
{{if $vote==-1}}
{{:assign var="ids_non." value=$id}}
{{elseif $vote==0}}
{{:assign var="ids_blanc." value=$id}}
{{elseif $vote==1}}
{{:assign var="ids_oui." value=$id}}
{{else}}
<p class="alert block">
Vote invalide détecté.
</p>
{{/if}}
{{/users}}
{{:assign var="nb_oui" value=$ids_oui|count}}
{{:assign var="nb_non" value=$ids_non|count}}
{{:assign var="nb_blanc" value=$ids_blanc|count|or:null}}
<table>
<tr>
<th> Oui </th>
<td> {{if $nb_oui}} {{$nb_oui}} {{else}} 0 {{/if}} </td>
<td> {{if $nb_oui}} (n° {{$ids_oui|implode:' ,'}}) {{/if}} </td>
</tr>
<tr>
<th> Non </th>
<td> {{if $nb_non}} {{$nb_non}} {{else}} 0 {{/if}} </td>
<td> {{if $nb_non}} (n° {{$ids_non|implode:' ,'}}) {{/if}} </td>
</tr>
<tr>
<th> Blanc </th>
<td> {{if $nb_blanc}} {{$nb_blanc}} {{else}} 0 {{/if}} </td>
<td> {{if $nb_blanc}} (n° {{$ids_blanc|implode:' ,'}}) {{/if}} </td>
</tr>
</table>
{{:assign var=result value="round( 100*(%f-%f)/(%f+%f+%f), 2)"|math:$nb_oui:$nb_non:$nb_oui:$nb_non:$nb_blanc}}
<p>Résultat : {{$result}}%</p>
</fieldset>
{{:linkbutton href="./" label="Retour" shape="left"}}
{{else}}
<p class="alert block">
Aucun scrutin sélectionné. Il ne devrait y avoir aucune raison d'atterir sur cette page.
</p>
{{/if}}