<?php

namespace App\Controllers\Admin;

use App\Controllers\BaseController;
use App\Models\UserModel;
use App\Models\PengajuanModel;

class Dashboard extends BaseController
{
    public function index()
    {
        $userModel = new UserModel();
        $pengajuanModel = new PengajuanModel();
        $pegawaiModel = new \App\Models\PegawaiModel();

        $data = [
            'title' => 'Admin Dashboard',
            'stats' => [
                'total_user' => $userModel->countAllResults(),
                'total_pegawai' => $pegawaiModel->countAllResults(),
                'pending' => $pengajuanModel->where('status', 'PENDING')->countAllResults(),
                'verified' => $pengajuanModel->where('status', 'VERIFIED')->countAllResults(),
                'rejected' => $pengajuanModel->where('status', 'REJECTED')->countAllResults(),
                'waiting_sk' => $pengajuanModel->where('status', 'WAITING_SK')->countAllResults(),
                'process_bkn' => $pengajuanModel->where('status', 'PROSES_BKN')->countAllResults(),
                'sk_finish' => $pengajuanModel->where('status', 'SK_FINISH')->countAllResults(),
            ],
            'recent_pengajuan' => $pengajuanModel->getWithPegawai(),
        ];

        return view('admin/dashboard', $data);
    }
}
