records.blade.php 46 KB

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