Subir archivos a "Interfaz"
This commit is contained in:
parent
5fe0ff7353
commit
59e7b50564
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Reporte de Ventas</title>
|
||||
<link rel="stylesheet" href="estilos/reporte_ventas.css">
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
</head>
|
||||
<body style="background-color: #f9f7f4;">
|
||||
<br>
|
||||
<div class="container">
|
||||
<h1>Reporte de Ventas</h1>
|
||||
<form id="formReporte">
|
||||
<label for="fechaInicio">Fecha de Inicio:</label>
|
||||
<input type="date" id="fechaInicio" name="fechaInicio" required>
|
||||
|
||||
<label for="fechaFin">Fecha de Fin:</label>
|
||||
<input type="date" id="fechaFin" name="fechaFin" required>
|
||||
|
||||
<button type="submit">Generar Reporte</button>
|
||||
</form>
|
||||
|
||||
<div id="resultadoReporte">
|
||||
<h2>Total de Boletos Vendidos: <span id="totalBoletos">0</span></h2>
|
||||
<table id="tablaVentas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fecha de Venta</th>
|
||||
<th>Número de Asiento</th>
|
||||
<th>Precio</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Las filas se llenarán dinámicamente -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="scripts/reporte_ventas.js"></script>
|
||||
<script src="js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
// Incluir el archivo de conexión
|
||||
require 'conexionbd.php';
|
||||
|
||||
// Obtener las fechas de inicio y fin desde la solicitud (GET)
|
||||
$fechaInicio = $_GET['fechaInicio'] ?? '';
|
||||
$fechaFin = $_GET['fechaFin'] ?? '';
|
||||
|
||||
// Validar que las fechas estén presentes
|
||||
if (empty($fechaInicio) || empty($fechaFin)) {
|
||||
die(json_encode(['error' => 'Faltan parámetros (fechaInicio y fechaFin).']));
|
||||
}
|
||||
|
||||
try {
|
||||
// Consultar el total de boletos vendidos en el período
|
||||
$stmtTotal = $conn->prepare("SELECT COUNT(*) AS total FROM ventas WHERE fecha_venta BETWEEN :fechaInicio AND :fechaFin");
|
||||
$stmtTotal->execute([':fechaInicio' => $fechaInicio, ':fechaFin' => $fechaFin]);
|
||||
$totalBoletos = $stmtTotal->fetch(PDO::FETCH_ASSOC)['total'];
|
||||
|
||||
// Consultar las ventas en el período con JOIN a la tabla asientos
|
||||
$stmtVentas = $conn->prepare("
|
||||
SELECT v.fecha_venta, a.asiento, v.precio
|
||||
FROM ventas v
|
||||
JOIN asientos a ON v.asiento_id = a.id
|
||||
WHERE v.fecha_venta BETWEEN :fechaInicio AND :fechaFin
|
||||
");
|
||||
$stmtVentas->execute([':fechaInicio' => $fechaInicio, ':fechaFin' => $fechaFin]);
|
||||
$ventas = $stmtVentas->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Devolver los datos en formato JSON
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'totalBoletos' => $totalBoletos,
|
||||
'ventas' => $ventas
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
// Devolver un mensaje de error en caso de fallo
|
||||
die(json_encode(['error' => 'Error al consultar las ventas: ' . $e->getMessage()]));
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
// Incluir el archivo de conexión a la base de datos
|
||||
require 'conexionbd.php';
|
||||
|
||||
// Obtener los datos de la solicitud (en formato JSON)
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// Extraer los datos recibidos
|
||||
$artista = $data['artista'] ?? '';
|
||||
$dia = $data['dia'] ?? '';
|
||||
$asientos = $data['asientos'] ?? [];
|
||||
|
||||
// Validar que los datos estén completos
|
||||
if (empty($artista) || empty($dia) || empty($asientos)) {
|
||||
die(json_encode(['error' => 'Faltan parámetros (artista, dia, asientos).']));
|
||||
}
|
||||
|
||||
try {
|
||||
// Preparar la consulta para actualizar el estado de los asientos
|
||||
$stmt = $conn->prepare("UPDATE asientos SET estado = 'vendido' WHERE artista = :artista AND dia = :dia AND asiento = :asiento");
|
||||
|
||||
// Actualizar cada asiento en la lista
|
||||
foreach ($asientos as $asiento) {
|
||||
$stmt->execute([
|
||||
':artista' => $artista,
|
||||
':dia' => $dia,
|
||||
':asiento' => $asiento
|
||||
]);
|
||||
}
|
||||
|
||||
// Devolver una respuesta de éxito
|
||||
echo json_encode(['success' => true, 'message' => 'Asientos vendidos actualizados correctamente.']);
|
||||
} catch (PDOException $e) {
|
||||
// Devolver un mensaje de error en caso de fallo
|
||||
die(json_encode(['error' => 'Error al actualizar los asientos: ' . $e->getMessage()]));
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue