Commit f84e30e374598278ad994af5d0422edb375d5760

Authored by Geoffrey PREUD'HOMME
1 parent e3af8154

[Orga] Retravail

- Nouveau design
- Classe Evenement
Showing 1 changed file with 125 additions and 40 deletions   Show diff stats
orga.php
... ... @@ -4,49 +4,134 @@
4 4 # DEBUG
5 5 # e_ : est
6 6 # r_ : a le droit de
7   -$e_connecte = true;
8   -$r_voir = $e_connecte;
9   -$r_vote = true;
10   -$r_proposer = true;
11   -
12   -if ($r_voir) {
13   - if ($r_vote) {
14   - if ($r_proposer) {
15   -?>
16   -<h3>Ajouter un évènement</h3>
17   -<form id="nvEv">
18   - <label for="nom">Nom :</label><br/><input type="text" name="nom"><br/>
19   - <label for="desc">Description :</label><br/><textarea name="desc"></textarea><br/>
20   - <h4>Dates proposées</h4>
21   - <div id="nvEvDates">
22   - Pas de date proposée pour l'instant.
23   - </div>
24   - <form id="nvDate" action="#">
25   - <h5>Proposer une date</h5>
26   - <label for="nvDateDate">Date :</label><br/><input type="datetime"name="nvDateDate"/><br/>
27   - <label for="nvDateDuree">Durée :</label><br/><input type="time"name="nvDateDuree"/><br/>
28   - <input class="btn btn-default" type="submit" value="Proposer la date">
29   - </form>
30   - <input class="btn btn-primary" type="submit" value="Ajouter l'évènement">
31   -</form>
32   -<?php
33   - }
  7 +
  8 +$e_connecte = false;
  9 +$e_modo = true;
  10 +
  11 +$droits = array('voir', 'voter', 'ajouter', 'proposer', 'annuler', 'supprimer', 'modifier', 'valider');
  12 +
  13 +class Evenement
  14 +{
  15 + public $id = 0;
  16 + public $nom = "Sans nom";
  17 + public $description = "Sans description";
  18 + public $annule = false;
  19 + public $valide = false;
  20 + public $duree = 120;
  21 +
  22 + public $dates = array();
  23 +
  24 + public function html() {
  25 + global $droits;
  26 +
  27 + $html = ' <li class="list-group-item">';
  28 +
  29 + # Titre
  30 + $html .= '<h3 class="list-group-item-heading">'.$this->nom;
  31 + if ($this->annule) {
  32 + $html .= ' <span class="label label-danger">Annulé</span>';
  33 + }
  34 + if (in_array('annuler', $droits) && !$this->annule) { # TODO
  35 + $html .= ' <button type="button" class="btn btn-danger"><span class="glyphicon glyphicon glyphicon-remove"></span></button>';
  36 + }
  37 + if (in_array('supprimer', $droits) && !$this->valide) { # TODO
  38 + $html .= ' <button type="button" class="btn btn-danger"><span class="glyphicon glyphicon glyphicon-trash"></span></button>';
  39 + }
  40 + $html .= '</h3>';
  41 +
  42 + # Description
  43 + $html .= '<div class="panel panel-default">';
  44 + $html .= '<div class="panel-heading">';
  45 + $html .= '<h4 class="panel-title">Description';
  46 + if (in_array('modifier', $droits)) {
  47 + $html .= ' <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></button>';
  48 + }
  49 + $html .= '</h4>';
  50 + $html .= '</div>';
  51 + $html .= '<div class="panel-body">';
  52 + $html .= '<p>';
  53 + $html .= nl2br(htmlspecialchars($this->description));
  54 + $html .= '</p>';
  55 + // $html .= '<hr/>';
  56 + $html .= '<p>';
  57 + $html .= 'Durée : '.$this->duree.' minutes <br/>';
  58 + if ($this->valide) {
  59 + $html .= 'Date : '.date('c', $this->valide).'<br/>';
  60 + }
  61 + $html .= '</p>';
  62 + if ($this->annule) {
  63 + $html .= '<p class="alert alert-danger" role="alert">Annulé</p>';
  64 +
  65 + }
  66 + $html .= '</div>';
  67 + $html .= '</div>';
  68 +
  69 + # Dates
  70 + if (!$this->valide && !$this->annule) {
  71 + $html .= '<div class="panel panel-default">';
  72 + $html .= '<div class="panel-heading">';
  73 + $html .= '<h4 class="panel-title">Dates possibles';
  74 + if (in_array('proposer', $droits)) {
  75 + $html .= '<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span></button>';
  76 + }
  77 + $html .= '</h4>';
  78 + $html .= '</div>';
  79 + $html .= '<div class="panel-body">';
  80 + $html .= '<ul class="list-group">';
  81 + foreach ($this->dates as $dateIndex => $date) {
  82 + $html .= '<li class="list-group-item">'.date('c', $date).' (6 <span class="glyphicon glyphicon-user"></span>)</li>';
  83 + }
  84 + $html .= '</ul>';
  85 + if (in_array('valider', $droits) && !$this->valide) {
  86 + $html .= '<p><button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Valider la date</button></p>';
  87 + }
  88 + $html .= '</div>';
  89 + $html .= '</div>';
  90 + }
  91 +
  92 + $html .= '</li>';
  93 + return $html;
  94 + }
  95 +}
  96 +
34 97 ?>
35   -<h3>Évènements à planifier</h3>
36   -<div class="ev">
37 98  
38   -</div>
39   -<?php
40   - }
  99 +<h1>Évènements</h1>
  100 +
  101 +<h2>Plannifiés <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span></button></h2>
  102 +<ul class="list-group">
  103 +<?
  104 +$test1 = new Evenement;
  105 +$test1->dates[] = time();
  106 +$test1->valide = time();
  107 +echo $test1->html()
41 108 ?>
42   -<h3>Évènements fixés</h3>
43   -<?php
44   -} else {
  109 +<?
  110 +$test2 = new Evenement;
  111 +$test2->dates[] = time();
  112 +$test2->valide = time();
  113 +$test2->annule = true;
  114 +echo $test2->html()
45 115 ?>
46   -<p class="bg-danger">
47   -Vous devez vous connecter pour gérer l'organisation des évènements.
48   -</p>
49   -<?php
50   -}
  116 +</ul>
  117 +
51 118  
  119 +<h2>À plannifier <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span></button></h2>
  120 +<ul class="list-group">
  121 +<?
  122 +$test3 = new Evenement;
  123 +$test3->dates[] = time();
  124 +echo $test3->html()
52 125 ?>
  126 +<?
  127 +$test4 = new Evenement;
  128 +$test4->dates[] = time();
  129 +$test4->annule = true;
  130 +echo $test4->html()
  131 +?>
  132 +</ul>
  133 +
  134 +
  135 +<h2>Évènements passés</h2>
  136 +<ul class="list-group">
  137 +</ul>
53 138 \ No newline at end of file
... ...