<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\RolesController;
use App\Http\Controllers\PermissionController;

/*
|--------------------------------------------------------------------------
| 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('/', function () { return view('auth.login'); });
Route::get('/foo', function () {
    Artisan::call('storage:link');
});

Route::get('login', [LoginController::class,'showLoginForm'])->name('login');
Route::post('login', [LoginController::class,'login']);
Route::post('register', [RegisterController::class,'register']);

Route::get('password/forget',  function () { 
	return view('pages.forgot-password'); 
})->name('password.forget');
Route::post('password/email', [ForgotPasswordController::class,'sendResetLinkEmail'])->name('password.email');
Route::get('password/reset/{token}', [ResetPasswordController::class,'showResetForm'])->name('password.reset');
Route::post('password/reset', [ResetPasswordController::class,'reset'])->name('password.update');


Route::group(['middleware' => 'auth'], function(){
	// logout route
	Route::get('/logout', [LoginController::class,'logout']);
	Route::get('/clear-cache', [HomeController::class,'clearCache']);

	// dashboard route  
	Route::get('/dashboard', [HomeController::class,'dashboard'])->name('dashboard');
	Route::get('/user_logs', [HomeController::class,'user_logs'])->name('user_logs');

	//only those have manage_user permission will get access
	Route::group(['middleware' => 'can:manage_user'], function(){
	Route::get('/users', [UserController::class,'index'])->name('users');
	Route::post('/getdistrict', [UserController::class,'getdistrict'])->name('getdistrict');
	Route::post('/getartcenter', [UserController::class,'getartcenter'])->name('getartcenter');
	Route::get('/user/get-list', [UserController::class,'getUserList']);
		Route::get('/user/create', [UserController::class,'create']);
		Route::post('/user/create', [UserController::class,'store'])->name('create-user');
		Route::get('/user/{id}', [UserController::class,'edit']);
		Route::post('/user/update', [UserController::class,'update']);
		Route::post('/user/edit-profile', [UserController::class,'edit_user_profile'])->name('edit_user_profile');
		Route::get('/user/delete/{id}', [UserController::class,'delete']);
	});

	//only those have manage_role permission will get access
	Route::group(['middleware' => 'can:manage_role|manage_user'], function(){
		Route::get('/roles', [RolesController::class,'index']);
		Route::get('/role/get-list', [RolesController::class,'getRoleList']);
		Route::post('/role/create', [RolesController::class,'create']);
		Route::get('/role/edit/{id}', [RolesController::class,'edit']);
		Route::post('/role/update', [RolesController::class,'update']);
		Route::get('/role/delete/{id}', [RolesController::class,'delete']);
	});


	//only those have manage_permission permission will get access
	Route::group(['middleware' => 'can:manage_permission|manage_user'], function(){
		Route::get('/permission', [PermissionController::class,'index']);
		Route::get('/permission/get-list', [PermissionController::class,'getPermissionList']);
		Route::post('/permission/create', [PermissionController::class,'create']);
		Route::get('/permission/update', [PermissionController::class,'update']);
		Route::get('/permission/delete/{id}', [PermissionController::class,'delete']);
	});

	// get permissions
	Route::get('/get-role-permissions-badge', [PermissionController::class,'getPermissionBadgeByRole']);


	// permission examples
    Route::get('/permission-example', function () {
    	return view('permission-example'); 
    });
    // API Documentation
    Route::get('/rest-api', function () { return view('api'); });
    // Editable Datatable
	Route::get('/table-datatable-edit', function () { 
		return view('pages.datatable-editable'); 
	});

    Route::get('/profile', function () { return view('pages.profile'); });
    Route::get('/user-login', function () { return view('pages.user-login'); });
    Route::get('/state-master', function () { return view('pages.state-master'); });
    Route::get('/district-master', function () { return view('pages.district-master'); });
    Route::get('/artcenter-master', function () { return view('pages.artcenter-master'); });
    Route::get('/lfumis-master', function () { return view('pages.lfumis-master'); });
    Route::get('/hd-master', function () { return view('pages.hd-master'); });
    Route::get('/vl-master', function () { return view('pages.vl-master'); });
    Route::get('/lfuci-master', function () { return view('pages.lfuci-master'); });
    Route::get('/cd4ci-master', function () { return view('pages.cd4ci-master'); });
    Route::get('/duedate-master', function () { return view('pages.duedate-master'); });
    Route::get('/tbfollow-master', function () { return view('pages.tbfollow-master'); });
    Route::get('/bta-master', function () { return view('pages.bta-master'); });
    Route::get('/int-master', function () { return view('pages.int-master'); });
    Route::get('/adh-master', function () { return view('pages.adh-master'); });
    Route::get('/sup-master', function () { return view('pages.sup-master'); });
    Route::get('/upload-patient', function () { return view('pages.upload-patient'); });
    Route::get('/upload-patient-mapping', function () { return view('pages.upload-patient-mapping'); });
    Route::get('/patient-register', function () { return view('pages.patient-register'); });
    Route::get('/patient-mapping', function () { return view('pages.patient-mapping'); });
    Route::get('/outreach-input', function () { return view('pages.outreach-input'); });
    Route::get('/calling-input', function () { return view('pages.calling-input'); });
    Route::get('/eac-input', function () { return view('pages.eac-input'); });
    Route::get('/deo-input', function () { return view('pages.deo-input'); });
});


Route::get('/register', function () { return view('pages.register'); });
Route::get('/login-1', function () { return view('pages.login'); });

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

Route::post("/statemasterinsert", "StateController@insertstate");
Route::get('/state-master-data', "StateController@getstate");
Route::get('/deletestate/{id}', "StateController@deletestate");
Route::get('editstate/{id}', "StateController@showstate");
Route::post('/updatestate', "StateController@updatestate");

Route::post("/districtinsert", "DistrictController@insertdistrict");
Route::post("/getstatecode", "DistrictController@getstatecode");
Route::get('/district-master-data', "DistrictController@getdistrict");
Route::get('/deletedistrict/{id}', "DistrictController@deletedistrict");
Route::get('editdistrict/{id}', "DistrictController@showdistrict");
Route::post('/updatedistrict', "DistrictController@updatedistrict");

Route::post("/employeeinsert", "EmployeeController@insertemployee");
Route::get('/employee-master-data', "EmployeeController@getemployee");
Route::get('/deleteemployee/{id}', "EmployeeController@deleteemployee");
Route::get('editemployee/{id}', "EmployeeController@showemployee");
Route::post('/updateemployee', "EmployeeController@updateemployee");

Route::post("/questionansinsert", "QuestionController@questionansinsert");
Route::get('/question-answer-data', "QuestionController@getquestion");
Route::get('/deletequestion/{id}', "QuestionController@deletequestion");
Route::get('editquestion/{id}', "QuestionController@showquestion");
Route::post('/updatequestion', "QuestionController@updatequestion");

Route::post("/userlogininsert", "UserLoginController@insertuserlogin");
Route::get('/user-login-data', "UserLoginController@getuserlogin");
Route::get('/deleteuserlogin/{id}', "UserLoginController@deleteuserlogin");
Route::get('edituserlogin/{id}', "UserLoginController@showuserlogin");
Route::post('/updateuserlogin', "UserLoginController@updateuserlogin");

Route::post("/artcenterinsert", "ArtCenterController@insertartcenter");
Route::get('/artcenter-master-data', "ArtCenterController@getartcenter");
Route::get('/deleteartcenter/{id}', "ArtCenterController@deleteartcenter");
Route::get('editartcenter/{id}', "ArtCenterController@showartcenter");
Route::post('/updateartcenter', "ArtCenterController@updateartcenter");

Route::post("/lfumisinsert", "MasterController@lfumisinsert");
Route::get('/lfumis-master-data', "MasterController@getlfumis");
Route::get('/deletelfumis/{id}', "MasterController@deletelfumis");
Route::get('editlfumis/{id}', "MasterController@showlfumis");
Route::post('/updatelfumis', "MasterController@updatelfumis");

Route::post("/hdinsert", "MasterController@hdinsert");
Route::get('/hd-master-data', "MasterController@gethdmaster");
Route::get('deletehd/{id}', "MasterController@deletehd");
Route::get('edithd/{id}', "MasterController@showhd");
Route::post('/updatehd', "MasterController@updatehd");

Route::post("/vlinsert", "MasterController@vlinsert");
Route::get('/vl-master-data', "MasterController@getvlmaster");
Route::get('editvl/{id}', "MasterController@showvl");
Route::get('deletevl/{id}', "MasterController@deletevl");
Route::post('/updatevl', "MasterController@updatevl");

Route::post("/lfuciinsert", "MasterController@lfuciinsert");
Route::get('/lfuci-master-data', "MasterController@getlfucimaster");
Route::get('deletelfuci/{id}', "MasterController@deletelfuci");
Route::get('editlfuci/{id}', "MasterController@showlfuci");
Route::post('/updatelfuci', "MasterController@updatelfuci");

Route::post("/cd4ciinsert", "MasterController@cd4ciinsert");
Route::get('/cd4ci-master-data', "MasterController@getcd4cimaster");
Route::get('deletecd4ci/{id}', "MasterController@deletecd4ci");
Route::get('editcd4ci/{id}', "MasterController@showcd4ci");
Route::post('/updatecd4ci', "MasterController@updatecd4ci");

Route::post("/duedateinsert", "MasterController@duedateinsert");
Route::get('/duedate-master-data', "MasterController@getduedatemaster");
Route::get('deleteduedate/{id}', "MasterController@deleteduedate");
Route::get('editduedate/{id}', "MasterController@showduedate");
Route::post('/updateduedate', "MasterController@updateduedate");

Route::post("/tbfollowinsert", "MasterController@tbfollowinsert");
Route::get('/tbfollow-master-data', "MasterController@gettbfollowmaster");
Route::get('deletetbfolllow/{id}', "MasterController@deletetbfolllow");
Route::get('edittbfollow/{id}', "MasterController@showtbfolllow");
Route::post('/updatetbfollow', "MasterController@updatetbfollow");

Route::post("/btainsert", "MasterController@btainsert");
Route::get('/bta-master-data', "MasterController@getbtamaster");
Route::get('deletebta/{id}', "MasterController@deletebta");
Route::get('editbta/{id}', "MasterController@showbta");
Route::post('/updatebta', "MasterController@updatebta");

Route::post("/intinsert", "MasterController@intinsert");
Route::get('/int-master-data', "MasterController@getintmaster");
Route::get('deleteint/{id}', "MasterController@deleteint");
Route::get('editint/{id}', "MasterController@showint");
Route::post('/updateint', "MasterController@updateint");

Route::post("/adhinsert", "MasterController@adhinsert");
Route::get('/adh-master-data', "MasterController@getadhmaster");
Route::get('deleteadh/{id}', "MasterController@deleteadh");
Route::get('editadh/{id}', "MasterController@showadh");
Route::post('/updateadh', "MasterController@updateadh");

Route::post("/supinsert", "MasterController@supinsert");
Route::get('/sup-master-data', "MasterController@getsupmaster");
Route::get('deletesup/{id}', "MasterController@deletesup");
Route::get('editsup/{id}', "MasterController@showsup");
Route::post('/updatesup', "MasterController@updatesup");

Route::post("/upload_patient_data", "PatientController@upload_patient_data");
Route::post("/upload_patient_mapping_data", "PatientController@upload_patient_mapping_data");
Route::post("/insertpatient", "PatientController@insertpatient");
Route::post("/getartcentrename", "PatientController@getartcentrename");
Route::get('/patient-register-data', "PatientController@getpatientdata");
Route::get('editpatient/{id}', "PatientController@showpatient");
Route::post("/updatepatient", "PatientController@updatepatient");
Route::post("/checkpatmobile", "PatientController@checkpatmobile");
Route::post("/checkartreg", "PatientController@checkartreg");
Route::post("/checkpatdata", "PatientController@checkpatdata");
Route::post("/checkpatmapdata", "PatientController@checkpatmapdata");

Route::post("/insertpatientmapping", "PatientController@insertpatientmapping");
Route::get('/patient-mapping-data', "PatientController@getpatientmappingdata");
Route::get('editpatient/{id}', "PatientController@showpatient");
Route::post("/updatepatientmapping", "PatientController@updatepatientmapping");

Route::post("/inserteacinput", "InputFormController@inserteacinput");
Route::post("/insertoutreachinput", "InputFormController@insertoutreachinput");
Route::post("/getlinelistmaster", "InputFormController@getlinelistmaster");
Route::post("/geteaclinelistmaster", "InputFormController@geteaclinelistmaster");
Route::get('/eac-input-data', "InputFormController@geteacinputdata");
Route::get('/outreach-input-data', "InputFormController@getoutreachinputdata");
Route::get('/calling-input-data', "InputFormController@getcallinginputdata");
Route::get('editeacinput/{id}', "InputFormController@showeacinput");
Route::get('editoutreachinput/{id}', "InputFormController@showoutreachinput");
Route::get('editcallinginput/{id}', "InputFormController@showcallinginput");
Route::post("/updateeacinput", "InputFormController@updateeacinput");
Route::post("/updateoutreachinput", "InputFormController@updateoutreachinput");
Route::post("/checkdeodate", "InputFormController@checkdeodate");

Route::post("/insertdeoinput", "InputFormController@insertdeoinput");
Route::get('/deo-input-data', "InputFormController@getdeoinputdata");
Route::get('editdeoinput/{id}', "InputFormController@showdeoinput");
Route::post("/updatedeoinput", "InputFormController@updatedeoinput");

Route::get('/outreach-input-report', "ReportController@getoutreachreport");
Route::post('/outreach-input-report', "ReportController@getfilteredoutreachreport")->name('getfilteredoutreachreport');

Route::get('/calling-input-report', "ReportController@getcallingreport");
Route::post('/calling-input-report', "ReportController@getfilteredcallingreport")->name('getfilteredcallingreport');

Route::get('/eac-input-report', "ReportController@geteacreport");
Route::post('/eac-input-report', "ReportController@getfilteredeacreport")->name('getfilteredeacreport');

Route::get('/linelist-summary-report', "ReportController@getlinelistsummaryreport");
Route::post('/linelist-summary-report', "ReportController@getfilteredlinelistsummaryreport")->name('getfilteredlinelistsummaryreport');

Route::get('/outreach-ageing-report', "ReportController@getoutreachageingreport");
Route::post('/outreach-ageing-report', "ReportController@getfilteredoutreachageingreport")->name('getfilteredoutreachageingreport');

Route::get('/calling-ageing-report', "ReportController@getcallingageingreport");
Route::post('/calling-ageing-report', "ReportController@getfilteredcallingageingreport")->name('getfilteredcallingageingreport');

Route::get('/eac-ageing-report', "ReportController@geteacageingreport");
Route::post('/eac-ageing-report', "ReportController@getfilteredeacageingreport")->name('getfilteredeacageingreport');
});
