Subir archivos a "Interfaz"
This commit is contained in:
parent
6e549a3876
commit
5fe0ff7353
|
@ -5,6 +5,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Selección de Asientos</title>
|
<title>Selección de Asientos</title>
|
||||||
<link rel="stylesheet" href="estilos/ventaboletos.css">
|
<link rel="stylesheet" href="estilos/ventaboletos.css">
|
||||||
|
<link rel="stylesheet" href="estilos/modal.css">
|
||||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color: #f9f7f4;">
|
<body style="background-color: #f9f7f4;">
|
||||||
|
@ -27,7 +28,24 @@
|
||||||
<button class="boton-vender" onclick="venderAsientos()">Vender</button>
|
<button class="boton-vender" onclick="venderAsientos()">Vender</button>
|
||||||
</div>
|
</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="scripts/BoletosArtista1.js"></script>
|
||||||
<script src="js/bootstrap.bundle.min.js"></script>
|
<script src="js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -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());
|
||||||
|
}
|
||||||
|
?>
|
|
@ -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.']));
|
||||||
|
}
|
||||||
|
?>
|
|
@ -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);
|
|
@ -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());
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue