<?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('/', 'Admin\Login::index');  // to load index page dynamically

$routes->post('admin/authenticate', 'Admin\Login::authenticate'); // to authenticate users/admins
$routes->get('home', 'Admin\Home::index'); // to redirect to home
$routes->get('employees','Admin\Users::index'); // to load users page 
$routes->get('users', 'Admin\Users::index');
$routes->post('users/store', 'Admin\Users::store');
$routes->get('users/edit/(:num)', 'Admin\Users::edit/$1');
$routes->post('users/update/(:num)', 'Admin\Users::update/$1');
$routes->get('users/delete/(:num)', 'Admin\Users::delete/$1');
$routes->get('logout', 'Admin\Login::logout');


$routes->get('attendance', 'Admin\Attendance::index');
$routes->post('attendance/punch-in', 'Admin\Attendance::punchIn');
$routes->post('attendance/punch-out', 'Admin\Attendance::punchOut');    


$routes->get('reports', 'Admin\Report::index');
$routes->get('reports/exportCsv', 'Admin\Report::exportCsv');
$routes->get('my-attendance', 'Admin\MyAttendance::index');


$routes->get('my-profile', 'Admin\MyProfile::index');

//$route['default_controller'] = 'admin/Login';

/*
 * --------------------------------------------------------------------
 * 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';
}
