records.blade.php 80 KB

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