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)
@foreach ($products as $product) -
+
{{-- Imagen si existe --}} @if (!empty($product->image_path)) {{ $product->name }} @else -
- Sin imagen +
+ Sin imagen
@endif {{-- Nombre --}} -

{{ $product->name }}

+

{{ $product->name }}

{{-- Descripción corta --}}
@if (!empty($product->description)) -

{{ $product->description }}

+

{{ $product->description }}

@endif
{{-- Precio --}} @if (!empty($product->price)) -

${{ 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 @@ @endforeach
@else -

No hay productos disponibles.

+

No hay productos disponibles.

@endif
diff --git a/resources/views/catalogo/show.blade.php b/resources/views/catalogo/show.blade.php index 4e94d0c..cfc1485 100644 --- a/resources/views/catalogo/show.blade.php +++ b/resources/views/catalogo/show.blade.php @@ -3,23 +3,23 @@
- + Volver al Catálogo -
+
- -
+ +
@if($product->image_path) {{ $product->name }} @else -
+
Sin Imagen
@@ -27,7 +27,7 @@
- + @if($product->type == 'bike') Bicicleta @elseif($product->type == 'clothing') @@ -42,34 +42,34 @@
- -
+ +
-
-

SKU: {{ $product->sku ?? 'N/A' }}

-

{{ $product->name }}

+
+

SKU: {{ $product->sku ?? 'N/A' }}

+

{{ $product->name }}

@if($product->stock_quantity > 5) - - En Stock ({{ $product->stock_quantity }} unid.) + + En Stock ({{ $product->stock_quantity }} unid.) @elseif($product->stock_quantity > 0) - - ¡Últimas Unidades! ({{ $product->stock_quantity }}) + + ¡Últimas Unidades! ({{ $product->stock_quantity }}) @else - Agotado + Agotado @endif
- Precio Contado + Precio Contado
- ${{ number_format($product->price, 0, ',', '.') }} + ${{ number_format($product->price, 0, ',', '.') }} ARG

* Consultar financiación en el local.

@@ -77,20 +77,20 @@
-

Descripción

-

+

Descripción

+

{{ $product->description ?? 'Sin descripción detallada disponible para este producto. Por favor, acérquese al local para más información.' }}

- - + WhatsApp diff --git a/resources/views/clients/create.blade.php b/resources/views/clients/create.blade.php index 34bacb0..e97d183 100644 --- a/resources/views/clients/create.blade.php +++ b/resources/views/clients/create.blade.php @@ -1,45 +1,40 @@ - -
- +
@csrf - -
+
- +
- +
- +
- +
- + @error('address') {{ $message }} @enderror
-
-
- Cancelar - -
diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index bb10afb..b3137fd 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -1,75 +1,41 @@ - -
- +
@csrf - @method('PUT')
+ @method('PUT') +
+
- +
- +
- +
- +
- +
- +
- + @error('address') {{ $message }} @enderror
-
-
- - - Cancelar - - -
diff --git a/resources/views/clients/index.blade.php b/resources/views/clients/index.blade.php index d2853b0..0795f4a 100644 --- a/resources/views/clients/index.blade.php +++ b/resources/views/clients/index.blade.php @@ -2,6 +2,8 @@ + + @if(session('success'))
{{ session('success') }} @@ -13,24 +15,24 @@
-
- + + Nuevo Cliente
-
- - +
+
+ @@ -40,45 +42,43 @@ @forelse($clients as $client) - - + - - - - diff --git a/resources/views/components/footer.blade.php b/resources/views/components/footer.blade.php index c1105a8..94645f9 100644 --- a/resources/views/components/footer.blade.php +++ b/resources/views/components/footer.blade.php @@ -1,16 +1,16 @@ -
+ \ No newline at end of file diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index 5f0c99c..dfe5fa1 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -1,6 +1,6 @@ @props(['disabled' => false, 'error' => null]) -merge(['class' => 'bg-neutral-800 border-neutral-700 text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5 placeholder-gray-500 transition-colors ' . ($error ? 'border-red-500 focus:border-red-500 focus:ring-red-500' : '')]) !!}> +merge(['class' => 'bg-gray-300 dark:bg-neutral-800 border border-neutral-400 dark:border-neutral-700 dark:text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5 placeholder-neutral-600 dark:placeholder-gray-400 transition-colors ' . ($error ? 'border-red-500 focus:border-red-500 focus:ring-red-500' : '')]) !!}> @if($error)

{{ $error }}

diff --git a/resources/views/components/forms/label.blade.php b/resources/views/components/forms/label.blade.php index e729c95..57439de 100644 --- a/resources/views/components/forms/label.blade.php +++ b/resources/views/components/forms/label.blade.php @@ -1,5 +1,5 @@ @props(['value']) -
Cliente / Email Teléfono / WhatsApp
-
{{ $client->name }}
-
+
{{ $client->name }}
+
{{ $client->email ?? 'Sin email registrado' }}
@if($client->phone)
- {{ $client->phone }} - WA + {{ $client->phone }} + WA
@else - No registrado + No registrado @endif
- + {{ $client->address ?? '-' }} - - Editar + + + - -
+ @csrf @method('DELETE') - - -
+
- +
+
+ @@ -52,10 +51,10 @@ @forelse($products as $product) - - + - - @empty - diff --git a/resources/views/productos/show.blade.php b/resources/views/productos/show.blade.php index 2ed4516..9858012 100644 --- a/resources/views/productos/show.blade.php +++ b/resources/views/productos/show.blade.php @@ -35,15 +35,7 @@
- Volver - Editar -
- @csrf - @method('DELETE') - - + Volver
diff --git a/resources/views/productos/vistaUsuario.blade.php b/resources/views/productos/vistaUsuario.blade.php deleted file mode 100644 index 10b5d82..0000000 --- a/resources/views/productos/vistaUsuario.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - -
- Volver a catalogo -

Titulo: {{ $producto->name }}

-

- Categoria: {{ $producto->type }} -

-

- {{ $producto->content }} -

-
-
diff --git a/resources/views/sales/create.blade.php b/resources/views/sales/create.blade.php index bfdacea..7a16985 100644 --- a/resources/views/sales/create.blade.php +++ b/resources/views/sales/create.blade.php @@ -1,36 +1,85 @@ @push('styles') @endpush @@ -48,11 +97,11 @@ @endif -
+
@csrf -
+
@@ -65,26 +114,24 @@
-
- Total Items: 1 +
+ Total Items: 1
-
+
- + + +
- Subtotal - $0.00 + Subtotal + $0.00
-
-
-
+
- Monto Total a Pagar - $0.00 + Monto Total a Pagar + $0.00
-
+
- @@ -146,10 +192,8 @@
- - Cancelar - -
diff --git a/resources/views/sales/index.blade.php b/resources/views/sales/index.blade.php index faee08e..782cbd4 100644 --- a/resources/views/sales/index.blade.php +++ b/resources/views/sales/index.blade.php @@ -2,24 +2,69 @@ - -
- -
- -
+
+ + +
+ +
+
+ + + +
+ +
+
- - - - Registrar Venta - +
+ + +
+ +
+ + +
+
+ + +
+ +
+ + + @if(request()->hasAny(['search', 'client_id', 'date_from', 'date_to'])) + + + + + + @endif +
+
- -
-
Producto / SKU Tipo
+
{{ $product->name }}
-
{{ $product->sku }}
+
{{ $product->sku }}
@if($product->type === 'bike') Bicicleta @@ -63,7 +62,7 @@ @elseif($product->type === 'spare') Repuesto @else Accesorio @endif + ${{ number_format($product->price, 2) }} @@ -75,13 +74,32 @@ {{ $product->stock_quantity }} @endif - Editar + + + + + + + +
+ @csrf + @method('DELETE') + +
+ No se encontraron productos.
- + +
+
+ @@ -30,13 +75,70 @@ + @forelse($sales as $sale) + + + + + + + + + + + + + @empty + + + + @endforelse
# Ref Fecha
+ #{{ str_pad($sale->id, 5, '0', STR_PAD_LEFT) }} + + {{ $sale->created_at->format('d/m/Y H:i') }} + + @if($sale->client) +
{{ $sale->client->name }}
+
{{ $sale->client->phone ?? '' }}
+ @else + Consumidor Final + @endif +
+ @php + $colors = [ + 'Efectivo' => 'text-white dark:text-green-400 bg-green-600/80 dark:bg-green-900/20 border-green-800', + 'Transferencia' => 'text-white dark:text-blue-400 bg-blue-600/80 dark:bg-blue-900/20 border-blue-800', + 'Tarjeta de Débito' => 'text-white dark:text-purple-400 bg-purple-600/80 dark:bg-purple-900/20 border-purple-800', + 'Tarjeta de Crédito' => 'text-white dark:text-orange-400 bg-orange-600/80 dark:bg-orange-900/20 border-orange-800', + ]; + $badgeClass = $colors[$sale->payment_method] ?? 'bg-gray-400 dark:bg-gray-800 border-gray-700'; + @endphp + + {{ $sale->payment_method }} + + + ${{ number_format($sale->total, 2) }} + + + + + + + +
+
+ +

No se encontraron ventas registradas.

+
+
- -
+
+ {{ $sales->links() }}
- \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4b5f9ae..2fcbc18 100644 --- a/routes/web.php +++ b/routes/web.php @@ -54,10 +54,3 @@ Route::middleware(['auth'])->group(function () { Route::get('/appointments/{appointment}', [AppointmentController::class, 'show']) ->name('appointments.show'); }); - - -Route::get('/productos/{id}/vistaUsuario', [ProductosController::class,'vistaUsuario'])->name('productos.vistaUsuario'); - - - - diff --git a/tailwind.config.js b/tailwind.config.js index 20be7ba..443c689 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,5 +1,6 @@ /** @type {import('tailwindcss').Config} */ export default { + darkMode: "selector", content: [ "./resources/**/*.blade.php", "./resources/**/*.js",