<?php

use App\Http\Controllers\Client\PackagesController;
use App\Http\Controllers\Client\PaymentController;
use App\Models\Branch;
use App\Models\Safe;
use App\Models\Store;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;





Route::get('otp',function(){return view('client.otp');});


Route::group(
    [
        'namespace' => 'Client',
        'prefix' => 'authentication'

    ], function () {
    Route::get('/',function(){return redirect(route('client.login'));});
    Route::get('login', 'Auth\LoginController@showLoginForm')->name('client.login');
    Route::post('login', 'Auth\LoginController@login');

    Route::get('/register', 'Auth\RegisterController@showRegistrationForm')->name('client.register');
    Route::post('/register/post', 'CompanyController@store')->name('client.register.company');

    
    Route::post('logout', 'Auth\LoginController@logout')->name('client.logout');

    Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
    Route::get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('client.verification.verify');
    Route::post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');

    Route::GET('password/confirm', 'Auth\ConfirmPasswordController@showConfirmForm')->name('client.password.confirm');
    Route::POST('password/confirm', 'Auth\ConfirmPasswordController@confirm');
    
    Route::GET('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('client.password.request');
    Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('client.password.email');
    
    Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('client.password.reset');
    Route::POST('password/reset', 'Auth\ResetPasswordController@reset')->name('client.password.update');
});



Route::group(
    ['middleware' => ['auth:client-web','CheckStatus'],
        'prefix' => '/dashboard',
        'namespace' => 'Client'
    ], function () {
    // clients Routes
    Route::get('/',function(){return redirect(route('client.home'));});
    Route::get('/home', 'HomeController@index')->name('client.home');

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

            Route::get('/index', 'ClientController@index')->name('client.users.index');
            Route::get('/create', 'ClientController@create')->name('client.users.create');
            Route::post('/update', 'ClientController@update')->name('client.users.update');
            Route::post('/delete', 'ClientController@destroy')->name('client.users.delete');
            Route::get('/edit/{id}', 'ClientController@edit')->name('client.users.edit');
            Route::post('/store', 'ClientController@store')->name('client.users.store');
        
        });


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


            Route::get('/',[PackagesController::class,'index'])->name('client.packages.index')->withoutMiddleware(['CheckStatus']);
            Route::post('/subscription/trail',[PackagesController::class,'trail'])->name('client.packages.trail')->withoutMiddleware(['CheckStatus']);
            Route::get('/{id}/checkout',[PackagesController::class,'checkout'])->name('client.packages.checkout')->withoutMiddleware(['CheckStatus']);
             Route::get('/Paypal/{paymentID}/{paymentToken}/{payerID}/{package}/{type}',[PaymentController::class,'validatePayment'])->withoutMiddleware(['CheckStatus']);
        
        });

    Route::get('buy-bills/{id}/show', 'BuyBillController@get__invoices')->name('client.buy_bills.filter.by_id');
    Route::get('sale-bills/{id}/show', 'SaleBillController@get_client_invoices')->name('client.sale_bills.filter.by_id');
    Route::get('cash-history/{id}/show', 'CashController@cash_clients_by_id')->name('client.cash.clients.by.id');
    Route::post('get_client_debit', 'CashController@get_client_debit_by_id')->name('get_client_debit');
    
    

    // ClientProfile Routes
    Route::group(['prefix' => 'profile',], function () {

        Route::get('/edit', 'ClientProfileController@edit')->name('client.profile.edit');
        Route::post('/edit/post', 'ClientProfileController@update')->name('client.profile.update');
        Route::post('/password/edit', 'ClientProfileController@password')->name('client.profile.password');

    });
   
// settings

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

    Route::get('/basic', 'SettingsController@basic')->name('client.basic.settings.edit');
    Route::get('/billing', 'SettingsController@billing')->name('client.billing.settings.edit');
    Route::get('/email', 'SettingsController@email')->name('client.email.settings.edit');
    Route::get('/pre', 'SettingsController@pre')->name('client.pre.settings.edit');
    Route::get('/extra', 'SettingsController@extra')->name('client.extra.settings.edit');
    Route::get('/backup', 'SettingsController@backup')->name('client.backup.settings.edit');
    Route::get('/backup/get', 'SettingsController@get_backup')->name('client.get.backup');
    Route::get('/screens','SettingsController@screens_settings')->name('screens.settings');

    Route::post('client-basic-settings-update', 'SettingsController@update_basic')->name('client.basic.settings.update');
    Route::post('client-billing-settings-update', 'SettingsController@update_billing')->name('client.billing.settings.update');
    Route::post('client-fiscal-settings-update', 'SettingsController@update_fiscal')->name('client.fiscal.settings.update');
    Route::post('client-email-settings-update', 'SettingsController@update_email')->name('client.email.settings.update');
    Route::post('client-pre-settings-update', 'SettingsController@update_pre')->name('client.pre.settings.update');
    Route::post('client-extra-settings-update', 'SettingsController@update_extra')->name('client.extra.settings.update');
    Route::post('client-extra-settings-update-2', 'SettingsController@update_extra_2')->name('client.extra.settings.update_2');
    Route::post('client-extra-settings-update-3', 'SettingsController@update_extra_3')->name('client.extra.settings.update_3');
    Route::post('client-restore', 'SettingsController@restore')->name('client.restore');
    Route::post('screens-settings-post','SettingsController@screens_settings_post')->name('screens.settings.post');

    });

    // currencies Routes
    Route::resource('currencies', 'CurrencyController')->names([
        'index' => 'client.currencies.index',
        'create' => 'client.currencies.create',
        'update' => 'client.currencies.update',
        'destroy' => 'client.currencies.destroy',
        'edit' => 'client.currencies.edit',
        'store' => 'client.currencies.store',
    ]);


    // Branches Routes
    Route::group(['prefix' => 'branches',], function () {

    Route::get('/index', 'BranchController@index')->name('client.branches.index');
    Route::get('/create', 'BranchController@create')->name('client.branches.create');
    Route::post('/update', 'BranchController@update')->name('client.branches.update');
    Route::post('/delete', 'BranchController@delete')->name('client.branches.delete');
    Route::get('/edit/{id}', 'BranchController@edit')->name('client.branches.edit');
    Route::post('/store', 'BranchController@store')->name('client.branches.store');

});

    // Branches Routes
    Route::group(['prefix' => 'branches',], function () {

        Route::get('/index', 'BranchController@index')->name('client.branches.index');
        Route::get('/create', 'BranchController@create')->name('client.branches.create');
        Route::post('/update', 'BranchController@update')->name('client.branches.update');
        Route::post('/delete', 'BranchController@delete')->name('client.branches.delete');
        Route::get('/edit/{id}', 'BranchController@edit')->name('client.branches.edit');
        Route::post('/store', 'BranchController@store')->name('client.branches.store');
    
    });
    
    
    
        // Stores Routes
        Route::group(['prefix' => 'stores',], function () {
    
            Route::get('/index', 'StoreController@index')->name('client.stores.index');
            Route::get('/create', 'StoreController@create')->name('client.stores.create');
            Route::post('/update', 'StoreController@update')->name('client.stores.update');
            Route::post('/delete', 'StoreController@delete')->name('client.stores.delete');
            Route::get('/edit/{id}', 'StoreController@edit')->name('client.stores.edit');
            Route::post('/store', 'StoreController@store')->name('client.stores.store');
            Route::get('/inventory', 'StoreController@inventory_get')->name('client.inventory.get');
            Route::post('/inventory', 'StoreController@inventory_post')->name('client.inventory.post');
    
        });

    // Categories Routes
    Route::group(['prefix' => 'categories',], function () {

        Route::get('/index', 'CategoryController@index')->name('client.categories.index');
        Route::get('/create', 'CategoryController@create')->name('client.categories.create');
        Route::post('/store', 'CategoryController@store')->name('client.categories.store');
        Route::post('/update', 'CategoryController@update')->name('client.categories.update');
        Route::post('/delete', 'CategoryController@delete')->name('client.categories.delete');
        Route::get('/edit/{id}', 'CategoryController@edit')->name('client.categories.edit');

    });


    
    // Safes Routes
    Route::group(['prefix' => 'safes',], function () {

        Route::get('/index', 'SafeController@index')->name('client.safes.index');
        Route::get('/create', 'SafeController@create')->name('client.safes.create');
        Route::post('/store', 'SafeController@store')->name('client.safes.store');
        Route::get('/edit/{id}', 'SafeController@edit')->name('client.safes.edit');
        Route::post('/update', 'SafeController@update')->name('client.safes.update');
        Route::post('/delete', 'SafeController@delete')->name('client.safes.delete');

    });



    // units Routes
    Route::group(['prefix' => 'units',], function () {

        Route::get('/index', 'UnitController@index')->name('client.units.index');
        Route::get('/create', 'UnitController@create')->name('client.units.create');
        Route::post('/store', 'UnitController@store')->name('client.units.store');
        Route::post('/update', 'UnitController@update')->name('client.units.update');
        Route::post('/delete', 'UnitController@delete')->name('client.units.delete');
        Route::get('/edit/{id}', 'UnitController@edit')->name('client.units.edit');

    });
    Route::group(['prefix' => 'products',], function () {

        Route::get('/index', 'ProductController@index')->name('client.products.index');
        Route::get('/show/{id}', 'ProductController@show')->name('client.products.show');
        Route::get('/create', 'ProductController@create')->name('client.products.create');
        Route::post('/update', 'ProductController@update')->name('client.products.update');
        Route::post('/delete', 'ProductController@delete')->name('client.products.delete');
        Route::get('/edit/{id}', 'ProductController@edit')->name('client.products.edit');
        Route::post('/store', 'ProductController@store')->name('client.products.store');
        Route::get('/out-stock', 'ProductController@empty')->name('client.products.out');
        Route::get('/limited-stock', 'ProductController@limited')->name('client.products.limited');
        Route::get('/print', 'ProductController@print')->name('client.products.print');
        Route::get('/services', 'ProductController@services')->name('client.services.index');
        Route::post('/units_update', 'ProductController@units_update')->name('client.products.units.update');


    
    });



    // outer_clients Routes
    Route::group(['prefix' => 'outer_clients',], function () {

        Route::get('/index', 'OuterClientController@index')->name('client.outer_clients.index');
        Route::get('/create', 'OuterClientController@create')->name('client.outer_clients.create');
        Route::post('/store', 'OuterClientController@store')->name('client.outer_clients.store');
        Route::post('/update', 'OuterClientController@update')->name('client.outer_clients.update');
        Route::post('/delete', 'OuterClientController@delete')->name('client.outer_clients.delete');
        Route::get('/edit/{id}', 'OuterClientController@edit')->name('client.outer_clients.edit');
        Route::get('/print', 'OuterClientController@print')->name('client.outer_clients.print');

        Route::get('{id}/cash/pay', 'CashController@add_cash_clients')->name('client.add.cash.clients');
        Route::post('pay/store', 'CashController@store_cash_clients')->name('client.store.cash.clients');
        Route::get('{outer_client}/cash/pay/{opreation}', 'CashController@edit_cash_clients')->name('client.edit.cash.clients');
        Route::post('pay/delete', 'CashController@destroy_cash_clients')->name('client.destroy.cash.clients');
        Route::post('pay/update', 'CashController@update_cash_clients')->name('client.update.cash.clients');

        Route::get('{id}/bank/pay', 'CashBankController@add_cashbank_clients')->name('client.add.cashbank.clients');
        Route::post('bank/store', 'CashBankController@store_cashbank_clients')->name('client.store.cashbank.clients');
        Route::get('{id}/bank/pay/{opreation}', 'CashBankController@edit_cashbank_clients')->name('client.edit.cashbank.clients');
        Route::post('bank/delete', 'CashBankController@destroy_cashbank_clients')->name('client.destroy.cashbank.clients');
    
    
        Route::get('{id}/cash/advance', 'CashController@give_cash_clients')->name('client.give.cash.clients');
        Route::post('cash/advance/save', 'CashController@store2_cash_clients')->name('client.store2.cash.clients');
        Route::get('{outer_client}/advance/{opreation}/edit', 'CashController@edit_borrow_clients')->name('client.edit.borrow.clients');
        Route::post('borrow/update', 'CashController@update_cash_borrow_clients')->name('client.update.cash.borrow.clients');
        Route::post('cash/advance/delete', 'CashController@destroy_borrow_clients')->name('client.destroy.borrow.cash.clients');
    

        Route::get('{id}/bank/advance', 'CashBankController@give_advance_bank_clients')->name('client.give.borrow.bank.clients');
        Route::post('bank/advance/save', 'CashBankController@store2_bank_clients')->name('client.store2.bank.clients');
        // Route::get('{id}/advance/{opreation}/edit', 'CashController@edit_borrow_clients')->name('client.edit.borrow.clients');
        Route::post('bank/advance/delete', 'CashBankController@destroy_bank_borrow_clients')->name('client.destroy.borrow.bank.clients');
    
        
    });

        // suppliers Routes
        Route::group(['prefix' => 'suppliers',], function () {

            Route::get('/index', 'SupplierController@index')->name('client.suppliers.index');
            Route::get('/create', 'SupplierController@create')->name('client.suppliers.create');
            Route::post('/store', 'SupplierController@store')->name('client.suppliers.store');
            Route::post('/update', 'SupplierController@update')->name('client.suppliers.update');
            Route::post('/delete', 'SupplierController@delete')->name('client.suppliers.delete');
            Route::get('/edit/{id}', 'SupplierController@edit')->name('client.suppliers.edit');
            Route::get('/print', 'SupplierController@print')->name('client.suppliers.print');

            Route::get('{id}/cash/pay', 'CashController@add_cash_suppliers')->name('client.add.cash.suppliers');
            Route::post('cash/pay', 'CashController@store_cash_suppliers')->name('client.store.cash.suppliers');
            Route::get('clients-cash-suppliers/{id}', 'CashController@cash_suppliers')->name('client.cash.suppliers');
            Route::post('cash/delete', 'CashController@destroy_cash_suppliers')->name('client.destroy.cash.suppliers');
            Route::get('{supplier}/cash/pay/{opreation}', 'CashController@edit_cash_suppliers')->name('client.edit.cash.suppliers');
            Route::post('/cash/pay/edit', 'CashController@update_cash_suppliers')->name('client.update.cash.suppliers');
        
        
            Route::get('{id}/bank/pay', 'CashBankController@add_cashbank_suppliers')->name('client.add.cashbank.suppliers');
            Route::post('bank/pay', 'CashBankController@store_cashbank_suppliers')->name('client.store.cashbank.suppliers');
            Route::get('clients-edit-cashbank-suppliers/{id}', 'CashBankController@edit_cashbank_suppliers')->name('client.edit.cashbank.suppliers');
            Route::post('bank/delete', 'CashBankController@destroy_cashbank_suppliers')->name('client.destroy.cashbank.suppliers');



            Route::get('{id}/take/advance/cash', 'CashController@take_cash_borrow_form_supplier')->name('client.give.cash.suppliers');
            Route::post('take/advance', 'CashController@store_cash_borrow_form_supplier')->name('client.store2.cash.suppliers');
            Route::get('{supplier}/advance/edit/{opreation}', 'CashController@edit_borrow_suppliers')->name('client.edit.borrow.suppliers');
            Route::post('advance/edit', 'CashController@update_borrow_suppliers')->name('client.update.borrow.suppliers');
            Route::post('advance/delete', 'CashController@destroy_cash_borrow_from_suppliers')->name('client.destroy.borrow.cash.suppliers');
        
        
            Route::get('{id}/take/advance/bank', 'CashBankController@take_bank_borrow_form_supplier')->name('client.add.advance.bank.suppliers');
            Route::post('take/advance/bank', 'CashBankController@store_bank_borrow_form_supplier')->name('client.store.advance.bank.suppliers');
            Route::post('/advance/bank/delete', 'CashBankController@destroy_bank_borrow_form_supplier')->name('client.destroy.advance.bank.suppliers');

            
    
        });
    
  



    // banks Routes
    Route::group(['prefix' => 'banks',], function () {

        Route::get('/index', 'BankController@index')->name('client.banks.index');
        Route::get('/create', 'BankController@create')->name('client.banks.create');
        Route::post('/store', 'BankController@store')->name('client.banks.store');
        Route::post('/update', 'BankController@update')->name('client.banks.update');
        Route::post('/delete', 'BankController@delete')->name('client.banks.delete');
        Route::get('/edit/{id}', 'BankController@edit')->name('client.banks.edit');

    });

    // safe  opreations
    Route::group(['prefix' => 'opreations',], function () {

        Route::get('/bank/{id}/process/{type}', 'BankController@banks_process')->name('client.banks.process');
        Route::post('/bank/process/store', 'BankController@banks_process_store')->name('client.banks.process.store');
        Route::post('/bank/process/delete', 'BankController@banks_process_destroy')->name('client.banks.process.delete');
    
        Route::get('/bank/{id}/process/bank-balance/transfer', 'BankController@banks_transfer')->name('client.banks.transfer');
        Route::post('/bank/process/transfer/store', 'BankController@banks_transfer_store')->name('client.banks.transfer.store');
        Route::post('/bank/process/destroy', 'BankController@banks_transfer_destroy')->name('client.banks.transfer.delete');
    
        Route::get('/bank/{id}/process/bank/transfer/safe', 'BankController@bank_safe_transfer')->name('client.bank.safe.transfer');
        Route::post('/bank/process/transfer/safe/store', 'BankController@bank_safe_transfer_store')->name('client.bank.safe.transfer.store');
        Route::post('/bank/process/transfer/safe/delete', 'BankController@bank_safe_transfer_destroy')->name('client.bank.safe.transfer.delete');
    

        Route::get('/safe/{id}/process/safe/transfer/bank', 'BankController@safe_bank_transfer')->name('client.safe.bank.transfer');
        Route::post('/safe/process/safe/transfer/store', 'BankController@safe_bank_transfer_store')->name('client.safe.bank.transfer.store');
        Route::post('/safe/process/safe/transfer/delete', 'BankController@safe_bank_transfer_destroy')->name('client.safe.bank.transfer.destroy');
    
    });



    // expenses Routes
    Route::group(['prefix' => 'expenses',], function () {
        Route::get('/index', 'ExpenseController@index')->name('client.expenses.index');
        Route::get('/create', 'ExpenseController@create')->name('client.expenses.create');
        Route::post('/store', 'ExpenseController@store')->name('client.expenses.store');
        Route::post('/update', 'ExpenseController@update')->name('client.expenses.update');
        Route::post('/delete', 'ExpenseController@delete')->name('client.expenses.delete');
        Route::get('/edit/{id}', 'ExpenseController@edit')->name('client.expenses.edit');

        Route::get('/fixed', 'ExpenseController@fixed_expenses')->name('client.fixed.expenses');
        Route::post('/fixed/store', 'ExpenseController@fixed_expenses_store')->name('client.fixed.expenses.store');
        Route::post('/fixed/destroy', 'ExpenseController@fixed_expenses_destroy')->name('client.fixed.expenses.destroy');
        Route::get('/fixed/edit/{id?}', 'ExpenseController@fixed_expenses_edit')->name('client.fixed.expenses.edit');
        Route::post('/fixed/update', 'ExpenseController@fixed_expenses_update')->name('client.fixed.expenses.update');
    
    });

         // capitals Routes
        Route::group(['prefix' => 'capitals',], function () {

            Route::get('/index', 'CapitalController@index')->name('client.capitals.index');
            Route::get('/create', 'CapitalController@create')->name('client.capitals.create');
            Route::post('/store', 'CapitalController@store')->name('client.capitals.store');
            Route::post('/update', 'CapitalController@update')->name('client.capitals.update');
            Route::post('/delete', 'CapitalController@destroy')->name('client.capitals.delete');
            Route::get('/edit/{id}', 'CapitalController@edit')->name('client.capitals.edit');
    
        });

    // gifts Routes
    Route::resource('gifts', 'GiftController')->names([
        'index' => 'client.gifts.index',
        'create' => 'client.gifts.create',
        'update' => 'client.gifts.update',
        'destroy' => 'client.gifts.destroy',
        'edit' => 'client.gifts.edit',
        'store' => 'client.gifts.store',
        'show' => 'client.gifts.show',
    ]);

    Route::get('clients-emails-clients', 'EmailController@emails_clients')->name('client.emails.clients');
    Route::post('clients-send-client-email', 'EmailController@send_client_email')->name('client.send.client.email');

    Route::get('clients-emails-suppliers', 'EmailController@emails_suppliers')->name('client.emails.suppliers');
    Route::post('clients-send-supplier-email', 'EmailController@send_supplier_email')->name('client.send.supplier.email');

// quotations Routes

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

    Route::get('index', 'QuotationController@index')->name('client.quotations.index');
    Route::get('create', 'QuotationController@create')->name('client.quotations.create');
    Route::get('edit/{id}', 'QuotationController@edit')->name('client.quotations.edit');
    Route::post('delete', 'QuotationController@delete')->name('client.quotations.delete');
    Route::post('/search_filter', 'QuotationController@search_filter')->name('client.quotations.search_filter');
    Route::get('print/{id}', 'QuotationController@print')->name('client.quotations.print');


    Route::post('get', 'QuotationController@get_product_price');
    Route::post('element/delete', 'QuotationController@destroy_element');
    Route::post('post', 'QuotationController@save');
    Route::post('discount', 'QuotationController@apply_discount');
    Route::post('extra', 'QuotationController@apply_extra');
    Route::post('changeQuotation', 'QuotationController@changeQuotation');
    Route::get('send/{id?}', 'QuotationController@send')->name('client.quotations.send');
    Route::get('redirect', 'QuotationController@redirect')->name('client.quotations.redirect');
    Route::post('getOuterClientDetails', 'QuotationController@get_outer_client_details');
    Route::post('getProducts', 'QuotationController@get_products');
    Route::post('/convert-to-salebill/{id?}', 'QuotationController@convert_to_salebill')->name('convert.to.salebill');
    Route::post('total/update', 'QuotationController@update_total');
    Route::post('updatePriceAndQuuantity', 'QuotationController@updatePriceAndQuuantity');
    Route::post('checkInvoice', 'QuotationController@checkInvoice');
    Route::post('saveAll', 'QuotationController@saveAll');
    Route::post('cancel', 'QuotationController@cancel')->name('client.quotations.cancel');




});


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


        Route::get('index', 'PurchaseOrderController@index')->name('client.purchase_orders.index');
        Route::get('create', 'PurchaseOrderController@create')->name('client.purchase_orders.create');
        Route::post('update', 'PurchaseOrderController@update')->name('client.purchase_orders.update');
        Route::post('delete', 'PurchaseOrderController@delete')->name('client.purchase_orders.delete');
        Route::get('edit/{id}', 'PurchaseOrderController@edit')->name('client.purchase_orders.edit');
        Route::post('store', 'PurchaseOrderController@store')->name('client.purchase_orders.store');
        Route::get('show', 'PurchaseOrderController@show')->name('client.purchase_orders.out');


        Route::post('get', 'PurchaseOrderController@get_product_price');
        Route::post('elements', 'PurchaseOrderController@get_purchase_order_elements');
        Route::post('element/delete', 'PurchaseOrderController@destroy_element');
        Route::post('element/destroy', 'PurchaseOrderController@delete_element');
        Route::post('post', 'PurchaseOrderController@save');
        Route::post('discount', 'PurchaseOrderController@apply_discount');
        Route::post('extra', 'PurchaseOrderController@apply_extra');
        Route::post('updateData', 'PurchaseOrderController@updateData');
        Route::post('changepurchase_order', 'PurchaseOrderController@changePurchaseOrder');
    
        Route::get('send/{id?}', 'PurchaseOrderController@send')->name('client.purchase_orders.send');
        Route::get('/purchase_orders-redirect', 'PurchaseOrderController@redirect')->name('client.purchase_orders.redirect');
    
        Route::post('get-edit', 'PurchaseOrderController@get_edit_product_price');
        Route::post('element/update', 'PurchaseOrderController@update_element');
        Route::post('edit-element', 'PurchaseOrderController@edit_element');
    
        Route::post('getSupplierDetails', 'PurchaseOrderController@get_supplier_details');
        Route::post('getProducts', 'PurchaseOrderController@get_products');
        Route::delete('/purchase_orders-deleteBill', 'PurchaseOrderController@delete_bill')->name('client.purchase_orders.deleteBill');
    
        Route::get('/convert-to-buybill/{id?}', 'PurchaseOrderController@convert_to_buybill')->name('convert.to.buybill');


    });



// sale_bills Routes
    Route::group(['prefix' => 'sale_bills',], function () {

        Route::get('/index', 'SaleBillController@index')->name('client.sale_bills.index');
        Route::get('/create', 'SaleBillController@create')->name('client.sale_bills.create');
        Route::post('/store', 'SaleBillController@store')->name('client.sale_bills.store');
        Route::post('/update', 'SaleBillController@update')->name('client.sale_bills.update');
        Route::post('/delete', 'SaleBillController@delete')->name('client.sale_bills.delete');
        Route::get('/edit/{id}', 'SaleBillController@edit')->name('client.sale_bills.edit');
        Route::post('/search_filter', 'SaleBillController@search_filter')->name('client.sale_bills.search_filter');
        Route::get('/print/{id}', 'SaleBillController@print')->name('client.sale_bills.print');
        Route::post('/checkInvoice', 'SaleBillController@checkInvoice')->name('client.sale_bills.checkInvoice');
        Route::post('/inv/product/get', 'SaleBillController@get_product_by_inv');
        Route::post('/get', 'SaleBillController@get_product_price');
        Route::post('/get/UnitPrice', 'SaleBillController@getUnitPrice');
        Route::post('/getOuterClientDetails', 'SaleBillController@get_outer_client_details');
        Route::post('/element/delete', 'SaleBillController@delete_element');
        Route::post('/post', 'SaleBillController@save');
        Route::post('/updatePriceAndQuuantity', 'SaleBillController@updatePriceAndQuuantity');    
        Route::post('/discount', 'SaleBillController@apply_discount');
        Route::post('/extra', 'SaleBillController@apply_extra');
        Route::post('/get-return', 'SaleBillController@get_return');
        Route::post('/post-return', 'SaleBillController@post_return')->name('client.sale_bills.post.return');
        Route::get('/get-returns', 'SaleBillController@get_returns')->name('client.sale_bills.returns');
        Route::get('/redirect', 'SaleBillController@redirect')->name('client.sale_bills.redirect');
        Route::get('/send/{id?}', 'SaleBillController@send')->name('client.sale_bills.send');
        Route::post('/pay/store/cash', 'SaleBillController@store_cash_outer_clients')->name('client.store.cash.sale_bills');
        Route::post('/getProducts', 'SaleBillController@get_products');
        Route::delete('/deleteBill', 'SaleBillController@delete_bill')->name('client.sale_bills.deleteBill');
        Route::post('/deleteSaleBill', 'SaleBillController@destroy')->name('client.sale_bills.cancel');
        Route::post('/pay-delete', 'SaleBillController@pay_delete')->name('sale_bills.pay.delete');
        Route::post('/saveAll', 'SaleBillController@saveAll');
        Route::post('/check_payment', 'SaleBillController@check_payment');
        Route::post('total/update', 'SaleBillController@update_total');
        Route::post('check_sale_bill_elment', 'SaleBillController@check_sale_bill_elment');

    });

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

        Route::get('/index', 'BuyBillController@index')->name('client.buy_bills.index');
        Route::get('/create', 'BuyBillController@create')->name('client.buy_bills.create');
        Route::post('/store', 'BuyBillController@store')->name('client.buy_bills.store');
        Route::post('/update', 'BuyBillController@update')->name('client.buy_bills.update');
        Route::post('/delete', 'BuyBillController@delete')->name('client.buy_bills.delete');
        Route::get('/edit/{id}', 'BuyBillController@edit')->name('client.buy_bills.edit');
        Route::post('/search_filter', 'BuyBillController@')->name('client.buy_bills.search_filter');
        Route::get('/print/{id}', 'BuyBillController@print')->name('client.buy_bills.print');
        Route::post('/get/UnitPrice', 'BuyBillController@getUnitPrice');
        Route::post('/getSupplierDetails', 'BuyBillController@get_supplier_details');
        Route::post('/search_filter', 'BuyBillController@search_filter')->name('client.buy_bills.search_filter');
        Route::post('/get', 'BuyBillController@get_product_price');
        Route::post('/post', 'BuyBillController@save');
        Route::post('/updatePriceAndQuuantity', 'BuyBillController@updatePriceAndQuuantity');
        Route::post('/element/delete', 'BuyBillController@delete_element');
        Route::post('/discount', 'BuyBillController@apply_discount');
        Route::post('/extra', 'BuyBillController@apply_extra');
        Route::post('/saveAll', 'BuyBillController@saveAll');
        Route::post('/cash/suppliers/store', 'BuyBillController@store_cash_suppliers')->name('client.store.cash.suppliers.buyBill');
        Route::post('/pay-delete', 'BuyBillController@pay_delete')->name('buy_bills.pay.delete');
        Route::get('/redirect', 'BuyBillController@redirect')->name('client.buy_bills.redirect');
        Route::post('/checkInvoice', 'BuyBillController@checkInvoice')->name('client.buy_bills.checkInvoice');
        Route::post('/deleteBuyBill', 'BuyBillController@destroy')->name('client.buy_bills.cancel');
        Route::post('total/update', 'BuyBillController@update_total');


        Route::post('/get-return', 'BuyBillController@get_return');
        Route::post('/post-return', 'BuyBillController@post_return')->name('client.buy_bills.post.return');
        Route::get('/get-returns', 'BuyBillController@get_returns')->name('client.buy_bills.returns');
        Route::get('/send/{id?}', 'BuyBillController@send')->name('client.buy_bills.send');
    
    });

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

    Route::get('/journal', 'AccountingController@journal_get')->name('client.journal.get');
    Route::post('journal/post', 'AccountingController@journal_post')->name('client.journal.post');
    
    });



    // summary routes
    Route::group(['prefix' => 'summary',], function () {

    Route::get('/clients', 'SummaryController@get_clients_summary')->name('clients.summary.get');
    Route::get('/client/{id}', 'SummaryController@client_summary')->name('clients.summary');
    Route::get('/clients-result', 'SummaryController@post_clients_summary')->name('clients.summary.post')->withoutMiddleware(['auth:client-web','verified','CheckStatus']);

    Route::get('/suppliers', 'SummaryController@get_suppliers_summary')->name('suppliers.summary.get');
    Route::get('/suppliers/{id}', 'SummaryController@suppliers_summary')->name('suppliers.summary');
    Route::get('/suppliers-result', 'SummaryController@post_suppliers_summary')->name('suppliers.summary.post')->withoutMiddleware(['auth:client-web','verified','CheckStatus']);

    Route::get('/employees', 'SummaryController@get_employees_summary')->name('employees.summary.get');
    Route::post('/employees-result', 'SummaryController@post_employees_summary')->name('employees.summary.post');

    Route::post('/clients-summary/send', 'SummaryController@send_client_summary')
        ->name('client.summary.send');

    Route::post('/suppliers-summary/send', 'SummaryController@send_supplier_summary')
        ->name('supplier.summary.send');
    });


// reports
Route::group(['prefix' => 'reports',], function () {
    Route::get('/','ReportController@reports')->name('client.reports');
    Route::get('/1/get', 'ReportController@get_report1')->name('client.report1.get');
    Route::post('/1/post', 'ReportController@post_report1')->name('client.report1.post');

    Route::get('/2/get', 'ReportController@get_report2')->name('client.report2.get');
    Route::post('/2/post', 'ReportController@post_report2')->name('client.report2.post');

    Route::get('/3/get', 'ReportController@get_report3')->name('client.report3.get');
    Route::post('/3/post', 'ReportController@post_report3')->name('client.report3.post');

    Route::get('/4/get', 'ReportController@get_report4')->name('client.report4.get');
    Route::post('/4/post', 'ReportController@post_report4')->name('client.report4.post');

    Route::get('/5/get', 'ReportController@get_report5')->name('client.report5.get');
    Route::post('/5/post', 'ReportController@post_report5')->name('client.report5.post');

    Route::get('/6/get', 'ReportController@get_report6')->name('client.report6.get');
    Route::post('/6/post', 'ReportController@post_report6')->name('client.report6.post');

    Route::get('/7/get', 'ReportController@get_report7')->name('client.report7.get');
    Route::post('/7/post', 'ReportController@post_report7')->name('client.report7.post');

    Route::get('/8/get', 'ReportController@get_report8')->name('client.report8.get');
    Route::post('/8/post', 'ReportController@post_report8')->name('client.report8.post');

    Route::get('/9/get', 'ReportController@get_report9')->name('client.report9.get');
    Route::post('/9/post', 'ReportController@post_report9')->name('client.report9.post');

    Route::get('/10/get', 'ReportController@get_report10')->name('client.report10.get');
    Route::post('/10/post', 'ReportController@post_report10')->name('client.report10.post');

    Route::get('/11/get', 'ReportController@get_report11')->name('client.report11.get');
    Route::post('/11/post', 'ReportController@post_report11')->name('client.report11.post');

    Route::get('/12/get', 'ReportController@get_report12')->name('client.report12.get');
    Route::post('/12/post', 'ReportController@post_report12')->name('client.report12.post');

    Route::get('/profit/get', 'ReportController@get_report13')->name('client.report13.get');
    Route::post('/13/post', 'ReportController@post_report13')->name('client.report13.post');

    Route::get('/expense', 'ReportController@get_report14')->name('client.report14.get');
    Route::post('/14/post', 'ReportController@post_report14')->name('client.report14.post');

    Route::get('/bank', 'ReportController@get_report15')->name('client.report15.get');
    Route::post('/15/post', 'ReportController@post_report15')->name('client.report15.post');

    Route::get('/16/get', 'ReportController@get_report16')->name('client.report16.get');
    Route::post('/16/post', 'ReportController@post_report16')->name('client.report16.post');

    Route::get('/17/get', 'ReportController@get_report17')->name('client.report17.get');
    Route::post('/17/post', 'ReportController@post_report17')->name('client.report17.post');

    Route::get('/18/get', 'ReportController@get_report18')->name('client.report18.get');
    Route::post('/18/post', 'ReportController@post_report18')->name('client.report18.post');

    Route::get('/19/get', 'ReportController@get_report19')->name('client.report19.get');
    Route::post('/19/post', 'ReportController@post_report19')->name('client.report19.post');

    Route::get('/20/get', 'ReportController@get_report20')->name('client.report20.get');
    Route::post('/20/post', 'ReportController@post_report20')->name('client.report20.post');

    Route::get('/21/get', 'ReportController@get_report21')->name('client.report21.get');
    Route::post('/21/post', 'ReportController@post_report21')->name('client.report21.post');

    Route::get('/22/get', 'ReportController@get_report22')->name('client.report22.get');
    Route::post('/22/post', 'ReportController@post_report22')->name('client.report22.post');


});


        // employees Routes
        Route::group(['prefix' => 'roles',], function () {

            Route::get('/index', 'RoleController@index')->name('client.roles.index');
            Route::get('/create', 'RoleController@create')->name('client.roles.create');
            Route::post('/store', 'RoleController@store')->name('client.roles.store');
            Route::post('/update', 'RoleController@update')->name('client.roles.update');
            Route::post('/delete', 'RoleController@delete')->name('client.roles.delete');
            Route::get('/edit/{id}', 'RoleController@edit')->name('client.roles.edit');
    

    });



    Route::get('export-suppliers', 'ImportExportController@export_suppliers')->name('suppliers.export');
    Route::post('import-suppliers', 'ImportExportController@import_suppliers')->name('suppliers.import');
    Route::get('export-outer-clients', 'ImportExportController@export_outer_clients')->name('outer_clients.export');
    Route::post('import-outer-clients', 'ImportExportController@import_outer_clients')->name('outer_clients.import');
    Route::get('export-products', 'ImportExportController@export_products')->name('products.export');
    Route::post('import-products', 'ImportExportController@import_products')->name('products.import');



    // employees Routes
    Route::group(['prefix' => 'employees',], function () {

        Route::get('/index', 'EmployeeController@index')->name('client.employees.index');
        Route::get('/create', 'EmployeeController@create')->name('client.employees.create');
        Route::post('/store', 'EmployeeController@store')->name('client.employees.store');
        Route::post('/update', 'EmployeeController@update')->name('client.employees.update');
        Route::post('/delete', 'EmployeeController@delete')->name('client.employees.delete');
        Route::get('/edit/{id}', 'EmployeeController@edit')->name('client.employees.edit');

        Route::get('/{id}/cash', 'EmployeeController@get_cash')->name('employees.get.cash');
        Route::post('employees-cash-post', 'EmployeeController@post_cash')->name('employees.post.cash');
        Route::get('/{id}/cash/{cash}', 'EmployeeController@edit_cash')->name('employees.cash.edit');
        Route::post('employees-cash-update', 'EmployeeController@update_cash')->name('employees.cash.update');
        Route::post('employees-cash-destroy', 'EmployeeController@destroy_cash')->name('employees.cash.destroy');

        Route::get('/{id}/borrow', 'EmployeeController@get_borrow')->name('employees.get.borrow');
        Route::post('employees-borrow-post', 'EmployeeController@post_borrow')->name('employees.post.borrow');
        Route::get('/{id}/borrow/{borrow}', 'EmployeeController@edit_borrow')->name('employees.borrow.edit');
        Route::post('employees-borrow-update', 'EmployeeController@update_borrow')->name('employees.borrow.update');
        Route::post('employees-borrow-destroy', 'EmployeeController@destroy_borrow')->name('employees.borrow.destroy');


});


});


Route::group(
    ['middleware' => ['auth:admin-web'],
        'prefix' => 'admin',
        'namespace' => 'Admin'
    ], function () {
    Route::get('/', 'HomeController@index')->name('admin.home');

    Route::get('profile/edit/{id}', 'AdminProfileController@edit')->name('admin.profile.edit');
    Route::patch('profile/edit/{id}', 'AdminProfileController@update')->name('admin.profile.update');
    Route::patch('profile/store/{id}', 'AdminProfileController@store')->name('admin.profile.store');

    // Contacts Routes
    Route::resource('contacts', 'ContactController')->names([
        'index' => 'admin.contacts.index',
        'show' => 'admin.contacts.show',
        'destroy' => 'admin.contacts.destroy'
    ]);
    Route::patch('contacts-make-as-read', 'ContactController@makeAsRead')->name('admin.contacts.make.as.read');
    Route::patch('contacts-make-as-important', 'ContactController@makeAsImportant')->name('admin.contacts.make.as.important');
    Route::patch('contacts-make-as-destroy', 'ContactController@makeAsDestroy')->name('admin.contacts.make.as.destroy');
    Route::patch('contacts-print', 'ContactController@print')->name('admin.contacts.print');
    Route::get('contacts-important', 'ContactController@showImportant')->name('admin.contacts.important');

    // Companies Routes
    Route::resource('companies', 'CompanyController')->names([
        'index' => 'admin.companies.index',
        'update' => 'admin.companies.update',
        'edit' => 'admin.companies.edit',
        'destroy' => 'admin.companies.destroy',
    ]);
    Route::get('client/{id}','CompanyController@editClient')->name('admin.client.edit');
    Route::patch('client/update','CompanyController@updateClient')->name('admin.client.update');

    

    // subscriptions Routes
    Route::resource('subscriptions', 'SubscriptionController')->names([
        'index' => 'admin.subscriptions.index',
        'create' => 'admin.subscriptions.create',
        'update' => 'admin.subscriptions.update',
        'destroy' => 'admin.subscriptions.destroy',
        'edit' => 'admin.subscriptions.edit',
        'store' => 'admin.subscriptions.store',
    ]);
    Route::get('subscriptions-filter-get','SubscriptionController@get_filter')->name('subscriptions.filter.get');
    Route::post('subscriptions-filter-post','SubscriptionController@post_filter')->name('subscriptions.filter.post');

    
    Route::get('add-new-subscription','SubscriptionController@add_subscription_for_company')->name('subscriptions.add.get');
    Route::get('get/package-types/{id}','SubscriptionController@get_package_types')->name('subscriptions.get_package_types');
    Route::post('post-new-subscription','SubscriptionController@post_subscription_for_company')->name('subscriptions.add.post');




    // types Routes
    Route::resource('types', 'TypeController')->names([
        'index' => 'admin.types.index',
        'create' => 'admin.types.create',
        'update' => 'admin.types.update',
        'destroy' => 'admin.types.destroy',
        'edit' => 'admin.types.edit',
        'store' => 'admin.types.store',
    ]);

    // payments Routes
    Route::resource('payments', 'PaymentController')->names([
        'index' => 'admin.payments.index',
        'create' => 'admin.payments.create',
        'update' => 'admin.payments.update',
        'destroy' => 'admin.payments.destroy',
        'edit' => 'admin.payments.edit',
        'store' => 'admin.payments.store',
    ]);
    Route::get('payments-report-get','PaymentController@get_report')->name('payments.report.get');

    // payments Routes
    Route::resource('packages', 'PackageController')->names([
        'index' => 'admin.packages.index',
        'create' => 'admin.packages.create',
        'update' => 'admin.packages.update',
        'destroy' => 'admin.packages.destroy',
        'edit' => 'admin.packages.edit',
        'store' => 'admin.packages.store',
    ]);

});


Route::group(
    [
        'namespace' => 'Site',
    ], function () {
    Route::get('/', 'HomeController@index')->name('home');
});

// *********  Admin Routes ******** //

Route::group(
    [
        'namespace' => 'Admin'
    ], function () {

    Route::GET('admin/login', 'Auth\LoginController@showLoginForm')->name('admin.login');
    Route::POST('admin/login', 'Auth\LoginController@login');
    Route::POST('admin/logout', 'Auth\LoginController@logout')->name('admin.logout');
    Route::GET('admin/password/confirm', 'Auth\ConfirmPasswordController@showConfirmForm')->name('admin.password.confirm');
    Route::POST('admin/password/confirm', 'Auth\ConfirmPasswordController@confirm');
    Route::POST('admin/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('admin.password.email');
    Route::GET('admin/password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('admin.password.request');
    Route::POST('admin/password/reset', 'Auth\ResetPasswordController@reset')->name('admin.password.update');
    Route::GET('admin/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('admin.password.reset');
});

?>
