<?php

    use Illuminate\Support\Facades\Route;
    use App\Http\Controllers\Warehouse\DashboardController;
    use App\Http\Controllers\Warehouse\ItemController;
    use App\Http\Controllers\Warehouse\InventoryController;
    use App\Http\Controllers\Warehouse\ItemCategoryController;
    use App\Http\Controllers\Warehouse\IncomingOperationController;
    use App\Http\Controllers\Warehouse\OutgoingTransactionController;
    use App\Http\Controllers\Warehouse\ReturnTransactionController;
    use App\Http\Controllers\Warehouse\ProjectController;
    use App\Http\Controllers\Warehouse\ProjectDivisionController;
    use App\Http\Controllers\Warehouse\SupplierController;
    use App\Http\Controllers\Warehouse\LocationController;
    use App\Http\Controllers\Warehouse\ReportController;
    use App\Http\Controllers\Warehouse\AnalyticsController;
    use App\Http\Controllers\Warehouse\SettingController;
    use App\Http\Controllers\Warehouse\UserController;
    use App\Http\Controllers\Warehouse\ActivityLogController;
    use App\Http\Controllers\Warehouse\MaterialTransferRequestController;
    use App\Http\Controllers\Warehouse\MaterialSiteTransferController;
    use App\Http\Controllers\Warehouse\DirectDeliveryController;
    use App\Http\Controllers\Warehouse\MaterialTransferIssueController;
    use App\Http\Controllers\Warehouse\MaterialIssueController;
    use App\Http\Controllers\Warehouse\UniversalSearchController;
    use App\Http\Controllers\Warehouse\EasyInController;
    use App\Http\Controllers\Warehouse\EasyOutController;

    /*
    |--------------------------------------------------------------------------
    | Warehouse Routes
    |--------------------------------------------------------------------------
    |
    | Here are the routes for the warehouse management system. All routes
    | are protected by the warehouse.access middleware and use role-based
    | permissions for fine-grained access control.
    |
    */

    Route::prefix('warehouse')->name('warehouse.')->middleware(['auth', 'warehouse.access'])->group(function () {

        // Dashboard
        Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
        Route::get('/api/quick-stats', [DashboardController::class, 'quickStats'])->name('api.quick-stats');

        // Universal Search
        Route::get('/search', [UniversalSearchController::class, 'search'])->name('search');

        // Items Management
        Route::prefix('items')->name('items.')->group(function () {
            Route::get('/', [ItemController::class, 'index'])->name('index');
            Route::get('/create', [ItemController::class, 'create'])->name('create');
            Route::post('/', [ItemController::class, 'store'])->name('store');
            Route::get('/units-dropdown', [ItemController::class, 'getUnitsDropdown'])->name('units-dropdown');
            Route::get('/dropdown', [ItemController::class, 'getItemsDropdown'])->name('dropdown');

            // Import functionality (specific routes BEFORE parameterized routes)
            Route::get('/import-template', [ItemController::class, 'downloadTemplate'])->name('template');
            Route::post('/import', [ItemController::class, 'import'])->name('import');
            Route::get('/export', [ItemController::class, 'export'])->name('export');

            // Item specific actions (specific routes)
            Route::post('/bulk-import', [ItemController::class, 'bulkImport'])->name('bulk-import');
            Route::get('/low-stock/list', [ItemController::class, 'lowStock'])->name('low-stock');

            // Parameterized routes (AFTER specific routes)
            Route::get('/{id}', [ItemController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [ItemController::class, 'edit'])->name('edit');
            Route::put('/{id}', [ItemController::class, 'update'])->name('update');
            Route::delete('/{id}', [ItemController::class, 'destroy'])->name('destroy');
            Route::post('/{id}/generate-barcode', [ItemController::class, 'generateBarcode'])->name('generate-barcode');
            Route::post('/{id}/generate-qr-code', [ItemController::class, 'generateQrCode'])->name('generate-qr-code');

            // Categories
            Route::prefix('categories')->name('categories.')->group(function () {
                Route::get('/', [ItemCategoryController::class, 'index'])->name('index');
                Route::get('/create', [ItemCategoryController::class, 'create'])->name('create');
                Route::post('/', [ItemCategoryController::class, 'store'])->name('store');
                Route::get('/{id}', [ItemCategoryController::class, 'show'])->name('show');
                Route::get('/{id}/edit', [ItemCategoryController::class, 'edit'])->name('edit');
                Route::put('/{id}', [ItemCategoryController::class, 'update'])->name('update');
                Route::delete('/{id}', [ItemCategoryController::class, 'destroy'])->name('destroy');
            });
        });

        // Item Categories (standalone)
        Route::prefix('item-categories')->name('item-categories.')->group(function () {
            Route::get('/', [ItemCategoryController::class, 'index'])->name('index');
            Route::get('/create', [ItemCategoryController::class, 'create'])->name('create');
            Route::post('/', [ItemCategoryController::class, 'store'])->name('store');

            // Import functionality (specific routes BEFORE parameterized routes)
            Route::get('/import-template', [ItemCategoryController::class, 'downloadTemplate'])->name('template');
            Route::post('/import', [ItemCategoryController::class, 'import'])->name('import');
            Route::get('/export', [ItemCategoryController::class, 'export'])->name('export');

            // Parameterized routes (AFTER specific routes)
            Route::get('/{id}', [ItemCategoryController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [ItemCategoryController::class, 'edit'])->name('edit');
            Route::put('/{id}', [ItemCategoryController::class, 'update'])->name('update');
            Route::delete('/{id}', [ItemCategoryController::class, 'destroy'])->name('destroy');
        });

        // Item Types
        Route::prefix('item-types')->name('item-types.')->group(function () {
            Route::get('/', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'index'])->name('index');
            Route::get('/create', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'create'])->name('create');
            Route::post('/', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'store'])->name('store');
            Route::get('/dropdown', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'dropdown'])->name('dropdown');
            Route::get('/{id}', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'edit'])->name('edit');
            Route::put('/{id}', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'update'])->name('update');
            Route::delete('/{id}', [App\Http\Controllers\Warehouse\ItemTypeController::class, 'destroy'])->name('destroy');
        });

        // Inventory Management
        Route::prefix('inventory')->name('inventory.')->group(function () {
            Route::get('/', [InventoryController::class, 'index'])->name('index');
            Route::get('/location/{location}', [InventoryController::class, 'byLocation'])->name('by-location');
            Route::get('/low-stock', [InventoryController::class, 'lowStock'])->name('low-stock');
            Route::get('/condition-conversion', [InventoryController::class, 'conditionConversion'])->name('condition-conversion');
            Route::post('/condition-conversion', [InventoryController::class, 'processConditionConversion'])->name('condition-conversion.process');
            Route::get('/condition-conversion/{conversion}/print', [InventoryController::class, 'printConditionConversion'])->name('condition-conversion.print');
            Route::put('/damaged-items/{damagedItem}/status', [InventoryController::class, 'updateDamagedItemStatus'])->name('damaged-items.update-status');
            Route::get('/damaged-items/{damagedItem}', [InventoryController::class, 'getDamagedItemDetails'])->name('damaged-items.show');
            Route::get('/search-items', [InventoryController::class, 'searchItems'])->name('search-items');
            Route::get('/aging-report', [InventoryController::class, 'agingReport'])->name('aging-report');
            Route::get('/division-stock/{itemId}/{divisionId}', [InventoryController::class, 'getDivisionStock'])->name('division-stock');
            Route::get('/division-deliveries/{divisionId?}', [InventoryController::class, 'getDivisionDeliveries'])->name('division-deliveries');
            Route::get('/valuation', [InventoryController::class, 'valuation'])->name('valuation');

            // Inventory adjustments
            Route::get('/adjustments', [InventoryController::class, 'adjustments'])->name('adjustments');
            Route::post('/adjustments', [InventoryController::class, 'storeAdjustment'])->name('store-adjustment');
            Route::get('/adjustments/{id}/details', [InventoryController::class, 'getAdjustmentDetails'])->name('adjustment-details');
            Route::delete('/adjustments/clear', [InventoryController::class, 'clearAdjustments'])->name('clear-adjustments');
            Route::post('/adjustments/import', [InventoryController::class, 'importAdjustments'])->name('adjustments.import');
            Route::get('/adjustments/template/{format}', [InventoryController::class, 'downloadTemplate'])->name('adjustments.template');
            Route::get('/{itemId}/adjust', [InventoryController::class, 'adjust'])->name('adjust');
            Route::post('/{itemId}/adjust', [InventoryController::class, 'performAdjustment'])->name('perform-adjustment');

            // Inventory transfers
            Route::get('/transfers', [InventoryController::class, 'transfers'])->name('transfers');
            Route::get('/{itemId}/transfer', [InventoryController::class, 'transfer'])->name('transfer');
            Route::post('/{itemId}/transfer', [InventoryController::class, 'performTransfer'])->name('perform-transfer');

            // Inventory reservations
            Route::post('/{itemId}/reserve', [InventoryController::class, 'reserve'])->name('reserve');
            Route::post('/{itemId}/release-reserved', [InventoryController::class, 'releaseReserved'])->name('release-reserved');

            // Physical count
            Route::get('/physical-count', [InventoryController::class, 'physicalCount'])->name('physical-count');
            Route::post('/physical-count', [InventoryController::class, 'performPhysicalCount'])->name('perform-physical-count');

            // Stock movements
            Route::get('/{itemId}/stock-movements', [InventoryController::class, 'stockMovements'])->name('stock-movements');

            // Material Requests
            Route::get('/material-requests', [InventoryController::class, 'materialRequests'])->name('material-requests');
            Route::get('/material-requests/{id}', [InventoryController::class, 'viewMaterialRequest'])->name('material-requests.view');
            Route::get('/material-requests/{id}/dispatch', [InventoryController::class, 'dispatchMaterialRequest'])->name('material-requests.dispatch');
            Route::get('/material-requests/{id}/print', [InventoryController::class, 'printMaterialRequest'])->name('material-requests.print');
            Route::delete('/material-requests/{id}', [InventoryController::class, 'deleteMaterialRequest'])->name('material-requests.delete');
            Route::post('/material-requests/{id}/dispatch', [InventoryController::class, 'processDispatch'])->name('material-requests.process-dispatch');

            // Material Issued (completed issues view)
            Route::get('/material-issued', [MaterialIssueController::class, 'index'])->name('material-issued');
            Route::get('/material-issued/{id}/details', [MaterialIssueController::class, 'showIssueDetails'])->name('material-issued.show');
            Route::get('/material-issued/{id}/combined-print', [MaterialIssueController::class, 'printIssueDetails'])->name('material-issued.combined-print');
            Route::get('/material-issued/{id}/print', [InventoryController::class, 'printMaterialIssued'])->name('material-issued.print');

            // Material Issue Decision Center (for processing pending requests)
            Route::get('/material-issue-center', [MaterialIssueController::class, 'decisionCenter'])->name('material-issue-center');
            Route::get('/material-issue-center/{id}', [MaterialIssueController::class, 'show'])->name('material-issue-center.show');

            // Bulk operations
            Route::post('/check-bulk-availability', [InventoryController::class, 'checkBulkAvailability'])->name('check-bulk-availability');
        });

        // FOC API routes (outside transaction context to avoid routing conflicts)
        Route::prefix('material-issue-api')->name('material-issue.')->group(function () {
            Route::get('/foc-items', [MaterialIssueController::class, 'getFocItems'])->name('foc-items');
            Route::get('/foc-references', [MaterialIssueController::class, 'getFocReferences'])->name('foc-references');
            Route::get('/foc-quantities', [MaterialIssueController::class, 'getFocAvailableQuantities'])->name('foc-quantities');
            Route::get('/foc-division-stock/{itemId}/{divisionId}', [MaterialIssueController::class, 'getFocDivisionStock'])->name('foc-division-stock');
            Route::get('/indirect-division-stock/{indirectGoodId}/{divisionId}', [MaterialIssueController::class, 'getIndirectDivisionStock'])->name('indirect-division-stock');
            Route::get('/debug-foc', [MaterialIssueController::class, 'debugFocInventory'])->name('debug-foc');
        });

        // Material Issue Decision Center (transaction-specific routes)
        Route::prefix('material-issue')->name('material-issue.')->group(function () {
            Route::get('/', [MaterialIssueController::class, 'index'])->name('index');
            Route::get('/{transaction}', [MaterialIssueController::class, 'show'])->name('show');
            Route::post('/{transaction}/process', [MaterialIssueController::class, 'processDecision'])->name('process-decision');
            Route::post('/{transaction}/process-multi', [MaterialIssueController::class, 'processMultiSource'])->name('process-multi');

            Route::get('/test-44', function() {
                $transaction = \App\Models\Warehouse\OutgoingTransaction::with(['items.item'])->find(44);
                $item = $transaction->items->first();
                return response()->json([
                    'transaction_id' => $transaction->id,
                    'item_id' => $item->item_id,
                    'item_code' => $item->item->item_code,
                    'foc_available' => $item->foc_available,
                    'raw_attributes' => $item->getAttributes(),
                    'all_attributes' => $item->toArray()
                ]);
            })->name('test-44');
        });

        // Enhanced Incoming Operations
        Route::prefix('incoming-operations')->name('incoming-operations.')->group(function () {
            Route::get('/', [IncomingOperationController::class, 'index'])->name('index');
            Route::get('/create', [IncomingOperationController::class, 'create'])->name('create');
            Route::post('/', [IncomingOperationController::class, 'store'])->name('store');
            Route::get('/{operation}', [IncomingOperationController::class, 'show'])->name('show');
            Route::get('/{operation}/edit', [IncomingOperationController::class, 'edit'])->name('edit');
            Route::put('/{operation}', [IncomingOperationController::class, 'update'])->name('update');
            Route::delete('/{operation}', [IncomingOperationController::class, 'destroy'])->name('destroy');

            // Quality Control & Inspection
            Route::post('/{operation}/inspect', [IncomingOperationController::class, 'inspect'])->name('inspect');
            Route::post('/{operation}/complete', [IncomingOperationController::class, 'complete'])->name('complete');

            // Printing & Documents
            Route::get('/{operation}/print', [IncomingOperationController::class, 'print'])->name('print');

            // API routes
            Route::get('/api/items', [IncomingOperationController::class, 'getItems'])->name('api.items');
            Route::get('/api/lpo-details', [IncomingOperationController::class, 'getLpoDetails'])->name('api.lpo-details');
            Route::get('/api/quality-checklists', [IncomingOperationController::class, 'getQualityChecklists'])->name('api.quality-checklists');
        });

        // Supplier Delivery (Dedicated Page)
        Route::prefix('supplier-delivery')->name('supplier-delivery.')->group(function () {
            Route::get('/', [IncomingOperationController::class, 'supplierDeliveryIndex'])->name('index');
            Route::get('/create', [IncomingOperationController::class, 'supplierDeliveryCreate'])->name('create');
            Route::get('/api/data', [IncomingOperationController::class, 'supplierDeliveryData'])->name('api.data');
            Route::get('/export', [IncomingOperationController::class, 'exportSupplierDeliveries'])->name('export');
            Route::get('/{operation}/edit', [IncomingOperationController::class, 'supplierDeliveryEdit'])->name('edit');
            Route::put('/{operation}', [IncomingOperationController::class, 'supplierDeliveryUpdate'])->name('update');

        });

        // Site Return (Dedicated Page)
        Route::prefix('site-return')->name('site-return.')->group(function () {
            Route::get('/', [IncomingOperationController::class, 'siteReturnIndex'])->name('index');
            Route::get('/create', [IncomingOperationController::class, 'siteReturnCreate'])->name('create');
            Route::get('/project/{projectId}', [IncomingOperationController::class, 'showProjectReturns'])->name('project-returns');
            Route::get('/get-material-request/{id}', [IncomingOperationController::class, 'getMaterialRequest'])->name('get-material-request');
            Route::get('/get-direct-delivery/{id}', [IncomingOperationController::class, 'getDirectDelivery'])->name('get-direct-delivery');
            Route::get('/get-material-transfer/{id}', [IncomingOperationController::class, 'getMaterialTransfer'])->name('get-material-transfer');
            Route::get('/get-supplier-delivery/{id}', [IncomingOperationController::class, 'getSupplierDelivery'])->name('get-supplier-delivery');
            Route::get('/get-foc-transfer/{id}', [IncomingOperationController::class, 'getFocTransfer'])->name('get-foc-transfer');
            Route::get('/get-material-requests-by-project/{projectId}', [IncomingOperationController::class, 'getMaterialRequestsByProject'])->name('get-material-requests-by-project');
            Route::get('/get-direct-deliveries-by-project/{projectId}', [IncomingOperationController::class, 'getDirectDeliveriesByProject'])->name('get-direct-deliveries-by-project');
            Route::get('/get-combined-references-by-project/{projectId}', [IncomingOperationController::class, 'getCombinedReferencesByProject'])->name('get-combined-references-by-project');
            Route::get('/get-all-returnable-items/{projectId}', [IncomingOperationController::class, 'getAllReturnableItems'])->name('get-all-returnable-items');
            Route::get('/get-project-items-consolidated/{projectId}', [IncomingOperationController::class, 'getProjectItemsConsolidated'])->name('get-project-items-consolidated');
            Route::get('/mr-returns/{materialRequestId}', [IncomingOperationController::class, 'showMaterialRequestReturns'])->name('show-mr-returns');
            Route::get('/mr-returns/{materialRequestId}/print', [IncomingOperationController::class, 'printMaterialRequestReturns'])->name('print-mr-returns');
            Route::get('/{returnId}/print', [IncomingOperationController::class, 'printSiteReturn'])->name('print-site-return');
            Route::get('/project/{projectId}/print-consolidated', [IncomingOperationController::class, 'printProjectConsolidatedReturns'])->name('print-project-consolidated');
            Route::get('/api/data', [IncomingOperationController::class, 'siteReturnData'])->name('api.data');
            Route::get('/export', [IncomingOperationController::class, 'exportSiteReturns'])->name('export');
        });

        // Easy In (Quick Purchases)
        Route::prefix('easy-in')->name('easy-in.')->controller(EasyInController::class)->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/create', 'create')->name('create');
            Route::post('/', 'store')->name('store');
            Route::get('/{easyIn}', 'show')->name('show');
            Route::delete('/{easyIn}', 'destroy')->name('destroy');
        });

        // Outgoing Transactions
        Route::prefix('outgoing')->name('outgoing.')->group(function () {
            Route::get('/', [OutgoingTransactionController::class, 'index'])->name('index');
            Route::get('/create', [OutgoingTransactionController::class, 'create'])->name('create');
            Route::post('/', [OutgoingTransactionController::class, 'store'])->name('store');
            Route::get('/search-items', [OutgoingTransactionController::class, 'searchItems'])->name('search-items');
            Route::get('/{id}', [OutgoingTransactionController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [OutgoingTransactionController::class, 'edit'])->name('edit');
            Route::put('/{id}', [OutgoingTransactionController::class, 'update'])->name('update');
            Route::delete('/{id}', [OutgoingTransactionController::class, 'destroy'])->name('destroy');

            Route::get('/pending-approval/list', [OutgoingTransactionController::class, 'pendingApproval'])->name('pending-approval');
            Route::post('/{id}/approve', [OutgoingTransactionController::class, 'approve'])->name('approve');
            Route::post('/{id}/dispatch', [OutgoingTransactionController::class, 'dispatch'])->name('dispatch');
        });

        // Easy Out (Quick Dispatches)
        Route::prefix('easy-out')->name('easy-out.')->controller(EasyOutController::class)->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/create', 'create')->name('create');
            Route::post('/', 'store')->name('store');
            Route::get('/{easyOut}', 'show')->name('show');
            Route::delete('/{easyOut}', 'destroy')->name('destroy');
        });

        // Return Transactions
        Route::prefix('returns')->name('returns.')->group(function () {
            Route::get('/', [ReturnTransactionController::class, 'index'])->name('index');
            Route::get('/create', [ReturnTransactionController::class, 'create'])->name('create');
            Route::post('/', [ReturnTransactionController::class, 'store'])->name('store');
            Route::get('/{id}', [ReturnTransactionController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [ReturnTransactionController::class, 'edit'])->name('edit');
            Route::put('/{id}', [ReturnTransactionController::class, 'update'])->name('update');
            Route::delete('/{id}', [ReturnTransactionController::class, 'destroy'])->name('destroy');

            Route::post('/{id}/process', [ReturnTransactionController::class, 'process'])->name('process');
        });

        // Projects
        Route::prefix('projects')->name('projects.')->group(function () {
            Route::get('/', [ProjectController::class, 'index'])->name('index');
            Route::get('/create', [ProjectController::class, 'create'])->name('create');
            Route::post('/', [ProjectController::class, 'store'])->name('store');
            Route::get('/{id}', [ProjectController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [ProjectController::class, 'edit'])->name('edit');
            Route::put('/{id}', [ProjectController::class, 'update'])->name('update');
            Route::delete('/{id}', [ProjectController::class, 'destroy'])->name('destroy');
            Route::post('/sync-external', [ProjectController::class, 'syncExternal'])->name('sync-external');
            Route::get('/inspect-external', [ProjectController::class, 'inspectExternal'])->name('inspect-external');
            Route::get('/sync-statistics', [ProjectController::class, 'getSyncStatistics'])->name('sync-statistics');
            Route::post('/backfill-external-ids', [ProjectController::class, 'backfillExternalIds'])->name('backfill-external-ids');
        });

        // Project Divisions
        Route::prefix('project-divisions')->name('project-divisions.')->group(function () {
            Route::get('/', [ProjectDivisionController::class, 'index'])->name('index');
            Route::get('/create', [ProjectDivisionController::class, 'create'])->name('create');
            Route::post('/', [ProjectDivisionController::class, 'store'])->name('store');
            Route::get('/{id}', [ProjectDivisionController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [ProjectDivisionController::class, 'edit'])->name('edit');
            Route::put('/{id}', [ProjectDivisionController::class, 'update'])->name('update');
            Route::delete('/{id}', [ProjectDivisionController::class, 'destroy'])->name('destroy');
        });

        // Suppliers
        Route::prefix('suppliers')->name('suppliers.')->group(function () {
            Route::get('/', [SupplierController::class, 'index'])->name('index');
            Route::get('/data', [SupplierController::class, 'data'])->name('data');
            Route::get('/create', [SupplierController::class, 'create'])->name('create');
            Route::post('/', [SupplierController::class, 'store'])->name('store');

            // Additional supplier functionality (specific routes BEFORE parameterized routes)
            Route::get('/import-template', [SupplierController::class, 'downloadTemplate'])->name('template');
            Route::post('/import', [SupplierController::class, 'import'])->name('import');
            Route::get('/export', [SupplierController::class, 'export'])->name('export');
            Route::get('/filter-options', [SupplierController::class, 'filterOptions'])->name('filterOptions');
            Route::get('/dropdown', [SupplierController::class, 'dropdown'])->name('dropdown');

            // Parameterized routes (AFTER specific routes)
            Route::get('/{id}', [SupplierController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [SupplierController::class, 'edit'])->name('edit');
            Route::put('/{id}', [SupplierController::class, 'update'])->name('update');
            Route::delete('/{id}', [SupplierController::class, 'destroy'])->name('destroy');
            Route::post('/{id}/update-rating', [SupplierController::class, 'updateRating'])->name('updateRating');
            Route::get('/{id}/performance', [SupplierController::class, 'performance'])->name('performance');
        });

        // Locations
        Route::prefix('locations')->name('locations.')->group(function () {
            Route::get('/', [LocationController::class, 'index'])->name('index');
            Route::get('/create', [LocationController::class, 'create'])->name('create');
            Route::post('/', [LocationController::class, 'store'])->name('store');
            Route::get('/{id}', [LocationController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [LocationController::class, 'edit'])->name('edit');
            Route::put('/{id}', [LocationController::class, 'update'])->name('update');
            Route::delete('/{id}', [LocationController::class, 'destroy'])->name('destroy');
        });

        // Reports
        Route::prefix('reports')->name('reports.')->group(function () {
            Route::get('/', [ReportController::class, 'index'])->name('index');
            Route::get('/inventory', [ReportController::class, 'inventory'])->name('inventory');
            Route::get('/inventory/export', [ReportController::class, 'inventoryExport'])->name('inventory.export');
            Route::get('/inventory/item/{itemId}', [ReportController::class, 'inventoryItemDetails'])->name('inventory.item-details');
            Route::get('/materials', [ReportController::class, 'materials'])->name('materials');
            Route::get('/materials/item/{itemId}', [ReportController::class, 'materialsItemDetails'])->name('materials.item-details');
            Route::get('/incoming', [ReportController::class, 'incoming'])->name('incoming');
            Route::get('/incoming/item/{itemId}', [ReportController::class, 'incomingItemDetails'])->name('incoming.item-details');
            Route::get('/outgoing', [ReportController::class, 'outgoing'])->name('outgoing');
            Route::get('/outgoing/item/{itemId}', [ReportController::class, 'outgoingItemDetails'])->name('outgoing.item-details');
            Route::get('/outgoing/request/{requestId}', [ReportController::class, 'outgoingRequestDetails'])->name('outgoing.request-details');
            Route::get('/returns', [ReportController::class, 'returns'])->name('returns');
            Route::get('/returns/item/{itemId}', [ReportController::class, 'returnItemDetails'])->name('returns.item-details');
            Route::get('/stock-movements', [ReportController::class, 'stockMovements'])->name('stock-movements');
            Route::get('/transactions', [ReportController::class, 'transactions'])->name('transactions');
            Route::get('/aging', [ReportController::class, 'aging'])->name('aging');
            Route::get('/low-stock', [ReportController::class, 'lowStock'])->name('low-stock');
            Route::get('/supplier-performance', [ReportController::class, 'supplierPerformance'])->name('supplier-performance');
            Route::get('/project-transfers', [ReportController::class, 'projectTransfers'])->name('project-transfers');
            Route::get('/direct-deliveries', [ReportController::class, 'directDeliveries'])->name('direct-deliveries');
            Route::get('/stock-on-project', [ReportController::class, 'stockOnProject'])->name('stock-on-project');
            Route::get('/stock-on-project/{projectId}/details', [ReportController::class, 'stockOnProjectDetails'])->name('stock-on-project.details');
            Route::get('/stock-on-project/{projectId}/item/{itemId}/allocations', [ReportController::class, 'itemReferenceAllocations'])->name('item-reference-allocations');
            Route::get('/damaged-items', [ReportController::class, 'damagedItems'])->name('damaged-items');
            Route::get('/damaged-items/{itemId}/details', [ReportController::class, 'damagedItemsDetails'])->name('damaged-items-details');
            Route::get('/damaged-items/item/{damagedItemId}/details', [ReportController::class, 'showDamagedItemDetails'])->name('damaged-item-show');
            Route::get('/division-deliveries', [ReportController::class, 'divisionDeliveries'])->name('division-deliveries');
            Route::get('/division-item-details', [ReportController::class, 'getDivisionItemDetails'])->name('division-item-details');
        });

        // Analytics
        Route::prefix('analytics')->name('analytics.')->group(function () {
            Route::get('/', [AnalyticsController::class, 'index'])->name('index');
            Route::get('/inventory-turnover', [AnalyticsController::class, 'inventoryTurnover'])->name('inventory-turnover');
            Route::get('/stock-forecast', [AnalyticsController::class, 'stockForecast'])->name('stock-forecast');
            Route::get('/performance-metrics', [AnalyticsController::class, 'performanceMetrics'])->name('performance-metrics');
        });

        // Settings
        Route::prefix('settings')->name('settings.')->group(function () {
            Route::get('/', [SettingController::class, 'index'])->name('index');
            Route::put('/general', [SettingController::class, 'updateGeneral'])->name('update-general');
            Route::put('/notifications', [SettingController::class, 'updateNotifications'])->name('update-notifications');
            Route::put('/workflows', [SettingController::class, 'updateWorkflows'])->name('update-workflows');
        });

        // User Management
        Route::prefix('users')->name('users.')->group(function () {
            Route::get('/', [UserController::class, 'index'])->name('index');
            Route::get('/stats', [UserController::class, 'stats'])->name('stats');
            Route::post('/', [UserController::class, 'store'])->name('store');
            Route::get('/{user}', [UserController::class, 'show'])->name('show');
            Route::put('/{user}', [UserController::class, 'update'])->name('update');
            Route::delete('/{user}', [UserController::class, 'destroy'])->name('destroy');
            Route::put('/{user}/role', [UserController::class, 'updateRole'])->name('update-role');
        });

        // Material Transfer Requests
        Route::prefix('transfer-requests')->name('transfer-requests.')->group(function () {
            Route::get('/', [MaterialTransferRequestController::class, 'index'])->name('index');
            Route::get('/create', [MaterialTransferRequestController::class, 'create'])->name('create');
            Route::post('/', [MaterialTransferRequestController::class, 'store'])->name('store');
            Route::get('/{transferRequest}', [MaterialTransferRequestController::class, 'show'])->name('show');
            Route::get('/{transferRequest}/edit', [MaterialTransferRequestController::class, 'edit'])->name('edit');
            Route::put('/{transferRequest}', [MaterialTransferRequestController::class, 'update'])->name('update');
            Route::get('/{transferRequest}/approve', [MaterialTransferRequestController::class, 'showApproval'])->name('approve');
            Route::get('/{transferRequest}/print', [MaterialTransferRequestController::class, 'print'])->name('print');

            // Workflow actions
            Route::post('/{transferRequest}/submit', [MaterialTransferRequestController::class, 'submit'])->name('submit');
            Route::post('/{transferRequest}/approve-transferrer', [MaterialTransferRequestController::class, 'approveByTransferrer'])->name('approve-transferrer');
            Route::post('/{transferRequest}/reject', [MaterialTransferRequestController::class, 'reject'])->name('reject');
            Route::post('/{transferRequest}/cancel', [MaterialTransferRequestController::class, 'cancel'])->name('cancel');

            // AJAX endpoints
            Route::get('/project/{project}/inventory', [MaterialTransferRequestController::class, 'getProjectInventory'])->name('project-inventory');
            Route::get('/direct-delivery/{directDelivery}/items', [MaterialTransferRequestController::class, 'getDirectDeliveryItems'])->name('get-direct-delivery-items');
            Route::get('/project/{project}/combined-references', [MaterialTransferRequestController::class, 'getCombinedReferencesByProject'])->name('get-combined-references-by-project-transfer');
            Route::get('/material-transfer/{materialTransfer}', [MaterialTransferRequestController::class, 'getMaterialTransfer'])->name('get-material-transfer');
            Route::get('/material-request/{materialRequest}/items', [MaterialTransferRequestController::class, 'getMaterialRequestItems'])->name('get-material-request-items');
        });

        // Material Transfer Issues
        Route::prefix('transfer-issues')->name('transfer-issues.')->group(function () {
            Route::get('/', [MaterialTransferIssueController::class, 'index'])->name('index');
            Route::get('/create/{transferRequest}', [MaterialTransferIssueController::class, 'create'])->name('create');
            Route::post('/{transferRequest}', [MaterialTransferIssueController::class, 'store'])->name('store');
            Route::get('/{transferIssue}', [MaterialTransferIssueController::class, 'show'])->name('show');

            // Workflow actions
            Route::post('/{transferIssue}/dispatch', [MaterialTransferIssueController::class, 'dispatch'])->name('dispatch');
            Route::post('/{transferIssue}/mark-in-transit', [MaterialTransferIssueController::class, 'markInTransit'])->name('mark-in-transit');
            Route::post('/{transferIssue}/receive', [MaterialTransferIssueController::class, 'receive'])->name('receive');
            Route::post('/{transferIssue}/complete-inspection', [MaterialTransferIssueController::class, 'completeInspection'])->name('complete-inspection');
            Route::post('/{transferIssue}/upload-documents', [MaterialTransferIssueController::class, 'uploadDocuments'])->name('upload-documents');
            Route::post('/{transferIssue}/cancel', [MaterialTransferIssueController::class, 'cancel'])->name('cancel');

            // Print/Export
            Route::get('/{transferIssue}/print', [MaterialTransferIssueController::class, 'print'])->name('print');
        });

        // Site Transfers (Project to Project - Simplified)
        Route::prefix('site-transfers')->name('site-transfers.')->group(function () {
            Route::get('/', [MaterialSiteTransferController::class, 'index'])->name('index');
            Route::get('/create', [MaterialSiteTransferController::class, 'create'])->name('create');
            Route::get('/print', [MaterialSiteTransferController::class, 'print'])->name('print');
            Route::post('/', [MaterialSiteTransferController::class, 'store'])->name('store');
            Route::get('/{siteTransfer}', [MaterialSiteTransferController::class, 'show'])->name('show');
            Route::get('/{siteTransfer}/print', [MaterialSiteTransferController::class, 'printSingle'])->name('print-single');

            // AJAX endpoints
            Route::get('/api/project-inventory', [MaterialSiteTransferController::class, 'getProjectInventory'])->name('project-inventory');
            Route::get('/api/item-allocation', [MaterialSiteTransferController::class, 'getItemAllocation'])->name('item-allocation');
            Route::get('/api/project-items-consolidated/{projectId}', [MaterialSiteTransferController::class, 'getProjectItemsConsolidated'])->name('project-items-consolidated');
        });

        // Direct Deliveries (Supplier to Project)
        Route::prefix('direct-deliveries')->name('direct-deliveries.')->group(function () {
            Route::get('/', [DirectDeliveryController::class, 'index'])->name('index');
            Route::get('/create', [DirectDeliveryController::class, 'create'])->name('create');
            Route::post('/', [DirectDeliveryController::class, 'store'])->name('store');
            Route::get('/{directDelivery}', [DirectDeliveryController::class, 'show'])->name('show');
            Route::get('/{directDelivery}/edit', [DirectDeliveryController::class, 'edit'])->name('edit');
            Route::put('/{directDelivery}', [DirectDeliveryController::class, 'update'])->name('update');
            Route::delete('/{directDelivery}', [DirectDeliveryController::class, 'destroy'])->name('destroy');
            Route::get('/{directDelivery}/print', [DirectDeliveryController::class, 'print'])->name('print');

            // Receipt processing
            Route::get('/{directDelivery}/receipt', [DirectDeliveryController::class, 'receipt'])->name('receipt');
            Route::post('/{directDelivery}/receipt', [DirectDeliveryController::class, 'processReceipt'])->name('process-receipt');

            // Approval workflow
            Route::post('/{directDelivery}/approve', [DirectDeliveryController::class, 'approve'])->name('approve');

            // Site return processing
            Route::get('/{directDelivery}/site-return', [DirectDeliveryController::class, 'siteReturn'])->name('site-return');
            Route::post('/{directDelivery}/site-return', [DirectDeliveryController::class, 'processSiteReturn'])->name('process-site-return');

            // AJAX endpoints
            Route::get('/project/{projectId}/divisions', [DirectDeliveryController::class, 'getProjectDivisions'])->name('project-divisions');
        });

        // Activity Log
        Route::prefix('activity-log')->name('activity-log.')->group(function () {
            Route::get('/', [ActivityLogController::class, 'index'])->name('index');
            Route::get('/{id}', [ActivityLogController::class, 'show'])->name('show');
            Route::delete('/cleanup', [ActivityLogController::class, 'cleanup'])->name('cleanup');
        });

        /*
        |--------------------------------------------------------------------------
        | Indirect Goods Routes
        |--------------------------------------------------------------------------
        */

        Route::prefix('indirect-goods')->name('indirect-goods.')->group(function () {

            // Catalog
            Route::prefix('catalog')->name('catalog.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'store'])->name('store');
                Route::get('/dropdown', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'getDropdown'])->name('dropdown');
                Route::get('/import-template', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'downloadTemplate'])->name('template');
                Route::post('/import', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'import'])->name('import');
                Route::get('/export', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'export'])->name('export');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'show'])->name('show');
                Route::get('/{id}/edit', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'edit'])->name('edit');
                Route::put('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'update'])->name('update');
                Route::delete('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodController::class, 'destroy'])->name('destroy');
            });

            // Incoming Receipts
            Route::prefix('incoming')->name('incoming.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'store'])->name('store');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'show'])->name('show');
                Route::get('/{id}/edit', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'edit'])->name('edit');
                Route::put('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'update'])->name('update');
                Route::delete('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'destroy'])->name('destroy');
                Route::post('/{id}/approve', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'approve'])->name('approve');
                Route::post('/{id}/complete', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'complete'])->name('complete');
                Route::get('/{id}/print', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsIncomingController::class, 'print'])->name('print');
            });

            // Material Requests
            Route::prefix('requests')->name('requests.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'store'])->name('store');
                Route::get('/pending-approval', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'pendingApproval'])->name('pending-approval');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'show'])->name('show');
                Route::post('/{id}/approve', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'approve'])->name('approve');
                Route::post('/{id}/reject', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'reject'])->name('reject');
                Route::post('/{id}/issue', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'issue'])->name('issue');
                Route::get('/{id}/print', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsRequestController::class, 'print'])->name('print');
            });

            // Consumption / Write-Off
            Route::prefix('consumption')->name('consumption.')->group(function () {
            Route::get('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsConsumptionController::class, 'index'])->name('index');
            Route::get('/create', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsConsumptionController::class, 'create'])->name('create');
            Route::post('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsConsumptionController::class, 'store'])->name('store');
            // AJAX endpoints
            Route::get('/api/project-items/{projectId}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsConsumptionController::class, 'getProjectItems'])->name('api.project-items');
            Route::get('/api/item-invoices/{projectId}/{indirectGoodId}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsConsumptionController::class, 'getItemInvoices'])->name('api.item-invoices');
            Route::get('/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsConsumptionController::class, 'show'])->name('show');
        });

            // Inventory
            Route::prefix('inventory')->name('inventory.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsInventoryController::class, 'index'])->name('index');
                Route::get('/project-inventory', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsInventoryController::class, 'projectInventory'])->name('project-inventory');
                Route::get('/low-stock', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsInventoryController::class, 'lowStock'])->name('low-stock');
                Route::get('/adjustments', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsInventoryController::class, 'adjustments'])->name('adjustments');
                Route::post('/adjustments', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsInventoryController::class, 'storeAdjustment'])->name('store-adjustment');
                Route::get('/stock-movements/{id}', [\App\Http\Controllers\Warehouse\IndirectGoods\IndirectGoodsInventoryController::class, 'stockMovements'])->name('stock-movements');
            });
        });

        /*
        |--------------------------------------------------------------------------
        | Fixed Assets Routes
        |--------------------------------------------------------------------------
        */

        Route::prefix('fixed-assets')->name('fixed-assets.')->group(function () {

            // Categories
            Route::prefix('categories')->name('categories.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetCategoryController::class, 'index'])->name('index');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetCategoryController::class, 'store'])->name('store');
                Route::put('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetCategoryController::class, 'update'])->name('update');
                Route::delete('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetCategoryController::class, 'destroy'])->name('destroy');
            });

            // Catalog (Asset Register)
            Route::prefix('catalog')->name('catalog.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'store'])->name('store');
                Route::get('/dropdown', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'getDropdown'])->name('dropdown');
                Route::get('/available', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'getAvailableAssets'])->name('available');
                Route::get('/import-template', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'downloadTemplate'])->name('template');
                Route::post('/import', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'import'])->name('import');
                Route::get('/export', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'export'])->name('export');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'show'])->name('show');
                Route::get('/{id}/edit', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'edit'])->name('edit');
                Route::put('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'update'])->name('update');
                Route::delete('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetController::class, 'destroy'])->name('destroy');
            });

            // Incoming (Asset Receipts)
            Route::prefix('incoming')->name('incoming.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'store'])->name('store');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'show'])->name('show');
                Route::get('/{id}/edit', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'edit'])->name('edit');
                Route::put('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'update'])->name('update');
                Route::delete('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'destroy'])->name('destroy');
                Route::post('/{id}/approve', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'approve'])->name('approve');
                Route::post('/{id}/complete', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'complete'])->name('complete');
                Route::get('/{id}/print', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetIncomingController::class, 'print'])->name('print');
            });

            // Allocations (Asset Assignment Requests)
            Route::prefix('allocations')->name('allocations.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'store'])->name('store');
                Route::get('/pending-approval', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'pendingApproval'])->name('pending-approval');
                Route::post('/asset-location/toggle', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'toggleAssetLocation'])->name('asset-location.toggle');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'show'])->name('show');
                Route::post('/{id}/approve', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'approve'])->name('approve');
                Route::post('/{id}/reject', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'reject'])->name('reject');
                Route::post('/{id}/allocate', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'allocate'])->name('allocate');
                Route::post('/{id}/items/{itemId}/allocate', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'allocateItem'])->name('items.allocate');
                Route::get('/{id}/print', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetAllocationController::class, 'print'])->name('print');
            });

            // Returns (Asset Returns from Projects)
            Route::prefix('returns')->name('returns.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'store'])->name('store');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'show'])->name('show');
                Route::post('/{id}/inspect', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'inspect'])->name('inspect');
                Route::post('/{id}/complete', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'complete'])->name('complete');
                Route::get('/{id}/print', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'print'])->name('print');
                Route::get('/api/project-assets/{projectId}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetReturnController::class, 'getProjectAssets'])->name('api.project-assets');
            });

            // Maintenance
            Route::prefix('maintenance')->name('maintenance.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'store'])->name('store');
                Route::get('/upcoming', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'upcoming'])->name('upcoming');
                Route::get('/overdue', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'overdue'])->name('overdue');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'show'])->name('show');
                Route::get('/{id}/edit', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'edit'])->name('edit');
                Route::put('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'update'])->name('update');
                Route::post('/{id}/start', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'start'])->name('start');
                Route::post('/{id}/complete', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetMaintenanceController::class, 'complete'])->name('complete');
            });

            // Depreciation
            Route::prefix('depreciation')->name('depreciation.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDepreciationController::class, 'index'])->name('index');
                Route::get('/asset/{assetId}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDepreciationController::class, 'show'])->name('show');
                Route::post('/calculate', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDepreciationController::class, 'calculate'])->name('calculate');
                Route::get('/export', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDepreciationController::class, 'export'])->name('export');
            });

            // Disposal
            Route::prefix('disposal')->name('disposal.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'index'])->name('index');
                Route::get('/create', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'create'])->name('create');
                Route::post('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'store'])->name('store');
                Route::get('/{id}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'show'])->name('show');
                Route::post('/{id}/approve', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'approve'])->name('approve');
                Route::post('/{id}/complete', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'complete'])->name('complete');
                Route::get('/{id}/print', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetDisposalController::class, 'print'])->name('print');
            });

            // Inventory / Asset Register Overview
            Route::prefix('inventory')->name('inventory.')->group(function () {
                Route::get('/', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetInventoryController::class, 'index'])->name('index');
                Route::get('/project-assets', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetInventoryController::class, 'projectAssets'])->name('project-assets');
                Route::get('/warehouse-assets', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetInventoryController::class, 'warehouseAssets'])->name('warehouse-assets');
                Route::get('/condition-report', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetInventoryController::class, 'conditionReport'])->name('condition-report');
                Route::get('/movement-history/{assetId?}', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetInventoryController::class, 'movementHistory'])->name('movement-history');
                Route::get('/all-assets', [\App\Http\Controllers\Warehouse\FixedAssets\FixedAssetInventoryController::class, 'allAssets'])->name('all-assets');
            });
        });
    });
