records.blade.php 79 KB

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