records.blade.php 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972
  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. <div class="col-12 mb-3">
  30. <select wire:model="selectedPeriod" class="form-select" @if($isFiltering) disabled @endif style="height: 43px!important;">
  31. <option value="OGGI">Oggi</option>
  32. <option value="IERI">Ieri</option>
  33. <option value="GIORNO_PERSONALIZZATO">Giorno Personalizzato</option>
  34. <option value="MESE CORRENTE">Mese Corrente</option>
  35. <option value="MESE PRECEDENTE">Mese Precedente</option>
  36. <option value="MESE_PERSONALIZZATO">Mese Personalizzato</option>
  37. <option value="ULTIMO TRIMESTRE">Ultimo Trimestre</option>
  38. <option value="ULTIMO QUADRIMESTRE">Ultimo Quadrimestre</option>
  39. </select>
  40. </div>
  41. @if($selectedPeriod === 'GIORNO_PERSONALIZZATO')
  42. <div class="col-12 mb-2" wire:transition>
  43. <div class="day-picker-container position-relative">
  44. <div class="input-group">
  45. <input type="date"
  46. wire:model="selectedDay"
  47. class="form-control"
  48. style="height: 43px!important;"
  49. @if($isFiltering) disabled @endif>
  50. </div>
  51. @if($showDayPicker)
  52. <div class="day-picker-dropdown position-absolute bg-white border rounded shadow-lg p-3 mt-1"
  53. style="z-index: 1060; width: 100%; max-width: 350px;">
  54. <div class="d-flex justify-content-between align-items-center mb-3">
  55. <h6 class="mb-0 text-primary">
  56. <i class="fa-regular fa-calendar me-2"></i>
  57. Seleziona Giorno
  58. </h6>
  59. <button type="button"
  60. class="btn-close btn-sm"
  61. wire:click="toggleDayPicker"></button>
  62. </div>
  63. <div class="row g-2 mb-3">
  64. <div class="col-6">
  65. <button type="button"
  66. class="btn btn-sm btn-outline-primary w-100"
  67. wire:click="selectToday">
  68. <i class="fas fa-calendar-day me-1"></i>
  69. Oggi
  70. </button>
  71. </div>
  72. <div class="col-6">
  73. <button type="button"
  74. class="btn btn-sm btn-outline-secondary w-100"
  75. wire:click="selectYesterday">
  76. <i class="fas fa-step-backward me-1"></i>
  77. Ieri
  78. </button>
  79. </div>
  80. </div>
  81. <div class="mb-3">
  82. <label class="form-label small">Anno</label>
  83. <select wire:model="selectedYear" class="form-select form-select-sm">
  84. @php
  85. $currentYear = date('Y');
  86. $selectedDayYear = $selectedDay ? substr($selectedDay, 0, 4) : $currentYear;
  87. @endphp
  88. @for($year = $currentYear - 3; $year <= $currentYear + 1; $year++)
  89. <option value="{{ $year }}" {{ $year == $selectedDayYear ? 'selected' : '' }}>
  90. {{ $year }}
  91. </option>
  92. @endfor
  93. </select>
  94. </div>
  95. <div class="mb-3">
  96. <label class="form-label small">Mese</label>
  97. <div class="row g-1">
  98. @php
  99. $months = [
  100. '01' => 'Gen', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr',
  101. '05' => 'Mag', '06' => 'Giu', '07' => 'Lug', '08' => 'Ago',
  102. '09' => 'Set', '10' => 'Ott', '11' => 'Nov', '12' => 'Dic'
  103. ];
  104. $currentMonth = $selectedDay ? substr($selectedDay, 5, 2) : date('m');
  105. $currentYear = $selectedDay ? substr($selectedDay, 0, 4) : date('Y');
  106. @endphp
  107. @foreach($months as $monthNum => $monthName)
  108. <div class="col-3">
  109. <button type="button"
  110. class="btn btn-sm w-100 month-selector {{ $monthNum === $currentMonth ? 'btn-primary' : 'btn-outline-secondary' }}"
  111. data-month="{{ $monthNum }}">
  112. {{ $monthName }}
  113. </button>
  114. </div>
  115. @endforeach
  116. </div>
  117. </div>
  118. <div class="mb-3">
  119. <label class="form-label small">Giorno</label>
  120. <div class="day-grid" id="dayGrid">
  121. </div>
  122. </div>
  123. <div class="row g-2">
  124. <div class="col-6">
  125. <button type="button"
  126. class="btn btn-sm btn-success w-100"
  127. id="confirmDaySelection">
  128. <i class="fas fa-check me-1"></i>
  129. Conferma
  130. </button>
  131. </div>
  132. <div class="col-6">
  133. <button type="button"
  134. class="btn btn-sm btn-outline-secondary w-100"
  135. wire:click="toggleDayPicker">
  136. <i class="fas fa-times me-1"></i>
  137. Annulla
  138. </button>
  139. </div>
  140. </div>
  141. </div>
  142. @endif
  143. </div>
  144. </div>
  145. @if($selectedDay && $selectedPeriod === 'GIORNO_PERSONALIZZATO')
  146. <div class="col-12 mb-2">
  147. <div class="alert alert-info py-2 px-3 mb-0" style="font-size: 0.875rem;">
  148. <i class="fas fa-info-circle me-1"></i>
  149. <strong>Giorno selezionato:</strong><br>
  150. {{ \Carbon\Carbon::createFromFormat('Y-m-d', $selectedDay)->locale('it')->isoFormat('dddd, D MMMM YYYY') }}
  151. </div>
  152. </div>
  153. @endif
  154. @endif
  155. @if($selectedPeriod === 'MESE_PERSONALIZZATO')
  156. <div class="col-12 mb-2" wire:transition>
  157. <div class="month-picker-container position-relative">
  158. <div class="input-group">
  159. <input type="month"
  160. wire:model="selectedMonth"
  161. class="form-control"
  162. style="height: 43px!important;"
  163. @if($isFiltering) disabled @endif>
  164. </div>
  165. @if($showMonthPicker)
  166. <div class="month-picker-dropdown position-absolute bg-white border rounded shadow-lg p-3 mt-1"
  167. style="z-index: 1060; width: 100%; max-width: 300px;">
  168. <div class="d-flex justify-content-between align-items-center mb-3">
  169. <h6 class="mb-0 text-primary">
  170. <i class="fa-regular fa-calendar me-2"></i>
  171. Seleziona Mese
  172. </h6>
  173. <button type="button"
  174. class="btn-close btn-sm"
  175. wire:click="toggleMonthPicker"></button>
  176. </div>
  177. <div class="mb-3">
  178. <label class="form-label small">Anno</label>
  179. <select wire:model="selectedYear" class="form-select form-select-sm">
  180. @php
  181. $currentYear = date('Y');
  182. $selectedYear = $selectedMonth ? substr($selectedMonth, 0, 4) : $currentYear;
  183. @endphp
  184. @for($year = $currentYear - 3; $year <= $currentYear + 1; $year++)
  185. <option value="{{ $year }}" {{ $year == $selectedYear ? 'selected' : '' }}>
  186. {{ $year }}
  187. </option>
  188. @endfor
  189. </select>
  190. </div>
  191. <div class="row g-1 mb-3">
  192. @php
  193. $months = [
  194. '01' => 'Gen', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr',
  195. '05' => 'Mag', '06' => 'Giu', '07' => 'Lug', '08' => 'Ago',
  196. '09' => 'Set', '10' => 'Ott', '11' => 'Nov', '12' => 'Dic'
  197. ];
  198. $currentMonth = $selectedMonth ?: date('Y-m');
  199. @endphp
  200. @foreach($months as $monthNum => $monthName)
  201. <div class="col-3">
  202. <button type="button"
  203. class="btn btn-sm w-100 {{ ($selectedYear . '-' . $monthNum) === $currentMonth ? 'btn-primary' : 'btn-outline-secondary' }}"
  204. wire:click="selectMonth('{{ $selectedYear }}-{{ $monthNum }}')">
  205. {{ $monthName }}
  206. </button>
  207. </div>
  208. @endforeach
  209. </div>
  210. <div class="row g-1">
  211. <div class="col-6">
  212. <button type="button"
  213. class="btn btn-sm btn-outline-primary w-100"
  214. wire:click="selectMonth('{{ date('Y-m') }}')">
  215. <i class="fas fa-calendar-day me-1"></i>
  216. Questo Mese
  217. </button>
  218. </div>
  219. <div class="col-6">
  220. <button type="button"
  221. class="btn btn-sm btn-outline-secondary w-100"
  222. wire:click="selectMonth('{{ date('Y-m', strtotime('-1 month')) }}')">
  223. <i class="fas fa-step-backward me-1"></i>
  224. Mese Scorso
  225. </button>
  226. </div>
  227. </div>
  228. </div>
  229. @endif
  230. </div>
  231. </div>
  232. @if($selectedMonth && $selectedPeriod === 'MESE_PERSONALIZZATO')
  233. <div class="col-12 mb-2">
  234. <div class="alert alert-info py-2 px-3 mb-0" style="font-size: 0.875rem;">
  235. <i class="fas fa-info-circle me-1"></i>
  236. <strong>Periodo selezionato:</strong><br>
  237. {{ \Carbon\Carbon::createFromFormat('Y-m', $selectedMonth)->locale('it')->isoFormat('MMMM YYYY') }}
  238. </div>
  239. </div>
  240. @endif
  241. @endif
  242. </div>
  243. <div class="col-md-2">
  244. <div class="prima--nota_buttons ms-auto" style="float:right; margin-top:25px;">
  245. <button class="btn--ui primary" wire:click="applyFilters" style="margin-right:5px;" @if($isFiltering) disabled @endif>
  246. @if($isFiltering)
  247. <i class="fas fa-spinner fa-spin"></i> CARICAMENTO...
  248. @else
  249. FILTRA
  250. @endif
  251. </button>
  252. <button class="btn--ui lightGrey reset reset" style="margin-left:5px;color:#10172A;" wire:click="resetFilters" @if($isFiltering) disabled @endif>RESET</button>
  253. </div>
  254. </div>
  255. </div>
  256. {{-- Custom loader --}}
  257. <div wire:loading>
  258. <div class="custom_loader">
  259. <i class="fas fa-spinner fa-spin"></i>
  260. </div>
  261. </div>
  262. <style>
  263. .custom_loader {
  264. position: fixed;
  265. top: 0;
  266. left: 0;
  267. right: 0;
  268. bottom: 0;
  269. display: flex;
  270. flex-direction: column;
  271. flex-wrap: nowrap;
  272. align-content: center;
  273. justify-content: center;
  274. align-items: center;
  275. padding: 10px;
  276. background: #ffffff80;
  277. z-index: 1000;
  278. }
  279. .custom_loader i {
  280. font-size: 50px;
  281. color: #0c6197;
  282. }
  283. </style>
  284. {{-- END Custom loader --}}
  285. <div style="float:left; margin-top:10px; margin-bottom:10px;">
  286. <div class="dropdown">
  287. <button class="btn--ui_outline light dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false"
  288. style="color:#10172A;" @if($isFiltering) disabled @endif>
  289. ESPORTA
  290. </button>
  291. <ul class="dropdown-menu" aria-labelledby="exportDropdown">
  292. <li><a class="dropdown-item" href="#" wire:click="openExportModal">Excel</a></li>
  293. <li><a class="dropdown-item" href="#" id="print">Stampa</a></li>
  294. </ul>
  295. </div>
  296. </div>
  297. </section>
  298. <section id="resume-table" class="scrollTable records-table" style="position: relative;">
  299. @if($isFiltering)
  300. <div class="loading-overlay">
  301. <div class="loading-content">
  302. <i class="fas fa-spinner fa-spin fa-3x"></i>
  303. <p>Caricamento dati in corso...</p>
  304. </div>
  305. </div>
  306. @endif
  307. <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
  308. <thead>
  309. <tr>
  310. <th scope="col">Data</th>
  311. <th scope="col" style="border-left:3px solid white;">Causale</th>
  312. <th scope="col" style="border-left:3px solid white;">Dettaglio Causale</th>
  313. <th scope="col" style="border-left:3px solid white;">Stato</th>
  314. <th scope="col" style="border-left:3px solid white;">Nominativo</th>
  315. @foreach($payments as $p)
  316. <th colspan="2" scope="col" style="text-align:center; border-left:3px solid white;">{{$p->name}}</th>
  317. @endforeach
  318. </tr>
  319. <tr>
  320. <th scope="col"></th>
  321. <th scope="col" style="border-left:3px solid white;"></th>
  322. <th scope="col" style="border-left:3px solid white;"></th>
  323. <th scope="col" style="border-left:3px solid white;"></th>
  324. <th scope="col" style="border-left:3px solid white;"></th>
  325. @foreach($payments as $p)
  326. @if($p->type == 'ALL')
  327. <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
  328. <th scope="col" style="text-align:center">Uscite</th>
  329. @elseif($p->type == 'IN')
  330. <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
  331. <th scope="col" style="text-align:center;"></th>
  332. @elseif($p->type == 'OUT')
  333. <th style="border-left:3px solid white;"></th>
  334. <th scope="col" style="text-align:center;">Uscite</th>
  335. @endif
  336. @endforeach
  337. </tr>
  338. </thead>
  339. <tbody id="checkall-target">
  340. @php $count = 0; @endphp
  341. @foreach($records as $causal => $record)
  342. <tr>
  343. @php
  344. $parts = explode("§", $causal);
  345. $d = $parts[0] ?? '';
  346. $c = $parts[1] ?? '';
  347. $n = $parts[2] ?? '';
  348. $det = $parts[3] ?? '';
  349. $del = $parts[4] ?? '';
  350. $detailParts = explode('|', $det);
  351. $isMultiple = count($detailParts) > 1;
  352. $displayDetail = $isMultiple ? 'Varie' : $det;
  353. @endphp
  354. <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($d))}}</td>
  355. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$c}}</td>
  356. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  357. @if($isMultiple)
  358. <span class="varie-link" data-causals="{{implode('|', array_slice($detailParts, 1))}}" style="color: #0C6197; cursor: pointer; text-decoration: underline;">
  359. {{$displayDetail}}
  360. </span>
  361. @else
  362. {{$displayDetail}}
  363. @endif
  364. </td>
  365. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  366. @if($del == 'DELETED')
  367. <span style='color:red'>Annullata</span>
  368. @endif
  369. </td>
  370. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$n}}</td>
  371. @foreach($payments as $p)
  372. @if(isset($record[$p->name]))
  373. <td style="text-align:right; border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  374. @if(isset($record[$p->name]["IN"]))
  375. <span class="tablesaw-cell-content " style="color:green">{{formatPrice($record[$p->name]["IN"])}}</span>
  376. @endif
  377. </td>
  378. <td style="text-align:right;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
  379. @if(isset($record[$p->name]["OUT"]))
  380. <span class="tablesaw-cell-content " style="color:red">{{formatPrice($record[$p->name]["OUT"])}}</span>
  381. @endif
  382. </td>
  383. @else
  384. <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
  385. <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
  386. @endif
  387. @endforeach
  388. </tr>
  389. @php $count++; @endphp
  390. @endforeach
  391. </tbody>
  392. <tfoot>
  393. <tr>
  394. <td></td>
  395. <td></td>
  396. <td></td>
  397. <td></td>
  398. <td><b>Totale</b></td>
  399. @foreach($payments as $p)
  400. @if(isset($totals[$p->name]))
  401. @if($p->type == 'ALL')
  402. <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>
  403. <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>
  404. @elseif($p->type == 'IN')
  405. <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>
  406. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>&nbsp;</b></span></td>
  407. @elseif($p->type == 'OUT')
  408. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>&nbsp;</b></span></td>
  409. <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>
  410. @endif
  411. @else
  412. @if($p->type == 'ALL')
  413. <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>
  414. <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>
  415. @elseif($p->type == 'IN')
  416. <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>
  417. <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>&nbsp;</b></span></td>
  418. @elseif($p->type == 'OUT')
  419. <td style="text-align:right"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>&nbsp;</b></span></td>
  420. <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>
  421. @endif
  422. @endif
  423. @endforeach
  424. </tr>
  425. <tr style="display:none">
  426. <td></td>
  427. <td><b>Differenza</b></td>
  428. @foreach($payments as $p)
  429. @if(isset($totals[$p->name]))
  430. @php
  431. $diff = $totals[$p->name]["IN"] - $totals[$p->name]["OUT"];
  432. @endphp
  433. @if($diff < 0)
  434. <td></td>
  435. @endif
  436. <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>
  437. @if($diff > 0)
  438. <td></td>
  439. @endif
  440. @else
  441. <td colspan="2" style="text-align:right"><b>{{formatPrice(0)}}</b></td>
  442. @endif
  443. @endforeach
  444. </tr>
  445. </tfoot>
  446. </table>
  447. <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-bottom"><i class="fas fa-arrow-down"></i></button>
  448. <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-top"><i class="fas fa-arrow-up"></i></button>
  449. </section>
  450. <div class="modal fade" id="causalsModal" tabindex="-1" aria-labelledby="causalsModalLabel" aria-hidden="true">
  451. <div class="modal-dialog modal-lg">
  452. <div class="modal-content">
  453. <div class="modal-header" style="background-color: #0C6197!important;">
  454. <h5 class="modal-title" id="causalsModalLabel">
  455. <i class="me-2"></i>
  456. Dettaglio Causali
  457. </h5>
  458. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="CHIUDI"></button>
  459. </div>
  460. <div class="modal-body">
  461. <div class="row">
  462. <div class="col-12">
  463. <div class="d-flex justify-content-between align-items-center mb-3">
  464. <h6 class="mb-0">
  465. <i class="me-2 text-primary"></i>
  466. Causali incluse:
  467. </h6>
  468. </div>
  469. <div class="border rounded" style="max-height: 400px; overflow-y: auto;">
  470. <ul id="causalsList" class="list-group list-group-flush mb-0">
  471. <!-- Causals will be populated here by JavaScript -->
  472. </ul>
  473. </div>
  474. </div>
  475. </div>
  476. </div>
  477. <div class="modal-footer" style="background-color: #FFF!important;">
  478. <button type="button" class="btn--ui lightGrey me-2" data-bs-dismiss="modal">
  479. <i class="fas fa-times me-1"></i>
  480. CHIUDI
  481. </button>
  482. </div>
  483. </div>
  484. </div>
  485. </div>
  486. <div class="modal fade" id="exportModal" tabindex="-1" aria-labelledby="exportModalLabel" aria-hidden="true">
  487. <div class="modal-dialog">
  488. <div class="modal-content">
  489. <div class="modal-header" style="background-color: #0C6197!important;">
  490. <h5 class="modal-title" id="exportModalLabel">Seleziona Periodo per Export</h5>
  491. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="CHIUDI"></button>
  492. </div>
  493. <div class="modal-body">
  494. <div class="row g-3">
  495. <div class="col-md-6">
  496. <label for="exportFromDate" class="form-label">Data Inizio</label>
  497. <input type="date" class="form-control" id="exportFromDate" wire:model.defer="exportFromDate">
  498. </div>
  499. <div class="col-md-6">
  500. <label for="exportToDate" class="form-label">Data Fine</label>
  501. <input type="date" class="form-control" id="exportToDate" wire:model.defer="exportToDate">
  502. </div>
  503. </div>
  504. <div class="row mt-4">
  505. <div class="col-12">
  506. <div class="form-check export-method-check">
  507. <input class="form-check-input" type="checkbox" id="sendViaEmail" wire:model.defer="sendViaEmail">
  508. <label class="form-check-label" for="sendViaEmail">
  509. <i class="fas fa-envelope me-2"></i>Invia via Email
  510. <small class="d-block text-muted mt-1">L'export verrà elaborato in background e inviato alla tua email</small>
  511. </label>
  512. </div>
  513. </div>
  514. </div>
  515. <div class="row mt-3" style="display: none;" id="emailAddressRow">
  516. <div class="col-12">
  517. <label for="exportEmailAddress" class="form-label">
  518. <i class="fas fa-envelope me-1"></i>Indirizzo Email
  519. </label>
  520. <input type="email" class="form-control" id="exportEmailAddress"
  521. wire:model.defer="exportEmailAddress"
  522. placeholder="inserisci@email.com">
  523. <div class="invalid-feedback" id="emailValidationFeedback">
  524. Inserisci un indirizzo email valido
  525. </div>
  526. <small class="form-text text-muted">
  527. Il file Excel verrà inviato a questo indirizzo
  528. </small>
  529. </div>
  530. </div>
  531. <div class="row mt-3" style="display: none;" id="emailSubjectRow">
  532. <div class="col-12">
  533. <label for="exportEmailSubject" class="form-label">
  534. <i class="fas fa-tag me-1"></i>Oggetto Email
  535. </label>
  536. <input type="text" class="form-control" id="exportEmailSubject"
  537. wire:model.defer="exportEmailSubject"
  538. placeholder="Prima Nota - Export">
  539. <small class="form-text text-muted">
  540. Personalizza l'oggetto dell'email
  541. </small>
  542. </div>
  543. </div>
  544. <div class="row mt-3">
  545. <div class="col-12">
  546. <div class="alert alert-info d-flex align-items-start">
  547. <i class="fas fa-info-circle me-2 mt-1"></i>
  548. <div>
  549. <strong>Informazioni Export:</strong>
  550. <ul class="mb-0 mt-1">
  551. <li>L'export includerà tutti i record nel periodo selezionato</li>
  552. <li>Verranno applicati i filtri attualmente attivi</li>
  553. <li id="emailProcessingInfo" style="display: none;">L'elaborazione avverrà in background, potrai continuare a usare l'applicazione</li>
  554. </ul>
  555. </div>
  556. </div>
  557. </div>
  558. </div>
  559. </div>
  560. <div class="modal-footer" style="background-color: #FFF!important;">
  561. <button type="button" class="btn--ui lightGrey me-2" data-bs-dismiss="modal">ANNULLA</button>
  562. <button type="button" class="btn--ui primary" onclick="handleExportClick()" id="exportButton">
  563. <span id="loadingState" style="display: none;">
  564. <div class="spinner-border spinner-border-sm me-2" role="status">
  565. <span class="visually-hidden">Loading...</span>
  566. </div>
  567. ELABORAZIONE...
  568. </span>
  569. <span id="normalState">
  570. <i class="fas fa-download me-1"></i>
  571. ESPORTA
  572. </span>
  573. </button>
  574. </div>
  575. </div>
  576. </div>
  577. </div>
  578. <div class="toast-container position-fixed top-0 end-0 p-3" style="z-index: 11000;">
  579. <!-- Toasts will be dynamically added here -->
  580. </div>
  581. </div>
  582. @push('scripts')
  583. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  584. @endpush
  585. @push('scripts')
  586. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  587. <style>
  588. .loading-overlay {
  589. position: absolute;
  590. top: 0;
  591. left: 0;
  592. right: 0;
  593. bottom: 0;
  594. background-color: rgba(255, 255, 255, 0.9);
  595. display: flex;
  596. justify-content: center;
  597. align-items: center;
  598. z-index: 1000;
  599. border-radius: 4px;
  600. }
  601. .loading-content {
  602. text-align: center;
  603. color: #0C6197;
  604. }
  605. .loading-content i {
  606. margin-bottom: 15px;
  607. color: #0C6197;
  608. }
  609. .loading-content p {
  610. margin: 0;
  611. font-size: 16px;
  612. font-weight: 500;
  613. color: #10172A;
  614. }
  615. .modal {
  616. z-index: 9999 !important;
  617. }
  618. .modal-backdrop {
  619. z-index: 9998 !important;
  620. background-color: rgba(0, 0, 0, 0.6) !important;
  621. }
  622. .modal-content {
  623. border-radius: 8px;
  624. border: none;
  625. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  626. z-index: 10000 !important;
  627. }
  628. .modal-header {
  629. color: white;
  630. border-bottom: none;
  631. border-radius: 8px 8px 0 0;
  632. }
  633. .modal-header .btn-close {
  634. filter: invert(1);
  635. }
  636. .modal-title {
  637. font-weight: 600;
  638. }
  639. .varie-link:hover {
  640. color: #084c6b !important;
  641. text-decoration: underline !important;
  642. }
  643. #btn-back-to-top {
  644. background-color: #0C6197;
  645. color: white;
  646. position: fixed;
  647. display: none;
  648. }
  649. #btn-back-to-bottom {
  650. background-color: #0C6197;
  651. color: white;
  652. position: fixed;
  653. z-index: 9999;
  654. display: none;
  655. }
  656. button[disabled] {
  657. opacity: 0.7;
  658. cursor: not-allowed;
  659. }
  660. .btn--ui .fa-spinner {
  661. margin-right: 5px;
  662. }
  663. .scrollTable {
  664. margin-left: 0px;
  665. margin-right: 0px;
  666. padding: 15px;
  667. overflow-x: auto;
  668. overflow-y: auto;
  669. white-space: nowrap;
  670. border: 1px solid #ddd;
  671. }
  672. ::-webkit-scrollbar-thumb {
  673. background: #e4e4e4;
  674. border-radius: 10px;
  675. }
  676. table thead {
  677. position: sticky;
  678. z-index: 100;
  679. top: 0;
  680. }
  681. .select2-container--default .select2-selection--single {
  682. background-color: #E9F0F5;
  683. border: 0.0625rem solid #DFE5EB;
  684. font-size: 0.75rem;
  685. height: 38px !important;
  686. }
  687. .select2-selection__rendered {
  688. padding-top: 3px;
  689. }
  690. .select2 {
  691. width: 100% !important;
  692. }
  693. .select2-selection--multiple {
  694. overflow: hidden !important;
  695. height: auto !important;
  696. }
  697. .select2-container {
  698. box-sizing: border-box;
  699. display: inline-block;
  700. margin: 0;
  701. position: relative;
  702. vertical-align: middle;
  703. z-index: 999 !important;
  704. }
  705. .select2-dropdown {
  706. z-index: 999 !important;
  707. }
  708. .select2-container .select2-selection--single {
  709. box-sizing: border-box;
  710. cursor: pointer;
  711. display: block;
  712. height: 38px;
  713. user-select: none;
  714. -webkit-user-select: none;
  715. }
  716. .select2-container .select2-selection--single .select2-selection__rendered {
  717. display: block;
  718. padding-left: 8px;
  719. padding-right: 20px;
  720. overflow: hidden;
  721. text-overflow: ellipsis;
  722. white-space: nowrap;
  723. }
  724. button#exportDropdown.btn--ui_outline.light {
  725. font-weight: normal !important;
  726. }
  727. .btn--ui_outline.light.dropdown-toggle:active,
  728. .btn--ui_outline.light.dropdown-toggle:focus,
  729. .btn--ui_outline.light.dropdown-toggle.show {
  730. background-color: transparent !important;
  731. color: #10172A !important;
  732. box-shadow: none !important;
  733. }
  734. .btn--ui_outline.light.dropdown-toggle:hover {
  735. background-color: transparent !important;
  736. color: #10172A !important;
  737. }
  738. .form-select {
  739. height: 38px !important;
  740. }
  741. .form-control {
  742. height: 43px !important;
  743. }
  744. #exportModal .modal-body {
  745. padding: 1.5rem;
  746. }
  747. #exportModal .form-label {
  748. font-weight: 600;
  749. color: #10172A;
  750. margin-bottom: 0.5rem;
  751. }
  752. #exportModal .text-muted {
  753. font-size: 0.875rem;
  754. }
  755. .btn--ui[disabled] .fa-spinner {
  756. margin-right: 0.5rem;
  757. }
  758. body.modal-open {
  759. overflow: hidden;
  760. }
  761. .modal-dialog {
  762. z-index: 10001 !important;
  763. margin: 1.75rem auto;
  764. }
  765. .list-group-item {
  766. border-left: none;
  767. border-right: none;
  768. border-top: 1px solid #dee2e6;
  769. padding: 12px 15px;
  770. }
  771. .list-group-item:first-child {
  772. border-top: none;
  773. }
  774. .list-group-item:last-child {
  775. border-bottom: none;
  776. }
  777. @media (max-width: 768px) {
  778. .col-md-2, .col-md-3, .col-md-4 {
  779. margin-bottom: 10px;
  780. }
  781. .prima--nota_buttons {
  782. float: none !important;
  783. margin-top: 10px !important;
  784. text-align: center;
  785. }
  786. }
  787. .export-method-check {
  788. padding: 16px 16px 16px 50px;
  789. background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  790. border-radius: 8px;
  791. border: 2px solid #e9ecef;
  792. transition: all 0.3s ease;
  793. cursor: pointer;
  794. position: relative;
  795. }
  796. .export-method-check:hover {
  797. border-color: #0C6197;
  798. background: linear-gradient(135deg, #e8f4f8 0%, #d1ecf1 100%);
  799. }
  800. .export-method-check .form-check-input {
  801. position: absolute;
  802. left: 16px;
  803. top: 50%;
  804. transform: translateY(-50%);
  805. margin: 0;
  806. width: 20px;
  807. height: 20px;
  808. background-color: #fff;
  809. border: 2px solid #dee2e6;
  810. border-radius: 4px;
  811. cursor: pointer;
  812. }
  813. .export-method-check .form-check-input:checked {
  814. background-color: #0C6197;
  815. border-color: #0C6197;
  816. }
  817. .export-method-check .form-check-input:checked ~ .form-check-label {
  818. color: #0C6197;
  819. font-weight: 600;
  820. }
  821. .export-method-check .form-check-label {
  822. font-weight: 500;
  823. color: #495057;
  824. cursor: pointer;
  825. margin-left: 0;
  826. display: block;
  827. }
  828. .form-check-input:focus {
  829. border-color: #0C6197;
  830. outline: 0;
  831. box-shadow: 0 0 0 0.2rem rgba(12, 97, 151, 0.25);
  832. }
  833. #emailAddressRow.show, #emailSubjectRow.show {
  834. display: block !important;
  835. animation: slideDown 0.3s ease-out;
  836. }
  837. @keyframes slideDown {
  838. from {
  839. opacity: 0;
  840. transform: translateY(-10px);
  841. }
  842. to {
  843. opacity: 1;
  844. transform: translateY(0);
  845. }
  846. }
  847. .invalid-feedback {
  848. display: none;
  849. }
  850. .is-invalid ~ .invalid-feedback {
  851. display: block;
  852. }
  853. .alert-info {
  854. background-color: rgba(12, 97, 151, 0.1);
  855. border-color: rgba(12, 97, 151, 0.2);
  856. color: #0C6197;
  857. }
  858. .spinner-border-sm {
  859. width: 1rem;
  860. height: 1rem;
  861. }
  862. .toast {
  863. min-width: 300px;
  864. }
  865. .toast-body {
  866. font-weight: 500;
  867. }
  868. .btn--ui:disabled {
  869. opacity: 0.7;
  870. cursor: not-allowed;
  871. }
  872. .list-group-item {
  873. border-left: none;
  874. border-right: none;
  875. border-top: 1px solid #dee2e6;
  876. padding: 12px 15px;
  877. }
  878. .list-group-item:first-child {
  879. border-top: none;
  880. }
  881. .list-group-item:last-child {
  882. border-bottom: none;
  883. }
  884. .list-group-item.d-flex {
  885. display: flex !important;
  886. justify-content: space-between !important;
  887. align-items: center !important;
  888. }
  889. .list-group-item .badge {
  890. font-size: 0.875rem;
  891. font-weight: 600;
  892. }
  893. .list-group-item:hover {
  894. background-color: rgba(12, 97, 151, 0.05);
  895. transition: background-color 0.2s ease;
  896. }
  897. #causalsModal .modal-body {
  898. padding: 1rem 0;
  899. }
  900. .loading-overlay {
  901. position: absolute;
  902. top: 0;
  903. left: 0;
  904. right: 0;
  905. bottom: 0;
  906. background-color: rgba(255, 255, 255, 0.9);
  907. display: flex;
  908. justify-content: center;
  909. align-items: center;
  910. z-index: 1000;
  911. border-radius: 4px;
  912. }
  913. /* New styles for Custom Day Picker */
  914. .day-picker-container {
  915. position: relative;
  916. }
  917. .day-picker-dropdown {
  918. max-height: 600px;
  919. overflow-y: auto;
  920. border: 1px solid #dee2e6;
  921. background: white;
  922. border-radius: 8px;
  923. box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  924. z-index: 1060;
  925. animation: slideDown 0.2s ease-out;
  926. transform-origin: top;
  927. }
  928. .day-grid {
  929. display: grid;
  930. grid-template-columns: repeat(7, 1fr);
  931. gap: 2px;
  932. margin-bottom: 1rem;
  933. }
  934. .day-grid .day-header {
  935. text-align: center;
  936. font-weight: bold;
  937. font-size: 0.75rem;
  938. padding: 0.25rem;
  939. background-color: #f8f9fa;
  940. border-radius: 3px;
  941. color: #6c757d;
  942. }
  943. .day-grid .day-button {
  944. padding: 0.375rem 0.25rem;
  945. font-size: 0.75rem;
  946. border: 1px solid #dee2e6;
  947. background: white;
  948. border-radius: 4px;
  949. cursor: pointer;
  950. transition: all 0.15s ease-in-out;
  951. text-align: center;
  952. min-height: 32px;
  953. display: flex;
  954. align-items: center;
  955. justify-content: center;
  956. }
  957. .day-grid .day-button:hover:not(.disabled) {
  958. background-color: #e9ecef;
  959. border-color: #0C6197;
  960. }
  961. .day-grid .day-button.selected {
  962. background-color: #0C6197;
  963. border-color: #0C6197;
  964. color: white;
  965. }
  966. .day-grid .day-button.today {
  967. border-color: #28a745;
  968. font-weight: bold;
  969. }
  970. .day-grid .day-button.disabled {
  971. color: #6c757d;
  972. background-color: #f8f9fa;
  973. cursor: not-allowed;
  974. opacity: 0.5;
  975. }
  976. .day-grid .day-button.other-month {
  977. color: #adb5bd;
  978. background-color: #f8f9fa;
  979. }
  980. .month-selector.btn-primary {
  981. background-color: #0C6197;
  982. border-color: #0C6197;
  983. }
  984. .month-selector.btn-outline-secondary:hover {
  985. background-color: #6c757d;
  986. border-color: #6c757d;
  987. color: white;
  988. }
  989. input[type="date"] {
  990. background-color: #E9F0F5;
  991. border: 0.0625rem solid #DFE5EB;
  992. font-size: 0.75rem;
  993. }
  994. input[type="date"]:focus {
  995. border-color: #0C6197;
  996. box-shadow: 0 0 0 0.2rem rgba(12, 97, 151, 0.25);
  997. }
  998. input[type="date"]::-webkit-calendar-picker-indicator {
  999. cursor: pointer;
  1000. opacity: 0.7;
  1001. transition: opacity 0.15s ease-in-out;
  1002. }
  1003. input[type="date"]::-webkit-calendar-picker-indicator:hover {
  1004. opacity: 1;
  1005. }
  1006. @media (max-width: 768px) {
  1007. .day-picker-dropdown {
  1008. width: 100% !important;
  1009. max-width: none !important;
  1010. }
  1011. .day-grid .day-button {
  1012. font-size: 0.7rem;
  1013. padding: 0.25rem;
  1014. min-height: 28px;
  1015. }
  1016. }
  1017. .month-picker-container {
  1018. position: relative;
  1019. }
  1020. .month-picker-dropdown {
  1021. max-height: 500px;
  1022. overflow-y: auto;
  1023. border: 1px solid #dee2e6;
  1024. background: white;
  1025. border-radius: 8px;
  1026. box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  1027. z-index: 1060;
  1028. }
  1029. .month-picker-dropdown .btn {
  1030. font-size: 0.75rem;
  1031. padding: 0.375rem 0.5rem;
  1032. border-radius: 4px;
  1033. transition: all 0.15s ease-in-out;
  1034. }
  1035. .month-picker-dropdown .btn-sm {
  1036. font-size: 0.875rem;
  1037. padding: 0.25rem 0.5rem;
  1038. }
  1039. .month-picker-dropdown .btn-close {
  1040. padding: 0.25rem;
  1041. font-size: 0.75rem;
  1042. }
  1043. .month-picker-dropdown .btn-primary {
  1044. background-color: #0C6197;
  1045. border-color: #0C6197;
  1046. }
  1047. .month-picker-dropdown .btn-outline-primary {
  1048. color: #0C6197;
  1049. border-color: #0C6197;
  1050. }
  1051. .month-picker-dropdown .btn-outline-primary:hover {
  1052. background-color: #0C6197;
  1053. border-color: #0C6197;
  1054. }
  1055. .month-picker-dropdown .btn-outline-secondary:hover {
  1056. background-color: #6c757d;
  1057. border-color: #6c757d;
  1058. }
  1059. input[type="month"] {
  1060. background-color: #E9F0F5;
  1061. border: 0.0625rem solid #DFE5EB;
  1062. font-size: 0.75rem;
  1063. }
  1064. input[type="month"]:focus {
  1065. border-color: #0C6197;
  1066. box-shadow: 0 0 0 0.2rem rgba(12, 97, 151, 0.25);
  1067. }
  1068. input[type="month"]::-webkit-calendar-picker-indicator {
  1069. cursor: pointer;
  1070. opacity: 0.7;
  1071. transition: opacity 0.15s ease-in-out;
  1072. }
  1073. input[type="month"]::-webkit-calendar-picker-indicator:hover {
  1074. opacity: 1;
  1075. }
  1076. .alert-info {
  1077. background-color: rgba(12, 97, 151, 0.1);
  1078. border-color: rgba(12, 97, 151, 0.2);
  1079. color: #0C6197;
  1080. border-radius: 6px;
  1081. }
  1082. .month-picker-dropdown {
  1083. animation: slideDown 0.2s ease-out;
  1084. transform-origin: top;
  1085. }
  1086. @keyframes slideDown {
  1087. from {
  1088. opacity: 0;
  1089. transform: translateY(-10px) scaleY(0.8);
  1090. }
  1091. to {
  1092. opacity: 1;
  1093. transform: translateY(0) scaleY(1);
  1094. }
  1095. }
  1096. @media (max-width: 768px) {
  1097. .month-picker-dropdown {
  1098. width: 100% !important;
  1099. max-width: none !important;
  1100. }
  1101. .month-picker-dropdown .row.g-1 .col-3 {
  1102. flex: 0 0 25%;
  1103. max-width: 25%;
  1104. }
  1105. }
  1106. [wire\:transition] {
  1107. transition: all 0.3s ease-in-out;
  1108. }
  1109. .select2-container {
  1110. z-index: 999 !important;
  1111. }
  1112. .select2-dropdown {
  1113. z-index: 999 !important;
  1114. }
  1115. .month-picker-dropdown {
  1116. z-index: 1060 !important;
  1117. }
  1118. .month-picker-dropdown .btn-group-sm .btn {
  1119. padding: 0.25rem 0.5rem;
  1120. font-size: 0.75rem;
  1121. }
  1122. .month-picker-container .form-label {
  1123. font-weight: 600;
  1124. color: #10172A;
  1125. margin-bottom: 0.5rem;
  1126. }
  1127. .month-picker-container .input-group .btn {
  1128. border-left: 0;
  1129. background-color: #f8f9fa;
  1130. border-color: #DFE5EB;
  1131. color: #6c757d;
  1132. }
  1133. .month-picker-container .input-group .btn:hover {
  1134. background-color: #e9ecef;
  1135. color: #0C6197;
  1136. }
  1137. </style>
  1138. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  1139. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  1140. <script src="/assets/js/aCollapTable.js"></script>
  1141. @endpush
  1142. @push('scripts')
  1143. <script>
  1144. let selectedDayValue = '';
  1145. let currentDisplayMonth = '';
  1146. let currentDisplayYear = '';
  1147. function initializeDayPicker() {
  1148. const today = new Date();
  1149. const selectedDay = @this.get('selectedDay');
  1150. if (selectedDay) {
  1151. selectedDayValue = selectedDay;
  1152. const selectedDate = new Date(selectedDay);
  1153. currentDisplayMonth = String(selectedDate.getMonth() + 1).padStart(2, '0');
  1154. currentDisplayYear = String(selectedDate.getFullYear());
  1155. } else {
  1156. currentDisplayMonth = String(today.getMonth() + 1).padStart(2, '0');
  1157. currentDisplayYear = String(today.getFullYear());
  1158. }
  1159. updateDayGrid();
  1160. }
  1161. function updateDayGrid() {
  1162. const dayGrid = document.getElementById('dayGrid');
  1163. if (!dayGrid) return;
  1164. const year = parseInt(currentDisplayYear);
  1165. const month = parseInt(currentDisplayMonth);
  1166. const today = new Date();
  1167. const selectedDate = selectedDayValue ? new Date(selectedDayValue) : null;
  1168. dayGrid.innerHTML = '';
  1169. const dayHeaders = ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'];
  1170. dayHeaders.forEach(header => {
  1171. const headerDiv = document.createElement('div');
  1172. headerDiv.className = 'day-header';
  1173. headerDiv.textContent = header;
  1174. dayGrid.appendChild(headerDiv);
  1175. });
  1176. const firstDay = new Date(year, month - 1, 1);
  1177. const lastDay = new Date(year, month, 0);
  1178. const startDate = new Date(firstDay);
  1179. startDate.setDate(startDate.getDate() - firstDay.getDay());
  1180. for (let i = 0; i < 42; i++) {
  1181. const currentDate = new Date(startDate);
  1182. currentDate.setDate(startDate.getDate() + i);
  1183. const dayButton = document.createElement('button');
  1184. dayButton.type = 'button';
  1185. dayButton.className = 'day-button';
  1186. dayButton.textContent = currentDate.getDate();
  1187. const isCurrentMonth = currentDate.getMonth() === month - 1;
  1188. const isToday = currentDate.toDateString() === today.toDateString();
  1189. const isSelected = selectedDate && currentDate.toDateString() === selectedDate.toDateString();
  1190. if (!isCurrentMonth) {
  1191. dayButton.classList.add('other-month');
  1192. }
  1193. if (isToday) {
  1194. dayButton.classList.add('today');
  1195. }
  1196. if (isSelected) {
  1197. dayButton.classList.add('selected');
  1198. }
  1199. const dateString = currentDate.getFullYear() + '-' +
  1200. String(currentDate.getMonth() + 1).padStart(2, '0') + '-' +
  1201. String(currentDate.getDate()).padStart(2, '0');
  1202. dayButton.addEventListener('click', function() {
  1203. document.querySelectorAll('.day-button.selected').forEach(btn => {
  1204. btn.classList.remove('selected');
  1205. });
  1206. this.classList.add('selected');
  1207. selectedDayValue = dateString;
  1208. });
  1209. dayGrid.appendChild(dayButton);
  1210. }
  1211. }
  1212. document.addEventListener('click', function(event) {
  1213. if (event.target.classList.contains('month-selector')) {
  1214. const month = event.target.getAttribute('data-month');
  1215. currentDisplayMonth = month;
  1216. document.querySelectorAll('.month-selector').forEach(btn => {
  1217. btn.classList.remove('btn-primary');
  1218. btn.classList.add('btn-outline-secondary');
  1219. });
  1220. event.target.classList.remove('btn-outline-secondary');
  1221. event.target.classList.add('btn-primary');
  1222. updateDayGrid();
  1223. }
  1224. });
  1225. document.addEventListener('click', function(event) {
  1226. if (event.target.id === 'confirmDaySelection') {
  1227. if (selectedDayValue) {
  1228. @this.call('selectDay', selectedDayValue);
  1229. }
  1230. }
  1231. });
  1232. document.addEventListener('click', function(event) {
  1233. const dayPicker = document.querySelector('.day-picker-dropdown');
  1234. const dayPickerContainer = document.querySelector('.day-picker-container');
  1235. if (dayPicker && dayPickerContainer && !dayPickerContainer.contains(event.target)) {
  1236. @this.set('showDayPicker', false);
  1237. }
  1238. });
  1239. document.addEventListener('livewire:updated', function() {
  1240. const dayPicker = document.querySelector('.day-picker-dropdown');
  1241. if (dayPicker) {
  1242. initializeDayPicker();
  1243. }
  1244. });
  1245. function closeSelect2Dropdowns() {
  1246. $('.filterCausals').each(function() {
  1247. if ($(this).hasClass('select2-hidden-accessible')) {
  1248. $(this).select2('close');
  1249. }
  1250. });
  1251. $('.filterMember').each(function() {
  1252. if ($(this).hasClass('select2-hidden-accessible')) {
  1253. $(this).select2('close');
  1254. }
  1255. });
  1256. }
  1257. function load() {
  1258. $(document).ready(function(){
  1259. $(document).on("keypress", $('.filterCausals'), function (e) {
  1260. setTimeout(() => {
  1261. $(".select2-results__option").each(function(){
  1262. var txt = $(this).html();
  1263. var count = (txt.match(/-/g) || []).length;
  1264. $(this).addClass('paddingLeftSelect' + count);
  1265. });
  1266. }, 100);
  1267. });
  1268. if (!$('.filterCausals').hasClass('select2-hidden-accessible')) {
  1269. $('.filterCausals').select2({
  1270. "language": {"noResults": function(){return "Nessun risultato";}},
  1271. "dropdownParent": $('body'),
  1272. "width": "100%"
  1273. });
  1274. }
  1275. $('.filterCausals').off('change.customHandler').on('change.customHandler', function (e) {
  1276. var data = $('.filterCausals').select2("val");
  1277. @this.set('filterCausals', data);
  1278. });
  1279. $('.filterCausals').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
  1280. if ($('#causalsModal').hasClass('show')) {
  1281. $('#causalsModal').modal('hide');
  1282. }
  1283. setTimeout(() => {
  1284. $(".select2-results__option").each(function(){
  1285. var txt = $(this).html();
  1286. var count = (txt.match(/-/g) || []).length;
  1287. $(this).addClass('paddingLeftSelect' + count);
  1288. });
  1289. }, 100);
  1290. });
  1291. if (!$('.filterMember').hasClass('select2-hidden-accessible')) {
  1292. $('.filterMember').select2({
  1293. "language": {"noResults": function(){return "Nessun risultato";}},
  1294. "dropdownParent": $('body'),
  1295. "width": "100%"
  1296. });
  1297. }
  1298. $('.filterMember').off('change.customHandler').on('change.customHandler', function (e) {
  1299. var data = $('.filterMember').select2("val");
  1300. @this.set('filterMember', data);
  1301. });
  1302. $('.filterMember').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
  1303. if ($('#causalsModal').hasClass('show')) {
  1304. $('#causalsModal').modal('hide');
  1305. }
  1306. });
  1307. });
  1308. }
  1309. function printData() {
  1310. var divToPrint = document.getElementById("tablesaw-350");
  1311. newWin = window.open("");
  1312. var htmlToPrint = '' +
  1313. '<style type="text/css">' +
  1314. 'table th, table td {' +
  1315. 'border:1px solid #000;' +
  1316. 'padding:0.5em;' +
  1317. '}' +
  1318. '</style>';
  1319. htmlToPrint += divToPrint.outerHTML;
  1320. newWin.document.write(htmlToPrint);
  1321. newWin.document.close();
  1322. newWin.print();
  1323. newWin.close();
  1324. }
  1325. function scrollFunction() {
  1326. const element = document.getElementById('resume-table');
  1327. const mybuttonBottom = document.getElementById("btn-back-to-bottom");
  1328. const mybutton = document.getElementById("btn-back-to-top");
  1329. if (element.scrollTop > 20) {
  1330. mybutton.style.display = "block";
  1331. mybuttonBottom.style.display = "block";
  1332. } else {
  1333. mybutton.style.display = "none";
  1334. mybuttonBottom.style.display = "none";
  1335. }
  1336. }
  1337. function backToTop() {
  1338. $('#resume-table').scrollTop(0);
  1339. }
  1340. function backToBottom() {
  1341. $('#resume-table').scrollTop($('#resume-table')[0].scrollHeight);
  1342. }
  1343. $(document).ready(function() {
  1344. load();
  1345. document.querySelector("#print").addEventListener("click", function(){
  1346. printData();
  1347. });
  1348. const element = document.getElementById('resume-table');
  1349. element.onscroll = scrollFunction;
  1350. const mybuttonBottom = document.getElementById("btn-back-to-bottom");
  1351. const mybutton = document.getElementById("btn-back-to-top");
  1352. mybutton.addEventListener("click", backToTop);
  1353. mybuttonBottom.addEventListener("click", backToBottom);
  1354. $(document).on('click', '.varie-link', function(e) {
  1355. e.preventDefault();
  1356. e.stopPropagation();
  1357. closeSelect2Dropdowns();
  1358. const causalsData = $(this).data('causals');
  1359. if (causalsData) {
  1360. const causals = causalsData.split('|');
  1361. $('#causalsList').empty();
  1362. causals.forEach(function(causal) {
  1363. if (causal.trim()) {
  1364. if (causal.includes(':::')) {
  1365. const parts = causal.split(':::');
  1366. const causalName = parts[0].trim();
  1367. const amount = parts[1].trim();
  1368. $('#causalsList').append(
  1369. '<li class="list-group-item d-flex justify-content-between align-items-center">' +
  1370. '<div>' +
  1371. '<i class="fas fa-tags me-2" style="color: #0C6197;"></i>' +
  1372. causalName +
  1373. '</div>' +
  1374. '<span class="badge bg-primary rounded-pill" style="background-color: #0C6197 !important;">' +
  1375. amount +
  1376. '</span>' +
  1377. '</li>'
  1378. );
  1379. } else {
  1380. $('#causalsList').append(
  1381. '<li class="list-group-item">' +
  1382. '<i class="fas fa-tags me-2" style="color: #0C6197;"></i>' +
  1383. causal.trim() +
  1384. '</li>'
  1385. );
  1386. }
  1387. }
  1388. });
  1389. $('#causalsModal').modal('show');
  1390. $('#causalsModal').on('shown.bs.modal', function () {
  1391. $(this).find('.btn-close').focus();
  1392. });
  1393. }
  1394. });
  1395. });
  1396. Livewire.on('load-table', () => {
  1397. load();
  1398. });
  1399. Livewire.on('load-select', () => {
  1400. load();
  1401. });
  1402. Livewire.on('filters-reset', () => {
  1403. $('.filterMember').val('').trigger('change');
  1404. $('.filterCausals').val('').trigger('change');
  1405. load();
  1406. });
  1407. Livewire.on('show-export-modal', () => {
  1408. $('#exportModal').modal('show');
  1409. });
  1410. Livewire.on('hide-export-modal', () => {
  1411. $('#exportModal').modal('hide');
  1412. });
  1413. function showToast(type, message, duration = 5000) {
  1414. const toastContainer = document.querySelector('.toast-container');
  1415. if (!toastContainer) {
  1416. console.error('Toast container not found');
  1417. return;
  1418. }
  1419. const toastId = 'toast-' + Date.now();
  1420. const toastColors = {
  1421. success: 'bg-success',
  1422. error: 'bg-danger',
  1423. warning: 'bg-warning',
  1424. info: 'bg-info'
  1425. };
  1426. const toastIcons = {
  1427. success: 'fa-check-circle',
  1428. error: 'fa-exclamation-circle',
  1429. warning: 'fa-exclamation-triangle',
  1430. info: 'fa-info-circle'
  1431. };
  1432. const toast = document.createElement('div');
  1433. toast.id = toastId;
  1434. toast.className = `toast align-items-center text-white ${toastColors[type]} border-0`;
  1435. toast.setAttribute('role', 'alert');
  1436. toast.innerHTML = `
  1437. <div class="d-flex">
  1438. <div class="toast-body">
  1439. <i class="fas ${toastIcons[type]} me-2"></i>
  1440. ${message}
  1441. </div>
  1442. <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
  1443. </div>
  1444. `;
  1445. toastContainer.appendChild(toast);
  1446. if (typeof bootstrap !== 'undefined') {
  1447. const bsToast = new bootstrap.Toast(toast, { delay: duration });
  1448. bsToast.show();
  1449. toast.addEventListener('hidden.bs.toast', function() {
  1450. if (toastContainer.contains(toast)) {
  1451. toastContainer.removeChild(toast);
  1452. }
  1453. });
  1454. return bsToast;
  1455. } else {
  1456. toast.style.display = 'block';
  1457. setTimeout(() => {
  1458. if (toastContainer.contains(toast)) {
  1459. toastContainer.removeChild(toast);
  1460. }
  1461. }, duration);
  1462. }
  1463. }
  1464. document.addEventListener('DOMContentLoaded', function() {
  1465. const sendViaEmailCheckbox = document.getElementById('sendViaEmail');
  1466. const emailAddressRow = document.getElementById('emailAddressRow');
  1467. const emailSubjectRow = document.getElementById('emailSubjectRow');
  1468. const emailProcessingInfo = document.getElementById('emailProcessingInfo');
  1469. const exportIcon = document.getElementById('exportIcon');
  1470. const exportButtonText = document.getElementById('exportButtonText');
  1471. const emailInput = document.getElementById('exportEmailAddress');
  1472. function toggleEmailFields() {
  1473. if (sendViaEmailCheckbox && sendViaEmailCheckbox.checked) {
  1474. if (emailAddressRow) {
  1475. emailAddressRow.style.display = 'block';
  1476. emailAddressRow.classList.add('show');
  1477. }
  1478. if (emailSubjectRow) {
  1479. emailSubjectRow.style.display = 'block';
  1480. emailSubjectRow.classList.add('show');
  1481. }
  1482. if (emailProcessingInfo) {
  1483. emailProcessingInfo.style.display = 'list-item';
  1484. }
  1485. if (exportIcon) exportIcon.className = 'fas fa-paper-plane me-1';
  1486. if (exportButtonText) exportButtonText.textContent = 'INVIA EMAIL';
  1487. } else {
  1488. if (emailAddressRow) {
  1489. emailAddressRow.style.display = 'none';
  1490. emailAddressRow.classList.remove('show');
  1491. }
  1492. if (emailSubjectRow) {
  1493. emailSubjectRow.style.display = 'none';
  1494. emailSubjectRow.classList.remove('show');
  1495. }
  1496. if (emailProcessingInfo) {
  1497. emailProcessingInfo.style.display = 'none';
  1498. }
  1499. if (exportIcon) exportIcon.className = 'fas fa-download me-1';
  1500. if (exportButtonText) exportButtonText.textContent = 'ESPORTA';
  1501. }
  1502. }
  1503. function validateEmail(email) {
  1504. const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  1505. return emailRegex.test(email);
  1506. }
  1507. if (sendViaEmailCheckbox) {
  1508. sendViaEmailCheckbox.addEventListener('change', toggleEmailFields);
  1509. }
  1510. if (emailInput) {
  1511. emailInput.addEventListener('blur', function() {
  1512. if (sendViaEmailCheckbox && sendViaEmailCheckbox.checked && this.value) {
  1513. if (validateEmail(this.value)) {
  1514. this.classList.remove('is-invalid');
  1515. this.classList.add('is-valid');
  1516. } else {
  1517. this.classList.remove('is-valid');
  1518. this.classList.add('is-invalid');
  1519. }
  1520. }
  1521. });
  1522. emailInput.addEventListener('input', function() {
  1523. this.classList.remove('is-invalid', 'is-valid');
  1524. });
  1525. }
  1526. if (typeof $ !== 'undefined') {
  1527. $('#exportModal').on('shown.bs.modal', function() {
  1528. toggleEmailFields();
  1529. });
  1530. }
  1531. });
  1532. document.addEventListener('livewire:load', function () {
  1533. console.log('Livewire loaded, setting up export event listeners');
  1534. Livewire.on('export-email-queued', function() {
  1535. console.log('Export email queued event received');
  1536. showToast('info',
  1537. '<strong>Export avviato!</strong><br>' +
  1538. 'L\'elaborazione è in corso in background. Riceverai l\'email a breve.',
  1539. 8000
  1540. );
  1541. });
  1542. Livewire.on('export-email-sent', function() {
  1543. console.log('Export email sent event received');
  1544. showToast('success',
  1545. '<strong>Email inviata!</strong><br>' +
  1546. 'L\'export è stato completato e inviato alla tua email.',
  1547. 6000
  1548. );
  1549. });
  1550. Livewire.on('export-email-error', function(message) {
  1551. console.log('Export email error event received:', message);
  1552. showToast('error',
  1553. '<strong>Errore nell\'export:</strong><br>' +
  1554. (message || 'Si è verificato un errore durante l\'elaborazione.'),
  1555. 10000
  1556. );
  1557. });
  1558. Livewire.on('show-export-modal', function() {
  1559. console.log('Show export modal event received');
  1560. if (typeof $ !== 'undefined') {
  1561. $('#exportModal').modal('show');
  1562. }
  1563. });
  1564. Livewire.on('hide-export-modal', function() {
  1565. console.log('Hide export modal event received');
  1566. if (typeof $ !== 'undefined') {
  1567. $('#exportModal').modal('hide');
  1568. }
  1569. });
  1570. });
  1571. if (typeof Livewire !== 'undefined') {
  1572. document.addEventListener('livewire:initialized', function () {
  1573. console.log('Livewire initialized, setting up export event listeners');
  1574. Livewire.on('export-email-queued', function() {
  1575. showToast('info',
  1576. '<strong>Export avviato!</strong><br>' +
  1577. 'L\'elaborazione è in corso in background. Riceverai l\'email a breve.',
  1578. 8000
  1579. );
  1580. });
  1581. Livewire.on('export-email-sent', function() {
  1582. showToast('success',
  1583. '<strong>Email inviata!</strong><br>' +
  1584. 'L\'export è stato completato e inviato alla tua email.',
  1585. 6000
  1586. );
  1587. });
  1588. Livewire.on('export-email-error', function(message) {
  1589. showToast('error',
  1590. '<strong>Errore nell\'export:</strong><br>' +
  1591. (message || 'Si è verificato un errore durante l\'elaborazione.'),
  1592. 10000
  1593. );
  1594. });
  1595. Livewire.on('show-export-modal', function() {
  1596. if (typeof $ !== 'undefined') {
  1597. $('#exportModal').modal('show');
  1598. }
  1599. });
  1600. Livewire.on('hide-export-modal', function() {
  1601. if (typeof $ !== 'undefined') {
  1602. $('#exportModal').modal('hide');
  1603. }
  1604. });
  1605. });
  1606. }
  1607. window.addEventListener('load', function() {
  1608. if (typeof showToast === 'function') {
  1609. console.log('showToast function is available globally');
  1610. } else {
  1611. console.error('showToast function is not available globally');
  1612. }
  1613. });
  1614. function handleExportClick() {
  1615. showExportLoading();
  1616. @this.call('exportWithDateRange');
  1617. }
  1618. function showExportLoading() {
  1619. document.getElementById('normalState').style.display = 'none';
  1620. document.getElementById('loadingState').style.display = 'inline-flex';
  1621. document.getElementById('exportButton').disabled = true;
  1622. }
  1623. function hideExportLoading() {
  1624. document.getElementById('normalState').style.display = 'inline-flex';
  1625. document.getElementById('loadingState').style.display = 'none';
  1626. document.getElementById('exportButton').disabled = false;
  1627. }
  1628. Livewire.on('export-complete', function() {
  1629. hideExportLoading();
  1630. });
  1631. Livewire.on('hide-export-modal', function() {
  1632. hideExportLoading();
  1633. });
  1634. function setupSimpleExportListeners() {
  1635. if (typeof Livewire !== 'undefined') {
  1636. Livewire.on('export-email-queued', function() {
  1637. setTimeout(() => {
  1638. hideExportLoading();
  1639. $('#exportModal').modal('hide');
  1640. showToast('success',
  1641. '<i class="fas fa-paper-plane me-2"></i>' +
  1642. '<strong>Export avviato!</strong><br>' +
  1643. 'Riceverai l\'email a breve.',
  1644. 6000
  1645. );
  1646. }, 1500);
  1647. });
  1648. Livewire.on('export-complete', function() {
  1649. hideExportLoading();
  1650. });
  1651. Livewire.on('hide-export-modal', function() {
  1652. hideExportLoading();
  1653. $('#exportModal').modal('hide');
  1654. });
  1655. }
  1656. }
  1657. document.addEventListener('DOMContentLoaded', function() {
  1658. document.addEventListener('click', function(event) {
  1659. const monthPicker = document.querySelector('.month-picker-dropdown');
  1660. const monthPickerContainer = document.querySelector('.month-picker-container');
  1661. if (monthPicker && monthPickerContainer && !monthPickerContainer.contains(event.target)) {
  1662. if (typeof @this !== 'undefined') {
  1663. @this.set('showMonthPicker', false);
  1664. }
  1665. }
  1666. });
  1667. document.addEventListener('keydown', function(event) {
  1668. if (event.key === 'Escape') {
  1669. if (typeof @this !== 'undefined') {
  1670. @this.set('showMonthPicker', false);
  1671. }
  1672. }
  1673. });
  1674. document.addEventListener('click', function(event) {
  1675. const monthPickerDropdown = event.target.closest('.month-picker-dropdown');
  1676. if (monthPickerDropdown) {
  1677. event.stopPropagation();
  1678. }
  1679. });
  1680. });
  1681. function resetFiltersWithMonthPicker() {
  1682. $('.filterMember').val('').trigger('change');
  1683. $('.filterCausals').val('').trigger('change');
  1684. if (typeof @this !== 'undefined') {
  1685. @this.call('resetFilters');
  1686. }
  1687. load();
  1688. }
  1689. if (typeof Livewire !== 'undefined') {
  1690. Livewire.on('filters-applied', function() {
  1691. console.log('Filters applied with month picker');
  1692. });
  1693. Livewire.on('filters-reset', function() {
  1694. console.log('Filters reset including month picker');
  1695. load();
  1696. });
  1697. }
  1698. function initializeMonthPicker() {
  1699. const monthPickerDropdown = document.querySelector('.month-picker-dropdown');
  1700. if (monthPickerDropdown) {
  1701. monthPickerDropdown.style.opacity = '0';
  1702. monthPickerDropdown.style.transform = 'translateY(-10px)';
  1703. setTimeout(() => {
  1704. monthPickerDropdown.style.transition = 'all 0.2s ease-out';
  1705. monthPickerDropdown.style.opacity = '1';
  1706. monthPickerDropdown.style.transform = 'translateY(0)';
  1707. }, 10);
  1708. }
  1709. }
  1710. document.addEventListener('livewire:updated', function() {
  1711. initializeMonthPicker();
  1712. });
  1713. </script>
  1714. @endpush