Commit a998c9079a9c83e5ce865ecd68d6e6897bedd6f8
1 parent
64904ba2
Exists in
master
and in
3 other branches
Refactorisation de code dans AppController et MaterielController pour
(grandement) simplifier les vues => (voir par exemple à quel point la vue Materiels/view est maintenant bien plus lisible)
Showing
3 changed files
with
215 additions
and
35 deletions
Show diff stats
src/Controller/AppController.php
... | ... | @@ -32,6 +32,21 @@ use PhpParser\Node\Expr\Include_; |
32 | 32 | class AppController extends Controller { |
33 | 33 | |
34 | 34 | public $confLabinvent; |
35 | + | |
36 | + const PROFILE_USER = 1; | |
37 | + const PROFILE_RESPONSABLE = 2; | |
38 | + const PROFILE_ADMIN = 3; | |
39 | + const PROFILE_ADMINPLUS = 4; | |
40 | + const PROFILE_SUPERADMIN = 5; | |
41 | + | |
42 | + private $allProfiles = [ | |
43 | + 'Utilisateur' => self::PROFILE_USER, | |
44 | + 'Responsable' => self::PROFILE_RESPONSABLE, | |
45 | + 'Administration' => self::PROFILE_ADMIN, | |
46 | + 'Administration Plus' => self::PROFILE_ADMINPLUS, | |
47 | + 'Super Administrateur' => self::PROFILE_SUPERADMIN | |
48 | + ]; | |
49 | + | |
35 | 50 | |
36 | 51 | /** |
37 | 52 | * Initialization hook method. |
... | ... | @@ -205,7 +220,15 @@ class AppController extends Controller { |
205 | 220 | * @return void |
206 | 221 | */ |
207 | 222 | public function beforeRender(Event $event) { |
208 | - if (! array_key_exists('_serialize', $this->viewVars) && in_array($this->response->type(), [ | |
223 | + | |
224 | + $this->set('PROFILE_USER', self::PROFILE_USER); | |
225 | + $this->set('PROFILE_ADMIN', self::PROFILE_ADMIN); | |
226 | + $this->set('PROFILE_RESPONSABLE', self::PROFILE_RESPONSABLE); | |
227 | + $this->set('PROFILE_ADMINPLUS', self::PROFILE_ADMINPLUS); | |
228 | + $this->set('PROFILE_SUPERADMIN', self::PROFILE_SUPERADMIN); | |
229 | + $this->set('allProfiles', $this->allProfiles); | |
230 | + | |
231 | + if (! array_key_exists('_serialize', $this->viewVars) && in_array($this->response->type(), [ | |
209 | 232 | 'application/json', |
210 | 233 | 'application/xml' |
211 | 234 | ])) { |
... | ... | @@ -227,6 +250,23 @@ class AppController extends Controller { |
227 | 250 | if ($role == null) |
228 | 251 | $role = 'Utilisateur'; |
229 | 252 | $this->set('role', $role); |
253 | + | |
254 | + $profile = $this->allProfiles["$role"]; | |
255 | + $this->set('profile', $profile); | |
256 | + | |
257 | + $USER_IS_UTILISATEUR = ($profile == self::PROFILE_USER); | |
258 | + $USER_IS_RESPONSABLE = ($profile == self::PROFILE_RESPONSABLE); | |
259 | + $USER_IS_ADMIN = ($profile == self::PROFILE_ADMIN); | |
260 | + $USER_IS_ADMINPLUS = ($profile == self::PROFILE_ADMINPLUS); | |
261 | + $USER_IS_SUPERADMIN = ($profile == self::PROFILE_SUPERADMIN); | |
262 | + $USER_IS_ADMIN_OR_MORE = ($profile >= self::PROFILE_ADMIN); | |
263 | + | |
264 | + $this->set('USER_IS_UTILISATEUR', $USER_IS_UTILISATEUR); | |
265 | + $this->set('USER_IS_RESPONSABLE', $USER_IS_RESPONSABLE); | |
266 | + $this->set('USER_IS_ADMIN', $USER_IS_ADMIN); | |
267 | + $this->set('USER_IS_ADMINPLUS', $USER_IS_ADMINPLUS); | |
268 | + $this->set('USER_IS_SUPERADMIN', $USER_IS_SUPERADMIN); | |
269 | + $this->set('USER_IS_ADMIN_OR_MORE', $USER_IS_ADMIN_OR_MORE); | |
230 | 270 | |
231 | 271 | $this->set('userConnected', $user); |
232 | 272 | ... | ... |
src/Controller/MaterielsController.php
... | ... | @@ -12,6 +12,18 @@ use Cake\Mailer\Email; |
12 | 12 | */ |
13 | 13 | class MaterielsController extends AppController { |
14 | 14 | |
15 | + const CREATED = 1; | |
16 | + const VALIDATED = 2; | |
17 | + const TOBEARCHIVED = 3; | |
18 | + const ARCHIVED = 4; | |
19 | + | |
20 | + private $allStatus = [ | |
21 | + 'CREATED' => self::CREATED, | |
22 | + 'VALIDATED' => self::VALIDATED, | |
23 | + 'TOBEARCHIVED' => self::TOBEARCHIVED, | |
24 | + 'ARCHIVED' => self::ARCHIVED, | |
25 | + ]; | |
26 | + | |
15 | 27 | private $NOTARCHIVED = [ |
16 | 28 | 'CREATED', |
17 | 29 | 'VALIDATED', |
... | ... | @@ -19,7 +31,22 @@ class MaterielsController extends AppController { |
19 | 31 | ]; |
20 | 32 | |
21 | 33 | public $role; |
22 | - | |
34 | + | |
35 | + /* | |
36 | + * EP added 13/6/17 | |
37 | + * Set some useful global variables for all (Materiel) views | |
38 | + * Overload beforeRender() | |
39 | + */ | |
40 | + public function beforeRender(\Cake\Event\Event $event){ | |
41 | + parent::beforeRender($event); | |
42 | + | |
43 | + //$this->layout = 'default'; | |
44 | + $this->set('CREATED', self::CREATED); | |
45 | + $this->set('VALIDATED', self::VALIDATED); | |
46 | + $this->set('TOBEARCHIVED', self::TOBEARCHIVED); | |
47 | + $this->set('ARCHIVED', self::ARCHIVED); | |
48 | + } | |
49 | + | |
23 | 50 | /** |
24 | 51 | * |
25 | 52 | * @param $user Give |
... | ... | @@ -327,6 +354,7 @@ class MaterielsController extends AppController { |
327 | 354 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
328 | 355 | */ |
329 | 356 | public function view($id = null) { |
357 | + | |
330 | 358 | $materiel = $this->Materiels->get($id, [ |
331 | 359 | 'contain' => [ |
332 | 360 | 'SurCategories', |
... | ... | @@ -342,7 +370,18 @@ class MaterielsController extends AppController { |
342 | 370 | 'Fournisseurs' |
343 | 371 | ] |
344 | 372 | ]); |
345 | - | |
373 | + | |
374 | + $IS_CREATED = ( $materiel->status == 'CREATED' ); | |
375 | + $IS_VALIDATED = ( $materiel->status == 'VALIDATED' ); | |
376 | + $IS_TOBEARCHIVED = ( $materiel->status == 'TOBEARCHIVED' ); | |
377 | + $IS_ARCHIVED = ( $materiel->status == 'ARCHIVED' ); | |
378 | + $status = $this->allStatus[$materiel->status]; | |
379 | + $this->set('IS_CREATED', $IS_CREATED); | |
380 | + $this->set('IS_VALIDATED', $IS_VALIDATED); | |
381 | + $this->set('IS_TOBEARCHIVED', $IS_TOBEARCHIVED); | |
382 | + $this->set('IS_ARCHIVED', $IS_ARCHIVED); | |
383 | + $this->set('status', $status); | |
384 | + | |
346 | 385 | $sites = TableRegistry::get('Sites'); |
347 | 386 | $typeSuivis = TableRegistry::get('TypeSuivis'); |
348 | 387 | $typeDocuments = TableRegistry::get('TypeDocuments'); |
... | ... | @@ -357,6 +396,7 @@ class MaterielsController extends AppController { |
357 | 396 | $this->set('typeSuivis', $typeSuivis); |
358 | 397 | $this->set('typeDocuments', $typeDocuments); |
359 | 398 | $this->set('fournisseurs', $fournisseurs); |
399 | + | |
360 | 400 | $this->set('materiel', $materiel); |
361 | 401 | $this->set('_serialize', [ |
362 | 402 | 'materiel' | ... | ... |
src/Template/Materiels/view.ctp
... | ... | @@ -2,13 +2,80 @@ |
2 | 2 | use Cake\I18n\Time; |
3 | 3 | use Cake\I18n\Date; |
4 | 4 | use Cake\ORM\TableRegistry; |
5 | + | |
6 | +// EP | |
7 | +// Set some useful global variables for this view | |
8 | + | |
9 | +// 1) Materiel settings | |
10 | +/* | |
11 | +const CREATED = 1; | |
12 | +const VALIDATED = 2; | |
13 | +const TOBEARCHIVED = 3; | |
14 | +const ARCHIVED = 4; | |
15 | +$allStatus = [ | |
16 | + 'CREATED' => CREATED, | |
17 | + 'VALIDATED' => VALIDATED, | |
18 | + 'TOBEARCHIVED' => TOBEARCHIVED, | |
19 | + 'ARCHIVED' => ARCHIVED, | |
20 | +]; | |
21 | +$IS_CREATED = ( $materiel->status == 'CREATED' ); | |
22 | +$IS_VALIDATED = ( $materiel->status == 'VALIDATED' ); | |
23 | +$IS_TOBEARCHIVED = ( $materiel->status == 'TOBEARCHIVED' ); | |
24 | +$IS_ARCHIVED = ( $materiel->status == 'ARCHIVED' ); | |
25 | +$status = $allStatus[$materiel->status]; | |
26 | + | |
27 | +// 2) User settings | |
28 | +const PROFILE_USER = 1; | |
29 | +const PROFILE_RESPONSABLE = 2; | |
30 | +const PROFILE_ADMIN = 3; | |
31 | +const PROFILE_ADMINPLUS = 4; | |
32 | +const PROFILE_SUPERADMIN = 5; | |
33 | +$allProfiles = [ | |
34 | + 'Utilisateur' => PROFILE_USER, | |
35 | + 'Responsable' => PROFILE_RESPONSABLE, | |
36 | + 'Administration' => PROFILE_ADMIN, | |
37 | + 'Administration Plus' => PROFILE_ADMINPLUS, | |
38 | + 'Super Administrateur' => PROFILE_SUPERADMIN | |
39 | +]; | |
40 | + | |
41 | +$profile = $allProfiles["$role"]; | |
42 | +echo $profile; | |
43 | + | |
44 | +$USER_IS_UTILISATEUR = ($profile == $PROFILE_USER); | |
45 | +$USER_IS_RESPONSABLE = ($profile == $PROFILE_RESPONSABLE); | |
46 | +$USER_IS_ADMIN = ($profile == $PROFILE_ADMIN); | |
47 | +$USER_IS_ADMINPLUS = ($profile == $PROFILE_ADMINPLUS); | |
48 | +$USER_IS_SUPERADMIN = ($profile == $PROFILE_SUPERADMIN); | |
49 | + | |
50 | +$USER_IS_ADMIN_OR_MORE = $profile >= $PROFILE_ADMIN; | |
51 | +*/ | |
52 | + | |
53 | +$USER_IS_UTILISATEUR_AND_CREATOR_OR_OWNER = $USER_IS_UTILISATEUR && in_array($username, [$materiel->nom_createur, $materiel->nom_responsable]); | |
54 | + | |
55 | +$USER_IS_RESPONSABLE_AND_SAME_GROUP = | |
56 | + $USER_IS_RESPONSABLE | |
57 | + && | |
58 | + ( | |
59 | + ( | |
60 | + isset($userConnected->groupes_metier_id) | |
61 | + && $userConnected->groupes_metier_id != $idGmNa | |
62 | + && $materiel->groupes_metier_id == $userConnected->groupes_metier_id | |
63 | + ) | |
64 | + || | |
65 | + ( | |
66 | + isset($userConnected->groupe_thematique_id) | |
67 | + && $userConnected->groupe_thematique_id != $idGtNa | |
68 | + && $materiel->groupes_thematique_id == $userConnected->groupe_thematique_id | |
69 | + ) | |
70 | + ); | |
5 | 71 | ?> |
6 | 72 | |
7 | 73 | <div class="materiels view"> |
8 | 74 | |
9 | 75 | <h2> |
10 | 76 | <?php |
11 | - if (h($materiel->status) == 'ARCHIVED') echo '<i class="icon-inbox"></i> '; | |
77 | + //if (h($materiel->status) == 'ARCHIVED') echo '<i class="icon-inbox"></i> '; | |
78 | + if ($IS_ARCHIVED) echo '<i class="icon-inbox"></i> '; | |
12 | 79 | $panne = h($materiel->hors_service) ? ' (HORS SERVICE)' : ''; |
13 | 80 | ?> |
14 | 81 | <?=h($materiel->designation) . $panne?> |
... | ... | @@ -16,8 +83,9 @@ use Cake\ORM\TableRegistry; |
16 | 83 | <span style="font-size: 70%; color: grey;"> |
17 | 84 | <?=h($materiel->numero_laboratoire)?> |
18 | 85 | <?php |
19 | - if (h($materiel->status) == 'ARCHIVED') echo ' (Archivé)'; | |
20 | - ?> | |
86 | + //if (h($materiel->status) == 'ARCHIVED') echo ' (Archivé)'; | |
87 | + if ($IS_ARCHIVED) echo ' (Archivé)'; | |
88 | + ?> | |
21 | 89 | </span> |
22 | 90 | </h2> |
23 | 91 | <br/> |
... | ... | @@ -41,21 +109,26 @@ use Cake\ORM\TableRegistry; |
41 | 109 | </div> |
42 | 110 | <br/> |
43 | 111 | |
112 | + | |
113 | + <!-- BOUTONS --> | |
114 | + | |
44 | 115 | <div id="boutons" class="actions" style="margin-bottom: 20px; width: 100%; float: none; padding: 10px 0;"> |
45 | 116 | |
46 | 117 | <?php |
47 | 118 | // CREATED or VALIDATED |
48 | - if ( in_array($materiel->status, ['CREATED','VALIDATED']) ) { | |
49 | - if ( | |
50 | - in_array($role, ['Administration','Administration Plus','Super Administrateur']) | |
119 | + //if ( in_array($materiel->status, ['CREATED','VALIDATED']) ) { | |
120 | + if ( $IS_CREATED || $IS_VALIDATED ) { | |
121 | + if ( $USER_IS_ADMIN_OR_MORE || $USER_IS_UTILISATEUR_AND_CREATOR_OR_OWNER || $USER_IS_RESPONSABLE_AND_SAME_GROUP ) | |
122 | + /* | |
123 | + //in_array($role, ['Administration','Administration Plus','Super Administrateur']) | |
51 | 124 | || |
52 | 125 | ( |
53 | - $role == 'Utilisateur' | |
54 | - && in_array($username, [$materiel->nom_createur, $materiel->nom_responsable]) | |
126 | + //$role == 'Utilisateur' | |
127 | + //&& in_array($username, [$materiel->nom_createur, $materiel->nom_responsable]) | |
55 | 128 | ) |
56 | 129 | || |
57 | 130 | ( |
58 | - $role == 'Responsable' | |
131 | + $role == 'Responsable' | |
59 | 132 | && ( |
60 | 133 | ( |
61 | 134 | isset($userConnected->groupes_metier_id) |
... | ... | @@ -70,7 +143,7 @@ use Cake\ORM\TableRegistry; |
70 | 143 | ) |
71 | 144 | ) |
72 | 145 | ) |
73 | - ) | |
146 | + */ | |
74 | 147 | echo $this->Html->link( |
75 | 148 | __('<i class="icon-pencil"></i> Editer ce matériel'), |
76 | 149 | [ 'action' => 'edit', $materiel->id ], |
... | ... | @@ -80,7 +153,8 @@ use Cake\ORM\TableRegistry; |
80 | 153 | |
81 | 154 | // TOBEARCHIVED+ |
82 | 155 | else { |
83 | - if (in_array($role, ['Administration Plus','Super Administrateur'])) { | |
156 | + //if (in_array($role, ['Administration Plus','Super Administrateur'])) { | |
157 | + if ($USER_IS_ADMIN_OR_MORE) { | |
84 | 158 | echo $this->Html->link( |
85 | 159 | __('<i class="icon-pencil"></i> Editer ce matériel'), |
86 | 160 | ['action' => 'edit', $materiel->id], |
... | ... | @@ -90,7 +164,8 @@ use Cake\ORM\TableRegistry; |
90 | 164 | } |
91 | 165 | |
92 | 166 | // VALIDATED |
93 | - if ($materiel->status == 'VALIDATED') { | |
167 | + //if ($materiel->status == 'VALIDATED') { | |
168 | + if ($IS_VALIDATED) { | |
94 | 169 | |
95 | 170 | // BOUTON NOUVEAU SUIVI |
96 | 171 | echo $this->Html->link( |
... | ... | @@ -112,6 +187,8 @@ use Cake\ORM\TableRegistry; |
112 | 187 | } |
113 | 188 | |
114 | 189 | // BOUTON "Lier un Doc" |
190 | + if ( $USER_IS_ADMIN_OR_MORE || $USER_IS_UTILISATEUR_AND_CREATOR_OR_OWNER || $USER_IS_RESPONSABLE_AND_SAME_GROUP ) { | |
191 | + /* | |
115 | 192 | if ( |
116 | 193 | in_array($role, ['Administration','Administration Plus','Super Administrateur']) |
117 | 194 | || |
... | ... | @@ -136,6 +213,7 @@ use Cake\ORM\TableRegistry; |
136 | 213 | ) |
137 | 214 | ) |
138 | 215 | ) { |
216 | + */ | |
139 | 217 | echo $this->Html->link('<i class="icon-file"></i> Lier un Doc.', [ |
140 | 218 | 'controller' => 'documents', |
141 | 219 | 'action' => 'add', |
... | ... | @@ -178,10 +256,12 @@ use Cake\ORM\TableRegistry; |
178 | 256 | |
179 | 257 | |
180 | 258 | // Doc admission et sortie (admin+) |
181 | - if (in_array($role, ['Administration','Administration Plus','Super Administrateur'])) { | |
259 | + if ($USER_IS_ADMIN_OR_MORE) { | |
260 | + //if (in_array($role, ['Administration','Administration Plus','Super Administrateur'])) { | |
182 | 261 | |
183 | 262 | // Doc admission (admin only) |
184 | - if (($materiel->status == 'VALIDATED') || ($materiel->status == 'CREATED')) { | |
263 | + if ( $IS_CREATED || $IS_VALIDATED ) { | |
264 | + //if (($materiel->status == 'VALIDATED') || ($materiel->status == 'CREATED')) { | |
185 | 265 | echo $this->Html->link('<i class="icon-file"></i> Doc. admission', [ |
186 | 266 | 'controller' => 'documents', |
187 | 267 | 'action' => 'admission', |
... | ... | @@ -194,7 +274,8 @@ use Cake\ORM\TableRegistry; |
194 | 274 | } |
195 | 275 | |
196 | 276 | // Doc sortie (admin only) |
197 | - else if (($materiel->status == 'ARCHIVED') || ($materiel->status == 'TOBEARCHIVED')) { | |
277 | + else if ( $IS_ARCHIVED || $IS_TOBEARCHIVED ) { | |
278 | + //else if (($materiel->status == 'ARCHIVED') || ($materiel->status == 'TOBEARCHIVED')) { | |
198 | 279 | echo $this->Html->link('<i class="icon-file"></i> Doc. sortie', [ |
199 | 280 | 'controller' => 'documents', |
200 | 281 | 'action' => 'sortie', |
... | ... | @@ -209,6 +290,8 @@ use Cake\ORM\TableRegistry; |
209 | 290 | |
210 | 291 | |
211 | 292 | // BOUTON changement statut |
293 | + if ( $USER_IS_ADMIN_OR_MORE || $USER_IS_RESPONSABLE_AND_SAME_GROUP ) { | |
294 | + /* | |
212 | 295 | if ( |
213 | 296 | in_array($role, ['Administration','Administration Plus','Super Administrateur']) |
214 | 297 | || ( |
... | ... | @@ -228,9 +311,12 @@ use Cake\ORM\TableRegistry; |
228 | 311 | ) |
229 | 312 | ) |
230 | 313 | ) { |
314 | + */ | |
231 | 315 | // 2) Bouton de changement de statut : Valider, Demander archivage, ou Archiver |
232 | - switch ($materiel->status) { | |
233 | - case "CREATED" : | |
316 | + //switch ($materiel->status) { | |
317 | + switch ($status) { | |
318 | + //case "CREATED" : | |
319 | + case $CREATED : | |
234 | 320 | echo $this->Html->link('<i class="icon-ok-sign"></i> Valider', [ |
235 | 321 | 'action' => 'statusValidated', |
236 | 322 | $materiel->id, |
... | ... | @@ -241,7 +327,7 @@ use Cake\ORM\TableRegistry; |
241 | 327 | 'escape' => false |
242 | 328 | ]); |
243 | 329 | break; |
244 | - case "VALIDATED" : | |
330 | + case $VALIDATED : | |
245 | 331 | echo $this->Html->link('<i class="icon-ok-sign"></i> Demander sortie', [ |
246 | 332 | 'action' => 'statusToBeArchived', |
247 | 333 | $materiel->id, |
... | ... | @@ -252,7 +338,7 @@ use Cake\ORM\TableRegistry; |
252 | 338 | 'escape' => false |
253 | 339 | ]); |
254 | 340 | break; |
255 | - case "TOBEARCHIVED" : | |
341 | + case $TOBEARCHIVED : | |
256 | 342 | if ($role != 'Responsable' && $role != 'Super Administrateur') { |
257 | 343 | echo $this->Html->link('<i class="icon-ok-sign"></i> Sortie inventaire', [ |
258 | 344 | 'action' => 'statusArchived', |
... | ... | @@ -430,8 +516,10 @@ use Cake\ORM\TableRegistry; |
430 | 516 | |
431 | 517 | |
432 | 518 | <!-- PARTIE ADMIN --> |
519 | + | |
433 | 520 | <?php |
434 | - if (in_array($role, ['Administration','Administration Plus','Super Administrateur'])) { | |
521 | + if ( $USER_IS_ADMIN_OR_MORE ) { | |
522 | + //if (in_array($role, ['Administration','Administration Plus','Super Administrateur'])) { | |
435 | 523 | echo '<h3 id="t_informations_admin" style="cursor: pointer;">'; |
436 | 524 | echo '<i class="icon-chevron-down" style="font-size: 14px;" id="i_informations_admin"></i>'; |
437 | 525 | echo '<span style="text-decoration: underline;"> Informations administratives</span>'; |
... | ... | @@ -451,6 +539,7 @@ use Cake\ORM\TableRegistry; |
451 | 539 | |
452 | 540 | |
453 | 541 | <!-- SUIVIS --> |
542 | + | |
454 | 543 | <h3 id="t_suivis" style="cursor: pointer;"> |
455 | 544 | <i class="icon-chevron-down" style="font-size: 14px;" id="i_suivis"></i> |
456 | 545 | <span style="text-decoration: underline;">Suivi(s) du matériel (<?=count($materiel->suivis)?>)</span> |
... | ... | @@ -471,6 +560,8 @@ use Cake\ORM\TableRegistry; |
471 | 560 | <tr> |
472 | 561 | <td class="actions" style="padding: 6px 0; text-align: left;"> |
473 | 562 | <?php |
563 | + if ( $USER_IS_ADMIN_OR_MORE || $USER_IS_UTILISATEUR_AND_CREATOR_OR_OWNER || $USER_IS_RESPONSABLE_AND_SAME_GROUP ) { | |
564 | + /* | |
474 | 565 | if ( |
475 | 566 | in_array($role, ['Administration','Administration Plus','Super Administrateur']) |
476 | 567 | || |
... | ... | @@ -495,6 +586,7 @@ use Cake\ORM\TableRegistry; |
495 | 586 | ) |
496 | 587 | ) |
497 | 588 | ) { |
589 | + */ | |
498 | 590 | echo $this->Html->link(__('<i class="icon-pencil"></i>'), ['controller' => 'Suivis','action' => 'edit',$suivis->id], ['escape' => false,'style' => 'margin:0']); |
499 | 591 | echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['controller' => 'Suivis','action' => 'delete',$suivis->id], ['escape' => false,'style' => 'margin:0','confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $suivis->id)]); |
500 | 592 | } |
... | ... | @@ -518,6 +610,7 @@ use Cake\ORM\TableRegistry; |
518 | 610 | |
519 | 611 | |
520 | 612 | <!-- EMPRUNTS --> |
613 | + | |
521 | 614 | <h3 id="t_emprunts" style="cursor: pointer;"> |
522 | 615 | <i class="icon-chevron-down" style="font-size: 14px;" id="i_emprunts"></i> |
523 | 616 | <span style="text-decoration: underline;">Emprunt(s) du matériel (<?=count($materiel->emprunts)?>)</span> |
... | ... | @@ -534,19 +627,21 @@ use Cake\ORM\TableRegistry; |
534 | 627 | <th><?=__('Date de l\'emprunt')?></th> |
535 | 628 | <th><?=__('Date de retour')?></th> |
536 | 629 | </tr> |
537 | - <?php foreach ($materiel->emprunts as $emprunts) : | |
630 | + <?php foreach ($materiel->emprunts as $emprunt) : | |
538 | 631 | $type = 'Externe'; |
539 | - $lieu = $emprunts['laboratoire']; | |
540 | - if ($emprunts['emprunt_interne'] == 1) { | |
632 | + $lieu = $emprunt['laboratoire']; | |
633 | + if ($emprunt['emprunt_interne'] == 1) { | |
541 | 634 | $type = 'Interne'; |
542 | 635 | $lieu = $sites->find()->where([ |
543 | - 'id =' => h($emprunts->site_id) | |
544 | - ])->first()['nom'] . '-' . h($emprunts->e_lieu_detail); | |
636 | + 'id =' => h($emprunt->site_id) | |
637 | + ])->first()['nom'] . '-' . h($emprunt->e_lieu_detail); | |
545 | 638 | } |
546 | 639 | ?> |
547 | 640 | <tr> |
548 | 641 | <td class="actions" style="padding: 6px 0; text-align: left;"> |
549 | 642 | <?php |
643 | + if ( $USER_IS_ADMIN_OR_MORE || $USER_IS_UTILISATEUR_AND_CREATOR_OR_OWNER || $USER_IS_RESPONSABLE_AND_SAME_GROUP ) { | |
644 | + /* | |
550 | 645 | if ( |
551 | 646 | in_array($role, ['Administration','Administration Plus','Super Administrateur']) |
552 | 647 | || |
... | ... | @@ -571,17 +666,18 @@ use Cake\ORM\TableRegistry; |
571 | 666 | ) |
572 | 667 | ) |
573 | 668 | ) { |
574 | - echo $this->Html->link(__('<i class="icon-pencil"></i>'), ['controller' => 'Emprunts','action' => 'edit',$emprunts->id], ['escape' => false,'style' => 'margin:0']); | |
575 | - echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['controller' => 'Emprunts','action' => 'delete',$emprunts->id], ['escape' => false,'style' => 'margin:0','confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $emprunts->id)]); | |
669 | + */ | |
670 | + echo $this->Html->link(__('<i class="icon-pencil"></i>'), ['controller' => 'Emprunts','action' => 'edit',$emprunt->id], ['escape' => false,'style' => 'margin:0']); | |
671 | + echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['controller' => 'Emprunts','action' => 'delete',$emprunt->id], ['escape' => false,'style' => 'margin:0','confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $emprunt->id)]); | |
576 | 672 | } |
577 | 673 | ?> |
578 | 674 | </td> |
579 | - <td><?=$this->Html->link('Emprunt ' . $emprunts->id, ['controller' => 'emprunts','action' => 'view',$emprunts->id])?></td> | |
580 | - <td><?=h($emprunts->nom_emprunteur)?></td> | |
675 | + <td><?=$this->Html->link('Emprunt ' . $emprunt->id, ['controller' => 'emprunts','action' => 'view',$emprunt->id])?></td> | |
676 | + <td><?=h($emprunt->nom_emprunteur)?></td> | |
581 | 677 | <td><?=h($type)?></td> |
582 | 678 | <td><?=h($lieu)?></td> |
583 | - <td><?=h($emprunts->date_emprunt)?></td> | |
584 | - <td><?=h($emprunts->date_retour_emprunt)?></td> | |
679 | + <td><?=h($emprunt->date_emprunt)?></td> | |
680 | + <td><?=h($emprunt->date_retour_emprunt)?></td> | |
585 | 681 | </tr> |
586 | 682 | <?php endforeach;?> |
587 | 683 | </table> |
... | ... | @@ -594,6 +690,7 @@ use Cake\ORM\TableRegistry; |
594 | 690 | |
595 | 691 | |
596 | 692 | <!-- FICHIERS liés --> |
693 | + | |
597 | 694 | <?php $nbFic = count($materiel->documents); ?> |
598 | 695 | <h3 id="t_fichiers" style="cursor: pointer;"> |
599 | 696 | <i class="icon-chevron-down" style="font-size: 14px;" id="i_fichiers"></i> |
... | ... | @@ -631,6 +728,8 @@ use Cake\ORM\TableRegistry; |
631 | 728 | 'escape' => false |
632 | 729 | ]); |
633 | 730 | } |
731 | + if ( $USER_IS_ADMIN_OR_MORE || $USER_IS_UTILISATEUR_AND_CREATOR_OR_OWNER || $USER_IS_RESPONSABLE_AND_SAME_GROUP ) { | |
732 | + /* | |
634 | 733 | if ( |
635 | 734 | in_array($role, ['Administration','Administration Plus','Super Administrateur']) |
636 | 735 | || |
... | ... | @@ -656,6 +755,7 @@ use Cake\ORM\TableRegistry; |
656 | 755 | ) |
657 | 756 | ) |
658 | 757 | ) { |
758 | + */ | |
659 | 759 | echo $this->Html->link(__('<i class="icon-pencil"></i>'), ['controller' => 'Documents','action' => 'edit',$documents->id], ['escape' => false,'style' => 'margin:0']); |
660 | 760 | echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['controller' => 'Documents','action' => 'delete',$documents->id], ['escape' => false,'style' => 'margin:0','confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $documents->id)]); |
661 | 761 | } |
... | ... | @@ -666,7 +766,7 @@ use Cake\ORM\TableRegistry; |
666 | 766 | <td><?=$p?></td> |
667 | 767 | </tr> |
668 | 768 | <?php |
669 | - endforeach; | |
769 | + endforeach; | |
670 | 770 | ?> |
671 | 771 | </table> |
672 | 772 | <?php } else echo 'Aucun fichier pour ce matériel.'; ?> | ... | ... |