<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Home::index');
$routes->get('/login', 'Shield\LoginController::loginView');
$routes->post('/login', 'Shield\LoginController::loginActionAjax');
$routes->get('/register', 'Shield\RegisterController::registerView');
$routes->post('/register', 'Shield\RegisterController::registerActionAjax');

$routes->cli('dcron/bday/birthday', 'Dcron\Bday::birthday');

$routes->group('account/profile', [
    'namespace' => 'App\Controllers\Account',
    'filter' => 'log',
], static function ($routes) {
    $routes->get('/', 'Profile::index');
    $routes->post('datagrid', 'Profile::datagrid');
    //$routes->post('datagrid_notif', 'Profile::datagrid_notif');
    $routes->post('update', 'Profile::update');
    $routes->post('update_tfa', 'Profile::update_tfa');
    $routes->post('update_avatar', 'Profile::update_avatar');
    $routes->post('update_password', 'Profile::update_password');
});

$routes->addRedirect('admin', 'admin/modul');
$routes->group('admin/modul', [
        'namespace' => 'App\Controllers\Admin',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Modul::index');
    $routes->get('autocomplete', 'Modul::autocomplete');
    $routes->post('datagrid_modul', 'Modul::datagrid_modul');
    $routes->post('datagrid_menu', 'Modul::datagrid_menu');
    $routes->get('show_modul/(:segment)', 'Modul::show_modul/$1');
    $routes->get('show_menu/(:segment)', 'Modul::show_menu/$1');
    $routes->get('new_modul', 'Modul::new_modul');
    $routes->get('new_menu', 'Modul::new_menu');
    $routes->post('create_modul', 'Modul::create_modul');
    $routes->post('create_menu', 'Modul::create_menu');
    $routes->get('edit_modul/(:segment)', 'Modul::edit_modul/$1');
    $routes->get('edit_menu/(:segment)', 'Modul::edit_menu/$1');
    $routes->post('update_modul', 'Modul::update_modul');
    $routes->post('update_menu', 'Modul::update_menu');
    $routes->post('delete_modul', 'Modul::delete_modul');
    $routes->post('delete_menu', 'Modul::delete_menu');
    $routes->post('get_parent', 'Modul::get_parent');
});

$routes->group('admin/rolegroup', [
        'namespace' => 'App\Controllers\Admin',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Rolegroup::index');
    $routes->post('datagrid_rg', 'Rolegroup::datagrid_rg');
    $routes->post('datagrid_rm', 'Rolegroup::datagrid_rm');
    $routes->post('create_rg', 'Rolegroup::create_rg');
    $routes->post('update_rg', 'Rolegroup::update_rg');
    $routes->get('add_rm', 'Rolegroup::add_rm');
    $routes->post('create_rm', 'Rolegroup::create_rm');
    $routes->post('get_related_menu2', 'Rolegroup::get_related_menu2');
    $routes->post('update_rm', 'Rolegroup::update_rm');
    $routes->post('delete_rg', 'Rolegroup::delete_rg');
    $routes->post('delete_rm', 'Rolegroup::delete_rm');
    $routes->post('get_related_menu', 'Rolegroup::get_related_menu');
});

$routes->group('admin/user_setting', [
    'namespace' => 'App\Controllers\Admin',
    'filter' => 'autho',
], static function ($routes) {
    $routes->get('/', 'UserSetting::index');
    $routes->post('datagrid', 'UserSetting::datagrid');
    $routes->post('get_avatar', 'UserSetting::get_avatar');
    $routes->get('new_user', 'UserSetting::new_user');
    $routes->post('create', 'UserSetting::create');
    $routes->get('edit_user/(:segment)', 'UserSetting::edit_user/$1');
    $routes->post('update', 'UserSetting::update');
    $routes->post('delete', 'UserSetting::delete');
    $routes->get('excel/(:segment)/(:num)', 'UserSetting::excel/$1/$2');
    $routes->post('activate', 'UserSetting::activate');
    $routes->post('deactivate', 'UserSetting::deactivate');
    $routes->post('ban', 'UserSetting::ban');
    $routes->post('unban', 'UserSetting::unban');
});

$routes->group('admin/user_priv', [
        'namespace' => 'App\Controllers\Admin',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'UserPriv::index');
    $routes->post('datagrid_user', 'UserPriv::datagrid_user');
    $routes->post('datagrid_am', 'UserPriv::datagrid_am');
    $routes->post('get_modul', 'UserPriv::get_modul');
    $routes->post('get_role', 'UserPriv::get_role');
    $routes->post('create', 'UserPriv::create');
    $routes->post('update', 'UserPriv::update');
    $routes->post('delete', 'UserPriv::delete');
});

/*ROUTES DASHBOARD -------------------------------------*/
$routes->addRedirect('dashboard', 'dashboard/lokasikantor');
$routes->group('dashboard/lokasikantor', [
        'namespace' => 'App\Controllers\Dashboard',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Lokasikantor::index');
    $routes->get('getPusatWilayah', 'Lokasikantor::getPusatWilayah');
    $routes->get('getWilayahWithArea/(:num)', 'Lokasikantor::getWilayahWithArea/$1');
    $routes->get('getAreaWithCabang/(:num)', 'Lokasikantor::getAreaWithCabang/$1');
    $routes->get('getKantorDetail/(:num)', 'Lokasikantor::getKantorDetail/$1');
});

$routes->group('dashboard/pusat', [
        'namespace' => 'App\Controllers\Dashboard',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pusat::index');
    $routes->post('setTahun', 'Pusat::setTahun');
    $routes->post('sync', 'Pusat::sync');
    $routes->get('drill-down-wilayah/(:segment)', 'Pusat::drillDownWilayah/$1');
});

$routes->group('dashboard/wilayah', [
        'namespace' => 'App\Controllers\Dashboard',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Wilayah::index');
    $routes->post('setTahun', 'Wilayah::setTahun');
    $routes->post('sync', 'Wilayah::sync');
    $routes->get('drill-down-area/(:segment)', 'Wilayah::drillDownArea/$1');
});

$routes->group('dashboard/area', [
        'namespace' => 'App\Controllers\Dashboard',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Area::index');
    $routes->post('setTahun', 'Area::setTahun');
    $routes->post('sync', 'Area::sync');
    $routes->get('hmap', 'Area::hmap');
    $routes->get('detail-cabang/(:segment)', 'Area::detailCabang/$1');
});

$routes->group('dashboard/cabang', [
        'namespace' => 'App\Controllers\Dashboard',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Cabang::index');
    $routes->post('setTahun', 'Cabang::setTahun');
    $routes->get('hmap', 'Cabang::hmap');
});
/*END ROUTES DASHBOARD---------------------------------*/


/*ROUTES LIBSS -------------------------------------*/
$routes->addRedirect('libskill', 'libskill/libdata');
$routes->group('libskill/libdata', [
        'namespace' => 'App\Controllers\Libskill',
    ], static function ($routes) {
    $routes->get('/', 'Libdata::index');
    $routes->get('rekam', 'Libdata::rekam');
    $routes->post('rekam_act', 'Libdata::rekam_act');
    $routes->get('edit/(:segment)', 'Libdata::edit/$1');
    $routes->post('edit_act', 'Libdata::edit_act');
    $routes->post('hapus', 'Libdata::hapus');
});

$routes->addRedirect('cusen', 'cusen/kirim_pesan');
$routes->group('cusen/kirim_pesan', [
        'namespace' => 'App\Controllers\Cusen',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'KirimPesan::index');
    $routes->post('datagrid', 'KirimPesan::datagrid');
    $routes->post('send_wa', 'KirimPesan::send_wa');
});

$routes->group('cusen/browse_pesan', [
        'namespace' => 'App\Controllers\Cusen',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'BrowsePesan::index');
    $routes->post('datagrid_pesan', 'BrowsePesan::datagrid_pesan');
    $routes->post('datagrid_rcv', 'BrowsePesan::datagrid_rcv');
    $routes->post('show/(:segment)', 'BrowsePesan::show/$1');
    $routes->post('delete_pesan', 'BrowsePesan::delete_pesan');
});

/*ROUTES MODUL REFERENSI ---------*/
$routes->addRedirect('referensi', 'referensi/pdkunit');
$routes->group('referensi/pdkunit', [
        'namespace' => 'App\Controllers\Referensi',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pdkunit::index');
    $routes->get('manualx', 'Pdkunit::manualx');
    $routes->post('datagrid', 'Pdkunit::datagrid');
    $routes->get('show/(:segment)', 'Pdkunit::show/$1');
    $routes->get('new', 'Pdkunit::new');
    $routes->post('create', 'Pdkunit::create');
    $routes->get('edit/(:segment)', 'Pdkunit::edit/$1');
    $routes->post('update', 'Pdkunit::update');
    $routes->post('delete', 'Pdkunit::delete');
});

$routes->group('referensi/pdkjabatan', [
        'namespace' => 'App\Controllers\Referensi',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pdkjabatan::index');
    $routes->get('manualx', 'Pdkjabatan::manualx');
    $routes->post('datagrid', 'Pdkjabatan::datagrid');
    $routes->get('show/(:segment)', 'Pdkjabatan::show/$1');
    $routes->get('new', 'Pdkjabatan::new');
    $routes->post('create', 'Pdkjabatan::create');
    $routes->get('edit/(:segment)', 'Pdkjabatan::edit/$1');
    $routes->post('update', 'Pdkjabatan::update');
    $routes->post('delete', 'Pdkjabatan::delete');
});

$routes->group('referensi/pdksatker', [
        'namespace' => 'App\Controllers\Referensi',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pdksatker::index');
    $routes->get('manualx', 'Pdksatker::manualx');
    $routes->post('datagrid', 'Pdksatker::datagrid');
    $routes->get('show/(:segment)', 'Pdksatker::show/$1');
    $routes->get('new', 'Pdksatker::new');
    $routes->post('create', 'Pdksatker::create');
    $routes->get('edit/(:segment)', 'Pdksatker::edit/$1');
    $routes->post('update', 'Pdksatker::update');
    $routes->post('delete', 'Pdksatker::delete');
    $routes->post('get_prov', 'Pdksatker::get_prov');
    $routes->post('get_wilayah', 'Pdksatker::get_wilayah');
    $routes->post('get_area', 'Pdksatker::get_area');
});

$routes->group('referensi/pdkprov', [
        'namespace' => 'App\Controllers\Referensi',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pdkprov::index');
    $routes->post('datagrid_prov', 'Pdkprov::datagrid_prov');
    $routes->post('datagrid_kako', 'Pdkprov::datagrid_kako');
    $routes->get('show_prov/(:segment)', 'Pdkprov::show_prov/$1');
    $routes->get('show_kako/(:segment)', 'Pdkprov::show_kako/$1');
    $routes->get('new_prov', 'Pdkprov::new_prov');
    $routes->get('new_kako', 'Pdkprov::new_kako');
    $routes->post('create_prov', 'Pdkprov::create_prov');
    $routes->post('create_kako', 'Pdkprov::create_kako');
    $routes->get('edit_prov/(:segment)', 'Pdkprov::edit_prov/$1');
    $routes->get('edit_kako/(:segment)', 'Pdkprov::edit_kako/$1');
    $routes->post('update_prov', 'Pdkprov::update_prov');
    $routes->post('update_kako', 'Pdkprov::update_kako');
    $routes->post('delete_prov', 'Pdkprov::delete_prov');
    $routes->post('delete_kako', 'Pdkprov::delete_kako');
});

$routes->group('referensi/pdkpromo', [
        'namespace' => 'App\Controllers\Referensi',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pdkpromo::index');
    $routes->get('manualx', 'Pdkpromo::manualx');
    $routes->post('datagrid', 'Pdkpromo::datagrid');
    $routes->get('show/(:segment)', 'Pdkpromo::show/$1');
    $routes->get('new', 'Pdkpromo::new');
    $routes->post('create', 'Pdkpromo::create');
    $routes->get('edit/(:segment)', 'Pdkpromo::edit/$1');
    $routes->post('update', 'Pdkpromo::update');
    $routes->post('delete', 'Pdkpromo::delete');
});

$routes->group('referensi/pdklayanan', [
        'namespace' => 'App\Controllers\Referensi',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Pdklayanan::index');
    $routes->post('datagrid_mlay', 'Pdklayanan::datagrid_mlay');
    $routes->post('datagrid_clay', 'Pdklayanan::datagrid_clay');
    $routes->get('show_mlay/(:segment)', 'Pdklayanan::show_mlay/$1');
    $routes->get('show_clay/(:segment)', 'Pdklayanan::show_clay/$1');
    $routes->get('view_pdf/(:segment)', 'Pdklayanan::view_pdf/$1');
    $routes->get('new_mlay', 'Pdklayanan::new_mlay');
    $routes->get('new_clay', 'Pdklayanan::new_clay');
    $routes->post('create_mlay', 'Pdklayanan::create_mlay');
    $routes->post('create_clay', 'Pdklayanan::create_clay');
    $routes->get('edit_mlay/(:segment)', 'Pdklayanan::edit_mlay/$1');
    $routes->get('edit_clay/(:segment)', 'Pdklayanan::edit_clay/$1');
    $routes->post('update_mlay', 'Pdklayanan::update_mlay');
    $routes->post('update_clay', 'Pdklayanan::update_clay');
    $routes->post('delete_mlay', 'Pdklayanan::delete_mlay');
    $routes->post('delete_clay', 'Pdklayanan::delete_clay');
});
/*END ROUTES MODUL REFERENSI ---- */

/*ROUTES MODUL POTENSI WILAYAH ---------*/
$routes->addRedirect('potensiwilayah', 'potensiwilayah/kelolalokasi');
$routes->group('potensiwilayah/kelolalokasi', [
        'namespace' => 'App\Controllers\Potensiwilayah',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Kelolalokasi::index');
    $routes->post('saveLokasi', 'Kelolalokasi::saveLokasi');
});

$routes->group('potensiwilayah/datapromosi', [
        'namespace' => 'App\Controllers\Potensiwilayah',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Datapromosi::index');
    $routes->post('datagrid', 'Datapromosi::datagrid');
    $routes->get('show/(:segment)', 'Datapromosi::show/$1');
    $routes->get('new', 'Datapromosi::new');
    $routes->post('create', 'Datapromosi::create');
    $routes->get('edit/(:segment)', 'Datapromosi::edit/$1');
    $routes->post('update', 'Datapromosi::update');
    $routes->post('delete', 'Datapromosi::delete');
    $routes->post('get_lokasi', 'Datapromosi::get_lokasi');
    $routes->post('get_lokasi_detail', 'Datapromosi::get_lokasi_detail');
});

$routes->group('potensiwilayah/calonasabah', [
        'namespace' => 'App\Controllers\Potensiwilayah',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Calonasabah::index');
    $routes->post('datagrid', 'Calonasabah::datagrid');
    $routes->get('show/(:segment)', 'Calonasabah::show/$1');
    $routes->get('new', 'Calonasabah::new');
    $routes->post('create', 'Calonasabah::create');
    $routes->get('edit/(:segment)', 'Calonasabah::edit/$1');
    $routes->post('update', 'Calonasabah::update');
    $routes->post('delete', 'Calonasabah::delete');
    $routes->post('get_lokasi', 'Calonasabah::get_lokasi');
    $routes->post('get_kegiatan_detail', 'Calonasabah::get_kegiatan_detail');
    $routes->get('closing/(:segment)', 'Calonasabah::closing/$1');
    $routes->post('proses_closing', 'Calonasabah::proses_closing');
});

$routes->group('potensiwilayah/datanasabah', [
        'namespace' => 'App\Controllers\Potensiwilayah',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Datanasabah::index');
    $routes->post('datagrid', 'Datanasabah::datagrid');
    $routes->get('show/(:segment)', 'Datanasabah::show/$1');
    $routes->get('edit/(:segment)', 'Datanasabah::edit/$1');
    $routes->post('update', 'Datanasabah::update');
    $routes->post('delete', 'Datanasabah::delete');
});
/*END ROUTES MODUL POTENSI WILAYAH ---------*/

/*ROUTES MODUL PESAING ---------*/
$routes->addRedirect('pesaing', 'pesaing/kuralokasi');
$routes->group('pesaing/kuralokasi', [
        'namespace' => 'App\Controllers\Pesaing',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Kuralokasi::index');
    $routes->post('saveLokasi', 'Kuralokasi::saveLokasi');
});

$routes->group('pesaing/datapesaing', [
        'namespace' => 'App\Controllers\Pesaing',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Datapesaing::index');
    $routes->post('datagrid', 'Datapesaing::datagrid');
    $routes->get('show/(:segment)', 'Datapesaing::show/$1');
    $routes->post('delete', 'Datapesaing::delete');
});

$routes->group('pesaing/dataswot', [
        'namespace' => 'App\Controllers\Pesaing',
        'filter' => 'autho',
    ], static function ($routes) {
    $routes->get('/', 'Dataswot::index');
    $routes->post('datagrid', 'Dataswot::datagrid');
    $routes->get('show/(:segment)', 'Dataswot::show/$1');
    $routes->get('new', 'Dataswot::new');
    $routes->post('create', 'Dataswot::create');
    $routes->get('edit/(:segment)', 'Dataswot::edit/$1');
    $routes->post('update', 'Dataswot::update');
    $routes->post('delete', 'Dataswot::delete');
    $routes->post('get_pesaing_detail', 'Dataswot::get_pesaing_detail');
});
/*END ROUTES MODUL PESAING ---------*/

$routes->set404Override(function()
{
    //echo view('errors/html/production.php');
    echo view('errors/error.php');
});

service('auth')->routes($routes);