|
|
@@ -8,143 +8,160 @@
|
|
|
|
|
|
</header>
|
|
|
|
|
|
+
|
|
|
<section id="subheader" class="">
|
|
|
- <!--
|
|
|
- <form action="" class="group--action d-flex align-items-center">
|
|
|
- <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example">
|
|
|
- <option selected>Open this select menu</option>
|
|
|
- <option value="1">One</option>
|
|
|
- <option value="2">Two</option>
|
|
|
- <option value="3">Three</option>
|
|
|
- </select>
|
|
|
- <button type="submit" class="btn--ui">applica</button>
|
|
|
- </form>
|
|
|
- -->
|
|
|
-
|
|
|
- <div class="row g-3">
|
|
|
- <div class="col-md-2">
|
|
|
- Utente
|
|
|
- <select name="search_member_id" class="form-select filterMember" wire:model="filterMember">
|
|
|
- <option value="">--Seleziona--
|
|
|
- @foreach($members as $member)
|
|
|
- <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}}
|
|
|
- @endforeach
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col-md-4">
|
|
|
- Causale
|
|
|
- <select name="search_causal_id[]" class="form-select filterCausals me-2" multiple="multiple" wire:model="filterCausals">
|
|
|
- @foreach($causals as $causal)
|
|
|
- <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
|
|
|
- @endforeach
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col-md-2">
|
|
|
- <span class="date_span">Dal</span><input type="date" wire:model="fromDate" class="form-control">
|
|
|
- </div>
|
|
|
- <div class="col-md-2">
|
|
|
- <span class="date_span ms-2">al</span><input type="date" wire:model="toDate" class="form-control">
|
|
|
- </div>
|
|
|
- <div class="col-md-2">
|
|
|
- <div class="prima--nota_buttons ms-auto " style="float:right; margin-top:25px;">
|
|
|
- <button class="btn--ui lightGrey reset reset" style="margin-left:5px;color:#10172A;" onclick="reset()">RESET</button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <div class="row g-3">
|
|
|
+ <div class="col-md-2">
|
|
|
+ Utente
|
|
|
+ <select name="search_member_id" class="form-select filterMember" wire:model="filterMember">
|
|
|
+ <option value="">--Seleziona--
|
|
|
+ @foreach($members as $member)
|
|
|
+ <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}}
|
|
|
+ @endforeach
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-4">
|
|
|
+ Causale
|
|
|
+ <select name="search_causal_id[]" class="form-select filterCausals me-2" multiple="multiple" wire:model="filterCausals">
|
|
|
+ @foreach($causals as $causal)
|
|
|
+ <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
|
|
|
+ @endforeach
|
|
|
+ </select>
|
|
|
</div>
|
|
|
- <div style="float:left; margin-top:10px; margin-bottom:10px;">
|
|
|
- <div class="dropdown">
|
|
|
- <button class="btn--ui_outline light dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false"
|
|
|
- style="color:#10172A;">
|
|
|
- ESPORTA
|
|
|
- </button>
|
|
|
- <ul class="dropdown-menu" aria-labelledby="exportDropdown">
|
|
|
- <li><a class="dropdown-item" href="#" wire:click="export()">Excel</a></li>
|
|
|
- <li><a class="dropdown-item" href="#" id="print">Stampa</a></li>
|
|
|
- </ul>
|
|
|
+ <div class="col-md-2">
|
|
|
+ <span class="date_span">Dal</span>
|
|
|
+ <input type="date" wire:model.defer="fromDate" class="form-control" @if($isFiltering) disabled @endif>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-2">
|
|
|
+ <span class="date_span ms-2">al</span>
|
|
|
+ <input type="date" wire:model.defer="toDate" class="form-control" @if($isFiltering) disabled @endif>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-2">
|
|
|
+ <div class="prima--nota_buttons ms-auto" style="float:right; margin-top:25px;">
|
|
|
+ <button class="btn--ui primary" wire:click="applyFilters" style="margin-right:5px;" @if($isFiltering) disabled @endif>
|
|
|
+ @if($isFiltering)
|
|
|
+ <i class="fas fa-spinner fa-spin"></i> CARICAMENTO...
|
|
|
+ @else
|
|
|
+ FILTRA
|
|
|
+ @endif
|
|
|
+ </button>
|
|
|
+ <button class="btn--ui lightGrey reset reset" style="margin-left:5px;color:#10172A;" onclick="reset()" @if($isFiltering) disabled @endif>RESET</button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="float:left; margin-top:10px; margin-bottom:10px;">
|
|
|
+ <div class="dropdown">
|
|
|
+ <button class="btn--ui_outline light dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false"
|
|
|
+ style="color:#10172A;" @if($isFiltering) disabled @endif>
|
|
|
+ ESPORTA
|
|
|
+ </button>
|
|
|
+ <ul class="dropdown-menu" aria-labelledby="exportDropdown">
|
|
|
+ <li><a class="dropdown-item" href="#" wire:click="export()">Excel</a></li>
|
|
|
+ <li><a class="dropdown-item" href="#" id="print">Stampa</a></li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</section>
|
|
|
|
|
|
- <section id="resume-table" class="scrollTable records-table">
|
|
|
+ <section id="resume-table" class="scrollTable records-table" style="position: relative;">
|
|
|
|
|
|
- <!--
|
|
|
- <canvas id="recordChart"></canvas>
|
|
|
- -->
|
|
|
- <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th scope="col">Data</th>
|
|
|
- <th scope="col" style="border-left:3px solid white;">Causale</th>
|
|
|
- <th scope="col" style="border-left:3px solid white;">Dettaglio Causale</th>
|
|
|
- <th scope="col" style="border-left:3px solid white;">Stato</th>
|
|
|
- <th scope="col" style="border-left:3px solid white;">Nominativo</th>
|
|
|
- @foreach($payments as $p)
|
|
|
- <th colspan="2" scope="col" style="text-align:center; border-left:3px solid white;">{{$p->name}}</th>
|
|
|
- @endforeach
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="col"></th>
|
|
|
- <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
- <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
- <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
- <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
- @foreach($payments as $p)
|
|
|
- @if($p->type == 'ALL')
|
|
|
- <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
|
|
|
- <th scope="col" style="text-align:center">Uscite</th>
|
|
|
- @elseif($p->type == 'IN')
|
|
|
- <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
|
|
|
- <th scope="col" style="text-align:center;"></th>
|
|
|
-
|
|
|
- @elseif($p->type == 'OUT')
|
|
|
- <th style="border-left:3px solid white;"></th>
|
|
|
- <th scope="col" style="text-align:center;">Uscite</th>
|
|
|
- @endif
|
|
|
- @endforeach
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody id="checkall-target">
|
|
|
- @php
|
|
|
- $count = 0;
|
|
|
- @endphp
|
|
|
- @foreach($records as $causal => $record)
|
|
|
+ @if($isFiltering)
|
|
|
+ <div class="loading-overlay">
|
|
|
+ <div class="loading-content">
|
|
|
+ <i class="fas fa-spinner fa-spin fa-3x"></i>
|
|
|
+ <p>Caricamento dati in corso...</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ @endif
|
|
|
+
|
|
|
+ <!-- Your existing table -->
|
|
|
+ <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
|
|
|
+ <thead>
|
|
|
<tr>
|
|
|
- @php
|
|
|
- $check = strpos($causal, "$") ? explode("$", $causal)[1] : $causal;
|
|
|
- list($d, $c, $n, $det, $del) = explode("§", $check);
|
|
|
- @endphp
|
|
|
- <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($d))}}</td>
|
|
|
- <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$c}}</td>
|
|
|
- <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$det}}</td>
|
|
|
- <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
- @if($del == 'DELETED')
|
|
|
- <span style='color:red'>Annullata</span>
|
|
|
- @endif
|
|
|
- </td>
|
|
|
- <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$n}}</td>
|
|
|
+ <th scope="col">Data</th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;">Causale</th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;">Dettaglio Causale</th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;">Stato</th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;">Nominativo</th>
|
|
|
+ @foreach($payments as $p)
|
|
|
+ <th colspan="2" scope="col" style="text-align:center; border-left:3px solid white;">{{$p->name}}</th>
|
|
|
+ @endforeach
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <th scope="col"></th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
+ <th scope="col" style="border-left:3px solid white;"></th>
|
|
|
@foreach($payments as $p)
|
|
|
- @if(isset($record[$p->name]))
|
|
|
- <td style="text-align:right; border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
- @if(isset($record[$p->name]["IN"]))
|
|
|
- <span class="tablesaw-cell-content " style="color:green">{{formatPrice($record[$p->name]["IN"])}}</span>
|
|
|
- @endif
|
|
|
- </td>
|
|
|
- <td style="text-align:right;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
- @if(isset($record[$p->name]["OUT"]))
|
|
|
- <span class="tablesaw-cell-content " style="color:red">{{formatPrice($record[$p->name]["OUT"])}}</span>
|
|
|
- @endif
|
|
|
- </td>
|
|
|
- @else
|
|
|
- <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
|
|
|
- <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
|
|
|
+ @if($p->type == 'ALL')
|
|
|
+ <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
|
|
|
+ <th scope="col" style="text-align:center">Uscite</th>
|
|
|
+ @elseif($p->type == 'IN')
|
|
|
+ <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
|
|
|
+ <th scope="col" style="text-align:center;"></th>
|
|
|
+ @elseif($p->type == 'OUT')
|
|
|
+ <th style="border-left:3px solid white;"></th>
|
|
|
+ <th scope="col" style="text-align:center;">Uscite</th>
|
|
|
@endif
|
|
|
@endforeach
|
|
|
</tr>
|
|
|
- @php
|
|
|
- $count++;
|
|
|
- @endphp
|
|
|
- @endforeach
|
|
|
- </tbody>
|
|
|
+ </thead>
|
|
|
+ <tbody id="checkall-target">
|
|
|
+ @php $count = 0; @endphp
|
|
|
+ @foreach($records as $causal => $record)
|
|
|
+ <tr>
|
|
|
+ @php
|
|
|
+ $parts = explode("§", $causal);
|
|
|
+ $d = $parts[0] ?? '';
|
|
|
+ $c = $parts[1] ?? '';
|
|
|
+ $n = $parts[2] ?? ''; // Nominativo
|
|
|
+ $det = $parts[3] ?? '';
|
|
|
+ $del = $parts[4] ?? '';
|
|
|
+
|
|
|
+ // Check if detail contains multiple causals (separated by |)
|
|
|
+ $detailParts = explode('|', $det);
|
|
|
+ $isMultiple = count($detailParts) > 1;
|
|
|
+ $displayDetail = $isMultiple ? 'Varie' : $det;
|
|
|
+ @endphp
|
|
|
+ <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($d))}}</td>
|
|
|
+ <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$c}}</td>
|
|
|
+ <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
+ @if($isMultiple)
|
|
|
+ <span class="varie-link" data-causals="{{implode('|', array_slice($detailParts, 1))}}" style="color: #0C6197; cursor: pointer; text-decoration: underline;">
|
|
|
+ {{$displayDetail}}
|
|
|
+ </span>
|
|
|
+ @else
|
|
|
+ {{$displayDetail}}
|
|
|
+ @endif
|
|
|
+ </td>
|
|
|
+ <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
+ @if($del == 'DELETED')
|
|
|
+ <span style='color:red'>Annullata</span>
|
|
|
+ @endif
|
|
|
+ </td>
|
|
|
+ <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$n}}</td>
|
|
|
+ @foreach($payments as $p)
|
|
|
+ @if(isset($record[$p->name]))
|
|
|
+ <td style="text-align:right; border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
+ @if(isset($record[$p->name]["IN"]))
|
|
|
+ <span class="tablesaw-cell-content " style="color:green">{{formatPrice($record[$p->name]["IN"])}}</span>
|
|
|
+ @endif
|
|
|
+ </td>
|
|
|
+ <td style="text-align:right;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
|
|
|
+ @if(isset($record[$p->name]["OUT"]))
|
|
|
+ <span class="tablesaw-cell-content " style="color:red">{{formatPrice($record[$p->name]["OUT"])}}</span>
|
|
|
+ @endif
|
|
|
+ </td>
|
|
|
+ @else
|
|
|
+ <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
|
|
|
+ <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}"></td>
|
|
|
+ @endif
|
|
|
+ @endforeach
|
|
|
+ </tr>
|
|
|
+ @php $count++; @endphp
|
|
|
+ @endforeach
|
|
|
+ </tbody>
|
|
|
<tfoot>
|
|
|
<tr>
|
|
|
<td></td>
|
|
|
@@ -203,40 +220,32 @@
|
|
|
</tr>
|
|
|
</tfoot>
|
|
|
</table>
|
|
|
-
|
|
|
- <!--
|
|
|
- <div class="paginator d-flex justify-content-center">
|
|
|
- <nav aria-label="Page navigation example">
|
|
|
- <ul class="pagination">
|
|
|
- <li class="page-item">
|
|
|
- <a class="page-link" href="#" aria-label="Previous">
|
|
|
- <span aria-hidden="true"></span>
|
|
|
- </a>
|
|
|
- </li>
|
|
|
- <li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
|
- <li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
|
- <li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
|
- <li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
|
-
|
|
|
- <li class="page-item"><span class="more-page">...</span></li>
|
|
|
-
|
|
|
- <li class="page-item">
|
|
|
- <a class="page-link" href="#" aria-label="Next">
|
|
|
- <span aria-hidden="true"></span>
|
|
|
- </a>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </nav>
|
|
|
- </div>
|
|
|
- -->
|
|
|
- <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-bottom" ><i class="fas fa-arrow-down"></i></button>
|
|
|
- <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-top" ><i class="fas fa-arrow-up"></i></button>
|
|
|
+ <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-bottom"><i class="fas fa-arrow-down"></i></button>
|
|
|
+ <button type="button" class="btn btn-floating btn-lg" id="btn-back-to-top"><i class="fas fa-arrow-up"></i></button>
|
|
|
</section>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ <div class="modal fade" id="causalsModal" tabindex="-1" aria-labelledby="causalsModalLabel" aria-hidden="true">
|
|
|
+ <div class="modal-dialog modal-lg">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header" style="background-color: #0C6197!important;">
|
|
|
+ <h5 class="modal-title" id="causalsModalLabel" >Dettaglio Causali</h5>
|
|
|
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="CHIUDI"></button>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body">
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-12">
|
|
|
+ <h6>Causali incluse:</h6>
|
|
|
+ <ul id="causalsList" class="list-group list-group-flush">
|
|
|
+ <!-- Causals will be populated here by JavaScript -->
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer" style="background-color: #FFF!important;">
|
|
|
+ <button type="button" class="btn--ui lightGrey me-2" data-bs-dismiss="modal">CHIUDI</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@@ -462,7 +471,7 @@
|
|
|
|
|
|
setMaxWidth();
|
|
|
setMaxHeight();
|
|
|
- $( window ).bind( "resize", setMaxWidth ); //Remove this if it's not needed. It will react when window changes size.
|
|
|
+ $( window ).bind( "resize", setMaxWidth );
|
|
|
$( window ).bind( "resize", setMaxHeight );
|
|
|
|
|
|
$(".open-filter").click(function(){
|
|
|
@@ -473,17 +482,14 @@
|
|
|
});
|
|
|
|
|
|
function setMaxWidth() {
|
|
|
- // $("#resume-table").width( Math.round( $(window ).width() - size ) ) ;
|
|
|
}
|
|
|
|
|
|
function setMaxHeight() {
|
|
|
- // $("#resume-table").height( Math.round( $(window ).height() - 300 ) ) ;
|
|
|
}
|
|
|
|
|
|
let mybuttonBottom = document.getElementById("btn-back-to-bottom");
|
|
|
let mybutton = document.getElementById("btn-back-to-top");
|
|
|
|
|
|
- // When the user scrolls down 20px from the top of the document, show the button
|
|
|
window.onscroll = function () {
|
|
|
scrollFunction();
|
|
|
};
|
|
|
@@ -492,15 +498,6 @@
|
|
|
element.onscroll = (e)=>{
|
|
|
scrollFunction();
|
|
|
};
|
|
|
- /*if (element.scrollTop < lastScrollTop){
|
|
|
- // upscroll
|
|
|
- return;
|
|
|
- }
|
|
|
- lastScrollTop = element.scrollTop <= 0 ? 0 : element.scrollTop;
|
|
|
- if (element.scrollTop + element.offsetHeight>= element.scrollHeight ){
|
|
|
- console.log("End");
|
|
|
- }
|
|
|
- }*/
|
|
|
|
|
|
function scrollFunction() {
|
|
|
if (
|
|
|
@@ -548,8 +545,190 @@
|
|
|
$('.filterCausals').trigger('change');
|
|
|
var today = new Date().toISOString().split('T')[0];
|
|
|
|
|
|
+ // Update the form inputs
|
|
|
window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('fromDate', today);
|
|
|
window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('toDate', today);
|
|
|
+
|
|
|
+ // Reset the applied dates and trigger filter
|
|
|
+ window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('appliedFromDate', today);
|
|
|
+ window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).set('appliedToDate', today);
|
|
|
+
|
|
|
+ // Trigger re-render
|
|
|
+ window.livewire.find(document.querySelector('[wire\\:id]').getAttribute('wire:id')).call('$refresh');
|
|
|
}
|
|
|
+
|
|
|
+ $(document).ready(function() {
|
|
|
+ // Safe function to close select2 dropdowns
|
|
|
+ function closeSelect2Dropdowns() {
|
|
|
+ // Only close select2 on elements that actually have select2 initialized
|
|
|
+ $('.filterCausals').each(function() {
|
|
|
+ if ($(this).hasClass('select2-hidden-accessible')) {
|
|
|
+ $(this).select2('close');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('.filterMember').each(function() {
|
|
|
+ if ($(this).hasClass('select2-hidden-accessible')) {
|
|
|
+ $(this).select2('close');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // Handle click on "Varie" links
|
|
|
+ $(document).on('click', '.varie-link', function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
+
|
|
|
+ // Close any open select2 dropdowns safely
|
|
|
+ closeSelect2Dropdowns();
|
|
|
+
|
|
|
+ // Get the causals data from the data attribute
|
|
|
+ const causalsData = $(this).data('causals');
|
|
|
+
|
|
|
+ if (causalsData) {
|
|
|
+ // Split the causals by | separator
|
|
|
+ const causals = causalsData.split('|');
|
|
|
+
|
|
|
+ // Clear the previous list
|
|
|
+ $('#causalsList').empty();
|
|
|
+
|
|
|
+ // Populate the modal with causals
|
|
|
+ causals.forEach(function(causal) {
|
|
|
+ if (causal.trim()) {
|
|
|
+ $('#causalsList').append(
|
|
|
+ '<li class="list-group-item">' +
|
|
|
+ '<i class="fas fa-tags me-2" style="color: #0C6197;"></i>' +
|
|
|
+ causal.trim() +
|
|
|
+ '</li>'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // Show the modal with proper focus management
|
|
|
+ $('#causalsModal').modal('show');
|
|
|
+
|
|
|
+ // Ensure modal gets focus
|
|
|
+ $('#causalsModal').on('shown.bs.modal', function () {
|
|
|
+ $(this).find('.btn-close').focus();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // Close select2 dropdowns when modal is opening
|
|
|
+ $('#causalsModal').on('show.bs.modal', function () {
|
|
|
+ closeSelect2Dropdowns();
|
|
|
+ $('body').addClass('modal-open');
|
|
|
+ });
|
|
|
+
|
|
|
+ // Clean up when modal is closed
|
|
|
+ $('#causalsModal').on('hidden.bs.modal', function () {
|
|
|
+ $('body').removeClass('modal-open');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // Update the existing load function to include the new event handlers
|
|
|
+ function load()
|
|
|
+ {
|
|
|
+ $(document).ready(function(){
|
|
|
+
|
|
|
+ $(document).on("keypress", $('.filterCausals'), function (e) {
|
|
|
+ setTimeout(() => {
|
|
|
+ $(".select2-results__option").each(function(){
|
|
|
+ var txt = $(this).html();
|
|
|
+ var count = (txt.match(/-/g) || []).length;
|
|
|
+ $(this).addClass('paddingLeftSelect' + count);
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+
|
|
|
+ // Initialize select2 only if not already initialized
|
|
|
+ if (!$('.filterCausals').hasClass('select2-hidden-accessible')) {
|
|
|
+ $('.filterCausals').select2({
|
|
|
+ "language": {"noResults": function(){return "Nessun risultato";}},
|
|
|
+ "dropdownParent": $('body'),
|
|
|
+ "width": "100%"
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $('.filterCausals').off('change.customHandler').on('change.customHandler', function (e) {
|
|
|
+ var data = $('.filterCausals').select2("val");
|
|
|
+ @this.set('filterCausals', data);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.filterCausals').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
|
|
|
+ // Close modal if open when select2 opens
|
|
|
+ if ($('#causalsModal').hasClass('show')) {
|
|
|
+ $('#causalsModal').modal('hide');
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ $(".select2-results__option").each(function(){
|
|
|
+ var txt = $(this).html();
|
|
|
+ var count = (txt.match(/-/g) || []).length;
|
|
|
+ $(this).addClass('paddingLeftSelect' + count);
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+
|
|
|
+ // Initialize select2 only if not already initialized
|
|
|
+ if (!$('.filterMember').hasClass('select2-hidden-accessible')) {
|
|
|
+ $('.filterMember').select2({
|
|
|
+ "language": {"noResults": function(){return "Nessun risultato";}},
|
|
|
+ "dropdownParent": $('body'),
|
|
|
+ "width": "100%"
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $('.filterMember').off('change.customHandler').on('change.customHandler', function (e) {
|
|
|
+ var data = $('.filterMember').select2("val");
|
|
|
+ @this.set('filterMember', data);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.filterMember').off('select2:open.customHandler').on('select2:open.customHandler', function (e) {
|
|
|
+ // Close modal if open when select2 opens
|
|
|
+ if ($('#causalsModal').hasClass('show')) {
|
|
|
+ $('#causalsModal').modal('hide');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // Re-attach event handlers for "Varie" links after Livewire updates
|
|
|
+ $(document).off('click', '.varie-link').on('click', '.varie-link', function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
+
|
|
|
+ // Close any open select2 dropdowns safely
|
|
|
+ $('.filterCausals').each(function() {
|
|
|
+ if ($(this).hasClass('select2-hidden-accessible')) {
|
|
|
+ $(this).select2('close');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('.filterMember').each(function() {
|
|
|
+ if ($(this).hasClass('select2-hidden-accessible')) {
|
|
|
+ $(this).select2('close');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const causalsData = $(this).data('causals');
|
|
|
+
|
|
|
+ if (causalsData) {
|
|
|
+ const causals = causalsData.split('|');
|
|
|
+
|
|
|
+ $('#causalsList').empty();
|
|
|
+
|
|
|
+ causals.forEach(function(causal) {
|
|
|
+ if (causal.trim()) {
|
|
|
+ $('#causalsList').append(
|
|
|
+ '<li class="list-group-item">' +
|
|
|
+ '<i class="fas fa-tags me-2" style="color: #0C6197;"></i>' +
|
|
|
+ causal.trim() +
|
|
|
+ '</li>'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#causalsModal').modal('show');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
</script>
|
|
|
@endpush
|