120 lines
3.9 KiB
PHP
Executable File
120 lines
3.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Stabile;
|
|
use App\Models\UnitaImmobiliare;
|
|
use App\Models\TabellaMillesimale;
|
|
use App\Models\GestioneCondominiale;
|
|
use Illuminate\Support\Facades\Auth as Auth;
|
|
use function view; // hint for analyzers
|
|
use function optional; // hint for analyzers
|
|
|
|
class CategoryDashboardController extends Controller
|
|
{
|
|
/**
|
|
* Dashboard Stabili
|
|
*/
|
|
public function stabili()
|
|
{
|
|
$user = Auth::user();
|
|
$amministratoreId = ($user && $user->amministratore) ? $user->amministratore->id : null;
|
|
$stabiliQuery = $amministratoreId ? Stabile::where('amministratore_id', $amministratoreId) : Stabile::whereRaw('1=0');
|
|
$unitaQuery = $amministratoreId ? UnitaImmobiliare::whereHas('stabile', function ($q) use ($amministratoreId) {
|
|
$q->where('amministratore_id', $amministratoreId);
|
|
}) : UnitaImmobiliare::whereRaw('1=0');
|
|
|
|
$statistiche = [
|
|
'totale_stabili' => (clone $stabiliQuery)->count(),
|
|
'stabili_attivi' => (clone $stabiliQuery)->where('attivo', true)->count(),
|
|
'totale_unita' => (clone $unitaQuery)->count(),
|
|
'unita_occupate' => (clone $unitaQuery)->whereIn('stato_occupazione', ['occupata_proprietario', 'occupata_inquilino'])->count(),
|
|
];
|
|
|
|
$stabili_recenti = (clone $stabiliQuery)->latest()->take(5)->get();
|
|
$unita_recenti = (clone $unitaQuery)->with('stabile')->latest()->take(5)->get();
|
|
|
|
return view('admin.dashboards.stabili', compact('statistiche', 'stabili_recenti', 'unita_recenti'));
|
|
}
|
|
|
|
/**
|
|
* Dashboard Condomini
|
|
*/
|
|
public function condomini()
|
|
{
|
|
$statistiche = [
|
|
'totale_condomini' => 0, // Da implementare con il modello Condomino
|
|
'condomini_attivi' => 0,
|
|
'proprietari' => 0,
|
|
'inquilini' => 0,
|
|
];
|
|
|
|
return view('admin.dashboards.condomini', compact('statistiche'));
|
|
}
|
|
|
|
/**
|
|
* Dashboard Amministrazione
|
|
*/
|
|
public function amministrazione()
|
|
{
|
|
$statistiche = [
|
|
'tabelle_millesimali' => TabellaMillesimale::count(),
|
|
'gestioni_attive' => GestioneCondominiale::where('stato', 'attiva')->count(),
|
|
'pratiche_aperte' => 0, // Da implementare
|
|
'assemblee_programmate' => 0, // Da implementare
|
|
];
|
|
|
|
$gestioni = GestioneCondominiale::all(); // Rimuoviamo temporaneamente la relazione con tabelleMillesimali
|
|
$tabelle_recenti = TabellaMillesimale::latest()->take(5)->get();
|
|
|
|
return view('admin.dashboards.amministrazione', compact('statistiche', 'gestioni', 'tabelle_recenti'));
|
|
}
|
|
|
|
/**
|
|
* Dashboard Contabilità
|
|
*/
|
|
public function contabilita()
|
|
{
|
|
$statistiche = [
|
|
'fatture_mese' => 0, // Da implementare
|
|
'pagamenti_pending' => 0, // Da implementare
|
|
'bilancio_anno' => 0, // Da implementare
|
|
'rate_scadute' => 1240, // Esempio
|
|
];
|
|
|
|
return view('admin.dashboards.contabilita', compact('statistiche'));
|
|
}
|
|
|
|
/**
|
|
* Dashboard Gestione Economica
|
|
*/
|
|
public function economica()
|
|
{
|
|
$statistiche = [
|
|
'affitti_attivi' => 0, // Da implementare
|
|
'consumi_mese' => 0, // Da implementare
|
|
'rate_incassate' => 0, // Da implementare
|
|
'spese_mensili' => 0, // Da implementare
|
|
];
|
|
|
|
return view('admin.dashboards.economica', compact('statistiche'));
|
|
}
|
|
|
|
/**
|
|
* Dashboard Supporto
|
|
*/
|
|
public function supporto()
|
|
{
|
|
$statistiche = [
|
|
'tickets_aperti' => 3,
|
|
'tickets_urgenti' => 1,
|
|
'tickets_risolti_mese' => 12,
|
|
'tempo_medio_risoluzione' => 2.5, // giorni
|
|
];
|
|
|
|
return view('admin.dashboards.supporto', compact('statistiche'));
|
|
}
|
|
}
|