<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
/*
// Pages
$routes->get('/', 'Pages::dashboard_index');
$routes->get('/userroles/', 'Pages::userroles_index');
$routes->get('/users/', 'Pages::users_index');
$routes->get('/changePass/', 'Pages::changePass');
$routes->get('/dictTests/', 'Pages::dictTests_index');
*/

// Auth
$routes->get('/auth/logout', 'Auth::logout');
$routes->get('/auth/loginTD', 'Auth::loginTD');
$routes->match(['get','post'], '/auth/login', 'Auth::login');
$routes->match(['get','post'], '/auth/setpass/(:any)', 'Auth::setpass/$1');
$routes->get('/', 'Auth::redirects');
$routes->get('changePass/', 'Auth::changePass');

// API - Dashboard
$routes->POST('/api/dashboard/index', 'API_Dashboard::index');

// API - Tubes
$routes->get('/tubes/collect/(:any)/(:any)', 'API_Tubes::collect/$1/$2');
$routes->get('/tubes/collectAll/(:any)', 'API_Tubes::collectAll/$1');
$routes->get('/tubes/uncollect/(:any)/(:any)', 'API_Tubes::uncollect/$1/$2');
$routes->get('/tubes/uncollectAll/(:any)', 'API_Tubes::uncollectAll/$1');
$routes->get('/tubes/unreceive/(:any)/(:any)', 'API_Tubes::unreceive/$1/$2');
$routes->get('/tubes/unreceiveAll/(:any)', 'API_Tubes::unreceiveAll/$1');
$routes->post('/tubes/comment/(:any)/(:any)', 'API_Tubes::comment/$1/$2');

// API - Userroles
$routes->get('/api/userroles/index', 'API_Userroles::index');
$routes->get('/api/userroles/detail/(:any)', 'API_Userroles::detail/$1');
$routes->post('/api/userroles/save/(:any)', 'API_Userroles::save/$1');

// API - Users
$routes->get('/api/users/index', 'API_Users::index');
$routes->get('/api/users/detail/(:any)', 'API_Users::detail/$1');
$routes->post('/api/users/savePass/(:any)', 'API_Users::savePass/$1');
$routes->post('/api/users/saveRole/(:any)', 'API_Users::saveRole/$1');

// API - DictTests
$routes->POST('api/dictTests/search', 'API_DictTests::search');
$routes->POST('api/dictTests/save', 'API_DictTests::save');
$routes->get('api/dictTests/index', 'API_DictTests::index');
$routes->get('api/dictTests/detail/(:any)', 'API_DictTests::detail/$1');

// API - DictTubes
$routes->POST('api/dictTubes/save', 'API_DictTubes::save');
$routes->get('api/dictTubes/index', 'API_DictTubes::index');
$routes->get('api/dictTubes/detail/(:any)', 'API_DictTubes::detail/$1');

// API - DictMappings
$routes->POST('api/dictMappings/search', 'API_DictMappings::search');
$routes->get('api/dictMappings/index', 'API_DictMappings::index');
$routes->POST('api/dictMappings/saveSingle', 'API_DictMappings::saveSingle');
$routes->POST('api/dictMappings/saveProfile', 'API_DictMappings::saveProfile');
$routes->get('api/dictMappings/detail/(:any)', 'API_DictMappings::detail/$1');

// API - DictChapters
$routes->get('api/dictChapters/index', 'API_DictChapters::index');
$routes->POST('api/dictChapters/save', 'API_DictChapters::save');
$routes->get('api/dictChapters/detail/(:any)', 'API_DictChapters::detail/$1');

// API - Orders
$routes->POST('api/orders/index', 'API_HISOrders::index');
$routes->POST('api/orders/save', 'API_HISOrders::save');
$routes->GET('api/orders/resend/(:any)', 'API_HISOrders::resend/$1');
$routes->get('api/orders/detail/(:any)', 'API_HISOrders::detail/$1');

// API - Patients
$routes->get('api/patients/patnumberSearch/(:any)', 'API_HISPatients::patnumberSearch/$1');
$routes->POST('api/patients/search/', 'API_HISPatients::search');
$routes->get('api/patients/detail/(:any)', 'API_HISPatients::detail/$1');
$routes->POST('api/patients/save', 'API_HISPatients::save');

// API - For TM
$routes->get('api/his/dictTests', 'API_HIS::dictTests');
$routes->get('api/his/results/(:any)', 'API_HIS::results/$1');
$routes->POST('api/his/requests', 'API_HIS::requests');

// API - TM Request
$routes->post('api/tm/index', 'API_DashboardTM::index');

// admin
$routes->group('admin', ['filter' => 'role:admin'], static function ($routes) {
    $routes->get('', 'AdminController::index');
	$routes->get('dashboard/viewAccess/(:any)', 'AdminController::viewAccess/$1');
	$routes->get('orders/', 'AdminController::orders_index');
	$routes->get('orders/create/', 'AdminController::orders_edit/0');
	$routes->get('orders/edit/(:any)', 'AdminController::orders_edit/$1');
	$routes->get('patients/', 'AdminController::patients_index');
	$routes->get('userroles/', 'AdminController::userroles_index');
	$routes->get('users/', 'AdminController::users_index');
	$routes->get('dictTests/', 'AdminController::dictTests_index');
	$routes->get('dictChapters/', 'AdminController::dictChapters_index');
	$routes->get('dictMappings/', 'AdminController::dictMappings_index');
	$routes->get('dictTubes/', 'AdminController::dictTubes_index');
	$routes->get('tm/', 'AdminController::tm_index');
});

// user
$routes->group('user', ['filter' => 'role:user'], static function ($routes) {
    $routes->get('', 'UserController::index');
	$routes->get('dashboard/viewAccess/(:any)', 'UserController::viewAccess/$1');

	$routes->get('orders/', 'UserController::orders_index');
	$routes->get('orders/create/', 'UserController::orders_edit/0');
	$routes->get('orders/edit/(:any)', 'UserController::orders_edit/$1');
	$routes->get('patients/', 'UserController::patients_index');
});

// sampling
$routes->group('sampling', ['filter' => 'role:sampling'], static function ($routes) {
    $routes->get('', 'samplingController::index');
	$routes->get('dashboard/viewAccess/(:any)', 'SamplingController::viewAccess/$1');
});

// fo
$routes->group('fo', ['filter' => 'role:fo'], static function ($routes) {
    $routes->get('', 'FoController::index');
	$routes->get('dashboard/viewAccess/(:any)', 'FoController::viewAccess/$1');
});

// Printers
$routes->get('printLabel/single/(:any)/(:any)', 'PrintLabel::printSingle/$1/$2');
$routes->get('printLabel/collection/(:any)', 'PrintLabel::labelPostekCollection/$1');
$routes->get('printLabel/all/(:any)', 'PrintLabel::printAll/$1');
$routes->get('printResult/(:any)', 'PrintResult::printResultTest/$1');

$routes->get('printLabelSby/single/(:any)/(:any)', 'PrintLabelSby::printSingle/$1/$2');
$routes->get('printLabelSby/collection/(:any)', 'PrintLabelSby::labelZebraCollection/$1');
$routes->get('printLabelSby/all/(:any)', 'PrintLabelSby::printAll/$1');

