orga.php
4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<h2> Organisation </h2>
<?php
# DEBUG
# e_ : est
# r_ : a le droit de
$e_connecte = false;
$e_modo = true;
$droits = array('voir', 'voter', 'ajouter', 'proposer', 'annuler', 'supprimer', 'modifier', 'valider');
class Evenement
{
public $id = 0;
public $nom = "Sans nom";
public $description = "Sans description";
public $annule = false;
public $valide = false;
public $duree = 120;
public $dates = array();
public function html() {
global $droits;
$html = ' <li class="list-group-item">';
# Titre
$html .= '<h3 class="list-group-item-heading">'.$this->nom;
if ($this->annule) {
$html .= ' <span class="label label-danger">Annulé</span>';
}
if (in_array('annuler', $droits) && !$this->annule) { # TODO
$html .= ' <button type="button" class="btn btn-danger"><span class="glyphicon glyphicon glyphicon-remove"></span></button>';
}
if (in_array('supprimer', $droits) && !$this->valide) { # TODO
$html .= ' <button type="button" class="btn btn-danger"><span class="glyphicon glyphicon glyphicon-trash"></span></button>';
}
$html .= '</h3>';
# Description
$html .= '<div class="panel panel-default">';
$html .= '<div class="panel-heading">';
$html .= '<h4 class="panel-title">Description';
if (in_array('modifier', $droits)) {
$html .= ' <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></button>';
}
$html .= '</h4>';
$html .= '</div>';
$html .= '<div class="panel-body">';
$html .= '<p>';
$html .= nl2br(htmlspecialchars($this->description));
$html .= '</p>';
// $html .= '<hr/>';
$html .= '<p>';
$html .= 'Durée : '.$this->duree.' minutes <br/>';
if ($this->valide) {
$html .= 'Date : '.date('c', $this->valide).'<br/>';
}
$html .= '</p>';
if ($this->annule) {
$html .= '<p class="alert alert-danger" role="alert">Annulé</p>';
}
$html .= '</div>';
$html .= '</div>';
# Dates
if (!$this->valide && !$this->annule) {
$html .= '<div class="panel panel-default">';
$html .= '<div class="panel-heading">';
$html .= '<h4 class="panel-title">Dates possibles';
if (in_array('proposer', $droits)) {
$html .= '<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span></button>';
}
$html .= '</h4>';
$html .= '</div>';
$html .= '<div class="panel-body">';
$html .= '<ul class="list-group">';
foreach ($this->dates as $dateIndex => $date) {
$html .= '<li class="list-group-item">'.date('c', $date).' (6 <span class="glyphicon glyphicon-user"></span>)</li>';
}
$html .= '</ul>';
if (in_array('valider', $droits) && !$this->valide) {
$html .= '<p><button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Valider la date</button></p>';
}
$html .= '</div>';
$html .= '</div>';
}
$html .= '</li>';
return $html;
}
}
?>
<h1>Évènements</h1>
<h2>Plannifiés <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span></button></h2>
<ul class="list-group">
<?
$test1 = new Evenement;
$test1->dates[] = time();
$test1->valide = time();
echo $test1->html()
?>
<?
$test2 = new Evenement;
$test2->dates[] = time();
$test2->valide = time();
$test2->annule = true;
echo $test2->html()
?>
</ul>
<h2>À plannifier <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span></button></h2>
<ul class="list-group">
<?
$test3 = new Evenement;
$test3->dates[] = time();
echo $test3->html()
?>
<?
$test4 = new Evenement;
$test4->dates[] = time();
$test4->annule = true;
echo $test4->html()
?>
</ul>
<h2>Évènements passés</h2>
<ul class="list-group">
</ul>