setting.global.navigation.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. global $myUser,$conf,$myFirm;
  3. if(!$myUser->connected()) throw new Exception("Vous devez être connecté pour accéder à cette fonctionnalité",401);
  4. require_once(__DIR__.SLASH.'MenuItem.class.php');
  5. if($conf->get("navigation_allow_custom_menu")==0 && !$myUser->can('navigation','configure')) throw new Exception("Vous n'avez pas la permission d'afficher cette page", 403);
  6. ?>
  7. <div class="row">
  8. <div class="col-md-12">
  9. <br>
  10. <div onclick="navigation_setting_save();" class="btn btn-success right"><i class="fas fa-check"></i> Enregistrer</div>
  11. <h3>Réglages Navigation</h3>
  12. <hr>
  13. </div>
  14. </div>
  15. <div class="row">
  16. <div class="col-md-12" id="notification_preference">
  17. <div class="tab-container mb-0 noPrint">
  18. <ul class="nav nav-tabs" role="tablist">
  19. <li class="nav-item"><a data-toggle="tab" class="nav-link active" href="#tab-menus" aria-controls="tab-menus" aria-selected="false">Menus</a></li>
  20. <?php if($myUser->can('navigation','configure')): ?>
  21. <li class="nav-item"><a data-toggle="tab" class="nav-link" href="#tab-settings" aria-controls="tab-settings" aria-selected="false">Paramètres</a></li>
  22. <?php endif; ?>
  23. </ul>
  24. </div>
  25. <div class="tab-content">
  26. <!-- Onglet Menus -->
  27. <div class="tab-pane show active in" id="tab-menus" role="tabpanel" aria-labelledby="tab-menus"><br>
  28. <div class="col-md-12 navigation-tree p-2">
  29. <h5 class="pt-1 d-inline-block m-0">Arborescence du menu
  30. <select class="navigation-menu-selector text-primary" id="navigation-menu" onchange="navigation_tree_search()">
  31. <?php $filters = array('menu'=>'0');
  32. if($myUser->can('navigation','configure')){
  33. //l'admin menu voit ses menu et les menu non attaché a un user
  34. $filters['user:IN'] = ','.$myUser->login;
  35. }else{
  36. //les non admins menu ne voient que leurs menus
  37. $filters['user'] = $myUser->login;
  38. }
  39. $menus = MenuItem::loadAll($filters, array('id'));
  40. //Récuperation du menu raccourcis du user
  41. $shortcutMenu = array_filter($menus, function($value) use ($myUser){
  42. return $value->user==$myUser->login && $value->slug==MenuItem::MENU_SHORTCUT;
  43. });
  44. $shortcutMenu = !empty($shortcutMenu) ? $shortcutMenu[array_key_first($shortcutMenu)] : false;
  45. //On créé un menu raccourcis pour l'utilisateur courant si celui ci n'existe pas
  46. if(!$shortcutMenu){
  47. $shortcutMenu = new MenuItem();
  48. $shortcutMenu->label = 'Menu raccourcis';
  49. $shortcutMenu->slug = MenuItem::MENU_SHORTCUT;
  50. $shortcutMenu->user = $myUser->login;
  51. $shortcutMenu->menu = '0';
  52. $shortcutMenu->save();
  53. $menus[] = $shortcutMenu;
  54. }
  55. foreach($menus as $menu): ?>
  56. <option <?php echo (!empty($_['menu']) && $_['menu']=="mine" && $shortcutMenu->id==$menu->id ? 'selected="selected"': ''); ?> value="<?php echo $menu->id; ?>" data-slug="<?php echo $menu->slug; ?>"><?php echo $menu->label ?></option>
  57. <?php endforeach; ?>
  58. </select> pour l'établissement
  59. <select class="navigation-firm-selector text-primary" id="navigation-firm" onchange="navigation_menu_setting_search()">
  60. <?php
  61. $firms = $myUser->firms;
  62. $allFirms = new Firm();
  63. $allFirms->id = 0;
  64. $allFirms->label = 'Tous les établissements';
  65. if($myUser->superadmin) $firms[] = $allFirms;
  66. foreach ($firms as $firm):
  67. ?> <option <?php echo ($myFirm->id == $firm->id ? "selected='selected'":"") ?> value="<?Php echo $firm->id; ?>"><?php echo $firm->label; ?></option>
  68. <?php endforeach ?>
  69. </select>
  70. </h5>
  71. <div class="d-inline-block float-right">
  72. <div onclick="navigation_tree_new();" class="btn btn-info"><i class="fas fa-plus"></i> Nouvel élément</div>
  73. <div class="btn btn-light" data-toggle="modal" data-target="#navigation-page-modal"><i class="fas fa-plus"></i> Ajouter une page existante</div>
  74. </div>
  75. <hr>
  76. <ul class="navigation-tree-list">
  77. <li class="navigation-line {{class}} hidden" data-id="{{id}}" >
  78. <div class="navigation-item">
  79. <div class="navigation-item-header">
  80. <span class="navigation-item-icon"><i class="{{icon}} fa-fw"></i></span>
  81. <h1 class="navigation-item-label">{{label}}</h1>
  82. <h3 class="navigation-item-type navigation-item-toggle pointer text-uppercase d-inline-flex" onclick="navigation_tree_toggle(this)" title="Afficher/Cacher" >
  83. <span class="m-auto">{{target.label}}</span>
  84. <i class="ml-1 fas fa-angle-right"></i>
  85. </h3>
  86. <small class="navigation-item-url">{{#url}}- {{url}}{{/url}}</small>
  87. </div>
  88. <div class="navigation-item-form row hidden">
  89. <div class="col-md-3">
  90. <h4>Titre :</h4>
  91. <div class="input-group mb-1">
  92. <input type="text" class="item-icon" data-type="icon" value="{{icon}}">
  93. <input type="text" class="form-control item-label" value="{{label}}" placeholder="Libellé du lien">
  94. </div>
  95. </div>
  96. <div class="col-md-9">
  97. <h4>Adresse :<small class="text-muted"> - Optionnel</small></h4>
  98. <div class="input-group mb-1">
  99. <input type="text" class="form-control item-url" value="{{url}}" placeholder="Adresse du lien">
  100. </div>
  101. </div>
  102. {{^shortcut}}
  103. <div class="col-md-3">
  104. <h4>Visibilité :<small class="text-muted"> - Laisser vide pour public</small></h4>
  105. <input type="text" class="item-visibility form-control" data-type="user-tpl" data-types="rank,user" data-multiple="true" value="{{visibility}}" data-default="<?php echo $conf->get('default_menu_visibility') ?>">
  106. </div>
  107. {{/shortcut}}
  108. <div class="{{#shortcut}}col-md-12{{/shortcut}}{{^shortcut}}col-md-9{{/shortcut}}">
  109. <h4>Type d'ouverture :<small class="text-muted"> - Optionnel</small></h4>
  110. <!-- la balise form est obligatoire pour contrer le bug de jquery ui sortable, ne pas enlever -->
  111. <form>
  112. <?php foreach (MenuItem::target() as $slug => $target): ?>
  113. <label class="m-0"><input data-type="radio" name="item-target" value="<?php echo $slug; ?>" data-value="{{target.slug}}"> <i class="<?php echo $target['icon']; ?>"></i> <?php echo $target['label']; ?></label>
  114. <?php endforeach; ?>
  115. </form>
  116. </div>
  117. <div class="col-md-12">
  118. <div class="navigation-item-delete text-danger btn btn-light float-right p-1" onclick="navigation_tree_remove(this)" title="Supprimer l'élément de menu"><i class="far fa-trash-alt"></i> Supprimer</div>
  119. <div class="clear"></div>
  120. </div>
  121. </div>
  122. </div>
  123. </li>
  124. </ul>
  125. </div>
  126. </div>
  127. <?php if($myUser->can('navigation','configure')): ?>
  128. <div class="tab-pane" id="tab-settings" role="tabpanel" aria-labelledby="tab-settings"><br>
  129. <div class="">
  130. <?php echo Configuration::html('navigation'); ?>
  131. </div>
  132. </div>
  133. <?php endif; ?>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- Modal page interne -->
  138. <div class="modal fade" id="navigation-page-modal" tabindex="-1" role="dialog" aria-hidden="true">
  139. <div class="modal-dialog" role="document">
  140. <div class="modal-content">
  141. <div class="modal-header">
  142. <h5 class="modal-title" id="exampleModalLabel">Pages existantes :</h5>
  143. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  144. <span aria-hidden="true">&times;</span>
  145. </button>
  146. </div>
  147. <div class="modal-body">
  148. <ul class="list-group">
  149. <?php
  150. $pages = array();
  151. Plugin::callHook("menu_main", array(&$pages));
  152. uasort ($pages , function($a,$b){return $a['sort']>$b['sort']?1:-1;});
  153. foreach($pages as $page):
  154. $icon = isset($page['icon'])? $page['icon'] : 'far fa-bookmark';
  155. ?>
  156. <li class="list-group-item d-flex justify-content-between align-items-center" data-label="<?php echo $page['label']; ?>" data-icon="<?php echo $page['icon']; ?>" data-url="<?php echo $page['url']; ?>">
  157. <div>
  158. <i class="<?php echo $icon; ?>"></i> <?php echo $page['label']; ?> <a class="text-muted" href="<?php echo $page['url']; ?>"> -<?php echo $page['url']; ?></a>
  159. </div>
  160. <span class="btn btn-squarred btn-mini btn-success" title="Ajouter la page <?php echo $page['label']; ?> au menu" onclick="navigation_tree_new(this);"><i class="fas fa-plus"></i></span>
  161. </li>
  162. <?php endforeach; ?>
  163. </ul>
  164. </div>
  165. <div class="modal-footer">
  166. <button type="button" class="btn btn-light" data-dismiss="modal">Fermer</button>
  167. </div>
  168. </div>
  169. </div>
  170. </div>