Browse Source

cambios de todo

main
sergiomarquez778 3 days ago
parent
commit
f5770f9cb6
  1. 0
      -i
  2. 31
      app/Http/Controllers/PrestamoController.php
  3. 3
      database/migrations/2025_04_01_191325_add_estado_to_prestamos_table.php
  4. 4
      database/migrations/2025_04_01_192918_add_fecha_aceptacion_to_prestamos_table.php
  5. 28
      database/migrations/2025_05_08_175205_add_estado_to_prestamos_table.php
  6. 20
      database/migrations/[timestamp]_add_fecha_aceptacion_to_prestamos_table.php
  7. 71
      resources/views/layouts/dashboard.blade.php
  8. 47
      resources/views/prestamos/pendientes.blade.php
  9. 91
      resources/views/prestamos/rechazados.blade.php
  10. 23
      resources/views/prestamos/show.blade.php
  11. 3
      routes/web.php

31
app/Http/Controllers/PrestamoController.php

@ -225,4 +225,35 @@ class PrestamoController extends Controller
return redirect()->back()->with('error', 'Formato no soportado');
}
}
public function show($id)
{
$prestamo = \App\Models\Prestamo::findOrFail($id);
return view('prestamos.show', compact('prestamo'));
}
public function pendientes()
{
$prestamos = \App\Models\Prestamo::where('estado', 'pendiente')->where('eliminado', 0)->get();
return view('prestamos.pendientes', compact('prestamos'));
}
public function rechazados(Request $request)
{
$busqueda = $request->busqueda;
$prestamos = \App\Models\Prestamo::where('estado', 'rechazado')
->where('eliminado', 0)
->when($busqueda, function($query) use ($busqueda) {
$query->where(function($q) use ($busqueda) {
$q->where('nombre_solicitante', 'LIKE', "%{$busqueda}%")
->orWhere('destino', 'LIKE', "%{$busqueda}%")
->orWhere('motivo', 'LIKE', "%{$busqueda}%");
});
})
->orderBy('created_at', 'desc')
->get();
return view('prestamos.rechazados', compact('prestamos'));
}
}

3
database/migrations/2025_04_01_191325_add_estado_to_prestamos_table.php

@ -12,7 +12,8 @@ return new class extends Migration
public function up(): void
{
Schema::table('prestamos', function (Blueprint $table) {
$table->enum('estado', ['pendiente', 'aceptado', 'rechazado'])->default('pendiente')->after('chofer');
// $table->enum('estado', ['pendiente', 'aceptado', 'rechazado'])->default('pendiente')->after('chofer');
// Línea comentada porque la columna ya existe
});
}

4
database/migrations/2025_04_01_192918_add_fecha_aceptacion_to_prestamos_table.php

@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::table('prestamos', function (Blueprint $table) {
//
$table->timestamp('fecha_aceptacion')->nullable();
});
}
@ -22,7 +22,7 @@ return new class extends Migration
public function down(): void
{
Schema::table('prestamos', function (Blueprint $table) {
//
$table->dropColumn('fecha_aceptacion');
});
}
};

28
database/migrations/2025_05_08_175205_add_estado_to_prestamos_table.php

@ -0,0 +1,28 @@
<?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('prestamos', function (Blueprint $table) {
$table->enum('estado', ['pendiente', 'aceptado', 'rechazado'])->default('pendiente')->after('chofer');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('prestamos', function (Blueprint $table) {
$table->dropColumn('estado');
});
}
};

20
database/migrations/[timestamp]_add_fecha_aceptacion_to_prestamos_table.php

@ -1,20 +0,0 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFechaAceptacionToPrestamosTable extends Migration
{
public function up()
{
Schema::table('prestamos', function (Blueprint $table) {
$table->timestamp('fecha_aceptacion')->nullable()->after('estado');
});
}
public function down()
{
Schema::table('prestamos', function (Blueprint $table) {
$table->dropColumn('fecha_aceptacion');
});
}
}

71
resources/views/layouts/dashboard.blade.php

@ -78,24 +78,26 @@
<span class="font-light">Nuevo Préstamo</span>
</a>
</li>
<li>
<!-- <li>
<a href="/prestamos/pendientes" class="nav-item-hover flex items-center space-x-3 px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm {{ request()->is('prestamos/pendientes') ? 'bg-white/20' : '' }}">
<i class="fas fa-clock text-white/80"></i>
<span class="font-light">Préstamos Pendientes</span>
</a>
</li>
-->
<li>
<a href="/prestamos/rechazados" class="nav-item-hover flex items-center space-x-3 px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm {{ request()->is('prestamos/rechazados') ? 'bg-white/20' : '' }}">
<i class="fas fa-times text-white/80"></i>
<span class="font-light">Préstamos Rechazados</span>
<a href="/prestamos/aceptados" class="nav-item-hover flex items-center space-x-3 px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm {{ request()->is('prestamos/aceptados') ? 'bg-white/20' : '' }}">
<i class="fas fa-clock text-white/80"></i>
<span class="font-light">Préstamos pendientes/aceptados</span>
</a>
</li>
<li>
<a href="/prestamos/aceptados" class="nav-item-hover flex items-center space-x-3 px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm {{ request()->is('prestamos/aceptados') ? 'bg-white/20' : '' }}">
<i class="fas fa-check text-white/80"></i>
<span class="font-light">Préstamos Aceptados</span>
<a href="/prestamos/rechazados" class="nav-item-hover flex items-center space-x-3 px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm {{ request()->is('prestamos/rechazados') ? 'bg-white/20' : '' }}">
<i class="fas fa-times text-white/80"></i>
<span class="font-light">Préstamos Rechazados</span>
</a>
</li>
<li>
<a href="/prestamos/historial" class="nav-item-hover flex items-center space-x-3 px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm {{ request()->is('prestamos/historial') ? 'bg-white/20' : '' }}">
<i class="fas fa-history text-white/80"></i>
@ -181,17 +183,7 @@
<span class="font-light">Tipo de Gasolina</span>
</a>
</li>
<!-- Puestos -->
<li x-data="{ openPuestos: false }" class="relative">
<button @click="openPuestos = !openPuestos"
class="nav-item-hover flex items-center justify-between w-full px-4 py-3 rounded-lg hover:bg-white/10 backdrop-blur-sm">
<div class="flex items-center space-x-2">
<i class="fas fa-user-tie text-white/80"></i>
<span class="font-light">Puestos</span>
</div>
<i class="fas fa-chevron-right text-xs"
:class="{ 'transform rotate-90': openPuestos }"></i>
</button>
<!-- Submenú de Puestos -->
<ul x-show="openPuestos"
@ -234,41 +226,18 @@
<!-- Navbar modernizado -->
<header class="bg-white/80 backdrop-blur-md shadow-sm">
<div class="flex items-center justify-between px-8 py-4">
<button class="md:hidden text-gray-500 hover:text-gray-700 transition-colors duration-200">
<i class="fas fa-bars text-xl"></i>
</button>
<div class="flex items-center space-x-4">
<div class="relative" x-data="{ open: false }">
<button @click="open = !open"
class="flex items-center space-x-3 text-gray-700 hover:text-gray-900 px-4 py-2 rounded-full hover:bg-gray-100 transition-all duration-200">
<img src="https://ui-avatars.com/api/?name={{ Auth::check() ? Auth::user()->name : 'Usuario' }}"
alt="Profile"
class="w-8 h-8 rounded-full ring-2 ring-blue-500/20">
<span class="font-medium">{{ Auth::check() ? Auth::user()->name : 'Usuario' }}</span>
<i class="fas fa-chevron-down text-sm transition-transform duration-200"
:class="{ 'transform rotate-180': open }"></i>
</button>
<!-- Menú desplegable modernizado -->
<div x-show="open"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 transform scale-95"
x-transition:enter-end="opacity-100 transform scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 transform scale-100"
x-transition:leave-end="opacity-0 transform scale-95"
@click.away="open = false"
class="absolute right-0 mt-2 w-48 bg-white rounded-xl shadow-lg py-2 ring-1 ring-black ring-opacity-5">
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors duration-150">
<i class="fas fa-sign-out-alt mr-2"></i> Cerrar Sesión
</button>
</form>
</div>
<div class="flex items-center gap-2 bg-gray-100 rounded-full px-2 py-1">
<div class="w-10 h-10 flex items-center justify-center rounded-full bg-gray-200 text-gray-700 font-semibold text-lg">
{{ strtoupper(substr(Auth::user()->name ?? 'U', 0, 1)) }}{{ strtoupper(substr(Auth::user()->name ?? 'U', 1, 1)) }}
</div>
<span class="font-medium text-gray-800">{{ Auth::user()->name ?? 'Usuario' }}</span>
</div>
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="flex items-center gap-1 text-red-600 hover:text-red-800 font-semibold transition-colors">
<i class="fas fa-sign-out-alt"></i> Cerrar Sesión
</button>
</form>
</div>
</header>

47
resources/views/prestamos/pendientes.blade.php

@ -0,0 +1,47 @@
@extends('layouts.dashboard')
@section('content')
<div class="container mx-auto px-4 py-6">
<div class="bg-white rounded-lg shadow-lg">
<div class="p-4 border-b border-gray-200 flex justify-between items-center">
<h2 class="text-2xl font-bold">Préstamos Pendientes</h2>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">#</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Solicitante</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Destino</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha Salida</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha Llegada</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Motivo</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Domicilio</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Personas</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Chofer</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($prestamos as $index => $prestamo)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $index + 1 }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->nombre_solicitante }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->destino }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->fecha_hora_salida }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->fecha_hora_llegada }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->motivo }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->domicilio }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->numero_personas }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->chofer ? 'Sí' : 'No' }}</td>
</tr>
@empty
<tr>
<td colspan="9" class="px-6 py-4 text-center text-gray-500">No hay préstamos pendientes.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
@endsection

91
resources/views/prestamos/rechazados.blade.php

@ -0,0 +1,91 @@
@extends('layouts.dashboard')
@section('content')
<div class="container mx-auto px-4 py-6">
<div class="bg-white rounded-lg shadow-lg">
<div class="p-4 border-b border-gray-200 flex justify-between items-center">
<h2 class="text-2xl font-bold">Préstamos Rechazados</h2>
</div>
<!-- Barra de búsqueda -->
<div class="p-4 border-b border-gray-200 bg-gray-50">
<form action="{{ route('prestamos.rechazados') }}" method="GET" class="flex gap-2">
<div class="relative w-full sm:w-64">
<input type="text"
name="busqueda"
placeholder="Buscar préstamo..."
value="{{ request('busqueda') }}"
class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<div class="absolute left-3 top-2.5 text-gray-400">
<i class="fas fa-search"></i>
</div>
</div>
<button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600">
Buscar
</button>
@if(request('busqueda'))
<a href="{{ route('prestamos.rechazados') }}" class="px-4 py-2 bg-gray-500 text-white rounded-lg hover:bg-gray-600">
Limpiar
</a>
@endif
</form>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Número</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Solicitante</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Destino</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha Salida</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha Llegada</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Motivo</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Domicilio</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Personas</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Chofer</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Estado</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($prestamos as $prestamo)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $prestamo->id }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<i class="fas fa-user text-blue-500 mr-2"></i>
{{ $prestamo->nombre_solicitante }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<i class="fas fa-map-marker-alt text-red-500 mr-2"></i>
{{ $prestamo->destino }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<i class="fas fa-calendar text-green-500 mr-2"></i>
{{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('d/m/Y H:i') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<i class="fas fa-calendar-check text-yellow-500 mr-2"></i>
{{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('d/m/Y H:i') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">{{ $prestamo->motivo }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">{{ $prestamo->domicilio }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-center">{{ $prestamo->numero_personas }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">{{ $prestamo->chofer ? 'Sí' : 'No' }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<span class="inline-flex items-center px-3 py-1 rounded-full bg-red-50">
<span class="flex items-center justify-center w-5 h-5 rounded-full bg-red-700 mr-2">
<i class="fas fa-times text-white text-xs"></i>
</span>
<span class="text-red-700 font-semibold">Rechazado</span>
</span>
</td>
</tr>
@empty
<tr>
<td colspan="10" class="px-6 py-4 text-center text-gray-500">No hay préstamos rechazados.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
@endsection

23
resources/views/prestamos/show.blade.php

@ -0,0 +1,23 @@
@extends('layouts.dashboard')
@section('content')
<div class="container mx-auto px-4 py-6">
<div class="max-w-lg mx-auto bg-white rounded-lg shadow-lg p-6">
<h2 class="text-2xl font-bold mb-4 text-gray-800">Detalle del Préstamo</h2>
<ul class="divide-y divide-gray-200">
<li class="py-2"><strong>Solicitante:</strong> {{ $prestamo->nombre_solicitante }}</li>
<li class="py-2"><strong>Destino:</strong> {{ $prestamo->destino }}</li>
<li class="py-2"><strong>Fecha y Hora de Salida:</strong> {{ $prestamo->fecha_hora_salida }}</li>
<li class="py-2"><strong>Fecha y Hora de Llegada:</strong> {{ $prestamo->fecha_hora_llegada }}</li>
<li class="py-2"><strong>Motivo:</strong> {{ $prestamo->motivo }}</li>
<li class="py-2"><strong>Domicilio:</strong> {{ $prestamo->domicilio }}</li>
<li class="py-2"><strong>Número de Personas:</strong> {{ $prestamo->numero_personas }}</li>
<li class="py-2"><strong>Chofer:</strong> {{ $prestamo->chofer ? 'Sí' : 'No' }}</li>
<li class="py-2"><strong>Estado:</strong> {{ $prestamo->estado }}</li>
</ul>
<div class="mt-6">
<a href="{{ route('prestamos.index') }}" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">Volver</a>
</div>
</div>
</div>
@endsection

3
routes/web.php

@ -63,6 +63,8 @@ use App\Http\Controllers\DespartamentoController;
Route::post('/prestamos/{id}/aceptar', [PrestamoController::class, 'aceptar'])->name('prestamos.aceptar');
Route::post('/prestamos/{id}/rechazar', [PrestamoController::class, 'rechazar'])->name('prestamos.rechazar');
Route::get('/prestamos/historial', [PrestamoController::class, 'historial'])->name('prestamos.historial');
Route::get('/prestamos/pendientes', [PrestamoController::class, 'pendientes'])->name('prestamos.pendientes');
Route::get('/prestamos/rechazados', [PrestamoController::class, 'rechazados'])->name('prestamos.rechazados');
// Después la ruta de recurso (más general)
Route::resource('prestamos', PrestamoController::class);
@ -73,6 +75,7 @@ use App\Http\Controllers\DespartamentoController;
// Rutas protegidas que requieren autenticación
// Rutas protegidas que requieren autenticación
Route::middleware(['auth'])->group(function () {

Loading…
Cancel
Save