<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Web::index');
$routes->get('info', 'Web::info');
$routes->post('siswalogin', 'Web::siswalogin');
$routes->get('logout', 'Web::siswalogout');
$routes->group('home', ['filter' => 'role:admin'], function ($routes) {
    $routes->get('/', 'Home::home');
    $routes->get('getlog', 'Home::getlog');
});
$routes->group('siswa', ['filter' => 'role:admin'], function ($routes) {
    $routes->get('/', 'Siswa::index');
    $routes->get('qrcode', 'Siswa::generateQrCode');
    $routes->get('getdata', 'Siswa::getData');
    $routes->get('getsiswa', 'Siswa::getSiswa');
    $routes->get('getsiswarombel/(:num)', 'Siswa::getSiswaRombel/$1');
    $routes->get('getrombel', 'Siswa::getRombel');
    $routes->get('getrombelpeminatan', 'Siswa::getrombelPeminatan');
    $routes->get('edit/(:num)', 'Siswa::edit/$1');
    $routes->post('add', 'Siswa::add');
    $routes->post('update', 'Siswa::update');
    $routes->delete('delete/(:num)', 'Siswa::delete/$1');
    $routes->post('import', 'Siswa::importViaAjax');
    $routes->post('uploadfoto', 'Siswa::uploadFoto');
    $routes->get('detail/(:num)', 'Siswa::indexProfil/$1');
    $routes->post('updateprofil', 'Siswa::updateprofil');
});
$routes->group('auth', function ($routes) {
    $routes->get('login', 'Auth::login');
    $routes->get('register', 'Auth::register');
    $routes->get('logout', 'Auth::logout');
    $routes->post('dologin', 'Auth::dologin');
});
$routes->group('matapelajaran', ['filter' => 'role:admin'], function ($routes) {
    $routes->get('/', 'MataPelajaran::index');
    $routes->get('getdata', 'MataPelajaran::getData');
    $routes->get('edit/(:num)', 'MataPelajaran::edit/$1');
    $routes->post('add', 'MataPelajaran::add');
    $routes->post('update', 'MataPelajaran::update');
    $routes->delete('delete/(:num)', 'MataPelajaran::delete/$1');
    $routes->post('import', 'Matapelajaran::import');
});
$routes->group('user', ['filter' => 'role:admin'], function ($routes) {
    $routes->get('/', 'User::index',);
    $routes->get('getUsers', 'User::getUsers');
    $routes->get('edit/(:num)', 'User::edit/$1');
    $routes->post('add', 'User::add');
    $routes->post('update', 'User::update');
    $routes->post('updateprofil', 'User::updateprofil');
    $routes->delete('delete/(:num)', 'User::delete/$1');
    $routes->post('import', 'User::importViaAjax');
});

$routes->group('pengumuman', ['filter' => 'role:admin'], function ($routes) {
    $routes->get('/', 'Pengumuman::index',);
    $routes->get('getdata', 'Pengumuman::getData');
    $routes->get('edit/(:num)', 'Pengumuman::edit/$1');
    $routes->post('add', 'Pengumuman::add');
    $routes->post('update', 'Pengumuman::update');
    $routes->delete('delete/(:num)', 'Pengumuman::delete/$1');
});

$routes->group('penilaian', ['filter' => 'role:admin'], function ($routes) {
    $routes->get('/', 'Penilaian::index',);
    $routes->get('getdata', 'Penilaian::getData');
    $routes->get('edit/(:num)', 'Penilaian::edit/$1');
    $routes->post('add', 'Penilaian::add');
    $routes->post('update', 'Penilaian::update');
    $routes->delete('delete/(:num)', 'Penilaian::delete/$1');
    $routes->post('import', 'Penilaian::import');
});

$routes->group('pengaturan', ['filter' => 'role:admin'], function ($routes) {
    $routes->group('sekolah', function ($routes) {
        $routes->get('/', 'Settings::index');
        $routes->get('getdata', 'Settings::getData');
        $routes->post('update', 'Settings::update');
        $routes->post('hapusdata', 'Settings::hapusdata');
    });
    $routes->group('patch', function ($routes) {
        $routes->get('/', 'PatchApp::index');
        $routes->post('update', 'PatchApp::update');
    });
});

$routes->group('kelulusan', ['filter' => 'role:admin'], function ($routes) {
    $routes->group('template', function ($routes) {
        $routes->get('/', 'Kelulusan::indexTemplate');
        $routes->get('getdata', 'Kelulusan::getDataTemplate');
        $routes->post('update', 'Kelulusan::updateTemplate');
    });
    $routes->get('/', 'Kelulusan::index');
    $routes->get('print/(:any)', 'Kelulusan::printSKL/$1');
});
