Commit 087b29e7d3fe30a2bfbb71c0e96b0798af3ad27e
1 parent
f63eabb2
Exists in
master
and in
1 other branch
GROSSE REFACTORISATION => vues et actions génériques (+ bugfixes acl)
- Vue 'index' générique utilisée par défaut pour plusieurs entités annexes : - catégories - type_documents - organismes - ... - boutons edit et delete génériques sur la vue détaillée générique (view) de toutes les entités - Action 'delete' générique pour presque toutes les entités - bugfixes acl sur "autres listes" v5.2.23-3.7.9
Showing
36 changed files
with
713 additions
and
573 deletions
Show diff stats
CHANGELOG
... | ... | @@ -13,6 +13,14 @@ CHANGEMENTS |
13 | 13 | |
14 | 14 | |
15 | 15 | ------- |
16 | +03/11/2021 NEWS#6 (v5.2.22) : | |
17 | + | |
18 | +- Domaines, Catégories, et Sous-Catégories enfin gérables plus facilement | |
19 | + | |
20 | +(TODO) - Champs obligatoires, modifiables, et readonly, désormais configurables via page web | |
21 | + | |
22 | + | |
23 | +------- | |
16 | 24 | 13/09/2021 NEWS#5 (v5) : |
17 | 25 | |
18 | 26 | - Documentation en ligne (install et technique) grandement mise à jour, pour une progression plus logique |
... | ... | @@ -27,14 +35,12 @@ CHANGEMENTS |
27 | 35 | |
28 | 36 | - Recherche des matériels plus fonctionnelle et résultats affichés exactement comme la liste des matériels (même colonnes pertinentes) |
29 | 37 | |
30 | -- Correction de nombreux bugs... | |
31 | - | |
32 | 38 | - Page "Gestion des fournisseurs" enrichie (/fournisseurs/index) avec : |
33 | 39 | => (superadmin) Bouton "Nettoyer la liste complète" (nettoyage "automagique" de la liste par suppression intelligente des doublons et espaces en trop) |
34 | 40 | => (administratif) Bouton "Remplacer" un fournisseur par un autre |
35 | 41 | |
36 | -- Ajout de la notion d'"utilisateur" en plus de la notion d'"acheteur" : | |
37 | - => L'"acheteur" commande un matériel pour un "utilisateur" destinataire du bien (par défaut, lui-même), | |
42 | +- Ajout de la notion "d'utilisateur" en plus de la notion "d'acheteur" : | |
43 | + => "L'acheteur" commande un matériel pour un "utilisateur" destinataire du bien (par défaut, lui-même), | |
38 | 44 | => peut aussi être juste la précision d'une destination quelconque (local technique, manip...) |
39 | 45 | => le but est seulement de préciser QUI utilise ce bien, ou à QUOI il est destiné exactement |
40 | 46 | |
... | ... | @@ -352,10 +358,25 @@ Commencer à implémenter le nouveau workflow v5 : |
352 | 358 | |
353 | 359 | ======= TODO ======= |
354 | 360 | |
355 | - PRIO : | |
356 | - - config via page web !!! | |
357 | - - tests ok | |
358 | - | |
361 | + | |
362 | + *) Quand on supprime un matos de “ma liste”, il faut revenir à “ma liste”, pas à “tous les matos” | |
363 | + | |
364 | + *) TEST_WEB ne marche pas avec docker | |
365 | + => utiliser plutot localhost:8081 | |
366 | +(update doc) | |
367 | +Mais ca serait mieux de faire localhost:8080 pour le site web et :8081 pour phpmyadmin (et non pas l’inverse !!) | |
368 | + | |
369 | + *) LDAP trou sécu (autres labos) : user se connecte avec bad mdp | |
370 | + | |
371 | + *) DOMPDF : pb Qrcode absent sur fiche pdf (mais présent sur page web), alors que le QrCode est bien généré et que le chemin dans le pdf est OK !!! | |
372 | +Par contre, ok avec FPDF | |
373 | + | |
374 | + *) Check extension ldap dans page web installation | |
375 | + | |
376 | + *) Augmenter taille upload de mon labo | |
377 | + | |
378 | + *) Créer une page qui liste les gestionnaires | |
379 | + | |
359 | 380 | *) Stats de connexion |
360 | 381 | - le tri des autres colonnes ne marche plus |
361 | 382 | |
... | ... | @@ -437,6 +458,29 @@ Commencer à implémenter le nouveau workflow v5 : |
437 | 458 | Gérer les autorisations (ACL) via fichier de conf |
438 | 459 | |
439 | 460 | |
461 | + | |
462 | + == DEPRECATED == | |
463 | + | |
464 | + Erreurs qu'on ne voit que si on met | |
465 | + 'errorLevel' => E_ALL, | |
466 | + dans app.php : | |
467 | + | |
468 | + | |
469 | + Deprecated (16384): Plugin::load() is deprecated. Use Application::addPlugin() instead. This method will be removed in 4.0.0. - /Users/epallier/_PROJ/_W/PROJ_LABINVENT/SOURCE/labinvent202101/config/bootstrap.php, line: 260 | |
470 | + You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. [CORE/src/Core/functions.php, line 311] | |
471 | + | |
472 | +Deprecated (16384): Plugin::load() is deprecated. Use Application::addPlugin() instead. This method will be removed in 4.0.0. - /Users/epallier/_PROJ/_W/PROJ_LABINVENT/SOURCE/labinvent202101/config/bootstrap.php, line: 265 | |
473 | + You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. [CORE/src/Core/functions.php, line 311] | |
474 | + | |
475 | +Deprecated (16384): Plugin::load() is deprecated. Use Application::addPlugin() instead. This method will be removed in 4.0.0. - /Users/epallier/_PROJ/_W/PROJ_LABINVENT/SOURCE/labinvent202101/config/bootstrap.php, line: 278 | |
476 | + You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. [CORE/src/Core/functions.php, line 311] | |
477 | + | |
478 | +Deprecated (16384): Plugin::bootstrap() is deprecated. This method will be removed in 4.0.0. - /Users/epallier/_PROJ/_W/PROJ_LABINVENT/SOURCE/labinvent202101/vendor/cakephp/cakephp/src/Core/Plugin.php, line: 173 | |
479 | + You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. [CORE/src/Core/functions.php, line 311] | |
480 | + | |
481 | + | |
482 | + | |
483 | + | |
440 | 484 | |
441 | 485 | == CAN WAIT == |
442 | 486 | |
... | ... | @@ -451,9 +495,44 @@ Commencer à implémenter le nouveau workflow v5 : |
451 | 495 | |
452 | 496 | |
453 | 497 | |
498 | + | |
499 | + | |
500 | + | |
501 | + | |
502 | + | |
503 | +TODO : | |
504 | + | |
505 | +- resp_credit non modifiable ??? (sur inventirap.irap) | |
506 | + - (b) bugfix champ "responsable crédit" non enregistré (modif perdue) !!! | |
507 | + + valider fiche hyp2 | |
508 | + | |
509 | + | |
510 | +- projets/index generic | |
511 | +- emprunts/index generic | |
512 | +- stats/index generic | |
513 | +- users/index generic | |
514 | + | |
515 | +- fusionner elem/button_add_edit et MyHelper echoActionButton... | |
516 | +(ne garder que elem/) | |
517 | +- séparer elem/button_add, button_edit, button_delete, et button_tout_court (générique) | |
518 | + | |
519 | +- short_role AppController ligne 819 => généraliser | |
520 | + | |
521 | + | |
454 | 522 | ======= CHANGES ======= |
455 | 523 | |
456 | 524 | ------- |
525 | +05/11/2021 v5.2.23-3.7.9 | |
526 | + - GROSSE REFACTORISATION => vues et actions génériques | |
527 | + - (e) Vue 'index' générique utilisée par défaut pour plusieurs entités annexes : | |
528 | + - catégories | |
529 | + - type_documents | |
530 | + - organismes | |
531 | + - ... | |
532 | + - (e) boutons edit et delete génériques sur la vue détaillée générique (view) de toutes les entités | |
533 | + - (i) Action 'delete' générique pour presque toutes les entités | |
534 | + | |
535 | +------- | |
457 | 536 | 02/11/2021 v5.2.22-3.7.9 |
458 | 537 | - (e) gestion plus simple des catégories, domaines, et sous-catégories |
459 | 538 | - (e) chaque utilisateur peut voir sa fiche profil |
... | ... | @@ -478,6 +557,8 @@ Commencer à implémenter le nouveau workflow v5 : |
478 | 557 | 23/10/2021 v5.2.18-3.7.9 |
479 | 558 | - (i) changé mot-clé "except" par "sauf" dans fichier config champs readonly (et adapté traitement) |
480 | 559 | - nouvelle exception si mot-clé "sauf" mal utilisé |
560 | + => Exemple pour interdire la modif du fournisseur (sauf pour le role Administration) : | |
561 | + "- fournisseur_id (sauf Administration)" | |
481 | 562 | |
482 | 563 | ------- |
483 | 564 | 22/10/2021 v5.2.17-3.7.9 | ... | ... |
README.md
... | ... | @@ -52,8 +52,8 @@ Logiciel testé et validé sur les configurations suivantes : |
52 | 52 | |
53 | 53 | -------------------------------------------------------------------------------------------- |
54 | 54 | |
55 | -Date: 02/11/2021 | |
56 | -Version: v5.2.22-3.7.9 | |
55 | +Date: 05/11/2021 | |
56 | +Version: v5.2.23-3.7.9 | |
57 | 57 | |
58 | 58 | |
59 | 59 | HISTORIQUE DES CHANGEMENTS DE VERSION : voir le fichier CHANGES.txt (ou la page web /pages/changes) | ... | ... |
config/bootstrap.php
... | ... | @@ -265,17 +265,24 @@ Plugin::load('Migrations'); |
265 | 265 | Plugin::load('Dompdf'); |
266 | 266 | |
267 | 267 | |
268 | +// DebugKit (cf https://book.cakephp.org/debugkit/3/fr/index.html) | |
268 | 269 | // Only try to load DebugKit in development mode |
269 | 270 | // Debug Kit should not be installed on a production system |
270 | 271 | if (Configure::read('debug')) { |
272 | + // Whitelister mes sites locaux : | |
273 | + Configure::write('DebugKit.safeTld', ['localhost', 'dev', 'invalid', 'test', 'example', 'local', 'devv']); | |
271 | 274 | /* (EP 20200316 added pour éviter l'erreur suivante retrouvée dans logs/error.log : |
272 | 275 | * 2020-03-16 12:20:28 Warning: DebugKit is disabling itself as your host `labinvent.devv` is not in the known safe list of top-level-domains |
273 | 276 | * (localhost, invalid, test, example, local). If you would like to force DebugKit on |
274 | 277 | * use the `DebugKit.forceEnable` Configure option. |
275 | 278 | */ |
276 | - Configure::write('DebugKit.forceEnable', true); | |
279 | + //Configure::write('DebugKit.forceEnable', true); | |
280 | + // Autres options dispo : | |
281 | + //Configure::write('DebugKit.ignoreAuthorization', true); | |
282 | + //Configure::write('DebugKit.panels', ['DebugKit.Packages' => false]); | |
277 | 283 | // Maintenant on peut charger DebugKit normalement |
278 | - Plugin::load('DebugKit', ['bootstrap' => true]); | |
284 | + //Plugin::load('DebugKit', ['bootstrap' => true]); | |
285 | + Plugin::load('DebugKit', ['bootstrap' => true, 'routes' => true]); | |
279 | 286 | } |
280 | 287 | |
281 | 288 | ... | ... |
src/Controller/AppController.php
... | ... | @@ -388,6 +388,7 @@ class AppController extends Controller |
388 | 388 | return $controller_name.'s'; |
389 | 389 | } |
390 | 390 | |
391 | + // SousCategories => SousCategoriesController instance | |
391 | 392 | protected function getControllerInstanceForName($controller_name) { |
392 | 393 | $c = 'App\\Controller\\'.$controller_name.'Controller'; |
393 | 394 | return new $c(); |
... | ... | @@ -2081,6 +2082,58 @@ class AppController extends Controller |
2081 | 2082 | */ |
2082 | 2083 | |
2083 | 2084 | } // beforeFilter() |
2085 | + | |
2086 | + | |
2087 | + /** | |
2088 | + * Delete generic method | |
2089 | + * | |
2090 | + * @param string|null $id | |
2091 | + * Entity id. | |
2092 | + * @return \Cake\Network\Response|null Redirects to index. | |
2093 | + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. | |
2094 | + */ | |
2095 | + //public function delete_generic($id = null, $return_to_materiel_view=false) | |
2096 | + public function delete_generic($id = null, $parent_to_return_to=null, $parent_fk_name=null) | |
2097 | + { | |
2098 | + | |
2099 | + // Construction des infos nécessaires | |
2100 | + $this->request->allowMethod([ | |
2101 | + 'post', | |
2102 | + 'delete' | |
2103 | + ]); | |
2104 | + $tableName = $this->name; | |
2105 | + $tableInstance = TableRegistry::getTableLocator()->get($tableName); | |
2106 | + $entity = $tableInstance->get($id); | |
2107 | + //if ($return_to_materiel_view) $matos_id = $entity->materiel_id; | |
2108 | + //if ($parent_to_return_to) $parent_id = $entity->sur_categorie_id; | |
2109 | + if ($parent_to_return_to) $parent_id = $entity->$parent_fk_name; | |
2110 | + | |
2111 | + // Suppression de l'entité $id | |
2112 | + if ($tableInstance->delete($entity)) { | |
2113 | + $this->Flash->success(__("L'entité a bien été supprimée")); | |
2114 | + } else { | |
2115 | + $this->Flash->error(__("L'entité n'a pas pu être supprimée")); | |
2116 | + } | |
2117 | + | |
2118 | + // Retour à la vue détaillée du matériel qui contenait cette entité | |
2119 | + if ($parent_to_return_to) { | |
2120 | + return $this->redirect([ | |
2121 | + //'controller' => 'materiels', | |
2122 | + //'controller' => 'sur-categories', | |
2123 | + 'controller' => $parent_to_return_to, | |
2124 | + 'action' => 'view', | |
2125 | + $parent_id | |
2126 | + ]); | |
2127 | + } | |
2128 | + // Retour à la liste des entités (index) | |
2129 | + else | |
2130 | + $this->setAction('index'); | |
2131 | + /* equivaut à | |
2132 | + return $this->redirect([ | |
2133 | + 'action' => 'index' | |
2134 | + ]); | |
2135 | + */ | |
2136 | + } | |
2084 | 2137 | |
2085 | 2138 | |
2086 | 2139 | /** |
... | ... | @@ -2089,20 +2142,32 @@ class AppController extends Controller |
2089 | 2142 | * @return \Cake\Network\Response|null |
2090 | 2143 | * TODO: à terminer... |
2091 | 2144 | */ |
2092 | - public function index_generic($entity_plural, $fields_names) | |
2145 | + public function index_generic($entity_plural, $fields_names=[], $contained_controllers=null) | |
2093 | 2146 | { |
2094 | 2147 | $controller_name = $this->getName(); |
2095 | 2148 | //debug($controller_name); |
2096 | - | |
2149 | + | |
2097 | 2150 | $this->paginate = [ |
2098 | - 'contain' => [ | |
2099 | - 'SurCategories' | |
2100 | - ] | |
2151 | + 'contain' => $contained_controllers | |
2152 | + //'contain' => ['SurCategories'] | |
2101 | 2153 | ]; |
2102 | 2154 | //$categories = $this->paginate($this->Categories); |
2103 | 2155 | $entities = $this->paginate($this->$controller_name); |
2156 | + | |
2157 | + // nb entités par page | |
2158 | + //debug(count($entities)); | |
2104 | 2159 | |
2105 | - $this->set(compact('entities', 'entity_plural', 'fields_names')); | |
2160 | + // Nb total entités total | |
2161 | + $this->set('nb_entities', $this->$controller_name->find()->count()); | |
2162 | + | |
2163 | + $CAN_ADD = $this->isAuthorizedActionForCurrentUser('add'); | |
2164 | + | |
2165 | + $this->set(compact('CAN_ADD', 'entities', 'entity_plural', 'fields_names')); | |
2166 | + | |
2167 | + // Pas bien..., mais pratique : | |
2168 | + // on passe le controleur à la vue index pour qu'elle | |
2169 | + // puisse appeler la methode isAuthorizedAction() | |
2170 | + $this->set("controller", $this); | |
2106 | 2171 | |
2107 | 2172 | /* (EP) Pas nécessaire |
2108 | 2173 | $this->set('_serialize', [ |
... | ... | @@ -2111,6 +2176,7 @@ class AppController extends Controller |
2111 | 2176 | */ |
2112 | 2177 | } |
2113 | 2178 | |
2179 | + | |
2114 | 2180 | public function index_groups($group_type1, $group_type2, $lab_website_url=null) { |
2115 | 2181 | |
2116 | 2182 | // https://book.cakephp.org/3/fr/controllers/components/pagination.html |
... | ... | @@ -2125,7 +2191,9 @@ class AppController extends Controller |
2125 | 2191 | // on affiche l'url vers la page des Groupes métiers sur le site web de l'IRAP |
2126 | 2192 | $lab_website_url = ($this->confLabinvent->labNameShort != 'IRAP') ? null : $lab_website_url; |
2127 | 2193 | |
2128 | - $this->set(compact('group_type1', 'group_type2', 'lab_website_url', 'groups')); | |
2194 | + $CAN_ADD = $this->isAuthorizedActionForCurrentUser('add'); | |
2195 | + | |
2196 | + $this->set(compact('CAN_ADD', 'group_type1', 'group_type2', 'lab_website_url', 'groups')); | |
2129 | 2197 | |
2130 | 2198 | /* Utile seulement pour JSON |
2131 | 2199 | $this->set('_serialize', [ |
... | ... | @@ -2136,7 +2204,8 @@ class AppController extends Controller |
2136 | 2204 | |
2137 | 2205 | //public function view_generic($id, $associated_entity_types, $parent_entity_controller_name=[]) { |
2138 | 2206 | //public function view_generic($id, $associated_entity_types, $containavirer=[]) { |
2139 | - public function view_generic($id, $child_entity_types=[], $sub_controller=null, $sub_controller_singular=null) { | |
2207 | + public function view_generic($id, $child_entity_types=[], | |
2208 | + $sub_controller_class_name=null, $sub_controller=null, $sub_controller_singular=null) { | |
2140 | 2209 | |
2141 | 2210 | //debug($contain_children); |
2142 | 2211 | // ex: SurCategories |
... | ... | @@ -2390,6 +2459,10 @@ class AppController extends Controller |
2390 | 2459 | ]; |
2391 | 2460 | */ |
2392 | 2461 | |
2462 | + // - can edit or delete | |
2463 | + $CAN_EDIT = $this->isAuthorizedActionForCurrentUser('edit', $id); | |
2464 | + $CAN_DELETE = $this->isAuthorizedActionForCurrentUser('delete', $id); | |
2465 | + | |
2393 | 2466 | // On passe ces variables à la vue |
2394 | 2467 | //$entities_list = [$categories, $materiels]; |
2395 | 2468 | //$entity_article = 'le '; |
... | ... | @@ -2400,10 +2473,19 @@ class AppController extends Controller |
2400 | 2473 | //$entity_name = $entity->nom; |
2401 | 2474 | $entity_name_field_label = $this->getNameFieldLabel(); |
2402 | 2475 | $entity_name = $entity->$entity_name_field_label; |
2476 | + | |
2477 | + // Sous-controleur défini ? => définir l'autorisation d'ajouter une sous-entité | |
2478 | + if ($sub_controller) { | |
2479 | + $sub_controller_instance = $this->getControllerInstanceForName($sub_controller_class_name); | |
2480 | + $CAN_ADD_SUB_ENTITY = $sub_controller_instance->isAuthorizedActionForCurrentUser('add'); | |
2481 | + } | |
2482 | + | |
2403 | 2483 | $this->set(compact( |
2404 | 2484 | |
2405 | 2485 | 'id', |
2406 | 2486 | |
2487 | + 'CAN_EDIT', 'CAN_DELETE', | |
2488 | + | |
2407 | 2489 | 'fields_label', |
2408 | 2490 | |
2409 | 2491 | // Infos sur l'entité courante |
... | ... | @@ -2422,7 +2504,8 @@ class AppController extends Controller |
2422 | 2504 | |
2423 | 2505 | // Optionnel : sous-controleur pour pouvoir ajouter une sous-entité (ex: ajouter une sous-catégorie à une catégorie) |
2424 | 2506 | 'sub_controller', |
2425 | - 'sub_controller_singular' | |
2507 | + 'sub_controller_singular', | |
2508 | + 'CAN_ADD_SUB_ENTITY' | |
2426 | 2509 | |
2427 | 2510 | )); |
2428 | 2511 | //debug($this->viewVars);exit; |
... | ... | @@ -3001,6 +3084,7 @@ class AppController extends Controller |
3001 | 3084 | ] |
3002 | 3085 | ); |
3003 | 3086 | }; |
3087 | + | |
3004 | 3088 | $this->set(compact('getActionButton', 'echoActionButton')); |
3005 | 3089 | |
3006 | 3090 | // Pass this function to all views (en fait, seulement add.ctp et edit.ctp) |
... | ... | @@ -3762,6 +3846,7 @@ class AppController extends Controller |
3762 | 3846 | */ |
3763 | 3847 | |
3764 | 3848 | $mailList = []; |
3849 | + $gestionnaire_ref_email = ''; | |
3765 | 3850 | |
3766 | 3851 | /* |
3767 | 3852 | * 4.2.1 - Envoi général (uniquement pour les entités liées à un matériel) |
... | ... | @@ -3788,7 +3873,6 @@ class AppController extends Controller |
3788 | 3873 | $mailList[] = $materiel->email_responsable; |
3789 | 3874 | |
3790 | 3875 | // - (2) G(R) - Ajout du Gestionnaire de Référence du matos (s'il y en a un) |
3791 | - $gestionnaire_ref_email = ''; | |
3792 | 3876 | if ($materiel->gestionnaire_id) { |
3793 | 3877 | $gestionnaire_ref_email = TableRegistry::getTableLocator()->get('Users')->get($materiel->gestionnaire_id)->email; |
3794 | 3878 | $mailList[] = $gestionnaire_ref_email; | ... | ... |
src/Controller/CategoriesController.php
... | ... | @@ -105,9 +105,10 @@ class CategoriesController extends AppController |
105 | 105 | $this->index_generic( |
106 | 106 | 'catégories', |
107 | 107 | [ |
108 | - 'nom'=>'Nom', | |
109 | - 'sur_categorie_id' => 'Domaine', | |
110 | - ] | |
108 | + //'nom'=>['nice_name'=>'Nom'], | |
109 | + 'sur_categorie_id'=>['nice_name'=>'Domaine', 'contained_entity_name'=>'sur_category', 'controller_name'=>'SurCategories'], | |
110 | + ], | |
111 | + ['SurCategories'] | |
111 | 112 | ); |
112 | 113 | |
113 | 114 | /* |
... | ... | @@ -141,7 +142,7 @@ class CategoriesController extends AppController |
141 | 142 | //return parent::view($id, $associated_entity_types); |
142 | 143 | //return $this->view_generic($id, $associated_entity_types, 'SurCategories'); |
143 | 144 | //return $this->view_generic($id, $child_entity_types, ['SurCategories']); |
144 | - return $this->view_generic($id, $child_entity_types, 'sous-categories', ' une sous-catégorie'); | |
145 | + return $this->view_generic($id, $child_entity_types, 'SousCategories', 'sous-categories', ' une sous-catégorie'); | |
145 | 146 | |
146 | 147 | /* |
147 | 148 | $category = $this->Categories->get($id, [ |
... | ... | @@ -249,6 +250,8 @@ class CategoriesController extends AppController |
249 | 250 | */ |
250 | 251 | public function delete($id = null) |
251 | 252 | { |
253 | + $this->delete_generic($id, 'sur-categories', 'sur_categorie_id'); | |
254 | + /* | |
252 | 255 | $this->request->allowMethod([ |
253 | 256 | 'post', |
254 | 257 | 'delete' |
... | ... | @@ -262,6 +265,7 @@ class CategoriesController extends AppController |
262 | 265 | return $this->redirect([ |
263 | 266 | 'action' => 'index' |
264 | 267 | ]); |
268 | + */ | |
265 | 269 | } |
266 | 270 | |
267 | 271 | public function getBySurCategorie() | ... | ... |
src/Controller/EmpruntsController.php
... | ... | @@ -219,6 +219,21 @@ class EmpruntsController extends AppController |
219 | 219 | */ |
220 | 220 | public function index() |
221 | 221 | { |
222 | + /* | |
223 | + $this->index_generic( | |
224 | + 'prêts', | |
225 | + [ | |
226 | + //'nom'=>['nice_name'=>'Nom'], | |
227 | + 'materiel_id'=>[ | |
228 | + 'nice_name'=>'Materiel', | |
229 | + 'contained_entity_name'=>'materiel', | |
230 | + 'controller_name'=>'Materiels' | |
231 | + ], | |
232 | + ], | |
233 | + ['Materiels', 'Sites'] | |
234 | + ); | |
235 | + */ | |
236 | + | |
222 | 237 | $this->paginate = [ |
223 | 238 | 'contain' => [ |
224 | 239 | 'Materiels', |
... | ... | @@ -648,6 +663,8 @@ class EmpruntsController extends AppController |
648 | 663 | */ |
649 | 664 | public function delete($id = null) |
650 | 665 | { |
666 | + $this->delete_generic($id, 'materiels', 'materiel_id'); | |
667 | + /* | |
651 | 668 | $this->request->allowMethod([ |
652 | 669 | 'post', |
653 | 670 | 'delete' |
... | ... | @@ -659,10 +676,6 @@ class EmpruntsController extends AppController |
659 | 676 | $this->Flash->error(__('L\'emprunt n\'a pas pu être supprimé.')); |
660 | 677 | } |
661 | 678 | $this->setAction('index'); |
662 | - /* equivaut à | |
663 | - return $this->redirect([ | |
664 | - 'action' => 'index' | |
665 | - ]); | |
666 | 679 | */ |
667 | 680 | } |
668 | 681 | ... | ... |
src/Controller/FournisseursController.php
... | ... | @@ -532,6 +532,8 @@ class FournisseursController extends AppController |
532 | 532 | */ |
533 | 533 | public function delete($id = null) |
534 | 534 | { |
535 | + $this->delete_generic($id); | |
536 | + /* | |
535 | 537 | $this->request->allowMethod([ |
536 | 538 | 'post', |
537 | 539 | 'delete' |
... | ... | @@ -545,5 +547,6 @@ class FournisseursController extends AppController |
545 | 547 | return $this->redirect([ |
546 | 548 | 'action' => 'index' |
547 | 549 | ]); |
550 | + */ | |
548 | 551 | } |
549 | 552 | } | ... | ... |
src/Controller/GroupesMetiersController.php
... | ... | @@ -222,6 +222,8 @@ class GroupesMetiersController extends AppController |
222 | 222 | */ |
223 | 223 | public function delete($id = null) |
224 | 224 | { |
225 | + $this->delete_generic($id); | |
226 | + /* | |
225 | 227 | $this->request->allowMethod([ |
226 | 228 | 'post', |
227 | 229 | 'delete' |
... | ... | @@ -235,5 +237,6 @@ class GroupesMetiersController extends AppController |
235 | 237 | return $this->redirect([ |
236 | 238 | 'action' => 'index' |
237 | 239 | ]); |
240 | + */ | |
238 | 241 | } |
239 | 242 | } | ... | ... |
src/Controller/GroupesThematiquesController.php
... | ... | @@ -217,6 +217,8 @@ class GroupesThematiquesController extends AppController |
217 | 217 | */ |
218 | 218 | public function delete($id = null) |
219 | 219 | { |
220 | + $this->delete_generic($id); | |
221 | + /* | |
220 | 222 | $this->request->allowMethod([ |
221 | 223 | 'post', |
222 | 224 | 'delete' |
... | ... | @@ -230,5 +232,6 @@ class GroupesThematiquesController extends AppController |
230 | 232 | return $this->redirect([ |
231 | 233 | 'action' => 'index' |
232 | 234 | ]); |
235 | + */ | |
233 | 236 | } |
234 | 237 | } | ... | ... |
src/Controller/MaterielsController.php
... | ... | @@ -2922,7 +2922,7 @@ class MaterielsController extends AppController { |
2922 | 2922 | public function delete($id = null) |
2923 | 2923 | { |
2924 | 2924 | |
2925 | - $DEBUG = true; | |
2925 | + $DEBUG = false; | |
2926 | 2926 | |
2927 | 2927 | // $this->request->allowMethod(['post', 'delete']); |
2928 | 2928 | $verb = 'supprimé'; |
... | ... | @@ -2944,8 +2944,8 @@ class MaterielsController extends AppController { |
2944 | 2944 | |
2945 | 2945 | //if ($materiel->has('sur_category')) debug($materiel->sur_category->nom); |
2946 | 2946 | //debug($materiel); exit; |
2947 | - //if ( !$DEBUG && $this->Materiels->delete($materiel) ) { | |
2948 | - if ( $this->Materiels->delete($materiel) ) { | |
2947 | + //if ( $this->Materiels->delete($materiel) ) { | |
2948 | + if ( !$DEBUG && $this->Materiels->delete($materiel) ) { | |
2949 | 2949 | $this->Flash->success(__("Le matériel a bien été $verb")); |
2950 | 2950 | /* |
2951 | 2951 | this->ilog("Materiel $verb = '$materiel' (id=$id)"); |
... | ... | @@ -2956,6 +2956,8 @@ class MaterielsController extends AppController { |
2956 | 2956 | } |
2957 | 2957 | else |
2958 | 2958 | $this->Flash->error(__("Le matériel n'a pas pu être $verb")); |
2959 | + | |
2960 | + // Retour à la liste des matos | |
2959 | 2961 | return $this->redirect([ |
2960 | 2962 | 'action' => 'index' |
2961 | 2963 | ]); | ... | ... |
src/Controller/OrganismesController.php
... | ... | @@ -71,12 +71,23 @@ class OrganismesController extends AppController |
71 | 71 | */ |
72 | 72 | public function index() |
73 | 73 | { |
74 | + $this->index_generic( | |
75 | + 'organismes' | |
76 | + /* | |
77 | + [ | |
78 | + 'nom'=>['nice_name'=>'Nom'], | |
79 | + ] | |
80 | + */ | |
81 | + ); | |
82 | + | |
83 | + /* | |
74 | 84 | $organismes = $this->paginate($this->Organismes); |
75 | 85 | |
76 | 86 | $this->set(compact('organismes')); |
77 | 87 | $this->set('_serialize', [ |
78 | 88 | 'organismes' |
79 | 89 | ]); |
90 | + */ | |
80 | 91 | } |
81 | 92 | |
82 | 93 | /** |
... | ... | @@ -181,6 +192,8 @@ class OrganismesController extends AppController |
181 | 192 | */ |
182 | 193 | public function delete($id = null) |
183 | 194 | { |
195 | + $this->delete_generic($id); | |
196 | + /* | |
184 | 197 | $this->request->allowMethod([ |
185 | 198 | 'post', |
186 | 199 | 'delete' |
... | ... | @@ -194,5 +207,6 @@ class OrganismesController extends AppController |
194 | 207 | return $this->redirect([ |
195 | 208 | 'action' => 'index' |
196 | 209 | ]); |
210 | + */ | |
197 | 211 | } |
198 | 212 | } | ... | ... |
src/Controller/ProjetsController.php
... | ... | @@ -211,6 +211,8 @@ class ProjetsController extends AppController { |
211 | 211 | */ |
212 | 212 | public function delete($id = null) |
213 | 213 | { |
214 | + $this->delete_generic($id); | |
215 | + /* | |
214 | 216 | $this->request->allowMethod(['post', 'delete']); |
215 | 217 | $projet = $this->Projets->get($id); |
216 | 218 | if ($this->Projets->delete($projet)) { |
... | ... | @@ -220,5 +222,8 @@ class ProjetsController extends AppController { |
220 | 222 | } |
221 | 223 | |
222 | 224 | return $this->redirect(['action' => 'index']); |
225 | + */ | |
223 | 226 | } |
227 | + | |
228 | + | |
224 | 229 | } | ... | ... |
src/Controller/SitesController.php
... | ... | @@ -59,12 +59,19 @@ class SitesController extends AppController |
59 | 59 | */ |
60 | 60 | public function index() |
61 | 61 | { |
62 | + | |
63 | + $this->index_generic( | |
64 | + 'sites' | |
65 | + ); | |
66 | + | |
67 | + /* | |
62 | 68 | $sites = $this->paginate($this->Sites); |
63 | 69 | |
64 | 70 | $this->set(compact('sites')); |
65 | 71 | $this->set('_serialize', [ |
66 | 72 | 'sites' |
67 | 73 | ]); |
74 | + */ | |
68 | 75 | } |
69 | 76 | |
70 | 77 | /** |
... | ... | @@ -174,6 +181,8 @@ class SitesController extends AppController |
174 | 181 | */ |
175 | 182 | public function delete($id = null) |
176 | 183 | { |
184 | + $this->delete_generic($id); | |
185 | + /* | |
177 | 186 | $this->request->allowMethod([ |
178 | 187 | 'post', |
179 | 188 | 'delete' |
... | ... | @@ -187,5 +196,6 @@ class SitesController extends AppController |
187 | 196 | return $this->redirect([ |
188 | 197 | 'action' => 'index' |
189 | 198 | ]); |
199 | + */ | |
190 | 200 | } |
191 | 201 | } | ... | ... |
src/Controller/SousCategoriesController.php
... | ... | @@ -94,6 +94,16 @@ class SousCategoriesController extends AppController |
94 | 94 | */ |
95 | 95 | public function index() |
96 | 96 | { |
97 | + $this->index_generic( | |
98 | + 'sous-catégories', | |
99 | + [ | |
100 | + //'nom'=>['nice_name'=>'Nom'], | |
101 | + 'categorie_id'=>['nice_name'=>'Catégorie', 'contained_entity_name'=>'category', 'controller_name'=>'Categories'], | |
102 | + ], | |
103 | + ['Categories'] | |
104 | + ); | |
105 | + | |
106 | + /* | |
97 | 107 | $this->paginate = [ |
98 | 108 | 'contain' => [ |
99 | 109 | 'Categories' |
... | ... | @@ -105,6 +115,7 @@ class SousCategoriesController extends AppController |
105 | 115 | $this->set('_serialize', [ |
106 | 116 | 'sousCategories' |
107 | 117 | ]); |
118 | + */ | |
108 | 119 | } |
109 | 120 | |
110 | 121 | /** |
... | ... | @@ -222,6 +233,9 @@ class SousCategoriesController extends AppController |
222 | 233 | */ |
223 | 234 | public function delete($id = null) |
224 | 235 | { |
236 | + $this->delete_generic($id, 'categories', 'categorie_id'); | |
237 | + | |
238 | + /* | |
225 | 239 | $this->request->allowMethod([ |
226 | 240 | 'post', |
227 | 241 | 'delete' |
... | ... | @@ -235,6 +249,7 @@ class SousCategoriesController extends AppController |
235 | 249 | return $this->redirect([ |
236 | 250 | 'action' => 'index' |
237 | 251 | ]); |
252 | + */ | |
238 | 253 | } |
239 | 254 | |
240 | 255 | public function getByCategorie() | ... | ... |
src/Controller/StatsController.php
... | ... | @@ -102,6 +102,8 @@ class StatsController extends AppController |
102 | 102 | //public function delete($id = null) |
103 | 103 | { |
104 | 104 | $id = [$year,$user_id]; |
105 | + $this->delete_generic($id); | |
106 | + /* | |
105 | 107 | $this->request->allowMethod(['post', 'delete']); |
106 | 108 | $stat = $this->Stats->get($id); |
107 | 109 | if ($this->Stats->delete($stat)) { |
... | ... | @@ -109,7 +111,7 @@ class StatsController extends AppController |
109 | 111 | } else { |
110 | 112 | $this->Flash->error(__('The stat could not be deleted. Please, try again.')); |
111 | 113 | } |
112 | - | |
113 | 114 | return $this->redirect(['action' => 'index']); |
115 | + */ | |
114 | 116 | } |
115 | 117 | } | ... | ... |
src/Controller/SuivisController.php
... | ... | @@ -1005,6 +1005,8 @@ class SuivisController extends AppController |
1005 | 1005 | */ |
1006 | 1006 | public function delete($id = null) |
1007 | 1007 | { |
1008 | + $this->delete_generic($id, 'materiels', 'materiel_id'); | |
1009 | + /* | |
1008 | 1010 | $this->request->allowMethod([ |
1009 | 1011 | 'post', |
1010 | 1012 | 'delete' |
... | ... | @@ -1024,6 +1026,7 @@ class SuivisController extends AppController |
1024 | 1026 | 'action' => 'view', |
1025 | 1027 | $parent_id |
1026 | 1028 | ]); |
1029 | + */ | |
1027 | 1030 | } |
1028 | 1031 | |
1029 | 1032 | /** | ... | ... |
src/Controller/SurCategoriesController.php
... | ... | @@ -168,10 +168,22 @@ class SurCategoriesController extends AppController |
168 | 168 | */ |
169 | 169 | public function index() |
170 | 170 | { |
171 | + | |
172 | + $this->index_generic( | |
173 | + 'domaines', | |
174 | + [ | |
175 | + //'nom'=>['nice_name'=>'Nom'], | |
176 | + //'sur_categorie_id'=>['nice_name'=>'Domaine', 'contained_entity_name'=>'sur_category', 'controller_name'=>'SurCategories'], | |
177 | + ] | |
178 | + //['SurCategories'] | |
179 | + ); | |
180 | + | |
181 | + /* | |
171 | 182 | $surCategories = $this->paginate($this->SurCategories); |
172 | 183 | |
173 | 184 | $this->set('nb_entities', $this->SurCategories->find()->count()); |
174 | 185 | $this->set(compact('surCategories')); |
186 | + */ | |
175 | 187 | /* (EP) inutile |
176 | 188 | $this->set('_serialize', [ |
177 | 189 | 'surCategories' |
... | ... | @@ -195,7 +207,7 @@ class SurCategoriesController extends AppController |
195 | 207 | 'Materiels' |
196 | 208 | ]; |
197 | 209 | //return parent::view($id, $associated_entity_types); |
198 | - return $this->view_generic($id, $child_entity_types, 'categories', ' une catégorie'); | |
210 | + return $this->view_generic($id, $child_entity_types, 'Categories', 'categories', ' une catégorie'); | |
199 | 211 | |
200 | 212 | } |
201 | 213 | |
... | ... | @@ -274,6 +286,8 @@ class SurCategoriesController extends AppController |
274 | 286 | */ |
275 | 287 | public function delete($id = null) |
276 | 288 | { |
289 | + $this->delete_generic($id); | |
290 | + /* | |
277 | 291 | $this->request->allowMethod([ |
278 | 292 | 'post', |
279 | 293 | 'delete' |
... | ... | @@ -287,6 +301,7 @@ class SurCategoriesController extends AppController |
287 | 301 | return $this->redirect([ |
288 | 302 | 'action' => 'index' |
289 | 303 | ]); |
304 | + */ | |
290 | 305 | } |
291 | 306 | |
292 | 307 | ... | ... |
src/Controller/TypeDocumentsController.php
... | ... | @@ -82,12 +82,18 @@ class TypeDocumentsController extends AppController |
82 | 82 | */ |
83 | 83 | public function index() |
84 | 84 | { |
85 | + $this->index_generic( | |
86 | + 'types de documents' | |
87 | + ); | |
88 | + | |
89 | + /* | |
85 | 90 | $typeDocuments = $this->paginate($this->TypeDocuments); |
86 | 91 | |
87 | 92 | $this->set(compact('typeDocuments')); |
88 | 93 | $this->set('_serialize', [ |
89 | 94 | 'typeDocuments' |
90 | 95 | ]); |
96 | + */ | |
91 | 97 | } |
92 | 98 | |
93 | 99 | /** |
... | ... | @@ -189,6 +195,8 @@ class TypeDocumentsController extends AppController |
189 | 195 | */ |
190 | 196 | public function delete($id = null) |
191 | 197 | { |
198 | + $this->delete_generic($id); | |
199 | + /* | |
192 | 200 | $this->request->allowMethod([ |
193 | 201 | 'post', |
194 | 202 | 'delete' |
... | ... | @@ -202,5 +210,8 @@ class TypeDocumentsController extends AppController |
202 | 210 | return $this->redirect([ |
203 | 211 | 'action' => 'index' |
204 | 212 | ]); |
213 | + */ | |
205 | 214 | } |
215 | + | |
216 | + | |
206 | 217 | } | ... | ... |
src/Controller/TypeSuivisController.php
... | ... | @@ -27,7 +27,10 @@ class TypeSuivisController extends AppController |
27 | 27 | */ |
28 | 28 | protected function setAuthorizations() { |
29 | 29 | // Actions autorisées seulement à superadmin |
30 | - foreach (['add', 'edit', 'delete'] as $action) $this->setAuthorizationsForAction($action, -1, ['super'=>0]); | |
30 | + foreach (['add', 'edit', 'delete'] as $action) | |
31 | + $this->setAuthorizationsForAction($action, -1, ['super'=>0]); | |
32 | + //$this->setAuthorizationsForAction('delete', -1, ['admin'=>0]); | |
33 | + | |
31 | 34 | } |
32 | 35 | |
33 | 36 | /** |
... | ... | @@ -73,12 +76,22 @@ class TypeSuivisController extends AppController |
73 | 76 | */ |
74 | 77 | public function index() |
75 | 78 | { |
79 | + $this->index_generic( | |
80 | + 'types de suivis', | |
81 | + [ | |
82 | + 'is_regular'=>['nice_name'=>'Régulier ?'], | |
83 | + 'is_metro'=>['nice_name'=>'Métrologie ?'], | |
84 | + ] | |
85 | + ); | |
86 | + | |
87 | + /* | |
76 | 88 | $typeSuivis = $this->paginate($this->TypeSuivis); |
77 | 89 | |
78 | 90 | $this->set(compact('typeSuivis')); |
79 | 91 | $this->set('_serialize', [ |
80 | 92 | 'typeSuivis' |
81 | 93 | ]); |
94 | + */ | |
82 | 95 | } |
83 | 96 | |
84 | 97 | /** |
... | ... | @@ -181,6 +194,8 @@ class TypeSuivisController extends AppController |
181 | 194 | */ |
182 | 195 | public function delete($id = null) |
183 | 196 | { |
197 | + $this->delete_generic($id); | |
198 | + /* | |
184 | 199 | $this->request->allowMethod([ |
185 | 200 | 'post', |
186 | 201 | 'delete' |
... | ... | @@ -194,5 +209,6 @@ class TypeSuivisController extends AppController |
194 | 209 | return $this->redirect([ |
195 | 210 | 'action' => 'index' |
196 | 211 | ]); |
212 | + */ | |
197 | 213 | } |
198 | 214 | } | ... | ... |
src/Controller/UsersController.php
... | ... | @@ -834,6 +834,8 @@ class UsersController extends AppController { |
834 | 834 | */ |
835 | 835 | public function delete($id = null) |
836 | 836 | { |
837 | + $this->delete_generic($id); | |
838 | + /* | |
837 | 839 | $this->request->allowMethod([ |
838 | 840 | 'post', |
839 | 841 | 'delete' |
... | ... | @@ -847,6 +849,7 @@ class UsersController extends AppController { |
847 | 849 | return $this->redirect([ |
848 | 850 | 'action' => 'index' |
849 | 851 | ]); |
852 | + */ | |
850 | 853 | } |
851 | 854 | |
852 | 855 | // called from Javascript (Ajax) | ... | ... |
src/Template/Common/index_gen.ctp
1 | 1 | <?php |
2 | 2 | |
3 | +/* | |
4 | + * *************************** | |
5 | + * VUE LISTE GÉNÉRIQUE (index) | |
6 | + * *************************** | |
7 | + */ | |
8 | + | |
9 | + | |
3 | 10 | $DEBUG=false; |
4 | 11 | //$DEBUG=true; |
5 | 12 | |
6 | 13 | // Variables passées par le contrôleur |
14 | + | |
15 | +// pas bien, mais pratique | |
16 | +$controller = $controller; | |
17 | + | |
18 | +$CAN_ADD = $CAN_ADD; | |
7 | 19 | $role = $role; |
20 | +$nb_entities = $nb_entities; | |
8 | 21 | $entities = $entities; |
9 | 22 | $entity_plural = $entity_plural; |
10 | 23 | $fields_names = $fields_names; |
11 | 24 | |
25 | +// Ajout du champ "nom" automatique | |
26 | +$new_fields_names['nom'] = ['nice_name'=>'Nom']; | |
27 | +foreach ($fields_names as $f=>$infos) $new_fields_names[$f] = $infos; | |
28 | +$fields_names = $new_fields_names; | |
29 | +//debug($fields_names); | |
30 | + | |
12 | 31 | ?> |
13 | 32 | |
14 | 33 | <div class="entities index"> |
15 | 34 | |
16 | - <?php echo "<h2><i class='icon-list'></i> Liste des $entity_plural</h2>"; ?> | |
35 | + <?php echo "<h2><i class='icon-list'></i> Liste des $entity_plural ($nb_entities)</h2>"; | |
36 | + if ($CAN_ADD) echo $this->element('button_add'); | |
37 | + ?> | |
17 | 38 | |
18 | - <?=$this->element('button_add'); ?> | |
19 | 39 | |
20 | 40 | <table style="border-collapse: separate; border-spacing: 0;width: 270px;"> |
21 | 41 | |
42 | + <!-- EN-TETES --> | |
22 | 43 | <thead> |
23 | 44 | <tr> |
45 | + <!-- Boutons action --> | |
24 | 46 | <th class="actions"><?= __('') ?></th> |
25 | - <!-- | |
26 | - <th><?= $this->Paginator->sort('sur_categorie_id', 'Domaine') ?></th> | |
27 | - --> | |
47 | + | |
48 | + <!-- Noms des champs --> | |
28 | 49 | <?php |
29 | - foreach ($fields_names as $fname=>$fnicename) | |
30 | - echo "<th>".$this->Paginator->sort($fname, $fnicename)."</th>"; | |
31 | - ?> | |
50 | + //foreach ($fields_names as $fname=>$fnicename) echo "<th>".$this->Paginator->sort($fname, $fnicename)."</th>"; | |
51 | + //foreach ($fields_names as $fname=>$infos) { | |
52 | + foreach ($fields_names as $fname=>$infos) { | |
53 | + echo "<th>".$this->Paginator->sort($fname, $infos['nice_name'])."</th>"; | |
54 | + } | |
55 | + ?> | |
56 | + | |
32 | 57 | </tr> |
33 | 58 | </thead> |
34 | 59 | |
60 | + <!-- DATA --> | |
35 | 61 | <tbody> |
36 | 62 | <?php foreach ($entities as $e): ?> |
37 | 63 | <tr> |
38 | 64 | |
39 | 65 | <!-- |
40 | - Actions edit / delete | |
41 | - --> | |
66 | + Boutons edit / delete | |
67 | + --> | |
42 | 68 | <td class="actions" style="padding: 6px 0; text-align: left;"> |
43 | - <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?> | |
44 | - <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $e->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> | |
45 | - <?php } ?> | |
46 | - | |
47 | - <?php if (in_array($role, ['Super Administrateur'])) { ?> | |
48 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $e->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $e->id)]) ?> | |
49 | - <?php } ?> | |
69 | + <?php | |
70 | + //debug(compact('id','CAN_EDIT','CAN_DELETE')); | |
71 | + $id = $e->id; | |
72 | + //$CAN_EDIT = in_array($role, ['Administration', 'Super Administrateur']); | |
73 | + $CAN_EDIT = $controller->isAuthorizedAction('edit', $id); | |
74 | + $CAN_DELETE = $controller->isAuthorizedAction('delete', $id); | |
75 | + //$CAN_DELETE=true; | |
76 | + $style_num=1; | |
77 | + $WITH_DIV = false; | |
78 | + echo $this->element('buttons_edit_del', compact('id','CAN_EDIT','CAN_DELETE', 'style_num', 'WITH_DIV')); | |
79 | + ?> | |
50 | 80 | </td> |
51 | 81 | |
52 | 82 | <!-- |
53 | - Data | |
83 | + DATA : affichage de chaque champ dans une colonne | |
84 | + <td class="smallText"><= $this->Html->link($e->nom, ['action' => 'view', $e->id]) ?></td> | |
85 | + <td class="smallText"><= $e->has('sur_category') ? $this->Html->link($e->sur_category->nom, ['controller' => 'SurCategories', 'action' => 'view', $e->sur_category->id]) : '' ?></td> | |
54 | 86 | --> |
55 | - <td class="smallText"><?= $this->Html->link($e->nom, ['action' => 'view', $e->id]) ?></td> | |
56 | - <td class="smallText"><?= $e->has('sur_category') ? $this->Html->link($e->sur_category->nom, ['controller' => 'SurCategories', 'action' => 'view', $e->sur_category->id]) : '' ?></td> | |
57 | 87 | <?php |
58 | - /* | |
59 | - //TODO: | |
60 | 88 | foreach ($e->toArray() as $fname=>$fval) { |
89 | + if (! in_array($fname, array_keys($fields_names)) ) continue; | |
90 | + //<td class="smallText"><?= $this->Html->link($e->nom, ['action' => 'view', $e->id]) ></td> | |
91 | + echo "<td class='smallText'>"; | |
92 | + // - Si c'est le champ "nom", on l'affiche comme un lien | |
93 | + if ($fname == 'nom') | |
94 | + echo $this->Html->link($fval, ['action' => 'view', $e->id]); | |
95 | + // - Si le champ est boolean => on affiche oui/non | |
96 | + elseif ( (substr($fname,0,3)=='is_') && ($fval===false || $fval===true) ) | |
97 | + echo $fval ? "Oui" : "Non"; | |
98 | + // - Si le champ n'est pas une FK (terminant par '_id') => on l'affiche directement | |
99 | + elseif ( strpos($fname,'_id') !== strlen($fname)-3 ) | |
100 | + echo $fval; | |
101 | + // Si le champ est une FK => on récupère la valeur du 'contained' | |
102 | + else { | |
103 | + //$fval = $e->has('sur_category') ? $e->sur_category->nom : $fval; | |
104 | + $contained_entity_name = $fields_names[$fname]['contained_entity_name']; | |
105 | + $controller_name = $fields_names[$fname]['controller_name']; | |
106 | + $linkval = $e->has($contained_entity_name) ? $e->$contained_entity_name->nom : $fval; | |
107 | + //echo $this->Html->link($fval, ['controller' => $controller_name, 'action' => 'view', $e->sur_category->id]); | |
108 | + echo $this->Html->link($linkval, ['controller' => $controller_name, 'action' => 'view', $fval]); | |
109 | + /* | |
110 | + //debug($fname); | |
111 | + $parent_entity_infos = &$parent_entities_infos[$fname]; | |
112 | + //debug($parent_entity_infos); | |
113 | + $fk_contained_name = $parent_entity_infos['fk_contained_name']; | |
114 | + //debug($fk_contained_name); | |
115 | + //$fvalue = $associated_entity_infos['name']; | |
116 | + $fvalue = $entity->$fk_contained_name->nom; | |
117 | + $this->MyHelper->displayElement( | |
118 | + __(ucfirst($parent_entity_infos['type_name'])), | |
119 | + //$category->has('sur_category') ? $this->Html->link($category->sur_category->nom, [ | |
120 | + $this->Html->link($fvalue, [ | |
121 | + 'controller' => $parent_entity_infos['controller_name'], | |
122 | + //'controller' => 'SurCategories', | |
123 | + 'action' => 'view', | |
124 | + //$associated_entity_infos['id'] | |
125 | + $fval | |
126 | + //$category->sur_category->id | |
127 | + ]) | |
128 | + ); | |
129 | + */ | |
130 | + } | |
131 | + echo "</td>"; | |
61 | 132 | } |
62 | - */ | |
63 | 133 | ?> |
64 | 134 | |
65 | 135 | </tr> | ... | ... |
src/Template/Common/index_groups.ctp
1 | 1 | <?php |
2 | 2 | // Variables passées par le controleur |
3 | +$CAN_ADD = $CAN_ADD; | |
3 | 4 | /* |
4 | 5 | $group_type1 = 'thematique'; |
5 | 6 | $group_type2 = 'thématique'; |
... | ... | @@ -30,7 +31,7 @@ $groups = $groups; |
30 | 31 | if ($lab_website_url) |
31 | 32 | echo "=> <a href=$lab_website_url>Groupes {$group_type2}s sur le site web du laboratoire</a><br/><br/>"; |
32 | 33 | |
33 | - echo $this->element('button_add'); | |
34 | + if ($CAN_ADD) echo $this->element('button_add'); | |
34 | 35 | ?> |
35 | 36 | |
36 | 37 | <table style="border-collapse: separate; border-spacing: 0; width: 270px;"> | ... | ... |
src/Template/Common/view.ctp
1 | 1 | <?php |
2 | + | |
3 | +/* | |
4 | + * ****************************** | |
5 | + * VUE DÉTAILLÉE GÉNÉRIQUE (view) | |
6 | + * ****************************** | |
7 | + */ | |
8 | + | |
2 | 9 | /* |
3 | 10 | use App\Controller\SurCategoriesController; |
4 | 11 | use Cake\ORM\Entity; |
... | ... | @@ -11,6 +18,12 @@ $DEBUG=false; |
11 | 18 | |
12 | 19 | // Arguments passés par le contrôleur |
13 | 20 | |
21 | +$CAN_EDIT = $CAN_EDIT; | |
22 | +$CAN_DELETE = $CAN_DELETE; | |
23 | +// Optionnel (pour categories...) | |
24 | +$CAN_ADD_SUB_ENTITY = isset($CAN_ADD_SUB_ENTITY) ? $CAN_ADD_SUB_ENTITY : false; | |
25 | + | |
26 | + | |
14 | 27 | $role = $role; |
15 | 28 | |
16 | 29 | $id = $id; |
... | ... | @@ -58,56 +71,51 @@ if (isset($sub_controller)) { |
58 | 71 | --> |
59 | 72 | <div class="Entity view"> |
60 | 73 | |
61 | - <!-- | |
62 | - <h2>Détail domaine</h2> | |
63 | - --> | |
64 | - | |
65 | 74 | <h2>Informations sur <?=$entity_article.$entity_type_name_singular.' "'.$entity_name.'"'?></h2> |
66 | 75 | |
67 | 76 | <?= $this->Html->link("Voir toutes les entités (liste)", ['action'=>'index']) ?> |
68 | 77 | <br /> |
69 | 78 | <br /> |
70 | 79 | |
71 | - <table style="margin-bottom: 30px;"> | |
72 | - | |
73 | - <tr> | |
74 | - <th style="width: 250px;"></th> | |
75 | - <th></th> | |
76 | - </tr> | |
80 | + <div id="boutons" class="actions" style="margin-bottom:20px; width:100%; float:none; padding:5px 0;"> | |
77 | 81 | |
82 | + <!-- BOUTONS edit / delete --> | |
78 | 83 | <?php |
79 | - | |
80 | - // Lien Editer | |
81 | - if (in_array($role, [ | |
82 | - //'Administration Plus', | |
83 | - 'Administration', | |
84 | - 'Super Administrateur' | |
85 | - ])) { | |
86 | - echo $this->Html->link(__('<i class="icon-pencil"></i> Editer'), [ | |
87 | - 'action' => 'edit', | |
88 | - //$surCategory->id | |
89 | - $entity->id | |
90 | - ], [ | |
91 | - 'style' => 'margin-right: 40px; display: inline-block', | |
92 | - 'escape' => false, | |
93 | - 'onclick' => 'return true;' | |
94 | - ]); | |
95 | - } | |
84 | + | |
85 | + $bStyle = 'margin-right: 10px'; | |
86 | + | |
87 | + // Bouton Modifier | |
88 | + /* | |
89 | + $CAN_EDIT = in_array($role, [ | |
90 | + //'Administration Plus', | |
91 | + 'Administration', | |
92 | + 'Super Administrateur' | |
93 | + ]); | |
94 | + */ | |
95 | + if ($CAN_EDIT) $this->MyHelper->echoActionButton('icon-pencil', $bStyle, '', 'edit', $entity->id, | |
96 | + null, [], 'Modifier' | |
97 | + ); | |
98 | + | |
99 | + // - Lien Supprimer | |
100 | + if ($CAN_DELETE) $this->MyHelper->echoDeleteButton('', $entity->id); | |
101 | + | |
102 | + ?> | |
103 | + | |
104 | + </div> | |
105 | + | |
106 | + | |
107 | + <div id="FIELDS"> | |
108 | + | |
109 | + <table style="margin-bottom: 30px;"> | |
110 | + | |
111 | + <tr> | |
112 | + <!-- Label --> | |
113 | + <th style="width: 250px;"></th> | |
114 | + <!-- Value --> | |
115 | + <th></th> | |
116 | + </tr> | |
96 | 117 | |
97 | - // Lien Supprimer | |
98 | - if (in_array($role, [ | |
99 | - 'Super Administrateur' | |
100 | - ])) { | |
101 | - echo $this->Form->postLink(__('<i class="icon-trash"></i> Supprimer'), [ | |
102 | - 'action' => 'delete', | |
103 | - $entity->id | |
104 | - ], [ | |
105 | - 'style' => 'display: inline-block', | |
106 | - 'escape' => false, | |
107 | - 'confirm' => __('Êtes-vous sur de vouloir supprimer cette entité ?') | |
108 | - //'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $surCategory->id) | |
109 | - ]); | |
110 | - } | |
118 | + <?php | |
111 | 119 | |
112 | 120 | /* |
113 | 121 | * I - Affichage des champs de l'entité (nom, description, ...) |
... | ... | @@ -126,7 +134,7 @@ if (isset($sub_controller)) { |
126 | 134 | $fvalue = $fval; |
127 | 135 | // Si le champ n'est pas une FK (terminant par '_id') => on l'affiche directement |
128 | 136 | if ( strpos($fname,'_id') !== strlen($fname)-3 ) |
129 | - $this->MyHelper->displayElement(__($flabel), h($fvalue)); | |
137 | + $this->MyHelper->displayTableRowLabelAndValue(__($flabel), h($fvalue)); | |
130 | 138 | // Si le champ est une FK => on récupère la valeur du 'contained' |
131 | 139 | else { |
132 | 140 | //debug($fname); |
... | ... | @@ -136,7 +144,7 @@ if (isset($sub_controller)) { |
136 | 144 | //debug($fk_contained_name); |
137 | 145 | //$fvalue = $associated_entity_infos['name']; |
138 | 146 | $fvalue = $entity->$fk_contained_name->nom; |
139 | - $this->MyHelper->displayElement( | |
147 | + $this->MyHelper->displayTableRowLabelAndValue( | |
140 | 148 | __(ucfirst($parent_entity_infos['type_name'])), |
141 | 149 | //$category->has('sur_category') ? $this->Html->link($category->sur_category->nom, [ |
142 | 150 | $this->Html->link($fvalue, [ |
... | ... | @@ -153,42 +161,6 @@ if (isset($sub_controller)) { |
153 | 161 | } // if |
154 | 162 | } // foreach |
155 | 163 | |
156 | - //$displayElement(__('Nom'), h($entity_name)); | |
157 | - /* | |
158 | - $this->MyHelper->displayElement(__('Nom'), h($entity_name)); | |
159 | - $this->MyHelper->displayElement(__('Description'), h($entity->description)); | |
160 | - */ | |
161 | - // Affichage du nom de l'entité parente si elle existe | |
162 | - // (ex: Domaine pour une catégorie, ou catégorie pour une sous-catégorie) | |
163 | - //debug($entity->sur_category->getSource()); // 'SurCategories' | |
164 | - /* | |
165 | - $e = new SurCategory(); | |
166 | - debug($e->getSource()); | |
167 | - */ | |
168 | - /* | |
169 | - if($parent_entity_infos) | |
170 | - //$this->MyHelper->displayElement(__('Domaine'), h($entity->sur_category->nom)); | |
171 | - //$this->MyHelper->displayElement(__(ucfirst($parent_entity_type_name)), h($parent_entity_name)); | |
172 | - $this->MyHelper->displayElement( | |
173 | - __(ucfirst($parent_entity_infos['type_name'])), | |
174 | - //$category->has('sur_category') ? $this->Html->link($category->sur_category->nom, [ | |
175 | - $this->Html->link($parent_entity_infos['name'], [ | |
176 | - 'controller' => $parent_entity_infos['controller_name'], | |
177 | - //'controller' => 'SurCategories', | |
178 | - 'action' => 'view', | |
179 | - $parent_entity_infos['id'] | |
180 | - //$category->sur_category->id | |
181 | - ]) | |
182 | - ); | |
183 | - */ | |
184 | - /* | |
185 | - $this->MyHelper->displayElement(__('Domaine'), $this->Html->link($entity->sur_category->nom, [ | |
186 | - 'controller' => 'SurCategories', | |
187 | - 'action' => 'view', | |
188 | - $entity->sur_category->id | |
189 | - ]) | |
190 | - ); | |
191 | - */ | |
192 | 164 | ?> |
193 | 165 | |
194 | 166 | </table> |
... | ... | @@ -206,29 +178,27 @@ if (isset($sub_controller)) { |
206 | 178 | } |
207 | 179 | ?> |
208 | 180 | |
209 | - | |
210 | - <!-- Bouton "Ajouter" pour ajouter un nouvel élément (ssi autorisé) --> | |
181 | + </div> <!-- FIELDS --> | |
182 | + | |
183 | + | |
184 | + <!-- Bouton "Ajouter" pour ajouter un sous-élément --> | |
185 | + <div id="add_sub_entity"> | |
211 | 186 | <?php |
212 | 187 | if (isset($sub_controller)) { |
213 | - echo $this->element('button_add', compact( | |
188 | + if ($CAN_ADD_SUB_ENTITY) echo $this->element('button_add', compact( | |
214 | 189 | 'id', |
215 | 190 | 'sub_controller', |
216 | 191 | 'sub_controller_singular' |
217 | 192 | )); |
218 | - /* | |
219 | - echo $this->element('button_add', [ | |
220 | - 'id' => $id, | |
221 | - 'sub_controller' => $sub_controller, | |
222 | - 'sub_controller_singular' => $sub_controller_singular | |
223 | - ]); | |
224 | - */ | |
225 | 193 | //echo "<br />"; |
226 | 194 | } |
227 | 195 | ?> |
196 | + </div> <!-- add_sub_entity --> | |
228 | 197 | |
229 | 198 | |
230 | 199 | <!-- II - Affichage des entités associées "ENFANTS" (matériels, utilisateurs, ...) --> |
231 | - | |
200 | + <div id="associated_data"> | |
201 | + | |
232 | 202 | <?php |
233 | 203 | //debug($entity); |
234 | 204 | //debug($child_entities_list); |
... | ... | @@ -281,8 +251,11 @@ if (isset($sub_controller)) { |
281 | 251 | //$this->MyButton->displaySectionShowHide(true, 'Aucun matériel lié', 'materiels', 'Matériels', $materiels, 'designation', 'Materiels', 'matériel'); |
282 | 252 | } |
283 | 253 | ?> |
254 | + | |
255 | + </div> <!-- associated_data --> | |
256 | + | |
284 | 257 | |
285 | -</div> | |
258 | +</div> <!-- General div (Entity) --> | |
286 | 259 | |
287 | 260 | <!-- |
288 | 261 | <div class="actions"> | ... | ... |
src/Template/Documents/view.ctp
... | ... | @@ -16,15 +16,19 @@ $photo_formats = ['png','jpg','jpeg']; |
16 | 16 | |
17 | 17 | <h2>Détail document</h2> |
18 | 18 | |
19 | - <!-- Boutons Edit & Delete --> | |
20 | - <?=$this->element( | |
19 | + <?php | |
20 | + | |
21 | + // Boutons Edit & Delete | |
22 | + echo $this->element( | |
21 | 23 | 'buttons_edit_del', [ |
22 | 24 | 'id' => $document->id, |
23 | 25 | 'CAN_EDIT' => $CAN_EDIT, |
24 | 26 | 'CAN_DELETE' => $CAN_DELETE, |
25 | - ]);?> | |
27 | + 'style_num' => 2, | |
28 | + 'WITH_DIV' => true, | |
29 | + ]); | |
26 | 30 | |
27 | - <?php // Affichage photo | |
31 | + // Affichage Photo | |
28 | 32 | $doc_name = $document->materiel_id .'_' . $document->nom.'_'. $document->id . '.' . $document->type_doc; |
29 | 33 | // Seulement les photos : |
30 | 34 | //$is_doc_photo = $document->type_document->nom == 'Photo'; | ... | ... |
src/Template/Element/button_add.ctp
... | ... | @@ -22,6 +22,7 @@ if (isset($sub_controller)) { |
22 | 22 | //echo $this->request->controller; |
23 | 23 | //$entity = $this->request->controller; // controller name (Sites, Suivis, Organismes, ...) |
24 | 24 | $bStyle = 'margin-right: 10px'; |
25 | + /* | |
25 | 26 | $CAN_ADD = ( |
26 | 27 | // Admin et Superadmin ont tous les droits |
27 | 28 | //in_array($role, ['Administration Plus','Super Administrateur']) |
... | ... | @@ -31,6 +32,8 @@ if (isset($sub_controller)) { |
31 | 32 | //in_array($singularHumanName, ['Matériel','Suivi','Emprunt','Fournisseur']) |
32 | 33 | in_array($this->request->controller, ['Materiels','Suivis','Emprunts','Fournisseurs']) |
33 | 34 | ); |
34 | - if ($CAN_ADD) $echoActionButton($this->Html, 'icon-plus', $bStyle, ' Ajouter'.$entities_name, $controller, 'add', $id); | |
35 | + */ | |
36 | + //if ($CAN_ADD) | |
37 | + $echoActionButton($this->Html, 'icon-plus', $bStyle, ' Ajouter'.$entities_name, $controller, 'add', $id); | |
35 | 38 | ?> |
36 | 39 | </div> | ... | ... |
src/Template/Element/buttons_edit_del.ctp
1 | 1 | <!-- Boutons "Editer" et "Supprimer" (ssi autorisé) --> |
2 | 2 | |
3 | 3 | <?php |
4 | -// element parameters | |
4 | + | |
5 | +// Constantes | |
6 | +$STYLE1 = 'margin: 0 2px'; | |
7 | +$STYLE2 = 'margin-right: 40px; display: inline-block'; | |
8 | + | |
9 | +// Paramètres obligatoires | |
5 | 10 | $id = $id; |
6 | -$CAN_EDIT = $CAN_EDIT;; | |
11 | +$CAN_EDIT = $CAN_EDIT; | |
7 | 12 | $CAN_DELETE = $CAN_DELETE; |
8 | -?> | |
9 | 13 | |
10 | -<div id="boutons" class="actions" style="margin-bottom:5px; width:100%; float:none; padding:5px 0;"> | |
11 | - | |
12 | -<?php | |
13 | - /* | |
14 | - $CAN_EDIT = ( | |
15 | - // Admin et Superadmin ont tous les droits | |
16 | - //in_array($role, ['Administration Plus','Super Administrateur']) | |
17 | - in_array($role, ['Administration','Super Administrateur']) | |
18 | - || | |
19 | - // Ces listes sont modifiables par tout le monde | |
20 | - in_array($this->request->controller, ['Fournisseurs']) | |
21 | - //in_array($this->request->controller, ['Materiels','Suivis','Emprunts','Fournisseurs']) | |
22 | - ); | |
23 | - //$CAN_DEL = in_array($role, ['Administration', 'Super Administrateur']); | |
24 | - $CAN_DEL = $CAN_EDIT; | |
25 | - */ | |
26 | - /* | |
27 | - $bStyle = 'margin-right: 10px'; | |
28 | - $echoActionButton($this->Html, 'icon-plus', $bStyle, ' Ajouter', $this->request->controller, 'add', null); | |
29 | - */ | |
14 | +// Paramètres optionnels | |
15 | +// '' par défaut | |
16 | +$label_edit = isset($label_edit) ? $label_edit : ''; | |
17 | +// '' par défaut | |
18 | +$label_del = isset($label_del) ? $label_del : ''; | |
19 | +// false par défaut | |
20 | +$WITH_DIV = isset($WITH_DIV) ? $WITH_DIV : false; | |
21 | +// Style 1 par défaut | |
22 | +$style_num = isset($style_num) ? $style_num : 1; | |
23 | +$STYLE_EDIT = $style_num==1 ? $STYLE1 : $STYLE2; | |
24 | +$STYLE_DELETE = $style_num==1 ? $STYLE1 : 'display: inline-block'; | |
25 | + | |
26 | + | |
27 | +// <DIV> | |
28 | +if ($WITH_DIV) echo " | |
29 | +<div id='boutons' class='actions' style='margin-bottom:5px; width:100%; float:none; padding:5px 0;'>"; | |
30 | + | |
30 | 31 | if ($CAN_EDIT) echo $this->Html->link( |
31 | - __('<i class="icon-pencil"></i> Editer'), | |
32 | - //[ 'action' => 'edit', $site->id ], | |
32 | + __("<i class='icon-pencil'></i>$label_edit"), | |
33 | 33 | [ 'action' => 'edit', $id ], |
34 | 34 | [ |
35 | - 'style' => 'margin-right: 40px; display: inline-block', | |
35 | + 'title' => 'Modifier', | |
36 | + //'style' => 'margin-right: 40px; display: inline-block', | |
37 | + 'style' => $STYLE_EDIT, | |
36 | 38 | 'escape' => false, |
37 | 39 | 'onclick' => 'return true;' |
38 | 40 | ]); |
39 | 41 | |
40 | 42 | if ($CAN_DELETE) echo $this->Form->postLink( |
41 | - __('<i class="icon-trash"></i> Supprimer'), | |
42 | - //[ 'action' => 'delete', $site->id ], | |
43 | + //__('<i class="icon-trash"></i> Supprimer'), | |
44 | + __("<i class='icon-trash'></i>$label_del"), | |
43 | 45 | [ 'action' => 'delete', $id ], |
44 | 46 | [ |
45 | - 'style' => 'display: inline-block', | |
47 | + 'title' => 'Supprimer', | |
48 | + //'style' => 'display: inline-block', | |
49 | + //'style' => 'margin: 0 2px', | |
50 | + 'style' => $STYLE_DELETE, | |
46 | 51 | 'escape' => false, |
47 | - //'confirm' => __('Êtes-vous sur de vouloir supprimer #{0}?', $site->id) | |
52 | + //'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $site->id) | |
48 | 53 | 'confirm' => __('Êtes-vous sur de vouloir supprimer cet élément ?', $id) |
49 | 54 | ]); |
55 | + | |
56 | +// </DIV> | |
57 | +if ($WITH_DIV) echo " | |
58 | +</div>"; | |
59 | + | |
50 | 60 | ?> |
51 | 61 | |
52 | -</div> | ... | ... |
src/Template/Element/materiels_list.ctp
... | ... | @@ -2,6 +2,29 @@ |
2 | 2 | use Cake\I18n\Time; |
3 | 3 | use Cake\I18n\Date; |
4 | 4 | |
5 | +// - Variables passées à l'appel de cet élément : $this->element('materiels_list', [...]); | |
6 | + | |
7 | +$SELECTED_STATUS = $SELECTED_STATUS; | |
8 | +$METRO = $METRO; | |
9 | + | |
10 | +// - Autres variables passées directement par la vue utilisatrice | |
11 | +// En fait, TOUTES les variables créées par la vue sont disponibles ici, | |
12 | +// mais on ne précise ici que les variables UTILISÉES par cet "element" | |
13 | + | |
14 | +// Pas bien mais pratique | |
15 | +$controller = $controller; | |
16 | + | |
17 | +//$HEADERS = $HEADERS; | |
18 | +//$HAS_COL_METRO = $HAS_COL_METRO; | |
19 | +// Seulement pour la partie données | |
20 | +$materiels = $materiels; | |
21 | +//debug($materiels); | |
22 | +//$today = $today; | |
23 | +//$materiel = $materiel; | |
24 | +//$color = $color; | |
25 | +//$date_color = $date_color; | |
26 | + | |
27 | + | |
5 | 28 | // - Fonction utilisée seulement pour la 2ème partie (affichage d'une ligne de données) |
6 | 29 | $displayActionButtonsForMateriel = function($materiel, $statuses_color, $username, $USER_IS_RESPONSABLE, $USER_IS_ADMIN_OR_MORE, $USER_IS_SUPERADMIN, $controller, $html) { |
7 | 30 | |
... | ... | @@ -159,23 +182,26 @@ $displayActionButtonsForMateriel = function($materiel, $statuses_color, $usernam |
159 | 182 | |
160 | 183 | }; // displayActionButtonsForMateriel |
161 | 184 | |
185 | +?> | |
162 | 186 | |
163 | 187 | |
164 | 188 | |
165 | 189 | |
166 | -// - Variables passées à cet élément | |
167 | -//$HEADERS = $HEADERS; | |
168 | -//$HAS_COL_METRO = $HAS_COL_METRO; | |
169 | -//$METRO = $METRO; | |
170 | -$SELECTED_STATUS = $SELECTED_STATUS; | |
171 | -// Seulement pour la partie données | |
172 | -$materiels = $materiels; | |
173 | -//debug($materiels); | |
174 | -//$today = $today; | |
175 | -//$materiel = $materiel; | |
176 | -//$color = $color; | |
177 | -//$date_color = $date_color; | |
178 | -?> | |
190 | + | |
191 | + | |
192 | + | |
193 | + | |
194 | + | |
195 | + | |
196 | +<!-- | |
197 | +************************************************ | |
198 | +************************************************ | |
199 | + PAGE HTML | |
200 | +************************************************ | |
201 | +************************************************ | |
202 | +--> | |
203 | + | |
204 | + | |
179 | 205 | |
180 | 206 | <table style="border-collapse: separate; border-spacing: 0;"> |
181 | 207 | ... | ... |
src/Template/Materiels/index.ctp
... | ... | @@ -17,6 +17,9 @@ use App\Controller\MaterielsController; |
17 | 17 | - CAN_ARCHIVE |
18 | 18 | */ |
19 | 19 | |
20 | +// pas bien, mais pratique | |
21 | +$controller = $controller; | |
22 | + | |
20 | 23 | // Options des filtres |
21 | 24 | $nblines_options = $nblines_options; |
22 | 25 | $age_options = $age_options; |
... | ... | @@ -29,7 +32,6 @@ $statuses_color = $statuses_color; |
29 | 32 | //debug($projet_options); |
30 | 33 | |
31 | 34 | $nbMateriels = $nbMateriels; |
32 | -$controller = $controller; | |
33 | 35 | //debug($controller); |
34 | 36 | $materiels = $materiels; |
35 | 37 | //debug($materiels); | ... | ... |
src/Template/Organismes/index.ctp
1 | - | |
2 | -<div class="organismes index"> | |
3 | - | |
4 | - <?php echo '<h2><i class="icon-list"></i> Liste des organismes</h2>'; ?> | |
5 | - | |
6 | - <?=$this->element('button_add'); ?> | |
7 | - | |
8 | - <table style="border-collapse: separate; border-spacing: 0; width: 270px;"> | |
9 | - <thead> | |
10 | - <tr> | |
11 | - <th class="actions"><?= __('') ?></th> | |
12 | - <th><?= $this->Paginator->sort('nom', 'Nom') ?></th> | |
13 | - | |
14 | - </tr> | |
15 | - </thead> | |
16 | - <tbody> | |
17 | - <?php foreach ($organismes as $organisme): ?> | |
18 | - <tr> | |
19 | - <td class="actions" style="padding: 6px 0; text-align: left;"> | |
20 | - <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?> | |
21 | - <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $organisme->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> | |
22 | - <?php } ?> | |
23 | - | |
24 | - <?php if (in_array($role, ['Super Administrateur'])) { ?> | |
25 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $organisme->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $organisme->id)]) ?> | |
26 | - <?php } ?> | |
27 | - </td> | |
28 | - | |
29 | - <td class="smallText"><?= $this->Html->link($organisme->nom, ['action' => 'view', $organisme->id]) ?></td> | |
30 | - | |
31 | - </tr> | |
32 | - <?php endforeach; ?> | |
33 | - </tbody> | |
34 | - </table> | |
35 | - | |
36 | - <?php echo $this->element('pagination'); ?> | |
37 | - | |
38 | -</div> | |
39 | - | |
40 | -<!-- | |
41 | -<div class="actions"> | |
42 | - <php echo $this->element('menu') ?> | |
43 | - <php | |
44 | - | |
45 | -echo $this->element('menu_index', [ | |
46 | - 'pluralHumanName' => 'Organismes', | |
47 | - 'singularHumanName' => 'Organisme' | |
48 | -])?> | |
49 | - </div> | |
50 | ---> | |
51 | 1 | \ No newline at end of file |
2 | +<?php | |
3 | +$this->extend('/Common/index_gen'); | |
52 | 4 | \ No newline at end of file | ... | ... |
src/Template/Pages/tools_sm.ctp
... | ... | @@ -7,7 +7,7 @@ $role = $role; |
7 | 7 | |
8 | 8 | |
9 | 9 | //global $verb; |
10 | -$can_manage=false; | |
10 | +$CAN_MANAGE=false; | |
11 | 11 | $title = ''; |
12 | 12 | if (in_array($role, [ |
13 | 13 | //'Administration', |
... | ... | @@ -16,7 +16,7 @@ if (in_array($role, [ |
16 | 16 | ])) { |
17 | 17 | $title = "Gérer le contenu variable de l'application"; |
18 | 18 | //$verb = 'Gérer'; |
19 | - $can_manage=true; | |
19 | + $CAN_MANAGE=true; | |
20 | 20 | } |
21 | 21 | else { |
22 | 22 | $title = "Voir les autres listes"; |
... | ... | @@ -26,9 +26,17 @@ else { |
26 | 26 | |
27 | 27 | // Elements that the "Administration" profile can manage (and not only view) |
28 | 28 | $admin_can_manage = array( |
29 | - "fournisseurs", | |
29 | + 'sur_categories', | |
30 | + 'type_documents', | |
31 | + 'fournisseurs', | |
32 | + 'groupes_thematiques', | |
33 | + 'groupes_metiers', | |
34 | + 'organismes', | |
30 | 35 | //"unites", |
31 | 36 | //"formules", |
37 | + 'projets', | |
38 | + 'sites', | |
39 | + 'type_suivis', | |
32 | 40 | ) |
33 | 41 | |
34 | 42 | ?> |
... | ... | @@ -73,7 +81,10 @@ function echo_list($html, $list_name, $controller_name, $action_name='index', $c |
73 | 81 | |
74 | 82 | //echo_list($this->Html, 'Catégories', 'categories'); |
75 | 83 | //echo_list($this->Html, 'Catégories', 'pages', 'tools_cat'); |
76 | -$this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'Catégories', 'categories'); | |
84 | +$entity_name = 'sur_categories'; | |
85 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
86 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Domaines & Catégories', $entity_name); | |
87 | + | |
77 | 88 | |
78 | 89 | /* |
79 | 90 | echo '<tr><td>'; |
... | ... | @@ -87,7 +98,9 @@ echo '</td></tr>'; |
87 | 98 | |
88 | 99 | |
89 | 100 | // types de DOCUMENTS |
90 | -$this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'types de Documents', 'type_documents'); | |
101 | +$entity_name = 'type_documents'; | |
102 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
103 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'types de Documents', $entity_name); | |
91 | 104 | /* |
92 | 105 | echo '<tr><td>'; |
93 | 106 | echo $this->Html->link('Gérer les types de Documents', [ |
... | ... | @@ -99,10 +112,9 @@ $this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'types de Documents |
99 | 112 | |
100 | 113 | |
101 | 114 | // FOURNISSEURS |
102 | -$this->MyHelper->echoListToManageOrViewWithIcon( | |
103 | - ( $can_manage || ( $role == 'Administration' && in_array('fournisseurs', $admin_can_manage)) ), | |
104 | - 'Fournisseurs', 'fournisseurs', 'index' | |
105 | -); | |
115 | +$entity_name = 'fournisseurs'; | |
116 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
117 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Fournisseurs', $entity_name, 'index'); | |
106 | 118 | |
107 | 119 | /* |
108 | 120 | echo '<tr><td>'; |
... | ... | @@ -125,7 +137,10 @@ foreach (['metier','thematique'] as $group_type) { |
125 | 137 | $nom = $names[0] . 's'; |
126 | 138 | } |
127 | 139 | //$this->MyHelper->echoListToManageOrViewWithIcon($this->Html, $nom, 'groupes_thematiques'); |
128 | - $this->MyHelper->echoListToManageOrViewWithIcon($can_manage, $nom, 'groupes_'.$group_type.'s'); | |
140 | + //$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, $nom, 'groupes_'.$group_type.'s'); | |
141 | + $entity_name = 'groupes_'.$group_type.'s'; | |
142 | + $can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
143 | + $this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, $nom, $entity_name, 'index'); | |
129 | 144 | /* |
130 | 145 | echo '<tr><td>'; |
131 | 146 | echo $this->Html->link('Gérer les ' . $nom, [ |
... | ... | @@ -140,7 +155,7 @@ foreach (['metier','thematique'] as $group_type) { |
140 | 155 | // METROLOGIE MODULE ONLY |
141 | 156 | if ($configuration->metrologie) { |
142 | 157 | |
143 | - $this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'Métrologie : Unités', 'unites'); | |
158 | + $this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Métrologie : Unités', 'unites'); | |
144 | 159 | /* |
145 | 160 | echo '<tr><td>'; |
146 | 161 | echo $this->Html->link('Gérer les Unités (Métrologie)', [ |
... | ... | @@ -150,7 +165,7 @@ if ($configuration->metrologie) { |
150 | 165 | echo '</td></tr>'; |
151 | 166 | */ |
152 | 167 | |
153 | - $this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'Métrologie : Formules', 'formules'); | |
168 | + $this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Métrologie : Formules', 'formules'); | |
154 | 169 | /* |
155 | 170 | echo '<tr><td>'; |
156 | 171 | echo $this->Html->link('Gérer les Formules (Métrologie)', [ |
... | ... | @@ -163,7 +178,11 @@ if ($configuration->metrologie) { |
163 | 178 | |
164 | 179 | |
165 | 180 | // ORGANISMES |
166 | -$this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'Organismes', 'organismes'); | |
181 | +//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Organismes', 'organismes'); | |
182 | +$entity_name = 'organismes'; | |
183 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
184 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Organismes', $entity_name); | |
185 | + | |
167 | 186 | /* |
168 | 187 | echo '<tr><td>'; |
169 | 188 | echo $this->Html->link('Gérer les Organismes', [ |
... | ... | @@ -173,9 +192,16 @@ echo $this->Html->link('Gérer les Organismes', [ |
173 | 192 | echo '</td></tr>'; |
174 | 193 | */ |
175 | 194 | |
176 | -$this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'Projets', 'projets'); | |
195 | +//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Projets', 'projets'); | |
196 | +$entity_name = 'projets'; | |
197 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
198 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Projets', $entity_name, 'index'); | |
199 | + | |
177 | 200 | |
178 | -$this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'Sites', 'sites'); | |
201 | +//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'Sites', 'sites'); | |
202 | +$entity_name = 'sites'; | |
203 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
204 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'Sites', $entity_name, 'index'); | |
179 | 205 | /* |
180 | 206 | echo '<tr><td>'; |
181 | 207 | echo $this->Html->link('Gérer les Sites', [ |
... | ... | @@ -187,7 +213,10 @@ echo '</td></tr>'; |
187 | 213 | */ |
188 | 214 | |
189 | 215 | |
190 | -$this->MyHelper->echoListToManageOrViewWithIcon($can_manage, 'types de Suivis', 'type_suivis'); | |
216 | +//$this->MyHelper->echoListToManageOrViewWithIcon($CAN_MANAGE, 'types de Suivis', 'type_suivis'); | |
217 | +$entity_name = 'type_suivis'; | |
218 | +$can_manage_this = $CAN_MANAGE || ( $role == 'Administration' && in_array($entity_name, $admin_can_manage) ); | |
219 | +$this->MyHelper->echoListToManageOrViewWithIcon($can_manage_this, 'types de Suivis', $entity_name, 'index'); | |
191 | 220 | /* |
192 | 221 | echo '<tr><td>'; |
193 | 222 | echo $this->Html->link('Gérer les types de Suivis', [ | ... | ... |
src/Template/Sites/index.ctp
1 | - | |
2 | -<div class="sites index"> | |
3 | - | |
4 | - <!-- TITRE --> | |
5 | - <?php echo '<h2><i class="icon-list"></i> Liste des sites</h2>'; ?> | |
6 | - | |
7 | - <!-- Bouton "Ajouter" pour ajouter un nouvel élément (ssi autorisé) --> | |
8 | - <?=$this->element('button_add'); ?> | |
9 | - <!-- | |
10 | - <=$this->element('button_add', ['singularHumanName' => 'Site']); ?> | |
11 | - <div id="boutons" class="actions" style="margin-bottom:5px; width:100%; float:none; padding:5px 0;"> | |
12 | - <php | |
13 | - //$entity = $this->request->controller; // controller name (Sites, Suivis, Organismes, ...) | |
14 | - $bStyle = 'margin-right: 10px'; | |
15 | - $CAN_ADD = false; | |
16 | - if ( | |
17 | - in_array($role, ['Administration Plus','Super Administrateur']) | |
18 | - || | |
19 | - in_array($singularHumanName, ['Matériel','Suivi','Emprunt','Fournisseur']) | |
20 | - ) $CAN_ADD = true; | |
21 | - if ($CAN_ADD) $echoActionButton($this->Html, 'icon-plus', $bStyle, ' Ajouter', $this->request->controller, 'add', null); | |
22 | - ?> | |
23 | - </div> | |
24 | - --> | |
25 | - | |
26 | - <table style="border-collapse: separate; border-spacing: 0; width: 270px;"> | |
27 | - | |
28 | - <thead> | |
29 | - <tr> | |
30 | - <th class="actions"><?= __('') ?></th> | |
31 | - <th><?= $this->Paginator->sort('nom', 'Nom') ?></th> | |
32 | - </tr> | |
33 | - </thead> | |
34 | - | |
35 | - <tbody> | |
36 | - <?php | |
37 | - foreach ($sites as $site) { | |
38 | - if ($site->id != 9) { | |
39 | - ?> | |
40 | - <tr> | |
41 | - <td class="actions" style="padding: 6px 0; text-align: left;"> | |
42 | - <?php | |
43 | - if (in_array($role, ['Administration Plus', 'Super Administrateur'])) | |
44 | - echo $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $site->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]); | |
45 | - if (in_array($role, ['Super Administrateur'])) | |
46 | - echo $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $site->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $site->id)]); | |
47 | - ?> | |
48 | - </td> | |
49 | - <td class="smallText"><?= $this->Html->link($site->nom, ['action' => 'view', $site->id]) ?></td> | |
50 | - </tr> | |
51 | - <?php | |
52 | - } // if | |
53 | - } // foreach | |
54 | - ?> | |
55 | - </tbody> | |
56 | - | |
57 | - </table> | |
58 | - | |
59 | - <?php echo $this->element('pagination'); ?> | |
60 | - | |
61 | -</div> | |
62 | - | |
63 | -<!-- | |
64 | -<div class="actions"> | |
65 | - <php echo $this->element('menu') ?> | |
66 | - <php | |
67 | - | |
68 | -echo $this->element('menu_index', [ | |
69 | - 'pluralHumanName' => 'Sites', | |
70 | - 'singularHumanName' => 'Site' | |
71 | -])?> | |
72 | - </div> | |
73 | ---> | |
74 | 1 | \ No newline at end of file |
2 | +<?php | |
3 | +$this->extend('/Common/index_gen'); | |
75 | 4 | \ No newline at end of file | ... | ... |
src/Template/SousCategories/index.ctp
1 | - | |
2 | -<div class="sousCategories index"> | |
3 | - | |
4 | - <?php echo '<h2><i class="icon-list"></i> Liste des sous-catégories</h2>'; ?> | |
5 | - | |
6 | - <?=$this->element('button_add'); ?> | |
7 | - | |
8 | - <table style="border-collapse: separate; border-spacing: 0;width: 270px;"> | |
9 | - <thead> | |
10 | - <tr> | |
11 | - <th class="actions"><?= __('') ?></th> | |
12 | - <th><?= $this->Paginator->sort('nom', 'Nom') ?></th> | |
13 | - <th><?= $this->Paginator->sort('categorie_id', 'Catégorie') ?></th> | |
14 | - | |
15 | - </tr> | |
16 | - </thead> | |
17 | - <tbody> | |
18 | - <?php foreach ($sousCategories as $sousCategory): ?> | |
19 | - <tr> | |
20 | - <td class="actions" style="padding: 6px 0; text-align: left;"> | |
21 | - <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?> | |
22 | - <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $sousCategory->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> | |
23 | - <?php } ?> | |
24 | - | |
25 | - <?php if (in_array($role, ['Super Administrateur'])) { ?> | |
26 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $sousCategory->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $sousCategory->id)]) ?> | |
27 | - <?php } ?> | |
28 | - </td> | |
29 | - <td class="smallText"><?= $this->Html->link($sousCategory->nom, ['action' => 'view', $sousCategory->id]) ?></td> | |
30 | - <td class="smallText"><?= $sousCategory->has('category') ? $this->Html->link($sousCategory->category->nom, ['controller' => 'Categories', 'action' => 'view', $sousCategory->category->id]) : '' ?></td> | |
31 | - | |
32 | - | |
33 | - | |
34 | - </tr> | |
35 | - <?php endforeach; ?> | |
36 | - </tbody> | |
37 | - </table> | |
38 | - | |
39 | - <?php echo $this->element('pagination'); ?> | |
40 | - | |
41 | -</div> | |
42 | - | |
43 | -<!-- | |
44 | -<div class="actions"> | |
45 | - <php echo $this->element('menu') ?> | |
46 | - <php | |
47 | - | |
48 | -echo $this->element('menu_index', [ | |
49 | - 'pluralHumanName' => 'Sous-Catégories', | |
50 | - 'singularHumanName' => 'Sous-Catégorie' | |
51 | -])?> | |
52 | - </div> | |
53 | ---> | |
54 | 1 | \ No newline at end of file |
2 | +<?php | |
3 | +$this->extend('/Common/index_gen'); | |
55 | 4 | \ No newline at end of file | ... | ... |
src/Template/SurCategories/index.ctp
1 | 1 | <?php |
2 | -// Variables passées à la vue par le controleur | |
3 | -$nb_entities = $nb_entities; | |
4 | -?> | |
5 | - | |
6 | - | |
7 | -<div class="surCategories index"> | |
8 | - | |
9 | - <?php echo '<h2><i class="icon-list"></i> Liste des domaines ('.$nb_entities.')</h2>'; ?> | |
10 | - | |
11 | - <?=$this->element('button_add'); ?> | |
12 | - | |
13 | - <table style="border-collapse: separate; border-spacing: 0; width: 270px;"> | |
14 | - <thead> | |
15 | - <tr> | |
16 | - <th class="actions"><?= __('') ?></th> | |
17 | - <th><?= $this->Paginator->sort('nom', 'Nom') ?></th> | |
18 | - </tr> | |
19 | - </thead> | |
20 | - <tbody> | |
21 | - <?php foreach ($surCategories as $surCategory): ?> | |
22 | - <tr> | |
23 | - <td class="actions" style="padding: 6px 0; text-align: left;"> | |
24 | - <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?> | |
25 | - <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $surCategory->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> | |
26 | - <?php } ?> | |
27 | - | |
28 | - <?php if (in_array($role, ['Super Administrateur'])) { ?> | |
29 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $surCategory->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $surCategory->id)]) ?> | |
30 | - <?php } ?> | |
31 | - </td> | |
32 | - <td class="smallText"><?= $this->Html->link($surCategory->nom, ['action' => 'view', $surCategory->id]) ?></td> | |
33 | - | |
34 | - | |
35 | - </tr> | |
36 | - <?php endforeach; ?> | |
37 | - </tbody> | |
38 | - </table> | |
39 | - | |
40 | - <?php echo $this->element('pagination'); ?> | |
41 | - | |
42 | -</div> | |
43 | - | |
44 | -<!-- | |
45 | -<div class="actions"> | |
46 | - <php echo $this->element('menu') ?> | |
47 | - <php | |
48 | - | |
49 | -echo $this->element('menu_index', [ | |
50 | - 'pluralHumanName' => 'Domaines', | |
51 | - 'singularHumanName' => 'Domaine' | |
52 | -])?> | |
53 | - </div> | |
54 | ---> | |
55 | 2 | \ No newline at end of file |
3 | +$this->extend('/Common/index_gen'); | |
56 | 4 | \ No newline at end of file | ... | ... |
src/Template/TypeDocuments/index.ctp
1 | - | |
2 | -<div class="typeDocuments index"> | |
3 | - | |
4 | - <?php echo '<h2><i class="icon-list"></i> Liste des types de documents</h2>'; ?> | |
5 | - | |
6 | - <?=$this->element('button_add'); ?> | |
7 | - | |
8 | - <table style="border-collapse: separate; border-spacing: 0; width: 270px;"> | |
9 | - <thead> | |
10 | - <tr> | |
11 | - <th class="actions"><?= __('') ?></th> | |
12 | - <th><?= $this->Paginator->sort('nom', 'Nom') ?></th> | |
13 | - </tr> | |
14 | - </thead> | |
15 | - <tbody> | |
16 | - <?php | |
17 | - foreach ($typeDocuments as $typeDocument) : | |
18 | - | |
19 | - if ($typeDocument->nom != 'N/A') { | |
20 | - ?> | |
21 | - | |
22 | - <tr> | |
23 | - <td class="actions" style="padding: 6px 0; text-align: left;"> | |
24 | - <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?> | |
25 | - <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $typeDocument->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> | |
26 | - <?php } ?> | |
27 | - | |
28 | - <?php if (in_array($role, ['Super Administrateur'])) { ?> | |
29 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $typeDocument->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $typeDocument->id)]) ?> | |
30 | - <?php } ?> | |
31 | - </td> | |
32 | - <td class="smallText"><?= $this->Html->link($typeDocument->nom, ['action' => 'view', $typeDocument->id]) ?></td> | |
33 | - | |
34 | - | |
35 | - | |
36 | - </tr> | |
37 | - | |
38 | - <?php | |
39 | - } | |
40 | - endforeach | |
41 | - ; | |
42 | - ?> | |
43 | - </tbody> | |
44 | - </table> | |
45 | - | |
46 | - <?php echo $this->element('pagination'); ?> | |
47 | - | |
48 | -</div> | |
49 | - | |
50 | -<!-- | |
51 | -<div class="actions"> | |
52 | - <php echo $this->element('menu') ?> | |
53 | - <php | |
54 | - | |
55 | -echo $this->element('menu_index', [ | |
56 | - 'pluralHumanName' => 'Types Documents', | |
57 | - 'singularHumanName' => 'Type Document' | |
58 | -])?> | |
59 | - </div> | |
60 | ---> | |
61 | 1 | \ No newline at end of file |
2 | +<?php | |
3 | +$this->extend('/Common/index_gen'); | |
62 | 4 | \ No newline at end of file | ... | ... |
src/Template/TypeSuivis/index.ctp
1 | - | |
2 | -<div class="typeSuivis index"> | |
3 | - | |
4 | - <?php echo '<h2><i class="icon-list"></i> Liste des types de suivis</h2>'; ?> | |
5 | - | |
6 | - <?=$this->element('button_add'); ?> | |
7 | - | |
8 | - <table style="border-collapse: separate; border-spacing: 0;"> | |
9 | - | |
10 | - <thead> | |
11 | - <tr> | |
12 | - <th class="actions"><?= __('') ?></th> | |
13 | - <th><?= $this->Paginator->sort('nom', 'Nom') ?></th> | |
14 | - <th><?= $this->Paginator->sort('is_regular', 'Régulier ?') ?></th> | |
15 | - <th><?= $this->Paginator->sort('is_metro', 'Métrologie ?') ?></th> | |
16 | - </tr> | |
17 | - </thead> | |
18 | - | |
19 | - <tbody> | |
20 | - | |
21 | - <?php foreach ($typeSuivis as $typeSuivi): ?> | |
22 | - <tr> | |
23 | - | |
24 | - <!-- boutons edit et delete --> | |
25 | - <td class="actions" style="padding: 6px 0; text-align: left;"> | |
26 | - | |
27 | - <?php if (in_array($role, ['Administration Plus', 'Super Administrateur'])) { ?> | |
28 | - <?= $this->Html->link(__('<i class="icon-pencil"></i>'), ['action' => 'edit', $typeSuivi->id], ['title' => 'Editer', 'style' => 'margin: 0 2px', 'escape' => false ]) ?> | |
29 | - <?php } ?> | |
30 | - | |
31 | - <?php if (in_array($role, ['Super Administrateur'])) { ?> | |
32 | - <?= $this->Form->postLink(__('<i class="icon-trash"></i>'), ['action' => 'delete', $typeSuivi->id], ['title' => 'Supprimer', 'style' => 'margin: 0 2px', 'escape' => false, 'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $typeSuivi->id)]) ?> | |
33 | - <?php } ?> | |
34 | - | |
35 | - </td> | |
36 | - | |
37 | - <!-- data --> | |
38 | - <td class="smallText"><?= $this->Html->link($typeSuivi->nom, ['action' => 'view', $typeSuivi->id]) ?></td> | |
39 | - <td class="smallText"><?= $typeSuivi->is_regular?"Oui":"Non" ?></td> | |
40 | - <td class="smallText"><?= $typeSuivi->is_metro?"Oui":"Non" ?></td> | |
41 | - | |
42 | - </tr> | |
43 | - <?php endforeach; ?> | |
44 | - </tbody> | |
45 | - </table> | |
46 | - | |
47 | - <?php echo $this->element('pagination'); ?> | |
48 | - | |
49 | -</div> | |
50 | - | |
51 | -<!-- | |
52 | -<div class="actions"> | |
53 | - <php echo $this->element('menu') ?> | |
54 | - <php | |
55 | - | |
56 | -echo $this->element('menu_index', [ | |
57 | - 'pluralHumanName' => 'Types suivis', | |
58 | - 'singularHumanName' => 'Type suivi' | |
59 | -])?> | |
60 | - </div> | |
61 | ---> | |
62 | 1 | \ No newline at end of file |
2 | +<?php | |
3 | +$this->extend('/Common/index_gen'); | |
63 | 4 | \ No newline at end of file | ... | ... |
src/View/Helper/MyHelperHelper.php
... | ... | @@ -161,7 +161,9 @@ class MyHelperHelper extends Helper { |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - public function displayElement($nom, $valeur, $params = "") { | |
164 | + public function displayTableRowLabelAndValue($label, $value, $params = "") { $this->displayElement($label, $value, $params); } | |
165 | + //@deprecated | |
166 | + public function displayElement($label, $value, $params = "") { | |
165 | 167 | $TD = ($params=="") ? 'TD' : "TD $params"; |
166 | 168 | //$TD = ($params=="") ? '<TD>' : '<TD '.$params.'>'; |
167 | 169 | //$tdstyle = $params!="" ? $params : ''; |
... | ... | @@ -170,15 +172,81 @@ class MyHelperHelper extends Helper { |
170 | 172 | //if ($valeur != "") echo '<tr><td><strong>' . $nom . ' </strong></td>' . $balise . $valeur . '</td></tr>'; |
171 | 173 | //if ($valeur!="") echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".h($valeur)."</TD> </TR>"; |
172 | 174 | //if ($valeur!="") echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".$valeur."</TD> </TR>"; |
173 | - if ($valeur!==null && $valeur!=='') { | |
174 | - $val = $valeur; | |
175 | - if ($valeur === true) $val = 'Oui'; | |
176 | - if ($valeur === false) $val = 'Non'; | |
177 | - echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".$val."</TD> </TR>"; | |
175 | + if ($value!==null && $value!=='') { | |
176 | + $val = $value; | |
177 | + if ($value === true) $val = 'Oui'; | |
178 | + if ($value === false) $val = 'Non'; | |
179 | + echo "<TR> <TD><strong>".__($label)."</strong></TD> <$TD>".$val."</TD> </TR>"; | |
178 | 180 | } |
179 | 181 | //if ($valeur!="") echo "<TR> <TD><strong>$nom</strong></TD> <$TD>$valeur</TD> </TR>"; |
180 | 182 | } |
181 | 183 | |
184 | + | |
185 | + public function echoActionButton ( | |
186 | + $icon_class, $buttonStyle, $title, | |
187 | + $action, $id, $controller=null, // si controleur null =>controleur par défaut | |
188 | + $other_args=[], $tip='', $confirmMessage='', $moreButtonStyle='' | |
189 | + ) { | |
190 | + | |
191 | + //if ($controller=='') $controller='materiels'; | |
192 | + $controllerArgs = []; | |
193 | + if ($controller) $controllerArgs['controller'] = $controller; | |
194 | + $controllerArgs['action'] = $action; | |
195 | + $controllerArgs[] = $id; | |
196 | + foreach ($other_args as $other_arg) $controllerArgs[] = $other_arg; | |
197 | + echo $this->Html->link( | |
198 | + __("<i class=$icon_class></i>$title"), | |
199 | + $controllerArgs, | |
200 | + /* | |
201 | + [ | |
202 | + 'controller' => $controller, | |
203 | + 'action' => $action, | |
204 | + $id, | |
205 | + $other_args | |
206 | + ], | |
207 | + */ | |
208 | + [ | |
209 | + 'title' => $tip, | |
210 | + 'escape' => false, | |
211 | + 'onclick' => 'return true;', | |
212 | + //'style' => 'margin-right: 10px'.$moreButtonStyle, | |
213 | + 'style' => $buttonStyle, | |
214 | + 'confirm' => $confirmMessage | |
215 | + ] | |
216 | + ); | |
217 | + } | |
218 | + | |
219 | + public function echoDeleteButton ( | |
220 | + $title, | |
221 | + $id, $controller=null, // si controleur null =>controleur par défaut | |
222 | + $other_args=[], $confirmMessage='', $moreButtonStyle='' | |
223 | + ) { | |
224 | + | |
225 | + //if ($controller=='') $controller='materiels'; | |
226 | + $controllerArgs = []; | |
227 | + if ($controller) $controllerArgs['controller'] = $controller; | |
228 | + $controllerArgs['action'] = 'delete'; | |
229 | + $controllerArgs[] = $id; | |
230 | + foreach ($other_args as $other_arg) $controllerArgs[] = $other_arg; | |
231 | + echo $this->Form->postLink(__("<i class='icon-trash'></i>$title"), | |
232 | + $controllerArgs, | |
233 | + [ | |
234 | + 'title' => 'Supprimer', | |
235 | + //'style' => $buttonStyle, | |
236 | + 'style' => 'margin-left: 10px', | |
237 | + 'escape' => false, | |
238 | + //'confirm' => $confirmMessage | |
239 | + 'confirm' => __('Êtes-vous sur de vouloir supprimer cette entité ?'), | |
240 | + //'confirm' => __('Êtes-vous sur de vouloir supprimer # {0}?', $suivi->id) | |
241 | + ]); | |
242 | + } | |
243 | + | |
244 | + | |
245 | + | |
246 | + | |
247 | + | |
248 | + | |
249 | + | |
182 | 250 | /* Pour src/Template/Configurations/view et edit */ |
183 | 251 | public function echoSectionStart($title) { |
184 | 252 | $WITH_TABLE=true; | ... | ... |