Commit a97b5772f968ce7f0e2913866110bdba6d77f260
1 parent
0e5846aa
Exists in
master
and in
3 other branches
Migration fonctionnalités, bugfixes (voir détail)
- Migration fonction "valider", "archivé", "demande archive" - Migration génération labNumber - MIgration fonctionnalité "recherche" #3537 - BugFixes
Showing
10 changed files
with
614 additions
and
30 deletions
Show diff stats
src/Controller/MaterielsController.php
... | ... | @@ -65,13 +65,14 @@ class MaterielsController extends AppController |
65 | 65 | $this->Flash->error(__('Le matériel n\'a pas pu être ajouté.')); |
66 | 66 | } |
67 | 67 | } |
68 | - $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
69 | - $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
70 | - $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
71 | - $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
72 | - $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
73 | - $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
74 | - $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
68 | + | |
69 | + $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SurCategories.nom']); | |
70 | + $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Categories.nom']); | |
71 | + $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SousCategories.nom']); | |
72 | + $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesThematiques.nom']); | |
73 | + $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesMetiers.nom']); | |
74 | + $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Organismes.nom']); | |
75 | + $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Sites.nom']); | |
75 | 76 | |
76 | 77 | $utilisateurs = TableRegistry::get('Users')->find('list', [ 'keyField' => 'nom', 'valueField' => 'nom']); |
77 | 78 | |
... | ... | @@ -102,13 +103,13 @@ class MaterielsController extends AppController |
102 | 103 | $this->Flash->error(__('Le matériel n\'a pas pu être édité.')); |
103 | 104 | } |
104 | 105 | } |
105 | - $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
106 | - $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
107 | - $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
108 | - $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
109 | - $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
110 | - $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
111 | - $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom']); | |
106 | + $surCategories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SurCategories.nom']); | |
107 | + $categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Categories.nom']); | |
108 | + $sousCategories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SousCategories.nom']); | |
109 | + $groupesThematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesThematiques.nom']); | |
110 | + $groupesMetiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesMetiers.nom']); | |
111 | + $organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Organismes.nom']); | |
112 | + $sites = $this->Materiels->Sites->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Sites.nom']); | |
112 | 113 | |
113 | 114 | $utilisateurs = TableRegistry::get('Users')->find('list', [ 'keyField' => 'nom', 'valueField' => 'nom']); |
114 | 115 | |
... | ... | @@ -143,14 +144,186 @@ class MaterielsController extends AppController |
143 | 144 | return $this->redirect(['action' => 'index']); |
144 | 145 | } |
145 | 146 | |
147 | + private function statusSetTo($newStatus, $message, $id = null, $from = 'index') { | |
148 | + $materiel = $this->Materiels->get($id)->set('status', $newStatus); | |
149 | + | |
150 | + if ($this->Materiels->save($materiel)) { | |
151 | + $this->Flash->success(__($message)); | |
152 | + } | |
153 | + | |
154 | + return $this->redirect(['action'=>$from, $id]); | |
155 | + } | |
156 | + | |
157 | + public function statusValidated($id = null, $from = 'index') { | |
158 | + $this->statusSetTo('VALIDATED', 'Le matériel a bien été validé', $id, $from); | |
159 | + } | |
160 | + public function statusToBeArchived($id = null, $from = 'index') { | |
161 | + $this->statusSetTo('TOBEARCHIVED', 'La sortie d\'inventaire a bien été demandée', $id, $from); | |
162 | + } | |
163 | + public function statusArchived($id = null, $from = 'index') { | |
164 | + $this->statusSetTo('ARCHIVED', 'Le matériel a bien été sorti de l\'inventaire', $id, $from); | |
165 | + } | |
166 | + | |
167 | + private function getConditionForField($fieldName) { | |
168 | + $searchFieldName = 's_' . $fieldName; | |
169 | + if ( isset($this->request->data[$searchFieldName]) && ($this->request->data[$searchFieldName] != '')) return ["Materiels.$fieldName LIKE" => '%'.$this->request->data[$searchFieldName].'%']; | |
170 | + return NULL; | |
171 | + } | |
172 | + | |
173 | + private function getConditionForFieldNumber($fieldName) { | |
174 | + $searchFieldName = 's_' . $fieldName; | |
175 | + if ( isset($this->request->data[$searchFieldName]) && ($this->request->data[$searchFieldName] != '')) return ["Materiels.$fieldName =" => $this->request->data[$searchFieldName]]; | |
176 | + return NULL; | |
177 | + } | |
178 | + | |
146 | 179 | public function find() { |
180 | + | |
181 | + $s_sur_categories = $this->Materiels->SurCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SurCategories.nom']); | |
182 | + $s_categories = $this->Materiels->Categories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Categories.nom']); | |
183 | + $s_sous_categories = $this->Materiels->SousCategories->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'SousCategories.nom']); | |
184 | + $s_groupes_thematiques = $this->Materiels->GroupesThematiques->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesThematiques.nom']); | |
185 | + $s_groupes_metiers = $this->Materiels->GroupesMetiers->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'GroupesMetiers.nom']); | |
186 | + $s_organismes = $this->Materiels->Organismes->find('list', [ 'keyField' => 'id', 'valueField' => 'nom', 'order' => 'Organismes.nom']); | |
187 | + | |
188 | + $this->set(compact('s_sur_categories', 's_categories', 's_sous_categories', 's_groupes_thematiques', 's_groupes_metiers', 's_organismes')); | |
189 | + | |
190 | + // some data POSTED (au moins le champ de recherche generale) ? | |
191 | + if ( isset($this->request->data['s_all']) || isset($this->request->data['s_all_2']) || isset($this->request->data['designation'])) { | |
192 | + $generalFieldConditions = NULL; | |
193 | + // if general field set (s_all), then set general request for it | |
194 | + if (isset($this->request->data['s_all'])) { | |
195 | + $all = $this->request->data['s_all']; | |
196 | + $generalFieldConditions = ['OR' => [ | |
197 | + 'Materiels.designation LIKE' => '%'.$all.'%', | |
198 | + 'Materiels.numero_laboratoire LIKE' => '%'.$all.'%', | |
199 | + 'Materiels.numero_inventaire_organisme LIKE' => '%'.$all.'%', | |
200 | + 'Materiels.numero_inventaire_old LIKE' => '%'.$all.'%', | |
201 | + 'Materiels.numero_commande LIKE' => '%'.$all.'%', | |
202 | + 'Materiels.description LIKE' => '%'.$all.'%', | |
203 | + 'Materiels.fournisseur LIKE' => '%'.$all.'%', | |
204 | + 'Materiels.nom_responsable LIKE' => '%'.$all.'%', | |
205 | + 'Materiels.email_responsable LIKE' => '%'.$all.'%', | |
206 | + 'Materiels.code_comptable LIKE' => '%'.$all.'%', | |
207 | + 'Materiels.numero_serie LIKE' => '%'.$all.'%', | |
208 | + 'Materiels.date_acquisition LIKE' => '%'.$all.'%', | |
209 | + 'Materiels.date_reception LIKE' => '%'.$all.'%', | |
210 | + ]]; | |
211 | + } | |
212 | + if (isset($this->request->data['s_all_2'])) { | |
213 | + $all = $this->request->data['s_all_2']; | |
214 | + $generalFieldConditions = ['OR' => [ | |
215 | + 'Materiels.designation LIKE' => '%'.$all.'%', | |
216 | + 'Materiels.numero_laboratoire LIKE' => '%'.$all.'%', | |
217 | + 'Materiels.numero_inventaire_organisme LIKE' => '%'.$all.'%', | |
218 | + 'Materiels.numero_inventaire_old LIKE' => '%'.$all.'%', | |
219 | + 'Materiels.numero_commande LIKE' => '%'.$all.'%', | |
220 | + 'Materiels.description LIKE' => '%'.$all.'%', | |
221 | + 'Materiels.fournisseur LIKE' => '%'.$all.'%', | |
222 | + 'Materiels.nom_responsable LIKE' => '%'.$all.'%', | |
223 | + 'Materiels.email_responsable LIKE' => '%'.$all.'%', | |
224 | + 'Materiels.code_comptable LIKE' => '%'.$all.'%', | |
225 | + 'Materiels.numero_serie LIKE' => '%'.$all.'%', | |
226 | + 'Materiels.date_acquisition LIKE' => '%'.$all.'%', | |
227 | + 'Materiels.date_reception LIKE' => '%'.$all.'%', | |
228 | + ]]; | |
229 | + } | |
230 | + $specificFieldsConditions = NULL; | |
231 | + // au moins un champ specifique rempli ? | |
232 | + if ( isset($this->request->data['s_designation']) ) { | |
233 | + // Materiel type | |
234 | + $matostype = $this->request->data['s_matostype']; | |
235 | + $matostypeRequest = NULL; | |
236 | + | |
237 | + switch ($matostype) { | |
238 | + // Administratif | |
239 | + case 'A': | |
240 | + $matostypeRequest['Materiels.materiel_administratif ='] = '1'; | |
241 | + break; | |
242 | + // Technique | |
243 | + case 'T': | |
244 | + $matostypeRequest['Materiels.materiel_technique ='] = '1'; | |
245 | + break; | |
246 | + // Admin et Tech | |
247 | + case 'AT': | |
248 | + $matostypeRequest['Materiels.materiel_administratif ='] = '1'; | |
249 | + $matostypeRequest['Materiels.materiel_technique ='] = '1'; | |
250 | + break; | |
251 | + // Admin ONLY | |
252 | + case 'AO': | |
253 | + $matostypeRequest['Materiels.materiel_administratif ='] = '1'; | |
254 | + $matostypeRequest['Materiels.materiel_technique ='] = '0'; | |
255 | + break; | |
256 | + // Tech ONLY | |
257 | + case 'TO': | |
258 | + $matostypeRequest['Materiels.materiel_administratif ='] = '0'; | |
259 | + $matostypeRequest['Materiels.materiel_technique ='] = '1'; | |
260 | + break; | |
261 | + } | |
262 | + | |
263 | + $periode_acquisitionRequest = NULL; | |
264 | + if ($this->request->data['s_periode_acquisition1'] != '') | |
265 | + $periode_acquisitionRequest['Materiels.date_acquisition >='] = $this->request->data['s_periode_acquisition1']; | |
266 | + if ($this->request->data['s_periode_acquisition2'] != '') | |
267 | + $periode_acquisitionRequest['Materiels.date_acquisition <='] = $this->request->data['s_periode_acquisition2']; | |
147 | 268 | |
269 | + $montantRequest = []; | |
270 | + if ($this->request->data['s_prix_ht_inf'] != '') | |
271 | + $montantRequest['Materiels.prix_ht <='] = $this->request->data['s_prix_ht_inf']; | |
272 | + if ($this->request->data['s_prix_ht_sup'] != '') | |
273 | + $montantRequest['Materiels.prix_ht >='] = $this->request->data['s_prix_ht_sup']; | |
274 | + | |
275 | + $specificFieldsConditions = [ | |
276 | + 'Materiels.designation LIKE' => '%'.$this->request->data['s_designation'].'%', | |
277 | + 'Materiels.numero_laboratoire LIKE' => '%'.$this->request->data['s_numero_laboratoire'].'%', | |
278 | + $this->getConditionForField('numero_commande'), | |
279 | + 'Materiels.date_acquisition LIKE' => '%'.$this->request->data['s_date_acquisition'].'%', | |
280 | + $periode_acquisitionRequest, | |
281 | + $this->getConditionForFieldNumber('prix_ht'), | |
282 | + $montantRequest, | |
283 | + $this->getConditionForFieldNumber('sur_categorie_id'), | |
284 | + $this->getConditionForFieldNumber('categorie_id'), | |
285 | + $this->getConditionForFieldNumber('sous_categorie_id'), | |
286 | + $this->getConditionForField('nom_responsable'), | |
287 | + $this->getConditionForField('numero_inventaire_organisme'), | |
288 | + $this->getConditionForField('numero_inventaire_old'), | |
289 | + $this->getConditionForFieldNumber('groupes_metier_id'), | |
290 | + $this->getConditionForFieldNumber('groupes_thematique_id'), | |
291 | + $this->getConditionForField('status'), | |
292 | + $this->getConditionForFieldNumber('organisme_id'), | |
293 | + $matostypeRequest, | |
294 | + ]; | |
295 | + } | |
296 | + | |
297 | + // CONSTRUCTION DE LA REQUETE SQL COMPLETE = $specificFieldsConditions OR $generalFieldConditions (mais entre chaque champ, c'est un AND) | |
298 | + // by default, no sort | |
299 | + $order = []; | |
300 | + | |
301 | + if (isset($this->passedArgs[0]) && isset($this->passedArgs[1])) { | |
302 | + $order = $this->passedArgs[0]; | |
303 | + $order .= ' '.$this->passedArgs[1]; | |
304 | + } | |
305 | + | |
306 | + if (isset($this->request->data['s_all_2']) && $this->request->data['s_all_2'] != '') { | |
307 | + $conditions = $generalFieldConditions; | |
308 | + } | |
309 | + else if (isset($this->request->data['s_all']) && $this->request->data['s_all'] != '') { | |
310 | + $conditions = $generalFieldConditions; | |
311 | + } | |
312 | + else { | |
313 | + $conditions = $specificFieldsConditions; | |
314 | + } | |
315 | + | |
316 | + $lastResults = $this->Materiels->find('all', ['limit' => 1000, 'order' => $order, 'conditions' => $conditions])->toArray(); | |
317 | + | |
318 | + $this->set('_results', $lastResults); | |
319 | + | |
320 | + } // end if() | |
148 | 321 | } |
149 | 322 | |
150 | 323 | public function export() { |
151 | 324 | |
152 | 325 | } |
153 | - | |
326 | + | |
154 | 327 | /** |
155 | 328 | * Activate install mode |
156 | 329 | * | ... | ... |
src/Model/Table/MaterielsTable.php
... | ... | @@ -6,6 +6,7 @@ use Cake\ORM\Query; |
6 | 6 | use Cake\ORM\RulesChecker; |
7 | 7 | use Cake\ORM\Table; |
8 | 8 | use Cake\Validation\Validator; |
9 | +use Cake\ORM\TableRegistry; | |
9 | 10 | |
10 | 11 | /** |
11 | 12 | * Materiels Model |
... | ... | @@ -243,4 +244,33 @@ class MaterielsTable extends AppTable |
243 | 244 | $rules->add($rules->existsIn(['site_id'], 'Sites')); |
244 | 245 | return $rules; |
245 | 246 | } |
247 | + | |
248 | + | |
249 | + public function beforeSave($event, $entity, $options) | |
250 | + { | |
251 | + if(!empty($entity->get('nom_responsable')) && empty($entity->get('nom_responsable'))){ | |
252 | + $entity->set('nom_responsable', $entity->get('nom_ancien_responsable')); | |
253 | + } | |
254 | + | |
255 | + // numero_laboratoire generator (QC changed this in Jan 2015) | |
256 | + if (empty($entity->get('numero_laboratoire')) && !empty($entity->get('date_acquisition'))) { | |
257 | + $year = substr($entity->get('date_acquisition'), 6, 4); | |
258 | + $labName = 'IRAP'; | |
259 | + | |
260 | + $num = TableRegistry::get('Materiels')->find('all', [ | |
261 | + 'fields' => ['numero_laboratoire'], | |
262 | + 'conditions' => ['Materiels.numero_laboratoire LIKE' => $labName.'-'.$year.'%'], | |
263 | + 'order' => ['Materiels.numero_laboratoire DESC'] | |
264 | + ])->first()['numero_laboratoire']; | |
265 | + | |
266 | + $newId = substr($num, -4)+1; | |
267 | + $labNumber = $labName.'-'.$year.'-'.sprintf("%04d", $newId); | |
268 | + | |
269 | + $entity->set('numero_laboratoire', $labNumber); | |
270 | + } | |
271 | + | |
272 | + return true; | |
273 | + } | |
274 | + | |
275 | + | |
246 | 276 | } | ... | ... |
src/Template/Element/menu.ctp
... | ... | @@ -34,6 +34,6 @@ |
34 | 34 | <?php |
35 | 35 | //Search function |
36 | 36 | echo $this->Form->create('Materiel', ['url' => '/materiels/find']); |
37 | - echo '<input name="data[Materiel][s_all]" class="search-input" type="text" id="MaterielSAll">'; | |
37 | + echo '<input name="s_all_2" class="search-input" type="text" id="MaterielSAll">'; | |
38 | 38 | echo $this->Form->end(); |
39 | 39 | ?> |
40 | 40 | \ No newline at end of file | ... | ... |
src/Template/Emprunts/index.ctp
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <tbody> |
20 | 20 | <?php foreach ($emprunts as $emprunt): ?> |
21 | 21 | <tr> |
22 | - <td><?php echo 'Emprunt '.$this->Number->format($emprunt->id) ?></td> | |
22 | + <td><?php echo $this->Html->link('Emprunt '.$this->Number->format($emprunt->id), ['action' => 'view', $emprunt->id])?></td> | |
23 | 23 | <td><?= $emprunt->has('materiel') ? $this->Html->link($emprunt->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $emprunt->materiel->id]) : '' ?></td> |
24 | 24 | <td><?= $emprunt->has('materiel') ? h($emprunt->materiel->numero_laboratoire) : '' ?></td> |
25 | 25 | <td><?php if (h($emprunt->emprunt_interne) == '1') { echo 'Interne'; } else { echo 'Externe'; } ?></td> | ... | ... |
src/Template/Layout/default.ctp
... | ... | @@ -93,7 +93,7 @@ $cakeDescription = 'Labinvent 2.0'; |
93 | 93 | </i></td> |
94 | 94 | <td id="version"> |
95 | 95 | <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) --> |
96 | - <font color="black">VERSION 2.0.2.2 (06/05/2016)</font> | |
96 | + <font color="black">VERSION 2.0.3.1 (08/05/2016)</font> | |
97 | 97 | </td> |
98 | 98 | </tr> |
99 | 99 | </table> | ... | ... |
src/Template/Materiels/add.ctp
... | ... | @@ -7,9 +7,24 @@ |
7 | 7 | |
8 | 8 | <?php |
9 | 9 | echo $this->Form->input('designation', ['label' => 'Désignation']); |
10 | + | |
10 | 11 | echo $this->Form->input('sur_categorie_id', ['label' => 'Domaine', 'options' => $surCategories, 'empty' => 'Choisir un domaine']); |
11 | - echo $this->Form->input('categorie_id', ['label' => 'Catégorie', 'options' => $categories, 'empty' => 'Choisir une catégorie']); | |
12 | - echo $this->Form->input('sous_categorie_id', ['label' => 'Sous-catégorie', 'options' => $sousCategories, 'empty' => 'Choisir une sous-catégorie']); | |
12 | + | |
13 | + // if a domaine is selected, reduce the categories list to this domaine | |
14 | + $categs = $categories; | |
15 | + if (isset ( $this->request->data['sur_categorie_id'] ) && ($this->request->data['sur_categorie_id'] != '')) { | |
16 | + $categs = $categs->where(['sur_categorie_id =' => $this->request->data['sur_categorie_id']]); | |
17 | + } | |
18 | + echo $this->Form->input('categorie_id', ['label' => 'Catégorie', 'options' => $categs, 'empty' => 'Choisir une catégorie']); | |
19 | + | |
20 | + // by default, list is empty | |
21 | + $souscategs = []; | |
22 | + // if a categ is selected, update sous-categs list for this categ (only) | |
23 | + if (isset ( $this->request->data['categorie_id'] ) && ($this->request->data['categorie_id'] != '')) { | |
24 | + $souscategs = $sousCategories; | |
25 | + $souscategs = $souscategs->where(['categorie_id' => $this->request->data['categorie_id']]); | |
26 | + } | |
27 | + echo $this->Form->input('sous_categorie_id', ['label' => 'Sous-catégorie', 'options' => $souscategs, 'empty' => 'Choisir une sous-catégorie']); | |
13 | 28 | |
14 | 29 | echo $this->Form->input('materiel_technique', ['label' => 'Technique']); |
15 | 30 | echo $this->Form->input('materiel_administratif', ['label' => 'Inventoriable (>800€)']); | ... | ... |
src/Template/Materiels/edit.ctp
... | ... | @@ -69,15 +69,30 @@ if (IS_VALIDATED) |
69 | 69 | 'disabled' => isReadonlyField ( 'sur_categorie_id', $myReadonlyFields ) |
70 | 70 | |
71 | 71 | ]); |
72 | + | |
73 | + $categs = $categories; | |
74 | + // if a domaine is selected, reduce the categories list to this domaine | |
75 | + if (isset ( $this->request->data['sur_categorie_id'] ) && ($this->request->data['sur_categorie_id'] != '')) { | |
76 | + $categs = $categs->where(['sur_categorie_id =' => $this->request->data['sur_categorie_id']]); | |
77 | + } | |
72 | 78 | echo $this->Form->input('categorie_id', [ |
73 | 79 | 'label' => 'Catégorie', |
74 | - 'options' => $categories, | |
80 | + 'options' => $categs, | |
75 | 81 | 'empty' => 'Choisir une catégorie', |
76 | 82 | 'disabled' => isReadonlyField('categorie_id', $myReadonlyFields) |
77 | 83 | ]); |
84 | + | |
85 | + // SOUS-CATEGORIES | |
86 | + // by default, list is empty | |
87 | + $souscategs = []; | |
88 | + // if a categ is selected, update sous-categs list for this categ (only) | |
89 | + if (isset ( $this->request->data['categorie_id'] ) && ($this->request->data['categorie_id'] != '')) { | |
90 | + $souscategs = $sousCategories; | |
91 | + $souscategs = $souscategs->where(['categorie_id' => $this->request->data['categorie_id']]); | |
92 | + } | |
78 | 93 | echo $this->Form->input('sous_categorie_id', [ |
79 | 94 | 'label' => 'Sous-catégorie', |
80 | - 'options' => $sousCategories, | |
95 | + 'options' => $souscategs, | |
81 | 96 | 'empty' => 'Choisir une sous-catégorie', |
82 | 97 | 'disabled' => isReadonlyField('sous_categorie_id', $myReadonlyFields) |
83 | 98 | ]); | ... | ... |
src/Template/Materiels/find.ctp
1 | 1 | |
2 | +<div class="index"> | |
3 | + <h2> | |
4 | + <i class="icon-search"></i> Recherche de matériel | |
5 | + </h2> | |
6 | +<?php | |
7 | +$r = isset ($_results); | |
8 | + | |
9 | +if ($r) { | |
10 | + echo '<div class="actions" style="margin-bottom: 20px; width: 100%; float: none; padding: 10px 0;">'; | |
11 | + echo $this->Html->link ( '<i class="icon-file"></i> Exporter la liste', [ | |
12 | + 'controller' => 'Materiels', | |
13 | + 'action' => 'export', | |
14 | + 'what' => 'search' | |
15 | + ], [ | |
16 | + 'title' => 'Editer le résultat de la recherche', | |
17 | + 'style' => 'margin-right: 15px', | |
18 | + 'escape' => false | |
19 | + ]); | |
20 | + echo '</div>'; | |
21 | +} | |
22 | +?> | |
23 | + | |
24 | + <h3 id="t_filter" style="cursor: pointer;"> | |
25 | + <i | |
26 | + class=<?php if ($r) echo '"icon-chevron-up"'; echo '"icon-chevron-down"'; ?> | |
27 | + style="font-size: 14px;" id="i_filter"></i> <span | |
28 | + style="text-decoration: underline;">Filtres</span> | |
29 | + </h3> | |
30 | + | |
31 | + <div id="filter" <?php if ($r) echo 'style="display: none;"'; ?>><?php | |
32 | + if (isset ( $_results )) | |
33 | + $selected = []; | |
34 | + else | |
35 | + $selected = [ | |
36 | + 'selected' => '' | |
37 | + ]; | |
38 | + function getSortLinkForColumnTitle($label, $fieldName) { | |
39 | + return "<th> | |
40 | + <input type='submit' class='sortable-submit-title' value='$label' onclick='url=document.URL; url=url.slice(0, url.lastIndexOf(\"/find\")+5); $(\"form\").attr(\"action\", url+\"/$fieldName/ASC\");'/> | |
41 | + </th>"; | |
42 | + } | |
43 | + | |
44 | + // FORMULAIRE DE RECHERCHE | |
45 | + echo $this->Form->create(); | |
46 | + | |
47 | + // -------Bouton recherche Haut--------- | |
48 | + echo $this->Form->submit ( 'Rechercher', ['style' => 'width: 20%']); | |
49 | + | |
50 | + // Designation | |
51 | + echo $this->Form->input ( 's_designation', ['label' => 'Désignation']); | |
52 | + | |
53 | + // Matériel administratif et/ou technique | |
54 | + $typeOptions = []; | |
55 | + echo $this->Form->input ( 's_matostype', [ | |
56 | + 'label' => 'Type', | |
57 | + 'empty' => 'Tous', | |
58 | + 'options' => [ | |
59 | + 'A' => 'Administratif', | |
60 | + 'T' => 'Technique', | |
61 | + 'AT' => 'Administratif et Technique', | |
62 | + 'AO' => 'Administratif seulement', | |
63 | + 'TO' => 'Technique seulement' | |
64 | + ], | |
65 | + 'style' => 'width: 280px' | |
66 | + ]); | |
67 | + | |
68 | + // DOMAINE | |
69 | + echo $this->Form->input ( 's_sur_categorie_id', [ | |
70 | + 'label' => 'Domaine', | |
71 | + 'empty' => 'Tous', | |
72 | + $selected, | |
73 | + 'options' => $s_sur_categories, | |
74 | + 'style' => 'width: 200px' | |
75 | + ]); | |
76 | + | |
77 | + // CATEGORIES | |
78 | + // by default, ALL categs | |
79 | + $categs = $s_categories; | |
80 | + | |
81 | + // if a domaine is selected, reduce the categories list to this domaine | |
82 | + if (isset ( $this->request->data['s_sur_categorie_id'] ) && ($this->request->data['s_sur_categorie_id'] != '')) { | |
83 | + $categs = $categs->where(['sur_categorie_id =' => $this->request->data['s_sur_categorie_id']]); | |
84 | + } | |
85 | + | |
86 | + echo $this->Form->input ( 's_categorie_id', [ | |
87 | + 'label' => 'Catégorie', | |
88 | + 'empty' => 'Toutes', | |
89 | + 'style' => 'width: 200px', | |
90 | + 'options' => $categs | |
91 | + ]); | |
92 | + | |
93 | + // SOUS-CATEGORIES | |
94 | + // by default, list is empty | |
95 | + $souscategs = []; | |
96 | + // if a categ is selected, update sous-categs list for this categ (only) | |
97 | + if (isset ( $this->request->data['s_categorie_id'] ) && ($this->request->data['s_categorie_id'] != '')) { | |
98 | + $souscategs = $s_sous_categories; | |
99 | + $souscategs = $souscategs->where(['categorie_id' => $this->request->data['s_categorie_id']]); | |
100 | + } | |
101 | + | |
102 | + echo $this->Form->input ( 's_sous_categorie_id', [ | |
103 | + 'label' => 'Sous-catégorie', | |
104 | + 'empty' => 'Toutes', | |
105 | + 'style' => 'width: 200px', | |
106 | + 'options' => $souscategs | |
107 | + ]); | |
108 | + | |
109 | + | |
110 | + // STATUT | |
111 | + echo $this->Form->input ( 's_status', [ | |
112 | + 'label' => 'Statut', | |
113 | + 'empty' => 'Tous', | |
114 | + $selected, | |
115 | + 'options' => [ | |
116 | + 'CREATED' => 'Créé', | |
117 | + 'VALIDATED' => 'Validé', | |
118 | + 'TOBEARCHIVED' => 'À archiver', | |
119 | + 'ARCHIVED' => 'Archivé' | |
120 | + ], | |
121 | + 'style' => 'width: 200px' | |
122 | + ]); | |
123 | + | |
124 | + // Groupe metier et thematique | |
125 | + echo $this->Form->input ( 's_groupes_metier_id', [ | |
126 | + 'label' => 'Groupe Métier', | |
127 | + 'empty' => 'Tous', | |
128 | + $selected, | |
129 | + 'options' => $s_groupes_metiers, | |
130 | + 'style' => 'width: 200px' | |
131 | + ]); | |
132 | + echo $this->Form->input ( 's_groupes_thematique_id', [ | |
133 | + 'label' => 'Groupe Thematique', | |
134 | + 'empty' => 'Tous', | |
135 | + $selected, | |
136 | + 'options' => $s_groupes_thematiques, | |
137 | + 'style' => 'width: 200px' | |
138 | + ]); | |
139 | + | |
140 | + // Autres champs | |
141 | + echo $this->Form->input ( 's_numero_commande', [ | |
142 | + 'label' => 'N° BC' | |
143 | + ]); | |
144 | + echo $this->Form->input ( 's_numero_laboratoire', [ | |
145 | + 'label' => 'N° interne (labo)' | |
146 | + ]); | |
147 | + | |
148 | + //ORGANISME | |
149 | + $orgas = $s_organismes; | |
150 | + echo $this->Form->input ( 's_organisme_id', [ | |
151 | + 'label' => 'Organisme', | |
152 | + 'empty' => 'Toutes', | |
153 | + 'style' => 'width: 200px', | |
154 | + 'options' => $orgas | |
155 | + ]); | |
156 | + | |
157 | + echo $this->Form->input ( 's_nom_responsable', [ | |
158 | + 'label' => 'Responsable' | |
159 | + ]); | |
160 | + echo $this->Form->input ( 's_numero_inventaire_organisme', [ | |
161 | + 'label' => 'N° inventaire organisme' | |
162 | + ]); | |
163 | + echo $this->Form->input ( 's_numero_inventaire_old', [ | |
164 | + 'label' => 'N° inventaire (ancien)' | |
165 | + ]); | |
166 | + | |
167 | + // Date acquisition | |
168 | + echo "<u>DATE d'achat:</u>"; | |
169 | + echo $this->Form->input ( 's_date_acquisition', [ | |
170 | + 'placeholder' => 'Cliquez pour selectionner une date', | |
171 | + 'label' => '- Date exacte', | |
172 | + 'class' => 'datepicker' | |
173 | + ]); | |
174 | + echo $this->Form->input ( 's_periode_acquisition1', [ | |
175 | + 'placeholder' => 'Cliquez pour selectionner une date', | |
176 | + 'label' => '- Date Début', | |
177 | + 'class' => 'datepicker' | |
178 | + ]); | |
179 | + echo $this->Form->input ( 's_periode_acquisition2', [ | |
180 | + 'placeholder' => 'Cliquez pour selectionner une date', | |
181 | + 'label' => '- Date Fin', | |
182 | + 'class' => 'datepicker' | |
183 | + ]); | |
184 | + | |
185 | + echo "<u>MONTANT :</u>"; | |
186 | + echo $this->Form->input ( 's_prix_ht', ['label' => '- Montant exact']); | |
187 | + echo $this->Form->input ( 's_prix_ht_sup', ['label' => '- Montant sup. ou égal à']); | |
188 | + echo $this->Form->input ( 's_prix_ht_inf', ['label' => '- Montant inf. ou égal à']); | |
189 | + | |
190 | + // CHAMP DE RECHERCHE GENERIQUE | |
191 | + echo $this->Form->input ( 's_all', ['label' => 'TOUS LES CHAMPS' ]); | |
192 | + | |
193 | + // -------Bouton recherche Bas--------- | |
194 | + echo $this->Form->submit('Rechercher', ['style' => 'width: 20%']); | |
195 | + echo '<br/><br/><br/>'; | |
196 | + ?> | |
197 | + </div> | |
198 | + <!-- RESULT DISPLAY --> | |
199 | + <h3 id="t_result" style="cursor: pointer;"> | |
200 | + <i | |
201 | + class=<?php if ($r) echo '"icon-chevron-down"'; echo '"icon-chevron-up"'; ?> | |
202 | + style="font-size: 14px;" id="i_result"></i> <span | |
203 | + style="text-decoration: underline;">Résultats <?php if ($r) echo '('.sizeof($_results).')'; ?></span> | |
204 | + </h3> | |
205 | + <div id="result" <?php if (!$r) echo 'style="display: none;"'; ?>> | |
206 | + <?php if (isset($_results) && sizeof($_results) != 0) { ?> | |
207 | + <table cellpadding="0" cellspacing="0"> | |
208 | + <thead> | |
209 | + <tr> | |
210 | + <!--Désignation--> | |
211 | + <?php echo getSortLinkForColumnTitle('Désignation','designation');?> | |
212 | + | |
213 | + <!--Numéro IRAP--> | |
214 | + <?php echo getSortLinkForColumnTitle('Numéro interne (labo)','numero_laboratoire'); ?> | |
215 | + | |
216 | + <!--Catégorie--> | |
217 | + <?php echo getSortLinkForColumnTitle('Catégorie','Categorie.id');?> | |
218 | + | |
219 | + <!--Responsable--> | |
220 | + <?php echo getSortLinkForColumnTitle('Responsable','nom_responsable'); ?> | |
221 | + | |
222 | + <!--Statut--> | |
223 | + <?php echo getSortLinkForColumnTitle('Statut','status'); ?> | |
224 | + | |
225 | + <!--Date--> | |
226 | + <?php echo getSortLinkForColumnTitle('Date','date_acquisition'); ?> | |
227 | + | |
228 | + <th style="width: 20px;"></th> | |
229 | + <th style="width: 20px;"></th> | |
230 | + <th style="width: 20px;"></th> | |
231 | + </tr> | |
232 | + </thead> | |
233 | + <tbody> | |
234 | + <!-- Affichage des lignes de données --> | |
235 | + <?php | |
236 | + foreach ( $_results as $material ) : | |
237 | + echo '<tr>'; | |
238 | + | |
239 | + echo '<td class="smallText">'; | |
240 | + echo $this->Html->link ( h($material->designation), [ | |
241 | + 'action' => 'view', | |
242 | + $material->id | |
243 | + ], ['title' => 'Détails']); | |
244 | + echo '</td>'; | |
245 | + echo '<td class="smallText">'; | |
246 | + echo $material->numero_laboratoire; | |
247 | + echo '</td>'; | |
248 | + echo '<td class="smallText">'; | |
249 | + echo $this->Html->link ( $material->nom, [ | |
250 | + 'controller' => 'categories', | |
251 | + 'action' => 'view', | |
252 | + $material->id | |
253 | + ]); | |
254 | + echo '</td>'; | |
255 | + echo '<td class="smallText">'; | |
256 | + echo $material->nom_responsable; | |
257 | + echo '</td>'; | |
258 | + echo '<td class="smallText">'; | |
259 | + echo $material->status; | |
260 | + echo '</td>'; | |
261 | + echo '<td class="smallText">'; | |
262 | + echo date ( "d-m-Y", strtotime ( $material->date_acquisition )); | |
263 | + echo '</td>'; | |
264 | + | |
265 | + /* | |
266 | + * ACTION 'edit' | |
267 | + */ | |
268 | + echo '<td class="actions" style="padding: 6px 0;">'; | |
269 | + | |
270 | + echo $this->Html->link('<i class="icon-pencil"></i>', | |
271 | + ['action' => 'edit', $material->id], | |
272 | + ['title' => 'Éditer', 'style' => 'margin: 0 2px', 'escape' => false] | |
273 | + ); | |
274 | + echo '</td>'; | |
275 | + | |
276 | + echo '<td class="actions" style="padding: 6px 0;">'; | |
277 | + | |
278 | + if(h($material->status) == 'CREATED') { | |
279 | + echo $this->Form->postLink('<i class="icon-ok-sign"></i>', | |
280 | + ['action' => 'statusValidated', $material->id], | |
281 | + ['title' => 'Valider', 'style' => 'margin: 0 2px', 'escape' => false, | |
282 | + 'confirm' => __('Êtes-vous sur de vouloir validé # {0}?', $material->designation)]); | |
283 | + } | |
284 | + else if ($material->status == 'VALIDATED' && $material->nom_responsable == $username) { | |
285 | + echo $this->Form->postLink('<i class="icon-inbox"></i>', | |
286 | + ['action' => 'statusToBeArchived', $material->id], | |
287 | + ['title' => 'Demander la sortie de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, | |
288 | + 'confirm' => __('Êtes-vous sur de vouloir faire une demande d\'archive # {0}?', $material->designation)]); | |
289 | + | |
290 | + } | |
291 | + else if (h($material->status) == 'VALIDATED'){ | |
292 | + echo $this->Form->postLink('<i class="icon-inbox"></i>', | |
293 | + ['action' => 'statusArchived', $material->id], | |
294 | + ['title' => 'Sortir de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, | |
295 | + 'confirm' => __('Êtes-vous sur de vouloir archivé # {0}?', $material->designation)]); | |
296 | + } | |
297 | + echo '</td>'; | |
298 | + | |
299 | + /* | |
300 | + * ACTION 'delete' | |
301 | + */ | |
302 | + // Seul un materiel CREATED peut être supprimer | |
303 | + if ($material->status == 'CREATED') { | |
304 | + echo '<td class="actions" style="padding: 6px 0;">'; | |
305 | + echo $this->Form->postLink(__('<i class="icon-trash"></i>'), | |
306 | + ['action' => 'delete', $material->id], | |
307 | + ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $material->id)] | |
308 | + ); | |
309 | + echo '</td>'; | |
310 | + } | |
311 | + | |
312 | + echo '<tr>'; | |
313 | + endforeach; | |
314 | + echo '</tbody>'; | |
315 | + echo '</table>'; | |
316 | + | |
317 | + } else { | |
318 | + echo 'Aucun résultats pour cette recherche.'; | |
319 | + } | |
320 | + ?> | |
321 | + </div> | |
322 | + | |
323 | + <?php | |
324 | + echo $this->Form->end(); | |
325 | + ?> | |
326 | +</div> | |
2 | 327 | |
3 | 328 | |
4 | 329 | |
... | ... | @@ -6,4 +331,5 @@ |
6 | 331 | |
7 | 332 | <div class="actions"> |
8 | 333 | <?php echo $this->element('menu') ?> |
9 | -</div> | |
10 | 334 | \ No newline at end of file |
335 | +</div> | |
336 | + | ... | ... |
src/Template/Materiels/index.ctp
... | ... | @@ -13,6 +13,8 @@ |
13 | 13 | <th><?= $this->Paginator->sort('date_acquisition', 'Date Achat') ?></th> |
14 | 14 | <th><?= $this->Paginator->sort('etiquette', 'Et') ?></th> |
15 | 15 | <th class="actions"><?= __('') ?></th> |
16 | + <th class="actions"><?= __('') ?></th> | |
17 | + <th class="actions"><?= __('') ?></th> | |
16 | 18 | </tr> |
17 | 19 | </thead> |
18 | 20 | <tbody> |
... | ... | @@ -30,14 +32,37 @@ |
30 | 32 | |
31 | 33 | <td class="actions" style="padding: 6px 0;"> |
32 | 34 | <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $materiel->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> |
33 | - | |
35 | + </td> | |
36 | + <td class="actions" style="padding: 6px 0;"> | |
34 | 37 | <?php |
35 | - //A implementer --> bouton valider/archivé | |
36 | - //$this->Html->link(__('<i class="icon-eye-open"></i>'), ['action' => 'view', $materiel->id], ['title' => 'Visualiser', 'style' => 'margin: 0 2px', 'escape' => false ]) | |
37 | - | |
38 | - //A implementer --> bouton suppression caché si matériel validé | |
38 | + if(h($materiel->status) == 'CREATED') { | |
39 | + echo $this->Form->postLink('<i class="icon-ok-sign"></i>', | |
40 | + ['action' => 'statusValidated', $materiel->id], | |
41 | + ['title' => 'Valider', 'style' => 'margin: 0 2px', 'escape' => false, | |
42 | + 'confirm' => __('Êtes-vous sur de vouloir validé # {0}?', $materiel->designation)]); | |
43 | + } | |
44 | + else if (h($materiel->status) == 'VALIDATED' && h($materiel->nom_responsable) == $username) { | |
45 | + echo $this->Form->postLink('<i class="icon-inbox"></i>', | |
46 | + ['action' => 'statusToBeArchived', $materiel->id], | |
47 | + ['title' => 'Demander la sortie de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, | |
48 | + 'confirm' => __('Êtes-vous sur de vouloir faire une demande d\'archive # {0}?', $materiel->designation)]); | |
49 | + | |
50 | + } | |
51 | + else if (h($materiel->status) == 'VALIDATED'){ | |
52 | + echo $this->Form->postLink('<i class="icon-inbox"></i>', | |
53 | + ['action' => 'statusArchived', $materiel->id], | |
54 | + ['title' => 'Sortir de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, | |
55 | + 'confirm' => __('Êtes-vous sur de vouloir archivé # {0}?', $materiel->designation)]); | |
56 | + } | |
57 | + | |
39 | 58 | ?> |
40 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $materiel->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $materiel->id)]) ?> | |
59 | + </td> | |
60 | + <td class="actions" style="padding: 6px 0;"> | |
61 | + <?php | |
62 | + if (h($materiel->status) == 'CREATED') { | |
63 | + echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $materiel->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $materiel->designation)]); | |
64 | + } | |
65 | + ?> | |
41 | 66 | </td> |
42 | 67 | </tr> |
43 | 68 | <?php endforeach; ?> | ... | ... |
src/Template/Suivis/index.ctp
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | <tbody> |
17 | 17 | <?php foreach ($suivis as $suivi): ?> |
18 | 18 | <tr> |
19 | - <td><?php echo 'Suivi '.$this->Number->format($suivi->id) ?></td> | |
19 | + <td><?php echo $this->Html->link('Suivi '.$this->Number->format($suivi->id), ['action' => 'view', $suivi->id])?></td> | |
20 | 20 | <td><?= $suivi->has('materiel') ? $this->Html->link($suivi->materiel->designation, ['controller' => 'Materiels', 'action' => 'view', $suivi->materiel->id]) : '' ?></td> |
21 | 21 | <td><?= $suivi->has('materiel') ? h($suivi->materiel->numero_laboratoire) : '' ?></td> |
22 | 22 | <td><?= h($suivi->date_controle) ?></td> | ... | ... |