<?php

/*
|--------------------------------------------------------------------------
| 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('/login',[
    'uses'=>'AuthController@getLogin',
    'as'=>'login'
]);

Route::post('/login',[
    'uses'=>'AuthController@postLogin',
    'as'=>'login'
]);


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

    Route::get('/', function (){
        return redirect()->route('dashboard');
    });

    //Property
    Route::get('/property',[
        'uses'=>'PropertyController@index',
        'as'=>'property'
    ]);

    Route::get('/property/new',[
        'uses'=>'PropertyController@getNew',
        'as'=>'property.new'
    ]);

    Route::post('/property/new',[
        'uses'=>'PropertyController@postNew',
        'as'=>'property.new'
    ]);

    //Sales
    Route::get('/sales',[
        'uses'=>'SalesController@index',
        'as'=>'sales'
    ]);

    Route::get('/sales/month/{month}/{year}',[
        'uses'=>'SalesController@month',
        'as'=>'sales.month'
    ]);

    Route::get('/sales/new',[
        'uses'=>'SalesController@getNew',
        'as'=>'sales.new'
    ]);

    Route::post('/sales/new',[
        'uses'=>'SalesController@postNew',
        'as'=>'sales.new'
    ]);
    Route::get('/sales/edit/{id}',[
        'uses'=>'SalesController@editSales',
        'as'=>'sales.edit'
    ]);
    Route::post('/sales/update',[
        'uses'=>'SalesController@updateSales',
        'as'=>'sales.update'
    ]);
    Route::get('/sales/getDefaultValues',[
        'uses'=>'SalesController@getDefaultValues',
        'as'=>'sales.getDefaultValues'
    ]);
    Route::post('/sales/delete',[
        'uses'=>'SalesController@DeleteSales',
        'as'=>'sales.delete'
    ]);
    Route::get('/sales/chkClientName',[
        'uses'=>'SalesController@chkClientName',
        'as'=>'sales.chkClientName'
    ]);

    //Rentals
    
    Route::get('/rentals',[
        'uses'=>'RentalController@index',
        'as'=>'rentals'
    ]);

    Route::get('/rentals/month/{month}/{year}',[
        'uses'=>'RentalController@month',
        'as'=>'rentals.month'
    ]);

    Route::get('/rentals/new',[
        'uses'=>'RentalController@getNew',
        'as'=>'rentals.new'
    ]);

    Route::post('/rentals/create',[
        'uses'=>'RentalController@postNew',
        'as'=>'rentals.create'
    ]);

    Route::get('/rentals/edit/{id}',[
        'uses'=>'RentalController@editRentals',
        'as'=>'rentals.edit'
    ]);
    Route::post('/rentals/update',[
        'uses'=>'RentalController@updateRentals',
        'as'=>'rentals.update'
    ]);
    Route::post('/rentals/delete',[
        'uses'=>'RentalController@DeleteRentals',
        'as'=>'rentals.delete'
    ]);

    //Quotation
    Route::get('/quotations',[
        'uses'=>'QuotationController@index',
        'as'=>'quotations'
    ]);

    Route::post('/quotations/new',[
        'uses'=>'QuotationController@postNew',
        'as'=>'quotations.new'
    ]);

    //Reports
    Route::get('/reports',[
        'uses'=>'ReportController@index',
        'as'=>'reports'
    ]);

    Route::get('/reports/panel',[
        'uses'=>'ReportController@panel',
        'as'=>'reports.panel'
    ]);

    Route::get('/reports/sales',[
        'uses'=>'ReportController@index',
        'as'=>'reports.sales.index'
    ]);

    Route::get('/reports/top-10',[
        'uses'=>'ReportController@top10',
        'as'=>'reports.sales.top10'
    ]);

    Route::post('/reports/sales/all',[
        'uses'=>'ReportController@rpt_post_sales',
        'as'=>'reports.sales.all'
    ]);

    Route::get('/reports/sales/quarter',[
        'uses'=>'ReportController@quarter',
        'as'=>'reports.sales.quarter'
    ]);

    Route::get('/reports/sales/agents',[
        'uses'=>'ReportController@rpt_sales_agents',
        'as'=>'reports.sales.agent'
    ]);

    Route::get('/reports/sales/developers',[
        'uses'=>'ReportController@rpt_sales_developers',
        'as'=>'reports.sales.developer'
    ]);

    Route::post('/reports/sales/agents',[
        'uses'=>'ReportController@rpt_sales_agents_post',
        'as'=>'reports.sales.agent'
    ]);

    Route::post('/reports/sales/developers',[
        'uses'=>'ReportController@rpt_sales_developers_post',
        'as'=>'reports.sales.developer'
    ]);

    Route::post('/reports/sales/quarter',[
        'uses'=>'ReportController@post_quarter',
        'as'=>'reports.sales.quarter'
    ]);

    Route::get('/reports/sales/top-agents',[
        'uses'=>'ReportController@get_top_agents',
        'as'=>'reports.sales.top-agents'
    ]);

    Route::post('/reports/sales/top-agents',[
        'uses'=>'ReportController@post_top_agents',
        'as'=>'reports.sales.top-agents'
    ]);

    Route::get('/reports/cash-advances',[
        'uses'=>'ReportController@get_cash_advances',
        'as'=>'reports.cash-advances'
    ]);

    Route::post('/reports/cash-advances',[
        'uses'=>'ReportController@post_cash_advances',
        'as'=>'reports.cash-advances'
    ]);

    Route::get('/reports/agents/ca-balances',[
        'uses'=>'ReportController@agents_ca_balance',
        'as'=>'reports.agents.ca-balances'
    ]);

    Route::get('/reports/managers/ca-balances',[
        'uses'=>'ReportController@managers_ca_balance',
        'as'=>'reports.managers.ca-balances'
    ]);

    //Developers commissions received
    Route::get('/reports/commission/developer',[
        'uses'=>'ReportController@developers_comm',
        'as'=>'reports.commission.developers'
    ]);

    Route::post('/reports/commission/developer',[
        'uses'=>'ReportController@rpt_post_developers_comm',
        'as'=>'reports.commission.developers'
    ]);

    //Agent Releases
    Route::get('/reports/commission/releases',[
        'uses'=>'ReportController@releases_comm',
        'as'=>'reports.commission.releases'
    ]);

    Route::post('/reports/commission/releases',[
        'uses'=>'ReportController@rpt_post_releases_comm',
        'as'=>'reports.commission.releases'
    ]);

    Route::get('/reports/commission/rpt_releases_summary',[
        'uses'=>'ReportController@rpt_releases_summary',
        'as'=>'reports.commission.rpt_releases_summary'
    ]);

    //Unit Manager Releases
    Route::get('/reports/commission/releases/managers',[
        'uses'=>'ReportController@releases_comm_managers',
        'as'=>'reports.commission.releases.managers'
    ]);

    Route::post('/reports/commission/releases/managers',[
        'uses'=>'ReportController@rpt_post_releases_comm_managers',
        'as'=>'reports.commission.releases.managers'
    ]);

    //Broker Share
    Route::get('/reports/broker-share',[
        'uses'=>'ReportController@rpt_get_broker_share',
        'as'=>'reports.broker-share'
    ]);

    Route::post('/reports/broker-share',[
        'uses'=>'ReportController@rpt_post_broker_share',
        'as'=>'reports.broker-share'
    ]);

    //Team Sales
    Route::get('/reports/team-sales',[
        'uses'=>'ReportController@rpt_get_team_sales',
        'as'=>'reports.team-sales'
    ]);

    Route::post('/reports/team-sales',[
        'uses'=>'ReportController@rpt_post_team_sales',
        'as'=>'reports.team-sales'
    ]);

    //Cash Payments
    Route::get('/reports/ca/agents',[
        'uses'=>'ReportController@rpt_get_ca_agents',
        'as'=>'reports.ca.agents'
    ]);

    Route::post('/reports/ca/agents',[
        'uses'=>'ReportController@rpt_post_ca_agents',
        'as'=>'reports.ca.agents'
    ]);

    Route::get('/reports/ca/managers',[
        'uses'=>'ReportController@rpt_get_ca_managers',
        'as'=>'reports.ca.managers'
    ]);

    Route::post('/reports/ca/managers',[
        'uses'=>'ReportController@rpt_post_ca_managers',
        'as'=>'reports.ca.managers'
    ]);

    //Comm Vouchers
    Route::get('/reports/commission/vouchers',[
        'uses'=>'ReportController@rpt_get_comm_vouchers',
        'as'=>'reports.commission.vouchers'
    ]);

    Route::post('/reports/commission/vouchers',[
        'uses'=>'ReportController@rpt_post_comm_vouchers',
        'as'=>'reports.commission.vouchers'
    ]);

    Route::get('/reports/releases/vouchers/{id}',[
        'uses'=>'ReportController@rpt_post_release_voucher',
        'as'=>'reports.releases.vouchers'
    ]);

    Route::get('/reports/commission/um-vouchers',[
        'uses'=>'ReportController@rpt_get_comm_um_vouchers',
        'as'=>'reports.commission.um-vouchers'
    ]);

    Route::post('/reports/commission/um-vouchers',[
        'uses'=>'ReportController@rpt_post_comm_um_vouchers',
        'as'=>'reports.commission.um-vouchers'
    ]);

    //comm balances
    Route::get('/reports/agents/balance',[
        'uses'=>'ReportController@agents_balance',
        'as'=>'reports.agents.balance'
    ]);

    Route::get('/reports/developers/balance',[
        'uses'=>'ReportController@developers_balance',
        'as'=>'reports.developers.balance'
    ]);

    //PDF Export
    Route::get('/reports/export_pdf/{id}',[
        'uses'=>'ReportController@export_pdf',
        'as'=>'reports.export_pdf'
    ]);

    //Route::resource('property', 'PropertyController');
    //Route::get('/quotations/{id}/preview','QuotationsController@preview_pdf')->name('quotation.pdf');
    //Route::post('quotations_mass_destroy', ['uses' => 'QuotationsController@massDestroy', 'as' => 'quotations.mass_destroy']);

    Route::group(['prefix'=>'user'], function (){

        Route::get('/account/setting',[
            'uses'=>'AdminController@getUserAccountSetting',
            'as'=>'account.setting'
        ]);
        Route::post('/password/update',[
            'uses'=>'AdminController@postUpdatePassword',
            'as'=>'password.update'
        ]);
        Route::get('/dashboard',[
            'uses'=>'AdminController@getDashboard',
            'as'=>'dashboard'
        ]);

        Route::get('/logout',[
            'uses'=>'AuthController@getLogout',
            'as'=>'logout'
        ]);
        Route::get('/error',[
            'uses'=>'AdminController@getError',
            'as'=>'error'
        ]);
    });

    Route::group(['prefix'=>'admin', ], function (){

        Route::get('/users',[
            'uses'=>'AdminController@getUsers',
            'as'=>'users'
        ]);
        Route::get('/user/new',[
            'uses'=>'AdminController@getNewUser',
            'as'=>'user.new'
        ]);
        Route::post('/user/new',[
            'uses'=>'AdminController@postNewUser',
            'as'=>'user.new'
        ]);
        Route::post('/user/delete',[
            'uses'=>'AdminController@postDeleteUser',
            'as'=>'user.delete'
        ]);
        Route::post('/user/update',[
            'uses'=>'AdminController@postUpdateUser',
            'as'=>'user.update'
        ]);

        //Settings
        /*Route::get('/settings',[
            'uses'=>'SettingsController@index',
            'as'=>'settings'
        ]);*/

        Route::get('/settings/view',[
            'uses'=>'SettingsController@view',
            'as'=>'settings.view'
        ]);

        Route::post('/settings/update',[
            'uses'=>'SettingsController@update',
            'as'=>'settings.update'
        ]);

        Route::post('/settings/apply-theme',[
            'uses'=>'SettingsController@apply_theme',
            'as'=>'settings.apply-theme'
        ]);

        Route::get('/settings/custom-theme',[
            'uses'=>'SettingsController@custom_theme',
            'as'=>'settings.custom-theme'
        ]);
		
        //Agents
        Route::get('/agents',[
            'uses'=>'AgentController@index',
            'as'=>'agents'
        ]);
        Route::get('/agents/new',[
            'uses'=>'AgentController@getNewAgent',
            'as'=>'agents.new'
        ]);
        Route::post('/agents/new',[
            'uses'=>'AgentController@postNewAgent',
            'as'=>'agents.new'
        ]);
        Route::get('/agents/edit/{id}',[
            'uses'=>'AgentController@editAgent',
            'as'=>'agents.edit'
        ]);
        Route::post('/agents/update',[
            'uses'=>'AgentController@udpdateAgent',
            'as'=>'agents.update'
        ]);
        Route::post('/agents/delete',[
            'uses'=>'AgentController@postDeleteAgent',
            'as'=>'agents.delete'
        ]);
        Route::get('/agents/info/{id}',[
            'uses'=>'AgentController@getAgentInfo',
            'as'=>'agents.info'
        ]);

        Route::get('/agents/releases/{id}',[
            'uses'=>'AgentController@getAgentReleases',
            'as'=>'agents.releases'
        ]);

        Route::get('/agents/um-releases/{id}',[
            'uses'=>'AgentController@getAgentUMReleases',
            'as'=>'agents.um_releases'
        ]);

        Route::get('/agents/chkFullname',[
            'uses'=>'AgentController@chkFullname',
            'as'=>'agents.chkFullname'
        ]);

        //Developers
        Route::get('/developers',[
            'uses'=>'DeveloperController@index',
            'as'=>'developers'
        ]);
        Route::get('/developer/new',[
            'uses'=>'DeveloperController@getNewDeveloper',
            'as'=>'developer.new'
        ]);
        Route::post('/developer/new',[
            'uses'=>'DeveloperController@postNewDeveloper',
            'as'=>'developer.new'
        ]);
        Route::get('/developer/update',[
            'uses'=>'DeveloperController@getUpdateDeveloper',
            'as'=>'developer.update'
        ]);
        Route::post('/developer/update',[
            'uses'=>'DeveloperController@postUpdateDeveloper',
            'as'=>'developer.update'
        ]);
        Route::post('/developer/delete',[
            'uses'=>'DeveloperController@postDeleteDeveloper',
            'as'=>'developer.delete'
        ]);
        Route::get('/developer/info/{id}',[
            'uses'=>'DeveloperController@getDeveloperInfo',
            'as'=>'developer.info'
        ]);

        //Teams
        Route::get('/teams',[
            'uses'=>'TeamController@index',
            'as'=>'teams'
        ]);

        Route::get('/teams/new',[
            'uses'=>'TeamController@getNewTeam',
            'as'=>'teams.new'
        ]);

        Route::post('/teams/new',[
            'uses'=>'TeamController@postNewTeam',
            'as'=>'teams.new'
        ]);

        Route::get('/teams/update',[
            'uses'=>'TeamController@getUpdateTeam',
            'as'=>'teams.update'
        ]);

        Route::post('/teams/update',[
            'uses'=>'TeamController@postUpdateTeam',
            'as'=>'teams.update'
        ]);

        Route::post('/teams/delete',[
            'uses'=>'TeamController@postDeleteTeam',
            'as'=>'teams.delete'
        ]);

        //Projects
        Route::get('/projects',[
            'uses'=>'ProjectController@index',
            'as'=>'projects'
        ]);

        Route::get('/projects/new',[
            'uses'=>'ProjectController@getNewProject',
            'as'=>'project.new'
        ]);

        Route::post('/projects/new',[
            'uses'=>'ProjectController@postNewProject',
            'as'=>'project.new'
        ]);

        Route::get('/projects/update',[
            'uses'=>'ProjectController@getUpdateProject',
            'as'=>'project.update'
        ]);

        Route::post('/projects/update',[
            'uses'=>'ProjectController@postUpdateProject',
            'as'=>'project.update'
        ]);

        Route::post('/projects/delete',[
            'uses'=>'ProjectController@postDeleteProject',
            'as'=>'project.delete'
        ]);

        Route::get('/testdata', [
           'uses' =>'TestDataController@index',
            'as' => 'testdata'
        ]);
        //Managers
        Route::get('/managers',[
            'uses'=>'AdminController@getManagers',
            'as'=>'managers'
        ]);

        //Clients
        Route::get('/clients',[
            'uses'=>'ClientController@index',
            'as'=>'clients'
        ]);

        Route::get('/clients/month/{month}/{year}',[
            'uses'=>'ClientController@month',
            'as'=>'clients.month'
        ]);

        //Receivables
        Route::get('/receivables',[
            'uses'=>'ReceivableController@index',
            'as'=>'receivables'
        ]);

        Route::get('/receivables/summary',[
            'uses'=>'ReceivableController@summary',
            'as'=>'receivables.summary'
        ]);

        Route::get('/receivables/month/{month}/{year}',[
            'uses'=>'ReceivableController@month',
            'as'=>'receivables.month'
        ]);

        Route::get('/receivables/getRCVDDtls',[
            'uses'=>'ReceivableController@getRCVDDtls',
            'as'=>'receivables.getRCVDDtls'
        ]);

        Route::get('/receivables/new',[
            'uses'=>'ReceivableController@getNewReceivable',
            'as'=>'receivables.new'
        ]);

        Route::post('/receivables/new',[
            'uses'=>'ReceivableController@postNewReceivable',
            'as'=>'receivables.new'
        ]);

        Route::post('/receivables/update',[
            'uses'=>'ReceivableController@postUpdateReceivable',
            'as'=>'receivables.update'
        ]);

        Route::get('/receivables/edit/{id}',[
            'uses'=>'ReceivableController@getEditReceivable',
            'as'=>'receivables.edit'
        ]);

        /*Route::post('/receivables/edit/{id}',[
            'uses'=>'ReceivableController@postEditReceivable',
            'as'=>'receivables.edit'
        ]);*/

        /*Route::post('/commissions/receivables/delete',[
            'uses'=>'CommissionController@deleteLineReceivable',
            'as'=>'receivables.delete'
        ]);*/

        //Releases
        Route::get('/releases',[
            'uses'=>'CommReleaseController@index',
            'as'=>'releases'
        ]);

        Route::get('/releases/month/{month}/{year}',[
            'uses'=>'CommReleaseController@month',
            'as'=>'releases.month'
        ]);

        Route::get('/releases/new/{grid}/{rcvd_id}',[
            'uses'=>'CommReleaseController@getNewReleases',
            'as'=>'releases.new'
        ]);

        Route::post('/releases/new/post',[
            'uses'=>'CommReleaseController@postNewReleases',
            'as'=>'releases.new.post'
        ]);

        Route::get('/releases/get/details',[
            'uses'=>'CommReleaseController@editPostDetails',
            'as'=>'releases.get.details'
        ]);

        Route::post('/releases/post/details',[
            'uses'=>'CommReleaseController@postDetails',
            'as'=>'releases.post.details'
        ]);

        /*Route::get('/releases/edit/{id}',[
            'uses'=>'CommReleaseController@getNewReleases',
            'as'=>'releases.edit'
        ]);*/

        Route::get('/releases/editt/{id}',[
            'uses'=>'CommReleaseController@editt',
            'as'=>'releases.editt'
        ]);

        Route::post('/releases/edit',[
            'uses'=>'CommReleaseController@postNewReleases',
            'as'=>'releases.edit'
        ]);

        Route::post('/releases/update',[
            'uses'=>'CommReleaseController@updateRelease',
            'as'=>'releases.update'
        ]);

        Route::get('/releases/getPropDetails',[
            'uses'=>'CommReleaseController@getPropDetails',
            'as'=>'releases.getPropDetails'
        ]);

        Route::get('/releases/chk_CA_Bal',[
            'uses'=>'CommReleaseController@chk_CA_Bal',
            'as'=>'releases.chk_CA_Bal'
        ]);

        //Gross Release
        Route::get('/gross/new',[
            'uses'=>'GrossReleaseController@getNewLine',
            'as'=>'gross.new'
        ]);

        Route::post('/gross/new',[
            'uses'=>'GrossReleaseController@postNewLine',
            'as'=>'gross.new'
        ]);

        Route::get('/gross/update',[
            'uses'=>'GrossReleaseController@getUpdateLine',
            'as'=>'gross.update'
        ]);

        Route::post('/gross/update/',[
            'uses'=>'GrossReleaseController@postUpdateLine',
            'as'=>'gross.update'
        ]);

        Route::post('/gross/delete',[
            'uses'=>'GrossReleaseController@deleteLine',
            'as'=>'gross.delete'
        ]);

        Route::get('/gross/getitems',[
            'uses'=>'GrossReleaseController@getLineItems',
            'as'=>'gross.getitems'
        ]);

        //Cash Advances
        Route::get('/advances',[
            'uses'=>'CashAdvanceController@index',
            'as'=>'advances'
        ]);

        Route::get('/advances/new',[
            'uses'=>'CashAdvanceController@getNewAdvance',
            'as'=>'advances.new'
        ]);

        Route::post('/advances/new',[
            'uses'=>'CashAdvanceController@postNewAdvance',
            'as'=>'advances.new'
        ]);

        Route::get('/advances/payments',[
            'uses'=>'CashAdvanceController@payments',
            'as'=>'advances.payments'
        ]);

        Route::get('/advances/payment/new',[
            'uses'=>'CashAdvanceController@getNewPayment',
            'as'=>'advances.payment.new'
        ]);

        Route::post('/advances/payment/new',[
            'uses'=>'CashAdvanceController@postPayment',
            'as'=>'advances.payment.new'
        ]);

        Route::get('/advances/payment/edit/{id}',[
            'uses'=>'CashAdvanceController@getEditPayment',
            'as'=>'advances.payment.edit'
        ]);

        Route::post('/advances/payment/update',[
            'uses'=>'CashAdvanceController@postUpdatePayment',
            'as'=>'advances.payment.update'
        ]);

        Route::post('/advances/payment/delete',[
            'uses'=>'CashAdvanceController@payment_delete',
            'as'=>'advances.payment.delete'
        ]);

        Route::get('/advances/getAgentData',[
            'uses'=>'CashAdvanceController@getAgentData',
            'as'=>'advances.payment.get-agent-data'
        ]);

        Route::get('/advances/edit/{id}',[
            'uses'=>'CashAdvanceController@getEditAdvance',
            'as'=>'advances.edit'
        ]);

        /*Route::post('/advances/edit/{id}',[
            'uses'=>'CashAdvanceController@postEditAdvance',
            'as'=>'advances.edit'
        ]);*/

        Route::post('/advances/update',[
            'uses'=>'CashAdvanceController@postUpdateAdvance',
            'as'=>'advances.update'
        ]);

        Route::post('/advances/delete',[
            'uses'=>'CashAdvanceController@delete',
            'as'=>'advances.delete'
        ]);

        Route::get('/advances/balance/agents',[
            'uses'=>'CashAdvanceController@bal_agents',
            'as'=>'advances.balance.agents'
        ]);

        Route::get('/advances/balance/managers',[
            'uses'=>'CashAdvanceController@bal_managers',
            'as'=>'advances.balance.managers'
        ]);


    });

});

Route::get('/clear-all', function() {

    Artisan::call('cache:clear');
    Artisan::call('config:clear');
    Artisan::call('config:cache');
    Artisan::call('view:clear');
    Artisan::call('route:clear');
    //Artisan::call('route:cache');

    return "Cleared!";

});

