user.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <div class="col card--ui" id="card--dashboard">
  2. @if(!$add && !$update)
  3. <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
  4. <div class="title--section_name d-flex align-items-center justify-content-between">
  5. <i class="ico--ui title_section utenti me-2"></i>
  6. <h2 class="primary">Utenti</h2>
  7. </div>
  8. <div class="title--section_addButton" wire:click="add()" style="cursor: pointer;">
  9. <div class="btn--ui entrata d-flex justify-items-between">
  10. <a href="#" wire:click="add()" style="color:white">Aggiungi</a>
  11. </div>
  12. </div>
  13. </header>
  14. <section id="resume-table">
  15. <div class="compare--chart_wrapper d-none"></div>
  16. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  17. <thead>
  18. <tr>
  19. <th scope="col">Cognome</th>
  20. <th scope="col">Nome</th>
  21. <th scope="col">Email</th>
  22. <th scope="col">Livello</th>
  23. <th scope="col">Abilitato</th>
  24. <th scope="col">...</th>
  25. </tr>
  26. </thead>
  27. <tbody id="checkall-target">
  28. @foreach($records as $record)
  29. <tr>
  30. <td>{{$record->cognome}}</td>
  31. <td>{{$record->name}}</td>
  32. <td>{{$record->email}}</td>
  33. <td>{{$record->level == 0 ? 'Admin' : ($record->level == 1 ? 'Worker' : 'Istruttore')}}</td>
  34. <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
  35. <td>
  36. @if($record->email != 'admin@admin.com')
  37. <button type="button" class="btn" wire:click="edit({{ $record->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button>
  38. <button type="button" class="btn" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
  39. @endif
  40. </td>
  41. </tr>
  42. @endforeach
  43. </tbody>
  44. </table>
  45. </section>
  46. @else
  47. <div class="container">
  48. <a class="btn--ui lightGrey" href="/users"><i class="fa-solid fa-arrow-left"></i></a><br><br>
  49. @if (session()->has('error'))
  50. <div class="alert alert-danger" role="alert">
  51. {{ session()->get('error') }}
  52. </div>
  53. @endif
  54. <div class="row">
  55. <div class="col">
  56. <form action="">
  57. <div class="row mb-3">
  58. <div class="col-md-6">
  59. <div class="form--item">
  60. <label for="name" class="form-label">Nome</label>
  61. <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
  62. @error('name')
  63. <div class="invalid-feedback">{{ $message }}</div>
  64. @enderror
  65. </div>
  66. </div>
  67. <div class="col-md-6">
  68. <div class="form--item">
  69. <label for="name" class="form-label">Cognome</label>
  70. <input class="form-control js-keyupTitle @error('') is-invalid @enderror" type="text" id="cognome" placeholder="Cognome" wire:model="cognome">
  71. @error('cognome')
  72. <div class="invalid-feedback">{{ $message }}</div>
  73. @enderror
  74. </div>
  75. </div>
  76. <div class="col-md-6">
  77. <div class="form--item">
  78. <label for="email" class="form-label">Email</label>
  79. <input class="form-control js-keyupTitle @error('email') is-invalid @enderror" type="text" id="email" placeholder="Email" wire:model="email" type="email">
  80. @error('email')
  81. <div class="invalid-feedback">{{ $message }}</div>
  82. @enderror
  83. </div>
  84. </div>
  85. <div class="col-md-6 ">
  86. <div class="form--item">
  87. <label for="password" class="form-label">Password</label>
  88. <input class="form-control js-keyupTitle @error('password') is-invalid @enderror" type="password" id="password" placeholder="Password" wire:model="password" type="password" {{ $userExists ? 'disabled' : '' }}>
  89. @if($update)
  90. <small>Lasciare vuota per NON modificarla</small>
  91. @endif
  92. @error('password')
  93. <div class="invalid-feedback">{{ $message }}</div>
  94. @enderror
  95. </div>
  96. </div>
  97. </div>
  98. <div class="row mt-3">
  99. <div class="col-md-6">
  100. <div class="form--item">
  101. <label for="enabled" class="form-label">Livello</label>
  102. <select class="form-control" id="level" wire:model="level">
  103. <option value="0">Admin
  104. <option value="1">Worker
  105. <option value="2">Istruttore
  106. </select>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="row mt-3 mb-3">
  111. <div class="col-md-6">
  112. <div class="form--item">
  113. <label for="enabled" class="form-label">Abilitato</label>
  114. <input class="form-check-input form-control" style="width:22px; height:22px;" type="checkbox" id="enabled" wire:model="enabled" {{ $userExists ? '' : '' }}>
  115. </div>
  116. </div>
  117. </div>
  118. <!-- // inline input field -->
  119. <div class="form--item">
  120. <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
  121. @if($add)
  122. <button type="submit" class="btn--ui" wire:click.prevent="store()">Invita</button>
  123. @endif
  124. @if($update)
  125. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  126. @endif
  127. </div>
  128. </form>
  129. </div>
  130. </div>
  131. </div>
  132. @endif
  133. </div>
  134. @push('scripts')
  135. <link href="/css/datatables.css" rel="stylesheet" />
  136. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  137. <script src="/assets/js/datatables.js"></script>
  138. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  139. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  140. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  141. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  142. @endpush
  143. @push('scripts')
  144. <script>
  145. $(document).ready(function() {
  146. loadDataTable();
  147. } );
  148. Livewire.on('load-data-table', () => {
  149. loadDataTable();
  150. });
  151. function loadDataTable(){
  152. if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
  153. $('#tablesaw-350').DataTable().destroy();
  154. }
  155. $('#tablesaw-350').DataTable({
  156. thead: {
  157. 'th': {'background-color': 'blue'}
  158. },
  159. layout: {
  160. topStart : null,
  161. topEnd : null,
  162. top1A: {
  163. buttons: [
  164. {
  165. extend: 'collection',
  166. text: 'ESPORTA',
  167. buttons: [
  168. {
  169. extend: 'excelHtml5',
  170. title: 'Durata corsi',
  171. exportOptions: {
  172. columns: ":not(':last')"
  173. }
  174. },
  175. {
  176. extend: 'pdfHtml5',
  177. title: 'Durata corsi',
  178. exportOptions: {
  179. columns: ":not(':last')"
  180. }
  181. },
  182. {
  183. extend: 'print',
  184. text: 'Stampa',
  185. title: 'Durata corsi',
  186. exportOptions: {
  187. columns: ":not(':last')"
  188. }
  189. }
  190. ],
  191. dropup: true
  192. }
  193. ]
  194. },
  195. top1B : {
  196. pageLength: {
  197. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  198. }
  199. },
  200. top1C :'search',
  201. },
  202. pagingType: 'numbers',
  203. "language": {
  204. "url": "/assets/js/Italian.json"
  205. },
  206. "fnInitComplete": function (oSettings, json) {
  207. var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  208. $(".dt-search").append(html);
  209. }
  210. });
  211. $('#tablesaw-350 thead tr th').addClass('col');
  212. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  213. $(document).ready(function() {
  214. $(document).on("click",".addData",function() {
  215. $(".title--section_addButton").trigger("click")
  216. });
  217. } );
  218. }
  219. </script>
  220. @endpush