Browse Source

formatooo

formato de los prestamos
main
sergiomarquez778 4 weeks ago
parent
commit
436b19f9f4
  1. 6
      app/Http/Controllers/PrestamoController.php
  2. 7
      app/Http/Controllers/UserDashboardController.php
  3. 66
      resources/views/exports/prestamo-individual-pdf.blade.php
  4. 79
      resources/views/exports/prestamos-reporte-pdf.blade.php
  5. 2
      resources/views/prestamos.blade.php
  6. 3
      resources/views/user-dashboard/detalle-prestamo.blade.php
  7. 1
      routes/web.php

6
app/Http/Controllers/PrestamoController.php

@ -152,9 +152,9 @@ class PrestamoController extends Controller
*/ */
public function exportPDF() public function exportPDF()
{ {
$prestamos = Prestamo::where('eliminado', 0)->get(); $prestamos = \App\Models\Prestamo::with(['vehiculo', 'choferAsignado'])->get();
$pdf = PDF::loadView('exports.prestamos-pdf', ['prestamos' => $prestamos]); $pdf = \PDF::loadView('exports.prestamos-reporte-pdf', ['prestamos' => $prestamos]);
return $pdf->download('prestamos.pdf'); return $pdf->download('reporte_general_prestamos.pdf');
} }
public function aceptados(Request $request) public function aceptados(Request $request)

7
app/Http/Controllers/UserDashboardController.php

@ -44,4 +44,11 @@ class UserDashboardController extends Controller
} }
return view('user-dashboard.cuestionario', compact('prestamo')); return view('user-dashboard.cuestionario', compact('prestamo'));
} }
public function pdfPrestamo($id)
{
$prestamo = \App\Models\Prestamo::with('choferAsignado')->findOrFail($id);
$pdf = \PDF::loadView('exports.prestamo-individual-pdf', compact('prestamo'));
return $pdf->download('reporte_prestamo_'.$prestamo->id.'.pdf');
}
} }

66
resources/views/exports/prestamo-individual-pdf.blade.php

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>Reporte de Préstamo</title>
<style>
body { font-family: Arial, sans-serif; font-size: 12px; }
.header { text-align: center; margin-bottom: 20px; }
.reporte-table {
width: 100%;
border-collapse: collapse;
margin: 0 auto 20px auto;
}
.reporte-table th, .reporte-table td {
border: 1px solid #333;
padding: 8px 6px;
text-align: center;
}
.reporte-table th {
background: #e3e8f0;
font-weight: bold;
}
.firmas {
margin-top: 40px;
width: 100%;
text-align: center;
}
.firmas td {
padding: 30px 10px 0 10px;
}
</style>
</head>
<body>
<div class="header">
<h2>REPORTE DE PRÉSTAMO</h2>
<p>Fecha de generación: {{ now()->format('d/m/Y H:i') }}</p>
</div>
<table class="reporte-table">
<tr>
<th>Solicitante</th>
<th>Destino</th>
<th>Fecha Salida</th>
<th>Fecha Llegada</th>
<th>Motivo</th>
<th>Personas</th>
<th>Chofer</th>
<th>Estado</th>
</tr>
<tr>
<td>{{ $prestamo->nombre_solicitante }}</td>
<td>{{ $prestamo->destino }}</td>
<td>{{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('d/m/Y H:i') }}</td>
<td>{{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('d/m/Y H:i') }}</td>
<td>{{ $prestamo->motivo }}</td>
<td>{{ $prestamo->numero_personas }}</td>
<td>{{ $prestamo->choferAsignado ? $prestamo->choferAsignado->nombre : 'Sin chofer' }}</td>
<td>{{ ucfirst($prestamo->estado) }}</td>
</tr>
</table>
<table class="firmas">
<tr>
<td>_________________________<br>Solicitante</td>
<td>_________________________<br>Vo. Bo.</td>
</tr>
</table>
</body>
</html>

79
resources/views/exports/prestamos-reporte-pdf.blade.php

@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<title>Reporte General de Préstamos</title>
<style>
body { font-family: Arial, sans-serif; font-size: 11px; }
.header { text-align: center; margin-bottom: 20px; }
.reporte-table {
width: 100%;
border-collapse: collapse;
margin: 0 auto 20px auto;
}
.reporte-table th, .reporte-table td {
border: 1px solid #333;
padding: 6px 4px;
text-align: center;
}
.reporte-table th {
background: #e3e8f0;
font-weight: bold;
font-size: 11px;
}
.firmas {
margin-top: 40px;
width: 100%;
text-align: center;
}
.firmas td {
padding: 30px 10px 0 10px;
}
</style>
</head>
<body>
<div class="header">
<h2>REPORTE GENERAL DE PRÉSTAMOS</h2>
<p>Fecha de generación: {{ now()->format('d/m/Y H:i') }}</p>
</div>
<table class="reporte-table">
<thead>
<tr>
<th>#</th>
<th>Solicitante</th>
<th>Vehículo</th>
<th>Destino</th>
<th>Fecha Salida</th>
<th>Fecha Llegada</th>
<th>Motivo</th>
<th>Domicilio</th>
<th>Personas</th>
<th>Chofer</th>
<th>Estado</th>
</tr>
</thead>
<tbody>
@foreach($prestamos as $i => $prestamo)
<tr>
<td>{{ $i + 1 }}</td>
<td>{{ $prestamo->nombre_solicitante }}</td>
<td>{{ $prestamo->vehiculo->nombre ?? '-' }}</td>
<td>{{ $prestamo->destino }}</td>
<td>{{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('d/m/Y H:i') }}</td>
<td>{{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('d/m/Y H:i') }}</td>
<td>{{ $prestamo->motivo }}</td>
<td>{{ $prestamo->domicilio }}</td>
<td>{{ $prestamo->numero_personas }}</td>
<td>{{ $prestamo->choferAsignado ? $prestamo->choferAsignado->nombre : 'Sin chofer' }}</td>
<td>{{ ucfirst($prestamo->estado) }}</td>
</tr>
@endforeach
</tbody>
</table>
<table class="firmas">
<tr>
<td>_________________________<br>Elaboró</td>
<td>_________________________<br>Vo. Bo.</td>
</tr>
</table>
</body>
</html>

2
resources/views/prestamos.blade.php

@ -86,8 +86,8 @@
<thead class="bg-gray-50"> <thead class="bg-gray-50">
<tr> <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">Número</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Vehiculo</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nombre Solicitante</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nombre Solicitante</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Vehiculo</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">Destino</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha y Hora Salida</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha y Hora Salida</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha y Hora Llegada</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha y Hora Llegada</th>

3
resources/views/user-dashboard/detalle-prestamo.blade.php

@ -21,5 +21,8 @@
Continuar con el cuestionario Continuar con el cuestionario
</a> </a>
<a href="{{ route('user.prestamos.aceptados') }}" class="btn btn-secondary">Volver a la lista</a> <a href="{{ route('user.prestamos.aceptados') }}" class="btn btn-secondary">Volver a la lista</a>
<a href="{{ route('user.prestamo.pdf', $prestamo->id) }}" class="btn btn-danger" target="_blank">
<i class="fas fa-file-pdf"></i> Descargar PDF
</a>
</div> </div>
@endsection @endsection

1
routes/web.php

@ -98,6 +98,7 @@ use App\Http\Controllers\PuestoController;
Route::get('/user-dashboard/prestamos-aceptados', [App\Http\Controllers\UserDashboardController::class, 'prestamosAceptados'])->name('user.prestamos.aceptados'); Route::get('/user-dashboard/prestamos-aceptados', [App\Http\Controllers\UserDashboardController::class, 'prestamosAceptados'])->name('user.prestamos.aceptados');
Route::get('/user-dashboard/prestamos-aceptados/{id}', [App\Http\Controllers\UserDashboardController::class, 'detallePrestamo'])->name('user.prestamos.detalle'); Route::get('/user-dashboard/prestamos-aceptados/{id}', [App\Http\Controllers\UserDashboardController::class, 'detallePrestamo'])->name('user.prestamos.detalle');
Route::get('/user-dashboard/cuestionario', [App\Http\Controllers\UserDashboardController::class, 'cuestionario'])->name('user.cuestionario'); Route::get('/user-dashboard/cuestionario', [App\Http\Controllers\UserDashboardController::class, 'cuestionario'])->name('user.cuestionario');
Route::get('/user-dashboard/prestamo/{id}/pdf', [App\Http\Controllers\UserDashboardController::class, 'pdfPrestamo'])->name('user.prestamo.pdf');
}); });
// Ruta para el dashboard de usuarios // Ruta para el dashboard de usuarios

Loading…
Cancel
Save