course_frequency.blade.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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">Frequenza corsi</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. <a class="btn--ui lightGrey" href="/settings?type=corsi"><i class="fa-solid fa-arrow-left"></i></a><br>
  15. <section id="resume-table">
  16. <div class="compare--chart_wrapper d-none"></div>
  17. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  18. <thead>
  19. <tr>
  20. <th scope="col">Nome</th>
  21. <th scope="col">Abilitato</th>
  22. <th scope="col">...</th>
  23. </tr>
  24. </thead>
  25. <tbody id="checkall-target">
  26. @foreach($records as $record)
  27. <tr>
  28. <td>{{$record->name}}</td>
  29. <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
  30. <td>
  31. <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>
  32. <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>
  33. </td>
  34. </tr>
  35. @endforeach
  36. </tbody>
  37. </table>
  38. </section>
  39. @else
  40. <div class="container">
  41. <a class="btn--ui lightGrey" href="/course_frequencies"><i class="fa-solid fa-arrow-left"></i></a><br><br>
  42. @if (session()->has('error'))
  43. <div class="alert alert-danger" role="alert">
  44. {{ session()->get('error') }}
  45. </div>
  46. @endif
  47. <div class="row">
  48. <div class="col">
  49. <form action="">
  50. <div class="row mb-3">
  51. <div class="col">
  52. <div class="form--item">
  53. <label for="inputName" class="form-label">Nome</label>
  54. <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
  55. @error('name')
  56. <div class="invalid-feedback">{{ $message }}</div>
  57. @enderror
  58. </div>
  59. </div>
  60. <div class="col">
  61. <div class="form--item">
  62. <label for="enabled" class="form-label">Abilitato</label>
  63. <input class="form-check-input form-control" style="width:22px; height:22px;" type="checkbox" id="enabled" wire:model="enabled">
  64. </div>
  65. </div>
  66. </div>
  67. <!-- // inline input field -->
  68. <div class="form--item">
  69. <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
  70. @if($add)
  71. <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
  72. @endif
  73. @if($update)
  74. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  75. @endif
  76. </div>
  77. </form>
  78. </div>
  79. </div>
  80. </div>
  81. @endif
  82. </div>
  83. @push('scripts')
  84. <link href="/css/datatables.css" rel="stylesheet" />
  85. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  86. <script src="/assets/js/datatables.js"></script>
  87. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  88. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  89. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  90. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  91. @endpush
  92. @push('scripts')
  93. <script>
  94. $(document).ready(function() {
  95. loadDataTable();
  96. } );
  97. Livewire.on('load-data-table', () => {
  98. loadDataTable();
  99. });
  100. function loadDataTable(){
  101. let date = new Date();
  102. let date_export = `${date.getFullYear()}${date.getMonth()}${date.getDate()}_`;
  103. if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
  104. $('#tablesaw-350').DataTable().destroy();
  105. }
  106. $('#tablesaw-350').DataTable({
  107. processing: true,
  108. thead: {
  109. 'th': {'background-color': 'blue'}
  110. },
  111. layout: {
  112. topStart : null,
  113. topEnd : null,
  114. top1A: {
  115. // buttons: [
  116. // {
  117. // extend: 'collection',
  118. // text: 'ESPORTA',
  119. buttons: [
  120. {
  121. extend: 'excelHtml5',
  122. text: '<i class="fa-solid fa-file-excel"></i>',
  123. action: newexportaction,
  124. title: date_export + 'Frequenza corsi',
  125. exportOptions: {
  126. columns: ":not(':last')"
  127. }
  128. },
  129. {
  130. extend: 'pdfHtml5',
  131. text: '<i class="fa-solid fa-file-pdf"></i>',
  132. action: newexportaction,
  133. title: date_export + 'Frequenza corsi',
  134. exportOptions: {
  135. columns: ":not(':last')"
  136. }
  137. },
  138. {
  139. extend: 'print',
  140. action: newexportaction,
  141. text: '<i class="fa-solid fa-print"></i>',
  142. title: date_export + 'Frequenza corsi',
  143. exportOptions: {
  144. columns: ":not(':last')"
  145. }
  146. }
  147. ],
  148. // dropup: true
  149. // }
  150. // ]
  151. },
  152. top1B : {
  153. pageLength: {
  154. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  155. }
  156. },
  157. top1C :'search',
  158. bottomEnd: {
  159. paging: {
  160. boundaryNumbers: false
  161. }
  162. }
  163. },
  164. pagingType: 'first_last_numbers',
  165. language: {
  166. "url": "/assets/js/Italian.json",
  167. paginate: {
  168. first: '<i class="fa-solid fa-angles-left"></i>',
  169. last: '<i class="fa-solid fa-angles-right"></i>',
  170. }
  171. },
  172. "fnInitComplete": function (oSettings, json) {
  173. var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  174. $(".dt-search").append(html);
  175. }
  176. });
  177. $('#tablesaw-350 thead tr th').addClass('col');
  178. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  179. $(document).ready(function() {
  180. $(document).on("click",".addData",function() {
  181. $(".title--section_addButton").trigger("click")
  182. });
  183. } );
  184. }
  185. </script>
  186. @endpush