<?php

Route::get('/', function () {
    
    if(Auth::check())
    {
        return redirect('/admin/check_user');
    }
    else{
        return redirect('/login');
    }
});

Route::get('test', function () {

    $node->makeRoot();
    $parent = $node->parent()->get();
});

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

    Route::get('/admin/check_user', 'Admin\HomeController@check_user');
    Route::get('admin/dashboard', 'Admin\HomeController@index');

    Route::post('admin/add_note', 'Admin\NoteController@add_note');
    Route::get('admin/change_note_status/{id}', 'Admin\NoteController@change_note_status');
    Route::get('admin/remove_note/{id}', 'Admin\NoteController@remove_note');

    Route::get('/admin/project_details/{id}', 'Admin\projectController@project_details');
    Route::post('admin/assign_project', 'Admin\projectController@assign_project');
    Route::get('admin/projects', 'Admin\projectController@index');
    Route::post('admin/add_proj', 'Admin\projectController@add_project');
    Route::post('admin/add_file', 'Admin\projectController@add_file');
    Route::get('admin/remove_proj/{id}', 'Admin\projectController@remove_proj');
    Route::get('admin/remove_proj_user/{id}', 'Admin\projectController@remove_proj_user');
    Route::get('admin/remove_proj_document/{id}', 'Admin\projectController@remove_proj_document');
    Route::post('admin/make_pm', 'Admin\projectController@make_pm');

    Route::post('admin/user_list_for_task_assign', 'Admin\TaskController@user_list_for_task_assign');
    Route::post('admin/task_assign_to_user', 'Admin\TaskController@task_assign_to_user');
    Route::post('admin/remove_assign_task_user', 'Admin\TaskController@remove_assign_task_user');

    Route::post('admin/remove_comment', 'Admin\CommentController@remove_comment');
    Route::post('admin/edit_comment_form', 'Admin\CommentController@edit_comment_form');
    Route::post('admin/save_update_comment', 'Admin\CommentController@save_update_comment');
    Route::post('admin/add_task_doc', 'Admin\CommentController@add_task_doc');
    Route::post('admin/change_notification', 'Admin\CommentController@change_notification');

    Route::post('admin/change_support_notification_status', 'Admin\HomeController@change_support_status');

    Route::get('admin/task', 'Admin\TaskController@index');
    Route::get('admin/task/deadline_today', 'Admin\TaskController@deadlineToday');
    Route::get('admin/task/deadline_missed', 'Admin\TaskController@deadlineMissed');
    Route::get('admin/task/completed_today', 'Admin\TaskController@completedToday');
    Route::get('admin/task/completed_yesterday', 'Admin\TaskController@completedYesterday');
    Route::get('admin/task/pending_task', 'Admin\TaskController@pendingTask');
    Route::get('admin/task/in_process', 'Admin\TaskController@inProcess');
    Route::post('admin/add_task', 'Admin\TaskController@add_task');
    Route::get('admin/remove_task/{id}', 'Admin\TaskController@remove_task');
    Route::post('admin/change_tast_by_proj', 'Admin\TaskController@change_tast_by_proj');
    Route::post('admin/add_task_comment', 'Admin\TaskController@add_task_comment');
    Route::post('admin/change_to_process', 'Admin\TaskController@change_to_process');

    Route::post('admin/company_task/{typ}', 'Admin\TaskController@company_task');

    Route::get('admin/employee', 'Admin\EmployeeController@index');
    Route::get('admin/employee/add', 'Admin\EmployeeController@create');
    Route::post('admin/employee/store', 'Admin\EmployeeController@store');
    Route::get('admin/employee/show/{id}', 'Admin\EmployeeController@show');
    Route::get('admin/employee/edit_employee/{id}', 'Admin\EmployeeController@editEmployee');
    Route::post('admin/employee/update/{id}', 'Admin\EmployeeController@update');
    Route::get('admin/employee/delete/{id}', 'Admin\EmployeeController@destroy');
    Route::get('admin/employee/status/{id}', 'Admin\EmployeeController@statusUpdate');
    Route::get('admin/employee/add_user/{id}', 'Admin\EmployeeController@addUser');
    Route::post('admin/employee/add_to_user/{id}', 'Admin\EmployeeController@addToUser');
    Route::post('admin/employee/change_password', 'Admin\EmployeeController@changePassword');
    Route::post('admin/employee/rejoining', 'Admin\EmployeeController@rejoining');
    
    // Education Level
    Route::get('admin/education_level', 'Admin\EducationController@index');
    Route::get('admin/education_level/add', 'Admin\EducationController@create');
    Route::post('admin/education_level/store', 'Admin\EducationController@store');
    Route::get('admin/education_level/edit/{id}', 'Admin\EducationController@edit');
    Route::post('admin/education_level/update/{id}', 'Admin\EducationController@update');
    Route::get('admin/education_level/delete/{id}', 'Admin\EducationController@destroy');
    Route::get('admin/education_level/status/{id}', 'Admin\EducationController@statusUpdate');
    // Document Type
    Route::get('admin/document_type', 'Admin\DocumentTypeController@index');
    Route::get('admin/document_type/add', 'Admin\DocumentTypeController@create');
    Route::post('admin/document_type/store', 'Admin\DocumentTypeController@store');
    Route::get('admin/document_type/edit/{id}', 'Admin\DocumentTypeController@edit');
    Route::post('admin/document_type/update/{id}', 'Admin\DocumentTypeController@update');
    Route::get('admin/document_type/delete/{id}', 'Admin\DocumentTypeController@destroy');
    Route::get('admin/document_type/status/{id}', 'Admin\DocumentTypeController@statusUpdate');
    // Grade
    Route::get('admin/grade', 'Admin\GradeController@index');
    Route::get('admin/grade/add', 'Admin\GradeController@create');
    Route::post('admin/grade/store', 'Admin\GradeController@store');
    Route::get('admin/grade/edit/{id}', 'Admin\GradeController@edit');
    Route::post('admin/grade/update/{id}', 'Admin\GradeController@update');
    Route::get('admin/grade/delete/{id}', 'Admin\GradeController@destroy');
    Route::get('admin/grade/status/{id}', 'Admin\GradeController@statusUpdate');
    // Designation
    Route::get('admin/designation', 'Admin\DesignationController@index');
    //Route::get('admin/designation/get', 'Admin\DesignationController@getDesignation');
    Route::get('admin/designation/add', 'Admin\DesignationController@create');
    Route::post('admin/designation/store', 'Admin\DesignationController@store');
    Route::get('admin/designation/edit/{id}', 'Admin\DesignationController@edit');
    Route::post('admin/designation/update/{id}', 'Admin\DesignationController@update');
    Route::get('admin/designation/delete/{id}', 'Admin\DesignationController@destroy');
    Route::get('admin/designation/status/{id}', 'Admin\DesignationController@statusUpdate');
    // Payroll Head
    Route::get('admin/payroll_head', 'Admin\PayrollHeadController@index');
    Route::get('admin/payroll_head/add', 'Admin\PayrollHeadController@create');
    Route::post('admin/payroll_head/store', 'Admin\PayrollHeadController@store');
    Route::get('admin/payroll_head/edit/{id}', 'Admin\PayrollHeadController@edit');
    Route::post('admin/payroll_head/update/{id}', 'Admin\PayrollHeadController@update');
    Route::get('admin/payroll_head/delete/{id}', 'Admin\PayrollHeadController@destroy');
    Route::get('admin/payroll_head/status/{id}', 'Admin\PayrollHeadController@statusUpdate');
    // Grade Structure
    Route::get('admin/grade_structure', 'Admin\GradeStructureController@index');
    Route::get('admin/grade_structure/add', 'Admin\GradeStructureController@create');
    Route::post('admin/grade_structure/store', 'Admin\GradeStructureController@store');
    Route::get('admin/grade_structure/edit/{id}', 'Admin\GradeStructureController@edit');
    Route::post('admin/grade_structure/update', 'Admin\GradeStructureController@update');
    Route::get('admin/grade_structure/delete/{id}', 'Admin\GradeStructureController@destroy');
    Route::get('admin/grade_structure/status/{id}', 'Admin\GradeStructureController@statusUpdate');
    // Payroll Structure
    Route::get('admin/payroll_structure', 'Admin\PayrollStructureController@index');
    Route::get('admin/payroll_structure/ps_update/{id}', 'Admin\PayrollStructureController@psUpdate');
    Route::post('admin/payroll_structure/update/{id}', 'Admin\PayrollStructureController@update');
    Route::get('admin/payroll_structure/delete/{id}', 'Admin\PayrollStructureController@destroy');
    Route::get('admin/payroll_structure/status/{id}', 'Admin\PayrollStructureController@statusUpdate');
    // Payroll
    Route::get('admin/payroll', 'Admin\PayrollController@index');
    Route::get('admin/payroll/create', 'Admin\PayrollController@create');
    Route::post('admin/payroll/bill_create', 'Admin\PayrollController@billCreate');
    Route::get('admin/payroll/pr_update/{id}', 'Admin\PayrollController@prUpdate');
    Route::post('admin/payroll/update/{id}', 'Admin\PayrollController@update');
    Route::get('admin/payroll/details/{id}', 'Admin\PayrollController@details');
    Route::get('admin/payroll/receipt/{id}/{pay_id}', 'Admin\PayrollController@receipt');

    // Notice Board
    Route::get('admin/notice_board', 'Admin\NoticeBoardController@index');
    Route::get('admin/notice_board/add', 'Admin\NoticeBoardController@create');
    Route::post('admin/notice_board/store', 'Admin\NoticeBoardController@store');
    Route::get('admin/notice_board/details/{id}', 'Admin\NoticeBoardController@show');
    Route::get('admin/notice_board/my_notice', 'Admin\NoticeBoardController@myNotice');
    Route::get('admin/notice_board/edit/{id}', 'Admin\NoticeBoardController@edit');
    Route::get('admin/notice_board/delete/{id}', 'Admin\NoticeBoardController@destroy');

    Route::get('admin/users', 'Admin\UsersController@index');
    Route::post('admin/add_user', 'Admin\UsersController@add_user');
    Route::get('admin/user_active/{id}', 'Admin\UsersController@user_active');
    Route::post('admin/change_user_pass', 'Admin\UsersController@change_user_pass');

    Route::get('admin/usergroup', 'Admin\UserGroupController@index');
    Route::post('admin/add_group_user', 'Admin\UserGroupController@add_group_user');
    Route::get('admin/remove_group_user/{id}', 'Admin\UserGroupController@remove_group_user');
    // Companies
    Route::resource('admin/companies','Admin\CompanyController');
    Route::post('admin/update_company', 'Admin\CompanyController@update_company');
    Route::get('admin/view_company/{id}', 'Admin\CompanyController@view_company');
    Route::post('admin/save_remarks', 'Admin\CompanyController@save_remarks');
    Route::post('admin/remove_remarks', 'Admin\CompanyController@remove_remarks');
    Route::post('admin/save_activity', 'Admin\CompanyController@save_activity');
    Route::post('admin/remove_activity', 'Admin\CompanyController@remove_activity');
    Route::post('admin/send_email_to_company', 'Admin\CompanyController@send_email_to_company');
    Route::post('admin/change_status','Admin\CompanyController@change_status')->name('change_company_status');
    Route::get('admin/company/edit_company/{id}','Admin\CompanyController@edit_company_info')->name('edit_company');
    Route::post('admin/company/change_company_info','Admin\CompanyController@change_company_info')->name('change_company_info');


    Route::get('admin/updateDrag/{id}/{levelchange}', 'Admin\projectController@updateDrag');
    Route::get('admin/change_task_status/{id}', 'Admin\projectController@change_task_status');
    Route::resource('admin/address_book','Admin\AddressBookController');
    Route::post('admin/update_address_book', 'Admin\AddressBookController@update_address_book');

    Route::resource('admin/file_upload','Admin\FileUploadController');

    //REPORT
    Route::get('admin/completed_task_by_user', 'Admin\ReportTaskController@completed_task_by_user');
    Route::post('admin/search_completed_task_by_user', 'Admin\ReportTaskController@search_completed_task_by_user');
    Route::get('admin/work_flow', 'Admin\ReportTaskController@work_flow');

    //SERVICE
    Route::post('admin/company/service/assign','Admin\CompanyController@assign_service');
    Route::get('admin/company/service/details/{id}','Admin\CompanyController@get_service');
    Route::get('admin/company/service/upload/{id}','Admin\CompanyController@file_upload_view');
    Route::post('admin/company/service/upload','Admin\CompanyController@save_upload');
    
    Route::get('admin/user_profile/{id}', 'Admin\HomeController@user_profile');

    Route::get('admin/user_attendace', 'Admin\HomeController@user_attendace');
    Route::post('admin/attendace_sheet_entry', 'Admin\HomeController@attendace_sheet_entry');
    Route::get('admin/attendace_report', 'Admin\HomeController@attendace_report');
    Route::post('admin/report_content', 'Admin\HomeController@get_report_by_user');
    Route::get('admin/load_content', 'Admin\HomeController@load_content');
    
    Route::get('admin/vocabulary', 'Admin\VocabularyController@index');
    Route::get('admin/vocabulary_edit/{id}', 'Admin\VocabularyController@edit');
    Route::post('admin/vocabulary_edit', 'Admin\VocabularyController@update');
    
    Route::get('admin/leave_requests', 'Admin\HomeController@leave_report');
    Route::get('admin/leave_requests/details/{id}', 'Admin\HomeController@leave_details');
    Route::post('admin/leave_req_approved/{id}', 'Admin\HomeController@leave_accept');
    Route::get('admin/leave_requests/apply', 'Admin\HomeController@apply');
    Route::post('admin/leave_requests/store', 'Admin\HomeController@store');
    Route::get('admin/leave_req_discard/{id}', 'Admin\HomeController@leave_discard');
    Route::get('admin/leave_requests/delete/{id}', 'Admin\HomeController@destroy');
    Route::get('admin/company/add_user/{id}','Admin\CompanyController@company_user');
    Route::post('admin/company/add_manager',['as'=>'add_manager','uses'=>'Admin\CompanyController@company_manager']);
    // Roles & Permissions

    Route::get('admin/roles', 'Admin\RoleController@index');
    Route::post('admin/roles/store', 'Admin\RoleController@store');
    Route::get('admin/roles/edit/{id}', 'Admin\RoleController@edit');
    Route::post('admin/roles/update/{id}', 'Admin\RoleController@update');
    Route::get('admin/roles/delete/{id}', 'Admin\RoleController@destroy');

    Route::get('admin/permissions', 'Admin\PermissionController@index');
    Route::post('admin/permissions/store', 'Admin\PermissionController@store');
    Route::get('admin/permissions/edit/{id}', 'Admin\PermissionController@edit');
    Route::post('admin/permissions/update/{id}', 'Admin\PermissionController@update');
    Route::get('admin/permissions/delete/{id}', 'Admin\PermissionController@destroy');
    // End Roles & Permissions

});

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

    Route::auth();

    Route::get('user/user_profile', 'User\UserController@index');
    Route::get('user/user_group', 'User\UserController@group');
    Route::post('user/update_profile', 'User\UserController@update_profile');
    Route::post('user/add_note', 'User\UserController@add_note');
    Route::get('user/change_note_status/{id}', 'User\UserController@change_note_status');
    Route::get('user/remove_note/{id}', 'User\UserController@remove_note');

    Route::get('user/user_projects', 'User\UProjectController@index');
    Route::get('user/uproject_details/{id}', 'User\UProjectController@uproject_details');
    Route::get('user/uproj_inprocess_pending_task/{id}', 'User\UProjectController@uproj_inprocess_pending_task');
    Route::post('user/assign_project', 'User\UProjectController@assign_project');
    Route::get('user/remove_proj_user/{id}', 'User\UProjectController@remove_proj_user');
    Route::get('user/remove_proj_document/{id}', 'User\UProjectController@remove_proj_document');
    Route::post('user/add_file', 'User\UProjectController@add_file');

    Route::post('user/add_task', 'User\UTaskController@add_task');
    Route::get('user/remove_task/{id}', 'User\UTaskController@remove_task');
    Route::post('user/task_assign_to_user', 'User\UTaskController@task_assign_to_user');
    Route::post('user/task_details', 'User\UTaskController@task_details');
    Route::post('user/add_task_comment', 'User\UTaskController@add_task_comment');
    Route::post('user/remove_assign_task_user', 'User\UTaskController@remove_assign_task_user');
    Route::post('user/user_list_for_task_assign', 'User\UTaskController@user_list_for_task_assign');
    Route::post('user/change_tast_by_proj', 'User\UTaskController@change_tast_by_proj');
    Route::post('user/change_to_process', 'User\UTaskController@change_to_process');
    Route::post('user/change_to_inprocess', 'User\UTaskController@change_to_inprocess');

    Route::post('user/remove_comment', 'User\UCommentController@remove_comment');
    Route::post('user/edit_comment_form', 'User\UCommentController@edit_comment_form');
    Route::post('user/save_update_comment', 'User\UCommentController@save_update_comment');
    Route::post('user/add_task_doc', 'User\UCommentController@add_task_doc');
    Route::get('user/change_task_status/{id}', 'User\UProjectController@change_task_status');
    Route::get('user/attend_entry', 'User\UserController@attend_entry');
    Route::post('user/attendace_sheet_entry', 'User\UserController@attendace_sheet_entry');
    
    Route::get('user/leave_apply', 'User\UserController@leave_apply');
    Route::post('user/leave_req', 'User\UserController@leave_req');
});

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

    Route::get('client/client_projects', 'Client\CProjectController@index');
    Route::get('client/client_profile', 'Client\ClientController@index');
    Route::get('client/client_dashboard', 'Client\ClientController@client_dashboard');

    Route::post('client/add_proj', 'Client\CProjectController@add_project');
    Route::get('client/remove_proj/{id}', 'Client\CProjectController@remove_proj');
    Route::post('client/add_file', 'Client\CProjectController@add_file');
    Route::get('client/cproject_details/{id}', 'Client\CProjectController@project_details');
    Route::get('client/remove_proj_document/{id}', 'Client\CProjectController@remove_proj_document');

    Route::post('client/add_task', 'Client\CTaskController@add_task');
    Route::get('client/remove_task/{id}', 'Client\CTaskController@remove_task');
    Route::post('client/user_list_for_task_assign', 'Client\CTaskController@user_list_for_task_assign');
    Route::post('client/change_to_process', 'Client\CTaskController@change_to_process');
    Route::post('client/add_task_comment', 'Client\CTaskController@add_task_comment');
});


Route::group(['middleware' => 'web','prefix'=>'account','namespace'=>'Admin'], function () {

    Route::get('journal','JounalController@index');
    Route::get('journal/new','JounalController@create');
    Route::post('journal/save','JounalController@store');
    Route::get('journal/get_head/{id}','JounalController@get_acc_head');
    Route::post('journal/change_approaval_status','JounalController@change_approaval_status');
    Route::get('journal/payment/{id}','JounalController@payment');
    Route::post('journal/payment/save','JounalController@save_payment');
    Route::get('journal/details/{id}','JounalController@get_details');


    Route::get('report/expense','AccountReportController@expense_report_view');
    Route::post('report/expense','AccountReportController@expense_report');
    
    Route::get('report/revenue','AccountReportController@revenue_report_view');
    Route::post('report/revenue','AccountReportController@revenue_report');

    Route::get('fund_req','FundRequestController@index');
    Route::post('fund_req/save','FundRequestController@store');
    Route::post('fund/approval_status','FundRequestController@change_approval_status');

    Route::get('revenue','RevenueController@index');
    Route::post('revenue/save','RevenueController@store');


});


Route::group(['middleware'=>'web','namespace'=>'Client'],function(){

    Route::get('ticket','TicketController@index');
    Route::get('ticket/new','TicketController@create');
    Route::post('ticket/save','TicketController@store');
    Route::get('ticket/show/{id}','TicketController@show');

    Route::get('ticket/comments/{tkt_id}','TicketController@get_comments');
    Route::post('ticket/comment/save','TicketController@save_comment');
    Route::post('ticket/status/change','TicketController@change_status');
    

});

Route::group(['middleware' => 'web','prefix'=>'invoice','namespace'=>'Admin'], function () {
    Route::get('/','InvoiceController@index');
    Route::get('show/{id}','InvoiceController@show');
    Route::get('new','InvoiceController@create');
    Route::post('save','InvoiceController@store');
    Route::get('edit/{id}','InvoiceController@edit');
    Route::post('update','InvoiceController@update');
    Route::get('delete/{id}','InvoiceController@delete');
    Route::post('pay','InvoiceController@make_payment');
    Route::get('invoice_created_email/{id}','InvoiceController@invoice_created_email');


});
Route::group(['prefix' => 'api','middleware' => 'api'], function () {
    Route::get('users','ApiController@get_all_users');
    Route::get('projects','ApiController@get_all_projects');
    Route::get('tasks','ApiController@get_all_tasks');
    Route::get('deadline_missed','ApiController@deadline_missed');
    Route::get('no_work_today','ApiController@no_work_today');
    Route::post('create_task','ApiController@create_task');
    Route::get('change_task_status/{id}','ApiController@change_task_status');
    Route::get('fund_purpose','ApiController@fund_purpose');
    Route::post('fund_save','ApiController@fund_save');
    Route::get('get_entry_time_today','ApiController@get_entry_time_today');
    Route::get('get_exit_time_yesterday','ApiController@get_exit_time_yesterday');
    Route::get('get_month_attendance_report','ApiController@get_month_attendance_report');
    Route::get('get_month_report/{id}','ApiController@get_month_report');
    Route::get('get_fund_requests','ApiController@get_fund_requests');
    Route::get('change_fund_request_status/{id}/{value}','ApiController@change_fund_request_status');
    Route::get('get_pending_tasks','ApiController@get_pending_tasks');
    Route::get('get_in_progress_tasks','ApiController@get_in_progress_tasks');
    Route::get('get_leave_purposes','ApiController@get_leave_purposes');
    Route::get('get_leave_requests','ApiController@get_leave_requests');
    Route::post('leave_req','ApiController@leave_req');
    Route::post('leave_accept','ApiController@leave_accept');
    Route::post('user_login','ApiController@login');
});