main
inicio
This commit is contained in:
122
views/transportes/importar_masivo.php
Normal file
122
views/transportes/importar_masivo.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
if (!($_SESSION['usuario_id'] ?? false)) {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>📂 Importación Masiva de Transportes</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><br>
|
||||
<h4>📂 Importación Masiva de Transportes</h4>
|
||||
|
||||
<?php if (isset($_SESSION['import_result'])):
|
||||
$res = $_SESSION['import_result'];
|
||||
unset($_SESSION['import_result']);
|
||||
?>
|
||||
<script>
|
||||
Swal.fire({
|
||||
title: 'Importación completada',
|
||||
html:
|
||||
'✅ Registros importados: <?= $res['imported'] ?>.<br>' +
|
||||
'<?php foreach ($res['errors'] as $err) {
|
||||
echo htmlspecialchars($err) . '<br>';
|
||||
} ?>',
|
||||
icon: 'info',
|
||||
width: 600
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card p-4 shadow-sm">
|
||||
<form action="/IMPORTADORES/transportes/importarGuardar" method="POST" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Archivo CSV *</label>
|
||||
<input type="file" name="csv" accept=".csv" class="form-control" required>
|
||||
</div>
|
||||
<p>Descarga la plantilla y llena las columnas: <code>vehiculo, identificador_fiscal, id_transportista</code>.</p>
|
||||
<a href="/IMPORTADORES/public/downloads/transportes_masivo_template.csv" class="btn btn-outline-secondary mb-3">
|
||||
📥 Descargar plantilla
|
||||
</a><br>
|
||||
<button type="submit" class="btn btn-primary">Importar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const Toast = Swal.mixin({
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 3000,
|
||||
timerProgressBar: true
|
||||
});
|
||||
|
||||
// Éxito: cuantos se importaron
|
||||
if (<?= $imported ?> > 0) {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: `✅ Importados: <?= $imported ?>`
|
||||
});
|
||||
}
|
||||
|
||||
// Errores: uno por toast
|
||||
JSON.parse('<?= addslashes($errors) ?>').forEach(err => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: err
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user