Commit f4e6dc027109b4e4073ed0e37329fad5c60d2677
1 parent
9347b408
Exists in
master
and in
3 other branches
Version: 2.5.2.0
envoi mail ajout document + edition details doc + acl documents + pb saut de ligne champ "text + bugfixes Demande (terminé) : https://projects.irap.omp.eu/issues/3913 https://projects.irap.omp.eu/issues/3716 https://projects.irap.omp.eu/issues/3912 Version majeure en cours (2.5): https://projects.irap.omp.eu/versions/99 ROADMAP: https://projects.irap.omp.eu/projects/labinvent/roadmap
Showing
13 changed files
with
292 additions
and
70 deletions
Show diff stats
README-LABINVENT.md
... | ... | @@ -50,18 +50,14 @@ Logiciel testé et validé sur les configurations suivantes : |
50 | 50 | |
51 | 51 | VERSION ACTUELLE |
52 | 52 | |
53 | -Date: 28/06/2016 | |
54 | -Version: 2.5.1.0 | |
53 | +Date: 29/06/2016 | |
54 | +Version: 2.5.2.0 | |
55 | 55 | |
56 | -!!! Se placer dans database/update et exécuter le script ./db-update-2016-06-28.sh !!! | |
56 | +envoi mail ajout document + bugfixes + edition details doc + acl documents + pb saut de ligne champ "text | |
57 | 57 | |
58 | -Confirmation suppression doc + organisation configuration/form + taille doc config + photo materiel + liste type document défaut + acl documents + bugfixes | |
59 | - | |
60 | -Demande (terminé) : https://projects.irap.omp.eu/issues/3905 | |
61 | - https://projects.irap.omp.eu/issues/3790 | |
62 | - https://projects.irap.omp.eu/issues/3904 | |
63 | - | |
64 | -Demande (en cours) : https://projects.irap.omp.eu/issues/3716 | |
58 | +Demande (terminé) : https://projects.irap.omp.eu/issues/3913 | |
59 | + https://projects.irap.omp.eu/issues/3716 | |
60 | + https://projects.irap.omp.eu/issues/3912 | |
65 | 61 | |
66 | 62 | Version majeure en cours (2.5): https://projects.irap.omp.eu/versions/99 |
67 | 63 | ... | ... |
src/Controller/AppController.php
... | ... | @@ -164,10 +164,7 @@ class AppController extends Controller |
164 | 164 | $this->set('_serialize', true); |
165 | 165 | } |
166 | 166 | $this->set('username', $this->LdapAuth->user('givenname')[0].' '.$this->LdapAuth->user('sn')[0]); |
167 | - | |
168 | - | |
169 | - | |
170 | - | |
167 | + | |
171 | 168 | $configuration = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); |
172 | 169 | $this->set('configuration', $configuration); |
173 | 170 | $this->request->session()->write("authType", $configuration->authentificationType_ldap); |
... | ... | @@ -249,30 +246,33 @@ class AppController extends Controller |
249 | 246 | |
250 | 247 | switch ($action) { |
251 | 248 | case 'add': |
252 | - $actionFrench = ['Création', 'créé']; | |
249 | + $actionFrench = ['Création d\'un ', 'été créé']; | |
253 | 250 | break; |
254 | 251 | case 'edit': |
255 | - $actionFrench = ['Modification', 'modifié']; | |
252 | + $actionFrench = ['Modification d\'un ', 'été modifié']; | |
256 | 253 | break; |
257 | 254 | case 'delete': |
258 | - $actionFrench = ['Suppression', 'supprimé']; | |
255 | + $actionFrench = ['Suppression d\'un ', 'été supprimé']; | |
259 | 256 | break; |
260 | 257 | case 'statusValidated': |
261 | - $actionFrench = ['Validation', 'validé']; | |
258 | + $actionFrench = ['Validation d\'un ', 'été validé']; | |
262 | 259 | break; |
263 | 260 | case 'statusToBeArchived': |
264 | - $actionFrench = ['Demande Archivage', 'demandé pour archivage']; | |
261 | + $actionFrench = ['Demande Archivage d\'un ', 'été demandé pour archivage']; | |
265 | 262 | break; |
266 | 263 | case 'statusArchived': |
267 | - $actionFrench = ['Archivage', 'archivé']; | |
264 | + $actionFrench = ['Archivage d\'un ', 'été archivé']; | |
265 | + break; | |
266 | + case 'setLabelIsPlaced': | |
267 | + $actionFrench = ['Etiquette posé sur un ', 'reçu une étiquette']; | |
268 | 268 | break; |
269 | 269 | default: |
270 | - $actionFrench = [$action, $action]; | |
270 | + $actionFrench = [$action.' d\'un ', 'été '.$action]; | |
271 | 271 | break; |
272 | 272 | } |
273 | 273 | $doneBy = $userName." (".$userEmail.", login=".$userAuth.", profil=".$role.")."; |
274 | 274 | |
275 | - $subject = $actionFrench[0]." d'un " .$controller; | |
275 | + $subject = $actionFrench[0].$controller; | |
276 | 276 | |
277 | 277 | if($id != null) { |
278 | 278 | $entityName = TableRegistry::get($modelName)->find('all')->where(['id =' => $id])->first(); |
... | ... | @@ -291,7 +291,7 @@ class AppController extends Controller |
291 | 291 | $entityName = NULL; |
292 | 292 | } |
293 | 293 | |
294 | - $message = $this->getArticle().$controller." ".$entityName." (id=".$id.") a été ".$actionFrench[1]." par ".$doneBy; | |
294 | + $message = $this->getArticle().$controller." ".$entityName." (id=".$id.") a ".$actionFrench[1]." par ".$doneBy; | |
295 | 295 | |
296 | 296 | $this->sendEmailToManagementWith($subject, $message); |
297 | 297 | ... | ... |
src/Controller/DocumentsController.php
... | ... | @@ -36,10 +36,33 @@ class DocumentsController extends AppController |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - if($action == 'delete') { | |
39 | + if(in_array($action, ['delete', 'edit'])) { | |
40 | 40 | if ($this->userHasRole('Administration')) { |
41 | 41 | return true; |
42 | 42 | } |
43 | + $u = TableRegistry::get('Users')->find()->where(['username' => $user[$configuration->authentificationType_ldap][0]])->first(); | |
44 | + | |
45 | + $doc = $this->Documents->get((int)$this->request->params['pass'][0]); | |
46 | + | |
47 | + $id = $doc->get('materiel_id'); | |
48 | + if(empty($id)) { | |
49 | + $id = $doc->get('suivi_id'); | |
50 | + $suiviTable = TableRegistry::get('Suivis'); | |
51 | + if ($role == 'Responsable') { | |
52 | + return ($suiviTable->exists(['id' => $id, 'groupes_metier_id' => $u['groupes_metier_id']]) || $suiviTable->exists(['id' => $id, 'groupes_thematique_id' => $u['groupe_thematique_id']])); | |
53 | + } | |
54 | + if ($role == 'Utilisateur') { | |
55 | + return $suiviTable->exists(['id' => $id, 'nom_createur' => $user['givenname'][0].' '.$user['sn'][0]]); | |
56 | + } | |
57 | + } else { | |
58 | + $materielTable = TableRegistry::get('Materiels'); | |
59 | + if ($role == 'Responsable') { | |
60 | + return ($materielTable->exists(['id' => $id, 'groupes_metier_id' => $u['groupes_metier_id']]) || $materielTable->exists(['id' => $id, 'groupes_thematique_id' => $u['groupe_thematique_id']])); | |
61 | + } | |
62 | + if ($role == 'Utilisateur') { | |
63 | + return ($materielTable->exists(['id' => $id, 'nom_createur' => $user['givenname'][0].' '.$user['sn'][0]]) || $materielTable->exists(['id' => $id, 'nom_responsable' => $user['givenname'][0].' '.$user['sn'][0]])); | |
64 | + } | |
65 | + } | |
43 | 66 | } |
44 | 67 | |
45 | 68 | //Pour tout le monde |
... | ... | @@ -101,20 +124,27 @@ class DocumentsController extends AppController |
101 | 124 | public function add() |
102 | 125 | { |
103 | 126 | $document = $this->Documents->newEntity(); |
127 | + | |
104 | 128 | if ($this->request->is('post')) { |
105 | 129 | $document = $this->Documents->patchEntity($document, $this->request->data); |
106 | 130 | |
131 | + $nomType = $this->Documents->TypeDocuments->find()->where(['id =' => $document->type_document_id])->first()['nom']; | |
132 | + | |
107 | 133 | if(isset($this->passedArgs[2]) && $this->passedArgs[2] == 'photo') { |
108 | 134 | $document->set('photo', 1); |
109 | 135 | } |
110 | - | |
136 | + | |
111 | 137 | if ($this->Documents->save($document)) { |
112 | 138 | $this->Flash->success(__('Le fichier a bien été ajouté.')); |
113 | 139 | |
140 | + $id = $document->materiel_id; | |
141 | + if(!empty($id)) { | |
142 | + $materielTable = TableRegistry::get('Materiels'); | |
143 | + $materiel = $materielTable->get($id); | |
144 | + } | |
145 | + | |
114 | 146 | if(isset($this->passedArgs[2]) && $this->passedArgs[2] == 'photo') { |
115 | - $materielTable = TableRegistry::get('Materiels'); | |
116 | - $materiel = $materielTable->get($document->materiel_id); | |
117 | - | |
147 | + | |
118 | 148 | $photoIdOld = $materiel->get('photo_id'); |
119 | 149 | if(isset($photoIdOld)) { |
120 | 150 | $docOld = TableRegistry::get('Documents')->get($photoIdOld); |
... | ... | @@ -125,11 +155,16 @@ class DocumentsController extends AppController |
125 | 155 | $materielTable->save($materiel); |
126 | 156 | } |
127 | 157 | |
158 | + $userName = $this->LdapAuth->user('givenname')[0].' '.$this->LdapAuth->user('sn')[0]; | |
159 | + $userEmail = $this->LdapAuth->user('mail')[0]; | |
160 | + | |
128 | 161 | $id = $document->materiel_id; |
129 | 162 | if(empty($id)) { |
130 | 163 | $id = $document->suivi_id; |
164 | + $this->sendEmailToManagementWith('[LabInvent] Ajout d\'un document', $userName.' (email = '.$userEmail.') a ajouté un document de type "'.$nomType.'" au suivi "Suivi '.$document->suivi_id.'".'); | |
131 | 165 | return $this->redirect(['controller' => 'suivis', 'action' => 'view', $id]); |
132 | 166 | } else { |
167 | + $this->sendEmailToManagementWith('[LabInvent] Ajout d\'un document', $userName.' (email = '.$userEmail.') a ajouté un document de type "'.$nomType.'" au matériel "'.$materiel->designation.'" (id = '.$materiel->id.').'); | |
133 | 168 | return $this->redirect(['controller' => 'materiels', 'action' => 'view', $id]); |
134 | 169 | } |
135 | 170 | |
... | ... | @@ -158,6 +193,56 @@ class DocumentsController extends AppController |
158 | 193 | $this->set('_serialize', ['document']); |
159 | 194 | } |
160 | 195 | |
196 | + /** | |
197 | + * EDit method | |
198 | + * | |
199 | + * @return \Cake\Network\Response|void Redirects on successful edit, renders view otherwise. | |
200 | + */ | |
201 | + public function edit($id = null) | |
202 | + { | |
203 | + $document = $this->Documents->get($id, [ | |
204 | + 'contain' => [] | |
205 | + ]); | |
206 | + | |
207 | + if ($this->request->is(['patch', 'post', 'put'])) { | |
208 | + $document = $this->Documents->patchEntity($document, $this->request->data); | |
209 | + | |
210 | + if ($this->Documents->save($document)) { | |
211 | + $this->Flash->success(__('Le fichier a bien été edité.')); | |
212 | + | |
213 | + $id = $document->materiel_id; | |
214 | + if(empty($id)) { | |
215 | + $id = $document->suivi_id; | |
216 | + return $this->redirect(['controller' => 'suivis', 'action' => 'view', $id]); | |
217 | + } else { | |
218 | + return $this->redirect(['controller' => 'materiels', 'action' => 'view', $id]); | |
219 | + } | |
220 | + | |
221 | + } else { | |
222 | + $this->Flash->error(__('Le fichier n\'a pas pu être edité.')); | |
223 | + } | |
224 | + } | |
225 | + | |
226 | + $id = $document->materiel_id; | |
227 | + if(empty($id)) { | |
228 | + $id = $document->suivi_id; | |
229 | + $suivi = $this->Documents->Suivis->find('list', [ 'keyField' => 'id', 'valueField' => 'id'])->where(['id =' => $id]); | |
230 | + $this->set('suivi', $suivi); | |
231 | + } else { | |
232 | + $materiel = $this->Documents->Materiels->find('list', [ 'keyField' => 'id', 'valueField' => 'numero_laboratoire'])->where(['id =' => $id]); | |
233 | + $this->set('materiel', $materiel); | |
234 | + } | |
235 | + | |
236 | + if($document->photo) { | |
237 | + $this->set('photo', 1); | |
238 | + } | |
239 | + | |
240 | + | |
241 | + $typesD = $this->Documents->TypeDocuments->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'TypeDocuments.nom']); | |
242 | + | |
243 | + $this->set(compact('document', 'typesD')); | |
244 | + $this->set('_serialize', ['document']); | |
245 | + } | |
161 | 246 | |
162 | 247 | /** |
163 | 248 | * Delete method | ... | ... |
src/Controller/MaterielsController.php
... | ... | @@ -906,16 +906,14 @@ class MaterielsController extends AppController |
906 | 906 | |
907 | 907 | if ($this->Materiels->save($materiel, ['checkRules' => false, 'checkExisting' => false])) { |
908 | 908 | $this->Flash->success(__('L\'étiquette a bien été éditer.')); |
909 | - $this->sendEmailToManagement($id); | |
909 | + // Envoi email seulement si etiquette posée | |
910 | + if ($printed) { | |
911 | + $this->sendEmailToManagement($id); | |
912 | + } | |
910 | 913 | } |
911 | 914 | else { |
912 | 915 | $this->Flash->error(__('L\'étiquette n\'a pas pu être édité.')); |
913 | 916 | } |
914 | - | |
915 | - // Envoi email seulement si etiquette posée | |
916 | - if ($printed) { | |
917 | - $this->sendEmailToManagementWith('etiquette posée', "Une étiquette a été posée sur le matériel (id=$id)"); | |
918 | - } | |
919 | 917 | |
920 | 918 | return $this->redirect($this->referer()); |
921 | 919 | } | ... | ... |
src/Model/Table/AppTable.php
... | ... | @@ -11,7 +11,7 @@ class AppTable extends Table |
11 | 11 | |
12 | 12 | // autoriser les caracteres habituels standards pour un ou plusieurs MOTs |
13 | 13 | // accents + - _ / () . , \s (=space) |
14 | - private $string = "a-zA-Z0-9éèàùâêôîôûç%().,\/\s\+\-_"; | |
14 | + private $string = "a-zA-Z0-9éèàùâêôîôûç%().,\/\s\+\-_'"; | |
15 | 15 | |
16 | 16 | public function check_string($check) { |
17 | 17 | return (bool) preg_match('/^['.$this->string.']*$/', $check); | ... | ... |
src/Model/Table/DocumentsTable.php
... | ... | @@ -61,8 +61,8 @@ class DocumentsTable extends AppTable |
61 | 61 | ->allowEmpty('type_doc'); |
62 | 62 | |
63 | 63 | $validator |
64 | - ->notEmpty('chemin_file'); | |
65 | - | |
64 | + ->allowEmpty('chemin_file'); | |
65 | + | |
66 | 66 | $validator |
67 | 67 | ->notEmpty('nom'); |
68 | 68 | |
... | ... | @@ -97,30 +97,49 @@ class DocumentsTable extends AppTable |
97 | 97 | $config = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); |
98 | 98 | |
99 | 99 | $checkSizeDoc= function($entity) { |
100 | - $config = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); | |
101 | - $size = $entity->get('chemin_file')['size']; | |
102 | - if(isset($size)) { | |
103 | - if($size > $config->taille_max_doc) { | |
104 | - return false; | |
100 | + if(!empty($entity->get('chemin_file')['tmp_name'])) { | |
101 | + $config = TableRegistry::get('Configurations')->find()->where(['id =' => 1])->first(); | |
102 | + $size = $entity->get('chemin_file')['size']; | |
103 | + if(isset($size)) { | |
104 | + if($size > $config->taille_max_doc) { | |
105 | + return false; | |
106 | + } else { | |
107 | + return true; | |
108 | + } | |
105 | 109 | } else { |
106 | - return true; | |
110 | + return false; | |
107 | 111 | } |
108 | 112 | } else { |
109 | - return false; | |
113 | + return true; | |
110 | 114 | } |
111 | - | |
112 | 115 | }; |
113 | 116 | |
114 | 117 | $checkPhoto= function($entity) { |
115 | - if($entity->get('photo')) { | |
116 | - $extension = strtolower(pathinfo($entity->get('chemin_file')['name'] , PATHINFO_EXTENSION)); | |
117 | - return in_array($extension, ['png', 'jpg', 'jpeg']); | |
118 | - } | |
119 | - else { | |
120 | - return true; | |
121 | - } | |
118 | + if(!empty($entity->get('chemin_file')['tmp_name'])) { | |
119 | + if($entity->get('photo')) { | |
120 | + $extension = strtolower(pathinfo($entity->get('chemin_file')['name'] , PATHINFO_EXTENSION)); | |
121 | + return in_array($extension, ['png', 'jpg', 'jpeg']); | |
122 | + } | |
123 | + else { | |
124 | + return true; | |
125 | + } | |
126 | + } else { | |
127 | + return true; | |
128 | + } | |
122 | 129 | }; |
123 | 130 | |
131 | + $checkEditFile= function($entity) { | |
132 | + if(!$entity->get('edit')) { | |
133 | + if(empty($entity->get('chemin_file')['tmp_name'])) { | |
134 | + return false; | |
135 | + } | |
136 | + else { | |
137 | + return true; | |
138 | + } | |
139 | + } else { | |
140 | + return true; | |
141 | + } | |
142 | + }; | |
124 | 143 | |
125 | 144 | $rules->add($checkSizeDoc, [ |
126 | 145 | 'errorField' => 'chemin_file', |
... | ... | @@ -132,6 +151,10 @@ class DocumentsTable extends AppTable |
132 | 151 | 'message' => 'La photo doit etre au format png, jpg (ou jpeg).' |
133 | 152 | ]); |
134 | 153 | |
154 | + $rules->add($checkEditFile, [ | |
155 | + 'errorField' => 'chemin_file', | |
156 | + 'message' => 'Un fichier doit être présent.' | |
157 | + ]); | |
135 | 158 | |
136 | 159 | return $rules; |
137 | 160 | } |
... | ... | @@ -154,10 +177,13 @@ class DocumentsTable extends AppTable |
154 | 177 | **/ |
155 | 178 | public function beforeSave($event, $entity, $options) |
156 | 179 | { |
180 | + | |
157 | 181 | $file = $entity->get('chemin_file'); |
158 | - $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); | |
182 | + if(!empty($file['tmp_name'])) { | |
183 | + $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); | |
184 | + $entity->set('type_doc', $extension); | |
185 | + } | |
159 | 186 | |
160 | - $entity->set('type_doc', $extension); | |
161 | 187 | return true; |
162 | 188 | } |
163 | 189 | ... | ... |
... | ... | @@ -0,0 +1,46 @@ |
1 | + | |
2 | +<div class="documents form"> | |
3 | + <?= $this->Form->create($document, ['type' => 'file']) ?> | |
4 | + <fieldset> | |
5 | + <?php | |
6 | + if(isset($photo)) { | |
7 | + echo '<h2><i class="icon-plus"></i> Editer une photo</h2>'; | |
8 | + }else { | |
9 | + echo '<h2><i class="icon-plus"></i> Editer un document</h2>'; | |
10 | + } | |
11 | + if(isset($materiel)) { | |
12 | + echo $this->Form->input('materiel_id', ['label' => 'N° materiel labo', 'options' => $materiel, 'default' => $this->passedArgs[0], 'readonly' => true]); | |
13 | + } | |
14 | + else if(isset($suivi)) { | |
15 | + echo $this->Form->input('suivi_id', ['label' => 'N° suivi', 'options' => $suivi, 'default' => $this->passedArgs[0], 'readonly' => true]); | |
16 | + } | |
17 | + | |
18 | + echo $this->Form->input('nom'); | |
19 | + echo $this->Form->input('type_document_id', ['label' => 'Type', 'options' => $typesD, 'default' => 1]); | |
20 | + echo $this->Form->input('description'); | |
21 | + | |
22 | + echo $this->Form->hidden('chemin_file', ['label' => 'Fichier ('.substr($configuration->taille_max_doc/(1024*1024), 0, 4).' Mo max)', 'type' => 'file']); | |
23 | + | |
24 | + echo $this->Form->hidden('edit', ['default' => 1]); | |
25 | + | |
26 | + if(isset($photo)) { | |
27 | + echo $this->Form->hidden('photo', ['default' => 1]); | |
28 | + } | |
29 | + else { | |
30 | + echo $this->Form->hidden('photo', ['default' => 0]); | |
31 | + } | |
32 | + | |
33 | + | |
34 | + | |
35 | + ?> | |
36 | + </fieldset> | |
37 | + <?= $this->Form->submit(__('Valider')) ?> | |
38 | + <?= $this->Form->end() ?> | |
39 | +</div> | |
40 | + | |
41 | +<div class="actions"> | |
42 | + <?php | |
43 | + echo $this->element('menu'); | |
44 | + echo $this->element('menu_form', [ 'pluralHumanName' => 'Documents' ]); | |
45 | + ?> | |
46 | +</div> | ... | ... |
src/Template/Documents/index.ctp
... | ... | @@ -45,6 +45,8 @@ |
45 | 45 | echo $this->Form->postLink(__('<i class="icon-download"></i>'), '/webroot/files/'.$document->id.'.'.$document->type_doc, ['title' => 'Télécharger', 'style' => 'margin: 0 2px', 'escape' => false ]); |
46 | 46 | } |
47 | 47 | ?> |
48 | + <?= $this->Html->link(__('<i class="icon-edit"></i>'), ['action' => 'edit', $document->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false]) ?> | |
49 | + | |
48 | 50 | <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $document->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $document->id)]) ?> |
49 | 51 | </td> |
50 | 52 | </tr> | ... | ... |
src/Template/Documents/view.ctp
... | ... | @@ -17,7 +17,9 @@ |
17 | 17 | |
18 | 18 | $displayElement(__('Nom'), h($document->nom)); |
19 | 19 | $displayElement(__('Type'), $document->has('type_document') ? h($document->type_document->nom) : ''); |
20 | - $displayElement(__('Description'), h($document->description)); | |
20 | + | |
21 | + echo '<tr><td><strong>'.__('Description').' </strong></td><td>'.nl2br($document->description).'</td></tr>'; | |
22 | + | |
21 | 23 | $displayElement(__('Extension fichier'), h($document->type_doc)); |
22 | 24 | |
23 | 25 | ... | ... |
src/Template/Element/menu_view.ctp
1 | +<?php | |
2 | +use Cake\ORM\TableRegistry; | |
3 | +?> | |
4 | + | |
1 | 5 | <h3 style="margin-top: 20px;"><?php echo $pluralHumanName;?></h3> |
2 | 6 | <ul> |
3 | 7 | <?php |
... | ... | @@ -67,6 +71,34 @@ |
67 | 71 | $isAuthorized = true; |
68 | 72 | } |
69 | 73 | } |
74 | + else if ($singularHumanName == 'Document') { | |
75 | + if(in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) { | |
76 | + $isAuthorized = true; | |
77 | + } | |
78 | + $doc = TableRegistry::get('Documents')->get((int)$this->request->params['pass'][0]); | |
79 | + | |
80 | + $id = $doc->get('materiel_id'); | |
81 | + | |
82 | + if(empty($id)) { | |
83 | + $id = $doc->get('suivi_id'); | |
84 | + $suiviTable = TableRegistry::get('Suivis'); | |
85 | + if ($role == 'Responsable') { | |
86 | + $isAuthorized = ($suiviTable->exists(['id' => $id, 'groupes_metier_id' => $userConnected['groupes_metier_id']]) || $suiviTable->exists(['id' => $id, 'groupes_thematique_id' => $userConnected['groupe_thematique_id']])); | |
87 | + } | |
88 | + if ($role == 'Utilisateur') { | |
89 | + $isAuthorized = $suiviTable->exists(['id' => $id, 'nom_createur' => $username]); | |
90 | + } | |
91 | + } else { | |
92 | + $materielTable = TableRegistry::get('Materiels'); | |
93 | + if ($role == 'Responsable') { | |
94 | + $isAuthorized = ($materielTable->exists(['id' => $id, 'groupes_metier_id' => $userConnected['groupes_metier_id']]) || $materielTable->exists(['id' => $id, 'groupes_thematique_id' => $userConnected['groupe_thematique_id']])); | |
95 | + } | |
96 | + if ($role == 'Utilisateur') { | |
97 | + $isAuthorized = ($materielTable->exists(['id' => $id, 'nom_createur' => $username]) || $materielTable->exists(['id' => $id, 'nom_responsable' => $username])); | |
98 | + } | |
99 | + } | |
100 | + | |
101 | + } | |
70 | 102 | else { |
71 | 103 | if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { |
72 | 104 | $isAuthorized = true; |
... | ... | @@ -74,7 +106,6 @@ |
74 | 106 | } |
75 | 107 | |
76 | 108 | if ($isAuthorized == true) { |
77 | - if($singularHumanName != 'Document') { | |
78 | 109 | $action = ''; |
79 | 110 | if(strstr($t, 'catégorie')) |
80 | 111 | $action = ' Editer cette'; |
... | ... | @@ -89,7 +120,6 @@ |
89 | 120 | ['action' => 'edit', $lien], |
90 | 121 | ['escape' => false,'onclick' => 'return true;'] |
91 | 122 | ); |
92 | - } | |
93 | 123 | } |
94 | 124 | |
95 | 125 | |
... | ... | @@ -130,6 +160,33 @@ |
130 | 160 | } |
131 | 161 | } |
132 | 162 | } |
163 | + } else if ($singularHumanName == 'Document') { | |
164 | + if(in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) { | |
165 | + $isAuthorized = true; | |
166 | + } | |
167 | + $doc = TableRegistry::get('Documents')->get((int)$this->request->params['pass'][0]); | |
168 | + | |
169 | + $id = $doc->get('materiel_id'); | |
170 | + | |
171 | + if(empty($id)) { | |
172 | + $id = $doc->get('suivi_id'); | |
173 | + $suiviTable = TableRegistry::get('Suivis'); | |
174 | + if ($role == 'Responsable') { | |
175 | + $isAuthorized = ($suiviTable->exists(['id' => $id, 'groupes_metier_id' => $userConnected['groupes_metier_id']]) || $suiviTable->exists(['id' => $id, 'groupes_thematique_id' => $userConnected['groupe_thematique_id']])); | |
176 | + } | |
177 | + if ($role == 'Utilisateur') { | |
178 | + $isAuthorized = $suiviTable->exists(['id' => $id, 'nom_createur' => $username]); | |
179 | + } | |
180 | + } else { | |
181 | + $materielTable = TableRegistry::get('Materiels'); | |
182 | + if ($role == 'Responsable') { | |
183 | + $isAuthorized = ($materielTable->exists(['id' => $id, 'groupes_metier_id' => $userConnected['groupes_metier_id']]) || $materielTable->exists(['id' => $id, 'groupes_thematique_id' => $userConnected['groupe_thematique_id']])); | |
184 | + } | |
185 | + if ($role == 'Utilisateur') { | |
186 | + $isAuthorized = ($materielTable->exists(['id' => $id, 'nom_createur' => $username]) || $materielTable->exists(['id' => $id, 'nom_responsable' => $username])); | |
187 | + } | |
188 | + } | |
189 | + | |
133 | 190 | } |
134 | 191 | else { |
135 | 192 | if (in_array($role, ['Super Administrateur'])) { |
... | ... | @@ -138,17 +195,17 @@ |
138 | 195 | } |
139 | 196 | |
140 | 197 | if($isAuthorized == true) { |
141 | - $action = ''; | |
142 | - if(strstr($t, 'catégorie')) | |
143 | - $action = ' Supprimer cette'; | |
144 | - elseif ( strstr($t, 'utilisateur') || strstr($t, 'emprunt') ) | |
145 | - $action = ' Supprimer cet'; | |
146 | - else | |
147 | - $action = ' Supprimer ce'; | |
198 | + $action = ''; | |
199 | + if(strstr($t, 'catégorie')) | |
200 | + $action = ' Supprimer cette'; | |
201 | + elseif ( strstr($t, 'utilisateur') || strstr($t, 'emprunt') ) | |
202 | + $action = ' Supprimer cet'; | |
203 | + else | |
204 | + $action = ' Supprimer ce'; | |
148 | 205 | |
149 | - echo $this->Form->postLink('<i class="icon-trash"></i>' . $action . ' ' . $t, | |
150 | - ['action' => 'delete', $lien], | |
151 | - ['escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer '.$lien.' ?')]); | |
206 | + echo $this->Form->postLink('<i class="icon-trash"></i>' . $action . ' ' . $t, | |
207 | + ['action' => 'delete', $lien], | |
208 | + ['escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer '.$lien.' ?')]); | |
152 | 209 | } |
153 | 210 | |
154 | 211 | ... | ... |
src/Template/Layout/default.ctp
... | ... | @@ -94,7 +94,7 @@ $cakeDescription = 'Labinvent 2'; |
94 | 94 | </i></td> |
95 | 95 | <td id="version"> |
96 | 96 | <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) --> |
97 | - <font color="black">VERSION 2.5.1.0 (28/06/2016)</font> | |
97 | + <font color="black">VERSION 2.5.2.0 (29/06/2016)</font> | |
98 | 98 | </td> |
99 | 99 | </tr> |
100 | 100 | </table> | ... | ... |
src/Template/Materiels/view.ctp
... | ... | @@ -307,7 +307,8 @@ if (h ( $materiel->status ) == 'ARCHIVED') |
307 | 307 | $type = 'Technique'; |
308 | 308 | } |
309 | 309 | |
310 | - $displayElement ( __ ( 'Description' ), h ( $materiel->description ) ); | |
310 | + echo '<tr><td><strong>'.__('Description').' </strong></td><td>'.nl2br($materiel->description).'</td></tr>'; | |
311 | + | |
311 | 312 | $displayElement ( __ ( 'Materiel inventorié' ), $type ); |
312 | 313 | $displayElement ( __ ( 'Organisme' ), $materiel->has ( 'organisme' ) ? h ( $materiel->organisme->nom ) : '' ); |
313 | 314 | $displayElement ( __ ( 'Domaine' ), $materiel->has ( 'sur_category' ) ? h ( $materiel->sur_category->nom ) : '' ); |
... | ... | @@ -493,6 +494,7 @@ foreach ( $materiel->emprunts as $emprunts ) : |
493 | 494 | <?php |
494 | 495 | if(($role == 'Utilisateur' && (in_array($username, [$materiel->nom_createur, $materiel->nom_responsable]))) || (in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) || ($role == 'Responsable' && ($materiel->groupes_metier_id == $userConnected->groupes_metier_id || $materiel->groupes_thematique_id == $userConnected->groupe_thematique_id))) { |
495 | 496 | ?> |
497 | + <th style="width: 50px;"><?= __('Editer') ?></th> | |
496 | 498 | <th style="width: 50px;"><?= __('Supprimer') ?></th> |
497 | 499 | <?php } ?> |
498 | 500 | </tr> |
... | ... | @@ -538,8 +540,11 @@ foreach ( $materiel->documents as $documents ) : |
538 | 540 | <?php |
539 | 541 | if(($role == 'Utilisateur' && (in_array($username, [$materiel->nom_createur, $materiel->nom_responsable]))) || (in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) || ($role == 'Responsable' && ($materiel->groupes_metier_id == $userConnected->groupes_metier_id || $materiel->groupes_thematique_id == $userConnected->groupe_thematique_id))) { |
540 | 542 | ?> |
543 | + <td class="actions"> | |
544 | + <?= $this->Html->link(__('<i class="icon-edit"></i>'), ['controller' => 'Documents', 'action' => 'edit', $documents->id], ['escape' => false, 'style' => 'margin:0'])?> | |
545 | + </td> | |
541 | 546 | <td class="actions"> |
542 | - <?= $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)])?> | |
547 | + <?= $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)])?> | |
543 | 548 | </td> |
544 | 549 | <?php } ?> |
545 | 550 | </tr> | ... | ... |
src/Template/Suivis/view.ctp
... | ... | @@ -66,9 +66,11 @@ |
66 | 66 | <th><?= __('Type') ?></th> |
67 | 67 | <th style="width:50px;"><?= __('Détail') ?></th> |
68 | 68 | <th style="width:50px;"><?= __('Télécharger') ?></th> |
69 | + | |
69 | 70 | <?php |
70 | 71 | if(($role == 'Utilisateur' && in_array($username, [$suivi->nom_createur])) || (in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) || $role == 'Responsable' && ($suivi->groupes_metier_id == $userConnected->groupes_metier_id || $suivi->groupes_thematique_id == $userConnected->groupe_thematique_id)) { |
71 | 72 | ?> |
73 | + <th style="width: 50px;"><?= __('Editer') ?></th> | |
72 | 74 | <th style="width:50px;"><?= __('Supprimer') ?></th> |
73 | 75 | <?php } ?> |
74 | 76 | </tr> |
... | ... | @@ -91,6 +93,9 @@ |
91 | 93 | if(($role == 'Utilisateur' && in_array($username, [$suivi->nom_createur])) || (in_array($role, ['Administration', 'Administration Plus', 'Super Administrateur'])) || $role == 'Responsable' && ($suivi->groupes_metier_id == $userConnected->groupes_metier_id || $suivi->groupes_thematique_id == $userConnected->groupe_thematique_id)) { |
92 | 94 | ?> |
93 | 95 | <td class="actions"> |
96 | + <?= $this->Html->link(__('<i class="icon-edit"></i>'), ['controller' => 'Documents', 'action' => 'edit', $documents->id], ['escape' => false, 'style' => 'margin:0'])?> | |
97 | + </td> | |
98 | + <td class="actions"> | |
94 | 99 | <?= $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)]) ?> |
95 | 100 | </td> |
96 | 101 | <?php } ?> | ... | ... |