149 lines
4.0 KiB
PHP
149 lines
4.0 KiB
PHP
<?php // views/transportistas/bulk_upload.php ?>
|
|
|
|
<?php
|
|
// Al principio de la vista, inicia sesión para leer los errores
|
|
session_start();
|
|
$errors = $_SESSION['import_errors'] ?? [];
|
|
$success = $_SESSION['import_success'] ?? false;
|
|
// Limpiar para que no se repitan
|
|
unset($_SESSION['import_errors'], $_SESSION['import_success']);
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>🚛 Carga Masiva de Transportistas</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<style>
|
|
body {
|
|
font-family: 'Segoe UI', sans-serif;
|
|
background-color: #f4f6f9;
|
|
}
|
|
.sidebar {
|
|
width: 220px;
|
|
height: 100vh;
|
|
background-color: #343a40;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
padding-top: 56px; /* Alineado con la altura de la navbar */
|
|
z-index: 1040; /* Asegura que esté por encima del contenido */
|
|
}
|
|
.sidebar .nav-link {
|
|
font-weight: bold;
|
|
color: white;
|
|
transition: all 0.3s ease;
|
|
}
|
|
.sidebar .nav-link:hover,
|
|
.sidebar .nav-link.active {
|
|
background-color: #495057;
|
|
color: #fff;
|
|
}
|
|
.content {
|
|
margin-top: 56px; /* Ajusta debajo de navbar */
|
|
padding: 40px 20px;
|
|
position: relative;
|
|
z-index: 1;
|
|
background-color: #f4f6f9; /* Asegura fondo uniforme */
|
|
transition: margin-left 0.3s ease;
|
|
}
|
|
.navbar {
|
|
position: fixed;
|
|
top: 0;
|
|
width: 100%;
|
|
z-index: 1050;
|
|
}
|
|
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
|
@media (min-width: 768px) {
|
|
.content {
|
|
margin-left: 250px; /* Ancho del sidebar */
|
|
}
|
|
}
|
|
|
|
/* En móviles, sin margen lateral */
|
|
@media (max-width: 767.98px) {
|
|
.content {
|
|
margin-left: 0;
|
|
}
|
|
.sidebar .nav-link {
|
|
font-weight: normal;
|
|
color: #343a40;
|
|
background-color: transparent;
|
|
}
|
|
.sidebar .nav-link:hover,
|
|
.sidebar .nav-link.active {
|
|
background-color: #e9ecef;
|
|
color: #212529;
|
|
}
|
|
}
|
|
.card {
|
|
border-radius: 12px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<?php include __DIR__ . '/../partials/sidebar_importador.php'; ?>
|
|
|
|
<div class="content">
|
|
<br>
|
|
|
|
<h4 class="mb-4">🚛 Carga Masiva de Transportistas</h4>
|
|
|
|
<div class="card p-4 shadow-sm">
|
|
<p>1. Descarga la plantilla, complétala con tus datos y luego súbela aquí.</p>
|
|
<a href="/IMPORTADORES/transportistas/template" class="btn btn-outline-secondary mb-4">
|
|
📥 Descargar Plantilla CSV
|
|
</a>
|
|
|
|
<form action="/IMPORTADORES/transportistas/importar" method="POST" enctype="multipart/form-data">
|
|
<div class="mb-3">
|
|
<label for="archivo_csv" class="form-label">Selecciona archivo CSV</label>
|
|
<input type="file" id="archivo_csv" name="archivo_csv" class="form-control" accept=".csv" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">🚀 Cargar Transportistas</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Si la importación fue exitosa
|
|
<?php if ($success): ?>
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: '¡Carga completada!',
|
|
text: 'Todos los transportistas se importaron correctamente.',
|
|
confirmButtonColor: '#198754'
|
|
});
|
|
<?php endif; ?>
|
|
|
|
// Si hubo errores, muéstralos en una lista
|
|
<?php if (!empty($errors)):
|
|
// Construir HTML con la lista de errores
|
|
$html = '<ul style="text-align:left;">';
|
|
foreach ($errors as $e) {
|
|
$html .= '<li>' . htmlspecialchars($e) . '</li>';
|
|
}
|
|
$html .= '</ul>';
|
|
?>
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Errores al importar',
|
|
html: <?= json_encode($html) ?>,
|
|
width: 600,
|
|
confirmButtonColor: '#d33'
|
|
});
|
|
<?php endif; ?>
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|
|
|
|
|