<?php

use Illuminate\Support\Facades\Route;

/*
  |--------------------------------------------------------------------------
  | Web Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register web routes for your application. These
  | routes are loaded by the RouteServiceProvider within a group which
  | contains the "web" middleware group. Now create something great!
  |
 */


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


Route::group(['middleware' => 'auth'], function () {
    Route::get('/', [App\Http\Controllers\HomeController::class, 'index']);
    Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

    // add indicators
    Route::get('addIndicatorEntries', [App\Http\Controllers\IndicatorEntryController::class, 'addIndicatorEntries'])->name('addIndicatorEntries');
    Route::post('getIndicatorEntriesData', [App\Http\Controllers\IndicatorEntryController::class, 'getIndicatorEntriesData'])->name('getIndicatorEntriesData');
    Route::post('saveIndicatorEntriesData', [App\Http\Controllers\IndicatorEntryController::class, 'saveIndicatorEntriesData'])->name('saveIndicatorEntriesData');
    Route::post('addIndicatorEntry', [App\Http\Controllers\IndicatorEntryController::class, 'addIndicatorEntry'])->name('addIndicatorEntry');
    Route::post('saveIndicatorEntryValue', [App\Http\Controllers\IndicatorEntryController::class, 'saveIndicatorEntryValue'])->name('saveIndicatorEntryValue');

    // Administration
    Route::group(['prefix' => 'admin'], function () {

        // indicator categories
        Route::get('indicatorCategories', [\App\Http\Controllers\IndicatorCategoryController::class, 'index'])->name('indicatorCategories');
        Route::get('indicatorCategoryForm/{indicator_category_id?}', [\App\Http\Controllers\IndicatorCategoryController::class, 'form'])->name('indicatorCategoryForm');
        Route::post('indicatorCategorySave', [\App\Http\Controllers\IndicatorCategoryController::class, 'save'])->name('indicatorCategorySave');
        Route::get('indicatorCategoryDelete/{indicator_category_id}', [\App\Http\Controllers\IndicatorCategoryController::class, 'delete'])->name('indicatorCategoryDelete');

        // units
        Route::get('units', [\App\Http\Controllers\UnitController::class, 'index'])->name('units');
        Route::get('unitForm/{unit_id?}', [\App\Http\Controllers\UnitController::class, 'form'])->name('unitForm');
        Route::post('unitSave', [\App\Http\Controllers\UnitController::class, 'save'])->name('unitSave');
        Route::get('unitDelete/{unit_id}', [\App\Http\Controllers\UnitController::class, 'delete'])->name('unitDelete');

        // indicators
        Route::get('indicators', [\App\Http\Controllers\IndicatorController::class, 'index'])->name('indicators');
        Route::get('indicatorForm/{indicator_id?}', [\App\Http\Controllers\IndicatorController::class, 'form'])->name('indicatorForm');
        Route::post('indicatorSave', [\App\Http\Controllers\IndicatorController::class, 'save'])->name('indicatorSave');
        Route::get('indicatorDelete/{indicator_id}', [\App\Http\Controllers\IndicatorController::class, 'delete'])->name('indicatorDelete');

        // companies
        Route::get('companies', [\App\Http\Controllers\CompanyController::class, 'index'])->name('companies');
        Route::get('companyForm/{company_id?}', [\App\Http\Controllers\CompanyController::class, 'form'])->name('companyForm');
        Route::post('companySave', [\App\Http\Controllers\CompanyController::class, 'save'])->name('companySave');
        Route::get('companyDelete/{company_id}', [\App\Http\Controllers\CompanyController::class, 'delete'])->name('companyDelete');

        // offices
        Route::get('offices/{company_id}', [\App\Http\Controllers\OfficeController::class, 'index'])->name('offices');
        Route::get('officeForm/{company_id}/{office_id?}', [\App\Http\Controllers\OfficeController::class, 'form'])->name('officeForm');
        Route::post('officeSave', [\App\Http\Controllers\OfficeController::class, 'save'])->name('officeSave');
        Route::get('officeDelete/{office_id}', [\App\Http\Controllers\OfficeController::class, 'delete'])->name('officeDelete');

        //users
        Route::get('users', [\App\Http\Controllers\UserController::class, 'index'])->name('users');
        Route::get('userForm/{user_id?}', [\App\Http\Controllers\UserController::class, 'form'])->name('userForm');
        Route::post('userSave', [\App\Http\Controllers\UserController::class, 'save'])->name('userSave');
        Route::get('userDelete/{user_id}', [\App\Http\Controllers\UserController::class, 'delete'])->name('userDelete');
    });
});
