diff --git a/README.md b/README.md index aec913f..5ca0729 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ # paheko-module-votes -Module pour le logiciel Paheko permettant de faire voter les utilisateurs. \ No newline at end of file +Module pour le logiciel Paheko permettant de faire voter les utilisateurs. + + +## To Do List + +[x] Permettre et comptabiliser les votes +[ ] Régler les droits d'accès +[ ] Permettre plusieurs questions par scrutin +[ ] Vérifier qu'un utilisateur ne puisse pas voter s'il arrive sur la page de vote en trichant (pour le moment, la page est juste cachée) +[ ] Afficher les résultats de façon moins moche diff --git a/delete.html b/delete.html new file mode 100644 index 0000000..4be8361 --- /dev/null +++ b/delete.html @@ -0,0 +1,17 @@ +{{#restrict section="accounting" level="write" block=true}}{{/restrict}} + +{{#load assign="scrutin" id=$_GET.id|intval}} +{{else}} + {{:error message="Aucun modèle trouvé"}} +{{/load}} + +{{#form on="delete"}} + {{:delete id=$scrutin.id}} + {{:redirect to="./"}} +{{/form}} + +{{:admin_header title="Supprimer scrutin"}} + +{{:delete_form legend="Supprimer un scrutin" warning="Supprimer le scrutin '%s' ?"|args:$scrutin.name}} + +{{:admin_footer}} \ No newline at end of file diff --git a/edit.html b/edit.html new file mode 100644 index 0000000..6438c5d --- /dev/null +++ b/edit.html @@ -0,0 +1,37 @@ +{{#restrict section="accounting" level="write" block=true}}{{/restrict}} +{{:admin_header title="Nouveau scrutin"}} + +{{if $_GET.id}} + {{#load assign="scrutin" id=$_GET.id|intval}}{{/load}} +{{/if}} + +{{if $_POST.save}} + {{:save id=$scrutin.id + validate_schema="./scrutin.schema.json" + name=$_POST.name|strval|trim + desc=$_POST.desc|strval|or:null + activity_see=$_POST.activity_see|intval|or:null + question=$_POST.question|strval|trim + votes=$_POST.votes + }} + {{:redirect to="./"}} +{{/if}} + +
+ +{{:admin_footer}} \ No newline at end of file diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..5f3dcd7 --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/index.html b/index.html new file mode 100644 index 0000000..852734d --- /dev/null +++ b/index.html @@ -0,0 +1,35 @@ +{{#restrict section="accounting" level="write" block=true}}{{/restrict}} +{{:admin_header title="Liste des scrutins"}} + + + +{{#list select="$$.name AS 'Scrutin'" order=1 desc=true}} + {{:assign var="qs" name=$name desc=$desc question=$question activity_see=$activity_see}} + {{:assign qs=$qs|http_build_query}} + {{:assign url="!voter/results.php?%s"|args:$qs}} + {{*Forbid visibility if not member of activity*}} + {{if $activity_see}} + {{#sql select="*" tables="services_users" where="id_service = :id_act AND id_user = :id_user" :id_act=$activity_see :id_user=$logged_user.id count="TRUE"}} + {{if !$count}} + {{:continue 2}} + {{/if}} + {{/sql}} + {{/if}} ++ Aucun scrutin. +
+{{/list}} \ No newline at end of file diff --git a/module.ini b/module.ini new file mode 100644 index 0000000..7a55859 --- /dev/null +++ b/module.ini @@ -0,0 +1,8 @@ +name = "Voter" +description = null +author = "Charlie, Mines de Rayons" +author_url = "https://www.minesderayons.fr" +restrict_section = null +restrict_level = "none" +menu = true +web = false diff --git a/result.html b/result.html new file mode 100644 index 0000000..b3d010d --- /dev/null +++ b/result.html @@ -0,0 +1,60 @@ +{{:admin_header title="Résultats du vote"}} + +{{if $_GET.id}} + {{#load assign="scrutin" id=$_GET.id|intval}}{{/load}} + + + {{:linkbutton href="./" label="Retour" shape="left"}} + +{{else}} ++ Aucun scrutin sélectionné. Il ne devrait y avoir aucune raison d'atterir sur cette page. +
+{{/if}} \ No newline at end of file diff --git a/scrutin.schema.json b/scrutin.schema.json new file mode 100644 index 0000000..4871eca --- /dev/null +++ b/scrutin.schema.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "name": { + "description": "Nom du scrutin", + "type": "string" + }, + "desc": { + "description": "Description", + "type": ["string", "null"] + }, + "activity_see": { + "description": "Activité à laquelle il faut être inscrit pour voir le scrutin", + "type": ["integer", "null"] + }, + "question": { + "description": "Question", + "type": "string" + }, + "votes": { + "description": "Votes", + "type": ["array", "null"] + } + }, + "required": ["name", "question"] +} \ No newline at end of file diff --git a/vote.html b/vote.html new file mode 100644 index 0000000..83baf4d --- /dev/null +++ b/vote.html @@ -0,0 +1,48 @@ +{{:admin_header title="Voter"}} + +{{if $_GET.id}} + {{#load assign="scrutin" id=$_GET.id|intval}}{{/load}} + + {{:assign var="reponses" -1="Non" 0="" 1="Oui" }} + + + {{:assign user_id=$logged_user.id }} + Bonjour {{$logged_user.nom}}. + + {{if $_POST.save}} + {{:assign var="scrutin.votes.%s"|args:$user_id value=$_POST.vote|intval}} + {{:save id=$scrutin.id + validate_schema="./scrutin.schema.json" + votes=$scrutin.votes + }} + + {{:redirect to="./"}} + {{/if}} + + + + +{{else}} ++ Aucun scrutin sélectionné. Il ne devrait y avoir aucune raison d'atterir sur cette page. +
+{{/if}} \ No newline at end of file