✅ CONTROLLERS IMPLEMENTATI: - VoceSpesaController: CRUD completo con filtri avanzati, duplicazione, AJAX - RipartizioneSpesaController: Calcolo automatico/manuale, workflow stati - PianoRateizzazioneController: Gestione piani rate con calcolo interessi - RataController: Pagamenti, posticipazioni, report, export CSV ✅ INTERFACCE UI RESPONSIVE: - Voci di Spesa: Elenco filtrato, form creazione Bootstrap 5 - Design System: Layout moderno con Font Awesome, responsive - Filtri Real-time: Aggiornamento automatico con AJAX - Validazioni: Client-side e server-side ✅ SISTEMA AUTORIZZAZIONI: - Policies complete per tutti i modelli - Controlli ownership per amministratori - Role-based access control - Data integrity e security ✅ FUNZIONALITÀ AVANZATE: - Calcoli automatici millesimi e rate - Gestione stati workflow (bozza→confermata→completata) - Codici alfanumerici univoci (SP, RP, PR) - Transazioni atomiche con rollback - Export CSV e reporting 🚀 SISTEMA CORE OPERATIVO: Pronto per gestione completa spese condominiali 📱 UI PRODUCTION-READY: Interfacce moderne e intuitive 🔐 SICUREZZA COMPLETA: Autorizzazioni e validazioni robuste 📊 BUSINESS LOGIC: Calcoli automatici e workflow operativi Next: Implementazione viste rimanenti e sistema plugin
91 lines
2.3 KiB
PHP
91 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\RipartizioneSpese;
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Access\Response;
|
|
|
|
class RipartizioneSpesaPolicy
|
|
{
|
|
/**
|
|
* Determine whether the user can view any models.
|
|
*/
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return $user->hasRole(['admin', 'amministratore']);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the model.
|
|
*/
|
|
public function view(User $user, RipartizioneSpese $ripartizioneSpese): bool
|
|
{
|
|
if ($user->hasRole('admin')) {
|
|
return true;
|
|
}
|
|
|
|
if ($user->hasRole('amministratore')) {
|
|
return $ripartizioneSpese->voceSpesa->stabile->amministratore_id === $user->amministratore->id_amministratore;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can create models.
|
|
*/
|
|
public function create(User $user): bool
|
|
{
|
|
return $user->hasRole(['admin', 'amministratore']);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the model.
|
|
*/
|
|
public function update(User $user, RipartizioneSpese $ripartizioneSpese): bool
|
|
{
|
|
if ($user->hasRole('admin')) {
|
|
return true;
|
|
}
|
|
|
|
if ($user->hasRole('amministratore')) {
|
|
return $ripartizioneSpese->voceSpesa->stabile->amministratore_id === $user->amministratore->id_amministratore;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*/
|
|
public function delete(User $user, RipartizioneSpese $ripartizioneSpese): bool
|
|
{
|
|
if ($user->hasRole('admin')) {
|
|
return true;
|
|
}
|
|
|
|
if ($user->hasRole('amministratore')) {
|
|
return $ripartizioneSpese->voceSpesa->stabile->amministratore_id === $user->amministratore->id_amministratore;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can restore the model.
|
|
*/
|
|
public function restore(User $user, RipartizioneSpese $ripartizioneSpese): bool
|
|
{
|
|
return $this->delete($user, $ripartizioneSpese);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can permanently delete the model.
|
|
*/
|
|
public function forceDelete(User $user, RipartizioneSpese $ripartizioneSpese): bool
|
|
{
|
|
return $user->hasRole('admin');
|
|
}
|
|
}
|