NUEVO: Implementado PROTOTIPO (v0.1) de taller, creado a partir de modelo kanban con columnas de estados. PENDIENTE DE MUCHOS CAMBIOS...

This commit is contained in:
Bryam105
2026-01-23 11:56:27 -03:30
parent bbef546d75
commit b2f2343592
8 changed files with 322 additions and 2 deletions
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers;
use App\Models\Appointment;
use App\Models\Client;
use Illuminate\Http\Request;
class TallerController extends Controller
{
/**
* Vista principal
*/
public function index()
{
// Trabajos activos ordenados por fecha
$jobs = Appointment::with('client')
->whereIn('status', ['pending', 'in_progress', 'ready']) // Entregados/historial no se muestra, implementar vista aparte
->orderBy('scheduled_at', 'asc')
->get();
// Agrupado por estado para las columnas
$pending = $jobs->where('status', 'pending');
$inProgress = $jobs->where('status', 'in_progress');
$ready = $jobs->where('status', 'ready');
return view('taller.index', compact('pending', 'inProgress', 'ready'));
}
/**
* Formulario para nuevo servicio
*/
public function create()
{
$clients = Client::orderBy('name')->get();
return view('taller.create', compact('clients'));
}
/**
* Guardar el servicio
*/
public function store(Request $request)
{
$request->validate([
'client_id' => 'required|exists:clients,id',
'bike_model' => 'required|string',
'problem_description' => 'required|string',
'scheduled_at' => 'required|date',
'estimated_cost' => 'nullable|numeric',
]);
// Buscamos el cliente para copiar su teléfono
$client = Client::find($request->client_id);
Appointment::create([
'client_id' => $request->client_id,
'contact_phone' => $request->contact_phone ?? $client->phone,
'bike_model' => $request->bike_model,
'problem_description' => $request->problem_description,
'parts_needed' => $request->parts_needed,
'estimated_cost' => $request->estimated_cost,
'scheduled_at' => $request->scheduled_at,
'status' => 'pending', // Estado inicial: Pendiente
]);
return redirect()->route('taller.index')->with('success', 'Bicicleta ingresada al taller correctamente.');
}
/**
* Mover de estado
*/
public function updateStatus(Request $request, Appointment $appointment)
{
$appointment->update(['status' => $request->status]);
return back()->with('success', 'Estado actualizado.');
}
}
+3
View File
@@ -11,9 +11,12 @@ class Appointment extends Model
protected $fillable = [
'client_id',
'contact_phone',
'scheduled_at',
'bike_model',
'problem_description',
'parts_needed',
'estimated_cost',
'status',
'notes'
];
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('appointments', function (Blueprint $table) {
// Repuestos estimados (texto simple por ahora)
$table->text('parts_needed')->nullable()->after('problem_description');
// Costo Aproximado (Presupuesto)
$table->decimal('estimated_cost', 10, 2)->nullable()->after('parts_needed');
// Teléfono de contacto rápido (por si es distinto al del cliente registrado)
$table->string('contact_phone')->nullable()->after('client_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('appointments', function (Blueprint $table) {
$table->dropColumn(['parts_needed', 'estimated_cost', 'contact_phone']);
});
}
};
@@ -0,0 +1,72 @@
@props(['job', 'color'])
@php
$borderColor = match($color) {
'red' => 'border-l-red-500',
'yellow' => 'border-l-yellow-500',
'neon' => 'border-l-neon-lime',
default => 'border-l-gray-500'
};
@endphp
<div class="bg-panel-bg p-4 rounded-lg border border-neutral-700 border-l-4 {{ $borderColor }} shadow-lg group hover:bg-neutral-800 transition-colors">
<!-- Encabezado Tarjeta -->
<div class="flex justify-between items-start mb-2">
<span class="text-xs font-bold text-gray-400">{{ $job->client->name }}</span>
<span class="text-xs font-mono text-gray-500">{{ $job->scheduled_at->format('d/m H:i') }}</span>
</div>
<h4 class="text-white font-bold text-sm mb-1">{{ $job->bike_model }}</h4>
<p class="text-gray-400 text-xs line-clamp-2 mb-3">{{ $job->problem_description }}</p>
@if($job->estimated_cost)
<div class="text-right mb-3">
<span class="text-xs text-gray-500">Presupuesto:</span>
<span class="text-sm font-mono text-white font-bold">${{ number_format($job->estimated_cost, 0) }}</span>
</div>
@endif
<!-- Controles de Estado -->
<div class="flex justify-between items-center pt-2 border-t border-neutral-700 mt-2 opacity-100 md:opacity-50 group-hover:opacity-100 transition-opacity">
<!-- Botón Mover Atrás -->
@if($job->status !== 'pending')
<form action="{{ route('taller.updateStatus', $job) }}" method="POST">
@csrf @method('PATCH')
<input type="hidden" name="status" value="{{ $job->status === 'ready' ? 'in_progress' : 'pending' }}">
<button class="text-gray-500 hover:text-white p-1" title="Volver al estado anterior">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg>
</button>
</form>
@else
<div></div> <!-- Espaciador -->
@endif
<!-- Enlace a WhatsApp -->
<a href="https://wa.me/{{ $job->contact_phone }}?text=Hola {{ $job->client->name }}, te escribimos de Lauck para avisarte sobre tu {{ $job->bike_model }}..." target="_blank" class="text-green-500 hover:text-green-400">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M17.472 14.382c..."></path></svg> <!-- (Usa el mismo SVG de whatsapp de antes) -->
<span class="text-xs ml-1">Avisar</span>
</a>
<!-- Botón Mover Adelante -->
@if($job->status !== 'ready')
<form action="{{ route('taller.updateStatus', $job) }}" method="POST">
@csrf @method('PATCH')
<input type="hidden" name="status" value="{{ $job->status === 'pending' ? 'in_progress' : 'ready' }}">
<button class="text-neon-lime hover:text-white p-1" title="Avanzar estado">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
</button>
</form>
@elseif($job->status === 'ready')
<!-- Botón Entregar (Archivar) -->
<form action="{{ route('taller.updateStatus', $job) }}" method="POST">
@csrf @method('PATCH')
<input type="hidden" name="status" value="delivered">
<button class="text-xs bg-neon-lime text-black px-2 py-1 rounded font-bold hover:bg-white" title="Marcar como entregado">
Entregar
</button>
</form>
@endif
</div>
</div>
+1 -1
View File
@@ -16,7 +16,7 @@
</x-ui.card>
<!-- Tarjeta Taller -->
<x-ui.card href="#" title="Taller" description="Gestión de services y reparaciones." linkText="Ver agenda">
<x-ui.card href="{{ url('/taller') }}" title="Taller" description="Gestión de services y reparaciones." linkText="Ver agenda">
<svg class="w-12 h-12 text-neon-lime" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
</x-ui.card>
+72
View File
@@ -0,0 +1,72 @@
<x-layout title="Ingreso Taller">
<x-section-header subtitle="Taller" title="Nueva " highlight="Orden de Reparación" />
<div class="max-w-4xl mx-auto bg-panel-bg border border-neutral-800 rounded-xl p-8 shadow-lg">
<form action="{{ route('taller.store') }}" method="POST" class="space-y-6">
@csrf
<!-- 1. Datos del Cliente y Contacto -->
<div class="border-b border-neutral-800 pb-6">
<h3 class="text-white font-bold uppercase tracking-wider text-sm mb-4">1. Cliente y Contacto</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Propietario</label>
<select name="client_id" class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime">
@foreach($clients as $client)
<option value="{{ $client->id }}">{{ $client->name }}</option>
@endforeach
</select>
<a href="{{ route('clients.create') }}" class="text-xs text-neon-lime hover:underline mt-1 inline-block">+ Nuevo Cliente</a>
</div>
<div>
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Teléfono Aviso (Opcional)</label>
<input type="text" name="contact_phone" placeholder="Dejar vacío para usar el del perfil" class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime">
</div>
</div>
</div>
<!-- 2. La Bicicleta y el Diagnóstico -->
<div class="border-b border-neutral-800 pb-6">
<h3 class="text-white font-bold uppercase tracking-wider text-sm mb-4">2. Diagnóstico Inicial</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="md:col-span-2">
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Modelo de Bici / Color</label>
<input type="text" name="bike_model" required placeholder="Ej: Venzo Loki Roja R29" class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime">
</div>
<div>
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Problema / Servicio Solicitado</label>
<textarea name="problem_description" rows="4" required class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime" placeholder="Ej: Service completo, hace ruido la caja, regular cambios..."></textarea>
</div>
<div>
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Repuestos Estimados (Opcional)</label>
<textarea name="parts_needed" rows="4" class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime" placeholder="Ej: Cadena nueva, pastillas de freno..."></textarea>
</div>
</div>
</div>
<!-- 3. Agenda y Costos -->
<div>
<h3 class="text-white font-bold uppercase tracking-wider text-sm mb-4">3. Acuerdo</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Fecha Prometida / Retiro</label>
<input type="datetime-local" name="scheduled_at" required class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime">
</div>
<div>
<label class="block text-xs font-bold text-gray-400 uppercase mb-2">Presupuesto Aproximado ($)</label>
<input type="number" name="estimated_cost" step="0.01" class="w-full bg-neutral-900 border border-neutral-700 text-white rounded-lg p-2.5 focus:ring-neon-lime focus:border-neon-lime text-right font-mono" placeholder="0.00">
</div>
</div>
</div>
<div class="flex justify-end pt-4">
<button type="submit" class="px-8 py-3 bg-neon-lime text-neutral-900 font-bold rounded-lg hover:bg-[#b3e600] uppercase tracking-wide">
Ingresar Bicicleta
</button>
</div>
</form>
</div>
</x-layout>
+54
View File
@@ -0,0 +1,54 @@
<x-layout title="Tablero de Taller">
<div class="flex justify-between items-end mb-6">
<x-section-header subtitle="Gestión" title="Tablero de " highlight="Taller" />
<a href="{{ route('taller.create') }}" class="mb-10 px-5 py-2.5 bg-neon-lime text-neutral-900 font-bold rounded-lg hover:bg-[#b3e600] uppercase tracking-wide text-xs flex items-center gap-2">
+ Ingresar Bici
</a>
</div>
<!-- Contenedor -->
<div class="flex flex-col md:flex-row gap-6 overflow-x-auto pb-4 h-[calc(100vh-250px)]">
<!-- COLUMNA 1 -->
<div class="flex-1 min-w-[300px] bg-neutral-900/50 border border-neutral-800 rounded-xl flex flex-col">
<div class="p-4 border-b border-neutral-800 bg-neutral-800/50 rounded-t-xl flex justify-between items-center">
<h3 class="font-bold text-gray-300 uppercase tracking-widest text-xs">🔴 Pendientes / A Revisar</h3>
<span class="bg-neutral-900 text-gray-400 text-xs px-2 py-1 rounded-full">{{ $pending->count() }}</span>
</div>
<div class="p-4 space-y-4 overflow-y-auto flex-1 custom-scrollbar">
@foreach($pending as $job)
<x-taller-card :job="$job" color="red" />
@endforeach
</div>
</div>
<!-- COLUMNA 2 -->
<div class="flex-1 min-w-[300px] bg-neutral-900/50 border border-neutral-800 rounded-xl flex flex-col">
<div class="p-4 border-b border-neutral-800 bg-neutral-800/50 rounded-t-xl flex justify-between items-center">
<h3 class="font-bold text-yellow-500 uppercase tracking-widest text-xs">🟡 En Reparación</h3>
<span class="bg-neutral-900 text-gray-400 text-xs px-2 py-1 rounded-full">{{ $inProgress->count() }}</span>
</div>
<div class="p-4 space-y-4 overflow-y-auto flex-1 custom-scrollbar">
@foreach($inProgress as $job)
<x-taller-card :job="$job" color="yellow" />
@endforeach
</div>
</div>
<!-- COLUMNA 3 -->
<div class="flex-1 min-w-[300px] bg-neutral-900/50 border border-neutral-800 rounded-xl flex flex-col">
<div class="p-4 border-b border-neutral-800 bg-neutral-800/50 rounded-t-xl flex justify-between items-center">
<h3 class="font-bold text-neon-lime uppercase tracking-widest text-xs">🟢 Listas para Retirar</h3>
<span class="bg-neutral-900 text-gray-400 text-xs px-2 py-1 rounded-full">{{ $ready->count() }}</span>
</div>
<div class="p-4 space-y-4 overflow-y-auto flex-1 custom-scrollbar">
@foreach($ready as $job)
<x-taller-card :job="$job" color="neon" />
@endforeach
</div>
</div>
</div>
</x-layout>
+8 -1
View File
@@ -9,6 +9,7 @@ use App\Http\Controllers\HomeController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\ProductosController;
use App\Http\Controllers\RegisterController;
use App\Http\Controllers\TallerController;
use App\Models\Product;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
@@ -40,7 +41,13 @@ Route::middleware(['auth'])->group(function () {
'productos' => 'product'
]);
Route::resource('sales', SaleController::class)->only(['index', 'create', 'store', 'show']);
// Rutas de Taller
Route::controller(TallerController::class)->prefix('taller')->name('taller.')->group(function () {
Route::get('/', 'index')->name('index');
Route::get('/create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::patch('/{appointment}/status', 'updateStatus')->name('updateStatus');
});
});