329 lines
15 KiB
PHP
329 lines
15 KiB
PHP
<!-- FILTRI E RICERCA: Grafica standard NetGescon -->
|
|
<div class="netgescon-card mb-3">
|
|
<form class="grid md:grid-cols-12 gap-3 items-end">
|
|
<div class="col-span-12 md:col-span-4">
|
|
<label class="form-label" for="search_stabili">Ricerca</label>
|
|
<input type="text" class="netgescon-input" id="search_stabili" placeholder="Denominazione, codice o indirizzo">
|
|
</div>
|
|
<div class="col-span-12 md:col-span-3">
|
|
<label class="form-label" for="filter_provincia">Provincia</label>
|
|
<select class="netgescon-input" id="filter_provincia">
|
|
<option value="">Tutte</option>
|
|
@foreach(($province ?? []) as $provincia)
|
|
<option value="{{ $provincia }}">{{ $provincia }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-span-12 md:col-span-3">
|
|
<label class="form-label" for="filter_stato">Stato</label>
|
|
<select class="netgescon-input" id="filter_stato">
|
|
<option value="">Tutti</option>
|
|
<option value="attivo">Attivo</option>
|
|
<option value="non_attivo">Non attivo</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-span-12 md:col-span-2">
|
|
<button type="button" class="netgescon-btn netgescon-btn-primary" onclick="filterStabili()">
|
|
<i class="mdi mdi-magnify me-1"></i> Filtra
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<div class="mt-2 flex gap-2">
|
|
<button type="button" class="netgescon-btn netgescon-btn-outline-secondary netgescon-btn-sm" onclick="refreshStabili()">
|
|
<i class="mdi mdi-refresh me-1"></i> Aggiorna
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-outline-success netgescon-btn-sm" onclick="exportStabili()">
|
|
<i class="mdi mdi-file-excel me-1"></i> Esporta Excel
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- TABELLA STABILI -->
|
|
<div class="netgescon-card">
|
|
<div class="netgescon-card-header flex justify-between items-center">
|
|
<h3 class="card-title">
|
|
<i class="mdi mdi-home-group me-2"></i>
|
|
Lista Stabili Importati
|
|
@if(isset($stabili))
|
|
<span class="text-sm text-gray-500">({{ number_format($stabili->total()) }})</span>
|
|
@endif
|
|
</h3>
|
|
<div></div>
|
|
</div>
|
|
<div class="netgescon-card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead class="table-dark">
|
|
<tr>
|
|
<th>
|
|
<input type="checkbox" id="select_all_stabili" onchange="toggleSelectAllStabili()">
|
|
</th>
|
|
<th>Codice/Denominazione</th>
|
|
<th>Indirizzo Completo</th>
|
|
<th>CF Stabile / Amm.</th>
|
|
<th>Unità</th>
|
|
<th>Millesimi</th>
|
|
<th>Data Import</th>
|
|
<th>Stato</th>
|
|
<th>Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="stabili_tbody">
|
|
@forelse($stabili as $stabile)
|
|
<tr>
|
|
<td>
|
|
<input type="checkbox" class="stabile_checkbox" value="{{ $stabile->id }}">
|
|
</td>
|
|
<td>
|
|
<div>
|
|
<strong>{{ $stabile->denominazione }}</strong>
|
|
@if($stabile->codice_interno)
|
|
<br><small class="text-gray-500">Cod: {{ $stabile->codice_interno }}</small>
|
|
@endif
|
|
@if($stabile->codice_fiscale)
|
|
<br><small class="text-gray-500">CF: {{ $stabile->codice_fiscale }}</small>
|
|
@endif
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div>
|
|
{{ $stabile->indirizzo }}
|
|
@if($stabile->numero_civico)
|
|
{{ $stabile->numero_civico }}
|
|
@endif
|
|
</div>
|
|
<small class="text-gray-500">
|
|
{{ $stabile->cap }} {{ $stabile->comune_denominazione ?? $stabile->comune_cod ?? '' }}
|
|
@if($stabile->provincia)
|
|
({{ $stabile->provincia }})
|
|
@endif
|
|
</small>
|
|
</td>
|
|
<td>
|
|
<div class="text-xs">
|
|
<div><span class="text-gray-500">Stab.:</span> <span class="font-mono">{{ $stabile->codice_fiscale ?? '—' }}</span></div>
|
|
@php $cfAmm = $stabile->cod_fisc_amministratore ?? null; @endphp
|
|
@if($cfAmm)
|
|
<div><span class="text-gray-500">Amm.:</span> <span class="font-mono">{{ $cfAmm }}</span></div>
|
|
@else
|
|
<div class="text-gray-500">Amm.: —</div>
|
|
@endif
|
|
</div>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="netgescon-badge netgescon-badge-primary">
|
|
{{ $stabile->numero_unita ?? $stabile->unitaImmobiliari()->count() }}
|
|
</span>
|
|
</td>
|
|
<td class="text-center">
|
|
@if($stabile->millesimi_generali)
|
|
<span class="netgescon-badge netgescon-badge-success">
|
|
{{ number_format($stabile->millesimi_generali, 0) }}‰
|
|
</span>
|
|
@else
|
|
<span class="netgescon-badge netgescon-badge-warning">N/D</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
<small>{{ $stabile->created_at->format('d/m/Y H:i') }}</small>
|
|
@if($stabile->updated_at != $stabile->created_at)
|
|
<br><small class="text-gray-500">Mod: {{ $stabile->updated_at->format('d/m/Y') }}</small>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($stabile->attivo)
|
|
<span class="netgescon-badge netgescon-badge-success">Attivo</span>
|
|
@else
|
|
<span class="netgescon-badge netgescon-badge-danger">Non attivo</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
<div class="btn-group btn-group-sm">
|
|
<button type="button" class="netgescon-btn netgescon-btn-info" onclick="viewStabile({{ $stabile->id }})" title="Visualizza dettagli">
|
|
<i class="mdi mdi-eye"></i>
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-warning" onclick="editStabile({{ $stabile->id }})" title="Modifica">
|
|
<i class="mdi mdi-pencil"></i>
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-success" onclick="viewUnita({{ $stabile->id }})" title="Visualizza unità">
|
|
<i class="mdi mdi-home-variant"></i>
|
|
</button>
|
|
<div class="btn-group" role="group">
|
|
<button type="button" class="netgescon-btn netgescon-btn-secondary dropdown-toggle" data-bs-toggle="dropdown">
|
|
<i class="mdi mdi-dots-vertical"></i>
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
<li><a class="dropdown-item" href="#" onclick="duplicateStabile({{ $stabile->id }})">
|
|
<i class="mdi mdi-content-copy me-1"></i> Duplica
|
|
</a></li>
|
|
<li><a class="dropdown-item" href="#" onclick="exportStabileData({{ $stabile->id }})">
|
|
<i class="mdi mdi-download me-1"></i> Esporta Dati
|
|
</a></li>
|
|
<li><hr class="dropdown-divider"></li>
|
|
<li><a class="dropdown-item text-danger" href="#" onclick="deleteStabile({{ $stabile->id }})">
|
|
<i class="mdi mdi-delete me-1"></i> Elimina
|
|
</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="8" class="text-center text-gray-500 py-4">
|
|
<i class="mdi mdi-information-outline"></i>
|
|
Nessun stabile trovato
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@if($stabili->hasPages())
|
|
<div class="netgescon-card-footer">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
Mostrando {{ $stabili->firstItem() }} - {{ $stabili->lastItem() }} di {{ number_format($stabili->total()) }} risultati
|
|
</div>
|
|
<div>
|
|
{{ $stabili->links() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- AZIONI BATCH -->
|
|
<div class="row mt-3" id="batch_actions" style="display: none;">
|
|
<div class="col-12">
|
|
<div class="netgescon-card bg-gray-100">
|
|
<div class="netgescon-card-body">
|
|
<h5>Azioni per <span id="selected_count">0</span> stabili selezionati:</h5>
|
|
<div class="btn-group">
|
|
<button type="button" class="netgescon-btn netgescon-btn-success" onclick="activateSelectedStabili()">
|
|
<i class="mdi mdi-check-circle"></i> Attiva Selezionati
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-warning" onclick="deactivateSelectedStabili()">
|
|
<i class="mdi mdi-pause-circle"></i> Disattiva Selezionati
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-info" onclick="exportSelectedStabili()">
|
|
<i class="mdi mdi-file-excel"></i> Esporta Selezionati
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-danger" onclick="deleteSelectedStabili()">
|
|
<i class="mdi mdi-delete"></i> Elimina Selezionati
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL DETTAGLI STABILE -->
|
|
<div class="modal fade" id="stabileDetailModal" tabindex="-1">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="mdi mdi-home-group me-2"></i>
|
|
Dettagli Stabile
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body" id="stabileDetailContent">
|
|
<!-- Content loaded via AJAX -->
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="netgescon-btn netgescon-btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-primary" onclick="editFromModal()">Modifica</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Funzioni JavaScript per gestione stabili
|
|
function filterStabili() {
|
|
const search = document.getElementById('search_stabili').value;
|
|
const provincia = document.getElementById('filter_provincia').value;
|
|
const stato = document.getElementById('filter_stato').value;
|
|
|
|
// Implementare filtro AJAX
|
|
console.log('Filtering:', { search, provincia, stato });
|
|
}
|
|
|
|
function toggleSelectAllStabili() {
|
|
const masterCheckbox = document.getElementById('select_all_stabili');
|
|
const checkboxes = document.querySelectorAll('.stabile_checkbox');
|
|
|
|
checkboxes.forEach(checkbox => {
|
|
checkbox.checked = masterCheckbox.checked;
|
|
});
|
|
|
|
updateBatchActions();
|
|
}
|
|
|
|
function updateBatchActions() {
|
|
const selected = document.querySelectorAll('.stabile_checkbox:checked').length;
|
|
const batchActions = document.getElementById('batch_actions');
|
|
const selectedCount = document.getElementById('selected_count');
|
|
|
|
if (selected > 0) {
|
|
batchActions.style.display = 'block';
|
|
selectedCount.textContent = selected;
|
|
} else {
|
|
batchActions.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
function viewStabile(id) {
|
|
// Load stabile details via AJAX
|
|
fetch(`/admin/stabili/${id}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
document.getElementById('stabileDetailContent').innerHTML = data.html;
|
|
new bootstrap.Modal(document.getElementById('stabileDetailModal')).show();
|
|
});
|
|
}
|
|
|
|
function editStabile(id) {
|
|
window.location.href = `/admin/stabili/${id}/edit`;
|
|
}
|
|
|
|
function viewUnita(id) {
|
|
// Switch to unita tab with filter for this stabile
|
|
const unitaTab = new bootstrap.Tab(document.querySelector('#unita-tab'));
|
|
unitaTab.show();
|
|
// Apply filter for this stabile
|
|
setTimeout(() => {
|
|
if (window.filterUnitaByStabile) {
|
|
window.filterUnitaByStabile(id);
|
|
}
|
|
}, 100);
|
|
}
|
|
|
|
function deleteStabile(id) {
|
|
if (confirm('Sei sicuro di voler eliminare questo stabile? Verranno eliminate anche tutte le unità associate.')) {
|
|
// Implement delete via AJAX
|
|
console.log('Delete stabile:', id);
|
|
}
|
|
}
|
|
|
|
function exportStabili() {
|
|
window.location.href = '/admin/gescon-import/export/stabili';
|
|
}
|
|
|
|
function refreshStabili() {
|
|
location.reload();
|
|
}
|
|
|
|
// Event listeners
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Add change listeners to checkboxes
|
|
document.querySelectorAll('.stabile_checkbox').forEach(checkbox => {
|
|
checkbox.addEventListener('change', updateBatchActions);
|
|
});
|
|
});
|
|
</script>
|