<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\CategoriaController;
use App\Http\Controllers\ProductoController;
use App\Http\Controllers\ClienteController;
use App\Http\Controllers\ProveedorController;
use App\Http\Controllers\CompraController;
use App\Http\Controllers\VentaController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::resource('categorias', CategoriaController::class);
Route::resource('productos', ProductoController::class);
Route::get('/productos/{producto}/costos', [ProductoController::class, 'costos'])->name('productos.costos');
Route::post('/productos/{producto}/costos', [ProductoController::class, 'guardarCostos'])->name('productos.guardarCostos');
Route::get('/reportes/financiero', [ProductoController::class, 'reporteFinanciero'])->name('reportes.financiero');

// Rutas para importación de productos
Route::get('/productos-importar', [ProductoController::class, 'mostrarImportar'])->name('productos.importar');
Route::post('/productos-importar', [ProductoController::class, 'importar'])->name('productos.importar.procesar');
Route::get('/productos-importar/plantilla', [ProductoController::class, 'descargarPlantilla'])->name('productos.importar.plantilla');

Route::resource('clientes', ClienteController::class);
Route::resource('proveedores', ProveedorController::class);
Route::resource('compras', CompraController::class);
Route::resource('ventas', VentaController::class);

// Ruta para notificaciones de stock bajo
Route::get('/api/notificaciones/stock-bajo', [ProductoController::class, 'getStockBajo'])->name('api.notificaciones.stock-bajo');
