|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Projet extends \Phalcon\Mvc\Model |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* |
|
8
|
|
|
* @var integer |
|
9
|
|
|
*/ |
|
10
|
|
|
protected $id; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $nom; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $description; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $dateLancement; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $dateFinPrevue; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $image; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* |
|
44
|
|
|
* @var integer |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $idClient; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Method to set the value of field id |
|
50
|
|
|
* |
|
51
|
|
|
* @param integer $id |
|
52
|
|
|
* @return $this |
|
53
|
|
|
*/ |
|
54
|
|
|
public function setId($id) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->id = $id; |
|
57
|
|
|
|
|
58
|
|
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Method to set the value of field nom |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $nom |
|
65
|
|
|
* @return $this |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setNom($nom) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->nom = $nom; |
|
70
|
|
|
|
|
71
|
|
|
return $this; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Method to set the value of field description |
|
76
|
|
|
* |
|
77
|
|
|
* @param string $description |
|
78
|
|
|
* @return $this |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setDescription($description) |
|
81
|
|
|
{ |
|
82
|
|
|
$this->description = $description; |
|
83
|
|
|
|
|
84
|
|
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Method to set the value of field dateLancement |
|
89
|
|
|
* |
|
90
|
|
|
* @param string $dateLancement |
|
91
|
|
|
* @return $this |
|
92
|
|
|
*/ |
|
93
|
|
|
public function setDateLancement($dateLancement) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->dateLancement = $dateLancement; |
|
96
|
|
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Method to set the value of field dateFinPrevue |
|
102
|
|
|
* |
|
103
|
|
|
* @param string $dateFinPrevue |
|
104
|
|
|
* @return $this |
|
105
|
|
|
*/ |
|
106
|
|
|
public function setDateFinPrevue($dateFinPrevue) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->dateFinPrevue = $dateFinPrevue; |
|
109
|
|
|
|
|
110
|
|
|
return $this; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Method to set the value of field image |
|
115
|
|
|
* |
|
116
|
|
|
* @param string $image |
|
117
|
|
|
* @return $this |
|
118
|
|
|
*/ |
|
119
|
|
|
public function setImage($image) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->image = $image; |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Method to set the value of field idClient |
|
128
|
|
|
* |
|
129
|
|
|
* @param integer $idClient |
|
130
|
|
|
* @return $this |
|
131
|
|
|
*/ |
|
132
|
|
|
public function setIdClient($idClient) |
|
133
|
|
|
{ |
|
134
|
|
|
$this->idClient = $idClient; |
|
135
|
|
|
|
|
136
|
|
|
return $this; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Returns the value of field id |
|
141
|
|
|
* |
|
142
|
|
|
* @return integer |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getId() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->id; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Returns the value of field nom |
|
151
|
|
|
* |
|
152
|
|
|
* @return string |
|
153
|
|
|
*/ |
|
154
|
|
|
public function getNom() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->nom; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Returns the value of field description |
|
161
|
|
|
* |
|
162
|
|
|
* @return string |
|
163
|
|
|
*/ |
|
164
|
|
|
public function getDescription() |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->description; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* Returns the value of field dateLancement |
|
171
|
|
|
* |
|
172
|
|
|
* @return string |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getDateLancement() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->dateLancement; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* Returns the value of field dateFinPrevue |
|
181
|
|
|
* |
|
182
|
|
|
* @return string |
|
183
|
|
|
*/ |
|
184
|
|
|
public function getDateFinPrevue() |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->dateFinPrevue; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Returns the value of field image |
|
191
|
|
|
* |
|
192
|
|
|
* @return string |
|
193
|
|
|
*/ |
|
194
|
|
|
public function getImage() |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->image; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* Returns the value of field idClient |
|
201
|
|
|
* |
|
202
|
|
|
* @return integer |
|
203
|
|
|
*/ |
|
204
|
|
|
public function getIdClient() |
|
205
|
|
|
{ |
|
206
|
|
|
return $this->idClient; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* Initialize method for model. |
|
211
|
|
|
*/ |
|
212
|
|
|
public function initialize() |
|
213
|
|
|
{ |
|
214
|
|
|
$this->hasMany('id', 'Message', 'idProjet', array('alias' => 'Messages')); |
|
215
|
|
|
$this->hasMany('id', 'Usecase', 'idProjet', array('alias' => 'Usecase')); |
|
216
|
|
|
$this->belongsTo('idClient', 'User', 'id', array('alias' => 'Client')); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Returns table name mapped in the model. |
|
221
|
|
|
* |
|
222
|
|
|
* @return string |
|
223
|
|
|
*/ |
|
224
|
|
|
public function getSource() |
|
225
|
|
|
{ |
|
226
|
|
|
return 'projet'; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* Allows to query a set of records that match the specified conditions |
|
231
|
|
|
* |
|
232
|
|
|
* @param mixed $parameters |
|
233
|
|
|
* @return Projet[] |
|
234
|
|
|
*/ |
|
235
|
|
|
public static function find($parameters = null) |
|
236
|
|
|
{ |
|
237
|
|
|
return parent::find($parameters); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* Allows to query the first record that match the specified conditions |
|
242
|
|
|
* |
|
243
|
|
|
* @param mixed $parameters |
|
244
|
|
|
* @return Projet |
|
245
|
|
|
*/ |
|
246
|
|
|
public static function findFirst($parameters = null) |
|
247
|
|
|
{ |
|
248
|
|
|
return parent::findFirst($parameters); |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
public function toString() |
|
252
|
|
|
{ |
|
253
|
|
|
return $this->nom; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
//Return a string containing the principal content of the model |
|
257
|
|
|
public function getPrincipal() |
|
258
|
|
|
{ |
|
259
|
|
|
return "Client : " . $this->client->toString() . " <br/> Desciption : " . $this->description; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
//R�cup�re la couleur dominante de l'image du profil |
|
263
|
|
|
public function getDominantColor() |
|
264
|
|
|
{ |
|
265
|
|
|
$rTotal = 0; |
|
266
|
|
|
$gTotal = 0; |
|
267
|
|
|
$bTotal = 0; |
|
268
|
|
|
$total = 0; |
|
269
|
|
|
|
|
270
|
|
|
|
|
271
|
|
|
$i = imagecreatefrompng($this->getImage()); |
|
272
|
|
|
|
|
273
|
|
|
for ($x = 0; $x < imagesx($i); $x++) { |
|
274
|
|
|
for ($y = 0; $y < imagesy($i); $y++) { |
|
275
|
|
|
|
|
276
|
|
|
$rgb = imagecolorat($i, $x, $y); |
|
277
|
|
|
$r = ($rgb >> 16) & 0xFF; |
|
278
|
|
|
$g = ($rgb >> 8) & 0xFF; |
|
279
|
|
|
$b = $rgb & 0xFF; |
|
280
|
|
|
|
|
281
|
|
|
$rTotal += $r; |
|
282
|
|
|
$gTotal += $g; |
|
283
|
|
|
$bTotal += $b; |
|
284
|
|
|
$total++; |
|
285
|
|
|
|
|
286
|
|
|
} |
|
287
|
|
|
} |
|
288
|
|
|
$rTotal = round($rTotal / $total); |
|
289
|
|
|
$gTotal = round($gTotal / $total); |
|
290
|
|
|
$bTotal = round($bTotal / $total); |
|
291
|
|
|
|
|
292
|
|
|
$tabColor = ["r" => $rTotal, "g" => $gTotal, "b" => $bTotal]; |
|
293
|
|
|
return $tabColor; |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
//Converti l'image de profil afin de pouvoir l'analyser. |
|
297
|
|
|
|
|
298
|
|
|
public function imageCreateFromAny() |
|
299
|
|
|
{ |
|
300
|
|
|
$img = $this->getImage(); |
|
301
|
|
|
$type = getImageSize($img); // [] if you don't have exif you could use getImageSize() |
|
302
|
|
|
$allowedTypes = array( |
|
303
|
|
|
1, // [] gif |
|
304
|
|
|
2, // [] jpg |
|
305
|
|
|
3, // [] png |
|
306
|
|
|
6 // [] bmp |
|
307
|
|
|
); |
|
308
|
|
|
if (!in_array($type, $allowedTypes)) { |
|
309
|
|
|
return false; |
|
310
|
|
|
} |
|
311
|
|
|
switch ($type) { |
|
312
|
|
|
case 1 : |
|
|
|
|
|
|
313
|
|
|
$im = imageCreateFromGif($img); |
|
314
|
|
|
break; |
|
315
|
|
|
case 2 : |
|
|
|
|
|
|
316
|
|
|
$im = imageCreateFromJpeg($img); |
|
317
|
|
|
break; |
|
318
|
|
|
case 3 : |
|
|
|
|
|
|
319
|
|
|
$im = imageCreateFromPng($img); |
|
320
|
|
|
break; |
|
321
|
|
|
case 6 : |
|
|
|
|
|
|
322
|
|
|
$im = imageCreateFromBmp($img); |
|
323
|
|
|
break; |
|
324
|
|
|
} |
|
325
|
|
|
return $im; |
|
|
|
|
|
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
} |
|
329
|
|
|
|
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.