<?php

use App\Http\Controllers\V3\Auth\LogoutController;
use App\Http\Controllers\V3\CMMSMachinesController;
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshController;
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController;
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController;
use App\Http\Controllers\V3\Dashboard\ObservedItemController;
use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController;
use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController;
use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController;
use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
use App\Http\Controllers\V3\FMSVehicleManagementController;
use App\Http\Controllers\V3\Harim\DivarkeshiController;
use App\Http\Controllers\V3\ProfileController;
use App\Http\Controllers\V3\RahdaranController;
use Illuminate\Support\Facades\Route;

Route::prefix('harim')->name('harim')->group(function () {
    Route::prefix('divarkeshi')->name('divarkeshi')->controller(DivarkeshiController::class)->group(function () {
        Route::get('/', 'index')->name('index');
        Route::get('/{divarkeshi}', 'details')->name('details');
        Route::post('/store', 'store')->name('store');
        // Route::get('/report/map', 'V3\Dashboard\ContractController@getAllDataToMap')->name('V3.contract.report.map');
        // Route::get('/{contract}', 'V3\Dashboard\ContractController@detail')->name('V3.contract.detail');
    });
    Route::prefix('rah_dastresi')->name('rah_dastresi')->group(function () {
        // Route::get('/store', 'V3\Dashboard\ContractController@unserialize')->name('store');
        // Route::get('/report/map', 'V3\Dashboard\ContractController@getAllDataToMap')->name('V3.contract.report.map');
        // Route::get('/{contract}', 'V3\Dashboard\ContractController@detail')->name('V3.contract.detail');
    });
    Route::prefix('tasisat_zirbana')->group(function () {
        // Route::get('/{contract}/unserialize', 'V3\Dashboard\ContractController@unserialize')->name('V3.contract.unserialize');
        // Route::get('/report/map', 'V3\Dashboard\ContractController@getAllDataToMap')->name('V3.contract.report.map');
        // Route::get('/{contract}', 'V3\Dashboard\ContractController@detail')->name('V3.contract.detail');
    });
});

Route::prefix('profile')
    ->name('profile.')
    ->controller(ProfileController::class)
    ->group(function () {
        Route::get('info', 'info')->name('info');
        Route::post('edit', 'edit')->name('edit');
        Route::post('change_password', 'changePassword')->name('changePassword');
        Route::post('add_activity', 'addActivity')->name('addActivity');
    });

Route::prefix('azmayesh_types')
    ->name('azmayesh_types.')
    ->controller(AzmayeshTypeController::class)
    ->group(function () {
        Route::get('/', 'index')->middleware('permission:azmayesh-type-management')->name('index');
        Route::get('/list', 'list')->middleware(['permission:azmayesh-type-management|azmayesh-management'])->name('list');
        Route::get('/fields/{azmayeshType}', 'fields')->middleware('permission:azmayesh-type-management')->name('fields');
        Route::get('/{azmayeshType}', 'show')->middleware('permission:azmayesh-type-management')->name('show');
        Route::post('/store', 'store')->middleware('permission:azmayesh-type-management')->name('store');
        Route::post('/update/{azmayeshType}', 'update')->middleware('permission:azmayesh-type-management')->name('update');
        Route::post('/delete/{azmayeshType}', 'destroy')->middleware('permission:azmayesh-type-management')->name('delete');
    });

Route::prefix('azmayesh_samples')
    ->name('azmayesh_samples.')
    ->middleware('permission:azmayesh-management')
    ->controller(AzmayeshSampleController::class)
    ->group(function () {
        Route::get('/index/{azmayesh_id}', 'index')->name('index');
        Route::get('/{azmayeshSample}', 'show')->name('show');
        Route::post('/store', 'store')->name('store');
        Route::post('/update/{azmayeshSample}', 'update')->name('update');
        Route::post('/delete/{azmayeshSample}', 'destroy')->name('delete');
    });

    Route::prefix('azmayeshes')
    ->name('azmayeshes.')
    ->middleware('permission:azmayesh-management')
    ->controller(AzmayeshController::class)
    ->group(function () {
        Route::get('/', 'index')->name('index');
        Route::get('/{azmayesh}', 'show')->name('show');
        Route::post('/store', 'store')->name('store');
        Route::post('/update/{azmayesh}', 'update')->name('update');
        Route::post('/delete/{azmayesh}', 'destroy')->name('delete');
    });

Route::post('logout', LogoutController::class)->name('logout');

Route::prefix('road_items')
    ->name('road_items.')
    ->controller(RoadItemsProjectController::class)
    ->group(function () {

        Route::get('/supervisor_index', 'supervisorIndex')
            ->middleware(['permission:show-road-item-supervise-cartable|show-road-item-supervise-cartable-province'])
            ->name('supervisorIndex');

        Route::post('/verify_by_supervisor/{roadItemsProject}', 'VerifyBySupervisor')
            ->name('VerifyBySupervisor');

        Route::post('/restore/{roadItemsProject}', 'restore')
            ->middleware('permission:restore-road-item')
            ->name('restore');

        Route::post('/delete/{roadItemsProject}', 'delete')
            ->middleware('permission:delete-road-item')
            ->name('delete');

        Route::get('/supervisor_report', 'supervisorCartableReport')
            ->name('supervisorCartableReport');

        Route::get('/operator_index', 'operatorIndex')
            ->middleware('permission:create-road-item')
            ->name('operatorIndex');

        Route::post('/store', 'store')
            ->middleware('permission:create-road-item')
            ->name('store');

        Route::post('/update/{roadItemsProject}', 'update')->name('update');

        Route::get('/operator_report', 'operatorCartableReport')
            ->name('operatorCartableReport');
    });

Route::prefix('road_patrols')
    ->name('road_patrols.')
    ->controller(RoadPatrolProjectController::class)
    ->group(function () {

        Route::get('/supervisor_index', 'supervisorIndex')
            ->middleware(['permission:show-road-patrol-supervise-cartable|show-road-patrol-supervise-cartable-province'])
            ->name('supervisorIndex');

        Route::post('/delete/{roadPatrol}', 'delete')
            ->middleware('permission:partial-delete-road-patrol|complete-delete-road-patrol')
            ->name('delete');

        Route::get('/supervisor_report', 'supervisorCartableReport')
            ->name('supervisorCartableReport');

        Route::get('/operator_index', 'operatorIndex')
            ->middleware('permission:add-road-patrol')
            ->name('operatorIndex');

        Route::post('/store', 'store')
            ->middleware('permission:add-road-patrol')
            ->name('store');

        Route::get('/operator_report', 'operatorCartableReport')
            ->name('operatorCartableReport');

        Route::get('/operator/report/{roadPatrol}', 'getReport')
            ->name('getReport');

        Route::get('/operator/map_data', 'getAllDataToMap')
            ->name('getAllDataToMap');

        Route::get('/detail/{roadPatrol}', 'show')
            ->name('show');
    });

Route::prefix('cmms_machines')
    ->name('cmms_machines.')
    ->controller(CMMSMachinesController::class)
    ->group(function () {
        Route::get('/list', 'list')->name('list');
        Route::get('/search', 'search')->name('search');
    });

Route::prefix('rahdaran')
    ->name('rahdaran.')
    ->controller(RahdaranController::class)
    ->group(function () {
        Route::get('/list', 'list')->name('list');
        Route::get('/search', 'search')->name('search');
    });

Route::prefix('fms_vehicle')
    ->name('fmsVehicle.')
    ->controller(FMSVehicleManagementController::class)
    ->group(function () {
        Route::post('/get_activity', 'getActivity')->name('getActivity');
    });

Route::prefix('observed_items')
    ->name('observedItem.')
    ->controller(ObservedItemController::class)
    ->group(function () {
        Route::get('/filter', 'filter')->name('filter');
        Route::get('/{observedItem}', 'show')->name('show');
    });

Route::prefix('road_item_reports')
    ->name('roadItemReports.')
    ->controller(RoadItemsReportController::class)
    ->group(function () {
        Route::get('/get_sub_items', 'getSubItems')->name('getSubItems');
        Route::get('/province_activity_per_sub_item', 'provinceActivityPerSubItem')->name('provinceActivityPerSubItem');
        Route::get('/city_activity_per_sub_item', 'cityActivityPerSubItem')->name('cityActivityPerSubItem');
        Route::get('/province_activity_per_item', 'provinceActivityPerItem')->name('provinceActivityPerItem');
        Route::get('/city_activity_per_item', 'cityActivityPerItem')->name('cityActivityPerItem');
        Route::get('/map', 'map')->name('map');
        Route::get('/country_activity_excel_per_item', 'countryActivityExcelPerItem')->name('countryActivityExcelPerItem');
        Route::get('/province_activity_excel_per_item', 'provinceActivityExcelPerItem')->name('provinceActivityExcelPerItem');
        Route::get('/country_activity_excel_per_sub_item', 'countryActivityExcelPerSubItem')->name('countryActivityExcelPerSubItem');
        Route::get('/province_activity_excel_per_sub_item', 'provinceActivityExcelPerSubItem')->name('provinceActivityExcelPerSubItem');
    });

Route::prefix('road_patrol_reports')
    ->name('roadPatrolReports.')
    ->controller(RoadPatrolReportController::class)
    ->group(function () {
        Route::get('/province_activity', 'provincePatrolActivity')->name('provincePatrolActivity');
        Route::get('/city_activity', 'cityPatrolActivity')->name('cityPatrolActivity');
        Route::get('/excel', 'excel')->name('excel');
    });
