page.list.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. User::check_access('notification','read');
  3. require_once(__DIR__.SLASH.'Notification.class.php');
  4. require_once(__DIR__.SLASH.'UserNotification.class.php');
  5. $categories = array();
  6. $unreads = UserNotification::get_unreads_count($myUser);
  7. foreach(Notification::types() as $slug => $type){
  8. $type['slug'] = $slug;
  9. $type['unread'] = isset($unreads['detailled'][$slug]) ? $unreads['detailled'][$slug] : 0;
  10. if(!isset($type['category'])) $type['category'] = 'Général';
  11. if(!isset($categories[slugify($type['category'])]))
  12. $categories[slugify($type['category'])] = array(
  13. 'label' => $type['category'],
  14. 'items' => array()
  15. );
  16. $categories[slugify($type['category'])]['items'][] = $type;
  17. }
  18. ?>
  19. <div class="row notifications-list">
  20. <div class="notification-summary">
  21. <span class="summary w-100 d-inline-flex">
  22. <div class="text-info">
  23. <i class="fas fa-bell mr-1 ml-1"></i>
  24. <span id="notifCounterFilter" class="badge badge-light pointer mr-1 ml-1">0</span>
  25. <span id="notifWord">notification</span>
  26. en attente
  27. </div>
  28. </span>
  29. <hr>
  30. <ul class="categories">
  31. <?php foreach($categories as $slug => $category): ?>
  32. <li class="category" data-category="<?php echo $slug; ?>">
  33. <div class="boxTitle">
  34. <input class="categoryCheckbox"
  35. type="checkbox"
  36. id="checkbox_<?php echo $slug; ?>"
  37. name="checkbox_<?php echo $slug; ?>"
  38. data-type="checkbox">
  39. <span onclick="$(this).closest('.category').toggleClass('folded');">
  40. <i class="categoryIcon fas fa-chevron-right"></i>
  41. <span class="categoryLabel pointer"><?php echo $category['label']; ?></span>
  42. </span>
  43. <span class="categoryBadge badge badge-pill badge-light float-right mt-1" data-category="<?php echo $slug; ?>">0</span>
  44. </div>
  45. <ul class="items" data-category="<?php echo $slug; ?>">
  46. <?php foreach ($category['items'] as $key => $item): ?>
  47. <li class="item" data-category="<?php echo $slug; ?>" data-item="<?php echo $item['slug']; ?>">
  48. <input class="itemCheckbox"
  49. type="checkbox"
  50. data-category="<?php echo $slug; ?>"
  51. data-item="<?php echo $item['slug']; ?>"
  52. id="checkbox_<?php echo $item['slug']; ?>"
  53. name="checkbox_<?php echo $item['slug']; ?>"
  54. data-type="checkbox">
  55. <div class="itemLabel d-inline">
  56. <i style="color:<?php echo $item['color']; ?>" class="itemIcon <?php echo $item['icon']; ?>"></i>
  57. <span class="pointer"><?php echo $item['label']; ?></span>
  58. </div>
  59. <span class="itemBadge badge badge-pill badge-light float-right" data-category="<?php echo $slug; ?>" data-item="<?php echo $item['slug']; ?>">0</span>
  60. </li>
  61. <?php endforeach; ?>
  62. </ul>
  63. </li>
  64. <?php endforeach; ?>
  65. </ul>
  66. </div>
  67. <div class="notification-detail">
  68. <div class="d-flex flex-row-reverse font-weight-light">
  69. <a href="#" onclick="notification_user_notification_delete_all('notifications', event);" id="deleteState">Tout supprimer <!-- <i class="far fa-trash-alt ml-1"></i> --></a>
  70. <a href="#" onclick="notification_user_notification_read_all('notifications', event);" class="mr-3" id="readState">Tout marquer comme lu <!-- <i class="fas fa-eye ml-1"></i> --></a>
  71. </div>
  72. <!-- Voir pour mettre en place un lazy loading -->
  73. <ul id="notifications" class="mid-pane notifications">
  74. <li data-id="{{id}}" data-category="{{category}}" data-item="{{type}}" class="hidden notification-item {{class}}">
  75. <h5 onclick="document.location.href='{{link}}';" class="pointer">{{label}}</h5>
  76. {{{html}}}
  77. <div class="notification-options">
  78. <div class="btn-group btn-group-sm" role="group">
  79. <div class="btn btn-info" title="Marquer comme {{readState}}" onclick="notification_user_notification_toggle_read(this);"><i class="fas fa-eye"></i></div>
  80. <div class="btn btn-danger btn-delete" title="Supprimer la notification" onclick="notification_user_notification_delete(this);"><i class="far fa-trash-alt"></i></div>
  81. </div>
  82. <small>{{{created-relative}}}</small>
  83. </div>
  84. </li>
  85. </ul>
  86. </div>
  87. </div>
  88. <br>