records.blade.php 48 KB

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