records.blade.php 71 KB

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