records.blade.php 70 KB

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