<?php

use Illuminate\Support\Facades\Route;
use Modules\HR\Http\Controllers\AttendanceController;
use Modules\HR\Http\Controllers\AttendancePolicyController;
use Modules\HR\Http\Controllers\BiometricDeviceController;
use Modules\HR\Http\Controllers\EmployeeTaxProfileController;
use Modules\HR\Http\Controllers\FestivalBonusPolicyController;
use Modules\HR\Http\Controllers\HolidayController;
use Modules\HR\Http\Controllers\HolidayGroupController;
use Modules\HR\Http\Controllers\HrLookupController;
use Modules\HR\Http\Controllers\WeekendPolicyController;
use Modules\HR\Http\Controllers\HolidayAllowancePolicyController;
use Modules\HR\Http\Controllers\LeavePolicyController;
use Modules\HR\Http\Controllers\LeaveTypeController;
use Modules\HR\Http\Controllers\SalaryComponentController;
use Modules\HR\Http\Controllers\SalaryRevisionController;
use Modules\HR\Http\Controllers\SalaryStructureController;
use Modules\HR\Http\Controllers\SalaryStructureItemController;
use Modules\HR\Http\Controllers\TaxConfigurationController;
use Modules\HR\Http\Controllers\TaxSlabController;

Route::middleware(['api.auth'])->group(function () {

    Route::prefix('hr-management')->group(function () {
        Route::apiResource('holiday-groups', HolidayGroupController::class)->except('destroy');
        Route::patch('holiday-groups/{holidayGroup}/status', [HolidayGroupController::class, 'updateStatus'])
            ->name('holiday-groups.update-status');

        Route::apiResource('holiday', HolidayController::class)->except('destroy');
        Route::patch('holiday/{holiday}/status', [HolidayController::class, 'updateStatus'])
            ->name('holiday.update-status');

        Route::apiResource('weekend-policies', WeekendPolicyController::class)->except('destroy');
        Route::patch('weekend-policies/{weekendPolicy}/status', [WeekendPolicyController::class, 'updateStatus'])
            ->name('weekend-policies.update-status');

        Route::apiResource('attendance-policies', AttendancePolicyController::class)->except('destroy');
        Route::patch('attendance-policies/{attendancePolicy}/status', [AttendancePolicyController::class, 'updateStatus'])
            ->name('attendance-policies.update-status');

        Route::apiResource('holiday-allowance-policies', HolidayAllowancePolicyController::class)->except('destroy');

        Route::patch('holiday-allowance-policies/{holidayAllowancePolicy}/status', [HolidayAllowancePolicyController::class, 'updateStatus'])
            ->name('holiday-allowance-policies.update-status');

        Route::apiResource('leave-types', LeaveTypeController::class)->except('destroy');
        Route::patch('leave-types/{leaveType}/status', [LeaveTypeController::class, 'updateStatus'])
            ->name('leave-types.update-status');

        Route::apiResource('leave-policies', LeavePolicyController::class)->except('destroy');
        Route::patch('leave-policies/{leavePolicy}/status', [LeavePolicyController::class, 'updateStatus'])
            ->name('leave-policies.update-status');

        Route::apiResource('biometric-devices', BiometricDeviceController::class)->except('destroy');

        Route::patch('biometric-devices/{biometricDevice}/status', [BiometricDeviceController::class, 'updateStatus'])
            ->name('biometric-devices.update-status');

        Route::apiResource('salary-components', SalaryComponentController::class)->except('destroy');

        Route::patch('salary-components/{salaryComponent}/status', [SalaryComponentController::class, 'updateStatus'])
            ->name('salary-components.update-status');

        Route::get('employees/{employee}/salary-structure', [SalaryStructureController::class, 'index'])->name('salary-structure.index');
        Route::post('salary-structure/{employee}', [SalaryStructureController::class, 'store'])->name('salary-structure.store');
        Route::get('salary-structure/{employee}', [SalaryStructureController::class, 'show'])->name('salary-structure.show');

        Route::patch('salary-structure/{salaryStructure}/status', [SalaryStructureController::class, 'updateStatus'])
            ->name('salary-structure.update-status');

        Route::apiResource('salary-structure-items', SalaryStructureItemController::class)->except('destroy');

        Route::patch('salary-structure-items/{salaryStructureItem}/status', [SalaryStructureItemController::class, 'updateStatus'])
            ->name('salary-structure-items.update-status');

        Route::apiResource('salary-revisions', SalaryRevisionController::class)->except('destroy');

        Route::patch('salary-revisions/{salaryRevision}/approve', [SalaryRevisionController::class, 'approve'])->name('salary-revisions.approve');
        Route::patch('salary-revisions/{salaryRevision}/reject', [SalaryRevisionController::class, 'reject'])->name('salary-revisions.reject');
        Route::patch('salary-revisions/{salaryRevision}/apply', [SalaryRevisionController::class, 'apply'])->name('salary-revisions.apply');
        Route::patch('salary-revisions/{salaryRevision}/cancel', [SalaryRevisionController::class, 'cancel'])->name('salary-revisions.cancel');

        Route::apiResource('tax-configurations', TaxConfigurationController::class)->except('destroy');

        Route::patch('tax-configurations/{taxConfiguration}/status', [TaxConfigurationController::class, 'updateStatus'])
            ->name('tax-configurations.update-status');

        Route::apiResource('tax-slabs', TaxSlabController::class)->except('destroy');
        Route::patch('tax-slabs/{taxSlab}/status', [TaxSlabController::class, 'updateStatus'])
            ->name('tax-slabs.update-status');

        Route::put('employees/{employee}/tax-profiles', [EmployeeTaxProfileController::class, 'updateTaxProfile'])->name('employees.update-tax-profile');
        Route::get('employees/{employee}/tax-profiles', [EmployeeTaxProfileController::class, 'showTaxProfile'])->name('employees.show-tax-profile');

        Route::apiResource('festival-bonus-policies', FestivalBonusPolicyController::class)->except('destroy');

        Route::patch('festival-bonus-policies/{festivalBonusPolicy}/status', [FestivalBonusPolicyController::class, 'updateStatus'])
            ->name('festival-bonus-policies.update-status');

        Route::get('attendances', [AttendanceController::class, 'getAttendances'])->name('attendances.list');
        Route::get('overtime-entries', [AttendanceController::class, 'getOvertimeEntries'])->name('overtime-entries.list');

        Route::patch('overtime-entries/{overtimeEntry}/approve', [AttendanceController::class, 'approveOvertimeEntry'])->name('overtime-entries.approve');

        Route::patch('holiday-allowances/{holidayAllowances}/approve', [AttendanceController::class,'approveHolidayAllowance'])->name('holiday-allowances.approve');
        
    });

    Route::prefix('hr-management/lookups')->group(function () {
        Route::get('holiday-groups', [HrLookupController::class, 'holidayGroupLookup'])
            ->name('lookups.holiday-groups');


        Route::get('holiday-allowance-policies', [HrLookupController::class, 'holidayAllowancePolicyLookup'])
            ->name('lookups.holiday-allowance-policies');


        Route::get('weekend-policies', [HrLookupController::class, 'weekendPolicyLookup'])
            ->name('lookups.weekend-policies');

        Route::get('attendance-policies', [HrLookupController::class, 'attendancePolicyLookup'])
            ->name('lookups.attendance-policies');

        Route::get('leave-types', [HrLookupController::class, 'leaveTypeLookup'])
            ->name('lookups.leave-types');

        Route::get('leave-policies', [HrLookupController::class, 'leavePolicyLookup'])
            ->name('lookups.leave-policies');

        Route::get('biometric-devices', [HrLookupController::class, 'biometricDeviceLookup'])
            ->name('lookups.biometric-devices');

        Route::get('salary-components', [HrLookupController::class, 'salaryComponentLookup'])->name('lookups.salary-components');

        Route::get('salary-structures', [HrLookupController::class, 'salaryStructureLookup'])->name('lookups.salary-structures');

        Route::get('employees', [HrLookupController::class, 'employeesList']);
        Route::get('designations', [HrLookupController::class, 'designationList']);
        Route::get('fiscal-years', [HrLookupController::class, 'fiscalYearList']);
    });
});
