<?php

use CodeIgniter\Router\RouteCollection;

/** @var RouteCollection $routes */
$routes->get('/', 'Home::index');

// Routes Login & Auth
$routes->get('/login', 'Auth::index');
$routes->post('/auth/loginSubmit', 'Auth::loginSubmit');
$routes->get('/logout', 'Auth::logout');

// Routes Data Master
$routes->get('/fakultas', 'Fakultas::index');
$routes->get('/fakultas/create', 'Fakultas::create');
$routes->post('/fakultas/store', 'Fakultas::store');
$routes->get('/fakultas/edit/(:num)', 'Fakultas::edit/$1');
$routes->post('/fakultas/update/(:num)', 'Fakultas::update/$1');
$routes->get('/fakultas/delete/(:num)', 'Fakultas::delete/$1'); // using HTTP DELETE if possible or POST
$routes->post('/fakultas/delete/(:num)', 'Fakultas::delete/$1'); // fallback post

$routes->get('/prodi', 'Prodi::index');
$routes->get('/prodi/sync-pddikti', 'Prodi::syncPddikti');
$routes->get('/prodi/create', 'Prodi::create');
$routes->post('/prodi/store', 'Prodi::store');
$routes->get('/prodi/edit/(:num)', 'Prodi::edit/$1');
$routes->post('/prodi/update/(:num)', 'Prodi::update/$1');
$routes->delete('/prodi/delete/(:num)', 'Prodi::delete/$1');
$routes->post('/prodi/delete/(:num)', 'Prodi::delete/$1');

// Routes Tahun Akademik
$routes->get('/kurikulum', 'Kurikulum::index');
$routes->get('/kurikulum/sync', 'Kurikulum::sync');
$routes->get('/pemetaan-kurikulum', 'PemetaanKurikulum::index');
$routes->post('/pemetaan-kurikulum/simpan', 'PemetaanKurikulum::simpan');
$routes->post('/pemetaan-kurikulum/hapus/(:num)', 'PemetaanKurikulum::hapus/$1');
$routes->get('/mata-kuliah', 'MataKuliah::index');
$routes->get('/mata-kuliah/sync', 'MataKuliah::sync');
$routes->get('/kelas-perkuliahan', 'KelasPerkuliahan::index');
$routes->get('/kelas-perkuliahan/sync', 'KelasPerkuliahan::sync');
$routes->get('/kelas-perkuliahan/create', 'KelasPerkuliahan::create');
$routes->post('/kelas-perkuliahan/store', 'KelasPerkuliahan::store');
$routes->get('/kelas-perkuliahan/edit/(:any)', 'KelasPerkuliahan::edit/$1');
$routes->post('/kelas-perkuliahan/update/(:any)', 'KelasPerkuliahan::update/$1');
$routes->get('/kelas-perkuliahan/delete/(:any)', 'KelasPerkuliahan::delete/$1');
$routes->get('/kelas-perkuliahan/get-matkul', 'KelasPerkuliahan::getMatkulByProdi');
$routes->get('/kelas-perkuliahan/dosen/(:any)', 'KelasPerkuliahan::dosen/$1');
$routes->post('/kelas-perkuliahan/dosen/add', 'KelasPerkuliahan::addDosen');
$routes->get('/kelas-perkuliahan/dosen/delete/(:num)', 'KelasPerkuliahan::deleteDosen/$1');
$routes->get('/kelas-perkuliahan/peserta/(:any)', 'KelasPerkuliahan::peserta/$1');
$routes->post('/kelas-perkuliahan/peserta/add', 'KelasPerkuliahan::addPeserta');
$routes->get('/kelas-perkuliahan/peserta/delete/(:num)', 'KelasPerkuliahan::deletePeserta/$1');
$routes->get('/tahun-akademik', 'TahunAkademik::index');
$routes->get('/tahun-akademik/sync-pddikti', 'TahunAkademik::syncPddikti');
$routes->post('/tahun-akademik/set-aktif', 'TahunAkademik::setAktif');
$routes->get('/tahun-akademik/debug-pddikti', 'TahunAkademik::debugPddikti');
$routes->get('/tahun-akademik/create', 'TahunAkademik::create');
$routes->post('/tahun-akademik/store', 'TahunAkademik::store');
$routes->get('/tahun-akademik/edit/(:num)', 'TahunAkademik::edit/$1');
$routes->post('/tahun-akademik/update/(:num)', 'TahunAkademik::update/$1');
$routes->delete('/tahun-akademik/delete/(:num)', 'TahunAkademik::delete/$1');

// Routes Dosen
$routes->get('/dosen', 'Dosen::index');
$routes->get('/dosen/sync-pddikti', 'Dosen::syncPddikti');
$routes->get('/dosen/create', 'Dosen::create');
$routes->post('/dosen/store', 'Dosen::store');
$routes->get('/dosen/edit/(:num)', 'Dosen::edit/$1');
$routes->post('/dosen/update/(:num)', 'Dosen::update/$1');
$routes->get('/dosen/delete/(:num)', 'Dosen::delete/$1');

// Routes Penugasan Dosen
$routes->get('/penugasan-dosen', 'PenugasanDosen::index');
$routes->get('/penugasan-dosen/sync', 'PenugasanDosen::syncPddikti');

// Routes Mahasiswa
$routes->group('mahasiswa', function ($routes) {
    $routes->get('migrate-db', 'Mahasiswa::migrateDb');
    $routes->get('', 'Mahasiswa::index');
    $routes->get('create', 'Mahasiswa::create');
    $routes->get('searchWilayah', 'Mahasiswa::searchWilayah');
    $routes->get('searchPT', 'Mahasiswa::searchPT');
    $routes->get('searchProdi', 'Mahasiswa::searchProdi');
    $routes->get('syncWilayah', 'Mahasiswa::syncWilayah');
    $routes->get('syncPT', 'Mahasiswa::syncPT');
    $routes->post('store', 'Mahasiswa::store');
    $routes->get('edit/(:num)', 'Mahasiswa::edit/$1');
    $routes->post('update/(:num)', 'Mahasiswa::update/$1');
    $routes->get('sync', 'Mahasiswa::syncPddikti');
    $routes->get('show/(:num)', 'Mahasiswa::show/$1');
    $routes->get('getBatchStudents', 'Mahasiswa::getBatchStudents');
    $routes->post('syncBiodataBatch', 'Mahasiswa::syncBiodataBatch');
});

$routes->post('/tahun-akademik/delete/(:num)', 'TahunAkademik::delete/$1');

// Routes Pengaturan PDDIKTI
$routes->get('/pddikti/setting', 'Pddikti::setting');
$routes->post('/pddikti/saveSetting', 'Pddikti::saveSetting');
$routes->get('/pddikti/testConnection', 'Pddikti::testConnection');

// Routes KRS (Mahasiswa)
$routes->group('krs', function ($routes) {
    $routes->get('/', 'Krs::index');
    $routes->get('pilih-kelas', 'Krs::pilih_kelas');
    $routes->post('simpan', 'Krs::simpan');
    $routes->post('ajukan', 'Krs::ajukan');
    $routes->get('hapus-kelas/(:num)', 'Krs::hapus_kelas/$1');
});

// Routes Persetujuan KRS (Dosen PA)
$routes->group('persetujuan-krs', function ($routes) {
    $routes->get('/', 'PersetujuanKrs::index');
    $routes->get('detail/(:num)', 'PersetujuanKrs::detail/$1');
    $routes->post('proses/(:num)', 'PersetujuanKrs::proses/$1');
});
