<?php

Route::post('loginCheck', 'Auth\LoginController@loginCheck');
Route::get('login', 'Auth\LoginController@index');
Route::get('cronjob/{manual?}', 'CronJobController@execute');

Route::group(['middleware' => 'web'], function () {
    Route::get('reauth/{data}', 'Auth\LoginController@reAuth');

    Route::group(['middleware' => ['auth']], function () {
        Route::get('logout', 'Auth\LoginController@logout')->name('logout');
        Route::get('dashboard', 'DashboardController@index')->name('dashboard');
        Route::get('my-profile', 'UserController@myProfile')->name('myProfile');
        Route::post('password-update', 'UserController@passwordUpdate');
        Route::post('profileUpdate', 'UserController@profileUpdate');
    });

    Route::group(['middleware' => ['auth','tz','acl']], function () {
        Route::get('userWiseEvent/{yearMonth}', 'DashboardController@getEvent')->name('userWiseEvent');
        Route::post('in', 'AttendanceController@in')->name('in');
        Route::post('out', 'AttendanceController@out')->name('out');
        Route::get('in-out-record', 'DashboardController@inOutRecord')->name('in-out-record');
        Route::get('my-report', 'UserController@myReport')->name('my-report');
        Route::post('my-report', 'UserController@myReport')->name('my-report.post');
        Route::get('my-rota', 'RotaController@myRota')->name('my-rota');
        Route::get('getMyRotaData/{yearMonth}', 'RotaController@getMyRotaData')->name('getMyRotaData');
        Route::get('details-view-report/{id}/{details}', 'UserController@dailyReport')->name('details-view-report');
        Route::post('taskSubmit', 'UserTaskController@save')->name('taskSubmit');
        Route::post('taskUpdate', 'UserTaskController@update')->name('taskUpdate');
        Route::resource('user', 'UserController');
        Route::get('userDelete/{userId}', 'UserController@delete')->name('userDelete');
        Route::get('user-details-report/{userId?}', 'UserController@userDetailsByAdmin')->name('user-details-report');
        Route::post('user-details-report', 'UserController@userDetailsByAdmin')->name('user-details-report');
        Route::get('daily-in-out-report/{userId}/{date}', 'UserController@dailyInOutByUser')->name('daily-in-out-report');
        Route::post('updateUserAttendance', 'AttendanceController@updateUserAttendance')->name('updateUserAttendance');
        Route::get('deleteAttendance/{id}', 'AttendanceController@deleteAttendance')->name('deleteAttendance');
/* Access control*/
        Route::get('acl', 'AccessControlController@index')->name('acl');
        Route::post('roleSave', 'AccessControlController@roleSave')->name('roleSave');
        Route::get('roleEditModal/{id}/{edit}', 'AccessControlController@roleEditModal')->name('roleEditModal');
        Route::get('deleteRole/{id}', 'AccessControlController@deleteRole')->name('deleteRole');
        Route::post('roleUpdate', 'AccessControlController@roleUpdate')->name('roleUpdate');
        Route::get('loadMenuByRole/{roleId}', 'AccessControlController@loadMenuByRole')->name('loadMenuByRole');
        Route::get('loadServiceByRole/{roleId}', 'AccessControlController@loadServiceByRole')->name('loadServiceByRole');
        Route::post('updateMenuByRole', 'AccessControlController@updateMenuByRole')->name('updateMenuByRole');
        Route::post('updateServiceByRole', 'AccessControlController@updateServiceByRole')->name('updateServiceByRole');
        Route::get('roleCreateModal', 'AccessControlController@roleCreateModal')->name('roleCreateModal');
        Route::get('permission/{roleId}', 'AccessControlController@permission')->name('permission');
        Route::post('permission', 'AccessControlController@permissionSave')->name('permission.post');
        /*Leave */
        Route::get('user-leave', 'LeaveManagementController@myLeave')->name('user-leave');
        Route::post('user-leave', 'LeaveManagementController@myLeave')->name('user-leave.post');
        Route::get('user-leave-apply', 'LeaveManagementController@leaveApply')->name('user-leave-apply');
        Route::post('user-leave-apply', 'LeaveManagementController@leaveApplySave')->name('user-leave-apply.post');
        Route::get('leave-notification-view/{leaveId}', 'LeaveManagementController@leaveNotificationUpdate')->name('leave-notification-view');
        Route::get('leave-apply-edit/{leaveId}/edit', 'LeaveManagementController@leaveApplyEdit')->name('leave_apply_edit');
        Route::post('leave-apply-edit','LeaveManagementController@leaveApplyUpdate')->name('leave_apply_edit.post');
        Route::get('leave-apply-delete/{leaveId}', 'LeaveManagementController@leaveApplyDelete')->name('leave-apply-delete');
        Route::get('leave-manage', 'LeaveManagementController@index')->name('leave-manage');
        Route::post('leave-manage', 'LeaveManagementController@approvedOrDeny')->name('leave-manage.post');
        Route::post('reply-comment', 'LeaveManagementController@replyComment')->name('reply-comment');
        /*Leave Exchange*/
        Route::get('exchange', 'LeaveManagementController@holidayExchange')->name('exchange');
        Route::post('exchange', 'LeaveManagementController@holidayExchange')->name('exchange.post');
        Route::get('exchange-apply', 'LeaveManagementController@exchangeApply')->name('exchange-apply');
        Route::post('exchange-apply', 'LeaveManagementController@exchangeApplySave')->name('exchange-apply.post');
        Route::get('exchange-edit/{exchangeId}/edit', 'LeaveManagementController@exchangeEdit')->name('exchange-edit');
        Route::post('exchange-edit', 'LeaveManagementController@exchangeEditSave')->name('exchange-edit.post');
        Route::get('exchange-delete/{exchangeId}', 'LeaveManagementController@exchangeDelete')->name('exchange-delete');
        Route::get('exchange-notification-view/{exchangeId}', 'LeaveManagementController@exchangeNotificationUpdate')->name('exchange-notification-view');
        Route::post('exchange-manage', 'LeaveManagementController@exchangeApprovedOrDeny')->name('exchange-manage');
        Route::post('reply-exchange-comment', 'LeaveManagementController@replyExchangeComment')->name('reply-exchange-comment');

        /*Calendar*/
        Route::get('event', 'EventsController@index')->name('event');
        Route::get('loadCalendar/{user_group_id}', 'EventsController@loadCalendar')->name('loadCalendar');
        Route::get('selectEventType/{id?}', 'EventsController@selectEventType')->name('selectEventType');
        Route::get('getEvent/{user_group_id}/{date}', 'EventsController@getEvent')->name('getEvent');
        Route::post('saveEvent', 'EventsController@saveEvent')->name('saveEvent');
        Route::get('getMembersByUserGroup/{user_group_id}', 'EventsController@getMembersByUserGroup')->name('getMembersByUserGroup');
        Route::get('getEventByMonth/{user_group_id}/{year}/{month}', 'EventsController@getEventByMonth')->name('getEventByMonth');
        Route::get('deleteEvent/{client_event_detail_id}', 'EventsController@deleteEvent')->name('deleteEvent');
        /*Basic Setup*/
        Route::resource('designation', 'DesignationController');
        Route::get('deleteDesignation/{id}', 'DesignationController@destroy')->name('deleteDesignation');
        Route::resource('holiday-type', 'HolidayTypeController');
        Route::get('holidayTypeDelete/{id}', 'HolidayTypeController@destroy')->name('holidayTypeDelete');
        Route::resource('client-leave-type', 'LeaveTypeController');
        Route::get('clientLeaveTypeDelete/{id}', 'LeaveTypeController@destroy')->name('clientLeaveTypeDelete');
        Route::resource('event-type', 'ClientEventTypeController');
        Route::get('clientEventTypeDelete/{id}', 'ClientEventTypeController@destroy')->name('clientEventTypeDelete');
        Route::resource('user-group', 'UserGroupController');
        Route::get('userGroupDelete/{id}', 'UserGroupController@destroy')->name('userGroupDelete');
        /*Reports*/
        Route::get('attendance-details', 'DetailsReportController@attendance')->name('attendance-details');
        Route::post('attendance-details', 'DetailsReportController@attendance')->name('attendance-details.post');
        Route::get('leave-reports', 'DetailsReportController@leave')->name('leave-reports');
        Route::post('leave-reports', 'DetailsReportController@leave')->name('leave-reports.post');
        Route::get('exchange-reports', 'DetailsReportController@exchange')->name('exchange-reports');
        Route::post('exchange-reports', 'DetailsReportController@exchange')->name('exchange-reports.post');
        /* Rota system*/
        Route::get('rota-setup/{userGroupId?}', 'RotaController@index')->name('rota-setup');
        Route::get('shift-assign-modal/{userId}/{date}', 'RotaController@shiftAssignModal')->name('shift-assign-modal');
        Route::get('shift-edit-modal/{rotaId}/{edit}', 'RotaController@shiftEditModal')->name('shift-edit-modal');
        Route::post('shift-edit-modal', 'RotaController@shiftUpdate')->name('shift-edit-modal.post');
        Route::get('shift-assign-modal-all/{userGroup}/{date}', 'RotaController@shiftAssignModalAll')->name('shift-assign-modal-all');
        Route::post('shift-assign', 'RotaController@shiftAssignSave')->name('shift-assign');
        Route::post('shift-assign-all', 'RotaController@shiftAssignSaveForAll')->name('shift-assign-all');
        Route::get('rotaNextWeek/{date}/{userGroup}', 'RotaController@rotaNextWeek')->name('rotaNextWeek');
        Route::get('rotaPrevWeek/{date}/{userGroup}', 'RotaController@rotaPrevWeek')->name('rotaPrevWeek');
        Route::get('deleteRota/{rotaId}', 'RotaController@deleteRota')->name('deleteRota');
        Route::post('copyRota', 'RotaController@copyRota')->name('copyRota');
        Route::post('pasteRota', 'RotaController@pasteRota')->name('pasteRota');
        Route::post('clearWeekRota', 'RotaController@clearWeekRota')->name('clearWeekRota');
        Route::post('weekShift', 'RotaController@weekShift')->name('weekShift');
        Route::get('copyIndividualRota/{rotaid}', 'RotaController@copyIndividualRota')->name('copyIndividualRota');
        Route::get('pasteIndividualRota/{userId}/{userGroup}/{date}', 'RotaController@pasteIndividualRota')->name('pasteIndividualRota');

    });
});

Route::group(['middleware' => 'web'], function () {
    Route::get('/','Frontend\HomeController@index');
    //Route::get('/', 'Auth\LoginController@index');
    Route::get('login', 'Auth\LoginController@index');
    Route::get('password-recovery', 'Auth\LoginController@passwordRecovery');
    Route::post('password-recovery', 'Auth\LoginController@checkPasswordForRecover');
    Route::get('recoverPassword', 'Auth\LoginController@recoverPassword');
    Route::post('recoverPassword', 'Auth\LoginController@passwordRecoverUpdate');
    Route::post('loginCheck', 'Auth\LoginController@loginCheck');
    Route::get('registration', 'ClientRegistrationController@index');
    Route::post('registration', 'ClientRegistrationController@store');
});

Route::group(['middleware' => 'auth','prefix'=>'admin'], function () {
    Route::get('admin', 'SuperAdmin\SuperAdminController@index');
    Route::get('dashboard', 'SuperAdmin\SuperAdminController@index');
    Route::get('logout', 'Auth\LoginController@logout')->name('logout');


});