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
|
|
|
|
25
|
|
|
$dialog=$this->jquery->bootstrap()->htmlModal("modal","Ajouter un nouveau projet","test"); |
26
|
|
|
$buttonFrm=$this->jquery->bootstrap()->htmlButton("btFrm","Nouveau"); |
27
|
|
|
$dialog->addOkayButton("Ajouter"); |
28
|
|
|
$this->jquery->postFormOnClick("#modal-Ajouter", "Projets/update", "frmAjout", null, array("jsCallback" => $this->jquery->getDeferred("Projets/index", ".content)"))); |
29
|
|
|
$dialog->addCancelButton(); |
30
|
|
|
$clients = User::find(); |
31
|
|
|
$dialog->renderContent($this->view,"projets","frm",array("clients"=>$clients)); |
32
|
|
|
|
33
|
|
|
$buttonFrm->onClick($dialog->jsShow()); |
34
|
|
|
|
35
|
|
|
$this->jquery->compile($this->view); |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function updateAction($id = null){ |
41
|
|
|
parent::updateAction(); |
42
|
|
|
|
43
|
|
|
//Retrouve l'id du dernier projet créer (En theorie celui qui viens d'être créé) |
44
|
|
|
$projet = Projet::findFirst(array( |
45
|
|
|
"order" => "id DESC" |
46
|
|
|
)); |
47
|
|
|
$idproj = $projet->getId(); |
48
|
|
|
$this->response->redirect("Projets/read/$idproj"); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function readAction($id = null) |
52
|
|
|
{ |
53
|
|
|
$projet = Projet::findFirst($id); |
54
|
|
|
$usecases = Usecase::find("idProjet = $id"); |
55
|
|
|
$messages = Message::find("idProjet = $id"); |
56
|
|
|
$colorTexte = "black"; |
57
|
|
|
|
58
|
|
|
$color = $projet->getDominantColor(); |
59
|
|
|
//Si jamais la couleur retournée est noire, alors change sa couleur en gris clair |
60
|
|
|
if ($color["r"] == 0 && $color["g"] == 0 && $color["b"] == 0) { |
61
|
|
|
$color["r"] = 240; |
62
|
|
|
$color["g"] = 240; |
63
|
|
|
$color["b"] = 240; |
64
|
|
|
//Sinon si la couleur est trop sombre change l'écriture en blanc pour qu'elle sois visible |
65
|
|
|
} elseif ($color["r"] < 120 || $color["g"] < 120 || $color["b"] < 120) { |
66
|
|
|
$colorTexte = "white"; |
67
|
|
|
$color["r"] += 70; |
68
|
|
|
$color["g"] += 70; |
69
|
|
|
$color["b"] += 70; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$avancementReel = $this->avancementReel($usecases); |
73
|
|
|
|
74
|
|
|
//Passage des différentes variables |
75
|
|
|
$this->view->setVar("colorTexte", $colorTexte); |
76
|
|
|
$this->view->setVar("color", $color); |
77
|
|
|
$this->view->setVar("projet", $projet); |
78
|
|
|
$this->view->setVar("messages", $messages); |
79
|
|
|
$this->view->setVar("usecases", $usecases); |
80
|
|
|
$this->view->setVar("avancement", $avancementReel); |
81
|
|
|
|
82
|
|
|
//Création de la progressbar |
83
|
|
|
$progress = $this->jquery->bootstrap()->htmlProgressbar("progress", "info", $avancementReel); |
84
|
|
|
$progress->showcaption(true); |
85
|
|
|
$this->jquery->get("Projets/resume/$id", "#contentProjet"); |
86
|
|
|
//Creation des évenements onClick et des éléments sur le menu |
87
|
|
|
$this->jquery->getOnClick("#menu1", "Projets/resume/$id", "#contentProjet"); |
88
|
|
|
$this->jquery->getOnClick("#menu2", "Projets/contributors/$id", "#contentProjet"); |
89
|
|
|
$this->jquery->getOnClick("#menu3", "Projets/usecases/$id", "#contentProjet"); |
90
|
|
|
$this->jquery->getOnClick("#menu5", "Projets/messages/$id", "#contentProjet"); |
91
|
|
|
|
92
|
|
|
//Compilation de Jquery dans la vue |
93
|
|
|
$this->jquery->compile($this->view); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function messagesAction($id = null) |
97
|
|
|
{ |
98
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
99
|
|
|
$messages = Message::find("idProjet = $id"); |
100
|
|
|
$this->jquery->postFormOnClick("#submitMsg", "Messages/update", "newMsgForm", null, array("jsCallback" => $this->jquery->getDeferred("Projets/messages/$id", "#contentProjet"))); |
101
|
|
|
$this->jquery->compile($this->view); |
102
|
|
|
|
103
|
|
|
$this->view->setVar("msg", $messages); |
104
|
|
|
$this->view->setVar("idProj", $id); |
105
|
|
|
|
106
|
|
|
$this->view->render("projets", "messages"); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function resumeAction($id = null) |
110
|
|
|
{ |
111
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
112
|
|
|
$projet = Projet::findFirst($id); |
113
|
|
|
$usecases = Usecase::find("idProjet = $id"); |
114
|
|
|
$messages = Message::find("idProjet = $id"); |
115
|
|
|
|
116
|
|
|
$this->view->setVar("projet", $projet); |
117
|
|
|
$this->view->setVar("messages", $messages); |
118
|
|
|
$this->view->setVar("usecases", $usecases); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function usecasesAction($id = null) |
122
|
|
|
{ |
123
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
124
|
|
|
$taches = Tache::find(); |
125
|
|
|
$usecases = Usecase::find(array( |
126
|
|
|
"idProjet = '$id'", |
127
|
|
|
"order" => "poids DESC" |
128
|
|
|
)); |
129
|
|
|
|
130
|
|
|
$this->view->setVar("usecases", $usecases); |
131
|
|
|
$this->view->setVar("taches", $taches); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function contributorsAction($id = null) |
135
|
|
|
{ |
136
|
|
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
137
|
|
|
$contributor = []; |
138
|
|
|
|
139
|
|
|
$usecases = Usecase::find("idProjet = $id"); |
140
|
|
|
|
141
|
|
|
foreach ($usecases as $uc) { |
142
|
|
|
$contributor[] = $uc->getUser(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
$contributor = array_unique($contributor, SORT_REGULAR); |
146
|
|
|
|
147
|
|
|
$this->view->setVar("contributors", $contributor); |
148
|
|
|
$this->view->setVar("usecases", $usecases); |
149
|
|
|
|
150
|
|
|
|
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
//Calcule le taux d'avancement total d'un projet |
154
|
|
|
public function avancementReel($usecases) |
155
|
|
|
{ |
156
|
|
|
//Calcul le taux de finition du projet en fonction du nombre d'usecases total et du taux d'avancement sur chaque usecases. |
157
|
|
|
$countUsecases = count($usecases); |
158
|
|
|
$totalAvancementFini = $countUsecases * 100; |
159
|
|
|
$totalAvancementReel = 0; |
160
|
|
|
|
161
|
|
|
foreach ($usecases as $u) { |
162
|
|
|
$totalAvancementReel = $totalAvancementReel + $u->getAvancement(); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
$avancementReel = ($totalAvancementReel / $totalAvancementFini) * 100; |
166
|
|
|
return number_format($avancementReel, 1); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
} |
170
|
|
|
|
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.