Browse Source

PDF de comision

main
TheSilva7 4 weeks ago
parent
commit
09b33d53e5
  1. 18
      app/Http/Controllers/PrestamoController.php
  2. 6
      resources/views/prestamos.blade.php
  3. 191
      resources/views/reports/oficio_comision.blade.php
  4. 14
      routes/web.php

18
app/Http/Controllers/PrestamoController.php

@ -106,8 +106,11 @@ class PrestamoController extends Controller
$prestamo->estado = 'pendiente'; $prestamo->estado = 'pendiente';
$prestamo->save(); $prestamo->save();
return redirect()->route('prestamos.index') // Generar el PDF del oficio de comisión
->with('success', 'Préstamo solicitado correctamente. Esperando aprobación.'); $pdf = PDF::loadView('reports.oficio_comision', compact('prestamo'));
// Descargar el PDF
return $pdf->download('oficio_comision_' . $prestamo->id . '.pdf');
} }
/** /**
@ -288,4 +291,15 @@ class PrestamoController extends Controller
return view('prestamos.rechazados', compact('prestamos')); return view('prestamos.rechazados', compact('prestamos'));
} }
public function descargarOficioComision($id)
{
$prestamo = Prestamo::with('vehiculo')->findOrFail($id); // Cargar el préstamo con la relación del vehículo
// Generar el PDF del oficio de comisión
$pdf = PDF::loadView('reports.oficio_comision', compact('prestamo'));
// Descargar el PDF
return $pdf->download('oficio_comision_' . $prestamo->id . '.pdf');
}
} }

6
resources/views/prestamos.blade.php

@ -86,6 +86,7 @@
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Número de Personas</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Número de 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">Chofer</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Estado</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Estado</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Reporte</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th>
</tr> </tr>
</thead> </thead>
@ -156,6 +157,11 @@
<i class="fas fa-check-circle mr-1"></i> Activo <i class="fas fa-check-circle mr-1"></i> Activo
</span> </span>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<a href="{{ route('prestamos.oficio-comision', $prestamo->id) }}" class="text-blue-600 hover:text-blue-900" title="Descargar Oficio de Comisión">
<i class="fas fa-file-pdf"></i>
</a>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium"> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<div class="flex space-x-2"> <div class="flex space-x-2">
<a href="{{ route('prestamos.edit', $prestamo->id) }}" class="text-blue-600 hover:text-blue-900"> <a href="{{ route('prestamos.edit', $prestamo->id) }}" class="text-blue-600 hover:text-blue-900">

191
resources/views/reports/oficio_comision.blade.php

@ -0,0 +1,191 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Oficio de Comisión</title>
<style>
body {
font-family: Arial, sans-serif;
font-size: 12pt;
}
.container {
width: 100%;
margin: 0 auto;
}
.header,
.footer {
width: 100%;
position: fixed;
left: 0;
right: 0;
}
.header {
top: 0;
}
.footer {
bottom: 0;
}
.content {
margin-top: 150px; /* Adjust based on header height */
margin-bottom: 50px; /* Adjust based on footer height */
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 15px;
}
th,
td {
padding: 5px;
text-align: left;
}
.text-center {
text-align: center;
}
.text-right {
text-align: right;
}
.logo {
float: left;
width: 100px;
}
.jalisco-logo {
float: right;
width: 100px;
}
.divider {
border-top: 1px solid #000;
margin: 20px 0;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<table>
<tr>
<td style="width: 30%;"><img src="{{ public_path('img/tecnm_logo.png') }}" alt="TecNM Logo" class="logo"></td>
<td class="text-center" style="width: 40%;">
<h2>OFICIO DE COMISIÓN</h2>
</td>
<td class="text-right" style="width: 30%;">
<img src="{{ public_path('img/jalisco_logo.png') }}" alt="Jalisco Logo" class="jalisco-logo">
</td>
</tr>
</table>
</div>
<div class="content">
<table>
<tr>
<td style="width: 50%;">
C:
<br> ADSCRITO A:
<br> CON CARGO DE:
</td>
<td style="width: 50%;">
{{ $prestamo->nombre_solicitante }}
<br> DIRECCIÓN UNIDAD ACADEMICA CHAPALA
<br> CHOFER DE DIRECCIÓN
</td>
</tr>
</table>
<p>POR MEDIO DE LA PRESENTE ME PERMITO INFORMAR A USTED, QUE HA SIDO COMISIONADO(A) A LA (S)</p>
<table>
<tr>
<td>POBLACIÓN (ES) DE:</td>
<td>{{ $prestamo->destino }}</td>
</tr>
</table>
<table>
<tr>
<td>EL {{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('d') }} DE {{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('F') }} DE {{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('Y') }} AL {{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('d') }} DE {{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('F') }} DE {{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('Y') }}</td>
</tr>
</table>
<table>
<tr>
<td>CON MOTIVO DE:</td>
</tr>
<tr>
<td>{{ $prestamo->motivo }}</td>
</tr>
</table>
<table>
<tr>
<td style="width: 50%;">HORA DE SALIDA:</td>
<td style="width: 50%;">{{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('H:i a') }}</td>
</tr>
<tr>
<td>REGRESO:</td>
<td>{{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('H:i a') }}</td>
</tr>
</table>
<table>
<tr>
<td>MEDIO DE TRANSPORTE A UTILIZAR</td>
</tr>
</table>
<table>
<tr>
<td>AVION</td>
<td>AUTOBUS</td>
<td>VEHICULO</td>
<td>OFICIAL</td>
</tr>
<tr>
<td>@if($prestamo->medio_transporte == 'avion') X @endif</td>
<td>@if($prestamo->medio_transporte == 'autobus') X @endif</td>
<td>@if($prestamo->medio_transporte == 'vehiculo') X @endif</td>
<td>@if($prestamo->tipo_vehiculo == 'oficial') X @endif</td>
</tr>
</table>
<table>
<tr>
<td>MARCA: {{ $prestamo->vehiculo ? $prestamo->vehiculo->marca : '' }}</td>
<td>TIPO: {{ $prestamo->vehiculo ? $prestamo->vehiculo->tipo : '' }}</td>
<td>MODELO: {{ $prestamo->vehiculo ? $prestamo->vehiculo->modelo : '' }}</td>
</tr>
<tr>
<td>No. CILINDROS: {{ $prestamo->vehiculo ? $prestamo->vehiculo->cilindros : '' }}</td>
<td>PLACAS: {{ $prestamo->vehiculo ? $prestamo->vehiculo->placas : '' }}</td>
<td></td>
</tr>
</table>
<p>SUJETOS A COMPROBACIÓN DE ACUERDO AL REGLAMENTO VIGENTE DENTRO DE LOS TRES DÍAS HABILES POSTERIORES AL TERMINO DE LA COMISIÓN.</p>
<br>
<br>
<br>
<table style="width: 80%; margin: 0 auto;">
<tr>
<td class="text-center">
ATENTAMENTE
<br>
<br>
___________________________________
<br>
DR. FRANCISCO JAVIER QUEZADA ANDRADE
<br>
DIRECTOR DE TECNOLOGICO SUPERIOR DE JALISCO CHAPALA
</td>
</tr>
</table>
</div>
<div class="footer">
<!-- Add footer content if any -->
</div>
</div>
</body>
</html>

14
routes/web.php

@ -69,15 +69,23 @@ use App\Http\Controllers\PuestoController;
Route::get('/prestamos/export/{format}', [PrestamoController::class, 'export'])->name('prestamos.export'); Route::get('/prestamos/export/{format}', [PrestamoController::class, 'export'])->name('prestamos.export');
}); });
// Rutas de gestión de préstamos (crear, editar, eliminar) para admin y servicios // Rutas de gestión de préstamos (crear, editar, eliminar, descargar oficio) para admin y servicios generales
Route::middleware(['auth', 'can:gestionar-prestamos'])->resource('prestamos', PrestamoController::class); Route::middleware(['auth', 'can:gestionar-prestamos'])->group(function () {
Route::resource('prestamos', PrestamoController::class)->except([
'index', 'show' // Estas rutas se manejan en el grupo de solo lectura de abajo
]);
Route::get('/prestamos/{id}/oficio-comision', [PrestamoController::class, 'descargarOficioComision'])->name('prestamos.oficio-comision'); // Añadida a este grupo
});
// Ruta general de préstamos (solo para ver) // Ruta general de préstamos (solo para ver) - Asegúrate de que index y show estén definidos aquí si es necesario para otros roles
Route::middleware(['auth'])->group(function () { Route::middleware(['auth'])->group(function () {
Route::get('/prestamos', [PrestamoController::class, 'index'])->name('prestamos.index'); Route::get('/prestamos', [PrestamoController::class, 'index'])->name('prestamos.index');
Route::get('/prestamos/{id}', [PrestamoController::class, 'show'])->name('prestamos.show'); Route::get('/prestamos/{id}', [PrestamoController::class, 'show'])->name('prestamos.show');
}); });
// Rutas para la gestión de departamentos (index, create, store, show, edit, update, destroy)
Route::resource('despartamentos', DespartamentoController::class);
Route::get('/docentes/export/{format}', [DocentesController::class, 'export'])->name('docentes.export'); Route::get('/docentes/export/{format}', [DocentesController::class, 'export'])->name('docentes.export');
Route::get('/docentes/{id}/toggle-status', [DocentesController::class, 'toggleStatus'])->name('docentes.toggle-status'); Route::get('/docentes/{id}/toggle-status', [DocentesController::class, 'toggleStatus'])->name('docentes.toggle-status');

Loading…
Cancel
Save