From 5fe0ff73532bc75aeedc0ef29f913e2c9aacd5d3 Mon Sep 17 00:00:00 2001 From: "bruno.martinez" <zs22016061@estudiantes.uv.mx> Date: Mon, 10 Mar 2025 05:22:40 +0000 Subject: [PATCH] Subir archivos a "Interfaz" --- Interfaz/BoletosArtista1.html | 20 +++++++++++++- Interfaz/conexionbd.php | 19 +++++++++++++ Interfaz/consultar_asientos.php | 30 +++++++++++++++++++++ Interfaz/conticket.sql | 28 ++++++++++++++++++++ Interfaz/inicializar_asientos.php | 44 +++++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 Interfaz/conexionbd.php create mode 100644 Interfaz/consultar_asientos.php create mode 100644 Interfaz/conticket.sql create mode 100644 Interfaz/inicializar_asientos.php diff --git a/Interfaz/BoletosArtista1.html b/Interfaz/BoletosArtista1.html index 05c68aa..a5ee0af 100644 --- a/Interfaz/BoletosArtista1.html +++ b/Interfaz/BoletosArtista1.html @@ -5,6 +5,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Selección de Asientos</title> <link rel="stylesheet" href="estilos/ventaboletos.css"> + <link rel="stylesheet" href="estilos/modal.css"> <link rel="stylesheet" href="css/bootstrap.min.css"> </head> <body style="background-color: #f9f7f4;"> @@ -27,7 +28,24 @@ <button class="boton-vender" onclick="venderAsientos()">Vender</button> </div> + <!-- Modal para el comprobante --> + <div id="comprobanteModal" class="modal"> + <div class="modal-content"> + <span class="close">×</span> + <h2>Comprobante de Compra</h2> + <p><strong>Artista:</strong> <span id="modalArtista"></span></p> + <p><strong>Día:</strong> <span id="modalDia"></span></p> + <p><strong>Asientos:</strong> <span id="modalAsientos"></span></p> + <p><strong>Precio Total:</strong> <span id="modalPrecioTotal"></span></p> + <p><strong>Fecha y Hora:</strong> <span id="modalFechaHora"></span></p> + <div class="botones"> + <button class="confirmar" onclick="confirmarVenta()">Confirmar</button> + <button class="rechazar" onclick="rechazarVenta()">Rechazar</button> + </div> + </div> + </div> + <script src="scripts/BoletosArtista1.js"></script> <script src="js/bootstrap.bundle.min.js"></script> </body> -</html> +</html> \ No newline at end of file diff --git a/Interfaz/conexionbd.php b/Interfaz/conexionbd.php new file mode 100644 index 0000000..9fe3141 --- /dev/null +++ b/Interfaz/conexionbd.php @@ -0,0 +1,19 @@ +<?php +// Datos de conexión a la base de datos +$host = 'localhost'; // Servidor de la base de datos +$dbname = 'conticket'; // Nombre de la base de datos +$username = 'root'; // Usuario de la base de datos +$password = 'password'; // Contraseña de la base de datos + +try { + // Crear una instancia de PDO para la conexión + $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); + // Configurar el manejo de errores + $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + // Configurar el charset a UTF-8 + $conn->exec("SET NAMES 'utf8'"); +} catch (PDOException $e) { + // En caso de error, mostrar un mensaje + die("Error de conexión a la base de datos: " . $e->getMessage()); +} +?> \ No newline at end of file diff --git a/Interfaz/consultar_asientos.php b/Interfaz/consultar_asientos.php new file mode 100644 index 0000000..0736c17 --- /dev/null +++ b/Interfaz/consultar_asientos.php @@ -0,0 +1,30 @@ +<?php +// Incluir el archivo de conexión +require 'conexionbd.php'; + +// Obtener el artista y el día desde la solicitud (GET o POST) +$artista = $_GET['artista'] ?? ''; +$dia = $_GET['dia'] ?? ''; + +if (empty($artista) || empty($dia)) { + die(json_encode(['error' => 'Faltan parámetros (artista y dia).'])); +} + +try { + // Consultar los asientos para el artista y día especificados + $stmt = $conn->prepare("SELECT asiento, estado FROM asientos WHERE artista = :artista AND dia = :dia"); + $stmt->execute([':artista' => $artista, ':dia' => $dia]); + $asientos = $stmt->fetchAll(PDO::FETCH_ASSOC); + + // Mensaje de depuración + error_log("Consulta realizada: Artista = $artista, Día = $dia"); + + // Devolver los asientos en formato JSON + header('Content-Type: application/json'); + echo json_encode(['success' => true, 'asientos' => $asientos]); +} catch (PDOException $e) { + // Mensaje de error + error_log("Error al consultar los asientos: " . $e->getMessage()); + die(json_encode(['error' => 'Error al consultar los asientos.'])); +} +?> \ No newline at end of file diff --git a/Interfaz/conticket.sql b/Interfaz/conticket.sql new file mode 100644 index 0000000..13081c8 --- /dev/null +++ b/Interfaz/conticket.sql @@ -0,0 +1,28 @@ +CREATE DATABASE IF NOT EXISTS conticket; +USE conticket; +drop table asientos; +DELETE FROM asientos; +ALTER TABLE asientos AUTO_INCREMENT = 1; + +-- Tabla para almacenar los asientos +CREATE TABLE asientos ( + id INT AUTO_INCREMENT PRIMARY KEY, + artista VARCHAR(50) NOT NULL, -- Nombre del artista/concierto + dia INT NOT NULL, -- Día del evento (22, 23, 24) + asiento VARCHAR(10) NOT NULL, -- Identificador del asiento (ej: 1A, 2B) + estado ENUM('disponible', 'vendido') DEFAULT 'disponible' -- Estado del asiento +); + +-- Tabla para registrar las ventas +CREATE TABLE ventas ( + id INT AUTO_INCREMENT PRIMARY KEY, + asiento_id INT NOT NULL, -- ID del asiento vendido + fecha_venta DATETIME DEFAULT CURRENT_TIMESTAMP, -- Fecha y hora de la venta + precio DECIMAL(10, 2) NOT NULL, -- Precio del boleto + FOREIGN KEY (asiento_id) REFERENCES asientos(id) +); + +INSERT INTO ventas (asiento_id, fecha_venta, precio) VALUES +(1, '2023-10-01 10:00:00', 100), +(2, '2023-10-02 11:00:00', 150), +(3, '2023-10-03 12:00:00', 200); \ No newline at end of file diff --git a/Interfaz/inicializar_asientos.php b/Interfaz/inicializar_asientos.php new file mode 100644 index 0000000..fdcb474 --- /dev/null +++ b/Interfaz/inicializar_asientos.php @@ -0,0 +1,44 @@ +<?php +// Incluir el archivo de conexión +require 'conexionbd.php'; + +// Artistas y días disponibles +$artistas = ['The Driver Era', 'The 1975', 'Taylor Swift']; +$dias = [22, 23, 24]; +$filas = 10; +$columnas = 12; + +try { + // Verificar si ya existen asientos en la base de datos + $stmt = $conn->query("SELECT COUNT(*) AS total FROM asientos"); + $resultado = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($resultado['total'] > 0) { + echo "La base de datos ya ha sido inicializada. No se insertaron nuevos asientos."; + exit; + } + + // Preparar la consulta para insertar asientos + $stmt = $conn->prepare("INSERT INTO asientos (artista, dia, asiento, estado) VALUES (:artista, :dia, :asiento, 'disponible')"); + + // Insertar asientos para cada artista y día + foreach ($artistas as $artista) { + foreach ($dias as $dia) { + for ($i = 1; $i <= $filas; $i++) { + for ($j = 0; $j < $columnas; $j++) { + $asiento = $i . chr(65 + $j); // Ej: 1A, 1B, ..., 10L + $stmt->execute([ + ':artista' => $artista, + ':dia' => $dia, + ':asiento' => $asiento + ]); + } + } + } + } + + echo "Base de datos inicializada correctamente."; +} catch (PDOException $e) { + die("Error al inicializar la base de datos: " . $e->getMessage()); +} +?> \ No newline at end of file