diff --git a/app/Http/Controllers/SaleController.php b/app/Http/Controllers/SaleController.php index f491de7..49149a1 100644 --- a/app/Http/Controllers/SaleController.php +++ b/app/Http/Controllers/SaleController.php @@ -11,13 +11,44 @@ use Illuminate\Support\Facades\DB; class SaleController extends Controller { - public function index() + public function index(Request $request) { - $sales = Sale::with('client') - ->orderBy('created_at', 'desc') - ->paginate(15); + // Recuperar filtros + $search = $request->input('search'); // Búsqueda por ID + $clientId = $request->input('client_id'); // Filtro Cliente + $dateFrom = $request->input('date_from'); // Fecha Desde + $dateTo = $request->input('date_to'); // Fecha Hasta - return view('sales.index', compact('sales')); + // Query principal + $sales = Sale::query() + ->with(['client', 'details']) + + // 1. Filtro por ID de venta (si escriben en el buscador texto) + ->when($search, function ($query, $search) { + return $query->where('id', 'like', "%{$search}%"); + }) + + // 2. Filtro por Cliente (Select2) + ->when($clientId, function ($query, $clientId) { + return $query->where('client_id', $clientId); + }) + + // 3. Filtro por Rango de Fechas + ->when($dateFrom, function ($query, $dateFrom) { + return $query->whereDate('created_at', '>=', $dateFrom); + }) + ->when($dateTo, function ($query, $dateTo) { + return $query->whereDate('created_at', '<=', $dateTo); + }) + + ->latest() // Ordenar por fecha descendente + ->paginate(10) + ->withQueryString(); // Mantener filtros al cambiar de página + + // Traemos clientes para el select del filtro (solo id y nombre para optimizar) + $clients = Client::orderBy('name')->get(['id', 'name']); + + return view('sales.index', compact('sales', 'clients')); } public function create() diff --git a/database/migrations/2025_12_06_182358_create_products_table.php b/database/migrations/2025_12_06_182358_create_products_table.php index 69f735f..326973c 100644 --- a/database/migrations/2025_12_06_182358_create_products_table.php +++ b/database/migrations/2025_12_06_182358_create_products_table.php @@ -13,8 +13,9 @@ return new class extends Migration { Schema::create('products', function (Blueprint $table) { $table->id(); - $table->string('name'); - $table->string('sku')->unique()->nullable(); // Código de barras o interno + $table->enum('type', ['bike', 'accessory', 'clothing', 'service']); + //$table->string('name'); + //$table->string('sku')->unique()->nullable(); // Código de barras o interno $table->text('description')->nullable(); $table->decimal('price', 10, 2); // Precio venta diff --git a/database/seeders/ProductSeeder.php b/database/seeders/ProductSeeder.php index abadd51..2a80423 100644 --- a/database/seeders/ProductSeeder.php +++ b/database/seeders/ProductSeeder.php @@ -276,7 +276,7 @@ class ProductSeeder extends Seeder 'cost' => 0, 'stock_quantity' => 999, 'min_stock_alert' => 0, - 'type' => 'service', + 'type' => 'clothing', ], ]; diff --git a/resources/css/app.css b/resources/css/app.css index b9da903..d0a3e62 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -3,6 +3,7 @@ /* 2. Importar Tailwind (v4) */ @import "tailwindcss"; +@custom-variant dark (&:is(.dark *)); @source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php'; @source '../../storage/framework/views/*.php'; @source '../**/*.blade.php'; @@ -25,13 +26,16 @@ /* 4. Patrón de fondo estilo "Técnico" */ .bg-grid-pattern { - /* CAMBIO: Usamos rgba(255,255,255, 0.1) para que las líneas sean claras sobre fondo oscuro */ - background-image: linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px), - linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px); + background-image: linear-gradient(to right, rgba(0, 0, 0, 0.1) 1px, transparent 1px), + linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 1px, transparent 1px); background-size: 40px 40px; background-position: center; } +:is(.dark) .bg-grid-pattern { + background-image: linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px), + linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px); +} /* 5. Personalización del Scrollbar */ ::-webkit-scrollbar { width: 8px; diff --git a/resources/views/catalogo/index.blade.php b/resources/views/catalogo/index.blade.php index 6219ae8..b50f89f 100644 --- a/resources/views/catalogo/index.blade.php +++ b/resources/views/catalogo/index.blade.php @@ -8,35 +8,35 @@ @if ($products->count() > 0)
${{ number_format($product->price, 2, ',', '.') }}
+${{ number_format($product->price, 2, ',', '.') }}
@endif {{-- Botón --}} + class="mt-4 block w-full bg-neutral-900 dark:bg-neon-lime/80 uppercase text-neon-lime dark:text-black font-semibold py-2 rounded-lg text-center shadow-md shadow-gray-900/10 dark:shadow-neon-lime/10 hover:bg-neon-lime hover:dark:bg-neutral-900/70 border border-transparent hover:text-black hover:dark:text-neon-lime hover:border-black hover:dark:border-neon-lime transition-all"> Ver + @@ -44,7 +44,7 @@ @endforeachNo hay productos disponibles.
+No hay productos disponibles.
@endifSKU: {{ $product->sku ?? 'N/A' }}
-SKU: {{ $product->sku ?? 'N/A' }}
+* Consultar financiación en el local.
@@ -77,20 +77,20 @@+
{{ $product->description ?? 'Sin descripción detallada disponible para este producto. Por favor, acérquese al local para más información.' }}