1
|
|
|
<?php |
2
|
|
|
use Phalcon\Mvc\View; |
3
|
|
|
use Phalcon\Mvc\Url; |
4
|
|
|
|
5
|
|
|
class ProjetsController extends \ControllerBase |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
protected $model; |
9
|
|
|
protected $title; |
10
|
|
|
protected $controller; |
11
|
|
|
|
12
|
|
|
public function initialize() |
13
|
|
|
{ |
14
|
|
|
$this->model = "Projet"; |
15
|
|
|
$this->title = "Projets"; |
16
|
|
|
$this->controller = "Projets"; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function indexAction($message = null) |
20
|
|
|
{ |
21
|
|
|
$projets = Projet::find(); |
22
|
|
|
$this->view->setVar("projets", $projets); |
23
|
|
|
|
24
|
|
|
$dialog = $this->jquery->bootstrap()->htmlModal("modal", "Ajouter un nouveau projet", "test"); |
25
|
|
|
$buttonFrm = $this->jquery->bootstrap()->htmlButton("btFrm", "Nouveau"); |
26
|
|
|
$dialog->addCancelButton(); |
27
|
|
|
$clients = User::find(); |
28
|
|
|
$dialog->renderContent($this->view, "projets", "frm", array("clients" => $clients)); |
29
|
|
|
|
30
|
|
|
$buttonFrm->onClick($dialog->jsShow()); |
31
|
|
|
|
32
|
|
|
$this->jquery->compile($this->view); |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function updateAction($id = null) |
38
|
|
|
{ |
39
|
|
|
if ($id = null) { |
|
|
|
|
40
|
|
|
//Retrouve l'id du dernier projet créer (En theorie celui qui vient d'être créé) |
41
|
|
|
$projet = Projet::findFirst(array( |
42
|
|
|
"order" => "id DESC" |
43
|
|
|
)); |
44
|
|
|
$idproj = $projet->getId(); |
45
|
|
|
$this->response->redirect("Projets/read/$idproj"); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function soloUpdateAction() |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
//Créer la fonction variable 'set' en fonction du name en POST |
52
|
|
|
$func = 'set' . ucfirst($_POST['name']); |
53
|
|
|
$projet = Projet::findFirst($_POST['pk']); |
54
|
|
|
$projet->$func($_POST['value']); |
55
|
|
|
$projet->save(); |
56
|
|
|
|
57
|
|
|
/*$value = $_POST['value']; |
|
|
|
|
58
|
|
|
$pk = $_POST['pk']; |
59
|
|
|
$name = $_POST['name']; |
60
|
|
|
$this->modelsManager->createQuery("UPDATE Projet SET $name = '$value' WHERE id = $pk")->execute();*/ |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function readAction($id = null) |
64
|
|
|
{ |
65
|
|
|
$url = new Url(); |
|
|
|
|
66
|
|
|
$projet = Projet::findFirst($id); |
67
|
|
|
$usecases = Usecase::find("idProjet = $id"); |
68
|
|
|
$messages = Message::find("idProjet = $id"); |
69
|
|
|
$colorTexte = "black"; |
70
|
|
|
|
71
|
|
|
$color = $projet->getDominantColor(); |
72
|
|
|
|
73
|
|
|
//Si jamais la couleur retournée est noire, alors change sa couleur en gris clair |
74
|
|
|
if ($color["r"] == 0 && $color["g"] == 0 && $color["b"] == 0) { |
75
|
|
|
$color["r"] = 240; |
76
|
|
|
$color["g"] = 240; |
77
|
|
|
$color["b"] = 240; |
78
|
|
|
//Sinon si la couleur est trop sombre change l'écriture en blanc pour qu'elle sois visible |
79
|
|
|
} elseif ($color["r"] < 120 || $color["g"] < 120 || $color["b"] < 120) { |
80
|
|
|
$colorTexte = "white"; |
81
|
|
|
$color["r"] += 70; |
82
|
|
|
$color["g"] += 70; |
83
|
|
|
$color["b"] += 70; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$avancementReel = $this->avancementReel($usecases); |
87
|
|
|
|
88
|
|
|
//Passage des différentes variables |
89
|
|
|
$this->view->setVar("colorTexte", $colorTexte); |
90
|
|
|
$this->view->setVar("color", $color); |
91
|
|
|
$this->view->setVar("projet", $projet); |
92
|
|
|
$this->view->setVar("messages", $messages); |
93
|
|
|
$this->view->setVar("usecases", $usecases); |
94
|
|
|
$this->view->setVar("avancement", $avancementReel); |
95
|
|
|
|
96
|
|
|
//Création de la progressbar |
97
|
|
|
$progress = $this->jquery->bootstrap()->htmlProgressbar("progress", "info", $avancementReel); |
98
|
|
|
$progress->showcaption(true); |
99
|
|
|
$this->jquery->get("Projets/resume/$id", "#contentProjet"); |
100
|
|
|
//Creation des évenements onClick et des éléments sur le menu |
101
|
|
|
$this->jquery->getOnClick("#menu1", "Projets/resume/$id", "#contentProjet"); |
102
|
|
|
$this->jquery->getOnClick("#menu2", "Projets/contributors/$id", "#contentProjet"); |
103
|
|
|
$this->jquery->getOnClick("#menu3", "Projets/usecases/$id", "#contentProjet"); |
104
|
|
|
$this->jquery->getOnClick("#menu5", "Projets/messages/$id", "#contentProjet"); |
105
|
|
|
|
106
|
|
|
$this->jquery->exec("$('#nom').editable()", true); |
107
|
|
|
|
108
|
|
|
//Compilation de Jquery dans la vue |
109
|
|
|
$this->jquery->compile($this->view); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function messagesAction($id = null) |
113
|
|
|
{ |
114
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
115
|
|
|
$messages = Message::find("idProjet = $id"); |
116
|
|
|
$this->jquery->postFormOnClick("#submitMsg", "Messages/update", "newMsgForm", null, array("jsCallback" => $this->jquery->getDeferred("Projets/messages/$id", "#contentProjet"))); |
117
|
|
|
$this->jquery->compile($this->view); |
118
|
|
|
|
119
|
|
|
$this->view->setVar("msg", $messages); |
120
|
|
|
$this->view->setVar("idProj", $id); |
121
|
|
|
|
122
|
|
|
$this->view->render("projets", "messages"); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function resumeAction($id = null) |
126
|
|
|
{ |
127
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
128
|
|
|
$projet = Projet::findFirst($id); |
129
|
|
|
$usecases = Usecase::find("idProjet = $id"); |
130
|
|
|
$messages = Message::find("idProjet = $id"); |
131
|
|
|
|
132
|
|
|
$this->view->setVar("projet", $projet); |
133
|
|
|
$this->view->setVar("messages", $messages); |
134
|
|
|
$this->view->setVar("usecases", $usecases); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function usecasesAction($id = null) |
138
|
|
|
{ |
139
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
140
|
|
|
$taches = Tache::find(); |
141
|
|
|
$usecases = Usecase::find(array( |
142
|
|
|
"idProjet = '$id'", |
143
|
|
|
"order" => "poids DESC" |
144
|
|
|
)); |
145
|
|
|
|
146
|
|
|
$this->view->setVar("usecases", $usecases); |
147
|
|
|
$this->view->setVar("taches", $taches); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function contributorsAction($id = null) |
151
|
|
|
{ |
152
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
153
|
|
|
$contributor = []; |
154
|
|
|
|
155
|
|
|
$usecases = Usecase::find("idProjet = $id"); |
156
|
|
|
|
157
|
|
|
foreach ($usecases as $uc) { |
158
|
|
|
$contributor[] = $uc->getUser(); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
$contributor = array_unique($contributor, SORT_REGULAR); |
162
|
|
|
|
163
|
|
|
$this->view->setVar("contributors", $contributor); |
164
|
|
|
$this->view->setVar("usecases", $usecases); |
165
|
|
|
|
166
|
|
|
|
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
//Calcule le taux d'avancement total d'un projet |
170
|
|
|
public function avancementReel($usecases) |
171
|
|
|
{ |
172
|
|
|
//Calcul le taux de finition du projet en fonction du nombre d'usecases total et du taux d'avancement sur chaque usecases. |
173
|
|
|
$countUsecases = count($usecases); |
174
|
|
|
$totalAvancementFini = $countUsecases * 100; |
175
|
|
|
$totalAvancementReel = 0; |
176
|
|
|
|
177
|
|
|
foreach ($usecases as $u) { |
178
|
|
|
$totalAvancementReel = $totalAvancementReel + $u->getAvancement(); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
$avancementReel = ($totalAvancementReel / $totalAvancementFini) * 100; |
182
|
|
|
return number_format($avancementReel, 1); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
} |
186
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.