<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Home::index');
$routes->get('login', 'Login::index');
$routes->post('login/auth', 'Login::auth');
$routes->get('login/logout', 'Login::logout');

$routes->get('dashboard', 'Dashboard::index');

// Master Data
$routes->group('bidang', ['filter' => 'auth'], function($routes) {
    $routes->get('/', 'BidangController::index');
    $routes->get('create', 'BidangController::create');
    $routes->post('store', 'BidangController::store');
    $routes->get('edit/(:num)', 'BidangController::edit/$1');
    $routes->post('update/(:num)', 'BidangController::update/$1');
    $routes->get('delete/(:num)', 'BidangController::delete/$1');
});

$routes->group('opd', ['filter' => 'auth'], function($routes) {
    $routes->get('/', 'OpdController::index');
    $routes->get('create', 'OpdController::create');
    $routes->post('store', 'OpdController::store');
    $routes->get('edit/(:num)', 'OpdController::edit/$1');
    $routes->post('update/(:num)', 'OpdController::update/$1');
    $routes->get('delete/(:num)', 'OpdController::delete/$1');
});

// Super Admin Routes
$routes->group('users', ['filter' => 'auth'], function($routes) {
    $routes->get('/', 'UserController::index');
    $routes->get('create', 'UserController::create');
    $routes->post('store', 'UserController::store');
    $routes->get('edit/(:num)', 'UserController::edit/$1');
    $routes->post('update/(:num)', 'UserController::update/$1');
    $routes->get('delete/(:num)', 'UserController::delete/$1');
});

$routes->group('jadwal', ['filter' => 'auth'], function($routes) {
    $routes->get('/', 'JadwalController::index');
    $routes->get('create', 'JadwalController::create');
    $routes->post('store', 'JadwalController::store');
    $routes->get('delete/(:num)', 'JadwalController::delete/$1');
});

$routes->get('notifikasi/read_all', 'NotifikasiController::readAll');

$routes->group('program', ['filter' => 'auth'], function($routes) {
    $routes->get('/', 'ProgramController::index');
    $routes->get('template', 'ProgramController::downloadTemplate');
    $routes->get('import', 'ProgramController::import');
    $routes->post('import', 'ProgramController::processImport');
});

// Alias typo route to avoid 404 when users type "/programa"
$routes->get('programa', function() {
    return redirect()->to('/program');
});

// Admin Bidang Routes
$routes->group('admin_bidang', ['filter' => 'auth'], function($routes) {
    $routes->get('dashboard', 'AdminBidangController::index');
    $routes->get('verifikasi', 'AdminBidangController::verifikasi');
    $routes->get('detail_verifikasi/(:num)', 'AdminBidangController::detail_verifikasi/$1');
    $routes->post('update_status', 'AdminBidangController::update_status');
    $routes->get('renja', 'AdminBidangController::renja');
    $routes->get('input_progres', 'AdminBidangController::input_progres');
    $routes->get('program_detail/(:num)', 'AdminBidangController::program_detail/$1');
    $routes->get('input_progres/form/(:num)', 'AdminBidangController::input_progres_form/$1');
    $routes->post('input_progres/save', 'AdminBidangController::input_progres_save');
    $routes->post('sub_kegiatan/store', 'AdminBidangController::sub_kegiatan_store');
    $routes->post('program/store', 'AdminBidangController::program_store');
    $routes->post('kegiatan/store', 'AdminBidangController::kegiatan_store');
});

// OPD Routes
$routes->group('opd_kinerja', ['filter' => 'auth'], function($routes) {
    $routes->get('dashboard', 'OpdKinerjaController::index');
    $routes->get('input', 'OpdKinerjaController::input');
    $routes->post('store', 'OpdKinerjaController::store');
    $routes->get('riwayat', 'OpdKinerjaController::riwayat');
});

// Laporan (Super Admin)
$routes->group('laporan', ['filter' => 'auth'], function($routes) {
    $routes->get('progres', 'LaporanController::progres');
    $routes->get('ekspor', 'LaporanController::ekspor');
    $routes->get('ekspor/excel', 'LaporanController::eksporExcel');
    $routes->get('ekspor/preview', 'LaporanController::eksporPreview');
    $routes->get('ekspor/pdf', 'LaporanController::eksporPdf');
});
