<?php

use App\Http\Controllers\Backend\ActionPerameterController;
use App\Http\Controllers\Backend\AlertActionController;
use App\Http\Controllers\Backend\AppSettingController;
use App\Http\Controllers\Backend\EmployeeController;
use App\Http\Controllers\Backend\EmployeeHistory\EmployeeHistoryController;
use App\Http\Controllers\Backend\Configuration\OrganizationController;
use App\Http\Controllers\Backend\Hr\Attend\HolidayController;
use App\Http\Controllers\Backend\Hr\Attend\ScheduleController;
use App\Http\Controllers\Backend\Hr\Attend\LeaveController;
use App\Http\Controllers\Backend\Hr\HrReportController;

use App\Http\Controllers\Backend\DashboardController;
use App\Http\Controllers\Backend\DatabaseBackupController;
use App\Http\Controllers\Backend\Report\GeneralReportController;
use App\Http\Controllers\Backend\User\ProfileController;
use App\Http\Controllers\Backend\User\RolesController;
use App\Http\Controllers\Backend\User\UserController;
use App\Http\Controllers\HomeController;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\NotificationController;


Route::get('/', function () {
    return view('auth.login');
});

Auth::routes(['register' => false]);

Route::get('/home', [HomeController::class, 'index'])->name('home');
Route::get('/language-change', [HomeController::class, 'LangChange'])->name('language-change');
// Route::get('/test2', [NotificationController::class, 'test'])->name('test2');
Route::post('/auto_attend', [NotificationController::class, 'auto_attendance'])->name('auto_attend');
// Route::post('/auto_attend2', [NotificationController::class, 'auto_attendance2'])->name('auto_attend2');

Route::group(['prefix' => 'system', 'middleware' => 'auth'], function () {
    /**
     * Web route for dashboard.
     * Dashboard shows some statistical and overview data for this system.
     */
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('super-admin.dashboard');
    Route::get('/chart-dashboard', [DashboardController::class, 'chartDashboard'])->name('chart-super-admin.dashboard');
    /**
     * Web route for dashboard filtered data.
     * Dashboard filtered data also shows some statistical and overview data for this system by filter by user access and organization herd lot wise.
     */
    Route::get('/dashboard/filter', [DashboardController::class, 'filter'])->name('dashboard.filter');

    // Firebas Notification
    Route::post('/save-token', [NotificationController::class, 'saveToken'])->name('save-token');
    Route::post('/send-notification', [NotificationController::class, 'sendNotification'])->name('send-notification');

    /**
     * Web routes for user profile section.
     */
    Route::group(['prefix' => 'profile'], function () {
        /**
         * Web route for edit profile option.
         */
        Route::get('/edit', [ProfileController::class, 'edit'])->name('profile.edit');
        /**
         * Web route for update profile data.
         */
        Route::post('/update', [ProfileController::class, 'update'])->name('profile.update');
        /**
         * Web route for edit password option.
         */
        Route::get('/password', [ProfileController::class, 'editPassword'])->name('profile.password.edit');
        /**
         * Web route for update  user password.
         */
        Route::post('/password-update', [ProfileController::class, 'updatePassword'])->name('profile.password.update');
    });

    /**
     * Web routes for user management.
     * Those route are responsible for assigning new user to a organization or lot, assigning new role, edit and manage users.
     */
    Route::group(['prefix' => 'users'], function () {
        /**
         * Web route for show a list of users by user access.
         */
        Route::get('/', [UserController::class, 'index'])->name('super-admin.users.index');
        Route::get('/create', [UserController::class, 'create'])->name('super-admin.users.create');
        Route::post('/store', [UserController::class, 'store'])->name('super-admin.users.store');
        Route::post('/show', [UserController::class, 'show'])->name('super-admin.users.show');
        Route::get('/show_employee/{id}', [UserController::class, 'show_employee'])->name('super-admin.show_employee');
        Route::post('/edit', [UserController::class, 'edit'])->name('super-admin.users.edit');
        Route::post('/update', [UserController::class, 'update'])->name('super-admin.users.update');
        Route::delete('/destroy/{id}', [UserController::class, 'destroy'])->name('super-admin.users.destroy');
    });

    /**
     * Web routes for manage roles.
     * Create new role, assigning permission to role and delete a role etc.
     */
    Route::group(['prefix' => 'roles'], function () {
        /**
         * Web route for show a list of roles.
         */
        Route::get('/', [RolesController::class, 'index'])->name('super-admin.roles.index');
        /**
         * Web route for create a role that will be assigned for each user without super admin.
         */
        Route::get('/create', [RolesController::class, 'create'])->name('super-admin.roles.create');
        /**
         * Web route for store a newly created role.
         */
        Route::post('/store', [RolesController::class, 'store'])->name('super-admin.roles.store');
        /**
         * Web route for edit role.
         */
        Route::get('/edit/{id}', [RolesController::class, 'edit'])->name('super-admin.roles.edit');
        /**
         * Web route for update a role.
         */
        Route::post('/update/{id}', [RolesController::class, 'update'])->name('super-admin.roles.update');
        /**
         * Web route for destroy a role.
         */
        Route::delete('/destroy/{id}', [RolesController::class, 'destroy'])->name('super-admin.roles.destroy');
    });

    Route::get('/action-perameters', [ActionPerameterController::class, 'index'])->name('action-perameters.index');
    Route::post('/action-perameters', [ActionPerameterController::class, 'update'])->name('action-perameters.update');

    /**
     * Routes Collection for alert action report start.
     */
    Route::group(['prefix' => 'alert-action'], function () {
        Route::get('/', [AlertActionController::class, 'index'])->name('alert-action.index');
        // Route::get('/refresh', [AlertActionController::class, 'refresh'])->name('alert-action.refresh');
        Route::post('/status/update', [AlertActionController::class, 'statusUpdate'])->name('alert.status.update');
    });
    /**
     * Routes Collection for alert action report end.
     */

    /**
     * Web route for app settings.
     * Smart dairy has app service also, this app settings contains url parameter that's can save current domain.
     */
    Route::resource('app-settings', AppSettingController::class);

    /**
     * Web route for full systems data backup as .sql file that an importable in php my admin.
     */
    Route::get('database-backup', [DatabaseBackupController::class, 'index'])->name('database-backup.index');

    /**
     * Routes Collection for Employee Management start.
     */
    Route::group(['prefix' => 'employees'], function () {
        /* Routes Collection for Employee register, list view, details show, update and destroy. */
        Route::get('/', [EmployeeController::class, 'index'])->name('employees.index');
        Route::get('/create', [EmployeeController::class, 'create'])->name('employees.create');
        Route::post('/store', [EmployeeController::class, 'store'])->name('employees.store');
        Route::get('/show/{id}', [EmployeeController::class, 'show'])->name('employees.show');
        Route::get('/edit/{id}', [EmployeeController::class, 'edit'])->name('employees.edit');
        Route::put('/update/{id}', [EmployeeController::class, 'update'])->name('employees.update');
        Route::delete('/destroy/{id}', [EmployeeController::class, 'destroy'])->name('employees.destroy');

        /* Route for Employee image destroy. */
        Route::post('/destroy/image/{id}', [EmployeeController::class, 'imageDestroy'])->name('employees.image.destroy');
        // Get tag list for dropdown with pagination
        Route::get('tagIdforselect2', [EmployeeController::class, 'getdataforselect2'])->name('dataforselect2');
        /* Routes Collection for Employee lifetime history and show details of lifetime history. */
        Route::get('/lifetime-history', [EmployeeHistoryController::class, 'lifetimeHistory'])->name('employees.lifetime-history.index');
        Route::get('/lifetime-history/{id}', [EmployeeHistoryController::class, 'lifetimeHistoryShow'])->name('employees.lifetime-history.show');

        /* Route for get Employee lifetime history with parity wise. */
        Route::get('/lifetime-history/{id}/parity-data', [EmployeeHistoryController::class, 'lifetimeHistoryParityData'])->name('employees.lifetime-history.parity-data');

        /* Route for get Employee lifetime summary. */
        Route::get('/summary/{id}', [EmployeeHistoryController::class, 'summary'])->name('employees.summary');
    });

    //  Old of Organizations route
    // Route::resource('organizations', OrganizationController::class);
    // Route::post('organization/update', [OrganizationController::class, 'update'])->name('organizations.new.update');

    Route::group(['prefix' => 'organizations'], function () {
        /* Routes Collection for Organizations register, list view, details show, update and destroy. */
        Route::get('/', [OrganizationController::class, 'index'])->name('organizations.index');
        Route::get('/create', [OrganizationController::class, 'create'])->name('organizations.create');
        Route::post('/store', [OrganizationController::class, 'store'])->name('organizations.store');
        Route::get('/show/{id}', [OrganizationController::class, 'show'])->name('organizations.show');
        Route::get('/{id}/edit', [OrganizationController::class, 'edit'])->name('organizations.edit');
        // Route::put('/update/{id}', [OrganizationController::class, 'update'])->name('organizations.update');
        Route::post('/update/{id}', [OrganizationController::class, 'update'])->name('organizations.update');
        Route::delete('/destroy/{id}', [OrganizationController::class, 'destroy'])->name('organizations.destroy');
        Route::post('/update', [OrganizationController::class, 'update'])->name('organizations.new.update');
    });

    Route::group(['prefix' => 'holidays'], function () {
        Route::get('/', [HolidayController::class, 'index'])->name('holidays.index');
        Route::get('/create', [HolidayController::class, 'create'])->name('holidays.create');
        Route::post('/store', [HolidayController::class, 'store'])->name('holidays.store');
        Route::get('/show/{id}', [HolidayController::class, 'show'])->name('holidays.show');
        Route::get('/{id}/edit', [HolidayController::class, 'edit'])->name('holidays.edit');
        Route::post('/update/{id}', [HolidayController::class, 'update'])->name('holidays.update');
        Route::delete('/destroy/{id}', [HolidayController::class, 'destroy'])->name('holidays.destroy');
        Route::post('/approve/{id}', [HolidayController::class, 'approve'])->name('holidays.approve');
    });
    Route::group(['prefix' => 'schedules'], function () {
        Route::get('/', [ScheduleController::class, 'index'])->name('schedules.index');
        Route::get('/create', [ScheduleController::class, 'create'])->name('schedules.create');
        Route::post('/store', [ScheduleController::class, 'store'])->name('schedules.store');
        Route::get('/{id}/edit', [ScheduleController::class, 'edit'])->name('schedules.edit');
        Route::delete('/destroy/{id}', [ScheduleController::class, 'destroy'])->name('schedules.destroy');
        Route::post('/approve/{id}', [ScheduleController::class, 'approveSchedule'])->name('schedules.approve');
    });
    Route::group(['prefix' => 'leaves'], function () {
        Route::get('/', [LeaveController::class, 'index'])->name('leaves.index');
        Route::get('/create', [LeaveController::class, 'create'])->name('leaves.create');
        Route::post('/store', [LeaveController::class, 'store'])->name('leaves.store');
        Route::get('/show/{id}', [LeaveController::class, 'show'])->name('leaves.show');
        Route::get('/{id}/edit', [LeaveController::class, 'edit'])->name('leaves.edit');
        Route::delete('/destroy/{id}', [LeaveController::class, 'destroy'])->name('leaves.destroy');
        Route::post('/approve/{id}', [LeaveController::class, 'approve'])->name('leaves.approve');
        Route::get('/leaveType', [LeaveController::class, 'leaveType'])->name('leaves.leave_type');
        Route::post('/availableLeaveDays', [LeaveController::class, 'getAvailableLeaveDays'])->name('leaves.availableLeaveDays');
    });
    Route::get('hr_reports/attendFilterMultis', [HrReportController::class, 'attendFilterMulti'])->name('hr_reports.attendFilterMultis');
    Route::get('hr_reports/attendReportMultis', [HrReportController::class, 'attendReportMulti'])->name('hr_reports.attendReportMultis');
    Route::get('hr_reports/attendReportDetails', [HrReportController::class, 'attendReportDetail'])->name('hr_reports.attendReportDetails');

    Route::get('hr_reports/attendStatusFilters', [HrReportController::class, 'attendStatusFilter'])->name('hr_reports.attendStatusFilters');
    Route::get('hr_reports/attendStatusReports', [HrReportController::class, 'attendStatusReport'])->name('hr_reports.attendStatusReports');

    // Route::get('manualAtts/attendEntryFilters', [ManualAttsController::class, 'attendEntryFilter'])->name('hr_reports.attendEntryFilters');
    // Route::get('manualAtts/attendEntryContents', [ManualAttsController::class, 'attendEntryContent'])->name('hr_reports.attendEntryContents');
});
//stogage
Route::get('clear-all-developer', function () {
    Artisan::call('storage:link');
    return redirect()->back();
});

