presence.blade.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <div class="col card--ui" id="card--dashboard">
  2. <a class="btn--ui lightGrey" href="/calendar"><i class="fa-solid fa-arrow-left"></i></a><br><br>
  3. <div class="compare--chart_wrapper d-none"></div>
  4. <div class="row">
  5. <div class="col-sm-12">
  6. <div class="row">
  7. <div class="col-auto">
  8. <h3 class="text-primary">{{$calendar->course ? $calendar->course->name : $calendar->name}}</h3>
  9. </div>
  10. <div class="col"></div>
  11. <div class="col-auto text-end">
  12. <h4>{!!$this->getDateX()!!}<br>ora inizio {{date("H:i", strtotime($calendar->from))}}</h4>
  13. </div>
  14. </div>
  15. </div>
  16. @if($manual)
  17. <div class="col-md-6">
  18. <label for="court_id" class="form-label">Motivazione</label>
  19. <select class="form-select form-select-lg me-1 " id="motivation_manual_id">
  20. <option value="">
  21. @foreach($motivations_add as $m)
  22. <option value="{{$m->id}}" {{$motivation_manual_id == $m->id ? 'selected' : ''}}>{{$m->name}}</option>
  23. @endforeach
  24. </select>
  25. </div>
  26. @else
  27. <div class="col-md-6">
  28. <label for="court_id" class="form-label">Campo</label>
  29. <select class="form-select form-select-lg me-1 " wire:model="court_id">
  30. <option value="">
  31. @foreach($courts as $c)
  32. <option value="{{$c["id"]}}">{{$c["name"]}}</option>
  33. @endforeach
  34. </select>
  35. </div>
  36. <div class="col">
  37. <label for="instructor_id" class="form-label">Istruttore</label>
  38. <select class="form-select form-select-lg me-1 " wire:model="instructor_id">
  39. <option value="">
  40. @foreach($instructors as $i)
  41. <option value="{{$i["id"]}}">{{$i["name"]}}</option>
  42. @endforeach
  43. </select>
  44. </div>
  45. <div class="col-auto mt-2">
  46. <br>
  47. <button type="button" class="btn--ui primary" data-bs-toggle="modal" data-bs-target="#instructorModal" style="width:50px">&nbsp;<i class="fa-solid fa-plus"></i></button>
  48. </div>
  49. <div class="col-md-12 mt-3">
  50. <textarea class="form-control" id="note" placeholder="Note" wire:model="note"></textarea>
  51. </div>
  52. @endif
  53. </div>
  54. <section id="resume-table" class="mt-5" style="margin-bottom:20px">
  55. <div class="compare--chart_wrapper d-none"></div>
  56. <div class="row">
  57. <div class="col-md-8 col-sm-6"></div>
  58. <div class="col-md-4 col-sm-6 mb-3">
  59. <input type="text" class="form-control" placeholder="Cerca utente" wire:model="filter">
  60. </div>
  61. </div>
  62. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  63. <thead>
  64. <tr>
  65. <th scope="col">#</th>
  66. <th scope="col">Cognome</th>
  67. <th scope="col">Nome</th>
  68. <th scope="col">Certificato</th>
  69. <th scope="col">Presenza</th>
  70. </tr>
  71. </thead>
  72. <tbody id="checkall-target">
  73. @foreach($records as $idx => $record)
  74. <tr>
  75. <td>{{$idx + 1}}</td>
  76. <td>{{$record["last_name"]}}</td>
  77. <td>{{$record["first_name"]}}</td>
  78. <td>
  79. <span class="tablesaw-cell-content d-flex align-items-center">
  80. @php
  81. list($status, $date) = explode("|", $record["certificate"]);
  82. @endphp
  83. @if($status == 0)
  84. <i class="ico--ui check suspended me-2"></i>Scaduto
  85. @endif
  86. @if($status == 1)
  87. <i class="ico--ui check due me-2"></i>In scadenza
  88. @endif
  89. @if($status == 2)
  90. <i class="ico--ui check active me-2"></i> Scadenza
  91. @endif
  92. {{$date}}
  93. </span>
  94. <td>
  95. @if ($record["status"] != 99)
  96. @if ($record["presence"])
  97. @if ($record["my_presence"])
  98. @if($manual)
  99. <a onclick="removeSingle({{$record['id']}})"><i class="fas fa-trash"></i></a>
  100. @else
  101. <input class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
  102. @endif
  103. @else
  104. {{-- &#10003; --}}
  105. <i class="fa-solid fa-lock"></i>
  106. @endif
  107. @else
  108. <input class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
  109. @endif
  110. @else
  111. <span class="p-1 text-white" style="background-color: #BE231D; border-radius: 5px">Annullata</span>&nbsp;
  112. <a href="#"><i class="fa-solid fa-undo"></i></a>
  113. @endif
  114. </td>
  115. </tr>
  116. @endforeach
  117. </tbody>
  118. </table>
  119. </section>
  120. @if($calendar->status == 0)
  121. <div class="row">
  122. <div class="col">
  123. <button type="button" class="btn--ui primary btSave btAdd" data-bs-toggle="modal" data-bs-target="#userModal" >Aggiungi utente</button>
  124. </div>
  125. </div>
  126. @endif
  127. <br>
  128. <br>
  129. <div class="row">
  130. @if($calendar->status == 0)
  131. <div class="col">
  132. @if(!$manual)
  133. <div class="col-lg-4 col-md-7 col-sm-12 showDelete" style="display:none">
  134. <label for="newMotivation" class="form-label">Motivazione</label>
  135. <select class="form-select form-select-lg me-1 " id="motivation_id">
  136. <option value="">
  137. @foreach($motivations as $m)
  138. <option value="{{$m["id"]}}">{{$m["name"]}}</option>
  139. @endforeach
  140. </select>
  141. </div>
  142. <button type="button" class="btn--ui lightGrey btSave" {{-- style="background-color:rgb(111, 31, 31) !important" --}} onclick="showHideDelete()">Annulla lezione per selezionati</button>
  143. @endif
  144. </div>
  145. @if(!$manual)
  146. <div class="col-auto mt-2 text-end">
  147. <button type="button" class="btn--ui btSave" onclick="save()">Salva</button>
  148. </div>
  149. <div class="col-xs-12 mt-2">
  150. <div class="showDelete" style="float:left;display:none;">
  151. <button type="button" class="btn--ui lightGrey btSaveDelete" onclick="hideShowDelete()">Indietro</button>
  152. <button type="button" class="btn--ui btSaveDelete" onclick="cancel()">Conferma</button>
  153. </div>
  154. </div>
  155. @endif
  156. @endif
  157. </div>
  158. <div class="row mt-3">
  159. @if($calendar->status == 0)
  160. @if(!$manual)
  161. <div class="col-md-6">
  162. </div>
  163. @endif
  164. @else
  165. LEZIONE ANNULLATA ({{$calendar->motivation ? $calendar->motivation->name : ''}})
  166. @endif
  167. </div>
  168. <div wire:ignore.self class="modal modal-lg fade" id="userModal" tabindex="-1" aria-labelledby="userModalLabel" aria-hidden="true">
  169. <div class="modal-dialog">
  170. <div class="modal-content">
  171. <div class="modal-header">
  172. <h5 class="modal-title text-primary" id="userModalLabel">Inserimento nuovo utente</h5>
  173. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  174. </div>
  175. <div class="modal-body">
  176. <h3 class="text-primary">Utente già registrato</h3>
  177. <div class="row mt-2">
  178. <div class="col-md-6">
  179. <label for="member_id" class="form-label">Aggiunge una o più persone</label>
  180. <select name="member_id" class="form-select memberClass" aria-label="Seleziona una persona" wire:model="member_ids" multiple>
  181. <option value="">--Seleziona--
  182. @foreach($members as $member)
  183. <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}} ({{$member->fiscal_code}})
  184. @endforeach
  185. </select>
  186. </div>
  187. <div class="col-md-6">
  188. <label for="newMotivation" class="form-label">Motivazione</label>
  189. <select class="form-select form-select-lg me-1 " id="newMemberMotivationId">
  190. <option value="">
  191. @foreach($motivations_add as $m)
  192. <option value="{{$m["id"]}}">{{$m["name"]}}</option>
  193. @endforeach
  194. </select>
  195. </div>
  196. </div>
  197. <br>
  198. <hr>
  199. <br>
  200. <h3 class="text-primary">Inserimento nuovo utente</h3>
  201. <br>
  202. <div class="row">
  203. <div class="col-md-6">
  204. <label for="newMemberFirstName" class="form-label">Nome</label>
  205. <input class="form-control @error('newMemberFirstName') is-invalid @enderror" type="text" id="newMemberFirstName" placeholder="Nome" >
  206. </div>
  207. <div class="col-md-6">
  208. <label for="newMemberLastName" class="form-label">Cognome</label>
  209. <input class="form-control @error('newMemberLastName') is-invalid @enderror" type="text" id="newMemberLastName" placeholder="Cognome" >
  210. </div>
  211. </div>
  212. <div class="row mt-2">
  213. <div class="col-md-6">
  214. <label for="newMemberEmail" class="form-label">Email</label>
  215. <input class="form-control @error('newMemberEmail') is-invalid @enderror" type="text" id="newMemberEmail" placeholder="Email">
  216. </div>
  217. <div class="col-md-6">
  218. <label for="newMemberFiscalCode" class="form-label">Codice fiscale</label>
  219. <input class="form-control @error('newMemberFiscalCode') is-invalid @enderror" type="text" id="newMemberFiscalCode" placeholder="Codice fiscale" maxlength="16">
  220. </div>
  221. </div>
  222. <div class="row mt-2">
  223. <div class="col-md-6">
  224. <input type="checkbox" id="newMemberToComplete" wire:model="newMemberToComplete">
  225. <label for="newMemberToComplete" class="form-label">Tesserato</label>
  226. </div>
  227. </div>
  228. </div>
  229. <div class="modal-footer">
  230. <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
  231. <button type="button" class="btn--ui btn-primary" onclick="createMember()">Salva</button>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. <div wire:ignore.self class="modal fade" id="instructorModal" tabindex="-1" aria-labelledby="instructorModalLabel" aria-hidden="true">
  237. <div class="modal-dialog">
  238. <div class="modal-content">
  239. <div class="modal-header">
  240. <h5 class="modal-title text-primary" id="instructorModalLabel">Inserimento nuovo istruttore</h5>
  241. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  242. </div>
  243. <div class="modal-body">
  244. <div class="row">
  245. <div class="col-md-6">
  246. <label for="userName" class="form-label">Nome</label>
  247. <input class="form-control @error('userName') is-invalid @enderror" type="text" id="userName" placeholder="Nome" wire:model="userName">
  248. </div>
  249. <div class="col-md-6">
  250. <label for="userEmail" class="form-label">Email</label>
  251. <input class="form-control @error('userEmail') is-invalid @enderror" type="text" id="userEmail" placeholder="Email" wire:model="userEmail">
  252. </div>
  253. </div>
  254. </div>
  255. <div class="modal-footer">
  256. <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
  257. <button type="button" class="btn--ui btn-primary" wire:click.prevent="createInstructor()">Salva</button>
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. <br><br>
  263. </div>
  264. @push('scripts')
  265. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  266. <style>
  267. table.tableHead thead {
  268. /* Important */
  269. position: sticky;
  270. z-index: 100;
  271. top: 0;
  272. }
  273. .select2-container--default .select2-selection--single{
  274. background-color: #E9F0F5;
  275. border: 0.0625rem solid #DFE5EB;
  276. font-size: 0.75rem;
  277. }
  278. .select2-selection
  279. {
  280. height: 38px !important;
  281. }
  282. .select2-selection__rendered
  283. {
  284. padding-top:3px;
  285. }
  286. .select2 {
  287. width:100% !important;
  288. }
  289. .page-link.active, .active > .page-link {
  290. background-color:#006099 !important;
  291. }
  292. .select2-selection--multiple{
  293. overflow: hidden !important;
  294. height: auto !important;
  295. }
  296. .select2-container {
  297. box-sizing: border-box;
  298. display: inline-block;
  299. margin: 0;
  300. position: relative;
  301. vertical-align: middle;
  302. }
  303. .select2-container .select2-selection--single {
  304. box-sizing: border-box;
  305. cursor: pointer;
  306. display: block;
  307. height: 38px;
  308. user-select: none;
  309. -webkit-user-select: none;
  310. }
  311. .select2-container .select2-selection--single .select2-selection__rendered {
  312. display: block;
  313. padding-left: 8px;
  314. padding-right: 20px;
  315. overflow: hidden;
  316. text-overflow: ellipsis;
  317. white-space: nowrap;
  318. }
  319. /* .total.primary
  320. {
  321. font-size:38px !important;
  322. } */
  323. /* .total.primary.comp
  324. {
  325. font-size:32px !important;
  326. } */
  327. </style>
  328. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  329. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  330. @endpush
  331. @push('scripts')
  332. <script>
  333. var showAlert = false;
  334. var isSaving = false;
  335. $(document).ready(function() {
  336. setTimeout(() => {
  337. $('.memberClass').select2({
  338. tags: false
  339. });
  340. $('.memberClass').on('change', function (e) {
  341. var data = $('.memberClass').select2("val");
  342. @this.addMember(data);
  343. });
  344. }, 100);
  345. $(".btAdd").click(function(){
  346. showAlert = true;
  347. });
  348. $(".form-select").change(function(){
  349. showAlert = true;
  350. });
  351. $(".chkM").click(function(){
  352. showAlert = true;
  353. });
  354. } );
  355. Livewire.on('reload', () => {
  356. setTimeout(() => {
  357. $('.memberClass').select2({
  358. tags: false
  359. });
  360. $('.memberClass').on('change', function (e) {
  361. var data = $('.memberClass').select2("val");
  362. @this.addMember(data);
  363. });
  364. }, 100);
  365. $(".showDelete").hide();
  366. $(".btSave").show();
  367. });
  368. window.livewire.on('saved', () => {
  369. $('#userModal').modal('hide');
  370. $('#deleteModal').modal('hide');
  371. $('#instructorModal').modal('hide');
  372. });
  373. window.livewire.on('deleteSaved', () => {
  374. $('#deleteModal').modal('hide');
  375. });
  376. window.livewire.on('setSaving', () => {
  377. isSaving = true;
  378. });
  379. function save()
  380. {
  381. var ids = [];
  382. $('input[type=checkbox]').each(function () {
  383. if ($(this).is(":checked"))
  384. {
  385. var val = $(this).val();
  386. ids.push(val);
  387. }
  388. });
  389. @if($manual)
  390. var motivation_manual_id = $("#motivation_manual_id").val();
  391. @this.set('motivation_manual_id', motivation_manual_id);
  392. @endif
  393. @this.save(ids);
  394. }
  395. function cancel()
  396. {
  397. var ids = [];
  398. $('input[type=checkbox]').each(function () {
  399. if ($(this).is(":checked"))
  400. {
  401. var val = $(this).val();
  402. ids.push(val);
  403. }
  404. });
  405. var motivation_id = $("#motivation_id").val();
  406. @this.cancel(ids, motivation_id);
  407. }
  408. function createMember()
  409. {
  410. var ids = [];
  411. /*$('input[type=checkbox]').each(function () {
  412. if ($(this).is(":checked"))
  413. {
  414. var val = $(this).val();
  415. ids.push(val);
  416. }
  417. });*/
  418. @this.set('newMemberMotivationId', $("#newMemberMotivationId").val());
  419. @this.set('newMemberFirstName', $("#newMemberFirstName").val());
  420. @this.set('newMemberLastName', $("#newMemberLastName").val());
  421. @this.set('newMemberEmail', $("#newMemberEmail").val());
  422. @this.set('newMemberFiscalCode', $("#newMemberFiscalCode").val());
  423. @this.createMember();
  424. }
  425. function removeSingle(id)
  426. {
  427. if (confirm('Sei sicuro?'))
  428. @this.removeSingle(id);
  429. }
  430. function annulla()
  431. {
  432. $('#userModal').modal('hide');
  433. $('#deleteModal').modal('hide');
  434. $('#instructorModal').modal('hide');
  435. }
  436. function showHideDelete()
  437. {
  438. $(".showDelete").show();
  439. $(".btSave").hide();
  440. }
  441. function hideShowDelete()
  442. {
  443. $(".showDelete").hide();
  444. $(".btSave").show();
  445. }
  446. window.onbeforeunload = function(){
  447. if (showAlert && !isSaving)
  448. return 'Sei sicuro';
  449. };
  450. </script>
  451. @endpush
  452. @push("css")
  453. <link href="/css/calendar.css" rel="stylesheet" />
  454. @endpush