<?php

use CodeIgniter\Router\RouteCollection;

/** @var RouteCollection $routes */
// --- JALUR TERBUKA (TIDAK DIKUNCI) ---
$routes->get('/login', 'Auth::index');
$routes->post('/login/proses', 'Auth::proses_login');
$routes->get('/logout', 'Auth::logout');


// --- JALUR TERTUTUP (DIKUNCI OLEH FILTER 'auth') ---
$routes->group('', ['filter' => 'auth'], function($routes) {
    
    // Halaman Utama / Dashboard
    $routes->get('/', 'Home::index');

    // Modul Arsip Dokumen
    $routes->get('/arsip', 'Arsip::index');
    $routes->get('/arsip/tambah', 'Arsip::tambah');
    $routes->post('/arsip/simpan', 'Arsip::simpan');
    $routes->get('/arsip/download/(:num)', 'Arsip::download/$1');
    $routes->get('/arsip/hapus/(:num)', 'Arsip::hapus/$1');
    // --- Tambahan Baru untuk Edit Arsip ---
    $routes->get('/arsip/edit/(:num)', 'Arsip::edit/$1');
    $routes->post('/arsip/update/(:num)', 'Arsip::update/$1');

    // Modul Pegawai
    $routes->get('/pegawai', 'Pegawai::index');
    $routes->get('/pegawai/tambah', 'Pegawai::tambah');
    $routes->post('/pegawai/simpan', 'Pegawai::simpan');
    $routes->get('/pegawai/hapus/(:num)', 'Pegawai::hapus/$1');
    // --- Tambahan Baru untuk Edit Pegawai ---
    $routes->get('/pegawai/edit/(:num)', 'Pegawai::edit/$1');
    $routes->post('/pegawai/update/(:num)', 'Pegawai::update/$1');

    // Modul Pegawai
    $routes->get('/pegawai', 'Pegawai::index');
    $routes->get('/pegawai/tambah', 'Pegawai::tambah');
    $routes->post('/pegawai/simpan', 'Pegawai::simpan');
    $routes->get('/pegawai/hapus/(:num)', 'Pegawai::hapus/$1');

    // Modul Peta Spasial
    $routes->get('/peta', 'Peta::index');
    $routes->get('/peta/kelola', 'Peta::kelola');
    $routes->get('/peta/form', 'Peta::form');
    $routes->get('/peta/form/(:num)', 'Peta::form/$1');
    $routes->post('/peta/simpan', 'Peta::simpan');
    $routes->get('/peta/hapus/(:num)', 'Peta::hapus/$1');

    // Modul Patroli Lapangan
    $routes->get('/patroli', 'Patroli::index');
    $routes->post('/patroli/simpan_ajax', 'Patroli::simpan_ajax');
    // --- Tambahan rute untuk melihat rekap laporan ---
    $routes->get('/patroli/data', 'Patroli::data_laporan');

    // Modul Manajemen Akun (Hanya Admin)
    $routes->get('/akun', 'Akun::index');
    $routes->get('/akun/tambah', 'Akun::tambah');
    $routes->post('/akun/simpan', 'Akun::simpan');
    $routes->get('/akun/edit/(:num)', 'Akun::edit/$1');
    $routes->post('/akun/update/(:num)', 'Akun::update/$1');
    $routes->get('/akun/hapus/(:num)', 'Akun::hapus/$1');

});