records.blade.php 48 KB

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