<?php

/*
|--------------------------------------------------------------------------
| Module Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for this module.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::group(['prefix' => Config::get('app.api_path') . '/hr', 'middleware' => ['web', 'auth']], function () {
    Route::get('lunch-status', [\App\Modules\Hr\controllers\api\v1\TimeLogControllerREST::class, 'checkLunchStatus']);
    Route::resource('time-log', \App\Modules\Hr\controllers\api\v1\TimeLogControllerREST::class, ['names' => [
        'index' => 'hr.v1.time-log.index',
        'create' => 'hr.v1.time-log.create',
        'store' => 'hr.v1.time-log.store',
        'show' => 'hr.v1.time-log.show',
        'edit' => 'hr.v1.time-log.edit',
        'update' => 'hr.v1.time-log.update',
        'destroy' => 'hr.v1.time-log.destroy',
    ]]);
    Route::resource('admin/time-log', \App\Modules\Hr\controllers\api\v1\AdminTimeLogControllerREST::class, [
        'only' => ['index', 'store', 'update'],
        'names' => [
            'index' => 'hr.v1.admin.time-log.index',
            'store' => 'hr.v1.admin.time-log.store',
            'update' => 'hr.v1.admin.time-log.update',
        ]
    ]);
    Route::resource('time-log-change-requests', \App\Modules\Hr\controllers\api\v1\TimeLogChangeRequestsControllerREST::class);
    Route::resource('user-details', \App\Modules\Hr\controllers\api\v1\UserDetailsControllerREST::class);
    Route::resource('holiday', \App\Modules\Hr\controllers\api\v1\HolidayControllerREST::class);
});

Route::group(['prefix' => 'api/v2' . '/hr', 'middleware' => ['web', 'auth']], function () {
    Route::resource('time-log', \App\Modules\Hr\controllers\api\v2\TimeLogControllerRESTv2::class, ['names' => [
        'index' => 'hr.v2.time-log.index',
        'create' => 'hr.v2.time-log.create',
        'store' => 'hr.v2.time-log.store',
        'show' => 'hr.v2.time-log.show',
        'edit' => 'hr.v2.time-log.edit',
        'update' => 'hr.v2.time-log.update',
        'destroy' => 'hr.v2.time-log.destroy',
    ]]);
    // Route::resource('admin/time-log', \App\Modules\Hr\AdminTimeLogControllerRESTv2::class, ['only' => ['index', 'store', 'update']]);
    // Route::resource('leave-requests', \App\Modules\Hr\LeaveRequestsControllerRESTv2::class);
    // Route::resource('admin/leave-requests', \App\Modules\Hr\AdminLeaveRequestsControllerRESTv2::class, ['only' => ['index', 'store', 'update']]);
    // Route::resource('stats', \App\Modules\Hr\StatsControllerRESTv2::class);
    // Route::resource('admin/stats', \App\Modules\Hr\AdminStatsControllerRESTv2::class, ['only' => ['index', 'store', 'update']]);
    // Route::resource('reports', \App\Modules\Hr\ReportsControllerRESTv2::class);
    // Route::resource('admin/reports', \App\Modules\Hr\AdminReportsControllerRESTv2::class, ['only' => ['index', 'store', 'update']]);
});

/*
|--------------------------------------------------------------------------
| Pages rendered on the server
|--------------------------------------------------------------------------
|
| This group routes are pages rendered on the server.
| All the pages require the user to be authentificated.
|
*/

Route::group(['middleware' => ['web', 'auth']], function () {
    Route::get('hr', [\App\Modules\Hr\controllers\HrController::class, 'getIndex']);
    Route::get('hr/admin', [\App\Modules\Hr\controllers\HrAdminController::class, 'getIndex']);
    Route::post('hr/admin/users/report', [\App\Modules\Hr\controllers\HrAdminController::class, 'postReport']);
    Route::post('hr/admin/user/{id}/report', [\App\Modules\Hr\controllers\HrAdminController::class, 'postIndividualReport']);
    Route::get('hr/admin/users/{id}', [\App\Modules\Hr\controllers\HrAdminController::class, 'getUsers']);
    Route::get('hr/admin/users/{id}/pdf', [\App\Modules\Hr\controllers\HrAdminController::class, 'getPDF']);
    Route::get('hr/admin/users/{id}/excel', [\App\Modules\Hr\controllers\HrAdminController::class, 'getExcel']);
    Route::get('hr/time-log', [\App\Modules\Hr\controllers\HrViewController::class, 'timeLogIndex'])->name('hr.time-log');
    Route::get('hr/admin/time-log', [\App\Modules\Hr\controllers\HrViewController::class, 'adminTimeLogIndex'])->name('hr.admin.time-log');
    Route::get('hr/leave-requests', [\App\Modules\Hr\controllers\HrViewController::class, 'leaveRequestsIndex'])->name('hr.leave-requests');
    Route::get('hr/admin/leave-requests', [\App\Modules\Hr\controllers\HrViewController::class, 'adminLeaveRequestsIndex'])->name('hr.admin.leave-requests');
    Route::get('hr/stats', [\App\Modules\Hr\controllers\HrViewController::class, 'statsIndex'])->name('hr.stats');
    Route::get('hr/admin/stats', [\App\Modules\Hr\controllers\HrViewController::class, 'adminStatsIndex'])->name('hr.admin.stats');
    Route::get('hr/reports', [\App\Modules\Hr\controllers\HrViewController::class, 'reportsIndex'])->name('hr.reports');
    Route::get('hr/admin/reports', [\App\Modules\Hr\controllers\HrViewController::class, 'adminReportsIndex'])->name('hr.admin.reports');
});
