<?php namespace Config;

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

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
	require SYSTEMPATH . 'Config/Routes.php';
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Dashboard');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override(function() {
    return view('page_not_found');
});
$routes->setAutoRoute(false); #default true

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

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
// last modified 13 Apr 2021
$routes->get('/', 'Dashboard::index');
$routes->get('/dashboard', 'Dashboard::index');
$routes->get('/login', 'Login::index');
$routes->post('/do-login', 'Login::doLogin');
$routes->get('/do-logout', 'Login::doLogout');
$routes->get('/change-password', 'App::changePassword');
$routes->post('/do-change-password', 'App::doChangePassword');
$routes->get('/menu', 'Menu::index');
$routes->post('/menu/save', 'Menu::saveData');
$routes->post('/menu/delete', 'Menu::deleteData');
$routes->get('/transaksi', 'Trx::addData');
$routes->get('/transaksi/add', 'Trx::addData');
$routes->get('/transaksi/edit/(:num)', 'Trx::editData/$1');
$routes->post('/transaksi/save', 'Trx::saveData');
$routes->post('/transaksi/delete', 'Trx::deleteData');
$routes->get('/transaksi/print/(:num)', 'Trx::printStruk/$1');
$routes->get('/antrian', 'Antrian::index');
$routes->get('/antrian/add', 'Antrian::addData');
$routes->get('/antrian/edit/(:num)', 'Antrian::editData/$1');
$routes->post('/antrian/save', 'Antrian::saveData');
$routes->post('/antrian/delete', 'Antrian::deleteData');
$routes->post('/antrian/update-status', 'Antrian::updateStatus');
$routes->get('/history', 'History::index');
$routes->get('/laporan', 'Report::index');
$routes->get('/user', 'User::index');
$routes->get('/user/add', 'User::addData');
$routes->get('/user/edit/(:any)', 'User::editData/$1');
$routes->post('/user/save', 'User::saveData');
$routes->post('/user/delete', 'User::deleteData');
$routes->get('/get-datatables/(:any)', 'Datatables::getDatatables/$1');
$routes->post('/get-datatables/(:any)', 'Datatables::getDatatables/$1');
$routes->post('/get-datatables/(:any)/(:any)/(:any)', 'Datatables::getDatatables/$1/$2/$3');

/**
 * --------------------------------------------------------------------
 * 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 (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'))
{
	require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
