- Aggiunte viste complete per ripartizioni-spesa: create, edit, show - Aggiunte viste complete per piani-rateizzazione: index, create, edit, show - Aggiunte viste complete per rate: index, create, edit, show - Interfacce responsive con Bootstrap 5 e componenti interattivi - Tabelle DataTables con filtri avanzati e ricerca - Form validation completa con Select2 e date picker - Grafici Chart.js per statistiche e monitoraggio - Funzionalità AJAX per calcoli automatici e aggiornamenti - Design mobile-first con sidebar navigation aggiornata - Tutte le viste pronte per integrazione con controller esistenti
287 lines
13 KiB
PHP
287 lines
13 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Gestione Rate')
|
|
|
|
@section('content')
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3 class="card-title">Gestione Rate</h3>
|
|
<div class="card-tools">
|
|
<a href="{{ route('admin.rate.create') }}" class="btn btn-primary btn-sm">
|
|
<i class="fas fa-plus"></i> Nuova Rata
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<!-- Filtri -->
|
|
<div class="row mb-3">
|
|
<div class="col-md-3">
|
|
<select class="form-control" id="filtro-stato">
|
|
<option value="">Tutti gli stati</option>
|
|
<option value="da_pagare">Da Pagare</option>
|
|
<option value="pagata">Pagata</option>
|
|
<option value="scaduta">Scaduta</option>
|
|
<option value="sospesa">Sospesa</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<select class="form-control" id="filtro-piano">
|
|
<option value="">Tutti i piani</option>
|
|
@foreach($piani as $piano)
|
|
<option value="{{ $piano->id }}">{{ $piano->denominazione }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<input type="month" class="form-control" id="filtro-mese" placeholder="Filtra per mese">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<button type="button" class="btn btn-secondary" id="btn-reset-filtri">
|
|
<i class="fas fa-sync"></i> Reset Filtri
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-striped" id="rate-table">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Piano</th>
|
|
<th>Numero Rata</th>
|
|
<th>Data Scadenza</th>
|
|
<th>Importo</th>
|
|
<th>Interessi</th>
|
|
<th>Spese</th>
|
|
<th>Totale</th>
|
|
<th>Stato</th>
|
|
<th>Pagato</th>
|
|
<th>Residuo</th>
|
|
<th>Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($rate as $rata)
|
|
<tr class="{{ $rata->data_scadenza->isPast() && $rata->stato != 'pagata' ? 'table-danger' : '' }}">
|
|
<td>{{ $rata->id }}</td>
|
|
<td>
|
|
<a href="{{ route('admin.piani-rateizzazione.show', $rata->piano->id) }}" class="text-info">
|
|
{{ $rata->piano->denominazione }}
|
|
</a>
|
|
</td>
|
|
<td>{{ $rata->numero_rata }}</td>
|
|
<td>{{ $rata->data_scadenza->format('d/m/Y') }}</td>
|
|
<td>€ {{ number_format($rata->importo, 2, ',', '.') }}</td>
|
|
<td>€ {{ number_format($rata->importo_interessi, 2, ',', '.') }}</td>
|
|
<td>€ {{ number_format($rata->importo_spese, 2, ',', '.') }}</td>
|
|
<td><strong>€ {{ number_format($rata->importo_totale, 2, ',', '.') }}</strong></td>
|
|
<td>
|
|
<span class="badge badge-{{ $rata->stato == 'pagata' ? 'success' : ($rata->stato == 'scaduta' ? 'danger' : ($rata->stato == 'sospesa' ? 'warning' : 'info')) }}">
|
|
{{ ucfirst($rata->stato) }}
|
|
</span>
|
|
</td>
|
|
<td>€ {{ number_format($rata->importo_pagato, 2, ',', '.') }}</td>
|
|
<td>€ {{ number_format($rata->importo_totale - $rata->importo_pagato, 2, ',', '.') }}</td>
|
|
<td>
|
|
<div class="btn-group">
|
|
<a href="{{ route('admin.rate.show', $rata->id) }}" class="btn btn-sm btn-info">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
@can('update', $rata)
|
|
<a href="{{ route('admin.rate.edit', $rata->id) }}" class="btn btn-sm btn-primary">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
@endcan
|
|
@if($rata->stato != 'pagata')
|
|
<button type="button" class="btn btn-sm btn-success" onclick="marcaPagata({{ $rata->id }})">
|
|
<i class="fas fa-check"></i>
|
|
</button>
|
|
@endif
|
|
@can('delete', $rata)
|
|
<form action="{{ route('admin.rate.destroy', $rata->id) }}" method="POST" style="display: inline;">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Sei sicuro di voler eliminare questa rata?')">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</form>
|
|
@endcan
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Statistiche -->
|
|
<div class="row">
|
|
<div class="col-lg-3 col-6">
|
|
<div class="small-box bg-info">
|
|
<div class="inner">
|
|
<h3>{{ $rate->count() }}</h3>
|
|
<p>Rate Totali</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-calendar-check"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-3 col-6">
|
|
<div class="small-box bg-success">
|
|
<div class="inner">
|
|
<h3>{{ $rate->where('stato', 'pagata')->count() }}</h3>
|
|
<p>Rate Pagate</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-check"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-3 col-6">
|
|
<div class="small-box bg-danger">
|
|
<div class="inner">
|
|
<h3>{{ $rate->where('stato', 'scaduta')->count() }}</h3>
|
|
<p>Rate Scadute</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-3 col-6">
|
|
<div class="small-box bg-warning">
|
|
<div class="inner">
|
|
<h3>€ {{ number_format($rate->sum('importo_totale'), 0, ',', '.') }}</h3>
|
|
<p>Importo Totale</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-euro-sign"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Rate in scadenza -->
|
|
@if($rateInScadenza->count() > 0)
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card card-warning">
|
|
<div class="card-header">
|
|
<h3 class="card-title">Rate in Scadenza (prossimi 30 giorni)</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-striped table-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Piano</th>
|
|
<th>Rata</th>
|
|
<th>Data Scadenza</th>
|
|
<th>Importo</th>
|
|
<th>Giorni alla scadenza</th>
|
|
<th>Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($rateInScadenza as $rata)
|
|
<tr>
|
|
<td>{{ $rata->piano->denominazione }}</td>
|
|
<td>{{ $rata->numero_rata }}</td>
|
|
<td>{{ $rata->data_scadenza->format('d/m/Y') }}</td>
|
|
<td>€ {{ number_format($rata->importo_totale, 2, ',', '.') }}</td>
|
|
<td>{{ $rata->data_scadenza->diffInDays(now()) }}</td>
|
|
<td>
|
|
<a href="{{ route('admin.rate.show', $rata->id) }}" class="btn btn-sm btn-info">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endsection
|
|
|
|
@section('scripts')
|
|
<script>
|
|
$(document).ready(function() {
|
|
var table = $('#rate-table').DataTable({
|
|
responsive: true,
|
|
lengthChange: false,
|
|
autoWidth: false,
|
|
order: [[3, 'desc']],
|
|
language: {
|
|
url: '//cdn.datatables.net/plug-ins/1.10.25/i18n/Italian.json'
|
|
}
|
|
});
|
|
|
|
// Filtri
|
|
$('#filtro-stato').on('change', function() {
|
|
var stato = $(this).val();
|
|
table.column(8).search(stato).draw();
|
|
});
|
|
|
|
$('#filtro-piano').on('change', function() {
|
|
var piano = $(this).val();
|
|
table.column(1).search(piano).draw();
|
|
});
|
|
|
|
$('#filtro-mese').on('change', function() {
|
|
var mese = $(this).val();
|
|
if (mese) {
|
|
var anno = mese.split('-')[0];
|
|
var meseNum = mese.split('-')[1];
|
|
table.column(3).search(meseNum + '/' + anno).draw();
|
|
} else {
|
|
table.column(3).search('').draw();
|
|
}
|
|
});
|
|
|
|
$('#btn-reset-filtri').on('click', function() {
|
|
$('#filtro-stato, #filtro-piano, #filtro-mese').val('');
|
|
table.search('').columns().search('').draw();
|
|
});
|
|
});
|
|
|
|
function marcaPagata(id) {
|
|
if (confirm('Sei sicuro di voler marcare questa rata come pagata?')) {
|
|
$.ajax({
|
|
url: '{{ route("admin.rate.marca-pagata", ":id") }}'.replace(':id', id),
|
|
type: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
location.reload();
|
|
} else {
|
|
alert('Errore: ' + response.message);
|
|
}
|
|
},
|
|
error: function() {
|
|
alert('Errore nella marcatura del pagamento');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
@endsection
|