<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\EmployeeController;
use App\Http\Controllers\ClaimController;
use App\Http\Controllers\ClaimReportController;
use App\Http\Controllers\CaseController;
use App\Http\Controllers\CaseReportController;
use App\Http\Controllers\RemarkController;
/*
|--------------------------------------------------------------------------
| 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('create/superadmin',[DashboardController::class,'createSuperAdmin']);
Route::get('/login',[LoginController::class,'showLoginForm'])->name('login');
Route::post('/login-post',[LoginController::class,'signIn'])->name('login-post');

Route::get('/home',[DashboardController::class,'homepage'])->name('home.page');
Route::get('/search/applicantname', [DashboardController::class, 'searchApplicantWise'])->name('search_nameapplicant');
Route::get('/search/defendentname', [DashboardController::class, 'defendentnamewise'])->name('search_namedefendent');
Route::get('/search/casenumberwise', [DashboardController::class, 'casenumberwise'])->name('search_casenumberwise');
Route::get('/search/casecourtwise', [DashboardController::class, 'casecourtwise'])->name('search_courtnamewise');
Route::get('/search/casetypewise', [DashboardController::class, 'searchcasetypewise'])->name('search_casetypewise');
Route::get('/search/datewise', [DashboardController::class, 'searchdatewise'])->name('search_casedatewise');

// Route::get('/', function () {
//     return view('welcome');
// });
Route::get('/', function () {
    // return view('pages.dashboard');
    return redirect('home');
});

Auth::routes();

// Auth 
Route::group(['middleware' => ['auth']],function() {
    // Dashboard
    Route::get('/dashboard',[DashboardController::class,'index'])->name('dashboard');
    Route::post('reset/user/password',[DashboardController::class,'resetPassword'])->name('reset.user.password');
    Route::get('send/mail',[DashboardController::class,'sendMailToClient'])->name('send.mail');
    Route::get('download/froms',[DashboardController::class,'downloadForms'])->name('download.forms');

    // Dashboard API
    Route::post('/case/chart/data',[DashboardController::class,'caseBarChartData'])->name('case.chart.data');
    Route::post('/claim/chart/data',[DashboardController::class,'claimBarChartData'])->name('claim.chart.data');

    // Login
    Route::get('/logout',[LoginController::class,'signOut'])->name('logout');

    // Employees 
    Route::get('/create/new/employee',[EmployeeController::class,'create'])->name('create.new.employee');
    Route::post('/store/new/employee',[EmployeeController::class, 'store'])->name('store.new.employee');
    Route::get('/list/all/employees',[EmployeeController::class,'index'])->name('list.all.employees');
    Route::get('/edit/employee/{id}',[EmployeeController::class,'edit'])->name('edit.employee');
    Route::post('/update/employee',[EmployeeController::class,'update'])->name('update.employee');
    Route::get('/deactivate/employee/{id}',[EmployeeController::class,'deactivate'])->name('deactivate.employee');
    Route::get('/user/profile/{id}',[EmployeeController::class,'profile'])->name('user.profile');
    Route::get('/edit/profile/{id}',[EmployeeController::class,'editProfile'])->name('edit.profile');
    Route::post('/update/profile',[EmployeeController::class,'updateProfile'])->name('update.profile');
    Route::get('/user/change/password/{id}',[EmployeeController::class,'changePassword'])->name('user.change.password');
    Route::post('/user/update/password',[EmployeeController::class,'updatePassword'])->name('user.update.password');
    Route::post('/update/profile/image',[EmployeeController::class,'updateProfileImage'])->name('update.profile.image');

    // Claims
    Route::get('/create/new/claim',[ClaimController::class,'create'])->name('create.new.claim');
    Route::post('/store/new/claim',[ClaimController::class, 'store'])->name('store.new.claim');
    Route::get('/next/claim/form/{claim_id}',[ClaimController::class, 'nextForm'])->name('next.claim.form');
    Route::post('/store/next/form/data',[ClaimController::class, 'storeNextForm'])->name('store.next.claim.form');
    Route::get('/list/all/claims',[ClaimController::class,'index'])->name('list.all.claims');
    Route::get('/view/claim/{claim_id}',[ClaimController::class,'show'])->name('view.claim.details');
    // Route::get('/update/claim/status/{claim_id}/{claim_for}',[ClaimController::class,'updateClaimStatus'])->name('update.claim.status');
    Route::post('/update/claim/status',[ClaimController::class,'saveUpdateClaimStatus'])->name('save.update.claim.status');
    Route::get('/edit/claim/info/{claim_id}',[ClaimController::class,'editClaim'])->name('edit.claim.info');
    Route::post('/update/claim/info',[ClaimController::class,'updateClaim'])->name('update.claim.info');
    Route::get('/edit/next/claim/form/{claim_id}/{claim_for}',[ClaimController::class, 'editNextForm'])->name('edit.next.claim.form');
    Route::post('/update/next/claim/form',[ClaimController::class, 'updateNextForm'])->name('update.next.claim.form');
    
    // Upload Claim Document
    Route::get('/upload/claim/document/{applied_claim_id}',[ClaimController::class, 'uploadClaimDocuments'])->name('upload.claim.document');
    Route::post('/store/claim/document',[ClaimController::class, 'storeClaimDocuments'])->name('store.claim.document');

    //Claims API
    Route::get('/load/divions',[ClaimController::class,'loadDivisions'])->name('load.divions');
    Route::get('/load/scheme',[ClaimController::class,'loadSchemes'])->name('load.schemes');
    Route::get('/load/posting/places',[ClaimController::class,'loadPostingPlace'])->name('load.posting.places');
    Route::get('/get/emp/details',[ClaimController::class,'getEmployeeDetails'])->name('get.emp.details');
    Route::get('/check/claim',[ClaimController::class,'checkClaimSaved'])->name('check.claim');

    // Claim Report
    Route::get('/claim/report/summary',[ClaimReportController::class,'reportSummary'])->name('claim.report.summary');
    Route::post('get/claim/report/summary',[ClaimReportController::class,'getReportSummary'])->name('get.claim.report.summary');
    Route::get('/detailed/claim/report',[ClaimReportController::class,'detailedClaimReport'])->name('detailed.claim.report');
    Route::post('get/detailed/claim/report',[ClaimReportController::class,'getdetailedClaimReport'])->name('get.detailed.claim.report');

    // Claim Report Summary Details
    Route::get('/claim/report/summarydetails/{type}/{claim_id?}',[ClaimReportController::class,'reportSummaryDetails'])->name('claim.report.summary.details');

    // export claim excel file
    Route::get('/export/claim/excel/',[ClaimReportController::class,'downloadClaimExcel'])->name('export.claim.excel');

    // Cases
    Route::get('/create/new/case/{type}/{claim_id?}',[CaseController::class,'create'])->name('create.new.case');
    Route::post('/store/new/case',[CaseController::class, 'store'])->name('store.new.case');
    Route::get('/list/all/cases',[CaseController::class,'index'])->name('list.all.cases');
    Route::get('/view/cases/{case_id}',[CaseController::class,'show'])->name('view.cases.details');
    Route::get('/edit/cases/{case_id}',[CaseController::class,'edit'])->name('edit.cases');
    Route::post('/update/cases',[CaseController::class,'update'])->name('update.cases');

    // Case API
    Route::get('/check/cases',[CaseController::class,'checkCase'])->name('check.cases');


    // Cases Hearings 
    Route::get('/update/hearing/{case_id}',[CaseController::class,'updateHearing'])->name('update.hearing');
    Route::post('/save/case/hearing',[CaseController::class,'saveCaseHearing'])->name('save.case.hearing');

    // Cases Report
    Route::get('/case/report/summary',[CaseReportController::class,'reportSummary'])->name('case.report.summary');
    Route::post('get/case/report/summary',[CaseReportController::class,'getReportSummary'])->name('get.case.report.summary');
    Route::get('/detailed/case/report',[CaseReportController::class,'detailedClaimReport'])->name('detailed.case.report');
    Route::post('get/detailed/case/report',[CaseReportController::class,'getdetailedClaimReport'])->name('get.detailed.case.report');
    
    // export Case excel file
    Route::get('/export/case/excel/',[CaseReportController::class,'downloadCaseExcel'])->name('export.case.excel');


    // Remarks
    // Route::get('/create/new/remark/{type}/{parent_id}',[RemarkController::class,'create'])->name('create.new.remark');
    Route::get('/create/claim/remark/{type}/{parent_id}',[RemarkController::class,'create'])->name('create.claim.remark');
    Route::get('/create/case/remark/{type}/{parent_id}',[RemarkController::class,'create'])->name('create.case.remark');
    Route::post('/store/remark',[RemarkController::class,'store'])->name('store.remark');
    Route::get('/view/remark/{type}/{parent_id}',[RemarkController::class,'view'])->name('view.remark');
    Route::get('/case/report/summarydetails/{type}/{claim_id?}',[CaseReportController::class,'reportSummaryDetails'])->name('case.report.summary.details');
    
    Route::get('/list/all/pendingcases',[CaseController::class,'allpendingcases'])->name('list.allpending.cases');
    Route::post('date/hearingdate',[DashboardController::class,'datefilter'])->name('datefilter.data');
    
    //akash chaudhary 26-07-2024
    Route::delete('/delete/case/data/{id}',[CaseController::class,'closedcasedelet'])->name('case.delete');
    Route::get('/closed/all/cases',[CaseController::class,'closedcase'])->name('done.case.list');
    Route::get('/update/hearing/cancel/{case_id}',[CaseController::class,'updateHearingdone'])->name('update.hearing.done');
    
    
    
});
