<?php

use App\Http\Controllers\AntibioticController;
use App\Http\Controllers\BaseController;
use App\Http\Controllers\CommentController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\InvoiceController;
use App\Http\Controllers\OrganismController;
use App\Http\Controllers\PatientController;
use App\Http\Controllers\PatientTypeController;
use App\Http\Controllers\PhysicianController;
use App\Http\Controllers\QuantityController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\SampleController;
use App\Http\Controllers\SampleSourceController;
use App\Http\Controllers\SampleTypeController;
use App\Http\Controllers\TestController;
use App\Http\Controllers\TestGroupController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\UtilController;
use App\Http\Middleware\VerifyBaseLab;
use App\Models\User;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\AuthController;
use App\Http\Controllers\OrganizationController;
use App\Http\Controllers\DepartmentController;
use App\Http\Controllers\ShareController;
use App\Http\Controllers\TelegramController;

use App\Http\Controllers\PublicationController;
use App\Http\Controllers\RepaymentController;
use App\Http\Controllers\AppointmentController;
use App\Http\Controllers\ActivityLogsController;

/*
|--------------------------------------------------------------------------
| 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!
|
*/

Route::get('/lang/{locale}', function ($locale){
    session(['locale' => $locale]);
    App::setLocale($locale);
    return redirect()->back();
});

Route::get('/telescope', function () {
    Gate::define('viewTelescope', function (User $user) {
        return in_array($user->email, [
            'taylor@laravel.com',
        ]);
    });
});

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

Route::post('do_login', [AuthController::class, 'do_login'])->name('auth.do_login');


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

    Route::get('/base', [BaseController::class, 'index'])->name('base');
    Route::post('base.save', [BaseController::class, 'store'])->name('base.save');
    Route::get('base.forget', [BaseController::class, 'forget'])->name('base.change');

    Route::get('/laboratory-profile', [OrganizationController::class, 'profile'])->name('laboratory-profile');
    Route::post('/laboratory-profile/save', [OrganizationController::class, 'labSettingSetters']);
    Route::post('/laboratory-profile/configure/save', [OrganizationController::class, 'saveLabConfigure']);
    Route::post('/laboratory-profile/avatar/upload', [OrganizationController::class, 'uploadImage']);
    Route::post('/laboratory-profile/avatar/remove', [OrganizationController::class, 'removeLabLogo']);

    Route::post('/laboratory-profile/update', [OrganizationController::class, 'updateInfo'])->middleware(VerifyBaseLab::class);


    Route::post('/laboratory-profile/verifies/upload', [OrganizationController::class, 'uploadVerifyImage']);
    Route::post('/laboratory-profile/verifies/remove', [OrganizationController::class, 'removeVerifyImage']);

	Route::post('/laboratory-profile/alter-verify-sign/upload', [OrganizationController::class, 'uploadAlterVerifySignature']);
    Route::post('/laboratory-profile/alter-verify-sign/remove', [OrganizationController::class, 'removeAlterVerifySignature']);
	Route::post('/laboratory-profile/alter-labtech-sign/upload', [OrganizationController::class, 'uploadAlterLabtechSignature']);
    Route::post('/laboratory-profile/alter-labtech-sign/remove', [OrganizationController::class, 'removeAlterLabtechSignature']);


	Route::post('/laboratory-profile/alternative-logo/upload', [OrganizationController::class, 'uploadAlternativeLogo']);
    Route::post('/laboratory-profile/alternative-logo/remove', [OrganizationController::class, 'removeAlternativeLogo']);

    Route::post('/laboratory-profile/default-footer/upload', [OrganizationController::class, 'uploadDefaultFooter']);
    Route::post('/laboratory-profile/default-footer/remove', [OrganizationController::class, 'removeDefaultFooter']);

    Route::post('/laboratory-profile/alternative-footer/upload', [OrganizationController::class, 'uploadAlternativeFooter']);
    Route::post('/laboratory-profile/alternative-footer/remove', [OrganizationController::class, 'removeAlternativeFooter']);

    Route::get('laboratory', [OrganizationController::class, 'index'])->name('laboratory')->middleware(VerifyBaseLab::class);

    Route::get('laboratory/search', [OrganizationController::class, 'index'])->name('laboratory.search')->middleware(VerifyBaseLab::class);
    Route::post('laboratory.save', [OrganizationController::class, 'save'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.get', [OrganizationController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.update', [OrganizationController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.delete', [OrganizationController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.restore', [OrganizationController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('user', [UserController::class, 'index'])->name('user')->middleware(VerifyBaseLab::class);
    Route::get('lab-users', [UserController::class, 'labUsers'])->name('lab_user')->middleware(VerifyBaseLab::class);
    Route::get('user/search', [UserController::class, 'index'])->name('user.search')->middleware(VerifyBaseLab::class);
    Route::post('user.save', [UserController::class, 'save'])->middleware(VerifyBaseLab::class);
    Route::post('user.get', [UserController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('user.update', [UserController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('user.delete', [UserController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('user.restore', [UserController::class, 'restore'])->middleware(VerifyBaseLab::class);
    Route::post('user.assign-labs', [UserController::class, 'assignLabs'])->middleware(VerifyBaseLab::class);


    Route::post('user/profile/signature/upload', [UserController::class, 'uploadSignature']);
    Route::post('user/profile/signature/remove', [UserController::class, 'removeSignature']);
    Route::post('user/password/change', [UserController::class, 'changePassword'])->name('profile.change_password')->middleware(VerifyBaseLab::class);

    Route::post('user.reset_password', [UserController::class, 'resetPassword'])->middleware(VerifyBaseLab::class);


    Route::get('role', [RoleController::class, 'index'])->name('role')->middleware(VerifyBaseLab::class);
    Route::get('role/search', [RoleController::class, 'index'])->name('role.search')->middleware(VerifyBaseLab::class);
    Route::post('role.save', [RoleController::class, 'save'])->middleware(VerifyBaseLab::class);
    Route::post('role.get', [RoleController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('role.update', [RoleController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('role.delete', [RoleController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('role.restore', [RoleController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('organism', [OrganismController::class, 'index'])->name('organism')->middleware(VerifyBaseLab::class);
    Route::get('organism/search', [OrganismController::class, 'index'])->name('organism.search')->middleware(VerifyBaseLab::class);
    Route::post('organism.save', [OrganismController::class, 'save'])->name('organism.save')->middleware(VerifyBaseLab::class);
    Route::post('organism.get', [OrganismController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('organism.update', [OrganismController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('organism.delete', [OrganismController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('organism.restore', [OrganismController::class, 'restore'])->middleware(VerifyBaseLab::class);


    Route::prefix('system')->group(function (){
        Route::get('/role-permission/{role_id}', [RoleController::class, 'viewPermissionByRoleId'])->middleware(VerifyBaseLab::class);
        Route::post('/role-permission', [RoleController::class, 'storeRolePermission'])->middleware(VerifyBaseLab::class);
    });

    Route::prefix('dashboard')->group(function (){
        Route::get('/', [DashboardController::class, 'index'])->name('homepage')->middleware(VerifyBaseLab::class);
        Route::get('/trend/samples-comparison', [DashboardController::class, 'samplesYearComparison'])->middleware(VerifyBaseLab::class);
        Route::get('/trend/revenue-comparison', [DashboardController::class, 'revenueYearComparison'])->middleware(VerifyBaseLab::class);
        Route::get('filter/samples', [DashboardController::class, 'filter_sample'])->middleware(VerifyBaseLab::class);
        Route::get('filter/income', [DashboardController::class, 'filter_income'])->middleware(VerifyBaseLab::class);
        Route::get('filter/patient', [DashboardController::class, 'filter_patient'])->middleware(VerifyBaseLab::class);
        Route::get('filter/rejected-sample', [DashboardController::class, 'filter_rejected_sample'])->middleware(VerifyBaseLab::class);
        Route::get('/source-distribution', [DashboardController::class, 'getSampleSourceByDistributor'])->middleware(VerifyBaseLab::class);
        Route::get('/panel-distribution', [DashboardController::class, 'getPanelDistributor'])->middleware(VerifyBaseLab::class);
    });
    //Activity Log Route
    Route::get('/activity-logs', [ActivityLogsController::class, 'index'])->name('activity-logs')->middleware(VerifyBaseLab::class);
    Route::get('/audit-logs', [ActivityLogsController::class,'index'])->name('audit.logs')->middleware(VerifyBaseLab::class);
    Route::get('/audit-logs/data', [ActivityLogsController::class,'data'])->name('audit.logs.data')->middleware(VerifyBaseLab::class);

    Route::get('publication', [PublicationController::class, 'index'])->name('publication')->middleware(VerifyBaseLab::class);
    Route::get('publication/search', [PublicationController::class, 'index'])->name('publication.search')->middleware(VerifyBaseLab::class);
    Route::post('publication.save', [PublicationController::class, 'save'])->name('publication.save')->middleware(VerifyBaseLab::class);
    Route::post('publication.get', [PublicationController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('publication.update', [PublicationController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('publication.delete', [PublicationController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('publication.restore', [PublicationController::class, 'restore'])->middleware(VerifyBaseLab::class);
    Route::get('publication/read/{id}', [PublicationController::class, 'read'])->middleware(VerifyBaseLab::class);

    /** end block share routes */


});

require __DIR__.'/auth.php';
