<?php

use App\Http\Controllers\UserController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\DatarepositoryController;
use App\Http\Controllers\CompanyController;
use App\Http\Controllers\QuicklinkController;
use App\Http\Controllers\QuicklinkCategoryController;
use App\Http\Controllers\NewsController;
use App\Http\Controllers\CropController;
use App\Http\Controllers\FrontendController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\RequestController;
use App\Http\Controllers\InquiryController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\MyController;
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!
|
*/
define('PAGELIMIT','30');
define('CONTACTMAIL','test6@bgp.com');
define('TITLE','BGP Oman');
define('ENVIRONMENT','Staging');

Route::get('/', [FrontendController::class, 'index'])
    ->name('index');

Route::get('/categories', [FrontendController::class, 'categoriesList'])
    ->name('categories');

Route::post('/frontend/users/store', [FrontendController::class, 'store'])
        ->name('frontendusers.store');

Route::post('/frontend/users/login', [FrontendController::class, 'login'])
        ->name('frontendusers.login');

Route::post('/checkemailexists', [FrontendController::class, 'checkemailexists'])
        ->name('frontendusers.checkemailexists');

Route::get('/frontend/users/logout', [FrontendController::class, 'logout'])
        ->name('frontendusers.logout');

Route::post('/forgotpassword', [FrontendController::class, 'forgotpassword'])
         ->name('frontendusers.forgotpassword');

Route::get('/recoverpassword/{key}', [FrontendController::class, 'recoverPassword'])
        ->name('frontendusers.resetpassword');

Route::post('/recoverpassword/{key}', [FrontendController::class, 'recoverPassword'])
        ->name('frontendusers.resetpassword');

Route::get('/datarepository', [FrontendController::class, 'datarepositoryListing'])
         ->name('frontendusers.datarepolisting');      

Route::get('/news', [FrontendController::class, 'newsListing'])
        ->name('frontendusers.newslisting'); 

Route::get('/newsdetails/{id}', [FrontendController::class, 'newsDetails'])
        ->name('frontendusers.newslisting');   

Route::get('/newssearch', [FrontendController::class, 'newsSearch'])
        ->name('frontendusers.newssearch');

Route::get('/quicklinks', [FrontendController::class, 'quicklinkListing'])
        ->name('frontendusers.qucklinklisting');

Route::get('/quicklinks/{cat_id}', [FrontendController::class, 'quicklinkListing'])
        ->name('frontendusers.qucklinklisting');

Route::get('users/accountactivation/{key}', [CompanyController::class, 'accountActivation'])
        ->name('company.invitemail'); 

Route::post('users/accountactivation/{key}', [CompanyController::class, 'accountActivation'])
        ->name('company.invitemail');   

Route::get('download/{id}', [FrontendController::class, 'downloadDetails'])
        ->name('frontendusers.download');  

Route::get('quicklinks/downloads/{id}', [FrontendController::class, 'QuicklinkDownloadDetails'])
        ->name('frontendusers.quicklinkdownload');

Route::get('downloads', [FrontendController::class, 'downloadedFileDetails'])
        ->name('frontendusers.downloads');

Route::post('downloads/triggercategory', [FrontendController::class, 'triggerCategory'])
        ->name('frontendusers.triggercategory');  

Route::get('aboutus', [FrontendController::class, 'aboutInfo'])
        ->name('frontendusers.aboutus'); 

Route::get('termsandconditions', [FrontendController::class, 'terms'])
        ->name('frontendusers.termsandconditions'); 

Route::get('privacypolicy', [FrontendController::class, 'privacyPolicy'])
        ->name('frontendusers.privacypolicy'); 

Route::get('disclaimer', [FrontendController::class, 'disclaimer'])
        ->name('frontendusers.disclaimer');  

Route::get('profile', [FrontendController::class, 'profile'])
        ->name('frontendusers.profile');

Route::get('profile-edit', [FrontendController::class, 'Editprofile'])
        ->name('frontendusers.Editprofile');

Route::post('frontendprofile/update', [FrontendController::class, 'Updateprofile'])
        ->name('frontendusers.Updateprofile');

Route::post('triggersubcategory',[FrontendController::class,'triggerSubcategory'])
        ->name('frontendusers.triggersubcategory');

Route::get('search',[FrontendController::class,'searchItems'])
        ->name('frontendusers.searchItems');

Route::get('contactus',[FrontendController::class,'contactInfo'])
        ->name('frontendusers.contactus');

Route::post('contactsubmit',[FrontendController::class,'contactInfo'])
        ->name('frontendusers.contactsubmit');

Route::post('requestaccess',[FrontendController::class,'requestAccess'])
        ->name('frontendusers.requestaccess');

Route::post('filerequestaccess',[FrontendController::class,'fileRequestAccess'])
        ->name('frontendusers.requestaccess');

Route::post('requestaccessform',[FrontendController::class,'requestAccessForm'])
        ->name('frontendusers.requestaccessform');



require __DIR__.'/auth.php';

Route::get('export', [MyController::class, 'export'])->name('export');

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

    Route::get('/dashboard', [UserController::class, 'index'])
    ->name('dashboard');

    /* Admins */
    Route::get('/admins/list', [UserController::class, 'list'])
        ->name('users.list');

    Route::post('/admins/destroy', [UserController::class, 'destroy'])
        ->name('users.destroy');

    Route::get('/admins/create', [UserController::class, 'create'])
        ->name('users.create');

    Route::post('/admins/store', [UserController::class, 'store'])
        ->name('users.store');

    Route::post('/admin/changepassword', [UserController::class, 'changePassword'])
        ->name('users.changePassword');

    Route::get('/admins/edit/{id}', [UserController::class, 'edit'])
        ->name('users.edit');

    Route::post('/admins/update/{id}', [UserController::class, 'update'])
        ->name('users.update');

    Route::get('/admins', [UserController::class, 'index'])
        ->name('users.index');

    Route::get('/admins/list/{status}', [UserController::class, 'list'])
        ->name('users.list');

    Route::get('/admins/list/{status}/{alpha}', [UserController::class, 'list'])
        ->name('users.listing');

    Route::post('admins/activate/{id}', [UserController::class, 'activateAdmin'])
        ->name('admins.activate');   

    /* Users */    
    Route::get('/users/list', [CompanyController::class, 'list'])
        ->name('company.list');

    Route::get('/users/list/{status}', [CompanyController::class, 'list'])
        ->name('company.list'); 

    Route::get('/users/list/{status}/{alpha}', [CompanyController::class, 'list'])
        ->name('company.listing'); 

    Route::post('users/activate/{id}', [CompanyController::class, 'activateUser'])
        ->name('users.activate'); 

    Route::post('users/changestatus', [CompanyController::class, 'changestatus'])
        ->name('users.changestatus');   

    Route::post('users/sendinvitation', [CompanyController::class, 'sendInvitation'])
        ->name('users.sendinvitation');  

    Route::post('users/resendinvitation', [CompanyController::class, 'sendInvitation'])
        ->name('users.resendinvitation');     

    Route::resource('users', CompanyController::class, ['names' => [
            'index' => 'company.index',
            'create' => 'company.create',
            'store' => 'company.store',
            'edit' => 'company.edit',
            'update' => 'company.update',
            'destroy' => 'company.destroy'
        ]]);
    
    /* Categories */
    Route::get('/datarepositories/categories/list', [CategoryController::class, 'list'])
        ->name('categories.list'); 

    Route::resource('/datarepositories/categories', CategoryController::class);

     Route::get('/datarepositories/categories/list/{status}', [CategoryController::class, 'list'])
        ->name('categories.list');

    Route::post('datarepositories/categories/activate/{id}', [CategoryController::class, 'activateCategory'])
        ->name('categories.activate'); 

    Route::get('/categories/subcategories/list/{id}/{status}', [CategoryController::class, 'subcategorieslisting'])
        ->name('categories.subcategorieslisting');

    Route::post('categories/subcategories/activate/{id}', [CategoryController::class, 'activateSubcategory'])
        ->name('subcategories.activate');  
    
    Route::post('/categories/subcategories/create'
        , [CategoryController::class, 'subcategoriesstore'])
        ->name('categories.subcategoriesstore');

    Route::post('/categories/subcategories/edit', [CategoryController::class, 'subcategoriesedit'])
        ->name('categories.subcategoriesedit');

    Route::post('/categories/subcategories/update', [CategoryController::class, 'subcategoriesupdate'])
        ->name('categories.subcategoriesupdate');

    Route::delete('/categories/subcategories/delete/{id}', [CategoryController::class, 'subcategoriesdestroy'])
        ->name('categories.subcategoriesdestroy');

    /* Datarepositories */

     Route::post('datarepository/triggersubcategory',[DatarepositoryController::class,'triggerSubcategory'])
        ->name('datarepositories.triggersubcategory');

    Route::post('datarepositoryedit/triggersubcategory',[DatarepositoryController::class,'triggerSubcategoryEdit'])
        ->name('datarepositories.triggersubcategoryedit');  
        
     Route::post('/activate/{id}', [DatarepositoryController::class, 'activateDatarepo'])
        ->name('datarepositories.activate');

    Route::post('/datarepositories/publish/{id}', [DatarepositoryController::class, 'PublishDatarepo'])
        ->name('datarepositories.publish');
        

     Route::post('/draft/{id}', [DatarepositoryController::class, 'draftDatarepo'])
        ->name('datarepositories.draft');

    Route::post('/datarepositories/{id}', [DatarepositoryController::class, 'update'])
        ->name('datarepositories.update');

    Route::get('/datarepositories/list/{status}', [DatarepositoryController::class, 'list'])
        ->name('datarepositories.list');

    Route::post('request/revoke',[DatarepositoryController::class,'revokeRequest'])
        ->name('requests.revokerequest'); 


    Route::resource('datarepositories', DatarepositoryController::class);   

    /* Quicklinks Categories*/

    Route::get('quicklinkcategories/list', [QuicklinkCategoryController::class, 'list'])
        ->name('quicklinkcategories.list'); 

    Route::resource('quicklinkcategories', QuicklinkCategoryController::class);   

    Route::post('quicklinkcategories/activate/{id}', [QuicklinkCategoryController::class, 'activateCategory'])
        ->name('quicklinkcategories.activate');   

    Route::get('quicklinkcategories/list/{status}', [QuicklinkCategoryController::class, 'list'])
        ->name('quicklinkcategories.list');

    /* Quicklinks */
    Route::post('/quicklinkslist/{id}', [QuicklinkController::class, 'update'])
        ->name('quicklinkslist.update');

    Route::get('/quicklinks/list', [QuicklinkController::class, 'list'])
        ->name('quicklinks.list');

    Route::resource('quicklinkslist', QuicklinkController::class);  

    Route::get('quicklinks/list/{status}', [QuicklinkController::class, 'list'])
        ->name('quicklinks.list'); 

    Route::post('quicklinks/activate/{id}', [QuicklinkController::class, 'activateQuicklink'])
        ->name('quicklinks.activate');   

     Route::post('quicklinks/publish/{id}', [QuicklinkController::class, 'publishQuicklink'])
        ->name('quicklinks.publish');   
        
    Route::post('quicklinks/draft/{id}', [QuicklinkController::class, 'draftQuicklink'])
        ->name('quicklinks.draft');    

     /* News */
    
    Route::get('/news/list', [NewsController::class, 'list'])
        ->name('news.list');

    Route::resource('newslist', NewsController::class);   

    Route::get('news/list/{status}', [NewsController::class, 'list'])
        ->name('news.list'); 

    Route::post('news/activate/{id}', [NewsController::class, 'activateNews'])
        ->name('news.activate');

     Route::post('news/publish/{id}', [NewsController::class, 'publishNews'])
        ->name('news.publish');   
        
    Route::post('news/draft/{id}', [NewsController::class, 'draftNews'])
        ->name('news.draft');  

    Route::get('crop/{type}' , [CropController::class, 'index'])
        ->name('profile.crop');

    Route::post('crop/{type}' , [CropController::class, 'index'])
        ->name('profile.crop');

    /* Reports */

    Route::get('reports/contentaccess', [ReportController::class, 'contentReportList'])
        ->name('reports.contentaccessreports'); 

    Route::get('userspecificreports', [ReportController::class, 'userSpecificReportList'])
        ->name('reports.userspecificreports');

    Route::post('userspecificreports', [ReportController::class, 'userSpecificReportList'])
        ->name('reports.userspecificreports'); 

    Route::post('reports/contentaccess', [ReportController::class, 'contentReportList'])
        ->name('reports.contentReportList'); 

    Route::post('reports/triggercategory',[ReportController::class,'triggerCategory'])
        ->name('reports.triggercategory');

    Route::post('reports/triggersubcategory',[ReportController::class,'triggerSubcategory'])
        ->name('reports.triggersubcategory'); 

    Route::get('reports/docnamesearch',[ReportController::class,'docnameSearch'])
        ->name('reports.docnamesearch');  

    Route::get('reports/doctitlesearch',[ReportController::class,'doctitleSearch'])
        ->name('reports.doctitlesearch'); 

    Route::get('reports/usernamesearch',[ReportController::class,'usernameSearch'])
        ->name('reports.usernamesearch');  

    /* File access requests*/

    Route::get('requestaccesslist',[RequestController::class,'requestAccess'])
        ->name('requests.requestaccesslist');

    Route::get('requestaccesslist/{status}',[RequestController::class,'requestAccess'])
        ->name('requests.requestaccesslist');  

     Route::post('request/view',[RequestController::class,'viewRequest'])
        ->name('requests.viewrequest');  

    Route::post('request/approve/{id}',[RequestController::class,'approveRequestAcess'])
        ->name('requests.approverequest');  

    Route::post('request/reject/{id}',[RequestController::class,'rejectRequestAcess'])
        ->name('requests.rejectrequest'); 

    Route::post('filerequest/approve/{id}',[RequestController::class,'approveFileRequestAcess'])
        ->name('requests.approverequest');  

    Route::post('filerequest/reject/{id}',[RequestController::class,'rejectFileRequestAcess'])
        ->name('requests.rejectrequest'); 


    /* inquiries */

    Route::get('inquiries',[InquiryController::class,'list'])
        ->name('inquiries.list'); 

    Route::post('inquiry/view',[InquiryController::class,'viewInquiry'])
        ->name('requests.viewrequest'); 

    /* myprofile */

    Route::get('myprofile',[ProfileController::class,'edit'])
        ->name('myprofile.edit'); 

    Route::post('/profile/update/',[ProfileController::class,'update'])
        ->name('myprofile.update'); 

    Route::post('/profile/changepassword', [ProfileController::class, 'changePassword'])
        ->name('myprofile.changePassword');

});