records.blade.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. <div class="col card--ui" id="card--dashboard">
  2. <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
  3. <div class="title--section_name d-flex align-items-center justify-content-between">
  4. <i class="ico--ui title_section utenti me-2"></i>
  5. <h2 class="primary">Prima nota</h2>
  6. </div>
  7. </header>
  8. <section id="subheader" class="">
  9. <div class="row g-3">
  10. <div class="col-md-3">
  11. Utente
  12. <select name="search_member_id" class="form-select filterMember" wire:model="filterMember">
  13. <option value="">--Seleziona--
  14. @foreach($members as $member)
  15. <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}}
  16. @endforeach
  17. </select>
  18. </div>
  19. <div class="col-md-4">
  20. Causale
  21. <select name="search_causal_id[]" class="form-select filterCausals me-2" multiple="multiple" wire:model="filterCausals">
  22. @foreach($causals as $causal)
  23. <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
  24. @endforeach
  25. </select>
  26. </div>
  27. <div class="col-md-3">
  28. Periodo
  29. <select wire:model="selectedPeriod" class="form-select" @if($isFiltering) disabled @endif style="height: 38px;">
  30. <option value="OGGI">Oggi</option>
  31. <option value="IERI">Ieri</option>
  32. <option value="MESE CORRENTE">Mese Corrente</option>
  33. <option value="MESE PRECEDENTE">Mese Precedente</option>
  34. <option value="ULTIMO TRIMESTRE">Ultimo Trimestre</option>
  35. <option value="ULTIMO QUADRIMESTRE">Ultimo Quadrimestre</option>
  36. </select>
  37. </div>
  38. <div class="col-md-2">
  39. <div class="prima--nota_buttons ms-auto" style="float:right; margin-top:25px;">
  40. <button class="btn--ui primary" wire:click="applyFilters" style="margin-right:5px;" @if($isFiltering) disabled @endif>
  41. @if($isFiltering)
  42. <i class="fas fa-spinner fa-spin"></i> CARICAMENTO...
  43. @else
  44. FILTRA
  45. @endif
  46. </button>
  47. <button class="btn--ui lightGrey reset reset" style="margin-left:5px;color:#10172A;" wire:click="resetFilters" @if($isFiltering) disabled @endif>RESET</button>
  48. </div>
  49. </div>
  50. </div>
  51. <div style="float:left; margin-top:10px; margin-bottom:10px;">
  52. <div class="dropdown">
  53. <button class="btn--ui_outline light dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false"
  54. style="color:#10172A;" @if($isFiltering) disabled @endif>
  55. ESPORTA
  56. </button>
  57. <ul class="dropdown-menu" aria-labelledby="exportDropdown">
  58. <li><a class="dropdown-item" href="#" wire:click="openExportModal">Excel</a></li>
  59. <li><a class="dropdown-item" href="#" id="print">Stampa</a></li>
  60. </ul>
  61. </div>
  62. </div>
  63. </section>
  64. <section id="resume-table" class="scrollTable records-table" style="position: relative;">
  65. @if($isFiltering)
  66. <div class="loading-overlay">
  67. <div class="loading-content">
  68. <i class="fas fa-spinner fa-spin fa-3x"></i>
  69. <p>Caricamento dati in corso...</p>
  70. </div>
  71. </div>
  72. @endif
  73. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  74. <thead>
  75. <tr>
  76. <th scope="col">Data</th>
  77. <th scope="col" style="border-left:3px solid white;">Causale</th>
  78. <th scope="col" style="border-left:3px solid white;">Dettaglio Causale</th>
  79. <th scope="col" style="border-left:3px solid white;">Stato</th>
  80. <th scope="col" style="border-left:3px solid white;">Nominativo</th>
  81. @foreach($payments as $p)
  82. <th colspan="2" scope="col" style="text-align:center; border-left:3px solid white;">{{$p->name}}</th>
  83. @endforeach
  84. </tr>
  85. <tr>
  86. <th scope="col"></th>
  87. <th scope="col" style="border-left:3px solid white;"></th>
  88. <th scope="col" style="border-left:3px solid white;"></th>
  89. <th scope="col" style="border-left:3px solid white;"></th>
  90. <th scope="col" style="border-left:3px solid white;"></th>
  91. @foreach($payments as $p)
  92. @if($p->type == 'ALL')
  93. <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
  94. <th scope="col" style="text-align:center">Uscite</th>
  95. @elseif($p->type == 'IN')
  96. <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
  97. <th scope="col" style="text-align:center;"></th>
  98. @elseif($p->type == 'OUT')
  99. <th style="border-left:3px solid white;"></th>
  100. <th scope="col" style="text-align:center;">Uscite</th>
  101. @endif
  102. @endforeach
  103. </tr>
  104. </thead>
  105. <tbody id="checkall-target">
  106. @php $count = 0; @endphp
  107. @foreach($records as $causal => $record)
  108. <tr>
  109. @php
  110. $parts = explode("§", $causal);
  111. $d = $parts[0] ?? '';
  112. $c = $parts[1] ?? '';
  113. $n = $parts[2] ?? '';
  114. $det = $parts[3] ?? '';
  115. $del = $parts[4] ?? '';
  116. $detailParts = explode('|', $det);
  117. $isMultiple = count($detailParts) > 1;
  118. $displayDetail = $isMultiple ? 'Varie' : $det;
  119. @endphp
  120. <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($d))}}</td>
  121. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$c}}</td>
  122. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  123. @if($isMultiple)
  124. <span class="varie-link" data-causals="{{implode('|', array_slice($detailParts, 1))}}" style="color: #0C6197; cursor: pointer; text-decoration: underline;">
  125. {{$displayDetail}}
  126. </span>
  127. @else
  128. {{$displayDetail}}
  129. @endif
  130. </td>
  131. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  132. @if($del == 'DELETED')
  133. <span style='color:red'>Annullata</span>
  134. @endif
  135. </td>
  136. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$n}}</td>
  137. @foreach($payments as $p)
  138. @if(isset($record[$p->name]))
  139. <td style="text-align:right; border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  140. @if(isset($record[$p->name]["IN"]))
  141. <span class="tablesaw-cell-content " style="color:green">{{formatPrice($record[$p->name]["IN"])}}</span>
  142. @endif
  143. </td>
  144. <td style="text-align:right;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  145. @if(isset($record[$p->name]["OUT"]))
  146. <span class="tablesaw-cell-content " style="color:red">{{formatPrice($record[$p->name]["OUT"])}}</span>
  147. @endif
  148. </td>
  149. @else
  150. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
  151. <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
  152. @endif
  153. @endforeach
  154. </tr>
  155. @php $count++; @endphp
  156. @endforeach
  157. </tbody>
  158. <tfoot>
  159. <tr>
  160. <td></td>
  161. <td></td>
  162. <td></td>
  163. <td></td>
  164. <td><b>Totale</b></td>
  165. @foreach($payments as $p)
  166. @if(isset($totals[$p->name]))
  167. @if($p->type == 'ALL')
  168. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["IN"] : 0)}}</b></span></td>
  169. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["OUT"] : 0)}}</b></span></td>
  170. @elseif($p->type == 'IN')
  171. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["IN"] : 0)}}</b></span></td>
  172. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>&nbsp;</b></span></td>
  173. @elseif($p->type == 'OUT')
  174. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>&nbsp;</b></span></td>
  175. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["OUT"] : 0)}}</b></span></td>
  176. @endif
  177. @else
  178. @if($p->type == 'ALL')
  179. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["IN"] : 0)}}</b></span></td>
  180. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["OUT"] : 0)}}</b></span></td>
  181. @elseif($p->type == 'IN')
  182. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["IN"] : 0)}}</b></span></td>
  183. <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>&nbsp;</b></span></td>
  184. @elseif($p->type == 'OUT')
  185. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>&nbsp;</b></span></td>
  186. <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice(isset($totals[$p->name]) ? $totals[$p->name]["OUT"] : 0)}}</b></span></td>
  187. @endif
  188. @endif
  189. @endforeach
  190. </tr>
  191. <tr style="display:none">
  192. <td></td>
  193. <td><b>Differenza</b></td>
  194. @foreach($payments as $p)
  195. @if(isset($totals[$p->name]))
  196. @php
  197. $diff = $totals[$p->name]["IN"] - $totals[$p->name]["OUT"];
  198. @endphp
  199. @if($diff < 0)
  200. <td></td>
  201. @endif
  202. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:{{$diff > 0 ? 'green' : 'red'}}; font-size:18px;"><b>{{formatPrice($diff)}}</b></span></td>
  203. @if($diff > 0)
  204. <td></td>
  205. @endif
  206. @else
  207. <td colspan="2" style="text-align:right"><b>{{formatPrice(0)}}</b></td>
  208. @endif
  209. @endforeach
  210. </tr>
  211. </tfoot>
  212. </table>
  213. <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-bottom"><i class="fas fa-arrow-down"></i></button>
  214. <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-top"><i class="fas fa-arrow-up"></i></button>
  215. </section>
  216. <div class="modal fade" id="causalsModal" tabindex="-1" aria-labelledby="causalsModalLabel" aria-hidden="true">
  217. <div class="modal-dialog modal-lg">
  218. <div class="modal-content">
  219. <div class="modal-header" style="background-color: #0C6197!important;">
  220. <h5 class="modal-title" id="causalsModalLabel">Dettaglio Causali</h5>
  221. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="CHIUDI"></button>
  222. </div>
  223. <div class="modal-body">
  224. <div class="row">
  225. <div class="col-12">
  226. <h6>Causali incluse:</h6>
  227. <ul id="causalsList" class="list-group list-group-flush">
  228. </ul>
  229. </div>
  230. </div>
  231. </div>
  232. <div class="modal-footer" style="background-color: #FFF!important;">
  233. <button type="button" class="btn--ui lightGrey me-2" data-bs-dismiss="modal">CHIUDI</button>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <!-- Modal for Export Date Range -->
  239. <div class="modal fade" id="exportModal" tabindex="-1" aria-labelledby="exportModalLabel" aria-hidden="true">
  240. <div class="modal-dialog">
  241. <div class="modal-content">
  242. <div class="modal-header" style="background-color: #0C6197!important;">
  243. <h5 class="modal-title" id="exportModalLabel">Seleziona Periodo per Export</h5>
  244. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="CHIUDI"></button>
  245. </div>
  246. <div class="modal-body">
  247. <div class="row g-3">
  248. <div class="col-md-6">
  249. <label for="exportFromDate" class="form-label">Data Inizio</label>
  250. <input type="date" class="form-control" id="exportFromDate" wire:model.defer="exportFromDate">
  251. </div>
  252. <div class="col-md-6">
  253. <label for="exportToDate" class="form-label">Data Fine</label>
  254. <input type="date" class="form-control" id="exportToDate" wire:model.defer="exportToDate">
  255. </div>
  256. </div>
  257. <div class="row mt-3">
  258. <div class="col-12">
  259. <small class="text-muted">
  260. <i class="fas fa-info-circle me-1"></i>
  261. L'export includerà tutti i record nel periodo selezionato con i filtri attualmente applicati.
  262. </small>
  263. </div>
  264. </div>
  265. </div>
  266. <div class="modal-footer" style="background-color: #FFF!important;">
  267. <button type="button" class="btn--ui lightGrey me-2" data-bs-dismiss="modal">ANNULLA</button>
  268. <button type="button" class="btn--ui primary" wire:click="exportWithDateRange" @if($isExporting) disabled @endif>
  269. @if($isExporting)
  270. <i class="fas fa-spinner fa-spin me-1"></i> ESPORTANDO...
  271. @else
  272. <i class="fas fa-download me-1"></i> ESPORTA
  273. @endif
  274. </button>
  275. </div>
  276. </div>
  277. </div>
  278. </div>
  279. </div>
  280. @push('scripts')
  281. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  282. @endpush
  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. .loading-overlay {
  287. position: absolute;
  288. top: 0;
  289. left: 0;
  290. right: 0;
  291. bottom: 0;
  292. background-color: rgba(255, 255, 255, 0.9);
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. z-index: 1000;
  297. border-radius: 4px;
  298. }
  299. .loading-content {
  300. text-align: center;
  301. color: #0C6197;
  302. }
  303. .loading-content i {
  304. margin-bottom: 15px;
  305. color: #0C6197;
  306. }
  307. .loading-content p {
  308. margin: 0;
  309. font-size: 16px;
  310. font-weight: 500;
  311. color: #10172A;
  312. }
  313. .modal {
  314. z-index: 9999 !important;
  315. }
  316. .modal-backdrop {
  317. z-index: 9998 !important;
  318. background-color: rgba(0, 0, 0, 0.6) !important;
  319. }
  320. .modal-content {
  321. border-radius: 8px;
  322. border: none;
  323. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  324. z-index: 10000 !important;
  325. }
  326. .modal-header {
  327. color: white;
  328. border-bottom: none;
  329. border-radius: 8px 8px 0 0;
  330. }
  331. .modal-header .btn-close {
  332. filter: invert(1);
  333. }
  334. .modal-title {
  335. font-weight: 600;
  336. }
  337. .varie-link:hover {
  338. color: #084c6b !important;
  339. text-decoration: underline !important;
  340. }
  341. #btn-back-to-top {
  342. background-color: #0C6197;
  343. color: white;
  344. position: fixed;
  345. display: none;
  346. }
  347. #btn-back-to-bottom {
  348. background-color: #0C6197;
  349. color: white;
  350. position: fixed;
  351. z-index: 9999;
  352. display: none;
  353. }
  354. button[disabled] {
  355. opacity: 0.7;
  356. cursor: not-allowed;
  357. }
  358. .btn--ui .fa-spinner {
  359. margin-right: 5px;
  360. }
  361. .scrollTable {
  362. margin-left: 0px;
  363. margin-right: 0px;
  364. padding: 15px;
  365. overflow-x: auto;
  366. overflow-y: auto;
  367. white-space: nowrap;
  368. border: 1px solid #ddd;
  369. }
  370. ::-webkit-scrollbar-thumb {
  371. background: #e4e4e4;
  372. border-radius: 10px;
  373. }
  374. table thead {
  375. position: sticky;
  376. z-index: 100;
  377. top: 0;
  378. }
  379. .select2-container--default .select2-selection--single {
  380. background-color: #E9F0F5;
  381. border: 0.0625rem solid #DFE5EB;
  382. font-size: 0.75rem;
  383. height: 38px !important;
  384. }
  385. .select2-selection__rendered {
  386. padding-top: 3px;
  387. }
  388. .select2 {
  389. width: 100% !important;
  390. }
  391. .select2-selection--multiple {
  392. overflow: hidden !important;
  393. height: auto !important;
  394. }
  395. .select2-container {
  396. box-sizing: border-box;
  397. display: inline-block;
  398. margin: 0;
  399. position: relative;
  400. vertical-align: middle;
  401. z-index: 999 !important;
  402. }
  403. .select2-dropdown {
  404. z-index: 999 !important;
  405. }
  406. .select2-container .select2-selection--single {
  407. box-sizing: border-box;
  408. cursor: pointer;
  409. display: block;
  410. height: 38px;
  411. user-select: none;
  412. -webkit-user-select: none;
  413. }
  414. .select2-container .select2-selection--single .select2-selection__rendered {
  415. display: block;
  416. padding-left: 8px;
  417. padding-right: 20px;
  418. overflow: hidden;
  419. text-overflow: ellipsis;
  420. white-space: nowrap;
  421. }
  422. button#exportDropdown.btn--ui_outline.light {
  423. font-weight: normal !important;
  424. }
  425. .btn--ui_outline.light.dropdown-toggle:active,
  426. .btn--ui_outline.light.dropdown-toggle:focus,
  427. .btn--ui_outline.light.dropdown-toggle.show {
  428. background-color: transparent !important;
  429. color: #10172A !important;
  430. box-shadow: none !important;
  431. }
  432. .btn--ui_outline.light.dropdown-toggle:hover {
  433. background-color: transparent !important;
  434. color: #10172A !important;
  435. }
  436. .form-select {
  437. height: 38px !important;
  438. }
  439. .form-control {
  440. height: 43px !important;
  441. }
  442. #exportModal .modal-body {
  443. padding: 1.5rem;
  444. }
  445. #exportModal .form-label {
  446. font-weight: 600;
  447. color: #10172A;
  448. margin-bottom: 0.5rem;
  449. }
  450. #exportModal .text-muted {
  451. font-size: 0.875rem;
  452. }
  453. .btn--ui[disabled] .fa-spinner {
  454. margin-right: 0.5rem;
  455. }
  456. body.modal-open {
  457. overflow: hidden;
  458. }
  459. .modal-dialog {
  460. z-index: 10001 !important;
  461. margin: 1.75rem auto;
  462. }
  463. .list-group-item {
  464. border-left: none;
  465. border-right: none;
  466. border-top: 1px solid #dee2e6;
  467. padding: 12px 15px;
  468. }
  469. .list-group-item:first-child {
  470. border-top: none;
  471. }
  472. .list-group-item:last-child {
  473. border-bottom: none;
  474. }
  475. @media (max-width: 768px) {
  476. .col-md-2, .col-md-3, .col-md-4 {
  477. margin-bottom: 10px;
  478. }
  479. .prima--nota_buttons {
  480. float: none !important;
  481. margin-top: 10px !important;
  482. text-align: center;
  483. }
  484. }
  485. </style>
  486. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  487. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  488. <script src="/assets/js/aCollapTable.js"></script>
  489. @endpush
  490. @push('scripts')
  491. <script>
  492. function closeSelect2Dropdowns() {
  493. $('.filterCausals').each(function() {
  494. if ($(this).hasClass('select2-hidden-accessible')) {
  495. $(this).select2('close');
  496. }
  497. });
  498. $('.filterMember').each(function() {
  499. if ($(this).hasClass('select2-hidden-accessible')) {
  500. $(this).select2('close');
  501. }
  502. });
  503. }
  504. function load() {
  505. $(document).ready(function(){
  506. $(document).on("keypress", $('.filterCausals'), function (e) {
  507. setTimeout(() => {
  508. $(".select2-results__option").each(function(){
  509. var txt = $(this).html();
  510. var count = (txt.match(/-/g) || []).length;
  511. $(this).addClass('paddingLeftSelect' + count);
  512. });
  513. }, 100);
  514. });
  515. if (!$('.filterCausals').hasClass('select2-hidden-accessible')) {
  516. $('.filterCausals').select2({
  517. "language": {"noResults": function(){return "Nessun risultato";}},
  518. "dropdownParent": $('body'),
  519. "width": "100%"
  520. });
  521. }
  522. $('.filterCausals').off('change.customHandler').on('change.customHandler', function (e) {
  523. var data = $('.filterCausals').select2("val");
  524. @this.set('filterCausals', data);
  525. });
  526. $('.filterCausals').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
  527. if ($('#causalsModal').hasClass('show')) {
  528. $('#causalsModal').modal('hide');
  529. }
  530. setTimeout(() => {
  531. $(".select2-results__option").each(function(){
  532. var txt = $(this).html();
  533. var count = (txt.match(/-/g) || []).length;
  534. $(this).addClass('paddingLeftSelect' + count);
  535. });
  536. }, 100);
  537. });
  538. if (!$('.filterMember').hasClass('select2-hidden-accessible')) {
  539. $('.filterMember').select2({
  540. "language": {"noResults": function(){return "Nessun risultato";}},
  541. "dropdownParent": $('body'),
  542. "width": "100%"
  543. });
  544. }
  545. $('.filterMember').off('change.customHandler').on('change.customHandler', function (e) {
  546. var data = $('.filterMember').select2("val");
  547. @this.set('filterMember', data);
  548. });
  549. $('.filterMember').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
  550. if ($('#causalsModal').hasClass('show')) {
  551. $('#causalsModal').modal('hide');
  552. }
  553. });
  554. });
  555. }
  556. function printData() {
  557. var divToPrint = document.getElementById("tablesaw-350");
  558. newWin = window.open("");
  559. var htmlToPrint = '' +
  560. '<style type="text/css">' +
  561. 'table th, table td {' +
  562. 'border:1px solid #000;' +
  563. 'padding:0.5em;' +
  564. '}' +
  565. '</style>';
  566. htmlToPrint += divToPrint.outerHTML;
  567. newWin.document.write(htmlToPrint);
  568. newWin.document.close();
  569. newWin.print();
  570. newWin.close();
  571. }
  572. function scrollFunction() {
  573. const element = document.getElementById('resume-table');
  574. const mybuttonBottom = document.getElementById("btn-back-to-bottom");
  575. const mybutton = document.getElementById("btn-back-to-top");
  576. if (element.scrollTop > 20) {
  577. mybutton.style.display = "block";
  578. mybuttonBottom.style.display = "block";
  579. } else {
  580. mybutton.style.display = "none";
  581. mybuttonBottom.style.display = "none";
  582. }
  583. }
  584. function backToTop() {
  585. $('#resume-table').scrollTop(0);
  586. }
  587. function backToBottom() {
  588. $('#resume-table').scrollTop($('#resume-table')[0].scrollHeight);
  589. }
  590. $(document).ready(function() {
  591. load();
  592. document.querySelector("#print").addEventListener("click", function(){
  593. printData();
  594. });
  595. const element = document.getElementById('resume-table');
  596. element.onscroll = scrollFunction;
  597. const mybuttonBottom = document.getElementById("btn-back-to-bottom");
  598. const mybutton = document.getElementById("btn-back-to-top");
  599. mybutton.addEventListener("click", backToTop);
  600. mybuttonBottom.addEventListener("click", backToBottom);
  601. $(document).on('click', '.varie-link', function(e) {
  602. e.preventDefault();
  603. e.stopPropagation();
  604. closeSelect2Dropdowns();
  605. const causalsData = $(this).data('causals');
  606. if (causalsData) {
  607. const causals = causalsData.split('|');
  608. $('#causalsList').empty();
  609. causals.forEach(function(causal) {
  610. if (causal.trim()) {
  611. $('#causalsList').append(
  612. '<li class="list-group-item">' +
  613. '<i class="fas fa-tags me-2" style="color: #0C6197;"></i>' +
  614. causal.trim() +
  615. '</li>'
  616. );
  617. }
  618. });
  619. $('#causalsModal').modal('show');
  620. $('#causalsModal').on('shown.bs.modal', function () {
  621. $(this).find('.btn-close').focus();
  622. });
  623. }
  624. });
  625. $('#causalsModal').on('show.bs.modal', function () {
  626. closeSelect2Dropdowns();
  627. $('body').addClass('modal-open');
  628. });
  629. $('#causalsModal').on('hidden.bs.modal', function () {
  630. $('body').removeClass('modal-open');
  631. });
  632. });
  633. Livewire.on('load-table', () => {
  634. load();
  635. });
  636. Livewire.on('load-select', () => {
  637. load();
  638. });
  639. Livewire.on('filters-reset', () => {
  640. $('.filterMember').val('').trigger('change');
  641. $('.filterCausals').val('').trigger('change');
  642. load();
  643. });
  644. Livewire.on('show-export-modal', () => {
  645. $('#exportModal').modal('show');
  646. });
  647. Livewire.on('hide-export-modal', () => {
  648. $('#exportModal').modal('hide');
  649. });
  650. </script>
  651. @endpush