<?php
namespace App\Controllers;

use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Shield\Entities\User;
use App\Libraries\GeneralLib;
use App\Libraries\Pluploadhandler;

class Statistik extends BaseController
{
    use ResponseTrait;

    public function distribusi_kabupaten()
    {
        if (!auth()->loggedIn()) {
            return redirect()->to('login');
        }

        $user = auth()->user();
        if (!$user->can('all_pangkalan.access')) {
            return redirect()->to('home');
        }

        $session = session();
        $general_lib = new GeneralLib();
        $userdata = service('user_data');
        
        $NotifikasiModel = model('NotifadminpengajuanpangkalanModel', true, $db);
        $data['notifikasi_pengajuan_pangkalan'] = $NotifikasiModel->get_latest_notifikasi("5","");

        $Notifikasi2Model = model('NotifadminpengajuanperubahanModel', true, $db);
        $data['notifikasi_pengajuan_perubahan'] = $Notifikasi2Model->get_latest_notifikasi("5","");

        $data['error']=$session->getFlashdata('error');
        $data['active_menu'] = 'data_pangkalan';
        $data['user'] = auth()->user();
        $data['user_data'] = $userdata;
        $data['user_foto'] = $general_lib->getProfilePic($data['user']->foto);

        $id_provinsi = "";
        $id_kabupaten = "";

        $db = db_connect();
        $query_kabupaten = $db->query("select * from vkabupaten_stat");
        $stat_kabupaten = $query_kabupaten->getResult();
        $data['stat_kabupaten'] = $stat_kabupaten;

        return view('template/admin/header',$data).view('pages/statistik/distribusi/kabupaten',$data).view('template/admin/footer',$data);
    }
}
?>