476 lines
19 KiB
PHP
476 lines
19 KiB
PHP
<?php
|
|
require_once 'database/database.php';
|
|
|
|
$query = "SELECT DISTINCT empresa, examen, certificacion FROM entrada";
|
|
$result = $conexion->query($query);
|
|
|
|
$opciones = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$empresa = $row['empresa'];
|
|
$examen = $row['examen'];
|
|
$certificacion = $row['certificacion'];
|
|
if (!isset($opciones[$empresa])) $opciones[$empresa] = [];
|
|
if (!isset($opciones[$empresa][$examen])) $opciones[$empresa][$examen] = [];
|
|
if (!in_array($certificacion, $opciones[$empresa][$examen])) {
|
|
$opciones[$empresa][$examen][] = $certificacion;
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Centro de Certificación LANIA</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
|
|
<link href="style/dashboard.css" rel="stylesheet">
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<?php include 'sidebar.php'; ?>
|
|
|
|
<div class="main-content">
|
|
<div class="container py-5">
|
|
<div class="text-center mb-4">
|
|
<h1 class="display-5">Centro de Certificación LANIA</h1>
|
|
<p class="lead">Formulario de registro para candidatos de exámenes PEARSON VUE</p>
|
|
</div>
|
|
|
|
<div class="card shadow p-4">
|
|
<form id="registroForm" action="model/login.php" method="POST">
|
|
<div class="row g-3">
|
|
<div class="col-md-6">
|
|
<label for="nombre" class="form-label">Nombre completo</label>
|
|
<input type="text" class="form-control" id="nombre" name="nombre" required>
|
|
</div>
|
|
|
|
<div class="col-md-6 position-relative">
|
|
<label for="correo" class="form-label">Correo electrónico</label>
|
|
<input type="email" class="form-control" id="correo" name="correo" required autocomplete="off">
|
|
<div id="sugerencias-correo" class="list-group position-absolute w-100" style="z-index: 1000;"></div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="telefono" class="form-label">Teléfono</label>
|
|
<input type="text" class="form-control" id="telefono" name="telefono" required>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label for="genero" class="form-label">Género</label>
|
|
<select class="form-select" id="genero" name="genero" required>
|
|
<option value="">Selecciona una opción</option>
|
|
<option value="Masculino">Masculino</option>
|
|
<option value="Femenino">Femenino</option>
|
|
<option value="Otro">Prefiero no especificar</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="edad" class="form-label">Edad</label>
|
|
<select class="form-select" id="edad" name="edad" required>
|
|
<option value="">Selecciona un rango de edad</option>
|
|
<option value="menor">Menos de 17</option>
|
|
<option value="18-21">18-21</option>
|
|
<option value="22-25">22-25</option>
|
|
<option value="26-30">26-30</option>
|
|
<option value="31-35">31-35</option>
|
|
<option value="36-40">36-40</option>
|
|
<option value="41-45">41-45</option>
|
|
<option value="46-50">46-50</option>
|
|
<option value="51-55">51-55</option>
|
|
<option value="56-60">56-60</option>
|
|
<option value="mayor">Más de 60</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label for="estado_procedencia" class="form-label">Estado de procedencia</label>
|
|
<input type="text" class="form-control" id="estado_procedencia" name="estado_procedencia" placeholder="Ingresa tu estado de procedencia" required>
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<label for="identificacion" class="form-label">Identificación</label>
|
|
<select id="identificacion" name="identificacion" class="form-select" required>
|
|
<option value="">Seleccione una identificación</option>
|
|
<option value="CE">Credencial de Estudiante</option>
|
|
<option value="INE">INE</option>
|
|
<option value="C.M">Cartilla Militar</option>
|
|
<option value="Pasaporte">Pasaporte</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<label for="empresa" class="form-label">Proveedor</label>
|
|
<select id="empresa" name="empresa" class="form-select" required onchange="mostrarInputOtro('empresa'); actualizarExamenes();">
|
|
<option value="">Seleccione un proveedor</option>
|
|
<?php
|
|
$proveedoresPredefinidos = ['Microsoft', 'Oracle', 'Cisco'];
|
|
foreach ($proveedoresPredefinidos as $proveedor) {
|
|
echo "<option value='$proveedor'>$proveedor</option>";
|
|
}
|
|
|
|
foreach ($opciones as $empresa => $examenes) {
|
|
if (!in_array($empresa, $proveedoresPredefinidos)) {
|
|
echo "<option value='$empresa'>$empresa</option>";
|
|
}
|
|
}
|
|
?>
|
|
<option value="otro">Otro</option>
|
|
</select>
|
|
<input type="text" id="empresa_otro" name="empresa_otro" class="form-control mt-2 d-none" placeholder="Especifica otro proveedor">
|
|
</div>
|
|
<!-- Examen -->
|
|
<div class="col-md-4">
|
|
<label for="examen" class="form-label">Examen</label>
|
|
<select id="examen" name="examen" class="form-select" required onchange="mostrarInputOtro('examen'); actualizarCertificaciones();">
|
|
<option value="">Selecciona un examen</option>
|
|
<option value="otro">Otro</option>
|
|
</select>
|
|
<input type="text" id="examen_otro" name="examen_otro" class="form-control mt-2 d-none" placeholder="Especifica otro examen">
|
|
</div>
|
|
|
|
<!-- Certificación -->
|
|
<div class="col-md-4">
|
|
<label for="certificacion" class="form-label">Certificación</label>
|
|
<select id="certificacion" name="certificacion" class="form-select" required onchange="mostrarInputOtro('certificacion')">
|
|
<option value="">Selecciona una certificación</option>
|
|
<option value="otro">Otro</option>
|
|
</select>
|
|
<input type="text" id="certificacion_otro" name="certificacion_otro" class="form-control mt-2 d-none" placeholder="Especifica otra certificación">
|
|
</div>
|
|
|
|
|
|
<input type="hidden" id="hora_local" name="h_entrada">
|
|
|
|
<div class="mt-4 text-end">
|
|
<button type="submit" class="btn btn-primary">Enviar registro</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal de confirmación -->
|
|
<div class="modal fade" id="modalConfirmacion" tabindex="-1" aria-labelledby="modalConfirmacionLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header bg-success text-white">
|
|
<h5 class="modal-title" id="modalConfirmacionLabel">¡Registro exitoso!</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
|
</div>
|
|
<div class="modal-body text-center">
|
|
<p id="mensajeConfirmacion" class="fs-5 fw-bold">Registro exitoso. Bienvenido a LANIA 😊</p>
|
|
</div>
|
|
<div class="modal-footer justify-content-center">
|
|
<button type="button" class="btn btn-success" data-bs-dismiss="modal">Aceptar</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const correoInput = document.getElementById('correo');
|
|
const sugerenciasDiv = document.getElementById('sugerencias-correo');
|
|
const dominios = ['@gmail.com', '@outlook.com', '@hotmail.com', '@lania.edu.mx'];
|
|
|
|
correoInput.addEventListener('input', () => {
|
|
const valor = correoInput.value.trim();
|
|
sugerenciasDiv.innerHTML = '';
|
|
|
|
if (valor && !valor.includes('@')) {
|
|
dominios.forEach(dominio => {
|
|
const sugerencia = document.createElement('div');
|
|
sugerencia.classList.add('list-group-item', 'list-group-item-action');
|
|
sugerencia.textContent = valor + dominio;
|
|
sugerencia.onclick = () => {
|
|
correoInput.value = sugerencia.textContent;
|
|
sugerenciasDiv.innerHTML = '';
|
|
};
|
|
sugerenciasDiv.appendChild(sugerencia);
|
|
});
|
|
}
|
|
});
|
|
|
|
document.addEventListener('click', (e) => {
|
|
if (!sugerenciasDiv.contains(e.target) && e.target !== correoInput) {
|
|
sugerenciasDiv.innerHTML = '';
|
|
}
|
|
});
|
|
|
|
const datos = {
|
|
Microsoft: {
|
|
"AZ-900": ["Fundamentals", "Associate"],
|
|
"AZ-104": ["Associate", "Expert"],
|
|
"MS-900": ["Fundamentals"]
|
|
},
|
|
Oracle: {
|
|
"Oracle Database SQL": ["Associate", "Professional"],
|
|
"Java SE Programmer": ["Associate", "Professional", "Master"]
|
|
},
|
|
Cisco: {
|
|
"CCNA": ["Associate"],
|
|
"CCNP": ["Professional"],
|
|
"CCIE": ["Expert"]
|
|
}
|
|
};
|
|
|
|
const datosBD = <?php echo json_encode($opciones); ?>;
|
|
for (const proveedor in datosBD) {
|
|
if (!datos[proveedor]) datos[proveedor] = {};
|
|
for (const examen in datosBD[proveedor]) {
|
|
if (!datos[proveedor][examen]) datos[proveedor][examen] = [];
|
|
datosBD[proveedor][examen].forEach(cert => {
|
|
if (!datos[proveedor][examen].includes(cert)) {
|
|
datos[proveedor][examen].push(cert);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function mostrarInputOtro(tipo) {
|
|
const select = document.getElementById(tipo);
|
|
const inputOtro = document.getElementById(tipo + '_otro');
|
|
|
|
if (select.value === 'otro') {
|
|
inputOtro.classList.remove('d-none');
|
|
inputOtro.required = true;
|
|
} else {
|
|
inputOtro.classList.add('d-none');
|
|
inputOtro.value = '';
|
|
inputOtro.required = false;
|
|
}
|
|
|
|
// Si cambias proveedor, resetea examen y certificación
|
|
if (tipo === 'empresa') {
|
|
// Oculta y limpia examen_otro y certificacion_otro
|
|
document.getElementById('examen_otro').classList.add('d-none');
|
|
document.getElementById('examen_otro').value = '';
|
|
document.getElementById('examen_otro').required = false;
|
|
|
|
document.getElementById('certificacion_otro').classList.add('d-none');
|
|
document.getElementById('certificacion_otro').value = '';
|
|
document.getElementById('certificacion_otro').required = false;
|
|
}
|
|
// Si cambias examen, resetea certificación
|
|
if (tipo === 'examen') {
|
|
document.getElementById('certificacion_otro').classList.add('d-none');
|
|
document.getElementById('certificacion_otro').value = '';
|
|
document.getElementById('certificacion_otro').required = false;
|
|
}
|
|
}
|
|
|
|
function actualizarExamenes() {
|
|
const empresa = document.getElementById("empresa").value;
|
|
const examenSelect = document.getElementById("examen");
|
|
const certificacionSelect = document.getElementById("certificacion");
|
|
|
|
examenSelect.innerHTML = '<option value="">Selecciona un examen</option>';
|
|
|
|
if (empresa && datos[empresa]) {
|
|
for (let examen in datos[empresa]) {
|
|
const option = document.createElement("option");
|
|
option.value = examen;
|
|
option.textContent = examen;
|
|
examenSelect.appendChild(option);
|
|
}
|
|
}
|
|
if (!Array.from(examenSelect.options).some(opt => opt.value === "otro")) {
|
|
const optionOtro = document.createElement("option");
|
|
optionOtro.value = "otro";
|
|
optionOtro.textContent = "Otro";
|
|
examenSelect.appendChild(optionOtro);
|
|
}
|
|
|
|
|
|
// Reinicia certificaciones
|
|
certificacionSelect.innerHTML = '<option value="">Selecciona una certificación</option>';
|
|
if (!Array.from(certificacionSelect.options).some(opt => opt.value === "otro")) {
|
|
const optionCertOtro = document.createElement("option");
|
|
optionCertOtro.value = "otro";
|
|
optionCertOtro.textContent = "Otro";
|
|
certificacionSelect.appendChild(optionCertOtro);
|
|
}
|
|
}
|
|
|
|
function actualizarCertificaciones() {
|
|
const empresa = document.getElementById("empresa").value;
|
|
const examen = document.getElementById("examen").value;
|
|
const certificacionSelect = document.getElementById("certificacion");
|
|
|
|
certificacionSelect.innerHTML = '<option value="">Selecciona una certificación</option>';
|
|
|
|
if (empresa && examen && datos[empresa] && datos[empresa][examen]) {
|
|
datos[empresa][examen].forEach(cert => {
|
|
const option = document.createElement("option");
|
|
option.value = cert;
|
|
option.textContent = cert;
|
|
certificacionSelect.appendChild(option);
|
|
});
|
|
}
|
|
// Solo agrega la opción "Otro" si no existe ya
|
|
if (![...certificacionSelect.options].some(opt => opt.value === "otro")) {
|
|
const optionOtro = document.createElement("option");
|
|
optionOtro.value = "otro";
|
|
optionOtro.textContent = "Otro";
|
|
certificacionSelect.appendChild(optionOtro);
|
|
}
|
|
}
|
|
|
|
document.getElementById("registroForm").addEventListener("submit", function(e) {
|
|
const ahora = new Date();
|
|
const hora = ahora.toTimeString().slice(0,8); // "HH:MM:SS"
|
|
document.getElementById("hora_local").value = hora;
|
|
|
|
e.preventDefault(); // Evitar el envío predeterminado del formulario
|
|
|
|
const form = e.target;
|
|
const formData = new FormData(form);
|
|
|
|
const empresaSelect = document.getElementById('empresa');
|
|
const empresaOtro = document.getElementById('empresa_otro');
|
|
if (empresaSelect.value === 'otro' && empresaOtro.value.trim() !== '') {
|
|
formData.set('empresa', empresaOtro.value.trim());
|
|
}
|
|
|
|
const examenSelect = document.getElementById('examen');
|
|
const examenOtro = document.getElementById('examen_otro');
|
|
if (examenSelect.value === 'otro' && examenOtro.value.trim() !== '') {
|
|
formData.set('examen', examenOtro.value.trim());
|
|
}
|
|
|
|
const certSelect = document.getElementById('certificacion');
|
|
const certOtro = document.getElementById('certificacion_otro');
|
|
if (certSelect.value === 'otro' && certOtro.value.trim() !== '') {
|
|
formData.set('certificacion', certOtro.value.trim());
|
|
}
|
|
|
|
if (empresaSelect.value === empresaOtro.value.trim()) {
|
|
if (!datos[empresaOtro.value.trim()]) {
|
|
datos[empresaOtro.value.trim()] = {};
|
|
}
|
|
}
|
|
if (examenSelect.value === examenOtro.value.trim()) {
|
|
if (!datos[empresaSelect.value]) datos[empresaSelect.value] = {};
|
|
if (!datos[empresaSelect.value][examenOtro.value.trim()]) {
|
|
datos[empresaSelect.value][examenOtro.value.trim()] = [];
|
|
}
|
|
}
|
|
if (certSelect.value === certOtro.value.trim()) {
|
|
if (!datos[empresaSelect.value]) datos[empresaSelect.value] = {};
|
|
if (!datos[empresaSelect.value][examenSelect.value]) datos[empresaSelect.value][examenSelect.value] = [];
|
|
if (!datos[empresaSelect.value][examenSelect.value].includes(certOtro.value.trim())) {
|
|
datos[empresaSelect.value][examenSelect.value].push(certOtro.value.trim());
|
|
}
|
|
}
|
|
|
|
if (empresaSelect.value === 'otro' && empresaOtro.value.trim() !== '') {
|
|
const nuevoProveedor = empresaOtro.value.trim();
|
|
if (!datos[nuevoProveedor]) {
|
|
datos[nuevoProveedor] = {};
|
|
const option = document.createElement("option");
|
|
option.value = nuevoProveedor;
|
|
option.textContent = nuevoProveedor;
|
|
empresaSelect.insertBefore(option, empresaSelect.querySelector('option[value="otro"]'));
|
|
}
|
|
localStorage.setItem('datosLania', JSON.stringify(datos));
|
|
}
|
|
|
|
if (examenSelect.value === 'otro' && examenOtro.value.trim() !== '') {
|
|
const proveedor = empresaSelect.value === 'otro' ? empresaOtro.value.trim() : empresaSelect.value;
|
|
const nuevoExamen = examenOtro.value.trim();
|
|
if (!datos[proveedor]) datos[proveedor] = {};
|
|
if (!datos[proveedor][nuevoExamen]) {
|
|
datos[proveedor][nuevoExamen] = [];
|
|
// Agregar la opción al select de examen
|
|
const option = document.createElement("option");
|
|
option.value = nuevoExamen;
|
|
option.textContent = nuevoExamen;
|
|
examenSelect.insertBefore(option, examenSelect.querySelector('option[value="otro"]'));
|
|
}
|
|
}
|
|
|
|
if (certSelect.value === 'otro' && certOtro.value.trim() !== '') {
|
|
const proveedor = empresaSelect.value === 'otro' ? empresaOtro.value.trim() : empresaSelect.value;
|
|
const examen = examenSelect.value === 'otro' ? examenOtro.value.trim() : examenSelect.value;
|
|
const nuevaCert = certOtro.value.trim();
|
|
if (!datos[proveedor]) datos[proveedor] = {};
|
|
if (!datos[proveedor][examen]) datos[proveedor][examen] = [];
|
|
if (!datos[proveedor][examen].includes(nuevaCert)) {
|
|
datos[proveedor][examen].push(nuevaCert);
|
|
// Agregar la opción al select de certificación
|
|
const option = document.createElement("option");
|
|
option.value = nuevaCert;
|
|
option.textContent = nuevaCert;
|
|
certSelect.insertBefore(option, certSelect.querySelector('option[value="otro"]'));
|
|
}
|
|
}
|
|
|
|
fetch("model/login.php", {
|
|
method: "POST",
|
|
body: formData
|
|
})
|
|
.then(data => {
|
|
// Mostrar el modal de confirmación
|
|
const modalConfirmacion = new bootstrap.Modal(document.getElementById('modalConfirmacion'));
|
|
modalConfirmacion.show();
|
|
form.reset(); // Reiniciar el formulario
|
|
|
|
const examenSelect = document.getElementById("examen");
|
|
const certificacionSelect = document.getElementById("certificacion");
|
|
|
|
examenSelect.innerHTML = '<option value="">Selecciona un examen</option><option value="otro">Otro</option>';
|
|
|
|
certificacionSelect.innerHTML = '<option value="">Selecciona una certificación</option><option value="otro">Otro</option>';
|
|
|
|
['empresa', 'examen', 'certificacion'].forEach(function(campo) {
|
|
const inputOtro = document.getElementById(campo + '_otro');
|
|
if (inputOtro) {
|
|
inputOtro.classList.add('d-none');
|
|
inputOtro.value = '';
|
|
inputOtro.removeAttribute('required');
|
|
}
|
|
});
|
|
})
|
|
.catch(error => {
|
|
console.error("Error al enviar:", error);
|
|
alert("Ocurrió un error al registrar la entrada.");
|
|
});
|
|
|
|
|
|
// Guardar datos en localStorage
|
|
localStorage.setItem('datosLania', JSON.stringify(datos));
|
|
});
|
|
|
|
const datosGuardados = localStorage.getItem('datosLania');
|
|
if (datosGuardados) {
|
|
const datosExtra = JSON.parse(datosGuardados);
|
|
for (const proveedor in datosExtra) {
|
|
if (!datos[proveedor]) datos[proveedor] = {};
|
|
for (const examen in datosExtra[proveedor]) {
|
|
if (!datos[proveedor][examen]) datos[proveedor][examen] = [];
|
|
datosExtra[proveedor][examen].forEach(cert => {
|
|
if (!datos[proveedor][examen].includes(cert)) {
|
|
datos[proveedor][examen].push(cert);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.querySelectorAll('.sidebar-menu li').forEach(item => {
|
|
item.classList.remove('active');
|
|
});
|
|
const menuEntrada = document.getElementById('menu-entrada');
|
|
if (menuEntrada) {
|
|
menuEntrada.classList.add('active');
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|