This commit is contained in:
2025-06-17 07:49:04 -06:00
13 changed files with 102 additions and 127 deletions

2
.env
View File

@@ -1,4 +1,4 @@
DB_HOST=DESKTOP-22T88B6 DB_HOST=localhost
DB_DATABASE=Importaciones_HC DB_DATABASE=Importaciones_HC
DB_USERNAME=sa DB_USERNAME=sa
DB_PASSWORD=Soluciones01 DB_PASSWORD=Soluciones01

View File

@@ -23,7 +23,7 @@ function index() {
ISNULL(SUM(ea.tamano_archivo), 0) AS total_tamano ISNULL(SUM(ea.tamano_archivo), 0) AS total_tamano
FROM solicitud_importacion_factura sif FROM solicitud_importacion_factura sif
LEFT JOIN expediente_archivos ea ON ea.id_solicitud = sif.id_solicitud LEFT JOIN expediente_archivos ea ON ea.id_solicitud = sif.id_solicitud
WHERE sif.numero_pedimento IS NOT NULL AND sif.id_importador = ? WHERE sif.numero_pedimento IS NOT NULL AND sif.id_importador = ? and sif.status > 0
GROUP BY sif.id_solicitud, sif.numero_pedimento, sif.fecha_factura, sif.aduana, sif.proveedor_clave GROUP BY sif.id_solicitud, sif.numero_pedimento, sif.fecha_factura, sif.aduana, sif.proveedor_clave
ORDER BY sif.fecha_factura DESC ORDER BY sif.fecha_factura DESC
"; ";

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,10 @@
clave_identificador,nombre,rfc,curp,telefono,caat,pais_id,estado_id,ciudad_id,domicilio
1020,"SERVICIOS Y SOLUCIONES,TRANSPORTE LOGISTIC",SYP141574IS5,,6566198524,2CTU,1,25,46,ENCINO 1708-9
1021,GAMALIEL PALACIOS,OPQ145210IS6,,6566198525,3KSS,1,15,43,BOTTEGHELLE # 2611 CANTO DE CALABRIA C.P. 38524
1022,JOREGEL TRANSPORTES SALCIDO,RHG153021IS7,,4196198526,1134,1,10,62,MADAGASCAR 77844 COL. OASIS
1023,TRANSPORTES FENIX FELIX,KLM257412IS8,,6566198527,6732,1,77,11,SAN CARLOS 87-13 PASEO DE SANTA MONICA 32742
1024,TRANSPORTES MARCELA REYES,HJN4251854IS9,,6566198528,2YRI,1,79,25,"C. WATERFILL No. 520, COL. RIO BRAVO., C.P. 32553"
1025,TRANSPORTES DE CARGA MASIVA,ERV147774IS10,,9586198529,2NJR,1,94,10,"REGION LOMBARDIA No. 1966, INT. 2. JARDINES DE SAN FELIPE, C.P. 32875"
1026,TRANSPORTES SUPER RAPIDO,LMK145574IS11,,7856198530,3101,1,108,4,VENUSTIANO CARRANZA 462 COL. NAMIQUIPA C.P. 32577
1027,OXXO MEX,AQG141587IS12,,6566198531,1747,1,135,28,"CARRETERA MONTERREY MONCLOVA KM. 8.3 S/N, CENTRO GENERAL ARTEMIO, C.P. 66077"
1028,GASPRO,KMV171594IS13,,6566198532,4305,1,39,8,ECONOMIA 206 COLONIA OLGA MARIA CP 34889
1 clave_identificador nombre rfc curp telefono caat pais_id estado_id ciudad_id domicilio
2 1020 SERVICIOS Y SOLUCIONES,TRANSPORTE LOGISTIC SYP141574IS5 6566198524 2CTU 1 25 46 ENCINO 1708-9
3 1021 GAMALIEL PALACIOS OPQ145210IS6 6566198525 3KSS 1 15 43 BOTTEGHELLE # 2611 CANTO DE CALABRIA C.P. 38524
4 1022 JOREGEL TRANSPORTES SALCIDO RHG153021IS7 4196198526 1134 1 10 62 MADAGASCAR 77844 COL. OASIS
5 1023 TRANSPORTES FENIX FELIX KLM257412IS8 6566198527 6732 1 77 11 SAN CARLOS 87-13 PASEO DE SANTA MONICA 32742
6 1024 TRANSPORTES MARCELA REYES HJN4251854IS9 6566198528 2YRI 1 79 25 C. WATERFILL No. 520, COL. RIO BRAVO., C.P. 32553
7 1025 TRANSPORTES DE CARGA MASIVA ERV147774IS10 9586198529 2NJR 1 94 10 REGION LOMBARDIA No. 1966, INT. 2. JARDINES DE SAN FELIPE, C.P. 32875
8 1026 TRANSPORTES SUPER RAPIDO LMK145574IS11 7856198530 3101 1 108 4 VENUSTIANO CARRANZA 462 COL. NAMIQUIPA C.P. 32577
9 1027 OXXO MEX AQG141587IS12 6566198531 1747 1 135 28 CARRETERA MONTERREY MONCLOVA KM. 8.3 S/N, CENTRO GENERAL ARTEMIO, C.P. 66077
10 1028 GASPRO KMV171594IS13 6566198532 4305 1 39 8 ECONOMIA 206 COLONIA OLGA MARIA CP 34889

View File

@@ -11,16 +11,14 @@
<!-- SweetAlert2 --> <!-- SweetAlert2 -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style> <style>
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9;} 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; z-index: 1040; } .sidebar { width: 220px; height: 100vh; background-color: #343a40; position: fixed; top: 0; left: 0; padding-top: 56px; z-index: 1040; }
.sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; } .sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; }
.sidebar .nav-link:hover, .sidebar .nav-link:hover,
.sidebar .nav-link.active { background-color: #495057; color: #fff; } .sidebar .nav-link.active { background-color: #495057; color: #fff; }
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; } .content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; } .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; } }
@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; } } @media (max-width: 767.98px) { .content { margin-left: 0; } }
.card { border-radius: 12px; } .card { border-radius: 12px; }
</style> </style>
@@ -30,6 +28,19 @@
<div class="content"> <div class="content">
<h4 class="mb-4">🚛 Alta de Transportista</h4> <h4 class="mb-4">🚛 Alta de Transportista</h4>
<form action="/IMPORTADORES/transportistas/guardar" method="POST" class="card p-4 shadow-sm" id="formAltaTransportista"> <form action="/IMPORTADORES/transportistas/guardar" method="POST" class="card p-4 shadow-sm" id="formAltaTransportista">
<!-- Hidden para persona moral -->
<input type="hidden" name="es_persona_moral" id="es_persona_moral" value="0">
<!-- Switch Persona Moral -->
<div class="row mb-3">
<div class="col-md-4 d-flex align-items-end">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="personaMoralSwitch">
<label class="form-check-label" for="personaMoralSwitch">Es Persona Moral</label>
</div>
</div>
</div>
<div class="row g-3"> <div class="row g-3">
<div class="col-md-4"> <div class="col-md-4">
<label for="clave" class="form-label">Clave *</label> <label for="clave" class="form-label">Clave *</label>
@@ -37,7 +48,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label for="nombre" class="form-label">Nombre *</label> <label for="nombre" class="form-label" id="labelNombre">Nombre *</label>
<input name="nombre" id="nombre" class="form-control" required> <input name="nombre" id="nombre" class="form-control" required>
</div> </div>
@@ -66,9 +77,7 @@
<select id="pais" name="pais" class="form-select" required> <select id="pais" name="pais" class="form-select" required>
<option value="">Selecciona país</option> <option value="">Selecciona país</option>
<?php foreach($paises as $p): ?> <?php foreach($paises as $p): ?>
<option value="<?= $p['id_pais'] ?>"> <option value="<?= $p['id_pais'] ?>"><?= htmlspecialchars($p['nombre']) ?></option>
<?= htmlspecialchars($p['nombre']) ?>
</option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
@@ -102,192 +111,148 @@
<script> <script>
document.getElementById('formAltaTransportista').addEventListener('submit', function(e) { document.getElementById('formAltaTransportista').addEventListener('submit', function(e) {
e.preventDefault(); // Prevenir envío por defecto e.preventDefault();
const rfcInput = document.getElementById('rfc'); const rfcInput = document.getElementById('rfc');
const curpInput = document.getElementById('curp'); const curpInput = document.getElementById('curp');
const telefonoInput = document.getElementById('telefono'); const telefonoInput = document.getElementById('telefono');
const rfc = rfcInput.value.trim().toUpperCase(); const rfc = rfcInput.value.trim().toUpperCase();
const curp = curpInput.value.trim(); const curp = curpInput.value.trim();
const telefono = telefonoInput.value.trim(); const telefono = telefonoInput.value.trim();
const clave = document.getElementById('clave').value.trim(); const clave = document.getElementById('clave').value.trim();
const nombre = document.getElementById('nombre').value.trim(); const nombre = document.getElementById('nombre').value.trim();
const caat = document.getElementById('caat').value.trim(); const caat = document.getElementById('caat').value.trim();
const pais = document.getElementById('pais').value; const pais = document.getElementById('pais').value;
const entidad = document.getElementById('entidad').value; const entidad= document.getElementById('entidad').value;
const ciudad = document.getElementById('ciudad').value; const ciudad = document.getElementById('ciudad').value;
const domicilio = document.getElementById('domicilio').value.trim(); const domicilio = document.getElementById('domicilio').value.trim();
// Expresiones regulares const curpRegex = /^[A-Z]{4}[0-9]{6}[HM](AS|BC|BS|CC|CL|CM|CS|CH|DF|DG|GT|GR|HG|JC|MC|MN|MS|NT|NL|OC|PL|QT|QR|SP|SL|SR|TC|TS|TL|VZ|YN|ZS)[A-Z]{3}[A-Z0-9]{2}$/;
const curpRegex = /^[A-Z]{4}[0-9]{6}[HM](AS|BC|BS|CC|CL|CM|CS|CH|DF|DG|GT|GR|HG|JC|MC|MN|MS|NT|NL|OC|PL|QT|QR|SP|SL|SR|TC|TS|TL|VZ|YN|ZS)[A-Z]{3}[A-Z0-9]{2}$/; const rfcRegex = /^[A-ZÑ&]{3,4}\d{6}[A-Z0-9]{3}$/;
const rfcRegex = /^[A-ZÑ&]{3,4}\d{6}[A-Z0-9]{3}$/; const telefonoRegex= /^\d{3}\s\d{7}$/;
const telefonoRegex = /^\d{3}\s\d{7}$/;
// Validaciones de campos obligatorios
if (!clave) { if (!clave) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'La clave es obligatoria.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'La clave es obligatoria.',confirmButtonColor:'#dc3545'});
document.getElementById('clave').focus(); document.getElementById('clave').focus();return;
return;
} }
if (clave.length > 8) { if (clave.length>8) {
Swal.fire({ icon: 'error', title: 'Clave inválida', text: 'La clave no puede tener más de 8 caracteres.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Clave inválida',text:'La clave no puede tener más de 8 caracteres.',confirmButtonColor:'#dc3545'});
document.getElementById('clave').focus(); document.getElementById('clave').focus();return;
return;
} }
if (!nombre) { if (!nombre) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'El nombre es obligatorio.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'El nombre es obligatorio.',confirmButtonColor:'#dc3545'});
document.getElementById('nombre').focus(); document.getElementById('nombre').focus();return;
return;
} }
if (!rfc) { if (!rfc) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'El RFC es obligatorio.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'El RFC es obligatorio.',confirmButtonColor:'#dc3545'});
document.getElementById('rfc').focus(); document.getElementById('rfc').focus();return;
return;
} }
if (!rfcRegex.test(rfc)) { if (!rfcRegex.test(rfc)) {
Swal.fire({ icon: 'error', title: 'RFC inválido', text: 'El RFC debe tener 12 o 13 caracteres con el formato correcto (ej. ABC123456XYZ).', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'RFC inválido',text:'El RFC debe tener 12 o 13 caracteres con el formato correcto (ej. ABC123456XYZ).',confirmButtonColor:'#dc3545'});
document.getElementById('rfc').focus(); document.getElementById('rfc').focus();return;
return;
} }
// Validación de CURP (solo si se ingresó)
if (curp && !curpRegex.test(curp)) { if (curp && !curpRegex.test(curp)) {
Swal.fire({ icon: 'error', title: 'CURP inválido', text: 'El CURP no tiene el formato correcto.', confirmButtonColor: '#dc3545' Swal.fire({ icon:'error',title:'CURP inválido',text:'El CURP no tiene el formato correcto.',confirmButtonColor:'#dc3545'});
}); document.getElementById('curp').focus();return;
document.getElementById('curp').focus();
return;
} }
if (!telefono) { if (!telefono) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'El teléfono es obligatorio.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'El teléfono es obligatorio.',confirmButtonColor:'#dc3545'});
document.getElementById('telefono').focus(); document.getElementById('telefono').focus();return;
return;
} }
if (!telefonoRegex.test(telefono)) { if (!telefonoRegex.test(telefono)) {
Swal.fire({ icon: 'error', title: 'Teléfono inválido', text: 'Debe tener 10 dígitos en el formato: 3 dígitos (LADA), espacio, y 7 dígitos. Ejemplo: 123 4567890', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Teléfono inválido',text:'Debe tener 10 dígitos en el formato: 3 dígitos (LADA), espacio, y 7 dígitos. Ejemplo: 123 4567890',confirmButtonColor:'#dc3545'});
document.getElementById('telefono').focus(); document.getElementById('telefono').focus();return;
return;
} }
if (telefono.length > 11) { if (telefono.length>11) {
Swal.fire({ icon: 'error', title: 'Teléfono inválido', text: 'El teléfono no puede tener más de 11 caracteres.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Teléfono inválido',text:'El teléfono no puede tener más de 11 caracteres.',confirmButtonColor:'#dc3545'});
document.getElementById('telefono').focus(); document.getElementById('telefono').focus();return;
return;
} }
if (!caat) { if (!caat) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'El código caat es obligatorio.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'El código caat es obligatorio.',confirmButtonColor:'#dc3545'});
document.getElementById('caat').focus(); document.getElementById('caat').focus();return;
return;
} }
if (!pais) { if (!pais) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'Debe seleccionar un país.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'Debe seleccionar un país.',confirmButtonColor:'#dc3545'});
document.getElementById('pais').focus(); document.getElementById('pais').focus();return;
return;
} }
if (!entidad) { if (!entidad) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'Debe seleccionar un estado.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'Debe seleccionar un estado.',confirmButtonColor:'#dc3545'});
document.getElementById('entidad').focus(); document.getElementById('entidad').focus();return;
return;
} }
if (!ciudad) { if (!ciudad) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'Debe seleccionar una ciudad.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'Debe seleccionar una ciudad.',confirmButtonColor:'#dc3545'});
document.getElementById('ciudad').focus(); document.getElementById('ciudad').focus();return;
return;
} }
if (!domicilio) { if (!domicilio) {
Swal.fire({ icon: 'error', title: 'Campo requerido', text: 'El domicilio es obligatorio.', confirmButtonColor: '#dc3545' }); Swal.fire({ icon:'error',title:'Campo requerido',text:'El domicilio es obligatorio.',confirmButtonColor:'#dc3545'});
document.getElementById('domicilio').focus(); document.getElementById('domicilio').focus();return;
return;
} }
// Si llegamos aquí, todas las validaciones pasaron
// Actualizar los valores en los campos antes de enviar
document.getElementById('rfc').value = rfc; document.getElementById('rfc').value = rfc;
document.getElementById('curp').value = curp; document.getElementById('curp').value = curp;
// Enviar el formulario
this.submit(); this.submit();
}); });
// Funcionalidad de selects en cascada
// 1) Cuando elige país → cargo estados
document.getElementById('pais').addEventListener('change', e => { document.getElementById('pais').addEventListener('change', e => {
const pid = e.target.value; const pid = e.target.value;
const estadoSelect = document.getElementById('entidad'); const estadoSelect = document.getElementById('entidad');
const ciudadSelect = document.getElementById('ciudad'); const ciudadSelect = document.getElementById('ciudad');
// Resetear selects dependientes
estadoSelect.innerHTML = '<option value="">Cargando…</option>'; estadoSelect.innerHTML = '<option value="">Cargando…</option>';
estadoSelect.disabled = true; estadoSelect.disabled = true;
ciudadSelect.innerHTML = '<option value="">Primero estado…</option>'; ciudadSelect.innerHTML = '<option value="">Primero estado…</option>';
ciudadSelect.disabled = true; ciudadSelect.disabled = true;
if (!pid) { estadoSelect.innerHTML = '<option value="">Primero país…</option>'; return; }
if (!pid) {
estadoSelect.innerHTML = '<option value="">Primero país…</option>';
return;
}
// Simulación de carga de estados (reemplaza con tu endpoint real)
fetch(`/IMPORTADORES/transportistas/estados?pais=${pid}`) fetch(`/IMPORTADORES/transportistas/estados?pais=${pid}`)
.then(r => { .then(r => { if (!r.ok) throw new Error('Error al cargar estados'); return r.json(); })
if (!r.ok) throw new Error('Error al cargar estados');
return r.json();
})
.then(list => { .then(list => {
estadoSelect.innerHTML = '<option value="">Selecciona estado</option>'; estadoSelect.innerHTML = '<option value="">Selecciona estado</option>';
list.forEach(st => { list.forEach(st => estadoSelect.add(new Option(st.nombre, st.id_estado)));
const option = new Option(st.nombre, st.id_estado);
estadoSelect.add(option);
});
estadoSelect.disabled = false; estadoSelect.disabled = false;
}) })
.catch(error => { .catch(() => {
console.error('Error:', error);
estadoSelect.innerHTML = '<option value="">Error al cargar</option>'; estadoSelect.innerHTML = '<option value="">Error al cargar</option>';
Swal.fire({ Swal.fire({ icon:'error',title:'Error',text:'No se pudieron cargar los estados',confirmButtonColor:'#dc3545'});
icon: 'error',
title: 'Error',
text: 'No se pudieron cargar los estados',
confirmButtonColor: '#dc3545'
});
}); });
}); });
// 2) Cuando elige estado → cargo ciudades
document.getElementById('entidad').addEventListener('change', e => { document.getElementById('entidad').addEventListener('change', e => {
const eid = e.target.value; const eid = e.target.value;
const ciudadSelect = document.getElementById('ciudad'); const ciudadSelect = document.getElementById('ciudad');
ciudadSelect.innerHTML = '<option value="">Cargando…</option>'; ciudadSelect.innerHTML = '<option value="">Cargando…</option>';
ciudadSelect.disabled = true; ciudadSelect.disabled = true;
if (!eid) { ciudadSelect.innerHTML = '<option value="">Primero estado…</option>'; return; }
if (!eid) {
ciudadSelect.innerHTML = '<option value="">Primero estado…</option>';
return;
}
// Simulación de carga de ciudades (reemplaza con tu endpoint real)
fetch(`/IMPORTADORES/transportistas/ciudades?estado=${eid}`) fetch(`/IMPORTADORES/transportistas/ciudades?estado=${eid}`)
.then(r => { .then(r => { if (!r.ok) throw new Error('Error al cargar ciudades'); return r.json(); })
if (!r.ok) throw new Error('Error al cargar ciudades');
return r.json();
})
.then(list => { .then(list => {
ciudadSelect.innerHTML = '<option value="">Selecciona ciudad</option>'; ciudadSelect.innerHTML = '<option value="">Selecciona ciudad</option>';
list.forEach(ct => { list.forEach(ct => ciudadSelect.add(new Option(ct.nombre, ct.id_ciudad)));
const option = new Option(ct.nombre, ct.id_ciudad);
ciudadSelect.add(option);
});
ciudadSelect.disabled = false; ciudadSelect.disabled = false;
}) })
.catch(error => { .catch(() => {
console.error('Error:', error);
ciudadSelect.innerHTML = '<option value="">Error al cargar</option>'; ciudadSelect.innerHTML = '<option value="">Error al cargar</option>';
Swal.fire({ Swal.fire({ icon:'error',title:'Error',text:'No se pudieron cargar las ciudades',confirmButtonColor:'#dc3545'});
icon: 'error',
title: 'Error',
text: 'No se pudieron cargar las ciudades',
confirmButtonColor: '#dc3545'
});
}); });
}); });
// Switch Persona Moral
document.getElementById('personaMoralSwitch').addEventListener('change', function() {
const checked = this.checked;
const label = document.getElementById('labelNombre');
const curp = document.getElementById('curp');
const hidden = document.getElementById('es_persona_moral');
if (checked) {
label.textContent = 'Razón Social *';
curp.value = '';
curp.disabled = true;
curp.removeAttribute('required');
hidden.value = '1';
} else {
label.textContent = 'Nombre *';
curp.disabled = false;
curp.setAttribute('required', 'required');
hidden.value = '0';
}
});
</script> </script>
</body> </body>