formularios
This commit is contained in:
parent
09e4ecd527
commit
0c33aaa6fa
|
@ -0,0 +1 @@
|
||||||
|
.idea/
|
|
@ -22,8 +22,8 @@ class CandidatoController {
|
||||||
$id_tipo_id = $_POST['id_tipo_id'];
|
$id_tipo_id = $_POST['id_tipo_id'];
|
||||||
$id_rango_edad = $_POST['id_rango_edad'];
|
$id_rango_edad = $_POST['id_rango_edad'];
|
||||||
$id_genero = $_POST['id_genero'];
|
$id_genero = $_POST['id_genero'];
|
||||||
|
|
||||||
$insertId = self::$candidatoModel->registrarCandidato(
|
return self::$candidatoModel->registrarCandidato(
|
||||||
$nombres,
|
$nombres,
|
||||||
$primer_apellido,
|
$primer_apellido,
|
||||||
$segundo_apellido,
|
$segundo_apellido,
|
||||||
|
@ -34,12 +34,27 @@ class CandidatoController {
|
||||||
$id_rango_edad,
|
$id_rango_edad,
|
||||||
$id_genero
|
$id_genero
|
||||||
);
|
);
|
||||||
|
|
||||||
return $insertId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function registrarInfoCandidato() {
|
public static function registrarInfoCandidato() {
|
||||||
$id_candidato = $_POST['id_candidato'];
|
$id_candidato = $_POST['id_candidato'];
|
||||||
|
|
||||||
|
$exiteInfo = self::existeRegistroInfoCandidato($id_candidato);
|
||||||
|
if ($exiteInfo) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Ya existe un registro de información para este candidato."
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!self::existeIdCandidato($id_candidato)){
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "El ID del candidato no existe."
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$id_pais = $_POST['id_pais'];
|
$id_pais = $_POST['id_pais'];
|
||||||
$id_estado = $_POST['id_estado'];
|
$id_estado = $_POST['id_estado'];
|
||||||
$id_municipio = $_POST['id_municipio'];
|
$id_municipio = $_POST['id_municipio'];
|
||||||
|
@ -50,8 +65,10 @@ class CandidatoController {
|
||||||
$motivo_examen = $_POST['motivo_examen'];
|
$motivo_examen = $_POST['motivo_examen'];
|
||||||
$calificacion_servicio = $_POST['calificacion_servicio'];
|
$calificacion_servicio = $_POST['calificacion_servicio'];
|
||||||
$consentimiento_pub = $_POST['consentimiento_pub'];
|
$consentimiento_pub = $_POST['consentimiento_pub'];
|
||||||
|
|
||||||
$insertId = self::$candidatoModel->registrarInfoCandidatos(
|
$fecha_salida = $_POST['fecha_salida'];
|
||||||
|
|
||||||
|
return self::$candidatoModel->registrarInfoCandidatos(
|
||||||
$id_candidato,
|
$id_candidato,
|
||||||
$id_pais,
|
$id_pais,
|
||||||
$id_estado,
|
$id_estado,
|
||||||
|
@ -62,10 +79,22 @@ class CandidatoController {
|
||||||
$nombre_empresa_institucion,
|
$nombre_empresa_institucion,
|
||||||
$motivo_examen,
|
$motivo_examen,
|
||||||
$calificacion_servicio,
|
$calificacion_servicio,
|
||||||
$consentimiento_pub
|
$consentimiento_pub,
|
||||||
|
$fecha_salida
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $insertId;
|
public static function existeRegistroInfoCandidato($id_candidato) {
|
||||||
|
return self::$candidatoModel->verificarRegistroInfoCandidato($id_candidato);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function existeIdCandidato($id_candidato){
|
||||||
|
$resultado = self::$candidatoModel->existeIdCandidato($id_candidato);
|
||||||
|
if($resultado['estado'] === 'exitoso'){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__ . '/../models/Catalogos.php';
|
require_once __DIR__ . '/../models/CatalogosModel.php';
|
||||||
|
|
||||||
class CatalogosController {
|
class CatalogosController {
|
||||||
private static $catalogosModel = null;
|
private static $catalogosModel = null;
|
||||||
|
@ -12,20 +12,81 @@ class CatalogosController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function obtenerInfiCodigoPostal($codigo_postal){
|
public static function obtenerInfiCodigoPostal($codigo_postal){
|
||||||
$result = self::$catalogosModel->obtenerInfiCodigoPostal($codigo_postal);
|
return self::$catalogosModel->obtenerInfiCodigoPostal($codigo_postal);
|
||||||
return $result;
|
}
|
||||||
|
|
||||||
|
public static function obtenerGiros(){
|
||||||
|
return self::$catalogosModel->obtenerGiros();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function obtenerNombresExamenes(){
|
||||||
|
return self::$catalogosModel->obtenerNombresExamenes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function obtenerTiposIdentificacion(){
|
||||||
|
return self::$catalogosModel->obtenerTiposIdentificacion();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function obtenerRangosEdad(){
|
||||||
|
return self::$catalogosModel->obtenerRangosEdad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function obtenerNivelesEstudio(){
|
||||||
|
return self::$catalogosModel->obtenerNivelesEstudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function obtenerNombresEmpresasInstituciones(){
|
||||||
|
return self::$catalogosModel->obtenerNombresEmpresasInstituciones();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CatalogosController::inicializar();
|
CatalogosController::inicializar();
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['codigo_postal'])) {
|
// Petición GET para información del código postal
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['codigo_postal'])) {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
$codigo_postal = $_GET['codigo_postal'];
|
$codigo_postal = $_GET['codigo_postal'];
|
||||||
$result = CatalogosController::obtenerInfiCodigoPostal($codigo_postal);
|
$result = CatalogosController::obtenerInfiCodigoPostal($codigo_postal);
|
||||||
|
|
||||||
echo $result;
|
echo json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'giros') {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$result = CatalogosController::obtenerGiros();
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'examenes') {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$result = CatalogosController::obtenerNombresExamenes();
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'identificacion') {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$result = CatalogosController::obtenerTiposIdentificacion();
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'rangosedad') {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$result = CatalogosController::obtenerRangosEdad();
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'nivelesestudio') {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$result = CatalogosController::obtenerNivelesEstudio();
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'empresasinstituciones') {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$result = CatalogosController::obtenerNombresEmpresasInstituciones();
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -4,11 +4,20 @@ require_once __DIR__ . '/CandidatoController.php';
|
||||||
// Manejar la solicitud POST para registrar información un candidato
|
// Manejar la solicitud POST para registrar información un candidato
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
|
||||||
$insertId = CandidatoController::registrarInfoCandidato();
|
$respuesta = CandidatoController::registrarInfoCandidato();
|
||||||
if($insertId > 0){
|
|
||||||
echo json_encode(['registroExitoso' => true, 'message' => 'Se ha registrado la información correctamente.']);
|
if(isset($respuesta["estado"]) && $respuesta["estado"] === "exitoso") {
|
||||||
} else {
|
echo json_encode([
|
||||||
echo json_encode(['registroExitoso' => false, 'message' => 'Error al registrar la información.']);
|
"estado" => "exitoso",
|
||||||
|
"mensaje" => "Se ha registrado la información correctamente.",
|
||||||
|
"res" => "id_candidato: " . $respuesta["mensaje"]
|
||||||
|
]);
|
||||||
|
} else if( isset($respuesta["estado"]) ){
|
||||||
|
echo json_encode([
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error al registrar la información.",
|
||||||
|
"res" => $respuesta["mensaje"]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,57 +123,28 @@
|
||||||
<div>
|
<div>
|
||||||
<label for="id_examen">Examen:</label>
|
<label for="id_examen">Examen:</label>
|
||||||
<select name="id_examen" id="id_examen" required>
|
<select name="id_examen" id="id_examen" required>
|
||||||
<option value="">Selecciona un examen</option>
|
<option value="NULL">Selecciona un examen</option>
|
||||||
<option value="1">Cisco</option>
|
|
||||||
<option value="2">IBM</option>
|
|
||||||
<option value="3">Microsoft</option>
|
|
||||||
<option value="4">Oracle</option>
|
|
||||||
<option value="5">SAP</option>
|
|
||||||
<option value="6">CompTIA</option>
|
|
||||||
<option value="7">Amazon Web Services</option>
|
|
||||||
<option value="8">Google Cloud Platform</option>
|
|
||||||
<option value="9">Salesforce</option>
|
|
||||||
<option value="10">Red Hat</option>
|
|
||||||
<option value="11">VMWare</option>
|
|
||||||
<option value="12">Palo Alto Networks</option>
|
|
||||||
<option value="13">Fornitet</option>
|
|
||||||
<option value="14">Juniper Networks</option>
|
|
||||||
<option value="15">Otros</option>
|
|
||||||
</select><br>
|
</select><br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="id_tipo_id">Tipo de Identificación:</label>
|
<label for="id_tipo_id">Tipo de Identificación:</label>
|
||||||
<select name="id_tipo_id" id="id_tipo_id" required>
|
<select name="id_tipo_id" id="id_tipo_id" required>
|
||||||
<option value="">Selecciona el tipo de identificación</option>
|
<option value="NULL">Selecciona el tipo de identificación</option>
|
||||||
<option value="1">INE</option>
|
|
||||||
<option value="2">Pasaporte</option>
|
|
||||||
<option value="3">CURP</option>
|
|
||||||
<option value="4">RFC</option>
|
|
||||||
<option value="5">Cédila Profesional</option>
|
|
||||||
<option value="6">Licencia de conducir</option>
|
|
||||||
<option value="7">Otro</option>
|
|
||||||
</select><br>
|
</select><br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="id_rango_edad">Rango de edad:</label>
|
<label for="id_rango_edad">Rango de edad:</label>
|
||||||
<select name="id_rango_edad" id="id_rango_edad" required>
|
<select name="id_rango_edad" id="id_rango_edad" required>
|
||||||
<option value="">Selecciona un rango de edad</option>
|
<option value="NULL">Selecciona un rango de edad</option>
|
||||||
<option value="1">Menos de 18</option>
|
|
||||||
<option value="2">18-24</option>
|
|
||||||
<option value="3">24-34</option>
|
|
||||||
<option value="4">35-44</option>
|
|
||||||
<option value="5">45-54</option>
|
|
||||||
<option value="6">55-64</option>
|
|
||||||
<option value="7">65 o más</option>
|
|
||||||
</select><br>
|
</select><br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="id_genero">Género:</label>
|
<label for="id_genero">Género:</label>
|
||||||
<select name="id_genero" id="id_genero" required>
|
<select name="id_genero" id="id_genero" required>
|
||||||
<option value="">Selecciona un género</option>
|
<option value="NULL">Selecciona un género</option>
|
||||||
<option value="1">Masculino</option>
|
<option value="1">Masculino</option>
|
||||||
<option value="2">Femenino</option>
|
<option value="2">Femenino</option>
|
||||||
<option value="3">Prefiero no decir</option>
|
<option value="3">Prefiero no decir</option>
|
||||||
|
@ -192,7 +163,7 @@
|
||||||
<!-- NAVBAR -->
|
<!-- NAVBAR -->
|
||||||
|
|
||||||
<script src="js/form.js"></script>
|
<script src="js/form.js"></script>
|
||||||
<script src="js/form_datos_basicos.js"""
|
<script src="js/form_datos_basicos.js"></script>
|
||||||
<script src="https://website-widgets.pages.dev/dist/sienna.min.js" defer></script>
|
<script src="https://website-widgets.pages.dev/dist/sienna.min.js" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,3 +1,15 @@
|
||||||
|
<?php
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['id_candidato'])){
|
||||||
|
// Verifica si se ha pasado el id_candidato como parámetro GET
|
||||||
|
$id_candidato = $_GET['id_candidato'];
|
||||||
|
// Si no se pasa el id_candidato
|
||||||
|
//header("Location: inicio.html");
|
||||||
|
//exit();
|
||||||
|
} else { // TEST //
|
||||||
|
$id_candidato = 0;
|
||||||
|
} // TEST \\
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -81,66 +93,69 @@
|
||||||
|
|
||||||
<!-- MAIN -->
|
<!-- MAIN -->
|
||||||
<main>
|
<main>
|
||||||
<h1 class="title">Datos Extendidos</h1>
|
<h1 class="title">Datos</h1>
|
||||||
<ul class="breadcrumbs">
|
<ul class="breadcrumbs">
|
||||||
<li><a href="#">Formularios</a></li>
|
<li><a href="#">Formulario</a></li>
|
||||||
<li class="divider">/</li>
|
<li class="divider">/</li>
|
||||||
<li><a href="#" class="active">Datos Extendidos</a></li>
|
<li><a href="#" class="active">Datos</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
|
<!-- Formulario -->
|
||||||
<form id="formulario-datos-extendido" method="post" action="#">
|
<form id="formulario-datos-extendido" method="post" action="#">
|
||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
<br>
|
<br>
|
||||||
<h3>Ubicación</h3>
|
<h3>Ubicación</h3>
|
||||||
<br>
|
<br>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<input type="hidden" id="id_candidato" name="id_candidato">
|
<label for="id_candidato">ID del candidato</label>
|
||||||
|
<input type="number" id="id_candidato" name="id_candidato" value="<?php echo $id_candidato; ?>">
|
||||||
|
|
||||||
<div class="form-col">
|
<div class="form-col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_pais" class="required">País</label>
|
<label for="id_pais" class="required">País</label>
|
||||||
<select id="id_pais" name="id_pais" required>
|
<select id="id_pais" name="id_pais" required>
|
||||||
<option value="">Seleccione...</option>
|
<option value="NULL">Seleccione su país</option>
|
||||||
<!-- Aquí irían los países desde la base de datos -->
|
|
||||||
<option value="1">México</option>
|
<option value="1">México</option>
|
||||||
<option value="2">Otro</option>
|
<option value="2">Otro</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-col">
|
<div class="form-col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="codigo_postal" class="required">Código Postal</label>
|
<label for="codigo_postal">Código postal</label>
|
||||||
<input type="number" min="0" step="1" id="codigo_postal" name="codigo_postal" maxlength="10" required>
|
<input type="number" id="codigo_postal" name="codigo_postal" maxlength="5" disabled>
|
||||||
<button type="button" id="buscarBtn"><span class="material-icons">search</span>Buscar</button>
|
<br>
|
||||||
|
<input type="button" class="btn" id="buscarBtn" value="Buscar" disabled>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-col">
|
<div class="form-col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_estado">Estado</label>
|
<label for="id_estado">Estado</label>
|
||||||
<select id="id_estado" name="id_estado">
|
<select id="id_estado" name="id_estado" disabled>
|
||||||
<option value="">Seleccione...</option>
|
<option value="NULL">Seleccione su estado</option>
|
||||||
<!-- Aquí irían los estados desde la base de datos -->
|
<!-- Aquí irían los estados desde la base de datos -->
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-col">
|
<div class="form-col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_municipio">Municipio</label>
|
<label for="id_municipio">Municipio</label>
|
||||||
<select id="id_municipio" name="id_municipio">
|
<select id="id_municipio" name="id_municipio" disabled>
|
||||||
<option value="">Seleccione...</option>
|
<option value="NULL">Seleccione su municipio</option>
|
||||||
<!-- Aquí irían los municipios desde la base de datos -->
|
<!-- Aquí irían los municipios desde la base de datos -->
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-col">
|
<div class="form-col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_colonia">Colonia</label>
|
<label for="id_colonia">Colonia</label>
|
||||||
<select id="id_colonia" name="id_colonia">
|
<select id="id_colonia" name="id_colonia" disabled>
|
||||||
<option value="">Seleccione...</option>
|
<option value="NULL">Seleccione su colonia</option>
|
||||||
<!-- Aquí irían las colonias desde la base de datos -->
|
<!-- Aquí irían las colonias desde la base de datos -->
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -151,81 +166,58 @@
|
||||||
<!-- Sección 3: Información Académica y Laboral -->
|
<!-- Sección 3: Información Académica y Laboral -->
|
||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
<br>
|
<br>
|
||||||
<h3>Información Académica/Laboral</h3>
|
<h3>Información académica/laboral</h3>
|
||||||
<br>
|
<br>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-col">
|
<div class="form-col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_nivel" class="required">Nivel de Estudios</label>
|
<label for="id_nivel" class="required">Nivel de Estudios</label>
|
||||||
<select id="id_nivel" name="id_nivel" required>
|
<select id="id_nivel" name="id_nivel" required>
|
||||||
<option value="">Seleccione...</option>
|
<option value="NULL">Seleccione una opción</option>
|
||||||
<option value="1">Primaria</option>
|
</select>
|
||||||
<option value="2">Secundaria</option>
|
</div>
|
||||||
<option value="3">Bachillerato</option>
|
</div>
|
||||||
<option value="4">Técnico Superior Universitario</option>
|
|
||||||
<option value="5">Licenciatura</option>
|
<div class="form-col">
|
||||||
<option value="6">Maestría</option>
|
<div class="form-group">
|
||||||
<option value="7">Doctorado</option>
|
<label for="nombre_empresa">Nombre de la empresa/institución</label>
|
||||||
<option value="8">Otro</option>
|
<input type="text" id="nombre_empresa" list="sugerencias_ei" maxlength="100">
|
||||||
</select>
|
<datalist id="sugerencias_ei"></datalist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-col">
|
|
||||||
<div class="form-group">
|
<div class="form-col">
|
||||||
<label for="id_giro" class="required">Giro</label>
|
<div class="form-group">
|
||||||
<select id="id_giro" name="id_giro" required>
|
<label for="id_giro" class="required">Giro de la empresa/institución</label>
|
||||||
<option value="">Seleccione...</option>
|
<select id="id_giro" name="id_giro" required>
|
||||||
<option value="1">Tecnologías de la Información</option>
|
<option value="NULL">Seleccione una opción</option>
|
||||||
<option value="2">Gobierno</option>
|
</select>
|
||||||
<option value="3">Finanzas</option>
|
</div>
|
||||||
<option value="4">Salud</option>
|
</div>
|
||||||
<option value="5">Educación</option>
|
|
||||||
<option value="6">Telecomunicaciones</option>
|
<div class="form-group">
|
||||||
<option value="7">Retail</option>
|
<label for="motivo_examen">Motivo del Examen</label>
|
||||||
<option value="8">Manufactura</option>
|
<textarea id="motivo_examen" name="motivo_examen" rows="3"></textarea>
|
||||||
<option value="9">Logística y Transporte</option>
|
</div>
|
||||||
<option value="10">Construcción</option>
|
</div>
|
||||||
<option value="11">Turismo y Hospitalidad</option>
|
|
||||||
<option value="12">Energía y Recursos Naturales</option>
|
|
||||||
<option value="13">Agricultura y Alimentación</option>
|
|
||||||
<option value="14">Medios de Comunicación y Entretenimiento</option>
|
|
||||||
<option value="15">Otros</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="nombre_empresa">Nombre de la Empresa/Institución</label>
|
|
||||||
<input type="text" id="nombre_empresa" name="nombre_empresa"
|
|
||||||
maxlength="100">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="motivo_examen">Motivo del Examen</label>
|
|
||||||
<textarea id="motivo_examen" name="motivo_examen" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Sección 4: Evaluación y Consentimiento -->
|
<!-- Sección 4: Evaluación y Consentimiento -->
|
||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
|
<br><h3>Evaluación</h3><br>
|
||||||
<br>
|
|
||||||
<h3>Evaluación y Consentimiento</h3>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<p>Calificación del Servicio</p>
|
<p>Calificación del servicio</p>
|
||||||
<br>
|
<br>
|
||||||
<label for="calificacion_servicio">¿Qué tan satisfecho estás con nuestra institución en general, considerando la calidad de las instalaciones, la atención del personal y el proceso de certificación?</label>
|
<label for="calificacion_servicio">Considerando la calidad de las instalaciones, la atención del personal y el proceso de certificación, ¿cuál es su nivel general de satisfacción con nuestra institución?</label>
|
||||||
<br>
|
<br>
|
||||||
<select id="calificacion_servicio" name="calificacion_servicio" class="select-emoji">
|
<select id="calificacion_servicio" name="calificacion_servicio" class="select-emoji">
|
||||||
<option value="">Seleccione una calificación...</option>
|
<option value="NULL">Seleccione una calificación...</option>
|
||||||
<option value="1">😡 Muy insatisfecho</option>
|
<option value="1">🙁 Muy insatisfecho</option>
|
||||||
<option value="2">😕 Insatisfecho</option>
|
<option value="2">😕 Insatisfecho</option>
|
||||||
<option value="3">😐 Neutral</option>
|
<option value="3">😐 Neutral</option>
|
||||||
<option value="4">🙂 Satisfecho</option>
|
<option value="4">🙂 Satisfecho</option>
|
||||||
<option value="5">😄 Muy satisfecho</option>
|
<option value="5">😐 Muy satisfecho</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -233,7 +225,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="checkbox" id="consentimiento_pub" name="consentimiento_pub" value="1" checked>
|
<input type="checkbox" id="consentimiento_pub" name="consentimiento_pub" value="1" checked>
|
||||||
<label for="consentimiento_pub" style="display: inline;">Doy mi consentimiento para la publicación de mis datos</label>
|
<label for="consentimiento_pub" style="display: inline;">Consiento que mis datos personales sean tratados de conformidad con los términos y condiciones informados en el presente <a href="#">aviso de privacidad</a>.</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -254,7 +246,7 @@
|
||||||
|
|
||||||
<script src="js/form.js"></script>
|
<script src="js/form.js"></script>
|
||||||
<script src="js/form_datos_extendidos.js"></script>
|
<script src="js/form_datos_extendidos.js"></script>
|
||||||
<script src="js/buscarCodigo.js"></script>
|
<!-- <script src="js/buscarCodigo.js"></script> -->
|
||||||
<script src="https://website-widgets.pages.dev/dist/sienna.min.js" defer></script>
|
<script src="https://website-widgets.pages.dev/dist/sienna.min.js" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -33,7 +33,7 @@
|
||||||
<a href="#"><i class='bx bxs-notepad icon' ></i> Formularios <i class='bx bx-chevron-right icon-right' ></i></a>
|
<a href="#"><i class='bx bxs-notepad icon' ></i> Formularios <i class='bx bx-chevron-right icon-right' ></i></a>
|
||||||
<ul class="side-dropdown">
|
<ul class="side-dropdown">
|
||||||
<li><a href="form_datos_basicos.html">Datos Básicos</a></li>
|
<li><a href="form_datos_basicos.html">Datos Básicos</a></li>
|
||||||
<li><a href="form_datos_extendidos.html">Datos Extendidos</a></li>
|
<li><a href="form_datos_extendidos.php">Datos Extendidos</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const buscarBtn = document.getElementById("buscarBtn");
|
||||||
|
const paisSelect = document.getElementById("id_pais");
|
||||||
|
const inputCodigoPostal = document.getElementById("codigo_postal");
|
||||||
|
const inputButtonBuscarCodigoPostal = document.getElementById("buscarBtn");
|
||||||
|
const estadoSelect = document.getElementById("id_estado");
|
||||||
|
const municipioSelect = document.getElementById("id_municipio");
|
||||||
|
const coloniaSelect = document.getElementById("id_colonia");
|
||||||
|
const giroSelect = document.getElementById("id_giro");
|
||||||
|
|
||||||
|
llenarSelectGiro();
|
||||||
|
|
||||||
|
// Añadir un evento de cambio al select de país
|
||||||
|
paisSelect.addEventListener("change", function() {
|
||||||
|
// Si el país es México, habilitar el campo de código postal
|
||||||
|
if (paisSelect.value === "1") {
|
||||||
|
inputCodigoPostal.removeAttribute("disabled");
|
||||||
|
inputButtonBuscarCodigoPostal.removeAttribute("disabled");
|
||||||
|
} else {
|
||||||
|
// Si el país no es México, deshabilitar el campo de código postal
|
||||||
|
inputCodigoPostal.setAttribute("disabled", "disabled");
|
||||||
|
inputButtonBuscarCodigoPostal.setAttribute("disabled", "disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Añadir un evento al boton de buscar
|
||||||
|
buscarBtn.addEventListener("click", function () {
|
||||||
|
let inputCodigoPostal = document.getElementById("codigo_postal").value;
|
||||||
|
|
||||||
|
//verificar si el codigo postal esta vacio
|
||||||
|
if (inputCodigoPostal) {
|
||||||
|
|
||||||
|
// Limpia los selects antes de llenarlos
|
||||||
|
estadoSelect.innerHTML = "<option value='NULL'>Seleccione su estado</option>";
|
||||||
|
municipioSelect.innerHTML = "<option value='NULL'>Seleccione su municipio</option>";
|
||||||
|
coloniaSelect.innerHTML = "<option value='NULL'>Seleccione su colonia</option>";
|
||||||
|
|
||||||
|
// Construye la URL para la solicitud
|
||||||
|
let url = "./controllers/CatalogosController.php?codigo_postal=" + encodeURIComponent(inputCodigoPostal);
|
||||||
|
|
||||||
|
// Realiza una solicitud HTTP GET a la URL especificada
|
||||||
|
fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
//console.log("Estado de la respuesta:", response.status);
|
||||||
|
//console.log("Contenido de la respuesta:", response.json());
|
||||||
|
|
||||||
|
// Verifica si la respuesta del servidor es exitosa
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Error en la respuesta del servidor");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convertir la respuesta a JSON
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
// Verifica si se recibieron datos
|
||||||
|
if (data.length > 0) {
|
||||||
|
|
||||||
|
// Quitar disable a los selects
|
||||||
|
estadoSelect.removeAttribute("disabled");
|
||||||
|
estadoSelect.setAttribute("required", "required");
|
||||||
|
municipioSelect.removeAttribute("disabled");
|
||||||
|
municipioSelect.setAttribute("required", "required");
|
||||||
|
coloniaSelect.removeAttribute("disabled");
|
||||||
|
coloniaSelect.setAttribute("required", "required");
|
||||||
|
|
||||||
|
//Crea conjuntos para almacenar estados, ciudades y colonias
|
||||||
|
let estados = new Map();
|
||||||
|
let municipios = new Map();
|
||||||
|
let colonias = new Map();
|
||||||
|
|
||||||
|
// Itera sobre cada fila de datos recibidos
|
||||||
|
data.forEach(row => {
|
||||||
|
console.log(row);
|
||||||
|
estados.set(row['id_estado'], row['estado']);
|
||||||
|
municipios.set(row['id_municipio'], row['municipio']);
|
||||||
|
colonias.set(row['id_colonia'], row['colonia']);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Añade las opciones de estados al elemento select
|
||||||
|
for (let [id_estado, estado] of estados) {
|
||||||
|
estadoSelect.innerHTML += "<option value='" + id_estado + "'>" + estado + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade las opciones de ciudades al elemento select
|
||||||
|
for (let [id_municipio, municipio] of municipios) {
|
||||||
|
municipioSelect.innerHTML += "<option value='" + id_municipio + "'>" + municipio + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade las opciones de colonias al elemento select
|
||||||
|
for (let [id_colonia, colonia] of colonias) {
|
||||||
|
coloniaSelect.innerHTML += "<option value='" + id_colonia + "'>" + colonia + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert("No se encontraron datos para el código postal ingresado.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error en la solicitud:", error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("Por favor, ingrese un código postal.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function llenarSelectGiro() {
|
||||||
|
|
||||||
|
// URL para la solicitud
|
||||||
|
let url = "./controllers/CatalogosController.php?obtener=giros";
|
||||||
|
|
||||||
|
// Realiza una solicitud HTTP GET a la URL especificada
|
||||||
|
fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
// Verifica si la respuesta del servidor es exitosa
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Error en la respuesta del servidor");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convertir la respuesta a JSON
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
// Verifica si se recibieron datos
|
||||||
|
if (data.length > 0) {
|
||||||
|
|
||||||
|
// Añade las opciones de giros al elemento select
|
||||||
|
data.forEach(row => {
|
||||||
|
giroSelect.innerHTML += "<option value='" + row.id_giro + "'>" + row.descripcion + "</option>";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("No se encontraron datos para los giros.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error en la solicitud:", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,76 +0,0 @@
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
var buscarBtn = document.getElementById("buscarBtn");
|
|
||||||
|
|
||||||
//Añadir un evento al boton de buscar
|
|
||||||
buscarBtn.addEventListener("click", function () {
|
|
||||||
var codigoPostal = document.getElementById("codigo_postal").value;
|
|
||||||
console.log(codigoPostal);
|
|
||||||
|
|
||||||
//verificar si el codigo postal esta vacio
|
|
||||||
if (codigoPostal) {
|
|
||||||
console.log("Código postal ingresado:", codigoPostal);
|
|
||||||
//crear la url para la peticion
|
|
||||||
const url = "./controllers/CatalogosController.php?codigo_postal=" + encodeURIComponent(codigoPostal);
|
|
||||||
|
|
||||||
//Realiza una solicitud HTTP GET a la URL especificada
|
|
||||||
fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
//console.log("Estado de la respuesta:", response.status);
|
|
||||||
//console.log("Contenido de la respuesta:", response.json());
|
|
||||||
// Verifica si la respuesta del servidor es exitosa
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Error en la respuesta del servidor");
|
|
||||||
}
|
|
||||||
//Convierte la respuesta que es unu array de objetos a formato JSON
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
var estadoSelect = document.getElementById("id_estado");
|
|
||||||
var municipioSelect = document.getElementById("id_municipio");
|
|
||||||
var coloniaSelect = document.getElementById("id_colonia");
|
|
||||||
|
|
||||||
// Inicializa los elementos select con una opción por defecto
|
|
||||||
estadoSelect.innerHTML = "<option value=''>Seleccionar Estado</option>";
|
|
||||||
municipioSelect.innerHTML = "<option value=''>Seleccionar Municipios</option>";
|
|
||||||
coloniaSelect.innerHTML = "<option value=''>Seleccionar Colonia</option>";
|
|
||||||
|
|
||||||
// Verifica si se recibieron datos
|
|
||||||
if (data.length > 0) {
|
|
||||||
//Crea conjuntos para almacenar estados, ciudades y colonias únicos
|
|
||||||
let estados = new Set();
|
|
||||||
let municipios = new Set();
|
|
||||||
let colonias = [];
|
|
||||||
|
|
||||||
// Itera sobre cada fila de datos recibidos
|
|
||||||
data.forEach(row => {
|
|
||||||
estados.add(row.estado);
|
|
||||||
municipios.add(row.municipio);
|
|
||||||
colonias.push(row.colonia);
|
|
||||||
});
|
|
||||||
|
|
||||||
//Añade las opciones de estados al elemento select
|
|
||||||
estados.forEach(estado => {
|
|
||||||
estadoSelect.innerHTML += "<option value='" + estado + "'>" + estado + "</option>";
|
|
||||||
});
|
|
||||||
|
|
||||||
//Añade las opciones de ciudades al elemento select
|
|
||||||
municipios.forEach(municipio => {
|
|
||||||
municipioSelect.innerHTML += "<option value='" + municipio + "'>" + municipio + "</option>";
|
|
||||||
});
|
|
||||||
|
|
||||||
//Añade las opciones de colonias al elemento select
|
|
||||||
colonias.forEach(colonia => {
|
|
||||||
coloniaSelect.innerHTML += "<option value='" + colonia + "'>" + colonia + "</option>";
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert("No se encontraron datos para el código postal ingresado.");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error("Error en la solicitud:", error);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert("Por favor, ingrese un código postal.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,6 +1,101 @@
|
||||||
const formulario = document.getElementById("formulario-datos-basicos");
|
const formulario = document.getElementById("formulario-datos-basicos");
|
||||||
const notificacion = document.getElementById("mensaje-error");
|
const notificacion = document.getElementById("mensaje-error");
|
||||||
|
|
||||||
|
obtenerNombresExamenes();
|
||||||
|
obtenerTiposIdentificacion();
|
||||||
|
obtenerRangosEdad();
|
||||||
|
|
||||||
|
function obtenerNombresExamenes(){
|
||||||
|
let url = "./controllers/CatalogosController.php?obtener=examenes";
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const selectExamen = document.getElementById('id_examen');
|
||||||
|
let examen = new Map();
|
||||||
|
|
||||||
|
// Iterar sobre cada fila y mapear por por id_examen, nombre_examen
|
||||||
|
data.forEach(row =>{
|
||||||
|
examen.set(row['id_examen'], row['nombre_examen']);
|
||||||
|
})
|
||||||
|
|
||||||
|
// LLenar opciones del select de examen
|
||||||
|
for (let [id_examen, nombre_examen] of examen) {
|
||||||
|
selectExamen.innerHTML += "<option value='" + id_examen + "'>" + nombre_examen + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error al obtener los exámenes:', error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function obtenerTiposIdentificacion(){
|
||||||
|
let url = "./controllers/CatalogosController.php?obtener=identificacion";
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const selectTipoId = document.getElementById('id_tipo_id');
|
||||||
|
|
||||||
|
let tipoId = new Map();
|
||||||
|
|
||||||
|
// Iterar sobre cada fila y mapear por por id_tipo_id, descripcion
|
||||||
|
data.forEach(row =>{
|
||||||
|
tipoId.set(row['id_tipo_id'], row['descripcion']);
|
||||||
|
})
|
||||||
|
|
||||||
|
// LLenar opciones del select de examen
|
||||||
|
for (let [id_tipo_id, descripcion] of tipoId) {
|
||||||
|
selectTipoId.innerHTML += "<option value='" + id_tipo_id + "'>" + descripcion + "</option>";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error al obtener los tipos de identificación:', error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function obtenerRangosEdad(){
|
||||||
|
let url = "./controllers/CatalogosController.php?obtener=rangosedad";
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const selectRangoEdad = document.getElementById('id_rango_edad');
|
||||||
|
|
||||||
|
let tipoId = new Map();
|
||||||
|
|
||||||
|
// Iterar sobre cada fila y mapear por por id_tipo_id, descripcion
|
||||||
|
data.forEach(row =>{
|
||||||
|
tipoId.set(row['id_rango_edad'], row['descripcion']);
|
||||||
|
})
|
||||||
|
|
||||||
|
// LLenar opciones del select de examen
|
||||||
|
for (let [id_rango_edad, descripcion] of tipoId) {
|
||||||
|
selectRangoEdad.innerHTML += "<option value='" + id_rango_edad + "'>" + descripcion + "</option>";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error al obtener rangos de edad:', error));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validaciones - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
function selectExamenValido(){
|
||||||
|
const selectExamen = document.getElementById('id_examen');
|
||||||
|
const idExamen = selectExamen.value;
|
||||||
|
return idExamen !== "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectTipoIdentificacionValido(){
|
||||||
|
const selectTipoId = document.getElementById('id_tipo_id');
|
||||||
|
const idTipoId = selectTipoId.value;
|
||||||
|
return idTipoId !== "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectRangoEdadValido(){
|
||||||
|
const selectRangoEdad = document.getElementById('id_rango_edad');
|
||||||
|
const idRangoEdad = selectRangoEdad.value;
|
||||||
|
return idRangoEdad !== "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectGeneroValido(){
|
||||||
|
const selectGenero = document.getElementById('id_genero');
|
||||||
|
const idGenero = selectGenero.value;
|
||||||
|
return idGenero !== "NULL";
|
||||||
|
}
|
||||||
// Función para validar el nombre
|
// Función para validar el nombre
|
||||||
function validarNombre(nombre) {
|
function validarNombre(nombre) {
|
||||||
const nombreRegex = /^[a-zA-ZÀ-ÿ\s]+$/; // Permite letras y espacios
|
const nombreRegex = /^[a-zA-ZÀ-ÿ\s]+$/; // Permite letras y espacios
|
||||||
|
@ -25,6 +120,8 @@ function validarCorreo(correo) {
|
||||||
return correoRegex.test(correo);
|
return correoRegex.test(correo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Validaciones
|
||||||
|
|
||||||
formulario.addEventListener("submit", async(event) => {
|
formulario.addEventListener("submit", async(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
@ -75,6 +172,19 @@ formulario.addEventListener("submit", async(event) => {
|
||||||
errores.push("El número telefónico debe ser un número de 10 dígitos. ");
|
errores.push("El número telefónico debe ser un número de 10 dígitos. ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!selectExamenValido()){
|
||||||
|
errores.push("Seleccione un examen. ");
|
||||||
|
}
|
||||||
|
if(!selectTipoIdentificacionValido()){
|
||||||
|
errores.push("Seleccione un tipo de identificación. ");
|
||||||
|
}
|
||||||
|
if(!selectRangoEdadValido()){
|
||||||
|
errores.push("Seleccione un rango de edad. ");
|
||||||
|
}
|
||||||
|
if(!selectGeneroValido()){
|
||||||
|
errores.push("Seleccione un género. ");
|
||||||
|
}
|
||||||
|
|
||||||
// Si hay errores, mostrarlos y detener el envío
|
// Si hay errores, mostrarlos y detener el envío
|
||||||
if (errores.length > 0) {
|
if (errores.length > 0) {
|
||||||
notificacion.textContent = errores.join("\n");
|
notificacion.textContent = errores.join("\n");
|
||||||
|
@ -84,9 +194,8 @@ formulario.addEventListener("submit", async(event) => {
|
||||||
|
|
||||||
// Preparar datos para envío
|
// Preparar datos para envío
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
//formData.append("id_candidato", idCandidato);
|
//formData.append("fecha_entrada", fechaEntrada); // No se usa porque tiene valor default
|
||||||
//formData.append("fecha_entrada", fechaEntrada);
|
//formData.append("fecha_salida", fechaSalida); // Se llena al completar el otro formulario de información
|
||||||
//formData.append("fecha_salida", fechaSalida);
|
|
||||||
formData.append("nombres", nombres);
|
formData.append("nombres", nombres);
|
||||||
formData.append("primer_apellido", primerApellido);
|
formData.append("primer_apellido", primerApellido);
|
||||||
formData.append("segundo_apellido", segundoApellido);
|
formData.append("segundo_apellido", segundoApellido);
|
||||||
|
@ -103,10 +212,10 @@ formulario.addEventListener("submit", async(event) => {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Obtener respuesta de petición de registro
|
// Obtener respuesta de petición de registro
|
||||||
const resultado = await respuesta.json();
|
const resultado = await respuesta.json();
|
||||||
|
|
||||||
// Verificar si el registro fue exitoso
|
// Verificar si el registro fue exitoso
|
||||||
if (resultado.registroExitoso) {
|
if (resultado.registroExitoso) {
|
||||||
alert('Se guardó la información correctamente');
|
alert('Se guardó la información correctamente');
|
||||||
|
|
|
@ -1,65 +1,353 @@
|
||||||
const formulario = document.getElementById("formulario-datos-extendido");
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
const notificacion = document.getElementById("mensaje-error");
|
const formulario = document.getElementById("formulario-datos-extendido");
|
||||||
|
const notificacion = document.getElementById("mensaje-error");
|
||||||
|
const buscarBtn = document.getElementById("buscarBtn");
|
||||||
|
const paisSelect = document.getElementById("id_pais");
|
||||||
|
const inputCodigoPostal = document.getElementById("codigo_postal");
|
||||||
|
const inputButtonBuscarCodigoPostal = document.getElementById("buscarBtn");
|
||||||
|
const estadoSelect = document.getElementById("id_estado");
|
||||||
|
const municipioSelect = document.getElementById("id_municipio");
|
||||||
|
const coloniaSelect = document.getElementById("id_colonia");
|
||||||
|
const giroSelect = document.getElementById("id_giro");
|
||||||
|
const nivelEstudioSelect = document.getElementById("id_nivel");
|
||||||
|
const selectCalificacionServicio = document.getElementById("calificacion_servicio");
|
||||||
|
const dataListEmpresasInstituciones = document.getElementById("sugerencias_ei");
|
||||||
|
|
||||||
formulario.addEventListener("submit", async(event) => {
|
llenarSelectGiro();
|
||||||
event.preventDefault();
|
llenarSelectNivelesEstudio();
|
||||||
|
llenarDataListEmpresasInstituciones();
|
||||||
// Limpiar mensaje de error previo
|
|
||||||
notificacion.textContent = "";
|
|
||||||
notificacion.style.display = "none";
|
|
||||||
|
|
||||||
// Obtener valores de los campos
|
// FUNCIONES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const idCandidato = document.getElementById('id_candidato').value;
|
function llenarSelectGiro() {
|
||||||
const idPais = document.getElementById('id_pais').value;
|
// URL para la solicitud
|
||||||
const codigoPostal = document.getElementById('codigo_postal').value; // campo numérico, no necesita trim
|
let url = "./controllers/CatalogosController.php?obtener=giros";
|
||||||
const idEstado = document.getElementById('id_estado').value;
|
|
||||||
const idMunicipio = document.getElementById('id_municipio').value;
|
|
||||||
const idColonia = document.getElementById('id_colonia').value;
|
|
||||||
|
|
||||||
const idNivel = document.getElementById('id_nivel').value;
|
|
||||||
const idGiro = document.getElementById('id_giro').value;
|
|
||||||
const nombreEmpresa = document.getElementById('nombre_empresa').value.trim();
|
|
||||||
const motivoExamen = document.getElementById('motivo_examen').value.trim();
|
|
||||||
|
|
||||||
const calificacionServicio = document.getElementById('calificacion_servicio').value;
|
|
||||||
const consentimientoPub = document.getElementById('consentimiento_pub').checked;
|
|
||||||
|
|
||||||
var id = 6;
|
|
||||||
|
|
||||||
// Preparar datos para envío
|
// Realiza una solicitud HTTP GET a la URL especificada
|
||||||
const formData = new FormData();
|
fetch(url)
|
||||||
formData.append("id_candidato", id);
|
.then(response => {
|
||||||
formData.append("id_pais", idPais);
|
// Verifica si la respuesta del servidor es exitosa
|
||||||
formData.append("codigo_postal", codigoPostal);
|
if (!response.ok) {
|
||||||
formData.append("id_estado", idEstado);
|
throw new Error("llenarSelectGiro(): Error en la respuesta del servidor.");
|
||||||
formData.append("id_municipio", idMunicipio);
|
}
|
||||||
formData.append("id_colonia", idColonia);
|
|
||||||
formData.append("id_nivel", idNivel);
|
|
||||||
formData.append("id_giro", idGiro);
|
|
||||||
|
|
||||||
formData.append("nombre_empresa_institucion", nombreEmpresa);
|
// Convertir la respuesta a JSON
|
||||||
formData.append("motivo_examen", motivoExamen);
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
// Verifica si se recibieron datos
|
||||||
|
if (data.length > 0) {
|
||||||
|
|
||||||
formData.append("calificacion_servicio", calificacionServicio);
|
// Añade las opciones de giros al elemento select
|
||||||
formData.append("consentimiento_pub", consentimientoPub ? 1 : 0);
|
data.forEach(row => {
|
||||||
|
giroSelect.innerHTML += "<option value='" + row.id_giro + "'>" + row.descripcion + "</option>";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("llenarSelectGiro(): No se encontraron datos para los giros.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("llenarSelectGiro(): Error en la solicitud. ", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
function llenarSelectNivelesEstudio(){
|
||||||
const respuesta = await fetch('controllers/registrarInfoCandidato.php', {
|
let url = "./controllers/CatalogosController.php?obtener=nivelesestudio";
|
||||||
method: "POST",
|
// Petición fetch y llenado de select
|
||||||
body: formData,
|
fetch(url)
|
||||||
});
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
const resultado = await respuesta.json();
|
throw new Error("llenarSelectNivelesEstudio(): Error en la respuesta del servidor.");
|
||||||
|
}
|
||||||
if (resultado.registroExitoso) {
|
return response.json();
|
||||||
alert('Se guardó la información correctamente');
|
})
|
||||||
window.location.href = 'inicio.html';
|
.then(data => {
|
||||||
|
if (data.length > 0) {
|
||||||
|
data.forEach(row => {
|
||||||
|
nivelEstudioSelect.innerHTML += "<option value='" + row.id_nivel + "'>" + row.descripcion + "</option>";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("llenarSelectNivelesEstudio(): No se encontraron datos para los giros.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("llenarSelectNivelesEstudio(): Error en la solicitud. ", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function llenarDataListEmpresasInstituciones(){
|
||||||
|
let url = "./controllers/CatalogosController.php?obtener=empresasinstituciones";
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.length > 0) {
|
||||||
|
data.forEach(row => {
|
||||||
|
dataListEmpresasInstituciones.innerHTML += "<option value='" + row.nombre_empresa_institucion + "'>" + row.nombre_empresa_institucion + "</option>";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("llenarDataListEmpresasInstituciones(): No se encontraron datos para las empresas o instituciones.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("llenarDataListEmpresasInstituciones(): Error en la solicitud. ", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Función para obtener fecha en formato: 2025-04-27 09:05:18
|
||||||
|
function obtenerFechaActual() {
|
||||||
|
const ahora = new Date();
|
||||||
|
|
||||||
|
const anio = ahora.getFullYear();
|
||||||
|
const mes = String(ahora.getMonth() + 1).padStart(2, '0'); // Mes comienza en 0
|
||||||
|
const dia = String(ahora.getDate()).padStart(2, '0');
|
||||||
|
|
||||||
|
const horas = String(ahora.getHours()).padStart(2, '0');
|
||||||
|
const minutos = String(ahora.getMinutes()).padStart(2, '0');
|
||||||
|
const segundos = String(ahora.getSeconds()).padStart(2, '0');
|
||||||
|
|
||||||
|
return `${anio}-${mes}-${dia} ${horas}:${minutos}:${segundos}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectPaisValido(){
|
||||||
|
return paisSelect.value !== "NULL";
|
||||||
|
}
|
||||||
|
function selectNivelEstudioValido(){
|
||||||
|
return nivelEstudioSelect.value !== "NULL";
|
||||||
|
}
|
||||||
|
function selectGiroValido(){
|
||||||
|
return giroSelect.value !== "NULL";
|
||||||
|
}
|
||||||
|
function selectCalificacionServicioValido(){
|
||||||
|
return selectCalificacionServicio.value !== "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectEstadoValido(){
|
||||||
|
if(paisSelect.value === "1"){
|
||||||
|
return estadoSelect.value !== "NULL";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function selectMunicipioValido(){
|
||||||
|
if(paisSelect.value === "1"){
|
||||||
|
return municipioSelect.value !== "NULL";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function selectColoniaValido(){
|
||||||
|
if(paisSelect.value === "1"){
|
||||||
|
return coloniaSelect.value !== "NULL";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FUNCIONES
|
||||||
|
|
||||||
|
// EVENTOS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
// Añadir un evento de cambio al select de país
|
||||||
|
paisSelect.addEventListener("change", function() {
|
||||||
|
// Si el país es México, habilitar el campo de código postal
|
||||||
|
if (paisSelect.value === "1") {
|
||||||
|
inputCodigoPostal.removeAttribute("disabled");
|
||||||
|
inputButtonBuscarCodigoPostal.removeAttribute("disabled");
|
||||||
} else {
|
} else {
|
||||||
notificacion.textContent = resultado.mensaje;
|
// Si el país no es México, deshabilitar el campo de código postal
|
||||||
|
inputCodigoPostal.setAttribute("disabled", "disabled");
|
||||||
|
inputButtonBuscarCodigoPostal.setAttribute("disabled", "disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Añadir un evento al boton de buscar
|
||||||
|
buscarBtn.addEventListener("click", function () {
|
||||||
|
let inputCodigoPostal = document.getElementById("codigo_postal").value;
|
||||||
|
|
||||||
|
//verificar si el codigo postal esta vacio
|
||||||
|
if (inputCodigoPostal) {
|
||||||
|
|
||||||
|
// Limpia los selects antes de llenarlos
|
||||||
|
estadoSelect.innerHTML = "<option value='NULL'>Seleccione su estado</option>";
|
||||||
|
municipioSelect.innerHTML = "<option value='NULL'>Seleccione su municipio</option>";
|
||||||
|
coloniaSelect.innerHTML = "<option value='NULL'>Seleccione su colonia</option>";
|
||||||
|
|
||||||
|
// Construye la URL para la solicitud
|
||||||
|
let url = "./controllers/CatalogosController.php?codigo_postal=" + encodeURIComponent(inputCodigoPostal);
|
||||||
|
|
||||||
|
// Realiza una solicitud HTTP GET a la URL especificada
|
||||||
|
fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
//console.log("Estado de la respuesta:", response.status);
|
||||||
|
//console.log("Contenido de la respuesta:", response.json());
|
||||||
|
|
||||||
|
// Verifica si la respuesta del servidor es exitosa
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Error en la respuesta del servidor");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convertir la respuesta a JSON
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
// Verifica si se recibieron datos
|
||||||
|
if (data.length > 0) {
|
||||||
|
|
||||||
|
// Quitar disable a los selects
|
||||||
|
estadoSelect.removeAttribute("disabled");
|
||||||
|
estadoSelect.setAttribute("required", "required");
|
||||||
|
municipioSelect.removeAttribute("disabled");
|
||||||
|
municipioSelect.setAttribute("required", "required");
|
||||||
|
coloniaSelect.removeAttribute("disabled");
|
||||||
|
coloniaSelect.setAttribute("required", "required");
|
||||||
|
|
||||||
|
//Crea conjuntos para almacenar estados, ciudades y colonias
|
||||||
|
let estados = new Map();
|
||||||
|
let municipios = new Map();
|
||||||
|
let colonias = new Map();
|
||||||
|
|
||||||
|
// Itera sobre cada fila de datos recibidos
|
||||||
|
data.forEach(row => {
|
||||||
|
//console.log(row);
|
||||||
|
estados.set(row['id_estado'], row['estado']);
|
||||||
|
municipios.set(row['id_municipio'], row['municipio']);
|
||||||
|
colonias.set(row['id_colonia'], row['colonia']);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Añade las opciones de estados al elemento select
|
||||||
|
for (let [id_estado, estado] of estados) {
|
||||||
|
estadoSelect.innerHTML += "<option value='" + id_estado + "'>" + estado + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade las opciones de ciudades al elemento select
|
||||||
|
for (let [id_municipio, municipio] of municipios) {
|
||||||
|
municipioSelect.innerHTML += "<option value='" + id_municipio + "'>" + municipio + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade las opciones de colonias al elemento select
|
||||||
|
for (let [id_colonia, colonia] of colonias) {
|
||||||
|
coloniaSelect.innerHTML += "<option value='" + id_colonia + "'>" + colonia + "</option>";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert("No se encontraron datos para el código postal ingresado.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error en la solicitud:", error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("Por favor, ingrese un código postal.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
formulario.addEventListener("submit", async(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// Limpiar mensaje de error previo
|
||||||
|
notificacion.textContent = "";
|
||||||
|
notificacion.style.display = "none";
|
||||||
|
|
||||||
|
// Obtener valores de los campos
|
||||||
|
const idCandidato = document.getElementById('id_candidato').value;
|
||||||
|
const idPais = document.getElementById('id_pais').value;
|
||||||
|
const codigoPostal = document.getElementById('codigo_postal').value;
|
||||||
|
const idEstado = document.getElementById('id_estado').value;
|
||||||
|
const idMunicipio = document.getElementById('id_municipio').value;
|
||||||
|
const idColonia = document.getElementById('id_colonia').value;
|
||||||
|
|
||||||
|
const idNivel = document.getElementById('id_nivel').value;
|
||||||
|
const idGiro = document.getElementById('id_giro').value;
|
||||||
|
const nombreEmpresa = document.getElementById('nombre_empresa').value.trim();
|
||||||
|
const motivoExamen = document.getElementById('motivo_examen').value.trim();
|
||||||
|
|
||||||
|
const calificacionServicio = document.getElementById('calificacion_servicio').value;
|
||||||
|
const consentimientoPub = document.getElementById('consentimiento_pub').checked;
|
||||||
|
|
||||||
|
const fechaSalida = obtenerFechaActual();
|
||||||
|
|
||||||
|
|
||||||
|
let validaciones = [];
|
||||||
|
|
||||||
|
if(!selectPaisValido()){
|
||||||
|
validaciones.push("Seleccione un país. ");
|
||||||
|
}
|
||||||
|
if(!selectNivelEstudioValido()){
|
||||||
|
validaciones.push("Seleccione un nivel de estudio.");
|
||||||
|
}
|
||||||
|
if(!selectGiroValido()){
|
||||||
|
validaciones.push("Seleccione un giro. ");
|
||||||
|
}
|
||||||
|
if(!selectCalificacionServicioValido()){
|
||||||
|
validaciones.push("Seleccione una calificación de servicio. ");
|
||||||
|
}
|
||||||
|
if(!selectEstadoValido()){
|
||||||
|
validaciones.push("Seleccione un estado. ");
|
||||||
|
}
|
||||||
|
if(!selectMunicipioValido()){
|
||||||
|
validaciones.push("Seleccione un municipio. ");
|
||||||
|
}
|
||||||
|
if(!selectColoniaValido()){
|
||||||
|
validaciones.push("Seleccione una colonia. ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(validaciones.length > 0){
|
||||||
|
alert("Campos requeridos sin llenar");
|
||||||
|
notificacion.textContent = validaciones.join("\n");
|
||||||
|
notificacion.style.display = "block";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preparar datos para envío
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("id_candidato", idCandidato);
|
||||||
|
formData.append("id_pais", idPais);
|
||||||
|
formData.append("codigo_postal", codigoPostal);
|
||||||
|
formData.append("id_estado", idEstado);
|
||||||
|
formData.append("id_municipio", idMunicipio);
|
||||||
|
formData.append("id_colonia", idColonia);
|
||||||
|
formData.append("id_nivel", idNivel);
|
||||||
|
formData.append("id_giro", idGiro);
|
||||||
|
|
||||||
|
formData.append("nombre_empresa_institucion", nombreEmpresa);
|
||||||
|
formData.append("motivo_examen", motivoExamen);
|
||||||
|
|
||||||
|
formData.append("calificacion_servicio", calificacionServicio);
|
||||||
|
if (consentimientoPub) {
|
||||||
|
formData.append("consentimiento_pub", 1);
|
||||||
|
} else {
|
||||||
|
formData.append("consentimiento_pub", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
formData.append("fecha_salida", fechaSalida);
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
//alert("FORMULARIO ENVIADO");
|
||||||
|
|
||||||
|
// TEST: Pintar en consola datos del formData
|
||||||
|
// for (let [key, value] of formData.entries()) {
|
||||||
|
// console.log(key + ": ", value);
|
||||||
|
// }
|
||||||
|
|
||||||
|
try {
|
||||||
|
const respuesta = await fetch('controllers/registrarInfoCandidato.php', {
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
const resultado = await respuesta.json();
|
||||||
|
|
||||||
|
if (resultado.estado === "exitoso") {
|
||||||
|
console.log(resultado.res);
|
||||||
|
alert('Se guardó la información correctamente');
|
||||||
|
//window.location.href = 'inicio.html';
|
||||||
|
} else if(resultado.estado === "error") {
|
||||||
|
console.error(resultado.res);
|
||||||
|
notificacion.textContent = resultado.mensaje;
|
||||||
|
notificacion.style.display = "block";
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
notificacion.textContent = "Lo sentimos, ocurrió un error: " + error.message;
|
||||||
notificacion.style.display = "block";
|
notificacion.style.display = "block";
|
||||||
}
|
}
|
||||||
} catch (error) {
|
});
|
||||||
notificacion.textContent = "Lo sentimos, ocurrió un error: " + error.message;
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EVENTOS
|
||||||
notificacion.style.display = "block";
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
@ -11,18 +11,21 @@ class CandidatoModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insertar información de candidatos en la base de datos.
|
* Registra la información de un candidato y su fecha de salida
|
||||||
* @param int $id_candidato ID del candidato.
|
*
|
||||||
* @param int $id_pais ID del país.
|
* @param int $id_candidato ID del candidato
|
||||||
* @param int $id_estado ID del estado.
|
* @param int $id_pais ID del país
|
||||||
* @param int $id_municipio ID del municipio.
|
* @param int|null $id_estado ID del estado
|
||||||
* @param int $id_colonia ID de la colonia.
|
* @param int|null $id_municipio ID del municipio
|
||||||
* @param int $id_nivel ID del nivel máxímo de estudios.
|
* @param int|null $id_colonia ID de la colonia
|
||||||
* @param int $id_giro ID del giro de la empresa.
|
* @param int $id_nivel ID del nivel
|
||||||
* @param string $nombre_empresa_institucion Nombre de la empresa o institución de la que proviene el candidato.
|
* @param int $id_giro ID del giro
|
||||||
* @param string $motivo_examen Motivo del examen.
|
* @param string $nombre_empresa_institucion Nombre de la empresa o institución
|
||||||
* @param int $calificacion_servicio Calificación del servicio.
|
* @param string $motivo_examen Motivo del examen
|
||||||
* @param int $consentimiento_pub Consentimiento para la publicación de datos.
|
* @param int $calificacion_servicio Calificación del servicio
|
||||||
|
* @param int $consentimiento_pub Consentimiento de publicación
|
||||||
|
* @param string $fecha_salida Fecha de salida
|
||||||
|
* @return array Retorna un array asociativo con las claves "estado" y "mensaje"
|
||||||
*/
|
*/
|
||||||
public function registrarInfoCandidatos(
|
public function registrarInfoCandidatos(
|
||||||
$id_candidato,
|
$id_candidato,
|
||||||
|
@ -35,38 +38,126 @@ class CandidatoModel {
|
||||||
$nombre_empresa_institucion,
|
$nombre_empresa_institucion,
|
||||||
$motivo_examen,
|
$motivo_examen,
|
||||||
$calificacion_servicio,
|
$calificacion_servicio,
|
||||||
$consentimiento_pub
|
$consentimiento_pub,
|
||||||
|
$fecha_salida
|
||||||
) {
|
) {
|
||||||
$sql = "INSERT INTO info_candidatos ( id_candidato, id_pais, id_estado, id_municipio, id_colonia, id_nivel, id_giro, nombre_empresa_institucion, motivo_examen, calificacion_servicio, consentimiento_pub ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
try {
|
||||||
$stmt = $this->conn->prepare($sql);
|
|
||||||
if ($stmt === false) {
|
|
||||||
throw new Exception("Error en la preparación de la consulta: " . $this->conn->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt->bind_param(
|
|
||||||
"iiiiiiissii",
|
|
||||||
$id_candidato,
|
|
||||||
$id_pais,
|
|
||||||
$id_estado,
|
|
||||||
$id_municipio,
|
|
||||||
$id_colonia,
|
|
||||||
$id_nivel,
|
|
||||||
$id_giro,
|
|
||||||
$nombre_empresa_institucion,
|
|
||||||
$motivo_examen,
|
|
||||||
$calificacion_servicio,
|
|
||||||
$consentimiento_pub
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$stmt->execute()) {
|
|
||||||
throw new Exception("Error al insertar datos de información del candidato: " . $stmt->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$insertId = $stmt->insert_id;
|
|
||||||
|
|
||||||
$stmt->close();
|
// Si el país no es México (ID 1), se asignan valores nulos a los campos de ubicación
|
||||||
|
if ($id_pais !== 1) {
|
||||||
|
$id_estado = null;
|
||||||
|
$id_municipio = null;
|
||||||
|
$id_colonia = null;
|
||||||
|
}
|
||||||
|
|
||||||
return $insertId;
|
$sql = "INSERT INTO info_candidatos (
|
||||||
|
id_candidato, id_pais, id_estado, id_municipio, id_colonia,
|
||||||
|
id_nivel, id_giro, nombre_empresa_institucion, motivo_examen,
|
||||||
|
calificacion_servicio, consentimiento_pub
|
||||||
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
$stmt = $this->conn->prepare($sql);
|
||||||
|
if ($stmt === false) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error en la preparación de la consulta: " . $this->conn->error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->bind_param(
|
||||||
|
"iiiiiiissii",
|
||||||
|
$id_candidato,
|
||||||
|
$id_pais,
|
||||||
|
$id_estado,
|
||||||
|
$id_municipio,
|
||||||
|
$id_colonia,
|
||||||
|
$id_nivel,
|
||||||
|
$id_giro,
|
||||||
|
$nombre_empresa_institucion,
|
||||||
|
$motivo_examen,
|
||||||
|
$calificacion_servicio,
|
||||||
|
$consentimiento_pub
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error al insertar datos del candidato: " . $stmt->error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// Registrar fecha de salida
|
||||||
|
$resultadoFecha = $this->registrarFechaSalida($id_candidato, $fecha_salida);
|
||||||
|
if (isset($resultadoFecha["estado"]) && $resultadoFecha["estado"] === "error") {
|
||||||
|
return $resultadoFecha; // Propagar el error desde registrarFechaSalida
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retornar éxito
|
||||||
|
return [
|
||||||
|
"estado" => "exitoso",
|
||||||
|
"mensaje" => $id_candidato
|
||||||
|
];
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error en el registro: " . $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registra la fecha de salida de un candidato
|
||||||
|
*
|
||||||
|
* @param int $id_candidato ID del candidato
|
||||||
|
* @param string $fecha_salida Fecha de salida
|
||||||
|
* @return array Retorna un array asociativo con las claves "estado" y "mensaje"
|
||||||
|
*/
|
||||||
|
private function registrarFechaSalida($id_candidato, $fecha_salida) {
|
||||||
|
try {
|
||||||
|
// Si no hay fecha de salida, retornar éxito sin hacer nada
|
||||||
|
if (empty($fecha_salida)) {
|
||||||
|
return [
|
||||||
|
"estado" => "exitoso",
|
||||||
|
"mensaje" => "No se registró fecha de salida"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consulta update
|
||||||
|
$sql = "UPDATE candidato SET fecha_salida = ? WHERE id_candidato = ?";
|
||||||
|
$stmt = $this->conn->prepare($sql);
|
||||||
|
|
||||||
|
if ($stmt === false) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error en la preparación de la consulta de fecha: " . $this->conn->error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->bind_param("si",$fecha_salida,$id_candidato);
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error al registrar fecha de salida: " . $stmt->error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return [
|
||||||
|
"estado" => "exitoso",
|
||||||
|
"mensaje" => "Fecha de salida registrada correctamente"
|
||||||
|
];
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error al registrar fecha de salida: " . $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +208,73 @@ class CandidatoModel {
|
||||||
return $insertId;
|
return $insertId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verificar si ya existe un registro de información del candidato en la base de datos.
|
||||||
|
* @param int $id_candidato ID del candidato.
|
||||||
|
* @return bool true si existe un registro, false en caso contrario.
|
||||||
|
*/
|
||||||
|
public function verificarRegistroInfoCandidato($id_candidato) {
|
||||||
|
$sql = "SELECT COUNT(*) as count FROM info_candidatos WHERE id_candidato = ?";
|
||||||
|
$stmt = $this->conn->prepare($sql);
|
||||||
|
if ($stmt === false) {
|
||||||
|
throw new Exception("Error en la preparación de la consulta: " . $this->conn->error);
|
||||||
|
}
|
||||||
|
$stmt->bind_param("i", $id_candidato);
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
throw new Exception("Error al ejecutar la consulta: " . $stmt->error);
|
||||||
|
}
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
$stmt->close();
|
||||||
|
return $row['count'] > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function existeIdCandidato($id_candidato) {
|
||||||
|
try {
|
||||||
|
$sql = "SELECT COUNT(*) as count FROM candidato WHERE id_candidato = ?";
|
||||||
|
|
||||||
|
$stmt = $this->conn->prepare($sql);
|
||||||
|
if ($stmt === false) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error en la preparación de la consulta: " . $this->conn->error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->bind_param("i", $id_candidato);
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error al ejecutar la consulta: " . $stmt->error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$stmt->close();
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
|
||||||
|
if($row['count'] > 0){
|
||||||
|
return [
|
||||||
|
"estado" => "exitoso",
|
||||||
|
"mensaje" => "ID de candidato existe"
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "ID de candidato no existe"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return [
|
||||||
|
"estado" => "error",
|
||||||
|
"mensaje" => "Error al verificar ID de candidato: " . $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function obtenerCandidatoPorId($id_candidato) {
|
public function obtenerCandidatoPorId($id_candidato) {
|
||||||
$sql = "SELECT * FROM candidato WHERE id_candidato = ?";
|
$sql = "SELECT * FROM candidato WHERE id_candidato = ?";
|
||||||
$stmt = $this->conn->prepare($sql);
|
$stmt = $this->conn->prepare($sql);
|
||||||
|
|
|
@ -9,98 +9,15 @@ class Catalogos{
|
||||||
$this->conn = Database::getInstance();
|
$this->conn = Database::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function obtenerGeneros(){
|
|
||||||
$sql = "SELECT id_genero, descripcion FROM genero";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$generos = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$generos[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $generos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function obtenerRangosEdad(){
|
|
||||||
$sql = "SELECT id_rango_edad, descripcion FROM rango_edad";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$rangos = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$rangos[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rangos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function obtenerTiposIdentificacion(){
|
|
||||||
$sql = "SELECT id_tipo_id, descripcion FROM tipo_identificacion ORDER BY descripcion";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$tipos = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$tipos[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tipos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function obtenerNivelesEstudio(){
|
|
||||||
$sql = "SELECT id_nivel, descripcion FROM nivel_estudio";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$niveles = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$niveles[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $niveles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function obtenerGiros(){
|
|
||||||
$sql = "SELECT id_giro, descripcion FROM giro ORDER BY descripcion";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$giros = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$giros[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $giros;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function obtenerExamenes(){
|
|
||||||
$sql = "SELECT id_examen, nombre_examen FROM examen ORDER BY nombre_examen";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$examenes = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$examenes[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $examenes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function obtenerPaises(){
|
|
||||||
$sql = "SELECT int as id, nombre FROM paises ORDER BY nombre";
|
|
||||||
$result = $this->conn->query($sql);
|
|
||||||
|
|
||||||
$paises = [];
|
|
||||||
while($row = $result->fetch_assoc()){
|
|
||||||
$paises[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $paises;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtiene el estado, municipio y colonia en base al código postal proporcionado.
|
* Obtiene el estado, municipio y colonia en base al código postal proporcionado.
|
||||||
* @param int $codigo_postal El código postal a buscar.
|
* @param int $codigo_postal El código postal a buscar.
|
||||||
|
* @return array Un array con los datos de estado, municipio y colonia.
|
||||||
*/
|
*/
|
||||||
public function obtenerInfiCodigoPostal($codigo_postal){
|
public function obtenerInfiCodigoPostal($codigo_postal){
|
||||||
|
|
||||||
// Consulta SQL para obtener estado, ciudad y colonia en base al código postal
|
// Consulta SQL para obtener estado, ciudad y colonia en base al código postal
|
||||||
$sql = "SELECT e.nombre AS estado, m.nombre AS municipio, c.nombre AS colonia
|
$sql = "SELECT e.id AS id_estado, e.nombre AS estado, m.id AS id_municipio, m.nombre AS municipio, c.id AS id_colonia, c.nombre AS colonia
|
||||||
FROM colonias c
|
FROM colonias c
|
||||||
JOIN municipios m ON c.municipio = m.id
|
JOIN municipios m ON c.municipio = m.id
|
||||||
JOIN estados e ON m.estado = e.id
|
JOIN estados e ON m.estado = e.id
|
||||||
|
@ -114,18 +31,111 @@ class Catalogos{
|
||||||
// Obtener los resultados
|
// Obtener los resultados
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
$stmt->close();
|
||||||
|
$data = [];
|
||||||
// Verificar si hay resultados
|
// Verificar si hay resultados
|
||||||
if ($result->num_rows > 0) {
|
if ($result->num_rows > 0) {
|
||||||
$data = [];
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
$data[] = $row; // Agregar cada resultado a un array
|
$data[] = $row; // Agregar cada resultado a un array
|
||||||
}
|
}
|
||||||
return json_encode($data); // Devolver los resultados en formato JSON
|
return $data;
|
||||||
} else {
|
} else {
|
||||||
return json_encode([]); // Si no hay resultados, devolver un array vacío
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->close();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene los giros.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function obtenerGiros(){
|
||||||
|
$sql = "SELECT id_giro, descripcion FROM giro ORDER BY descripcion";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
|
||||||
|
$giros = [];
|
||||||
|
while($row = $result->fetch_assoc()){
|
||||||
|
$giros[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $giros;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene los nombres de los examenes disponibles.
|
||||||
|
* @return array Lista del nombre de la institución a la que pertenece el examen.
|
||||||
|
*/
|
||||||
|
public function obtenerNombresExamenes(){
|
||||||
|
$sql = "SELECT id_examen, nombre_examen FROM examen ORDER BY nombre_examen";
|
||||||
|
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
|
||||||
|
$examenes = [];
|
||||||
|
while($row = $result->fetch_assoc()){
|
||||||
|
$examenes[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $examenes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtener los tipos de identificación.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function obtenerTiposIdentificacion(){
|
||||||
|
$sql = "SELECT id_tipo_id, descripcion FROM tipo_identificacion ORDER BY descripcion";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
|
||||||
|
$tipos = [];
|
||||||
|
while($row = $result->fetch_assoc()){
|
||||||
|
$tipos[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tipos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene los rangos de edad.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function obtenerRangosEdad(){
|
||||||
|
$sql = "SELECT id_rango_edad, descripcion FROM rango_edad";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
|
||||||
|
$rangos = [];
|
||||||
|
while($row = $result->fetch_assoc()){
|
||||||
|
$rangos[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rangos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene los niveles de estudio.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function obtenerNivelesEstudio(){
|
||||||
|
$sql = "SELECT id_nivel, descripcion FROM nivel_estudio";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
|
||||||
|
$niveles = [];
|
||||||
|
while($row = $result->fetch_assoc()){
|
||||||
|
$niveles[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $niveles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function obtenerNombresEmpresasInstituciones(){
|
||||||
|
$sql = "SELECT DISTINCT nombre_empresa_institucion FROM info_candidatos";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
|
||||||
|
$empresas = [];
|
||||||
|
while($row = $result->fetch_assoc()){
|
||||||
|
$empresas[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $empresas;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
7
test.php
7
test.php
|
@ -4,11 +4,4 @@
|
||||||
|
|
||||||
// UsuarioController::registrarUsuario("root", "root");
|
// UsuarioController::registrarUsuario("root", "root");
|
||||||
|
|
||||||
|
|
||||||
require_once __DIR__ . '/models/Catalogos.php';
|
|
||||||
$catalogoModel = new Catalogos();
|
|
||||||
$array = $catalogoModel->obtenerGeneros();
|
|
||||||
|
|
||||||
// Pintar arraycompleto en bruto de la variable $arrayInfoCodigoPostal
|
|
||||||
print_r($array);
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue