solucion de conlictos 2
This commit is contained in:
parent
bd62a804f1
commit
ecded5fe66
|
@ -1 +0,0 @@
|
|||
.idea/
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
@ -1,4 +0,0 @@
|
|||
-- Crear usuario que utiliza el sistema
|
||||
CREATE USER lania@localhost IDENTIFIED BY 'l4n1@Cc';
|
||||
GRANT ALL PRIVILEGES ON lania_cc.* TO lania@localhost;
|
||||
FLUSH PRIVILEGES;
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
// $db = Database::getInstance();
|
||||
|
||||
class Database {
|
||||
private static $instance = null;
|
||||
private $mysqli;
|
||||
private $host;
|
||||
private $dbname;
|
||||
private $user;
|
||||
private $password;
|
||||
private $Database;
|
||||
|
||||
public function __construct() {
|
||||
$host = 'localhost';
|
||||
$dbname = 'lania_cc';
|
||||
$user = 'lania';
|
||||
$password = 'l4n1@Cc';
|
||||
|
||||
try {
|
||||
$this->mysqli = new mysqli($host, $user, $password, $dbname);
|
||||
|
||||
// Verificar conexión
|
||||
if ($this->mysqli->connect_error) {
|
||||
throw new Exception("Database: Conexión fallida. " . $this->mysqli->connect_error);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Database: Error . " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new Database();
|
||||
}
|
||||
return self::$instance->mysqli;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/CandidatoController.php';
|
||||
|
||||
// Manejar la solicitud POST para registrar un candidato
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$insertId = CandidatoController::registrarCandidato();
|
||||
if($insertId > 0){
|
||||
echo json_encode(['registroExitoso' => true, 'message' => 'Se ha registrado el candidato correctamente.']);
|
||||
} else {
|
||||
echo json_encode(['registroExitoso' => false, 'message' => 'Error al registrar el candidato.']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/CandidatoController.php';
|
||||
|
||||
// Manejar la solicitud POST para registrar información un candidato
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$respuesta = CandidatoController::registrarInfoCandidato();
|
||||
|
||||
if(isset($respuesta["estado"]) && $respuesta["estado"] === "exitoso") {
|
||||
echo json_encode([
|
||||
"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"]
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
// filepath: c:\xampp\htdocs\Proyecto_Lania\LANIA_Proyecto\php\buscarCodigo.php
|
||||
include 'conexionBd.php'; // Asegúrate de que el archivo esté en la ruta correcta
|
||||
|
||||
header('Content-Type: application/json'); // Aseguramos que la respuesta sea JSON
|
||||
|
||||
// Crear instancia de la conexión
|
||||
$conexion = new Conexion();
|
||||
$conexionBD = $conexion->conectar(); // Establecer conexión
|
||||
|
||||
// Verificar que se ha enviado el parámetro 'codigo_postal'
|
||||
if (isset($_GET['codigo_postal'])) {
|
||||
$codigo_postal = $_GET['codigo_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
|
||||
FROM colonias c
|
||||
JOIN municipios m ON c.municipio = m.id
|
||||
JOIN estados e ON m.estado = e.id
|
||||
WHERE c.codigo_postal = ?";
|
||||
|
||||
// Verificar que la conexión a la base de datos esté activa
|
||||
if ($conexionBD) {
|
||||
// Preparar la sentencia SQL
|
||||
$stmt = $conexionBD->prepare($sql);
|
||||
$stmt->bind_param("i", $codigo_postal); // El parámetro es un entero (i)
|
||||
$stmt->execute();
|
||||
|
||||
// Obtener los resultados
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Verificar si hay resultados
|
||||
if ($result->num_rows > 0) {
|
||||
$data = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$data[] = $row; // Agregar cada resultado a un array
|
||||
}
|
||||
echo json_encode($data); // Devolver los resultados en formato JSON
|
||||
} else {
|
||||
echo json_encode([]); // Si no hay resultados, devolver un array vacío
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["error" => "Conexión a la base de datos fallida."]);
|
||||
}
|
||||
|
||||
$conexionBD->close();
|
||||
} else {
|
||||
// Si no se recibe un código postal, respondemos con un error
|
||||
echo json_encode(["error" => "Código postal no proporcionado."]);
|
||||
}
|
||||
?>
|
|
@ -579,5 +579,3 @@ main .btn-send:hover {
|
|||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
|
||||
<link rel="stylesheet" href="css/form.css">
|
||||
<title>AdminSite</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- SIDEBAR -->
|
||||
<section id="sidebar">
|
||||
<a href="inicio.html" class="brand"><i class='bx bx-code-alt icon' ></i> LANIA</a>
|
||||
<!-- <a href="#" class="brand">
|
||||
<img src="img/lania_logo.png" alt="Logo" style="height: 40px;">
|
||||
</a> -->
|
||||
<ul class="side-menu">
|
||||
<li><a href="#" class="active"><i class='bx bxs-dashboard icon' ></i> Dashboard</a></li>
|
||||
<li class="divider" data-text="main">Main</li>
|
||||
<li>
|
||||
<a href="#"><i class='bx bxs-inbox icon' ></i> Elements <i class='bx bx-chevron-right icon-right' ></i></a>
|
||||
<ul class="side-dropdown">
|
||||
<li><a href="#">Alert</a></li>
|
||||
<li><a href="#">Badges</a></li>
|
||||
<li><a href="#">Breadcrumbs</a></li>
|
||||
<li><a href="#">Button</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#"><i class='bx bxs-chart icon' ></i> Charts</a></li>
|
||||
<li><a href="#"><i class='bx bxs-widget icon' ></i> Widgets</a></li>
|
||||
<li class="divider" data-text="table and forms">Table and forms</li>
|
||||
<li><a href="#"><i class='bx bx-table icon' ></i> Tables</a></li>
|
||||
<li>
|
||||
<a href="#"><i class='bx bxs-notepad icon' ></i> Formularios <i class='bx bx-chevron-right icon-right' ></i></a>
|
||||
<ul class="side-dropdown">
|
||||
<li><a href="form_datos_basicos.html">Datos Básicos</a></li>
|
||||
<li><a href="form_datos_extendidos.html">Datos Extendidos</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- <div class="ads">
|
||||
<div class="wrapper">
|
||||
<a href="#" class="btn-upgrade">Upgrade</a>
|
||||
<p>Become a <span>PRO</span> member and enjoy <span>All Features</span></p>
|
||||
</div>
|
||||
</div> -->
|
||||
</section>
|
||||
<!-- SIDEBAR -->
|
||||
|
||||
<!-- NAVBAR -->
|
||||
<section id="content">
|
||||
<!-- NAVBAR -->
|
||||
<nav>
|
||||
<i class='bx bx-menu toggle-sidebar' ></i>
|
||||
<form action="#">
|
||||
<div class="form-group">
|
||||
<input type="text" placeholder="Buscar...">
|
||||
<i class='bx bx-search icon' ></i>
|
||||
</div>
|
||||
</form>
|
||||
<a href="#" class="nav-link">
|
||||
<i class='bx bxs-bell icon' ></i>
|
||||
<span class="badge">5</span>
|
||||
</a>
|
||||
<a href="#" class="nav-link">
|
||||
<i class='bx bxs-message-square-dots icon' ></i>
|
||||
<span class="badge">8</span>
|
||||
</a>
|
||||
<span class="divider"></span>
|
||||
<div class="profile">
|
||||
<img src="https://images.unsplash.com/photo-1517841905240-472988babdf9?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8cGVvcGxlfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="">
|
||||
<ul class="profile-link">
|
||||
<li><a href="#"><i class='bx bxs-user-circle icon' ></i> Profile</a></li>
|
||||
<li><a href="#"><i class='bx bxs-cog' ></i> Settings</a></li>
|
||||
<li><a href="#"><i class='bx bxs-log-out-circle' ></i> Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- NAVBAR -->
|
||||
|
||||
<!-- MAIN -->
|
||||
<main>
|
||||
<h1 class="title">Datos básicos</h1>
|
||||
<ul class="breadcrumbs">
|
||||
<li><a href="#">Formularios</a></li>
|
||||
<li class="divider">/</li>
|
||||
<li><a href="#" class="active">Datos básicos</a></li>
|
||||
</ul>
|
||||
|
||||
<h3 class="title2">¡Bienvenido (a)!</h3>
|
||||
<p>Nos gustaría conocerte mejor</p>
|
||||
<br>
|
||||
<form id="formulario-datos-basicos" action="" method="POST">
|
||||
<input type="hidden" id="id_candidato" name="id_candidato">
|
||||
<input type="hidden" id="fecha_entrada" name="fecha_entrada" value="">
|
||||
<input type="hidden" id="fecha_salida" name="fecha_salida" value="">
|
||||
|
||||
<div>
|
||||
<label for ="nombres">Nombres:</label>
|
||||
<input type="text" id="nombres" name="nombres" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="primer_apellido">Primer apellido:</label>
|
||||
<input type="text" id="primer_apellido" name="primer_apellido" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="segundo_apellido">Segundo apellido:</label>
|
||||
<input type="text" id="segundo_apellido" name="segundo_apellido" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="correo">Correo electrónico:</label>
|
||||
<input type="text" id="correo" name="correo" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="telefono">Teléfono:</label>
|
||||
<input type="number" id="telefono" name="telefono" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_examen">Examen:</label>
|
||||
<select name="id_examen" id="id_examen" required>
|
||||
<option value="">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>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_tipo_id">Tipo de Identificación:</label>
|
||||
<select name="id_tipo_id" id="id_tipo_id" required>
|
||||
<option value="">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>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_rango_edad">Rango de edad:</label>
|
||||
<select name="id_rango_edad" id="id_rango_edad" required>
|
||||
<option value="">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>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_genero">Género:</label>
|
||||
<select name="id_genero" id="id_genero" required>
|
||||
<option value="">Selecciona un género</option>
|
||||
<option value="1">Masculino</option>
|
||||
<option value="2">Femenino</option>
|
||||
<option value="3">Prefiero no decir</option>
|
||||
</select><br>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<button type="submit">Enviar</button>
|
||||
|
||||
<div id="mensaje-error" class="mensaje-error"><p>hola</p></div>
|
||||
</form>
|
||||
|
||||
</main>
|
||||
<!-- MAIN -->
|
||||
</section>
|
||||
<!-- NAVBAR -->
|
||||
|
||||
<script src="js/form.js"></script>
|
||||
<script src="js/form_datos_basicos.js"""
|
||||
<script src="https://website-widgets.pages.dev/dist/sienna.min.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -4,8 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
|
||||
<link rel="stylesheet" href="../css/inicio.css">
|
||||
|
||||
<link rel="stylesheet" href="css/inicio.css">
|
||||
<title>AdminSite</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -28,13 +27,13 @@
|
|||
</li>
|
||||
<li><a href="#"><i class='bx bxs-chart icon' ></i> Charts</a></li>
|
||||
<li><a href="#"><i class='bx bxs-widget icon' ></i> Widgets</a></li>
|
||||
<li class="divider" data-text="tablas y formularios">Tablas y formularios</li>
|
||||
<li><a href="#"><i class='bx bx-table icon' ></i> Tablas</a></li>
|
||||
<li class="divider" data-text="table and forms">Table and forms</li>
|
||||
<li><a href="#"><i class='bx bx-table icon' ></i> Tables</a></li>
|
||||
<li>
|
||||
<a href="#"><i class='bx bxs-notepad icon' ></i> Formularios <i class='bx bx-chevron-right icon-right' ></i></a>
|
||||
<ul class="side-dropdown">
|
||||
<li><a href="formulario-candidato.html">Registro de candidato</a></li>
|
||||
<li><a href="formulario-datos-candidato.php">Datos de candidato</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>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -86,109 +85,52 @@
|
|||
<li class="divider">/</li>
|
||||
<li><a href="#" class="active">Dashboard</a></li>
|
||||
</ul>
|
||||
|
||||
<!--Añadido nuevo -->
|
||||
<div class="select-data">
|
||||
<div class="info-data">
|
||||
<div class="card">
|
||||
<div class="head">
|
||||
<i class='bx bx-trending-up icon'></i>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="display: flex; gap: 20px; margin: 10px 0;">
|
||||
<!-- Campo: Edad -->
|
||||
<div style="flex: 1;">
|
||||
<label class="form-label" for="id_rango_edad">Edad</label>
|
||||
<select class="border rounded-pill shadow-sm form-select" id="id_rango_edad" required>
|
||||
<option value="NULL">Seleccione una opción</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Campo: Género -->
|
||||
<div style="flex: 1;">
|
||||
<label class="form-label" for="id_genero" style="margin: 10px 0px 5px;">Género</label>
|
||||
<select class="border rounded-pill shadow-sm form-select" id="id_genero" required="">
|
||||
<option value="NULL">Seleccione una opción</option>
|
||||
<option value="1">Masculino</option>
|
||||
<option value="2">Femenino</option>
|
||||
<option value="3">Prefiero no decir</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div style="flex: 1;">
|
||||
<label class="form-label" for="id_examen" style="margin: 10px 0px 5px;">Examen</label>
|
||||
<select class="border rounded-pill shadow-sm form-select" id="id_examen" required="">
|
||||
<option value="NULL">Seleccione una opción</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Fecha</h2>
|
||||
<h3>Ingresa una fecha de inicio:</h3>
|
||||
<br>
|
||||
<input type="date" id="date1" name="date1">
|
||||
<h3>Ingresa una fecha de final:</h3>
|
||||
<input type="date" id="date2" name="date2">
|
||||
<br>
|
||||
<button type="button" id="buscar">Buscar</button>
|
||||
<button type="button" id="limpiar">Limpiar</button>
|
||||
<br>
|
||||
<div class="content-data">
|
||||
<div class="head">
|
||||
<h3>Resultado de registros en el rango de fecha ingresado</h3>
|
||||
<div class="menu">
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart">
|
||||
<div id="chart5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<br>
|
||||
<h3>Promedio de géneros:</h3>
|
||||
<div class="info-data">
|
||||
<div class="card" id="card-femenino">
|
||||
<h2>1500</h2>
|
||||
<p>Traffic</p>
|
||||
</div>
|
||||
<i class='bx bx-trending-up icon' ></i>
|
||||
</div>
|
||||
<span class="progress" data-value="40%"></span>
|
||||
<span class="label">40%</span>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="head">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<i class='bx bx-female' style="font-size: 24px; color: #e91e63;"></i>
|
||||
<div>
|
||||
<h2>0</h2>
|
||||
<p>Femenino</p>
|
||||
<h2>234</h2>
|
||||
<p>Sales</p>
|
||||
</div>
|
||||
<i class='bx bx-trending-down icon down' ></i>
|
||||
</div>
|
||||
<span class="progress" data-value="60%"></span>
|
||||
<span class="label">60%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="card-masculino">
|
||||
<div class="card">
|
||||
<div class="head">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<i class='bx bx-male' style="font-size: 24px; color: #2196f3;"></i>
|
||||
<div>
|
||||
<h2>0</h2>
|
||||
<p>Masculino</p>
|
||||
<h2>465</h2>
|
||||
<p>Pageviews</p>
|
||||
</div>
|
||||
<i class='bx bx-trending-up icon' ></i>
|
||||
</div>
|
||||
|
||||
<span class="progress" data-value="30%"></span>
|
||||
<span class="label">30%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="card-nodefinido">
|
||||
<div class="card">
|
||||
<div class="head">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<i class='bx bx-male' style="font-size: 24px; color: black;"></i>
|
||||
<div>
|
||||
<h2>0</h2>
|
||||
<p>Prefiero no decirlo</p>
|
||||
<h2>235</h2>
|
||||
<p>Visitors</p>
|
||||
</div>
|
||||
<i class='bx bx-trending-up icon' ></i>
|
||||
</div>
|
||||
<span class="progress" data-value="80%"></span>
|
||||
<span class="label">80%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="data">
|
||||
<div class="content-data">
|
||||
<div class="head">
|
||||
|
@ -255,17 +197,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- MAIN -->
|
||||
</section>
|
||||
<!-- NAVBAR -->
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
||||
<script type="module" src="../js/inicio.js"></script>
|
||||
<script type="module" src="js/inicio.js"></script>
|
||||
<script src="https://website-widgets.pages.dev/dist/sienna.min.js" defer></script>
|
||||
<<<<<<< HEAD:views/inicio.html
|
||||
<script src="../js/formulario-candidato.js"></script>
|
||||
<script src="../js/tarjetasPromedio.js"></script>
|
||||
|
||||
=======
|
||||
>>>>>>> parent of a8e2895 (archivos de merge desde la rama recuperar-cambios):inicio.html
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,119 @@
|
|||
const formulario = document.getElementById("formulario-datos-basicos");
|
||||
const notificacion = document.getElementById("mensaje-error");
|
||||
|
||||
// Función para validar el nombre
|
||||
function validarNombre(nombre) {
|
||||
const nombreRegex = /^[a-zA-ZÀ-ÿ\s]+$/; // Permite letras y espacios
|
||||
return nombreRegex.test(nombre);
|
||||
}
|
||||
|
||||
//funcion para validar apellido
|
||||
function validarApellido(apellido) {
|
||||
const apellidoRegex = /^[a-zA-ZÀ-ÿ]+$/; // Permite solo letras, sin espacios
|
||||
return apellidoRegex.test(apellido);
|
||||
}
|
||||
|
||||
// Función para validar número telefónico (10 dígitos)
|
||||
function validarTelefono(telefono) {
|
||||
const telefonoRegex = /^\d{10}$/;
|
||||
return telefonoRegex.test(telefono);
|
||||
}
|
||||
|
||||
// Función para validar correo electrónico
|
||||
function validarCorreo(correo) {
|
||||
const correoRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
return correoRegex.test(correo);
|
||||
}
|
||||
|
||||
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 fechaEntrada = document.getElementById('fecha_entrada').value;
|
||||
const fechaSalida = document.getElementById('fecha_salida').value;
|
||||
|
||||
const nombres = document.getElementById('nombres').value.trim();
|
||||
const primerApellido = document.getElementById('primer_apellido').value.trim();
|
||||
const segundoApellido = document.getElementById('segundo_apellido').value.trim();
|
||||
const correo = document.getElementById('correo').value.trim();
|
||||
const telefono = document.getElementById('telefono').value.trim();
|
||||
|
||||
const idExamen = document.getElementById('id_examen').value;
|
||||
const idTipoId = document.getElementById('id_tipo_id').value;
|
||||
const idRangoEdad = document.getElementById('id_rango_edad').value;
|
||||
const idGenero = document.getElementById('id_genero').value;
|
||||
|
||||
// Validaciones
|
||||
let errores = [];
|
||||
|
||||
// Validar correo electrónico
|
||||
if (!validarCorreo(correo)) {
|
||||
errores.push("El correo electrónico no es válido. ");
|
||||
}
|
||||
|
||||
// validar nombre
|
||||
if (!validarNombre(nombres)) {
|
||||
errores.push("El nombre no tiene un formato válido. ");
|
||||
}
|
||||
|
||||
// validar apellido
|
||||
if (!validarApellido(primerApellido)) {
|
||||
errores.push("El primer apellido no tiene un formato válido. ");
|
||||
}
|
||||
|
||||
if (!validarApellido(segundoApellido)) {
|
||||
errores.push("El segundo apellido no tiene un formato válido. ");
|
||||
}
|
||||
|
||||
// Validar número telefónico
|
||||
if (!validarTelefono(telefono)) {
|
||||
errores.push("El número telefónico debe ser un número de 10 dígitos. ");
|
||||
}
|
||||
|
||||
// Si hay errores, mostrarlos y detener el envío
|
||||
if (errores.length > 0) {
|
||||
notificacion.textContent = errores.join("\n");
|
||||
notificacion.style.display = "block";
|
||||
return;
|
||||
}
|
||||
|
||||
// Preparar datos para envío
|
||||
const formData = new FormData();
|
||||
formData.append("id_candidato", idCandidato);
|
||||
formData.append("fecha_entrada", fechaEntrada);
|
||||
formData.append("fecha_salida", fechaSalida);
|
||||
formData.append("nombres", nombres);
|
||||
formData.append("primer_apellido", primerApellido);
|
||||
formData.append("segundo_apellido", segundoApellido);
|
||||
formData.append("correo", correo);
|
||||
formData.append("telefono", telefono);
|
||||
formData.append("id_examen", idExamen);
|
||||
formData.append("id_tipo_id", idTipoId);
|
||||
formData.append("id_rango_edad", idRangoEdad);
|
||||
formData.append("id_genero", idGenero);
|
||||
|
||||
try {
|
||||
const respuesta = await fetch('ruta', {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const resultado = await respuesta.json();
|
||||
|
||||
if (resultado.datosIngresados) {
|
||||
alert('Se guardó la información correctamente');
|
||||
window.location.href = 'inicio.html';
|
||||
} else {
|
||||
notificacion.textContent = resultado.mensaje;
|
||||
notificacion.style.display = "block";
|
||||
}
|
||||
} catch (error) {
|
||||
notificacion.textContent = "Lo sentimos, ocurrió un error: " + error.message;
|
||||
notificacion.style.display = "block";
|
||||
}
|
||||
});
|
|
@ -0,0 +1,61 @@
|
|||
const formulario = document.getElementById("formulario-datos-extendido");
|
||||
const notificacion = document.getElementById("mensaje-error");
|
||||
|
||||
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; // campo numérico, no necesita trim
|
||||
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;
|
||||
|
||||
|
||||
// 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", nombreEmpresa);
|
||||
formData.append("motivo_examen", motivoExamen);
|
||||
formData.append("calificacion_servicio", calificacionServicio);
|
||||
formData.append("consentimiento_pub", consentimientoPub ? 1 : 0);
|
||||
try {
|
||||
const respuesta = await fetch('ruta', {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const resultado = await respuesta.json();
|
||||
|
||||
if (resultado.datosIngresados) {
|
||||
alert('Se guardó la información correctamente');
|
||||
window.location.href = 'inicio.html';
|
||||
} else {
|
||||
notificacion.textContent = resultado.mensaje;
|
||||
notificacion.style.display = "block";
|
||||
}
|
||||
} catch (error) {
|
||||
notificacion.textContent = "Lo sentimos, ocurrió un error: " + error.message;
|
||||
notificacion.style.display = "block";
|
||||
}
|
||||
});
|
|
@ -1,226 +0,0 @@
|
|||
const formulario = document.getElementById("formulario-datos-basicos");
|
||||
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
|
||||
function validarNombre(nombre) {
|
||||
const nombreRegex = /^[a-zA-ZÀ-ÿ\s]+$/; // Permite letras y espacios
|
||||
return nombreRegex.test(nombre);
|
||||
}
|
||||
|
||||
//funcion para validar apellido
|
||||
function validarApellido(apellido) {
|
||||
const apellidoRegex = /^[a-zA-ZÀ-ÿ]+$/; // Permite solo letras, sin espacios
|
||||
return apellidoRegex.test(apellido);
|
||||
}
|
||||
|
||||
// Función para validar número telefónico (10 dígitos)
|
||||
function validarTelefono(telefono) {
|
||||
const telefonoRegex = /^\d{10}$/;
|
||||
return telefonoRegex.test(telefono);
|
||||
}
|
||||
|
||||
// Función para validar correo electrónico
|
||||
function validarCorreo(correo) {
|
||||
const correoRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
return correoRegex.test(correo);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Validaciones
|
||||
|
||||
formulario.addEventListener("submit", async(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
// Limpiar mensaje de error previo
|
||||
notificacion.textContent = "";
|
||||
notificacion.style.display = "none";
|
||||
|
||||
// Obtener valores de los campos
|
||||
const nombres = document.getElementById('nombres').value.trim();
|
||||
const primerApellido = document.getElementById('primer_apellido').value.trim();
|
||||
const segundoApellido = document.getElementById('segundo_apellido').value.trim();
|
||||
const correo = document.getElementById('correo').value.trim();
|
||||
const telefono = document.getElementById('telefono').value.trim();
|
||||
|
||||
const idExamen = document.getElementById('id_examen').value;
|
||||
const idTipoId = document.getElementById('id_tipo_id').value;
|
||||
const idRangoEdad = document.getElementById('id_rango_edad').value;
|
||||
const idGenero = document.getElementById('id_genero').value;
|
||||
|
||||
// Validaciones
|
||||
let errores = [];
|
||||
|
||||
// Validar correo electrónico
|
||||
if (!validarCorreo(correo)) {
|
||||
errores.push("⦁ El correo electrónico no es válido. ");
|
||||
}
|
||||
|
||||
// validar nombre
|
||||
if (!validarNombre(nombres)) {
|
||||
errores.push("⦁ El nombre no tiene un formato válido. ");
|
||||
}
|
||||
|
||||
// validar apellido
|
||||
if (!validarApellido(primerApellido)) {
|
||||
errores.push("⦁ El primer apellido no tiene un formato válido. ");
|
||||
}
|
||||
|
||||
if (!validarApellido(segundoApellido)) {
|
||||
errores.push("⦁ El segundo apellido no tiene un formato válido. ");
|
||||
}
|
||||
|
||||
// Validar número telefónico
|
||||
if (!validarTelefono(telefono)) {
|
||||
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
|
||||
if (errores.length > 0) {
|
||||
alert("Datos del formulario incompletos\n" + errores.join("\n"));
|
||||
//notificacion.textContent = errores.join("\n");
|
||||
//notificacion.style.display = "block";
|
||||
return;
|
||||
}
|
||||
|
||||
// Preparar datos para envío
|
||||
const formData = new FormData();
|
||||
formData.append("nombres", nombres);
|
||||
formData.append("primer_apellido", primerApellido);
|
||||
formData.append("segundo_apellido", segundoApellido);
|
||||
formData.append("correo", correo);
|
||||
formData.append("telefono", telefono);
|
||||
formData.append("id_examen", idExamen);
|
||||
formData.append("id_tipo_id", idTipoId);
|
||||
formData.append("id_rango_edad", idRangoEdad);
|
||||
formData.append("id_genero", idGenero);
|
||||
|
||||
// Enviar petición POST para registrar candidato
|
||||
try {
|
||||
const respuesta = await fetch('../controllers/RegistrarCandidatoController.php', {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
// Obtener respuesta de petición de registro
|
||||
const resultado = await respuesta.json();
|
||||
|
||||
// Verificar si el registro fue exitoso
|
||||
if (resultado.registroExitoso) {
|
||||
alert('Se guardó la información correctamente');
|
||||
window.location.href = 'pantalla-salida-form.html';
|
||||
} else {
|
||||
notificacion.textContent = resultado.message;
|
||||
notificacion.style.display = "block";
|
||||
}
|
||||
} catch (error) {
|
||||
notificacion.textContent = "Lo sentimos, ocurrió un error: " + error.message;
|
||||
notificacion.style.display = "block";
|
||||
}
|
||||
});
|
|
@ -1,10 +1,13 @@
|
|||
async function recuperarCantidadGenero(tipoConsulta, filtros = {}) {
|
||||
async function recuperarCantidadGenero(tipoConsulta) {
|
||||
try {
|
||||
const response = await fetch("/controllers/graficosController.php", {
|
||||
const response = await fetch("./php/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta, ...filtros }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ tipoConsulta }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
return data.cantidad || 0;
|
||||
} catch (error) {
|
||||
|
@ -13,13 +16,16 @@ async function recuperarCantidadGenero(tipoConsulta, filtros = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function recuperarCantidadEdad(tipoConsulta, filtros = {}) {
|
||||
async function recuperarCantidadEdad(tipoConsulta) {
|
||||
try {
|
||||
const response = await fetch("/controllers/graficosController.php", {
|
||||
const response = await fetch("./php/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta, ...filtros }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ tipoConsulta }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
return data.cantidad || 0;
|
||||
} catch (error) {
|
||||
|
@ -28,15 +34,22 @@ async function recuperarCantidadEdad(tipoConsulta, filtros = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function recuperarCantidadEstado(tipoConsulta, filtros = {}) {
|
||||
async function recuperarCantidadEstado(tipoConsulta) {
|
||||
try {
|
||||
const response = await fetch("/controllers/graficosController.php", {
|
||||
const response = await fetch("./php/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta, ...filtros }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ tipoConsulta }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!Array.isArray(data)) throw new Error("La respuesta del backend no es un array.");
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error("La respuesta del backend no es un array.");
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error al recuperar datos de estados:", error);
|
||||
|
@ -44,15 +57,22 @@ async function recuperarCantidadEstado(tipoConsulta, filtros = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function recuperarCantidadExamen(tipoConsulta, filtros = {}) {
|
||||
async function recuperarCantidadExamen(tipoConsulta) {
|
||||
try {
|
||||
const response = await fetch("/controllers/graficosController.php", {
|
||||
const response = await fetch("./php/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta, ...filtros }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ tipoConsulta }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!Array.isArray(data)) throw new Error("La respuesta del backend no es un array");
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error("La respuesta del backend no es un array");
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error al recuperar datos de examenes:", error);
|
||||
|
@ -60,48 +80,39 @@ async function recuperarCantidadExamen(tipoConsulta, filtros = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function recuperarCantidadFecha(tipoConsulta, filtros = {}) {
|
||||
try {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta, ...filtros }),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!Array.isArray(data)) throw new Error("La respuesta del backend no es un array.");
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error al recuperar datos de fechas:", error);
|
||||
return [];
|
||||
}
|
||||
|
||||
async function obtenerDatosEdades() {
|
||||
const edad1 = await recuperarCantidadEdad("Menor de 18 años");
|
||||
const edad2 = await recuperarCantidadEdad("18 a 24 años");
|
||||
const edad3 = await recuperarCantidadEdad("25 a 34 años");
|
||||
const edad4 = await recuperarCantidadEdad("35 a 44 años");
|
||||
const edad5 = await recuperarCantidadEdad("45 a 54 años");
|
||||
const edad6 = await recuperarCantidadEdad("55 a 64 años");
|
||||
const edad7 = await recuperarCantidadEdad("65 años o más");
|
||||
|
||||
return [edad1, edad2, edad3, edad4, edad5, edad6];
|
||||
}
|
||||
|
||||
async function obtenerDatosEdades(filtros = {}) {
|
||||
const edad1 = await recuperarCantidadEdad("Menor de 18 años", filtros);
|
||||
const edad2 = await recuperarCantidadEdad("18 a 24 años", filtros);
|
||||
const edad3 = await recuperarCantidadEdad("25 a 34 años", filtros);
|
||||
const edad4 = await recuperarCantidadEdad("35 a 44 años", filtros);
|
||||
const edad5 = await recuperarCantidadEdad("45 a 54 años", filtros);
|
||||
const edad6 = await recuperarCantidadEdad("55 a 64 años", filtros);
|
||||
const edad7 = await recuperarCantidadEdad("65 años o más", filtros);
|
||||
return [edad1, edad2, edad3, edad4, edad5, edad6, edad7];
|
||||
}
|
||||
|
||||
async function obtenerDatosGeneros(filtros = {}) {
|
||||
const femenino = await recuperarCantidadGenero("Femenino", filtros);
|
||||
const masculino = await recuperarCantidadGenero("Masculino", filtros);
|
||||
const noDefinido = await recuperarCantidadGenero("Prefiero no decirlo", filtros);
|
||||
async function obtenerDatosGeneros() {
|
||||
const femenino = await recuperarCantidadGenero("Femenino");
|
||||
const masculino = await recuperarCantidadGenero("Masculino");
|
||||
const noDefinido = await recuperarCantidadGenero("Prefiero no decirlo");
|
||||
|
||||
return [femenino, masculino, noDefinido];
|
||||
}
|
||||
|
||||
async function obtenerDatosEstados(filtros = {}) {
|
||||
async function obtenerDatosEstados() {
|
||||
try {
|
||||
const estados = await recuperarCantidadEstado("Estados", filtros);
|
||||
const estados = await recuperarCantidadEstado("Estados");
|
||||
|
||||
if (!Array.isArray(estados)) {
|
||||
console.error("Error: 'estados' no es un array. Verifica la respuesta del backend");
|
||||
return [];
|
||||
}
|
||||
|
||||
const estadosValidos = estados.filter(estado => estado.estado && estado.cantidad !== undefined);
|
||||
|
||||
return estadosValidos;
|
||||
} catch (error) {
|
||||
console.error("Error al obtener datos de estados:", error);
|
||||
|
@ -109,14 +120,17 @@ async function obtenerDatosEstados(filtros = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosExamenes(filtros = {}) {
|
||||
async function obtenerDatosExamenes() {
|
||||
try {
|
||||
const examenes = await recuperarCantidadExamen("Examenes", filtros);
|
||||
const examenes = await recuperarCantidadExamen("Examenes");
|
||||
|
||||
if (!Array.isArray(examenes)) {
|
||||
console.error("Error: 'examenes' no es un array. Verifica la respuesta del backend");
|
||||
return [];
|
||||
}
|
||||
|
||||
const examenesValidos = examenes.filter(examen => examen.examen && examen.cantidad !== undefined);
|
||||
|
||||
return examenesValidos;
|
||||
} catch (error) {
|
||||
console.error("Error al obtener datos de examenes:", error);
|
||||
|
@ -124,35 +138,6 @@ async function obtenerDatosExamenes(filtros = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosFechas(filtros = {}) {
|
||||
try {
|
||||
const fechas = await recuperarCantidadFecha("Fechas", filtros);
|
||||
if (!Array.isArray(fechas) || !fechas.length) {
|
||||
return [];
|
||||
}
|
||||
// Solo un objeto con la cantidad total
|
||||
return fechas;
|
||||
} catch (error) {
|
||||
console.error("Error al obtener datos de fechas:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function getFiltrosSeleccionados() {
|
||||
return {
|
||||
id_rango_edad: document.getElementById('id_rango_edad')?.value || "NULL",
|
||||
id_genero: document.getElementById('id_genero')?.value || "NULL",
|
||||
id_examen: document.getElementById('id_examen')?.value || "NULL",
|
||||
fechaInicio: document.getElementById('date1')?.value || "",
|
||||
fechaFin: document.getElementById('date2')?.value || ""
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
obtenerDatosGeneros,
|
||||
obtenerDatosEdades,
|
||||
obtenerDatosEstados,
|
||||
obtenerDatosExamenes,
|
||||
obtenerDatosFechas,
|
||||
getFiltrosSeleccionados
|
||||
};
|
||||
export { obtenerDatosGeneros, obtenerDatosEdades, obtenerDatosEstados, obtenerDatosExamenes };
|
284
js/inicio.js
284
js/inicio.js
|
@ -163,67 +163,10 @@ allProgress.forEach(item=> {
|
|||
|
||||
|
||||
|
||||
import {
|
||||
obtenerDatosGeneros,
|
||||
obtenerDatosEdades,
|
||||
obtenerDatosEstados,
|
||||
obtenerDatosExamenes,
|
||||
obtenerDatosFechas,
|
||||
getFiltrosSeleccionados
|
||||
} from './funcionesGraficos.js';
|
||||
import { obtenerDatosGeneros, obtenerDatosEdades, obtenerDatosEstados,obtenerDatosExamenes } from './funcionesGraficos.js';
|
||||
|
||||
// Variables globales para los graficos
|
||||
let chartGenero = null;
|
||||
let chartEdad = null;
|
||||
let chartEstado = null;
|
||||
let chartExamen = null;
|
||||
let chartFecha = null;
|
||||
|
||||
// Controla si el filtro de fecha está activo
|
||||
let filtroFechaActivo = false;
|
||||
|
||||
async function inicializarGraficoFecha(filtros) {
|
||||
// Solo dibujar si ambas fechas están presentes y el filtro está activo
|
||||
if (!filtroFechaActivo || !filtros.fechaInicio || !filtros.fechaFin) {
|
||||
if (chartFecha) {
|
||||
chartFecha.destroy();
|
||||
chartFecha = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const fechas = await obtenerDatosFechas(filtros);
|
||||
|
||||
if (!fechas.length) {
|
||||
if (chartFecha) {
|
||||
chartFecha.destroy();
|
||||
chartFecha = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Solo un valor total
|
||||
const cantidad = fechas[0].cantidad;
|
||||
const label = `Del ${fechas[0].fechaInicio} al ${fechas[0].fechaFin}`;
|
||||
|
||||
const options = {
|
||||
series: [{
|
||||
name: 'Candidatos',
|
||||
data: [cantidad]
|
||||
}],
|
||||
chart: { height: 350, type: 'bar' },
|
||||
xaxis: { categories: [label] },
|
||||
dataLabels: { enabled: true },
|
||||
tooltip: { y: { formatter: val => val + " candidatos" } }
|
||||
};
|
||||
|
||||
if (chartFecha) chartFecha.destroy();
|
||||
chartFecha = new ApexCharts(document.querySelector("#chart5"), options);
|
||||
chartFecha.render();
|
||||
}
|
||||
|
||||
async function inicializarGrafico(filtros) {
|
||||
const [femenino, masculino, noDefinido] = await obtenerDatosGeneros(filtros);
|
||||
async function inicializarGrafico() {
|
||||
const [femenino, masculino, noDefinido] = await obtenerDatosGeneros();
|
||||
|
||||
const options = {
|
||||
series: [
|
||||
|
@ -231,20 +174,40 @@ async function inicializarGrafico(filtros) {
|
|||
{ name: 'Masculino', data: [masculino] },
|
||||
{ name: 'Prefiero no decirlo', data: [noDefinido] },
|
||||
],
|
||||
chart: { height: 350, type: 'bar' },
|
||||
plotOptions: { bar: { horizontal: false, columnWidth: '55%', borderRadius: 5 } },
|
||||
dataLabels: { enabled: false },
|
||||
xaxis: { categories: ['Géneros'] },
|
||||
tooltip: { y: { formatter: val => val + " personas" } }
|
||||
chart: {
|
||||
height: 350,
|
||||
type: 'bar',
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: false,
|
||||
columnWidth: '55%',
|
||||
borderRadius: 5,
|
||||
},
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
},
|
||||
xaxis: {
|
||||
categories: ['Géneros'],
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (val) {
|
||||
return val + " personas";
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (chartGenero) chartGenero.destroy();
|
||||
chartGenero = new ApexCharts(document.querySelector("#chart"), options);
|
||||
chartGenero.render();
|
||||
const chart = new ApexCharts(document.querySelector("#chart"), options);
|
||||
chart.render();
|
||||
}
|
||||
|
||||
async function inicializarGrafico2(filtros) {
|
||||
const [edad1, edad2, edad3, edad4, edad5, edad6, edad7] = await obtenerDatosEdades(filtros);
|
||||
inicializarGrafico();
|
||||
|
||||
async function inicializarGrafico2() {
|
||||
const [edad1,edad2,edad3,edad4,edad5,edad6,edad7] = await obtenerDatosEdades();
|
||||
|
||||
const options2 = {
|
||||
series: [
|
||||
|
@ -256,20 +219,47 @@ async function inicializarGrafico2(filtros) {
|
|||
{ name: '55 a 64 años', data: [edad6] },
|
||||
{ name: '65 años o más', data: [edad7] },
|
||||
],
|
||||
chart: { height: 350, type: 'bar' },
|
||||
plotOptions: { bar: { horizontal: false, columnWidth: '55%', borderRadius: 5 } },
|
||||
dataLabels: { enabled: false },
|
||||
xaxis: { categories: ['Edades'] },
|
||||
tooltip: { y: { formatter: val => val + " Años" } }
|
||||
chart: {
|
||||
height: 350,
|
||||
type: 'bar',
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: false,
|
||||
columnWidth: '55%',
|
||||
borderRadius: 5,
|
||||
},
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
},
|
||||
xaxis: {
|
||||
categories: ['Edades'],
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (val) {
|
||||
return val + " Años";
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (chartEdad) chartEdad.destroy();
|
||||
chartEdad = new ApexCharts(document.querySelector("#chart2"), options2);
|
||||
chartEdad.render();
|
||||
const chart2 = new ApexCharts(document.querySelector("#chart2"), options2);
|
||||
chart2.render();
|
||||
}
|
||||
|
||||
async function inicializarGrafico3(filtros) {
|
||||
const estados = await obtenerDatosEstados(filtros);
|
||||
inicializarGrafico2();
|
||||
|
||||
|
||||
async function inicializarGrafico3() {
|
||||
try {
|
||||
const estados = await obtenerDatosEstados();
|
||||
|
||||
if (!Array.isArray(estados)) {
|
||||
console.error("Error: 'estados' no es un array. Verifica la funcion obtenerDatosEstados");
|
||||
return;
|
||||
}
|
||||
|
||||
const seriesData = estados.map(estado => ({
|
||||
name: estado.estado,
|
||||
|
@ -278,20 +268,49 @@ async function inicializarGrafico3(filtros) {
|
|||
|
||||
const options3 = {
|
||||
series: seriesData,
|
||||
chart: { height: 350, type: 'bar' },
|
||||
plotOptions: { bar: { horizontal: false, columnWidth: '55%', borderRadius: 5 } },
|
||||
dataLabels: { enabled: false },
|
||||
xaxis: { categories: estados.map(estado => estado.estado) },
|
||||
tooltip: { y: { formatter: val => val + " personas" } }
|
||||
chart: {
|
||||
height: 350,
|
||||
type: 'bar',
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: false,
|
||||
columnWidth: '55%',
|
||||
borderRadius: 5,
|
||||
},
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
},
|
||||
xaxis: {
|
||||
categories: estados.map(estado => estado.estado), // categorias en el eje X
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (val) {
|
||||
return val + " personas";
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (chartEstado) chartEstado.destroy();
|
||||
chartEstado = new ApexCharts(document.querySelector("#chart3"), options3);
|
||||
chartEstado.render();
|
||||
const chart3 = new ApexCharts(document.querySelector("#chart3"), options3);
|
||||
chart3.render();
|
||||
} catch (error) {
|
||||
console.error("Error al inicializar el gráfico 3:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function inicializarGrafico4(filtros) {
|
||||
const examenes = await obtenerDatosExamenes(filtros);
|
||||
inicializarGrafico3();
|
||||
|
||||
async function inicializarGrafico4() {
|
||||
try {
|
||||
const examenes = await obtenerDatosExamenes();
|
||||
|
||||
if (!Array.isArray(examenes)) {
|
||||
console.error("Error: 'examenes' no es un array. Verifica la función obtenerDatosExamenes");
|
||||
return;
|
||||
}
|
||||
|
||||
const seriesData = examenes.map(examen => ({
|
||||
name: examen.examen,
|
||||
|
@ -300,63 +319,38 @@ async function inicializarGrafico4(filtros) {
|
|||
|
||||
const options4 = {
|
||||
series: seriesData,
|
||||
chart: { height: 350, type: 'bar' },
|
||||
plotOptions: { bar: { horizontal: false, columnWidth: '55%', borderRadius: 5 } },
|
||||
dataLabels: { enabled: false },
|
||||
xaxis: { categories: examenes.map(examen => examen.examen) },
|
||||
tooltip: { y: { formatter: val => val + " examenes" } }
|
||||
chart: {
|
||||
height: 350,
|
||||
type: 'bar',
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: false,
|
||||
columnWidth: '55%',
|
||||
borderRadius: 5,
|
||||
},
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
},
|
||||
xaxis: {
|
||||
categories: examenes.map(examen => examen.examen), // categorías en el eje X
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (val) {
|
||||
return val + " examenes";
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (chartExamen) chartExamen.destroy();
|
||||
chartExamen = new ApexCharts(document.querySelector("#chart4"), options4);
|
||||
chartExamen.render();
|
||||
const chart4 = new ApexCharts(document.querySelector("#chart4"), options4);
|
||||
chart4.render();
|
||||
} catch (error) {
|
||||
console.error("Error al inicializar el grafico 4:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function actualizarTodosLosGraficos() {
|
||||
// Si el filtro de fecha está activo, se pasan las fechas, si no, se limpian
|
||||
let filtros = getFiltrosSeleccionados();
|
||||
if (!filtroFechaActivo) {
|
||||
filtros.fechaInicio = "";
|
||||
filtros.fechaFin = "";
|
||||
}
|
||||
await inicializarGrafico(filtros);
|
||||
await inicializarGrafico2(filtros);
|
||||
await inicializarGrafico3(filtros);
|
||||
await inicializarGrafico4(filtros);
|
||||
await inicializarGraficoFecha(filtros);
|
||||
}
|
||||
|
||||
// Espera a que el DOM esté listo antes de agregar eventos
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Solo combos, NO fechas
|
||||
['id_rango_edad', 'id_genero', 'id_examen'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.addEventListener('change', actualizarTodosLosGraficos);
|
||||
});
|
||||
|
||||
// Botón buscar para fechas
|
||||
const btnBuscar = document.getElementById('buscar');
|
||||
if (btnBuscar) {
|
||||
btnBuscar.addEventListener('click', () => {
|
||||
const date1 = document.getElementById('date1').value;
|
||||
const date2 = document.getElementById('date2').value;
|
||||
// Solo activa el filtro si ambas fechas están presentes
|
||||
filtroFechaActivo = !!(date1 && date2);
|
||||
actualizarTodosLosGraficos();
|
||||
});
|
||||
}
|
||||
|
||||
// Botón limpiar para quitar filtro de fecha
|
||||
const btnLimpiar = document.getElementById('limpiar');
|
||||
if (btnLimpiar) {
|
||||
btnLimpiar.addEventListener('click', () => {
|
||||
document.getElementById('date1').value = '';
|
||||
document.getElementById('date2').value = '';
|
||||
filtroFechaActivo = false;
|
||||
actualizarTodosLosGraficos();
|
||||
});
|
||||
}
|
||||
|
||||
filtroFechaActivo = false;
|
||||
actualizarTodosLosGraficos();
|
||||
});ñ
|
||||
inicializarGrafico4();
|
15
js/login.js
15
js/login.js
|
@ -13,11 +13,12 @@ formulario.addEventListener("submit", async (event) => {
|
|||
data.append("contrasena", contrasena);
|
||||
|
||||
try {
|
||||
const respuestaPeticion = await fetch("controllers/LoginController.php", {
|
||||
const respuestaPeticion = await fetch('controladores/login.php', {
|
||||
method: "POST",
|
||||
body: data,
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
// const respuesta = await respuestaPeticion.json();
|
||||
const respuesta = await respuestaPeticion.json();
|
||||
|
||||
|
@ -29,6 +30,14 @@ formulario.addEventListener("submit", async (event) => {
|
|||
if(respuesta.res){ // Si existe respuesta.res hubo un error y se imprime en consola
|
||||
console.error(respuesta.res)
|
||||
}
|
||||
=======
|
||||
const verificarCredenciales = await respuestaPeticion.json();
|
||||
|
||||
if (verificarCredenciales.loginExitoso) {
|
||||
window.location.href = 'inicio.html';
|
||||
} else {
|
||||
notificacion.textContent = "Usuario y/o contraseña incorrectos";
|
||||
>>>>>>> parent of a8e2895 (archivos de merge desde la rama recuperar-cambios)
|
||||
notificacion.style.display = "block";
|
||||
|
||||
} else {
|
||||
|
@ -37,7 +46,7 @@ formulario.addEventListener("submit", async (event) => {
|
|||
}
|
||||
|
||||
} catch (error) {
|
||||
notificacion.textContent = "Lo sentimos, el servicio no está disponible por el momento";
|
||||
console.error(error)
|
||||
notificacion.textContent =
|
||||
"Lo sentimos, el servicio no está disponible por el momento";
|
||||
}
|
||||
});
|
||||
|
|
7
test.php
7
test.php
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
//require_once __DIR__ . "/controllers/usuarioController.php";
|
||||
|
||||
// UsuarioController::registrarUsuario("root", "root");
|
||||
|
||||
?>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 257 KiB |
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html data-bs-theme="light" lang="es-mx">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||
<title>formsLania</title>
|
||||
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="text-bg-light" style="height: 70px;"><img src="assets/img/logo-lania.png" style="height: 65px;margin: 0px 10px;"></div>
|
||||
<div class="card">
|
||||
<div class="card-body" style="margin: 0px 30px;">
|
||||
<h1 class="text-center">¡Gracias por registrarse!</h1>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue