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

Route::get('/test',[\App\Http\Controllers\DebugController::class, 'testing']);

Route::get('/terms-of-service', [\App\Http\Controllers\BasicController::class,'termsAndCondition'])->name('terms.of.service.view');

Route::get('/', [\App\Http\Controllers\AuthController::class,'authRedirect'])->name('auth.redirect');

Route::get('/login', [\App\Http\Controllers\AuthController::class,'showLoginForm'])->name('login');

Route::post('/login', [\App\Http\Controllers\AuthController::class,'login'])->name('post.login');

Route::view('/user/{any?}', 'layouts.register')->where('any', '.*')->name('register');

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

        Route::group(['middleware'=>['permission:admin','permissionroute']],function (){
            Route::match(['get','post'],'/get-clients', [\App\Http\Controllers\UserController::class, 'getAllClient'])->name('get.clients');
            Route::get('/training-video', [\App\Http\Controllers\TrainingVideoController::class, 'list'])->name('training_video.list');
            Route::post('/add/training-video', [\App\Http\Controllers\TrainingVideoController::class, 'createTrainingVideo'])->name('create.video');
            Route::post('/update/training-video', [\App\Http\Controllers\TrainingVideoController::class, 'editTrainingVideo'])->name('update.video');
            Route::get('/process/get-ajax', [\App\Http\Controllers\AjaxController::class, 'getTrainingVideo'])->name('get.section.video');
            Route::get('/client/{id}', [\App\Http\Controllers\UserController::class, 'getClientInfo'])->name('get.client.info');
            Route::post('/update-client', [\App\Http\Controllers\UserController::class, 'updateClientInfo'])->name('update.client');
            Route::post('/update-client-id', [\App\Http\Controllers\UserController::class, 'updateClientInfoById'])->name('update.client.id');
            Route::post('/delete/training-video', [\App\Http\Controllers\TrainingVideoController::class, 'deleteTrainingVideo'])->name('delete.video');
            Route::match(['get','post'],'/recurring/list/{any?}', [\App\Http\Controllers\ReportController::class, 'recurringReport'])->name('recurring.report');
            Route::match(['get','post'],'/sales/list/{any?}', [\App\Http\Controllers\ReportController::class, 'salesReport'])->name('sales.report');
            Route::get('/delete-client/{id}', [\App\Http\Controllers\UserController::class, 'deleteClient'])->name('delete.client');
            Route::post('/process/admin-ajax', [\App\Http\Controllers\AjaxController::class, 'processAdminAjaxRequest'])->name('admin.ajax.process');
            Route::match(['get', 'post'],'/terms-of-service/create', [\App\Http\Controllers\BasicController::class,'termAndService'])->name('terms.of.service');
            Route::get('/security-question', [\App\Http\Controllers\SecurityQuestionController::class, 'index'])->name('security_question.list');
            Route::post('/add/security-question', [\App\Http\Controllers\SecurityQuestionController::class, 'createSecurityQuestion'])->name('create.security_question');
            Route::post('/change-admin-info', [\App\Http\Controllers\UserController::class, 'changeAdminInfo'])->name('change.admin_info');

            Route::get('/employee', [\App\Http\Controllers\UserController::class, 'employeeList'])->name('employee.list');
            Route::get('/add/employee', [\App\Http\Controllers\UserController::class, 'createEmployee'])->name('create.employee');
            Route::post('/add/employee', [\App\Http\Controllers\RegisterController::class, 'insertEmployee'])->name('insert.employee');
            Route::get('/employee/{id}', [\App\Http\Controllers\UserController::class, 'getEmployeeInfo'])->name('get.employee.info');
            Route::post('/update/employee', [\App\Http\Controllers\UserController::class, 'updateEmployeeInfo'])->name('update.employee');

            Route::get('/add/client', [\App\Http\Controllers\RegisterController::class, 'createAccount'])->name('client.create');
            Route::post('/add/client', [\App\Http\Controllers\RegisterController::class, 'createManualAccount'])->name('client.insert');

            Route::get('/report-provider', [\App\Http\Controllers\CreditReportProviderController::class, 'index'])->name('view.provider.link');
            Route::post('/add/report-provider', [\App\Http\Controllers\CreditReportProviderController::class, 'createReportProvider'])->name('create.provider.link');
            Route::post('/update/report-provider', [\App\Http\Controllers\CreditReportProviderController::class, 'editReportProvider'])->name('update.provider.link');
            Route::post('/delete/report-provider', [\App\Http\Controllers\CreditReportProviderController::class, 'deleteReportProvider'])->name('delete.provider.link');
        });

        Route::group(['middleware'=>['permission:client']],function (){
            Route::get('/manage-clients', [\App\Http\Controllers\UserController::class, 'showManageClient'])->name('show.manage.clients');
            Route::post('/manage-clients', [\App\Http\Controllers\UserController::class, 'manageClient'])->name('manage.clients');
            Route::post('/create/payment', [\App\Http\Controllers\PaymentController::class, 'paymentSetting'])->name('payment.create');
            Route::get('/training-videos', [\App\Http\Controllers\TrainingVideoController::class, 'index'])->name('training_video.index');

            Route::match(['get', 'post'], '/test-get-letter', [\App\Http\Controllers\DebugController::class, 'getLetter'])->name('test.get.letter');
            Route::post('/test-generate-pdf', [\App\Http\Controllers\DebugController::class, 'generatePdf'])->name('test.generate.pdf');//
            Route::post('/test-generate-pdf-validate', [\App\Http\Controllers\DebugController::class, 'getGeneratedPdf'])->name('test.get.generated.pdf');

            Route::post('/upload-profile-image', [\App\Http\Controllers\UserController::class, 'uploadClientImage'])->name('upload.client.image');


            Route::group(['middleware'=>['checkSubscription']],function (){
                Route::match(['get', 'post'], '/get-letter', [\App\Http\Controllers\EpicVelocityController::class, 'getLetter'])->name('get.letter');
                Route::post('/generate-pdf', [\App\Http\Controllers\EpicVelocityController::class, 'generatePdf'])->name('generate.pdf');//
                Route::post('/generate-pdf-validate', [\App\Http\Controllers\EpicVelocityController::class, 'getGeneratedPdf'])->name('get.generated.pdf');
                Route::post('/upload/report', [\App\Http\Controllers\UserController::class, 'uploadCreditReport'])->name('upload.report');//
                Route::get('import/report', [\App\Http\Controllers\CreditReportController::class, 'getReport']);
                Route::post('/credit/report', [\App\Http\Controllers\CreditReportController::class, 'getCreditReport'])->name('get.credit.report');//
                Route::post('/upload/credit-report', [\App\Http\Controllers\CreditReportController::class, 'uploadCreditReport'])->name('upload.credit.report');

            });

        });

        Route::post('/add/client-support', [\App\Http\Controllers\SupportController::class, 'insertClientSupport'])->name('create.client.support');
        Route::match(['get', 'post'],'/client-support', [\App\Http\Controllers\SupportController::class, 'index'])->name('list.client.support');
        Route::get('/client-support/{id}', [\App\Http\Controllers\SupportController::class, 'view'])->name('view.client.support');
        Route::post('/client-support/add', [\App\Http\Controllers\SupportController::class, 'add'])->name('insert.client.support');
        Route::match(['get', 'post'],'/iq-call-histories', [\App\Http\Controllers\HistoryController::class, 'index'])->name('list.iq.history');

        Route::post('/user/logout', [\App\Http\Controllers\AuthController::class, 'userLogout'])->name('user.logout');
        Route::match(['get','post'],'/get/admin-ajax/', [\App\Http\Controllers\AjaxController::class, 'processAdminGetAjaxRequest'])->name('admin.ajax.get.process');
        Route::post('/process/ajax', [\App\Http\Controllers\AjaxController::class, 'processAjaxRequest'])->name('process.ajax');
        Route::post('/view/modal',[\App\Http\Controllers\ModalController::class,'showModal'])->name('show.modal');


});

Route::group(['prefix'=>'api','middleware' => 'requestValidate'],function () {

//    Route::post('create/account', [\App\Http\Controllers\RegisterController::class, 'createAccount']);
    Route::post('create/account', [\App\Http\Controllers\RegisterController::class, 'emailVerification']);
    Route::post('make/payment', [\App\Http\Controllers\RegisterController::class, 'makePaymentByUser']);
    Route::post('make/payments', [\App\Http\Controllers\RegisterController::class, 'makePayment']);
    Route::get('get/security_question', [\App\Http\Controllers\RegisterController::class, 'getSecurityQuestion']);
    Route::post('create/customer', [\App\Http\Controllers\RegisterController::class, 'createCustomer']);
    Route::post('customer/profile-verify', [\App\Http\Controllers\RegisterController::class, 'profileVerification']);
    Route::get('get/identity_question', [\App\Http\Controllers\RegisterController::class, 'getIdentityQuestionAnswer']);
    Route::post('post/identity_question', [\App\Http\Controllers\RegisterController::class, 'postIdentityQuestion']);
    Route::post('get/subscription', [\App\Http\Controllers\RegisterController::class, 'userValidationInCreditReportProvider'])->name('use.subscription');

    Route::group(['middleware' => 'requestValidate'], function () {
        Route::post('add/profile', [\App\Http\Controllers\RegisterController::class, 'addProfile']);
        Route::post('import/credit-report', [\App\Http\Controllers\RegisterController::class, 'importCreditReportForUser']);
        Route::get('get-user-info', [\App\Http\Controllers\RegisterController::class, 'getUserInfoById']);
    });

});

