records.blade.php 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  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. <div class="modal fade" id="exportModal" tabindex="-1" aria-labelledby="exportModalLabel" aria-hidden="true">
  239. <div class="modal-dialog">
  240. <div class="modal-content">
  241. <div class="modal-header" style="background-color: #0C6197!important;">
  242. <h5 class="modal-title" id="exportModalLabel">Seleziona Periodo per Export</h5>
  243. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="CHIUDI"></button>
  244. </div>
  245. <div class="modal-body">
  246. <div class="row g-3">
  247. <div class="col-md-6">
  248. <label for="exportFromDate" class="form-label">Data Inizio</label>
  249. <input type="date" class="form-control" id="exportFromDate" wire:model.defer="exportFromDate">
  250. </div>
  251. <div class="col-md-6">
  252. <label for="exportToDate" class="form-label">Data Fine</label>
  253. <input type="date" class="form-control" id="exportToDate" wire:model.defer="exportToDate">
  254. </div>
  255. </div>
  256. <div class="row mt-4">
  257. <div class="col-12">
  258. <div class="form-check export-method-check">
  259. <input class="form-check-input" type="checkbox" id="sendViaEmail" wire:model.defer="sendViaEmail">
  260. <label class="form-check-label" for="sendViaEmail">
  261. <i class="fas fa-envelope me-2"></i>Invia via Email
  262. <small class="d-block text-muted mt-1">L'export verrà elaborato in background e inviato alla tua email</small>
  263. </label>
  264. </div>
  265. </div>
  266. </div>
  267. <div class="row mt-3" style="display: none;" id="emailAddressRow">
  268. <div class="col-12">
  269. <label for="exportEmailAddress" class="form-label">
  270. <i class="fas fa-envelope me-1"></i>Indirizzo Email
  271. </label>
  272. <input type="email" class="form-control" id="exportEmailAddress"
  273. wire:model.defer="exportEmailAddress"
  274. placeholder="inserisci@email.com">
  275. <div class="invalid-feedback" id="emailValidationFeedback">
  276. Inserisci un indirizzo email valido
  277. </div>
  278. <small class="form-text text-muted">
  279. Il file Excel verrà inviato a questo indirizzo
  280. </small>
  281. </div>
  282. </div>
  283. <div class="row mt-3" style="display: none;" id="emailSubjectRow">
  284. <div class="col-12">
  285. <label for="exportEmailSubject" class="form-label">
  286. <i class="fas fa-tag me-1"></i>Oggetto Email
  287. </label>
  288. <input type="text" class="form-control" id="exportEmailSubject"
  289. wire:model.defer="exportEmailSubject"
  290. placeholder="Prima Nota - Export">
  291. <small class="form-text text-muted">
  292. Personalizza l'oggetto dell'email
  293. </small>
  294. </div>
  295. </div>
  296. <div class="row mt-3">
  297. <div class="col-12">
  298. <div class="alert alert-info d-flex align-items-start">
  299. <i class="fas fa-info-circle me-2 mt-1"></i>
  300. <div>
  301. <strong>Informazioni Export:</strong>
  302. <ul class="mb-0 mt-1">
  303. <li>L'export includerà tutti i record nel periodo selezionato</li>
  304. <li>Verranno applicati i filtri attualmente attivi</li>
  305. <li id="emailProcessingInfo" style="display: none;">L'elaborazione avverrà in background, potrai continuare a usare l'applicazione</li>
  306. </ul>
  307. </div>
  308. </div>
  309. </div>
  310. </div>
  311. </div>
  312. <div class="modal-footer" style="background-color: #FFF!important;">
  313. <button type="button" class="btn--ui lightGrey me-2" data-bs-dismiss="modal">ANNULLA</button>
  314. <button type="button" class="btn--ui primary" wire:click="exportWithDateRange" @if($isExporting) disabled @endif>
  315. @if($isExporting)
  316. <div class="d-flex align-items-center">
  317. <div class="spinner-border spinner-border-sm me-2" role="status">
  318. <span class="visually-hidden">Loading...</span>
  319. </div>
  320. <span id="exportButtonText">ELABORAZIONE...</span>
  321. </div>
  322. @else
  323. <i class="fas fa-download me-1" id="exportIcon"></i>
  324. <span id="exportButtonText">ESPORTA</span>
  325. @endif
  326. </button>
  327. </div>
  328. </div>
  329. </div>
  330. </div>
  331. <div class="toast-container position-fixed top-0 end-0 p-3" style="z-index: 11000;">
  332. <!-- Toasts will be dynamically added here -->
  333. </div>
  334. </div>
  335. @push('scripts')
  336. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  337. @endpush
  338. @push('scripts')
  339. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  340. <style>
  341. .loading-overlay {
  342. position: absolute;
  343. top: 0;
  344. left: 0;
  345. right: 0;
  346. bottom: 0;
  347. background-color: rgba(255, 255, 255, 0.9);
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. z-index: 1000;
  352. border-radius: 4px;
  353. }
  354. .loading-content {
  355. text-align: center;
  356. color: #0C6197;
  357. }
  358. .loading-content i {
  359. margin-bottom: 15px;
  360. color: #0C6197;
  361. }
  362. .loading-content p {
  363. margin: 0;
  364. font-size: 16px;
  365. font-weight: 500;
  366. color: #10172A;
  367. }
  368. .modal {
  369. z-index: 9999 !important;
  370. }
  371. .modal-backdrop {
  372. z-index: 9998 !important;
  373. background-color: rgba(0, 0, 0, 0.6) !important;
  374. }
  375. .modal-content {
  376. border-radius: 8px;
  377. border: none;
  378. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  379. z-index: 10000 !important;
  380. }
  381. .modal-header {
  382. color: white;
  383. border-bottom: none;
  384. border-radius: 8px 8px 0 0;
  385. }
  386. .modal-header .btn-close {
  387. filter: invert(1);
  388. }
  389. .modal-title {
  390. font-weight: 600;
  391. }
  392. .varie-link:hover {
  393. color: #084c6b !important;
  394. text-decoration: underline !important;
  395. }
  396. #btn-back-to-top {
  397. background-color: #0C6197;
  398. color: white;
  399. position: fixed;
  400. display: none;
  401. }
  402. #btn-back-to-bottom {
  403. background-color: #0C6197;
  404. color: white;
  405. position: fixed;
  406. z-index: 9999;
  407. display: none;
  408. }
  409. button[disabled] {
  410. opacity: 0.7;
  411. cursor: not-allowed;
  412. }
  413. .btn--ui .fa-spinner {
  414. margin-right: 5px;
  415. }
  416. .scrollTable {
  417. margin-left: 0px;
  418. margin-right: 0px;
  419. padding: 15px;
  420. overflow-x: auto;
  421. overflow-y: auto;
  422. white-space: nowrap;
  423. border: 1px solid #ddd;
  424. }
  425. ::-webkit-scrollbar-thumb {
  426. background: #e4e4e4;
  427. border-radius: 10px;
  428. }
  429. table thead {
  430. position: sticky;
  431. z-index: 100;
  432. top: 0;
  433. }
  434. .select2-container--default .select2-selection--single {
  435. background-color: #E9F0F5;
  436. border: 0.0625rem solid #DFE5EB;
  437. font-size: 0.75rem;
  438. height: 38px !important;
  439. }
  440. .select2-selection__rendered {
  441. padding-top: 3px;
  442. }
  443. .select2 {
  444. width: 100% !important;
  445. }
  446. .select2-selection--multiple {
  447. overflow: hidden !important;
  448. height: auto !important;
  449. }
  450. .select2-container {
  451. box-sizing: border-box;
  452. display: inline-block;
  453. margin: 0;
  454. position: relative;
  455. vertical-align: middle;
  456. z-index: 999 !important;
  457. }
  458. .select2-dropdown {
  459. z-index: 999 !important;
  460. }
  461. .select2-container .select2-selection--single {
  462. box-sizing: border-box;
  463. cursor: pointer;
  464. display: block;
  465. height: 38px;
  466. user-select: none;
  467. -webkit-user-select: none;
  468. }
  469. .select2-container .select2-selection--single .select2-selection__rendered {
  470. display: block;
  471. padding-left: 8px;
  472. padding-right: 20px;
  473. overflow: hidden;
  474. text-overflow: ellipsis;
  475. white-space: nowrap;
  476. }
  477. button#exportDropdown.btn--ui_outline.light {
  478. font-weight: normal !important;
  479. }
  480. .btn--ui_outline.light.dropdown-toggle:active,
  481. .btn--ui_outline.light.dropdown-toggle:focus,
  482. .btn--ui_outline.light.dropdown-toggle.show {
  483. background-color: transparent !important;
  484. color: #10172A !important;
  485. box-shadow: none !important;
  486. }
  487. .btn--ui_outline.light.dropdown-toggle:hover {
  488. background-color: transparent !important;
  489. color: #10172A !important;
  490. }
  491. .form-select {
  492. height: 38px !important;
  493. }
  494. .form-control {
  495. height: 43px !important;
  496. }
  497. #exportModal .modal-body {
  498. padding: 1.5rem;
  499. }
  500. #exportModal .form-label {
  501. font-weight: 600;
  502. color: #10172A;
  503. margin-bottom: 0.5rem;
  504. }
  505. #exportModal .text-muted {
  506. font-size: 0.875rem;
  507. }
  508. .btn--ui[disabled] .fa-spinner {
  509. margin-right: 0.5rem;
  510. }
  511. body.modal-open {
  512. overflow: hidden;
  513. }
  514. .modal-dialog {
  515. z-index: 10001 !important;
  516. margin: 1.75rem auto;
  517. }
  518. .list-group-item {
  519. border-left: none;
  520. border-right: none;
  521. border-top: 1px solid #dee2e6;
  522. padding: 12px 15px;
  523. }
  524. .list-group-item:first-child {
  525. border-top: none;
  526. }
  527. .list-group-item:last-child {
  528. border-bottom: none;
  529. }
  530. @media (max-width: 768px) {
  531. .col-md-2, .col-md-3, .col-md-4 {
  532. margin-bottom: 10px;
  533. }
  534. .prima--nota_buttons {
  535. float: none !important;
  536. margin-top: 10px !important;
  537. text-align: center;
  538. }
  539. }
  540. .export-method-check {
  541. padding: 16px 16px 16px 50px;
  542. background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  543. border-radius: 8px;
  544. border: 2px solid #e9ecef;
  545. transition: all 0.3s ease;
  546. cursor: pointer;
  547. position: relative;
  548. }
  549. .export-method-check:hover {
  550. border-color: #0C6197;
  551. background: linear-gradient(135deg, #e8f4f8 0%, #d1ecf1 100%);
  552. }
  553. .export-method-check .form-check-input {
  554. position: absolute;
  555. left: 16px;
  556. top: 50%;
  557. transform: translateY(-50%);
  558. margin: 0;
  559. width: 20px;
  560. height: 20px;
  561. background-color: #fff;
  562. border: 2px solid #dee2e6;
  563. border-radius: 4px;
  564. cursor: pointer;
  565. }
  566. .export-method-check .form-check-input:checked {
  567. background-color: #0C6197;
  568. border-color: #0C6197;
  569. }
  570. .export-method-check .form-check-input:checked ~ .form-check-label {
  571. color: #0C6197;
  572. font-weight: 600;
  573. }
  574. .export-method-check .form-check-label {
  575. font-weight: 500;
  576. color: #495057;
  577. cursor: pointer;
  578. margin-left: 0;
  579. display: block;
  580. }
  581. .form-check-input:focus {
  582. border-color: #0C6197;
  583. outline: 0;
  584. box-shadow: 0 0 0 0.2rem rgba(12, 97, 151, 0.25);
  585. }
  586. #emailAddressRow.show, #emailSubjectRow.show {
  587. display: block !important;
  588. animation: slideDown 0.3s ease-out;
  589. }
  590. @keyframes slideDown {
  591. from {
  592. opacity: 0;
  593. transform: translateY(-10px);
  594. }
  595. to {
  596. opacity: 1;
  597. transform: translateY(0);
  598. }
  599. }
  600. .invalid-feedback {
  601. display: none;
  602. }
  603. .is-invalid ~ .invalid-feedback {
  604. display: block;
  605. }
  606. .alert-info {
  607. background-color: rgba(12, 97, 151, 0.1);
  608. border-color: rgba(12, 97, 151, 0.2);
  609. color: #0C6197;
  610. }
  611. .spinner-border-sm {
  612. width: 1rem;
  613. height: 1rem;
  614. }
  615. .toast {
  616. min-width: 300px;
  617. }
  618. .toast-body {
  619. font-weight: 500;
  620. }
  621. .btn--ui:disabled {
  622. opacity: 0.7;
  623. cursor: not-allowed;
  624. }
  625. </style>
  626. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  627. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  628. <script src="/assets/js/aCollapTable.js"></script>
  629. @endpush
  630. @push('scripts')
  631. <script>
  632. function closeSelect2Dropdowns() {
  633. $('.filterCausals').each(function() {
  634. if ($(this).hasClass('select2-hidden-accessible')) {
  635. $(this).select2('close');
  636. }
  637. });
  638. $('.filterMember').each(function() {
  639. if ($(this).hasClass('select2-hidden-accessible')) {
  640. $(this).select2('close');
  641. }
  642. });
  643. }
  644. function load() {
  645. $(document).ready(function(){
  646. $(document).on("keypress", $('.filterCausals'), function (e) {
  647. setTimeout(() => {
  648. $(".select2-results__option").each(function(){
  649. var txt = $(this).html();
  650. var count = (txt.match(/-/g) || []).length;
  651. $(this).addClass('paddingLeftSelect' + count);
  652. });
  653. }, 100);
  654. });
  655. if (!$('.filterCausals').hasClass('select2-hidden-accessible')) {
  656. $('.filterCausals').select2({
  657. "language": {"noResults": function(){return "Nessun risultato";}},
  658. "dropdownParent": $('body'),
  659. "width": "100%"
  660. });
  661. }
  662. $('.filterCausals').off('change.customHandler').on('change.customHandler', function (e) {
  663. var data = $('.filterCausals').select2("val");
  664. @this.set('filterCausals', data);
  665. });
  666. $('.filterCausals').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
  667. if ($('#causalsModal').hasClass('show')) {
  668. $('#causalsModal').modal('hide');
  669. }
  670. setTimeout(() => {
  671. $(".select2-results__option").each(function(){
  672. var txt = $(this).html();
  673. var count = (txt.match(/-/g) || []).length;
  674. $(this).addClass('paddingLeftSelect' + count);
  675. });
  676. }, 100);
  677. });
  678. if (!$('.filterMember').hasClass('select2-hidden-accessible')) {
  679. $('.filterMember').select2({
  680. "language": {"noResults": function(){return "Nessun risultato";}},
  681. "dropdownParent": $('body'),
  682. "width": "100%"
  683. });
  684. }
  685. $('.filterMember').off('change.customHandler').on('change.customHandler', function (e) {
  686. var data = $('.filterMember').select2("val");
  687. @this.set('filterMember', data);
  688. });
  689. $('.filterMember').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
  690. if ($('#causalsModal').hasClass('show')) {
  691. $('#causalsModal').modal('hide');
  692. }
  693. });
  694. });
  695. }
  696. function printData() {
  697. var divToPrint = document.getElementById("tablesaw-350");
  698. newWin = window.open("");
  699. var htmlToPrint = '' +
  700. '<style type="text/css">' +
  701. 'table th, table td {' +
  702. 'border:1px solid #000;' +
  703. 'padding:0.5em;' +
  704. '}' +
  705. '</style>';
  706. htmlToPrint += divToPrint.outerHTML;
  707. newWin.document.write(htmlToPrint);
  708. newWin.document.close();
  709. newWin.print();
  710. newWin.close();
  711. }
  712. function scrollFunction() {
  713. const element = document.getElementById('resume-table');
  714. const mybuttonBottom = document.getElementById("btn-back-to-bottom");
  715. const mybutton = document.getElementById("btn-back-to-top");
  716. if (element.scrollTop > 20) {
  717. mybutton.style.display = "block";
  718. mybuttonBottom.style.display = "block";
  719. } else {
  720. mybutton.style.display = "none";
  721. mybuttonBottom.style.display = "none";
  722. }
  723. }
  724. function backToTop() {
  725. $('#resume-table').scrollTop(0);
  726. }
  727. function backToBottom() {
  728. $('#resume-table').scrollTop($('#resume-table')[0].scrollHeight);
  729. }
  730. $(document).ready(function() {
  731. load();
  732. document.querySelector("#print").addEventListener("click", function(){
  733. printData();
  734. });
  735. const element = document.getElementById('resume-table');
  736. element.onscroll = scrollFunction;
  737. const mybuttonBottom = document.getElementById("btn-back-to-bottom");
  738. const mybutton = document.getElementById("btn-back-to-top");
  739. mybutton.addEventListener("click", backToTop);
  740. mybuttonBottom.addEventListener("click", backToBottom);
  741. $(document).on('click', '.varie-link', function(e) {
  742. e.preventDefault();
  743. e.stopPropagation();
  744. closeSelect2Dropdowns();
  745. const causalsData = $(this).data('causals');
  746. if (causalsData) {
  747. const causals = causalsData.split('|');
  748. $('#causalsList').empty();
  749. causals.forEach(function(causal) {
  750. if (causal.trim()) {
  751. $('#causalsList').append(
  752. '<li class="list-group-item">' +
  753. '<i class="fas fa-tags me-2" style="color: #0C6197;"></i>' +
  754. causal.trim() +
  755. '</li>'
  756. );
  757. }
  758. });
  759. $('#causalsModal').modal('show');
  760. $('#causalsModal').on('shown.bs.modal', function () {
  761. $(this).find('.btn-close').focus();
  762. });
  763. }
  764. });
  765. $('#causalsModal').on('show.bs.modal', function () {
  766. closeSelect2Dropdowns();
  767. $('body').addClass('modal-open');
  768. });
  769. $('#causalsModal').on('hidden.bs.modal', function () {
  770. $('body').removeClass('modal-open');
  771. });
  772. });
  773. Livewire.on('load-table', () => {
  774. load();
  775. });
  776. Livewire.on('load-select', () => {
  777. load();
  778. });
  779. Livewire.on('filters-reset', () => {
  780. $('.filterMember').val('').trigger('change');
  781. $('.filterCausals').val('').trigger('change');
  782. load();
  783. });
  784. Livewire.on('show-export-modal', () => {
  785. $('#exportModal').modal('show');
  786. });
  787. Livewire.on('hide-export-modal', () => {
  788. $('#exportModal').modal('hide');
  789. });
  790. function showToast(type, message, duration = 5000) {
  791. const toastContainer = document.querySelector('.toast-container');
  792. if (!toastContainer) {
  793. console.error('Toast container not found');
  794. return;
  795. }
  796. const toastId = 'toast-' + Date.now();
  797. const toastColors = {
  798. success: 'bg-success',
  799. error: 'bg-danger',
  800. warning: 'bg-warning',
  801. info: 'bg-info'
  802. };
  803. const toastIcons = {
  804. success: 'fa-check-circle',
  805. error: 'fa-exclamation-circle',
  806. warning: 'fa-exclamation-triangle',
  807. info: 'fa-info-circle'
  808. };
  809. const toast = document.createElement('div');
  810. toast.id = toastId;
  811. toast.className = `toast align-items-center text-white ${toastColors[type]} border-0`;
  812. toast.setAttribute('role', 'alert');
  813. toast.innerHTML = `
  814. <div class="d-flex">
  815. <div class="toast-body">
  816. <i class="fas ${toastIcons[type]} me-2"></i>
  817. ${message}
  818. </div>
  819. <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
  820. </div>
  821. `;
  822. toastContainer.appendChild(toast);
  823. if (typeof bootstrap !== 'undefined') {
  824. const bsToast = new bootstrap.Toast(toast, { delay: duration });
  825. bsToast.show();
  826. toast.addEventListener('hidden.bs.toast', function() {
  827. if (toastContainer.contains(toast)) {
  828. toastContainer.removeChild(toast);
  829. }
  830. });
  831. return bsToast;
  832. } else {
  833. toast.style.display = 'block';
  834. setTimeout(() => {
  835. if (toastContainer.contains(toast)) {
  836. toastContainer.removeChild(toast);
  837. }
  838. }, duration);
  839. }
  840. }
  841. document.addEventListener('DOMContentLoaded', function() {
  842. const sendViaEmailCheckbox = document.getElementById('sendViaEmail');
  843. const emailAddressRow = document.getElementById('emailAddressRow');
  844. const emailSubjectRow = document.getElementById('emailSubjectRow');
  845. const emailProcessingInfo = document.getElementById('emailProcessingInfo');
  846. const exportIcon = document.getElementById('exportIcon');
  847. const exportButtonText = document.getElementById('exportButtonText');
  848. const emailInput = document.getElementById('exportEmailAddress');
  849. function toggleEmailFields() {
  850. if (sendViaEmailCheckbox && sendViaEmailCheckbox.checked) {
  851. if (emailAddressRow) {
  852. emailAddressRow.style.display = 'block';
  853. emailAddressRow.classList.add('show');
  854. }
  855. if (emailSubjectRow) {
  856. emailSubjectRow.style.display = 'block';
  857. emailSubjectRow.classList.add('show');
  858. }
  859. if (emailProcessingInfo) {
  860. emailProcessingInfo.style.display = 'list-item';
  861. }
  862. if (exportIcon) exportIcon.className = 'fas fa-paper-plane me-1';
  863. if (exportButtonText) exportButtonText.textContent = 'INVIA EMAIL';
  864. } else {
  865. if (emailAddressRow) {
  866. emailAddressRow.style.display = 'none';
  867. emailAddressRow.classList.remove('show');
  868. }
  869. if (emailSubjectRow) {
  870. emailSubjectRow.style.display = 'none';
  871. emailSubjectRow.classList.remove('show');
  872. }
  873. if (emailProcessingInfo) {
  874. emailProcessingInfo.style.display = 'none';
  875. }
  876. if (exportIcon) exportIcon.className = 'fas fa-download me-1';
  877. if (exportButtonText) exportButtonText.textContent = 'ESPORTA';
  878. }
  879. }
  880. function validateEmail(email) {
  881. const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  882. return emailRegex.test(email);
  883. }
  884. if (sendViaEmailCheckbox) {
  885. sendViaEmailCheckbox.addEventListener('change', toggleEmailFields);
  886. }
  887. if (emailInput) {
  888. emailInput.addEventListener('blur', function() {
  889. if (sendViaEmailCheckbox && sendViaEmailCheckbox.checked && this.value) {
  890. if (validateEmail(this.value)) {
  891. this.classList.remove('is-invalid');
  892. this.classList.add('is-valid');
  893. } else {
  894. this.classList.remove('is-valid');
  895. this.classList.add('is-invalid');
  896. }
  897. }
  898. });
  899. emailInput.addEventListener('input', function() {
  900. this.classList.remove('is-invalid', 'is-valid');
  901. });
  902. }
  903. if (typeof $ !== 'undefined') {
  904. $('#exportModal').on('shown.bs.modal', function() {
  905. toggleEmailFields();
  906. });
  907. }
  908. });
  909. document.addEventListener('livewire:load', function () {
  910. console.log('Livewire loaded, setting up export event listeners');
  911. Livewire.on('export-email-queued', function() {
  912. console.log('Export email queued event received');
  913. showToast('info',
  914. '<strong>Export avviato!</strong><br>' +
  915. 'L\'elaborazione è in corso in background. Riceverai l\'email a breve.',
  916. 8000
  917. );
  918. });
  919. Livewire.on('export-email-sent', function() {
  920. console.log('Export email sent event received');
  921. showToast('success',
  922. '<strong>Email inviata!</strong><br>' +
  923. 'L\'export è stato completato e inviato alla tua email.',
  924. 6000
  925. );
  926. });
  927. Livewire.on('export-email-error', function(message) {
  928. console.log('Export email error event received:', message);
  929. showToast('error',
  930. '<strong>Errore nell\'export:</strong><br>' +
  931. (message || 'Si è verificato un errore durante l\'elaborazione.'),
  932. 10000
  933. );
  934. });
  935. Livewire.on('show-export-modal', function() {
  936. console.log('Show export modal event received');
  937. if (typeof $ !== 'undefined') {
  938. $('#exportModal').modal('show');
  939. }
  940. });
  941. Livewire.on('hide-export-modal', function() {
  942. console.log('Hide export modal event received');
  943. if (typeof $ !== 'undefined') {
  944. $('#exportModal').modal('hide');
  945. }
  946. });
  947. });
  948. if (typeof Livewire !== 'undefined') {
  949. document.addEventListener('livewire:initialized', function () {
  950. console.log('Livewire initialized, setting up export event listeners');
  951. Livewire.on('export-email-queued', function() {
  952. showToast('info',
  953. '<strong>Export avviato!</strong><br>' +
  954. 'L\'elaborazione è in corso in background. Riceverai l\'email a breve.',
  955. 8000
  956. );
  957. });
  958. Livewire.on('export-email-sent', function() {
  959. showToast('success',
  960. '<strong>Email inviata!</strong><br>' +
  961. 'L\'export è stato completato e inviato alla tua email.',
  962. 6000
  963. );
  964. });
  965. Livewire.on('export-email-error', function(message) {
  966. showToast('error',
  967. '<strong>Errore nell\'export:</strong><br>' +
  968. (message || 'Si è verificato un errore durante l\'elaborazione.'),
  969. 10000
  970. );
  971. });
  972. Livewire.on('show-export-modal', function() {
  973. if (typeof $ !== 'undefined') {
  974. $('#exportModal').modal('show');
  975. }
  976. });
  977. Livewire.on('hide-export-modal', function() {
  978. if (typeof $ !== 'undefined') {
  979. $('#exportModal').modal('hide');
  980. }
  981. });
  982. });
  983. }
  984. window.addEventListener('load', function() {
  985. if (typeof showToast === 'function') {
  986. console.log('showToast function is available globally');
  987. } else {
  988. console.error('showToast function is not available globally');
  989. }
  990. });
  991. </script>
  992. @endpush