<?php

namespace Config;

// Create a new instance of our RouteCollection class.
$routes = Services::routes();

/*
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
// $routes->setAutoRoute(false);

/*
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'User::index');

$routes->group('user', static function($routes) {
    $routes->get('add', 'User::add_form', ['filter' => 'admin']);
    $routes->get('remove/(:num)', 'User::remove/$1', ['filter' => 'admin']);
    $routes->post('save', 'User::save', ['filter' => 'admin']);
    $routes->get('list', 'User::list', ['filter' => 'admin']);
    $routes->get('login', 'User::login_form', ['filter' => 'login']);
    $routes->get('dashboard', 'User::dashboard', ['filter' => 'auth']);
    $routes->get('logout', 'User::logout');
    $routes->post('login/auth', 'User::login_auth');
});

$routes->group('pub/guest', static function($routes) {
    $routes->get('add', 'Guest::pub_add_guest_form');
    $routes->get('thankyou', 'Guest::pub_thankyou');
});


$routes->group('guest', static function($routes) {
    $routes->get('replace/(:num)/(:num)', 'Guest::add_guest_form/null/$1/$2', ['filter' => 'auth']);
});

$routes->post('/guest-save', 'Guest::save');
$routes->get('/add-guest', 'Guest::add_guest_form', ['filter' => 'auth']);
$routes->get('/edit-guest/(:num)', 'Guest::add_guest_form/$1', ['filter' => 'auth']);
$routes->get('/remove-guest/(:num)', 'Guest::remove_guest/$1', ['filter' => 'auth']);
$routes->get('/check-in/(:num)', 'Guest::check_in/$1', ['filter' => 'auth']);
$routes->get('/guests-list', 'Guest::guests_list', ['filter' => 'auth']);
$routes->post('/guests-list', 'Guest::guests_list', ['filter' => 'auth']);
$routes->get('/reports', 'Guest::reports_form', ['filter' => 'auth']);
$routes->post('/generate-report', 'Guest::generate_report', ['filter' => 'auth']);
$routes->get('/bulk-upload', 'Guest::bulk_upload', ['filter' => 'auth']);
$routes->post('/perform-bulk-upload', 'Guest::perform_bulk_upload', ['filter' => 'auth']);



$routes->get('/seating-plan/(:num)', 'Plans::seating_plan/$1', ['filter' => 'auth']);
$routes->get('/seating-plan/list/(:num)', 'Plans::plan_list/seating/$1', ['filter' => 'auth']);
$routes->get('/set-seating-plan/(:num)', 'Plans::set_seating_plan/$1', ['filter' => 'auth']);
$routes->get('/download-seating-plan', 'Plans::download_plan/seating', ['filter' => 'auth']);
$routes->get('/download-stage-plan', 'Plans::download_plan/stage', ['filter' => 'auth']);
$routes->post('/assign-seating/(:any)', 'Plans::assign_seating/$1', ['filter' => 'auth']);
$routes->get('/remove-seating/(:any)/(:num)/(:num)', 'Plans::remove_seating/$1/$2/$3', ['filter' => 'auth']);
$routes->post('/save-seating-plan', 'Plans::save_seating_plan', ['filter' => 'auth']);

$routes->get('/stage/(:num)', 'Plans::stage/$1', ['filter' => 'auth']);
$routes->get('/stage/list/(:num)', 'Plans::plan_list/stage/$1', ['filter' => 'auth']);
$routes->get('/set-stage/(:num)', 'Plans::set_stage/$1', ['filter' => 'auth']);
$routes->post('/assign-stage/(:any)', 'Plans::assign_stage/$1', ['filter' => 'auth']);
$routes->get('/remove-stage/(:any)/(:num)/(:num)', 'Plans::remove_stage/$1/$2/$3', ['filter' => 'auth']);
$routes->post('/save-stage-setup', 'Plans::save_stage_setup', ['filter' => 'auth']);

$routes->group('session', static function($routes) {
    $routes->add('add', 'Sessions::add_form', ['filter' => 'admin']);
    $routes->add('list', 'Sessions::list', ['filter' => 'auth']);
    $routes->add('save', 'Sessions::save', ['filter' => 'admin']);
    $routes->add('edit/(:num)', 'Sessions::add_form/$1', ['filter' => 'admin']);
    $routes->add('remove/(:num)', 'Sessions::remove/$1', ['filter' => 'admin']);

    $routes->add('checkin/(:num)', 'Checkin::list/$1', ['filter' => 'auth']);
    $routes->add('checkin/invite/(:num)/(:num)', 'Checkin::invite/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/checkin/(:num)/(:num)', 'Checkin::checkin/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/checkinajax/(:num)/(:num)', 'Checkin::checkinajax/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/checkoutajax/(:num)/(:num)', 'Checkin::checkoutajax/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/checkinspot/(:num)/(:num)', 'Checkin::checkin_spot/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/remove/(:num)/(:num)', 'Checkin::remove/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/editstatus/(:num)/(:num)/(:num)', 'Checkin::editstatus/$1/$2/$3', ['filter' => 'auth']);
    $routes->add('checkin/accept/(:any)/(:any)', 'Checkin::accept/$1/$2');
    $routes->add('checkin/reject/(:any)/(:any)', 'Checkin::reject/$1/$2');
    $routes->add('checkin/inviteall/(:num)', 'Checkin::inviteall/$1', ['filter' => 'auth']);
    $routes->add('checkin/inviteselect/(:num)/(:any)', 'Checkin::inviteselect/$1/$2', ['filter' => 'auth']);
    $routes->add('checkin/acceptall/(:any)', 'Checkin::acceptall/$1', ['filter' => 'auth']);
    $routes->add('checkin/qr/download/(:num)', 'Checkin::qr_download/$1', ['filter' => 'auth']);
    $routes->add('checkin/spot/(:num)', 'Checkin::spot/$1', ['filter' => 'auth']);
});

$routes->group('group', static function($routes) {

    $routes->add('add', 'Groups::add_form', ['filter' => 'auth']);
    $routes->add('list', 'Groups::list', ['filter' => 'auth']);
    $routes->add('save', 'Groups::save', ['filter' => 'auth']);
    $routes->add('edit/(:num)', 'Groups::add_form/$1', ['filter' => 'auth']);
    $routes->add('remove/(:num)', 'Groups::remove/$1', ['filter' => 'auth']);
    
});

$routes->add('debug/(:any)', 'Debug::dry_run/$1', ['filter' => 'auth']);
$routes->add('debug', 'Debug::dry_run', ['filter' => 'auth']);
/*
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
    require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
