presence.blade.php 23 KB

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