main
inicio
This commit is contained in:
137
views/transportistas/alta.php
Normal file
137
views/transportistas/alta.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dashboard | Alta transportista</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>
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
<?php include __DIR__ . '/../partials/sidebar_importador.php'; ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<body>
|
||||
<br><br><br>
|
||||
|
||||
|
||||
<div class="content">
|
||||
<h4 class="mb-4">🚛 Alta de Transportista</h4>
|
||||
<form action="/IMPORTADORES/transportistas/guardar" method="POST" class="card p-4 shadow-sm">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4"><input name="clave" class="form-control" placeholder="Clave" required></div>
|
||||
<div class="col-md-4"><input name="nombre" class="form-control" placeholder="Nombre completo" required></div>
|
||||
<div class="col-md-4"><input name="rfc" class="form-control" placeholder="RFC" required></div>
|
||||
<div class="col-md-4"><input name="curp" class="form-control" placeholder="CURP"></div>
|
||||
<div class="col-md-4"><input name="telefono" class="form-control" placeholder="Teléfono" required></div>
|
||||
<div class="col-md-4"><input name="caat" class="form-control" placeholder="Código CAAT" required></div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<select id="pais" name="pais" class="form-select" required>
|
||||
<option value="">Selecciona país</option>
|
||||
<?php foreach($paises as $p): ?>
|
||||
<option value="<?= $p['id_pais'] ?>">
|
||||
<?= htmlspecialchars($p['nombre']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<select id="estado" name="entidad" class="form-select" required disabled>
|
||||
<option value="">Primero país…</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<select id="ciudad" name="ciudad" class="form-select" required disabled>
|
||||
<option value="">Primero estado…</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8"><input name="domicilio" class="form-control" placeholder="Domicilio completo" required></div>
|
||||
</div>
|
||||
<div class="text-end mt-4">
|
||||
<button class="btn btn-success px-4">Guardar Transportista</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 1) Cuando elige país → cargo estados
|
||||
document.getElementById('pais').addEventListener('change', e => {
|
||||
const pid = e.target.value;
|
||||
const sel = document.getElementById('estado');
|
||||
sel.innerHTML = '<option>Cargando…</option>';
|
||||
sel.disabled = true;
|
||||
document.getElementById('ciudad').innerHTML = '<option>Primero estado…</option>';
|
||||
document.getElementById('ciudad').disabled = true;
|
||||
|
||||
fetch(`/IMPORTADORES/transportistas/estados?pais=${pid}`)
|
||||
.then(r=>r.json())
|
||||
.then(list=>{
|
||||
sel.innerHTML = '<option value="">Selecciona estado</option>';
|
||||
list.forEach(st => sel.add(new Option(st.nombre, st.id_estado)));
|
||||
sel.disabled = false;
|
||||
});
|
||||
});
|
||||
|
||||
// 2) Cuando elige estado → cargo ciudades
|
||||
document.getElementById('estado').addEventListener('change', e => {
|
||||
const eid = e.target.value;
|
||||
const sel = document.getElementById('ciudad');
|
||||
sel.innerHTML = '<option>Cargando…</option>';
|
||||
sel.disabled = true;
|
||||
|
||||
fetch(`/IMPORTADORES/transportistas/ciudades?estado=${eid}`)
|
||||
.then(r=>r.json())
|
||||
.then(list=>{
|
||||
sel.innerHTML = '<option value="">Selecciona ciudad</option>';
|
||||
list.forEach(ct => sel.add(new Option(ct.nombre, ct.id_ciudad)));
|
||||
sel.disabled = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
119
views/transportistas/bulk_upload.php
Normal file
119
views/transportistas/bulk_upload.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?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>
|
||||
|
||||
|
||||
|
||||
169
views/transportistas/editar.php
Normal file
169
views/transportistas/editar.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
// views/transportistas/editar.php
|
||||
session_start();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>✏️ Editar Transportista</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>
|
||||
<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">
|
||||
<h4 class="mb-4">✏️ Editar Transportista #<?= $t['id_transportista'] ?></h4>
|
||||
<form action="/IMPORTADORES/transportistas/actualizar" method="POST" class="card p-4 shadow-sm">
|
||||
<input type="hidden" name="id_transportista" value="<?= $t['id_transportista'] ?>">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Clave</label>
|
||||
<input name="clave" value="<?= htmlspecialchars($t['clave_identificador']) ?>"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Nombre</label>
|
||||
<input name="nombre" value="<?= htmlspecialchars($t['nombre']) ?>"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">RFC</label>
|
||||
<input name="rfc" value="<?= htmlspecialchars($t['rfc']) ?>"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">CURP</label>
|
||||
<input name="curp" value="<?= htmlspecialchars($t['curp']) ?>"
|
||||
class="form-control">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Teléfono</label>
|
||||
<input name="telefono" value="<?= htmlspecialchars($t['telefono']) ?>"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Código CAAT</label>
|
||||
<input name="caat" value="<?= htmlspecialchars($t['caat']) ?>"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">País</label>
|
||||
<select id="pais" name="pais" class="form-select" required>
|
||||
<option value="">Selecciona país</option>
|
||||
<?php foreach($paises as $p): ?>
|
||||
<option value="<?= $p['id_pais'] ?>"
|
||||
<?= $p['id_pais']==$t['pais']?'selected':'' ?>>
|
||||
<?= htmlspecialchars($p['nombre']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Estado</label>
|
||||
<select id="estado" name="entidad" class="form-select" required>
|
||||
<option value="">Selecciona estado</option>
|
||||
<?php foreach($estados as $e): ?>
|
||||
<option value="<?= $e['id_estado'] ?>"
|
||||
<?= $e['id_estado']==$t['entidad_federativa']?'selected':'' ?>>
|
||||
<?= htmlspecialchars($e['nombre']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Ciudad</label>
|
||||
<select id="ciudad" name="ciudad" class="form-select" required>
|
||||
<option value="">Selecciona ciudad</option>
|
||||
<?php foreach($ciudades as $c): ?>
|
||||
<option value="<?= $c['id_ciudad'] ?>"
|
||||
<?= $c['id_ciudad']==$t['ciudad']?'selected':'' ?>>
|
||||
<?= htmlspecialchars($c['nombre']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<label class="form-label">Domicilio Completo</label>
|
||||
<textarea name="domicilio" class="form-control" rows="3" required><?= htmlspecialchars($t['domicilio']) ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end mt-4">
|
||||
<button class="btn btn-success px-4">💾 Guardar Cambios</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Al cambiar país → recargar estados
|
||||
document.getElementById('pais').addEventListener('change', function(){
|
||||
const pid = this.value, selE = document.getElementById('estado');
|
||||
selE.innerHTML = '<option>Cargando…</option>'; selE.disabled = true;
|
||||
fetch(`/IMPORTADORES/transportistas/estados?pais=${pid}`)
|
||||
.then(r=>r.json())
|
||||
.then(list=>{
|
||||
selE.innerHTML = '<option value="">Selecciona estado</option>';
|
||||
list.forEach(e=> selE.add(new Option(e.nombre,e.id_estado)) );
|
||||
selE.disabled = false;
|
||||
// Dispara cambio para recargar ciudades
|
||||
selE.dispatchEvent(new Event('change'));
|
||||
});
|
||||
});
|
||||
|
||||
// Al cambiar estado → recargar ciudades
|
||||
document.getElementById('estado').addEventListener('change', function(){
|
||||
const eid = this.value, selC = document.getElementById('ciudad');
|
||||
selC.innerHTML = '<option>Cargando…</option>'; selC.disabled = true;
|
||||
fetch(`/IMPORTADORES/transportistas/ciudades?estado=${eid}`)
|
||||
.then(r=>r.json())
|
||||
.then(list=>{
|
||||
selC.innerHTML = '<option value="">Selecciona ciudad</option>';
|
||||
list.forEach(c=> selC.add(new Option(c.nombre,c.id_ciudad)) );
|
||||
selC.disabled = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
161
views/transportistas/lista.php
Normal file
161
views/transportistas/lista.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<!-- views/transportistas/lista.php -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>🚚 Mis 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>
|
||||
<link href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet">
|
||||
<style>
|
||||
table.dataTable thead th { background:#343a40; color:#fff; }
|
||||
|
||||
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">🚚 Mis Transportistas</h4>
|
||||
<div class="card p-3 shadow-sm">
|
||||
<table id="transportistas-table" class="display nowrap" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Clave</th>
|
||||
<th>Nombre</th>
|
||||
<th>RFC</th>
|
||||
<th>Ciudad</th>
|
||||
<th>Fecha Alta</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<!-- DataTables JS -->
|
||||
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
|
||||
<!-- Bootstrap JS -->
|
||||
<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>
|
||||
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
$('#transportistas-table').DataTable({
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
ajax: {
|
||||
url: '/IMPORTADORES/transportistas/ajax_lista',
|
||||
type: 'GET'
|
||||
},
|
||||
columns: [
|
||||
{ data: 0 },
|
||||
{ data: 1 },
|
||||
{ data: 2 },
|
||||
{ data: 3 },
|
||||
{ data: 4 },
|
||||
{ data: 5 },
|
||||
{
|
||||
data: null,
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
render: function(row) {
|
||||
const id = row[0];
|
||||
return `
|
||||
<a href="/IMPORTADORES/transportistas/editar?id=${id}" class="btn btn-sm btn-primary">✏️</a>
|
||||
<button class="btn btn-sm btn-danger" onclick="confirmDelete(${id})">🗑️</button>
|
||||
`;
|
||||
}
|
||||
|
||||
}
|
||||
],
|
||||
language: {
|
||||
url: '//cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function confirmDelete(id) {
|
||||
Swal.fire({
|
||||
title: '¿Eliminar transportista?',
|
||||
text: 'Esto sólo lo desactivará; no se podrá volver a usar.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí, eliminar',
|
||||
cancelButtonText: 'Cancelar',
|
||||
confirmButtonColor: '#d33'
|
||||
}).then(result => {
|
||||
if (result.isConfirmed) {
|
||||
window.location = `/IMPORTADORES/transportistas/eliminar?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Mostrar alert de “borrado” al volver de la acción
|
||||
<?php if (isset($_GET['deleted']) && $_GET['deleted']==='ok'): ?>
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Transportista eliminado',
|
||||
text: 'Ya no aparecerá en tu lista.',
|
||||
confirmButtonColor: '#198754'
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user