<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\RegisterController;
use App\Http\Controllers\Admin\PurchaseController;
use App\Http\Controllers\Admin\ExpenseCategoryController;
use App\Http\Controllers\Admin\ExpenseController;
use App\Http\Controllers\Admin\TaxGenerateController;
use App\Http\Controllers\Admin\TransactionStatementController;
use App\Http\Controllers\Admin\PayementController;
use App\Http\Controllers\Admin\IncomeController;
use App\Http\Controllers\Admin\AllTransaction;
/*
|--------------------------------------------------------------------------
| 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('/clear', function () {
    Artisan::call('cache:clear');
    Artisan::call('config:cache');
    Artisan::call('view:clear');
    return "Cleared!";
});
Route::get('/', function () {
    return view('auth.login');
});

Auth::routes(['register' => false]);
Route::resource('register-account', 'Admin\RegisterController');
Route::post('/create-account', [App\Http\Controllers\Admin\RegisterController::class, 'store'])->name('create-account');
    Route::get('/add-pre-booking', [App\Http\Controllers\Admin\AdminController::class, 'add_pre_booking'])->name('add-pre-booking');
Route::group(['middleware' => 'auth'], function () {
      Route::get('/register', 'Auth\CustomRegisterController@showRegistrationForm')->name('register');
    Route::post('/register', 'Auth\RegisterController@register');
    Route::resource('admin', 'Admin\AdminController');
    Route::post('/sale-update/{id}', [App\Http\Controllers\Admin\AdminController::class, 'update'])->name('sale-update');
    Route::get('/add-register', [App\Http\Controllers\Admin\AdminController::class, 'add_register'])->name('add-register');
    Route::get('/manage-register', [App\Http\Controllers\Admin\AdminController::class, 'manage_register'])->name('manage-register');
    Route::get('/change-password', [App\Http\Controllers\Admin\AdminController::class, 'change_password'])->name('change-password');
    Route::post('/UpdatePassword', [App\Http\Controllers\Admin\AdminController::class, 'UpdatePassword'])->name('UpdatePassword');
    Route::get('/fetchRegisterData', [App\Http\Controllers\Admin\AdminController::class, 'fetchRegisterData'])->name('fetchRegisterData');
    Route::post('/delete_register/{id}', [App\Http\Controllers\Admin\AdminController::class, 'destroy'])->name('delete_register');
    Route::get('/edit-register/{id}', [App\Http\Controllers\Admin\AdminController::class, 'edit'])->name('edit-register');
    Route::get('/print-bill/{id}', [App\Http\Controllers\Admin\AdminController::class, 'show'])->name('print-bill');
    Route::get('/print-bill-mob/{id}', [App\Http\Controllers\Admin\AdminController::class, 'print_bill_mob'])->name('print-bill-mob');


    Route::get('/add-customer', [App\Http\Controllers\Admin\AdminController::class, 'add_customer'])->name('add-customer');
    Route::get('/view-customer', [App\Http\Controllers\Admin\AdminController::class, 'view_customer'])->name('view-customer');
    Route::post('/insert-customer', [App\Http\Controllers\Admin\AdminController::class, 'insert_customer'])->name('insert-customer');
    Route::get('/customer_data', [App\Http\Controllers\Admin\AdminController::class, 'customer_data'])->name('customer_data');
    Route::post('/delete_users/{id}', [App\Http\Controllers\Admin\AdminController::class, 'delete_users'])->name('delete_users');
    Route::get('/edit-customer/{id}', [App\Http\Controllers\Admin\AdminController::class, 'edit_customer'])->name('edit-customer');
    Route::post('/update-customer/{id}', [App\Http\Controllers\Admin\AdminController::class, 'update_customer'])->name('update-customer');
    Route::get('/vehicle_by_id/{id}', [App\Http\Controllers\Admin\AdminController::class, 'vehicle_by_id'])->name('vehicle_by_id');
    Route::get('/vehicle_change/{id}', [App\Http\Controllers\Admin\AdminController::class, 'vehicle_change'])->name('vehicle_change');
    Route::get('/get_price/{id}', [App\Http\Controllers\Admin\AdminController::class, 'get_price'])->name('get_price');
    Route::get('/delete_vehicle/{id}', [App\Http\Controllers\Admin\AdminController::class, 'delete_vehicle'])->name('delete_vehicle');
    // USER
    Route::get('/add-users', [App\Http\Controllers\Admin\AdminController::class, 'add_user'])->name('add-users');
    Route::get('/manage-users', [App\Http\Controllers\Admin\AdminController::class, 'manage_user'])->name('manage-users');
    Route::post('/insert-users', [App\Http\Controllers\Admin\AdminController::class, 'insert_user'])->name('insert-users');
    Route::get('/fetch-user-data', [App\Http\Controllers\Admin\AdminController::class, 'fetch_user_data'])->name('fetch-user-data');
    Route::get('/edit-user/{id}', [App\Http\Controllers\Admin\AdminController::class, 'edit_user'])->name('edit-user');
    Route::post('/update-users/{id}', [App\Http\Controllers\Admin\AdminController::class, 'update_user'])->name('update-users');

    Route::get('/manage-pre-booking', [App\Http\Controllers\Admin\AdminController::class, 'manage_pre_booking'])->name('manage-pre-booking');
    Route::get('/insert-pre-booking', [App\Http\Controllers\Admin\AdminController::class, 'insert_pre_booking'])->name('insert-pre-booking');
    Route::post('/update_print_status/{id}', [App\Http\Controllers\Admin\AdminController::class, 'update_print_status'])->name('update_print_status');


    // PURCHASE
    Route::resource('purchase', 'Admin\PurchaseController');
    Route::get('/manage-purchase', [App\Http\Controllers\Admin\PurchaseController::class, 'manage_purchase'])->name('manage-purchase');
    Route::get('/fetch-purchase-data', [App\Http\Controllers\Admin\PurchaseController::class, 'fetch_purchase_data'])->name('fetch-purchase-data');
    Route::post('/delete-purchase-data/{id}', [App\Http\Controllers\Admin\PurchaseController::class, 'destroy'])->name('delete-purchase-data');
    Route::get('/edit-purchase/{id}', [App\Http\Controllers\Admin\PurchaseController::class, 'edit'])->name('edit-purchase');
    Route::post('/update-purchase/{id}', [App\Http\Controllers\Admin\PurchaseController::class, 'update'])->name('update-purchase');
    Route::post('/refresh/{id}', [App\Http\Controllers\Admin\PurchaseController::class, 'refresh'])->name('refresh');
    // Expense
    Route::resource('expense_category', 'Admin\ExpenseCategoryController');
    Route::resource('expense', 'Admin\ExpenseController');
    Route::get('/fetch-expense-category-data', [App\Http\Controllers\Admin\ExpenseCategoryController::class, 'get_expense_category'])->name('fetch-expense-category-data');
    Route::post('/delete-expense-category-data/{id}', [App\Http\Controllers\Admin\ExpenseCategoryController::class, 'delete_expense_category'])->name('delete-expense-category-data');
    Route::get('/edit-expense-category/{id}', [App\Http\Controllers\Admin\ExpenseCategoryController::class, 'edit'])->name('edit-expense-category');
    Route::get('/manage-expense', [App\Http\Controllers\Admin\ExpenseController::class, 'manage_expense'])->name('manage-expense');
    Route::get('/fetch-expense-data', [App\Http\Controllers\Admin\ExpenseController::class, 'fetch_expense'])->name('fetch-expense-data');
    Route::post('/delete-expense/{id}', [App\Http\Controllers\Admin\ExpenseController::class, 'destroy'])->name('delete-expense');
    Route::get('/edit-expense/{id}', [App\Http\Controllers\Admin\ExpenseController::class, 'edit'])->name('edit-expense');
    // EXPENSE REPORTS
    Route::get('/expense-report', [App\Http\Controllers\Admin\ExpenseController::class, 'expense_report'])->name('expense-report');
    Route::get('/fetch-expense-report', [App\Http\Controllers\Admin\ExpenseController::class, 'fetchExpenseReport'])->name('fetch-expense-report');
    // PURCHASE REPORT
    Route::get('/purchase-report', [App\Http\Controllers\Admin\PurchaseController::class, 'purchase_report'])->name('purchase-report');
    Route::get('/fetch-purchase-report', [App\Http\Controllers\Admin\PurchaseController::class, 'fetchPurchaseReport'])->name('fetch-purchase-report');
    // INCOME REPORT
    Route::get('/income-report', [App\Http\Controllers\Admin\AdminController::class, 'income_report'])->name('income-report');
    Route::get('/fetch-income-report', [App\Http\Controllers\Admin\AdminController::class, 'fetchIncomeReport'])->name('fetch-income-report');
     Route::get('/payment-voucher', [App\Http\Controllers\Admin\AdminController::class, 'payment_voucher'])->name('payment-voucher');
      Route::get('/fetch-payment-voucher', [App\Http\Controllers\Admin\AdminController::class, 'fetchPaymentVoucher'])->name('fetch-payment-voucher');
      Route::get('/edit_date/{id}', [App\Http\Controllers\Admin\AdminController::class, 'edit_date'])->name('edit_date');
       Route::post('/update_date/{id}', [App\Http\Controllers\Admin\AdminController::class, 'update_date'])->name('update_date');

    // LEDGER
    Route::get('/ledger', [App\Http\Controllers\Admin\AdminController::class, 'ledger'])->name('ledger');
    Route::get('/fetch-ledger-report/{datefrom}/{dateto}', [App\Http\Controllers\Admin\AdminController::class, 'fetch_ledger_report'])->name('fetch-ledger-report');
    Route::get('/fetch-ledger-report/excel/{datefrom}/{dateto}', [App\Http\Controllers\Admin\AdminController::class, 'fetch_ledger_report_excel'])->name('fetch-ledger-report/excel');

    // STOCK REPORTS
    Route::get('/stock-report', [App\Http\Controllers\Admin\PurchaseController::class, 'stock_report'])->name('stock-report');
    Route::get('/fetch-stock-report', [App\Http\Controllers\Admin\PurchaseController::class, 'fetch_stock_report'])->name('fetch-stock-report');
    // OVERALL REPORTS
    Route::get('/overall_reports', [App\Http\Controllers\Admin\AdminController::class, 'overall_reports'])->name('overall_reports');
    Route::get('/fetch_overall_report/{datefrom}/{dateto}/{id}', [App\Http\Controllers\Admin\AdminController::class, 'fetch_overall_report'])->name('fetch_overall_report');
    // PAYMENT
    Route::get('/total_balance/{id}', [App\Http\Controllers\Admin\AdminController::class, 'total_balance'])->name('total_balance');
    Route::post('/pay_amount/{id}', [App\Http\Controllers\Admin\AdminController::class, 'pay_amount'])->name('pay_amount');
    // TAX GENERATE
    Route::resource('tax', 'Admin\TaxGenerateController');
    Route::get('/manage-invoice', [App\Http\Controllers\Admin\TaxGenerateController::class, 'manage_tax_report'])->name('manage-invoice');
    Route::get('/fetchTaxData', [App\Http\Controllers\Admin\TaxGenerateController::class, 'fetchTaxData'])->name('fetchTaxData');
    Route::post('/delete_tax/{id}', [App\Http\Controllers\Admin\TaxGenerateController::class, 'destroy'])->name('delete_tax');
    Route::get('/print-tax/{customer_id}/{invoice_no}/{datefrom}/{dateto}/{created_at}', [App\Http\Controllers\Admin\TaxGenerateController::class, 'show'])->name('print-tax');
        Route::post('/updated_transaction_tax/{id}', [App\Http\Controllers\Admin\TaxGenerateController::class, 'updated_transaction_tax'])->name('updated_transaction_tax');

    // TRANSACTION STATEMENT
    Route::resource('transaction-statement', 'Admin\TransactionStatementController');
    Route::get('/fetchTransactionData', [App\Http\Controllers\Admin\TransactionStatementController::class, 'fetchTransactionData'])->name('fetchTransactionData');
    Route::get('/statement/{id}/{datefrom}/{dateto}', [App\Http\Controllers\Admin\TransactionStatementController::class, 'statement'])->name('statement');
    // PAYMENT
    Route::resource('payment', 'Admin\PayementController');
    Route::get('/fetchTotalPaymentDue', [App\Http\Controllers\Admin\PayementController::class, 'fetchTotalPaymentDue'])->name('fetchTotalPaymentDue');
    Route::get('/total_payment_due/{id}', [App\Http\Controllers\Admin\PayementController::class, 'total_payment_due'])->name('total_payment_due');
    Route::post('/pay_due_amount/{id}', [App\Http\Controllers\Admin\PayementController::class, 'pay_due_amount'])->name('pay_due_amount');
    Route::get('/fetchPaymentSlip', [App\Http\Controllers\Admin\PayementController::class, 'fetchPaymentSlip'])->name('fetchPaymentSlip');
    Route::get('/viewPaymentSlip', [App\Http\Controllers\Admin\PayementController::class, 'viewPaymentSlip'])->name('viewPaymentSlip');
    Route::get('/duePaymentBills', [App\Http\Controllers\Admin\PayementController::class, 'duePaymentBills'])->name('duePaymentBills');
    Route::get('/fetchDueBillrData', [App\Http\Controllers\Admin\PayementController::class, 'fetchDueBillrData'])->name('fetchDueBillrData');
     Route::get('/fetchBill/{id}', [App\Http\Controllers\Admin\PayementController::class, 'fetchBill'])->name('fetchBill');

    // EMI INCOME
    Route::resource('income', 'Admin\IncomeController');
    Route::get('/fetchaddition_income', [App\Http\Controllers\Admin\IncomeController::class, 'fetchaddition_income'])->name('fetchaddition_income');
    Route::get('/manage_addition_income', [App\Http\Controllers\Admin\IncomeController::class, 'manage_addition_income'])->name('manage_addition_income');
    Route::post('/delete_addition_income/{id}', [App\Http\Controllers\Admin\IncomeController::class, 'destroy'])->name('delete_addition_income');
    Route::get('/editIncome/{id}', [App\Http\Controllers\Admin\IncomeController::class, 'edit'])->name('editIncome');
    Route::post('/incomeupdate/{id}', [App\Http\Controllers\Admin\IncomeController::class, 'update'])->name('incomeupdate');
    Route::resource('all', 'Admin\AllTransaction');
    Route::get('/all_statement/{datefrom}/{dateto}/{id}/{tax_id}', [App\Http\Controllers\Admin\AllTransaction::class, 'all_statement'])->name('all_statement');
    Route::resource('all_tax', 'Admin\AllTaxController');
    Route::get('/all_tax_statement/{datefrom}/{dateto}', [App\Http\Controllers\Admin\AllTaxController::class, 'all_tax_statement'])->name('all_tax_statement');
    Route::post('/chenge_to_credit/{id}', [App\Http\Controllers\Admin\AdminController::class, 'chenge_to_credit'])->name('chenge_to_credit');

});

   Route::get('/download/{id}', [App\Http\Controllers\Admin\AdminController::class, 'download'])->name('download');
      Route::get('/download_new/{id}', [App\Http\Controllers\Admin\AdminController::class, 'download_new'])->name('download_new');

Route::get('export_public', [App\Http\Controllers\Admin\AdminController::class, 'export_public'])->name('export_public');
Route::get('export_public_slip_pdf', [App\Http\Controllers\Admin\PayementController::class, 'export_public_slip_pdf'])->name('export_public_slip_pdf');
Route::get('export_due_pdf', [App\Http\Controllers\Admin\PayementController::class, 'export_due_pdf'])->name('export_due_pdf');

