course_subscription.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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">Abbonamento 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">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->months}}</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. <a class="btn--ui lightGrey" href="/course_subscriptions"><i class="fa-solid fa-arrow-left"></i></a><br><br>
  43. <div class="container">
  44. @if (session()->has('error'))
  45. <div class="alert alert-danger" role="alert">
  46. {{ session()->get('error') }}
  47. </div>
  48. @endif
  49. <div class="row">
  50. <div class="col">
  51. <form action="">
  52. <div class="row mb-3">
  53. <div class="col-6">
  54. <div class="form--item">
  55. <label for="inputName" class="form-label">Nome</label>
  56. <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
  57. @error('name')
  58. <div class="invalid-feedback">{{ $message }}</div>
  59. @enderror
  60. </div>
  61. </div>
  62. <div class="col-6">
  63. <div class="form--item">
  64. <label for="months" class="form-label">Mesi</label>
  65. <select class="form-control" id="months" wire:model="months">
  66. @for($i=0;$i<=12;$i++)
  67. <option value="{{$i}}">{{$i}}</option>
  68. @endfor
  69. </select>
  70. </div>
  71. </div>
  72. @if(false)
  73. <div class="col-6 mt-4">
  74. <div class="form--item">
  75. <label for="month_day" class="form-label">Giorno del mese</label>
  76. <select class="form-control" id="month_day" wire:model="month_day">
  77. <option value=""></option>
  78. @for($i=1;$i<=31;$i++)
  79. <option value="{{$i}}">{{$i}} {{$i == 31 ? ' (fine mese)' : ''}}</option>
  80. @endfor
  81. </select>
  82. </div>
  83. </div>
  84. <div class="col-6 mt-4">
  85. <div class="form--item">
  86. <label for="when_start" class="form-label">Data inizio conteggio</label>
  87. <select class="form-control" id="when_start" wire:model="when_start">
  88. <option value=""></option>
  89. <option value="COURSE">Data inizio corso</option>
  90. <option value="MEMBER">Data iscrizione corso</option>
  91. </select>
  92. </div>
  93. </div>
  94. @endif
  95. <div class="col mt-4">
  96. <div class="form--item">
  97. <label for="enabled" class="form-label">Abilitato</label>
  98. <input class="form-check-input form-control" style="width:22px; height:22px;" type="checkbox" id="enabled" wire:model="enabled">
  99. </div>
  100. </div>
  101. </div>
  102. <!-- // inline input field -->
  103. <div class="form--item">
  104. <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
  105. @if($add)
  106. <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
  107. @endif
  108. @if($update)
  109. <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
  110. @endif
  111. </div>
  112. </form>
  113. </div>
  114. </div>
  115. </div>
  116. @endif
  117. </div>
  118. @push('scripts')
  119. <link href="/css/datatables.css" rel="stylesheet" />
  120. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  121. <script src="/assets/js/datatables.js"></script>
  122. <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
  123. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
  124. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
  125. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
  126. @endpush
  127. @push('scripts')
  128. <script>
  129. $(document).ready(function() {
  130. loadDataTable();
  131. } );
  132. Livewire.on('load-data-table', () => {
  133. loadDataTable();
  134. });
  135. function loadDataTable(){
  136. let date = new Date();
  137. let date_export = `${date.getFullYear()}${date.getMonth()}${date.getDate()}_`;
  138. if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
  139. $('#tablesaw-350').DataTable().destroy();
  140. }
  141. $('#tablesaw-350').DataTable({
  142. processing: true,
  143. thead: {
  144. 'th': {'background-color': 'blue'}
  145. },
  146. layout: {
  147. topStart : null,
  148. topEnd : null,
  149. top1A: {
  150. // buttons: [
  151. // {
  152. // extend: 'collection',
  153. // text: 'ESPORTA',
  154. buttons: [
  155. {
  156. extend: 'excelHtml5',
  157. text: '<i class="fa-solid fa-file-excel"></i>',
  158. action: newexportaction,
  159. title: date_export + 'Iscritti corsi',
  160. exportOptions: {
  161. columns: ":not(':last')"
  162. }
  163. },
  164. {
  165. extend: 'pdfHtml5',
  166. text: '<i class="fa-solid fa-file-pdf"></i>',
  167. action: newexportaction,
  168. title: date_export + 'Iscritti corsi',
  169. exportOptions: {
  170. columns: ":not(':last')"
  171. }
  172. },
  173. {
  174. extend: 'print',
  175. action: newexportaction,
  176. text: '<i class="fa-solid fa-print"></i>',
  177. title: date_export + 'Iscritti corsi',
  178. exportOptions: {
  179. columns: ":not(':last')"
  180. }
  181. }
  182. ],
  183. // dropup: true
  184. // }
  185. // ]
  186. },
  187. top1B : {
  188. pageLength: {
  189. menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
  190. }
  191. },
  192. top1C :'search',
  193. },
  194. pagingType: 'first_last_numbers',
  195. language: {
  196. "url": "/assets/js/Italian.json",
  197. paginate: {
  198. first: '<i class="fa-solid fa-angles-left"></i>',
  199. last: '<i class="fa-solid fa-angles-right"></i>',
  200. }
  201. },
  202. "fnInitComplete": function (oSettings, json) {
  203. var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
  204. $(".dt-search").append(html);
  205. }
  206. });
  207. $('#tablesaw-350 thead tr th').addClass('col');
  208. $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
  209. $(document).ready(function() {
  210. $(document).on("click",".addData",function() {
  211. $(".title--section_addButton").trigger("click")
  212. });
  213. } );
  214. }
  215. </script>
  216. @endpush