setting.dashboard.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. global $myUser;
  3. User::check_access('dashboard','configure');
  4. require_once(__DIR__.SLASH.'DashboardWidgetShare.class.php');
  5. require_once(__DIR__.SLASH.'DashboardWidget.class.php');
  6. require_once(__DIR__.SLASH.'Dashboard.class.php');
  7. $widgets = array();
  8. foreach (Dashboard::loadAll(array('user'=>$myUser->login)) as $dashboard) {
  9. foreach (DashboardWidget::loadAll(array('dashboard'=>$dashboard->id)) as $widget) {
  10. $widgets[] = $widget;
  11. }
  12. }
  13. usort($widgets, function($a,$b){
  14. if($a > $b) return 1;
  15. if($a < $b) return -1;
  16. if($a == $b) return 0;
  17. });
  18. ?>
  19. <div class="row">
  20. <div class="col-md-12"><br>
  21. <h3>Réglages Dashboard</h3>
  22. <div class="clear"></div>
  23. <hr>
  24. </div>
  25. </div>
  26. <div class="row">
  27. <!-- search results -->
  28. <div class="col-xl-12">
  29. <div class="tab-container mb-0 noPrint">
  30. <ul class="nav nav-tabs" role="tablist">
  31. <li class="nav-item"><a data-toggle="tab" class="nav-link active" href="#tab-dashboards" aria-controls="tab-dashboards" aria-selected="false">Liste Dashboards</a></li>
  32. <li class="nav-item"><a data-toggle="tab" class="nav-link" href="#tab-shared-widgets" aria-controls="tab-shared-widgets" aria-selected="false">Widgets communs</a></li>
  33. </ul>
  34. </div>
  35. <div class="tab-content">
  36. <!-- Onglet Dashboards -->
  37. <div class="tab-pane show active in" id="tab-dashboards" role="tabpanel" aria-labelledby="tab-dashboards">
  38. <div class="alert alert-info my-3"><strong>NB :</strong> Marquer une dashboard comme obligatoire imposera celle-ci à l'ensemble des utilisateurs (sans possibilité de modification)</div>
  39. <legend>Dashboard disponibles :</legend>
  40. <table id="dashboards" class="table table-striped table-dashboard" data-entity-search="dashboard_search">
  41. <thead class="bg-secondary text-light">
  42. <tr>
  43. <th data-sortable="label">Libellé</th>
  44. <?php if($myUser->can('dashboard','configure')): ?>
  45. <th data-sortable="creator">Utilisateur</th>
  46. <?php endif; ?>
  47. <th data-sortable="icon">Icône</th>
  48. <th data-sortable="default" class="text-center">Par défaut</th>
  49. <th data-sortable="mandatory" class="text-center">Obligatoire</th>
  50. <th></th>
  51. </tr>
  52. <tr id="dashboard-form" data-action="dashboard_dashboard_save" data-id="">
  53. <th class="align-middle"><input id="label" name="label" class="form-control" placeholder="eg. Metrics..." type="text"></th>
  54. <?php if($myUser->can('dashboard','configure')): ?>
  55. <th class="align-middle position-relative"><input id="user" name="user" data-type="user" class="form-control" placeholder="eg. John Doe..."></th>
  56. <?php endif; ?>
  57. <th class="align-middle position-relative"><input id="icon" name="icon" data-type="icon" class="form-control w-100" value="far fa-bookmark" type="text"></th>
  58. <th class="align-middle text-center"><input id="default" name="default" class="" data-type="checkbox" type="checkbox"></th>
  59. <th class="align-middle text-center"><input id="mandatory" name="mandatory" class="" data-type="checkbox" type="checkbox"></th>
  60. <th class="align-middle text-right"><div onclick="dashboard_dashboard_save();" class="btn btn-success"><i class="fas fa-check"></i></div></th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr data-id="{{id}}" class="hidden">
  65. <td>{{label}}</td>
  66. <?php if($myUser->can('dashboard','configure')): ?>
  67. <td>{{user}}</td>
  68. <?php endif; ?>
  69. <td><i class="{{icon}}"></i> {{icon}}</td>
  70. <td class="text-center">
  71. {{#default}}<i class="fas fa-check text-success"></i>{{/default}}
  72. {{^default}}<i class="fas fa-times text-danger"></i>{{/default}}
  73. </td>
  74. <td class="text-center">
  75. {{#mandatory}}<i class="fas fa-check text-success"></i>{{/mandatory}}
  76. {{^mandatory}}<i class="fas fa-times text-danger"></i>{{/mandatory}}
  77. </td>
  78. <td class="text-right">
  79. <div class="btn btn-info btn-mini btn-squarred" onclick="dashboard_dashboard_edit(this);"><i class="fas fa-pencil-alt"></i></div>
  80. <div class="btn btn-danger btn-mini btn-squarred" onclick="dashboard_dashboard_delete(this);"><i class="far fa-trash-alt"></i></div>
  81. </td>
  82. </tr>
  83. </tbody>
  84. </table>
  85. <!-- Pagination -->
  86. <ul class="pagination">
  87. <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');dashboard_dashboard_search();">
  88. <a class="page-link" href="#">{{label}}</a>
  89. </li>
  90. </ul>
  91. </div>
  92. <div class="tab-pane" id="tab-shared-widgets" role="tabpanel" aria-labelledby="tab-shared-widgets"><br>
  93. <legend>Gestion des widgets communs :</legend>
  94. <table id="dashboard-widget-shares" class="table table-striped " data-entity-search="dashboard_widget_share_search">
  95. <thead class="bg-secondary text-light">
  96. <tr>
  97. <th>ID Widget</th>
  98. <th class="text-center">Obligatoire</th>
  99. <th>Afficher pour <small class="text-muted">(Laisser vide pour tout le monde)</small></th>
  100. <th>Ordre par défaut</th>
  101. <th></th>
  102. </tr>
  103. <tr id="dashboard-widget-share-form" data-action="dashboard_widget_share_save" data-id="">
  104. <th>
  105. <select id="widget" name="widget" class="form-control">
  106. <option value="">-</option>
  107. <?php foreach ($widgets as $widget) : ?>
  108. <option value="<?php echo $widget->id; ?>">Widget type <?php echo $widget->model ?> en position <?php echo $widget->position ?></option>
  109. <?php endforeach; ?>
  110. </select>
  111. </th>
  112. <th class="text-center align-middle"><input id="mandatory" data-type="checkbox" name="mandatory" class="" placeholder="" value="" type="checkbox"></th>
  113. <th style="position:relative;"><input id="uid" name="uid" class="form-control" placeholder="" value="" type="text" data-type="user" data-types="user,rank"></th>
  114. <th><input id="sort" name="sort" class="form-control" placeholder="" value="" type="text"></th>
  115. <th class="text-center"><div onclick="dashboard_widget_share_save();" class="btn btn-success"><i class="fas fa-check"></i></div></th>
  116. </tr>
  117. </thead>
  118. <tbody>
  119. <tr data-id="{{id}}" class="hidden">
  120. <td>{{widget.model}} (#{{widget.id}}) en position {{widget.position}}</td>
  121. <td>{{mandatory}}</td>
  122. <td>{{for}}</td>
  123. <td>{{sort}}</td>
  124. <td class="text-right">
  125. <div class="btn btn-info btn-mini btn-squarred " onclick="dashboard_widget_share_edit(this);"><i class="fas fa-pencil-alt"></i></div>
  126. <div class="btn btn-danger btn-mini btn-squarred " onclick="dashboard_widget_share_delete(this);"><i class="far fa-trash-alt"></i></div>
  127. </td>
  128. </tr>
  129. </tbody>
  130. </table>
  131. </div>
  132. </div>
  133. </div>
  134. </div>