<?php
namespace App\Controllers;

use App\Models\KIP;

class MonitoringKIPController
{
    protected $kipModel;
    protected $perPage = 15;

    public function __construct()
    {
        $this->kipModel = new KIP();
    }

    public function index()
    {
        $search = $_GET['search'] ?? '';
        $page   = isset($_GET['page']) ? (int)$_GET['page'] : 1;
        if ($page < 1) $page = 1;

        $totalData = $this->kipModel->countAll($search);
        $totalPages = ceil($totalData / $this->perPage);
        $offset = ($page - 1) * $this->perPage;

        $pendaftar_list = $this->kipModel->getPaginated($search, $offset, $this->perPage);

        require_once __DIR__ . '/../Views/admin/manage_kip.php';
    }
}
