187 lines
11 KiB
PHP
187 lines
11 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Ripartizioni Spesa')
|
|
|
|
@section('content')
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h3 class="card-title">
|
|
<i class="fas fa-chart-pie"></i> Ripartizioni Spesa
|
|
</h3>
|
|
<a href="{{ route('admin.ripartizioni-spesa.create') }}" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i> Nuova Ripartizione
|
|
</a>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<!-- Filtri -->
|
|
<div class="row mb-3">
|
|
<div class="col-12">
|
|
<form method="GET" action="{{ route('admin.ripartizioni-spesa.index') }}" class="row g-3">
|
|
<div class="col-md-3">
|
|
<label for="stabile_id" class="form-label">Stabile</label>
|
|
<select name="stabile_id" id="stabile_id" class="form-control">
|
|
<option value="">Tutti gli stabili</option>
|
|
@foreach($stabili as $stabile)
|
|
<option value="{{ $stabile->id }}" {{ request('stabile_id') == $stabile->id ? 'selected' : '' }}>
|
|
{{ $stabile->denominazione }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label for="voce_spesa_id" class="form-label">Voce di Spesa</label>
|
|
<select name="voce_spesa_id" id="voce_spesa_id" class="form-control">
|
|
<option value="">Tutte le voci</option>
|
|
@foreach($vociSpesa as $voceSpesa)
|
|
<option value="{{ $voceSpesa->id }}" {{ request('voce_spesa_id') == $voceSpesa->id ? 'selected' : '' }}>
|
|
{{ $voceSpesa->denominazione }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label for="stato" class="form-label">Stato</label>
|
|
<select name="stato" id="stato" class="form-control">
|
|
<option value="">Tutti gli stati</option>
|
|
<option value="bozza" {{ request('stato') == 'bozza' ? 'selected' : '' }}>Bozza</option>
|
|
<option value="confermata" {{ request('stato') == 'confermata' ? 'selected' : '' }}>Confermata</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label for="data_da" class="form-label">Da</label>
|
|
<input type="date" name="data_da" id="data_da" class="form-control" value="{{ request('data_da') }}">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label"> </label>
|
|
<div class="btn-group d-block">
|
|
<button type="submit" class="btn btn-outline-primary">
|
|
<i class="fas fa-search"></i> Filtra
|
|
</button>
|
|
<a href="{{ route('admin.ripartizioni-spesa.index') }}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-times"></i> Reset
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tabella Ripartizioni -->
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Codice</th>
|
|
<th>Voce di Spesa</th>
|
|
<th>Descrizione</th>
|
|
<th>Importo</th>
|
|
<th>Data</th>
|
|
<th>Stato</th>
|
|
<th>Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse($ripartizioni as $ripartizione)
|
|
<tr>
|
|
<td><code>{{ $ripartizione->codice_ripartizione }}</code></td>
|
|
<td>
|
|
<strong>{{ $ripartizione->voceSpesa->denominazione }}</strong>
|
|
<br><small class="text-muted">{{ $ripartizione->voceSpesa->stabile->denominazione }}</small>
|
|
</td>
|
|
<td>{{ $ripartizione->descrizione }}</td>
|
|
<td>
|
|
<span class="text-success">€ {{ number_format($ripartizione->importo_totale, 2, ',', '.') }}</span>
|
|
</td>
|
|
<td>{{ $ripartizione->data_ripartizione->format('d/m/Y') }}</td>
|
|
<td>
|
|
@switch($ripartizione->stato)
|
|
@case('bozza')
|
|
<span class="badge bg-warning">Bozza</span>
|
|
@break
|
|
@case('confermata')
|
|
<span class="badge bg-success">Confermata</span>
|
|
@break
|
|
@endswitch
|
|
</td>
|
|
<td>
|
|
<div class="btn-group" role="group">
|
|
<a href="{{ route('admin.ripartizioni-spesa.show', $ripartizione) }}"
|
|
class="btn btn-sm btn-outline-primary" title="Visualizza">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
@if($ripartizione->stato == 'bozza')
|
|
<a href="{{ route('admin.ripartizioni-spesa.edit', $ripartizione) }}"
|
|
class="btn btn-sm btn-outline-warning" title="Modifica">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
<form method="POST" action="{{ route('admin.ripartizioni-spesa.conferma', $ripartizione) }}"
|
|
style="display: inline;">
|
|
@csrf
|
|
<button type="submit" class="btn btn-sm btn-outline-success" title="Conferma">
|
|
<i class="fas fa-check"></i>
|
|
</button>
|
|
</form>
|
|
<form method="POST" action="{{ route('admin.ripartizioni-spesa.destroy', $ripartizione) }}"
|
|
style="display: inline;"
|
|
onsubmit="return confirm('Sei sicuro di voler eliminare questa ripartizione?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="btn btn-sm btn-outline-danger" title="Elimina">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="7" class="text-center">
|
|
<div class="py-4">
|
|
<i class="fas fa-chart-pie fa-3x text-muted mb-3"></i>
|
|
<p class="text-muted">Nessuna ripartizione trovata</p>
|
|
<a href="{{ route('admin.ripartizioni-spesa.create') }}" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i> Crea la prima ripartizione
|
|
</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Paginazione -->
|
|
@if($ripartizioni->hasPages())
|
|
<div class="d-flex justify-content-center">
|
|
{{ $ripartizioni->appends(request()->query())->links() }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('scripts')
|
|
<script>
|
|
// Auto-submit form when select changes
|
|
document.getElementById('stabile_id').addEventListener('change', function() {
|
|
this.form.submit();
|
|
});
|
|
|
|
document.getElementById('voce_spesa_id').addEventListener('change', function() {
|
|
this.form.submit();
|
|
});
|
|
|
|
document.getElementById('stato').addEventListener('change', function() {
|
|
this.form.submit();
|
|
});
|
|
</script>
|
|
@endsection
|