setting.notification.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. global $myUser,$conf;
  3. require_once(__DIR__.SLASH.'Notification.class.php');
  4. User::check_access('notification','configure');
  5. $types = array();
  6. foreach(Notification::types() as $slug=>$type)
  7. $types[$slug] = html_decode_utf8($type['label']);
  8. $categories = Notification::categories();
  9. ?>
  10. <div class="row">
  11. <div class="col-md-12"><br>
  12. <h3>Réglages Notifications</h3>
  13. <hr>
  14. </div>
  15. </div>
  16. <div class="row">
  17. <div class="col-md-12" id="notification_preference">
  18. <div class="tab-container mb-0 noPrint">
  19. <ul class="nav nav-tabs" role="tablist">
  20. <li class="nav-item"><a data-toggle="tab" class="nav-link active" href="#tab-general" aria-controls="tab-general" aria-selected="true" onclick="setTimeout(function(){notification_search();},0);">Notifications épinglées</a></li>
  21. <li class="nav-item"><a data-toggle="tab" class="nav-link" href="#tab-send" aria-controls="tab-send" aria-selected="false" onclick="setTimeout(function(){init_components('#tab-send');},0);">Envoi</a></li>
  22. <li class="nav-item"><a data-toggle="tab" class="nav-link" href="#tab-followings" aria-controls="tab-followings" aria-selected="false">Suivis</a></li>
  23. <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>
  24. </ul>
  25. </div>
  26. <div class="tab-content">
  27. <!-- Onglet Général -->
  28. <div class="tab-pane show active in" id="tab-general" role="tabpanel" aria-labelledby="tab-general"><br>
  29. <div class="row">
  30. <!-- search results -->
  31. <div class="col-xl-12">
  32. <legend>Notifications épinglées :</legend>
  33. <select id="filters" data-type="filter" data-label="Recherche" data-function="notification_search">
  34. <option value="label" data-filter-type="text">Libellé</option>
  35. <option value="start" data-filter-type="date">Date de lancement</option>
  36. <option value="end" data-filter-type="date">Date d'expiration</option>
  37. <option value="type" data-filter-type="list" data-values='<?php echo json_encode($types); ?>'>Type</option>
  38. </select>
  39. <hr>
  40. <table id="notifications-pinned" class="table table-striped " data-entity-search="notification_notification_search">
  41. <thead>
  42. <tr>
  43. <th>#</th>
  44. <th data-sortable="type">Type</th>
  45. <th data-sortable="label">Label</th>
  46. <th data-sortable="start">Date de lancement</th>
  47. <th data-sortable="end">Date d'expiration</th>
  48. <th >Contenu</th>
  49. <th></th>
  50. </tr>
  51. </thead>
  52. <tbody>
  53. <tr data-id="{{id}}" class="hidden">
  54. <td>{{id}}</td>
  55. <td><i class="{{type.icon}}" style="color:{{type.color}};"></i> {{type.label}}</td>
  56. <td>{{label}}</td>
  57. <td>{{start}}</td>
  58. <td>{{end}}</td>
  59. <td>{{html}}</td>
  60. <td class="text-center">
  61. <div class="btn btn-danger btn-mini btn-squarred" onclick="notification_delete(this);"><i class="far fa-trash-alt"></i></div>
  62. </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. <!-- Pagination (data-range définit le nombre de pages max affichées avant et après la page courante) -->
  67. <ul class="pagination justify-content-center" data-range="3">
  68. <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');notification_notification_search();">
  69. <span class="page-link">{{label}}</span>
  70. </li>
  71. </ul>
  72. </div>
  73. </div>
  74. </div>
  75. <!-- Onglet Envoi -->
  76. <div class="tab-pane" id="tab-send" role="tabpanel" aria-labelledby="tab-send"><br>
  77. <div class="col-md-12" id="notification-send" data-action="notification_send">
  78. <div class="btn btn-primary float-right btn-send" onclick="notification_send()"><i class="far fa-paper-plane"></i> Envoyer</div>
  79. <legend class="mb-0 w-auto mr-2">Paramètres d'envoi :</legend>
  80. <small class="text-muted">Dans cette section, vous pouvez créer une notification pour les utilisateurs et types concernés</small>
  81. <div class="clear"></div>
  82. <div class="row mt-1">
  83. <div class="col-md-4">
  84. <label for="start">Date de lancement <small class="text-muted"> - Laisser vide pour maintenant</small> :</label>
  85. <input type="text" class="form-control" id="start" data-type="date">
  86. </div>
  87. <div class="col-md-8 mb-1 user-picker">
  88. <label for="recipients">Destinataires <small class="text-muted"> - Laisser vide pour envoyer à tout le monde</small> :</label>
  89. <input type="text" class="form-control" id="recipients" data-type="user" data-multiple>
  90. </div>
  91. <div class="col-md-4">
  92. <label for="end">Date d'expiration <small class="text-muted"> - Par défaut à 3 mois</small> :</label>
  93. <input type="text" class="form-control" id="end" data-type="date">
  94. </div>
  95. <div class="col-md-8">
  96. <label class="font-weight-bold text-center d-block mb-0 mt-1">OU</label>
  97. <label for="pinned" class="pointer mt-2 w-100 text-center"><input type="checkbox" class="" id="pinned" data-type="checkbox">Épingler<small class="text-muted"> - Concerne tout le monde</small></label>
  98. </div>
  99. </div>
  100. <hr class="w-100">
  101. <legend class="mb-0">Détails :</legend>
  102. <div class="row">
  103. <div class="col-md-8">
  104. <label for="label">Sujet : </label>
  105. <input type="text" class="form-control" id="label" placeholder="eg. Mise à jour majeure">
  106. </div>
  107. <div class="col-md-4">
  108. <label for="type">Type : </label>
  109. <select data-type="dropdown-select" id="type" class="w-100 p-0" title="Type de notification">
  110. <?php foreach(Notification::types() as $slug => $type):
  111. $types[$slug] = $type['label'];
  112. ?>
  113. <option value="<?php echo $slug;?>" data-title="<?php echo $type['description']; ?>" style="background-color:<?php echo $type['color']; ?>;color:#ffffff;" data-icon="<?php echo $type['icon']; ?>"><?php echo $type['label']; ?></option>
  114. <?php endforeach; ?>
  115. </select>
  116. </div>
  117. <div class="col-md-12 mt-2">
  118. <label for="html" class="mb-0">Contenu :<small class="text-muted"> - Le contenu présent dans la notification (accepte le HTML)</small> :</label>
  119. <textarea class="" id="html" data-type="wysiwyg"></textarea>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- Onglet Suivis -->
  125. <div class="tab-pane" id="tab-followings" role="tabpanel" aria-labelledby="tab-followings"><br>
  126. <div class="btn btn-success float-right" onclick="notification_setting_save();"><i class="fas fa-check"></i> Enregistrer</div>
  127. <legend>Suivis par défaut :</legend>
  128. <div class="clear"></div>
  129. <p>Configuration par défaut des différentes méthodes de suivis par type de notification pour l'ensemble des utilisateurs <small class="text-muted">(la configuration personnelle de l'utilisateur prendra le pas sur cette configuration)</small></p>
  130. <div class="row" id="notification-default-following">
  131. <div class="col-3">
  132. <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
  133. <?php
  134. $i = 0;
  135. foreach($categories as $categorySlug=>$category): ?>
  136. <a class="nav-link <?php echo $i==0?'active':'' ?>" id="v-pills-home-tab" data-toggle="pill" href="#category-<?php echo $categorySlug ?>" role="tab" aria-controls="v-pills-home" aria-selected="true"><i class="far fa-bookmark"></i> <?php echo $category['label'] ?></a>
  137. <?php
  138. $i++;
  139. endforeach; ?>
  140. </div>
  141. </div>
  142. <div class="col-9">
  143. <div class="tab-content" id="v-pills-tabContent">
  144. <?php
  145. $i = 0;
  146. foreach($categories as $categorySlug => $category): ?>
  147. <div class="tab-pane fade show <?php echo $i==0?'active':'' ?>" id="category-<?php echo $categorySlug ?>" role="tabpanel" aria-labelledby="v-pills-home-tab">
  148. <?php foreach($category['items'] as $type): ?>
  149. <div data-slug="<?php echo $type['slug']; ?>" class="list-group-item list-group-item-action flex-column align-items-start category user-select-none">
  150. <div class="d-flex w-100 justify-content-between">
  151. <h5 class="mb-1" style="color:<?php echo $type['color']; ?>;"><i class="<?php echo $type['icon']; ?>"></i> <?php echo $type['label']; ?></h5>
  152. </div>
  153. <p class="mb-3"><?php echo $type['description']; ?>.</p>
  154. <ul class="notificationType mb-0">
  155. <?php
  156. $methods = array();
  157. Plugin::callHook("notification_methods", array(&$methods));
  158. foreach ($methods as $method) {
  159. $slug = $type['slug'].'_'.$method['slug'];
  160. $checked = $conf->get($slug) ? 'checked="checked"' : (isset($type['default_methods'][$method['slug']]) && $type['default_methods'][$method['slug']] ? 'checked="checked"' : '');
  161. ?>
  162. <li class="d-inline-block">
  163. <input data-type="checkbox" data-category="<?php echo $type['slug']; ?>" data-method="<?php echo $method['slug']; ?>" id="<?php echo $slug; ?>" <?php echo $checked ?> class="">
  164. <label for="<?php echo $slug; ?>" class="pointer">
  165. <i class="<?php echo $method['icon'] ?>"></i>
  166. <?php echo $method['label'] ?>
  167. </label><br>
  168. <small class="ml-1 text-muted"><?php echo $method['explain']; ?></small>
  169. </li>
  170. <?php
  171. }
  172. ?>
  173. </ul>
  174. </div>
  175. <?php
  176. $i++;
  177. endforeach; ?>
  178. </div>
  179. <?php endforeach; ?>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. <!-- Onglet Paramètres -->
  185. <div class="tab-pane" id="tab-settings" role="tabpanel" aria-labelledby="tab-settings"><br>
  186. <div class="btn btn-success float-right" onclick="notification_setting_save();"><i class="fas fa-check"></i> Enregistrer</div>
  187. <legend>Paramètres généraux :</legend>
  188. <div class="clear"></div>
  189. <?php echo Configuration::html('notification'); ?>
  190. </div>
  191. </div>
  192. </div>
  193. </div>