records.blade.php 81 KB

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