120 lines
3.2 KiB
PHP
120 lines
3.2 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: 60px;
|
|
}
|
|
.sidebar .nav-link {
|
|
color: #ccc;
|
|
padding: 12px 20px;
|
|
}
|
|
.sidebar .nav-link:hover, .sidebar .nav-link.active {
|
|
background-color: #495057;
|
|
color: #fff;
|
|
}
|
|
.content {
|
|
margin-left: 220px;
|
|
padding: 40px 20px;
|
|
}
|
|
.navbar {
|
|
position: fixed;
|
|
top: 0;
|
|
width: 100%;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.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>
|
|
|
|
|
|
|