course_duration.blade.php 9.1 KB

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