<?php

use Illuminate\Support\Facades\Route;
use App\Modules\HR\Core\Http\Controllers\DepartmentController;
use App\Modules\HR\Core\Http\Controllers\DesignationController;
use App\Modules\HR\Core\Http\Controllers\EmploymentTypeController;
use App\Modules\HR\Core\Http\Controllers\GradeController;
use App\Modules\HR\Core\Http\Controllers\ShiftController;
use App\Modules\HR\Core\Http\Controllers\IdentificationTypeController;
use App\Modules\HR\Core\Http\Controllers\IllnessController;
use App\Modules\HR\Core\Http\Controllers\DynamicAttributeController;
use App\Modules\HR\Core\Http\Controllers\EmployeeController;
use App\Modules\HR\Core\Http\Controllers\EmployeeExitController;
use App\Modules\HR\Core\Http\Controllers\EmployeeGratuityController;
use App\Modules\HR\Core\Http\Controllers\EmployeeRejoinController;
use App\Modules\HR\Core\Http\Controllers\LeaveTypeController;
use App\Modules\HR\Core\Http\Controllers\ShiftCalendarController;
use App\Modules\HR\Core\Http\Controllers\ShiftSegmentController;
use App\Modules\HR\Core\Http\Controllers\TeamController;
use App\Modules\PLATFORM\Settings\Http\Controllers\DocumentTypeController;




Route::middleware(['auth','branch','module:core'])
    ->prefix('core')
    ->name('core.')
    ->group(function () {

        /*
        |--------------------------------------------------------------------------
        | HR MASTERS
        |--------------------------------------------------------------------------
        */
        Route::resources([
            'departments'           => DepartmentController::class,
            'designations'          => DesignationController::class,
            'employment-types'      => EmploymentTypeController::class,
            'grades'                => GradeController::class,
            'teams'                 => TeamController::class,
            'leave-types'           => LeaveTypeController::class,
            'shifts'                => ShiftController::class,
            'shift-segment'         => ShiftSegmentController::class,            
            'identification-types'  => IdentificationTypeController::class,
            'illnesses'             => IllnessController::class,
            'dynamic-attributes'    => DynamicAttributeController::class,
        ]);

        /*
        |--------------------------------------------------------------------------
        | STATUS TOGGLES
        |--------------------------------------------------------------------------
        */
        Route::post('departments/{department}/status', [DepartmentController::class, 'status'])->name('departments.status');
        Route::post('designations/{designation}/status', [DesignationController::class, 'status'])->name('designations.status');
        Route::post('employment-types/{employment_type}/status', [EmploymentTypeController::class, 'status'])->name('employment-types.status');
        Route::post('grades/{grade}/status', [GradeController::class, 'status'])->name('grades.status');
        Route::post('teams/{team}/status', [TeamController::class, 'status'])->name('teams.status');
        Route::post('leave-types/{leave}/status', [LeaveTypeController::class, 'status'])->name('leave-types.status');
        Route::post('shifts/{shift}/status', [ShiftController::class, 'status'])->name('shifts.status');
        Route::post('shift-segment/{shift}/status', [ShiftSegmentController::class, 'status'])->name('shift-segment.status');
        Route::post('document-types/{document_type}/status', [DocumentTypeController::class, 'status'])->name('document-types.status');
        Route::post('identification-types/{identification_type}/status', [IdentificationTypeController::class, 'status'])->name('identification-types.status');
        Route::post('illnesses/{illness}/status', [IllnessController::class, 'status'])->name('illnesses.status');
        Route::post('dynamic-attributes/{dynamic_attribute}/status', [DynamicAttributeController::class, 'status'])->name('dynamic-attributes.status');

        /*
        |--------------------------------------------------------------------------
        | SHIFT CALENDAR
        |--------------------------------------------------------------------------
        */
        Route::get('shift-calendar', [ShiftCalendarController::class, 'index'])->name('shift-calendar.index');
        Route::get('shift-calendar/events', [ShiftCalendarController::class, 'events'])->name('shift-calendar.events');
        Route::post('shift-calendar/save', [ShiftCalendarController::class, 'store'])->name('shift-calendar.store');

        /*
        |--------------------------------------------------------------------------
        | EMPLOYEES
        |--------------------------------------------------------------------------
        */
        Route::resource('employees', EmployeeController::class);
        Route::post('employees/{employee}/status', [EmployeeController::class, 'status'])->name('employees.status');

        Route::get('additions/{id}/details', [EmployeeController::class, 'getAdditionDetails'])->name('additions.details');
        Route::get('deductions/{id}/details', [EmployeeController::class, 'getDeductionDetails'])->name('deductions.details');
        Route::get('employee/{employee}/leaves/{year}', [EmployeeController::class, 'getEmployeeLeavesByYear'])
            ->name('employee.leaves.byYear');
        Route::get('designation/{designation}/details', [DesignationController::class, 'getPayrollDetails'])->name('designations.details');

        /*
        |--------------------------------------------------------------------------
        | EMPLOYEE LIFECYCLE
        |--------------------------------------------------------------------------
        */
        Route::resource('employee-exits', EmployeeExitController::class);
        Route::resource('employee-rejoins', EmployeeRejoinController::class);
        Route::resource('gratuities', EmployeeGratuityController::class);
    });