Optimizaciones
|
|
@ -0,0 +1,140 @@
|
||||||
|
<?php
|
||||||
|
// Validar el método de solicitud HTTP
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
// Recopilar datos del formulario
|
||||||
|
$datosReserva = recopilarDatosReserva($_POST);
|
||||||
|
|
||||||
|
// Procesar la reserva
|
||||||
|
$resultadoProcesamiento = procesarReserva($datosReserva);
|
||||||
|
|
||||||
|
// Mostrar resultado al usuario
|
||||||
|
mostrarResultado($resultadoProcesamiento);
|
||||||
|
} else {
|
||||||
|
echo "No se han recibido datos del formulario";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Función para recopilar datos del formulario
|
||||||
|
function recopilarDatosReserva($formulario)
|
||||||
|
{
|
||||||
|
$datos = [];
|
||||||
|
$campos = ['entrada', 'salida', 'habitacion', 'regimen', 'estancia', 'spa', 'guia', 'total', 'nombre', 'email', 'telefono', 'dni', 'noches', 'info'];
|
||||||
|
|
||||||
|
foreach ($campos as $campo) {
|
||||||
|
$datos[$campo] = $formulario[$campo] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $datos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Función para procesar la reserva
|
||||||
|
function procesarReserva($datosReserva)
|
||||||
|
{
|
||||||
|
// Variables para el resultado del procesamiento
|
||||||
|
$exito = true;
|
||||||
|
$mensaje = '';
|
||||||
|
|
||||||
|
// Obtener datos de reserva
|
||||||
|
$entrada = $datosReserva['entrada'];
|
||||||
|
$salida = $datosReserva['salida'];
|
||||||
|
$habitacion = $datosReserva['habitacion'];
|
||||||
|
$regimen = $datosReserva['regimen'];
|
||||||
|
$spa = $datosReserva['spa'];
|
||||||
|
$guia = $datosReserva['guia'];
|
||||||
|
$nombre = $datosReserva['nombre'];
|
||||||
|
$email = $datosReserva['email'];
|
||||||
|
$telefono = $datosReserva['telefono'];
|
||||||
|
$dni = $datosReserva['dni'];
|
||||||
|
$noches = $datosReserva['noches'];
|
||||||
|
$total = $datosReserva['total'];
|
||||||
|
|
||||||
|
// Generar identificador de reserva
|
||||||
|
$idReserva = time() . '_' . mt_rand(0000, 9999);
|
||||||
|
// Fecha de reserva
|
||||||
|
$fechaReserva = date("d-m-Y H:i:s");
|
||||||
|
// Estructurar ficha de reserva
|
||||||
|
$fichaReserva = "Id reserva: $idReserva \r\n";
|
||||||
|
$fichaReserva .= "Fecha de reserva: $fechaReserva \r\n";
|
||||||
|
$fichaReserva .= "Fecha de entrada: $entrada \r\n";
|
||||||
|
$fichaReserva .= "Fecha de salida: $salida \r\n";
|
||||||
|
$fichaReserva .= "Tipo de habitación: $habitacion \r\n";
|
||||||
|
$fichaReserva .= "Regimen de alojamiento: $regimen \r\n";
|
||||||
|
$fichaReserva .= "Días Spa: $spa \r\n";
|
||||||
|
$fichaReserva .= "Días Guia: $guia \r\n";
|
||||||
|
$fichaReserva .= "Duración estancia: $noches \r\n";
|
||||||
|
$fichaReserva .= "Coste Total: $total \r\n";
|
||||||
|
$fichaReserva .= "Nombre: $nombre \r\n";
|
||||||
|
$fichaReserva .= "Correo electrónico: $email \r\n";
|
||||||
|
$fichaReserva .= "Teléfono: $telefono \r\n";
|
||||||
|
$fichaReserva .= "DNI: $dni \r\n";
|
||||||
|
|
||||||
|
// Enviar correo electrónico con los detalles de la reserva
|
||||||
|
$destinatario = "appasin04@gmail.com";
|
||||||
|
$asunto = "Informacion de reserva - $idReserva";
|
||||||
|
$headers = 'Reply-To: appasin04@gmail.com' . "\r\n";
|
||||||
|
$headers .= 'Bcc: ' . $email . "\r\n";
|
||||||
|
if (!mail($destinatario, $asunto, $fichaReserva, $headers)) {
|
||||||
|
// Si falla el envío de correo, se marca como fallo
|
||||||
|
$exito = false;
|
||||||
|
$mensaje = "Error al enviar el correo electrónico.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guardar la ficha de reserva en un archivo
|
||||||
|
$nombre_archivo = "reservas/" . $idReserva . ".txt";
|
||||||
|
if (!guardarFichaReserva($fichaReserva, $nombre_archivo)) {
|
||||||
|
// Si falla la escritura del archivo, se marca como fallo
|
||||||
|
$exito = false;
|
||||||
|
$mensaje = "Error al guardar la ficha de reserva.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añadir al listado_reservas.txt una línea de reserva
|
||||||
|
$registroReserva = implode('/_/', [$idReserva, $nombre, $email, $telefono, $entrada, $salida, $fechaReserva, $noches]) . "\r\n";
|
||||||
|
$nombre_archivo = "listado_reservas.txt";
|
||||||
|
if (!guardaListaDatos($registroReserva, $nombre_archivo)) {
|
||||||
|
// Si falla la escritura del archivo, se marca como fallo
|
||||||
|
$exito = false;
|
||||||
|
$mensaje = "Error al guardar la lista de reservas.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resultado del procesamiento
|
||||||
|
$resultado = [
|
||||||
|
'exito' => $exito,
|
||||||
|
'mensaje' => $mensaje
|
||||||
|
];
|
||||||
|
|
||||||
|
return $resultado;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Función para guardar la ficha de reserva en un archivo
|
||||||
|
function guardarFichaReserva($fichaReserva, $nombre_archivo)
|
||||||
|
{
|
||||||
|
return file_put_contents($nombre_archivo, $fichaReserva) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Función para añadir al listado_reservas.txt una línea de reserva
|
||||||
|
function guardaListaDatos($registroReserva, $nombre_archivo)
|
||||||
|
{
|
||||||
|
return file_put_contents($nombre_archivo, $registroReserva, FILE_APPEND | LOCK_EX) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Función para mostrar el resultado al usuario
|
||||||
|
function mostrarResultado($resultado)
|
||||||
|
{
|
||||||
|
if ($resultado['exito']) {
|
||||||
|
echo "<p>{$resultado['mensaje']}</p>";
|
||||||
|
} else {
|
||||||
|
echo "<p>No se ha podido realizar la reserva correctamente.</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 3.3 MiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 255 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
|
@ -0,0 +1,141 @@
|
||||||
|
<!Doctype html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>Buscador de reservas</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="post">
|
||||||
|
<p>*Término a buscar: </p>
|
||||||
|
<p><input type="text" name="busqueda" id="busqueda" size="30" placeholder="Introduzca la palabra de busqueda" required></p>
|
||||||
|
<input type="submit" name="buscar" value="Buscar">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//Suponiendo que el archivo caracteres.php está en la misma carpeta:
|
||||||
|
include('caracteres.php');
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['buscar'])) {
|
||||||
|
// Busca una palabra
|
||||||
|
$busqueda = isset($_REQUEST['busqueda']) ? $_REQUEST['busqueda'] : "";
|
||||||
|
|
||||||
|
|
||||||
|
//Abrir el archivo
|
||||||
|
$archivo = fopen('listado_reservas.txt', 'r');
|
||||||
|
|
||||||
|
//Leer el archivo
|
||||||
|
|
||||||
|
if (!$archivo) {
|
||||||
|
echo ("Error abriendo archivo");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abro la tabla
|
||||||
|
echo '<br>';
|
||||||
|
echo '<table border="2">';
|
||||||
|
echo "<tr><th>Id Reserva</th><th>Nombre</th><th>Correo</th><th>Teléfono</th><th>Entrada</th><th>Salida</th><th>Fecha reserva</th><th>Duración</th></tr>";
|
||||||
|
|
||||||
|
//Busco la coincidencia
|
||||||
|
$id_encontrado = null;
|
||||||
|
while (($linea = fgets($archivo)) != false) {
|
||||||
|
if (strpos(eliminar_tildes(strtolower($linea)), eliminar_tildes(strtolower($busqueda))) !== false) {
|
||||||
|
|
||||||
|
// Mostrar la tabla con array
|
||||||
|
$arrayLinea = explode('/_/', $linea);
|
||||||
|
//foreach ($arrayLinea as $dato) {
|
||||||
|
// echo "<td>$dato</td>";
|
||||||
|
//}
|
||||||
|
echo "<tr><td>$arrayLinea[0]</td><td>$arrayLinea[1]</td><td>$arrayLinea[2]</td><td>$arrayLinea[3]</td><td>$arrayLinea[4]</td><td>$arrayLinea[5]</td><td>$arrayLinea[6]</td><td>$arrayLinea[7]</td></tr>";
|
||||||
|
|
||||||
|
//Guardar el ID de reserva encontrado
|
||||||
|
//file_put_contents("dato_temporal.txt",$arrayLinea[0]);
|
||||||
|
$id_encontrado = $arrayLinea[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Cierrro la tabla
|
||||||
|
echo "</table>";
|
||||||
|
//cerrar el archivo
|
||||||
|
fclose($archivo);
|
||||||
|
|
||||||
|
// Vacio los datos de POST
|
||||||
|
unset($_POST);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<br>
|
||||||
|
<form method="post">
|
||||||
|
<p>*ID de alquiler para borrar: </p><input type="text" name="Id_borrar" value="" id="Id_borrar" size="15" minlength="15" maxlength="15" placeholder="Id Alquiler" />
|
||||||
|
<input type="submit" name="borrar" value="Borrar reserva de alquiler">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Borrar reservas de alquiler
|
||||||
|
$listaReservas = "listado_reservas.txt";
|
||||||
|
$temporal = "temp.txt";
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['borrar']) && isset($_POST['Id_borrar'])) {
|
||||||
|
$borrado = $_POST['Id_borrar'];
|
||||||
|
|
||||||
|
$accesoLista = fopen($listaReservas, 'r');
|
||||||
|
$accesoTemporal = fopen($temporal, 'w');
|
||||||
|
|
||||||
|
// Buscar la reserva por ID
|
||||||
|
while (($linea = fgets($accesoLista)) !== false) {
|
||||||
|
// Obtener el ID de reserva de la línea actual
|
||||||
|
$arrayLinea = explode('/_/', $linea);
|
||||||
|
$id_reserva = $arrayLinea[0];
|
||||||
|
|
||||||
|
// Si el ID de reserva no coincide
|
||||||
|
if (trim($id_reserva) !== trim($borrado)) {
|
||||||
|
fwrite($accesoTemporal, $linea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($accesoLista);
|
||||||
|
fclose($accesoTemporal);
|
||||||
|
|
||||||
|
// Borrar listado y renombrar el temporal
|
||||||
|
unlink($listaReservas);
|
||||||
|
rename($temporal, $listaReservas);
|
||||||
|
|
||||||
|
// Borrar ficha de reserva individual
|
||||||
|
$ficha_individual = "reservas/reserva_" . $borrado . ".txt";
|
||||||
|
if (file_exists($ficha_individual)) {
|
||||||
|
if (unlink("reservas/reserva_" . $borrado . ".txt") !== false) {
|
||||||
|
echo "<div><p>La ficha de reserva se ha borrado</p></div>";
|
||||||
|
} else {
|
||||||
|
echo "<div><p>La ficha de reserva no se ha encontrado</p></div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Borrar DNI
|
||||||
|
$directorio = "dni_clientes";
|
||||||
|
// Obtener la lista de elemntos del directorio
|
||||||
|
$dni_clientes = scandir("dni_clientes");
|
||||||
|
|
||||||
|
// Iterar sobre la lista de archivos
|
||||||
|
foreach ($dni_clientes as $archivo_dni) {
|
||||||
|
// Verificar si es archivo o directorio
|
||||||
|
|
||||||
|
if (is_file('dni_clientes/' . $archivo_dni)) {
|
||||||
|
// Verificar si el nombre del archivo contiene la cadena determinada
|
||||||
|
if (strpos($archivo_dni, $borrado) !== false) {
|
||||||
|
// Borrar el archivo
|
||||||
|
unlink('dni_clientes/' . $archivo_dni);
|
||||||
|
echo "<div><p>Archivo borrado: $archivo_dni </p></div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vacio los datos de POST
|
||||||
|
unset($_POST);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||||
|
<title>Busqueda de registros</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<h2>Buqueda de registro</h2>
|
||||||
|
<input type="text" name="terminoBusqueda" id="terminoBusqueda">
|
||||||
|
<input type="submit" value="Buscar" required>
|
||||||
|
<br>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
include_once('./caracteres.php');
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$terminoBusqueda = $_POST['terminoBusqueda'];
|
||||||
|
|
||||||
|
$terminoBusqueda = eliminar_tildes(strtolower($terminoBusqueda));
|
||||||
|
|
||||||
|
$separador = "/_/";
|
||||||
|
$nombre_archivo = "listado_reservas.txt";
|
||||||
|
$archivo = fopen($nombre_archivo, 'r');
|
||||||
|
|
||||||
|
$registros = [];
|
||||||
|
while (($linea = fgets($archivo)) !== false) {
|
||||||
|
if (strpos(eliminar_tildes(strtolower($linea)), $terminoBusqueda) !== false) {
|
||||||
|
$registros[] = $linea;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($archivo);
|
||||||
|
|
||||||
|
echo "<table>
|
||||||
|
<tbody>
|
||||||
|
<thead>
|
||||||
|
<th>Id Usuario</th>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Nº Telefono</th>
|
||||||
|
<th>Fecha de entrada</th>
|
||||||
|
<th>Fecha de salida</th>
|
||||||
|
<th>Fecha de registro</th>
|
||||||
|
<th>Nº de noches</th>
|
||||||
|
<th>Acciones</th>
|
||||||
|
</thead>";
|
||||||
|
foreach ($registros as $registro) {
|
||||||
|
$campos = explode("/_/", $registro);
|
||||||
|
echo "<tr>";
|
||||||
|
foreach ($campos as $campo) {
|
||||||
|
echo "<td> $campo </td>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<td><form action=\"./eliminar_registro.php\" method=\"POST\">
|
||||||
|
<input type=\"hidden\" name=\"idRegistro\" value=\"$campos[0]\">
|
||||||
|
<input type=\"submit\" value=\"Eliminar\">
|
||||||
|
</form></td>";
|
||||||
|
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "</tbody>";
|
||||||
|
echo "</table>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="./eliminar_registro.php" method="POST">
|
||||||
|
<h2>Eliminacion de registro</h2>
|
||||||
|
<input type="text" name="idRegistro" id="idRegistro">
|
||||||
|
<input type="submit" value="Eliminar" required>
|
||||||
|
<br>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
// Eliminar tildes
|
||||||
|
function eliminar_tildes($cadena){
|
||||||
|
|
||||||
|
//Codificamos la cadena en formato utf8 en caso de que nos de errores
|
||||||
|
//$cadena = utf8_encode($cadena);
|
||||||
|
|
||||||
|
//Ahora reemplazamos las letras
|
||||||
|
$cadena = str_replace(
|
||||||
|
array('á', 'à', 'ä', 'â', 'ª', 'Á', 'À', 'Â', 'Ä'),
|
||||||
|
array('a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A'),
|
||||||
|
$cadena
|
||||||
|
);
|
||||||
|
|
||||||
|
$cadena = str_replace(
|
||||||
|
array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ê', 'Ë'),
|
||||||
|
array('e', 'e', 'e', 'e', 'E', 'E', 'E', 'E'),
|
||||||
|
$cadena );
|
||||||
|
|
||||||
|
$cadena = str_replace(
|
||||||
|
array('í', 'ì', 'ï', 'î', 'Í', 'Ì', 'Ï', 'Î'),
|
||||||
|
array('i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'),
|
||||||
|
$cadena );
|
||||||
|
|
||||||
|
$cadena = str_replace(
|
||||||
|
array('ó', 'ò', 'ö', 'ô', 'Ó', 'Ò', 'Ö', 'Ô'),
|
||||||
|
array('o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'),
|
||||||
|
$cadena );
|
||||||
|
|
||||||
|
$cadena = str_replace(
|
||||||
|
array('ú', 'ù', 'ü', 'û', 'Ú', 'Ù', 'Û', 'Ü'),
|
||||||
|
array('u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'),
|
||||||
|
$cadena );
|
||||||
|
|
||||||
|
$cadena = str_replace(
|
||||||
|
array('ñ', 'Ñ', 'ç', 'Ç'),
|
||||||
|
array('n', 'N', 'c', 'C'),
|
||||||
|
$cadena
|
||||||
|
);
|
||||||
|
|
||||||
|
return $cadena;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['idRegistro']) && $_POST['idRegistro'] !== "") {
|
||||||
|
$idRegistro = $_POST['idRegistro'];
|
||||||
|
$separador = "/_/";
|
||||||
|
$nombre_archivo = "listado_reservas.txt";
|
||||||
|
|
||||||
|
$nombreArchivoReserva = "";
|
||||||
|
$nombreImagenDni = "";
|
||||||
|
|
||||||
|
$archivo = fopen($nombre_archivo, 'r');
|
||||||
|
$flagEncontrado = false;
|
||||||
|
$registros = [];
|
||||||
|
while (($linea = fgets($archivo)) !== false) {
|
||||||
|
if (strpos($linea, $idRegistro) === false) {
|
||||||
|
$registros[] = $linea;
|
||||||
|
} else {
|
||||||
|
$flagEncontrado = true;
|
||||||
|
$idRegistro = explode("/_/", $linea)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($archivo);
|
||||||
|
|
||||||
|
if ($flagEncontrado) {
|
||||||
|
file_put_contents($nombre_archivo, $registros);
|
||||||
|
$directorio = "./reservas/";
|
||||||
|
$nombreArchivoReserva = $directorio . $idRegistro . '.txt';
|
||||||
|
if (deleteFile($nombreArchivoReserva)) {
|
||||||
|
echo "El archivo de registro se ha eliminado correctamente";
|
||||||
|
} else {
|
||||||
|
echo "Ocurrio un error al eliminar el archivo de registro";
|
||||||
|
}
|
||||||
|
|
||||||
|
$directorio = "./dni_clientes";
|
||||||
|
$patron = $directorio . "/*" . $idRegistro . "*";
|
||||||
|
$archivoDni = glob($patron);
|
||||||
|
if (count($archivoDni) > 0) {
|
||||||
|
deleteFile($archivoDni[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "No se ha encontrado el registro indicado";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "No se ha especificado id a eliminar";
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFile($rutaArchivo)
|
||||||
|
{
|
||||||
|
if (file_exists($rutaArchivo)) {
|
||||||
|
if (unlink($rutaArchivo)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
@charset "UTF-8";
|
||||||
|
|
||||||
|
*{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
text-decoration: none;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
p{
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width:80%;
|
||||||
|
min-width:350px;
|
||||||
|
margin:auto;
|
||||||
|
background-color:#9d2236;
|
||||||
|
border:2px solid #000000;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
td,th {
|
||||||
|
text-align: center;
|
||||||
|
padding:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form,div {
|
||||||
|
width:80%;
|
||||||
|
min-width:350px;
|
||||||
|
background-color:#9d2236;
|
||||||
|
border:2px solid #000000;
|
||||||
|
padding:10px;
|
||||||
|
box-sizing:border-box;
|
||||||
|
color:white;
|
||||||
|
font-size:18px;
|
||||||
|
margin:auto;
|
||||||
|
margin-top: 20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
background-color:#9d2236;
|
||||||
|
border:2px solid #ffffff;
|
||||||
|
padding:10px;
|
||||||
|
box-sizing:border-box;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#flex {
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
margin-right:10px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
color:white;
|
||||||
|
background-color:#9d2236;
|
||||||
|
border: 2px solid white;
|
||||||
|
padding: 2px;
|
||||||
|
min-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
legend {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
margin:10px;
|
||||||
|
}
|
||||||
|
select,option {
|
||||||
|
color:white;
|
||||||
|
background-color:#9d2236;
|
||||||
|
border: 2px solid white;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
background-color:#9d2236;
|
||||||
|
width:100%;
|
||||||
|
height:200px;
|
||||||
|
color:white;
|
||||||
|
border: 2px solid white;
|
||||||
|
padding:10px;
|
||||||
|
box-sizing:border-box;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=submit], input[type=button],input[type=reset] {
|
||||||
|
background-color:#9d2236;
|
||||||
|
color:white;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 5px;
|
||||||
|
border:2px solid #000000;
|
||||||
|
border-radius:5px;
|
||||||
|
box-shadow: 1px 2px 3px #fff;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Media query para pantallas de menos de 450 píxeles de ancho */
|
||||||
|
@media (max-width: 450px) {
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
#flex {
|
||||||
|
flex-wrap:wrap;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
display: block;
|
||||||
|
width: 80%;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,197 @@
|
||||||
|
|
||||||
|
<!Doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>Reservas hotel</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||||
|
<script>
|
||||||
|
// Función obtener() que realizará la captación de datos,los cálculos y la escritura del mensaje de info
|
||||||
|
|
||||||
|
function obtener() {
|
||||||
|
// Declaro y obtengo el valor de las variables
|
||||||
|
|
||||||
|
//Calcular periodo de la estancia (noches)
|
||||||
|
const inicio=document.getElementById("entradaH").valueAsNumber;
|
||||||
|
const fin=document.getElementById("salida").valueAsNumber;
|
||||||
|
const dif=fin - inicio;
|
||||||
|
const noches=Math.ceil(dif/(1000*60*60*24));
|
||||||
|
document.getElementById("noches").value=noches;
|
||||||
|
|
||||||
|
|
||||||
|
const habitacion=document.getElementById("habitacion").value;
|
||||||
|
const regimen=document.getElementById("regimen").value;
|
||||||
|
const spa=document.getElementById("spa").value;
|
||||||
|
const guia=document.getElementById("guia").value;
|
||||||
|
const nombreCliente=document.getElementById("nombre").value;
|
||||||
|
|
||||||
|
//Cáculo extras (spa y guia)
|
||||||
|
let spaT;
|
||||||
|
|
||||||
|
if (spa>5) {
|
||||||
|
spaT=spa*20;
|
||||||
|
}else {
|
||||||
|
spaT=spa*30;
|
||||||
|
}
|
||||||
|
|
||||||
|
let guiaT;
|
||||||
|
|
||||||
|
if(guia>7) {
|
||||||
|
guiaT=guia*40;
|
||||||
|
} else {
|
||||||
|
guiaT=guia*50;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tipo habitación
|
||||||
|
let hotel;
|
||||||
|
if (habitacion === "simple") {
|
||||||
|
hotel=50;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (habitacion === "doble") {
|
||||||
|
hotel=80;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (habitacion === "triple") {
|
||||||
|
hotel=120;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (habitacion === "suite") {
|
||||||
|
hotel=150;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Tipo de regimen
|
||||||
|
let comidas;
|
||||||
|
if (regimen === "desayuno") {
|
||||||
|
comidas=50;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regimen === "mediapension") {
|
||||||
|
comidas=80;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regimen === "pensioncompleta") {
|
||||||
|
comidas=120;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regimen === "todoincluido") {
|
||||||
|
comidas=150;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gastos estancia hotel+comidas
|
||||||
|
const hotelT=hotel*noches;
|
||||||
|
const regimenT=comidas*noches;
|
||||||
|
|
||||||
|
const estancia=hotelT+regimenT;
|
||||||
|
|
||||||
|
// Descuento por larga estancia
|
||||||
|
let estanciaDescuento;
|
||||||
|
if (noches <= 4) {
|
||||||
|
estanciaDescuento = estancia;
|
||||||
|
} else if (noches >= 5 && noches <= 10) {
|
||||||
|
estanciaDescuento = estancia * 0.85;
|
||||||
|
} else if (noches >= 11) {
|
||||||
|
estanciaDescuento = estancia * 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Envío el precio total sin IVA al formulario
|
||||||
|
document.getElementById("estancia").value=estanciaDescuento;
|
||||||
|
|
||||||
|
//Coste total con extras
|
||||||
|
const total=estanciaDescuento+spaT+guiaT;
|
||||||
|
const totalI=(total*1.21).toFixed(2);
|
||||||
|
// Envío el precio con IVA al formulario
|
||||||
|
document.getElementById("total").value=totalI;
|
||||||
|
// Precio de anulación
|
||||||
|
const precioAnulacion=(total*0.2).toFixed(2);
|
||||||
|
|
||||||
|
|
||||||
|
// Calcular días que faltan y fecha de regreso
|
||||||
|
const hoy=new Date().getTime();// Fecha de la reserva
|
||||||
|
const entrada=document.getElementById("entradaH").valueAsNumber;
|
||||||
|
const dif2=entrada-hoy;
|
||||||
|
const diasFaltan=dif2/(1000*60*60*24);// Días que faltan
|
||||||
|
|
||||||
|
const regresoF=new Date(fin);// Obtener en UTC
|
||||||
|
const regresoP=regresoF.toLocaleDateString();//Pasar fecha a formato corto dd/mm/xxxx
|
||||||
|
|
||||||
|
const anulacion=entrada-(3*24*60*60*1000);//Fecha de anulación
|
||||||
|
const anulacionF=new Date(anulacion);
|
||||||
|
const anulacionP=anulacionF.toLocaleDateString();
|
||||||
|
//Mensaje de información
|
||||||
|
const frase=
|
||||||
|
"Hola "+nombreCliente+"\n"
|
||||||
|
+"Faltan "+(Math.ceil(diasFaltan))+ " días "+"para tu viaje"+"\n"
|
||||||
|
+"Tu fecha de regreso es el "+regresoP+"\n"
|
||||||
|
+"Puedes anular tu reserva hasta el día "+anulacionP+"\n"
|
||||||
|
+"El coste de la anulación será de " +precioAnulacion+ " euros" ;
|
||||||
|
//Enviar mensaje al formulario
|
||||||
|
document.getElementById("info").value=frase;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="container">
|
||||||
|
<form action="recibe_formulario_hotel.php" method="post" enctype="multipart/form-data">
|
||||||
|
<h1>Reserve su habitación</h1>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Datos de la reserva</legend>
|
||||||
|
<p><label for="entradaH">Elige la fecha de entrada</label> <input type="date" id="entradaH" name="entrada">
|
||||||
|
<p><label for="salida">Elige la fecha de salida</label> <input type="date" id="salida" name="salida"></p>
|
||||||
|
<p><label for="habitacion">Seleccione el tipo de habitación</label>
|
||||||
|
<!-- Lista de selección -->
|
||||||
|
<select name="habitacion" id="habitacion">
|
||||||
|
<option value="simple">Simple</option>
|
||||||
|
<option value="doble">Doble</option>
|
||||||
|
<option value="triple">Triple</option>
|
||||||
|
<option value="suite">Suite</option>
|
||||||
|
</select></p>
|
||||||
|
<p><label for="regimen">Seleccione el regimen de alojamiento</label>
|
||||||
|
<!-- Lista de selección -->
|
||||||
|
<select name="regimen" id="regimen">
|
||||||
|
<option value="desayuno">Desayuno</option>
|
||||||
|
<option value="mediapension">Media pensión</option>
|
||||||
|
<option value="pensioncompleta">Pensión Completa</option>
|
||||||
|
<option value="todoincluido">Todo Incluido</option>
|
||||||
|
</select></p>
|
||||||
|
<p><label for="estancia">Coste de la estancia (Habitación + Comidas)</label> <input type="text" name="estancia" id="estancia"></p>
|
||||||
|
<p><label for="spa">Acceso al Spa, elija cuantos días</label> <input type="number" name="spa" id="spa" value="0" size="3"></p>
|
||||||
|
|
||||||
|
<p><label for="guia">Servicio de guía turístico, elija cuantos días </label><input type="number" name="guia" id="guia" value="0" size="3"></p>
|
||||||
|
<p><label for="total">Coste total con IVA incluido </label><input type="text" name="total" id="total" ></p>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Datos personales</legend>
|
||||||
|
<p><label for="nombre">*Nombre: </label><input type="text" name="nombre" id="nombre" placeholder="Nombre y Apellidos" required></p>
|
||||||
|
<p><label for="mail">*Correo electrónico: </label><input type="email" name="email" id="mail" placeholder="Escribe tu correo" required></p>
|
||||||
|
<p><label for="telefono">*Teléfono:</label> <input type="tel" id="telefono" name="telefono" required></p>
|
||||||
|
<p>Check-in online (opcional):</p>
|
||||||
|
<p><label for="dni">DNI:</label> <input type="text" id="dni" name="dni" ></p>
|
||||||
|
<p><label for="adjuntos">Adjunte fotocopia de DNI </label><input type="file" name="dnifile" id="dnifile" accept=".pdf,.jpg" ></p>
|
||||||
|
<div id="flex">
|
||||||
|
<div>
|
||||||
|
<input type="button" value="Calcular coste total" onclick="obtener()">
|
||||||
|
<br><input type="reset" name="limpiar" value="Borrar" />
|
||||||
|
<br><input type="submit" value="Enviar la reserva" >
|
||||||
|
<input id="noches" name="noches" type="hidden" value="noches">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<textarea name="info" id="info" >Información de su viaje</textarea>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||||
|
<title>Reservas hotel</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$entrada = $_POST['entrada'];
|
||||||
|
$salida = $_POST['salida'];
|
||||||
|
$habitacion = $_POST['habitacion'];
|
||||||
|
$regimen = $_POST['regimen'];
|
||||||
|
$estancia = $_POST['estancia'];
|
||||||
|
$spa = $_POST['spa'];
|
||||||
|
$guia = $_POST['guia'];
|
||||||
|
$total = $_POST['total'];
|
||||||
|
$nombre = $_POST['nombre'];
|
||||||
|
$email = $_POST['email'];
|
||||||
|
$telefono = $_POST['telefono'];
|
||||||
|
$dni = $_POST['dni'];
|
||||||
|
$noches = $_POST['noches'];
|
||||||
|
$info = $_POST['info'];
|
||||||
|
$idReserva = time() . '_' . mt_rand(0000, 9999);
|
||||||
|
$fechaReserva = date("d-m-Y H:i:s");
|
||||||
|
$separador = '/_/';
|
||||||
|
$fichaReserva = "Id reserva: $idReserva \r\n";
|
||||||
|
$fichaReserva .= "Fecha de reserva: $fechaReserva \r\n";
|
||||||
|
$fichaReserva .= "Fecha de entrada: $entrada \r\n";
|
||||||
|
$fichaReserva .= "Fecha de salida: $salida \r\n";
|
||||||
|
$fichaReserva .= "Tipo de habitación: $habitacion \r\n";
|
||||||
|
$fichaReserva .= "Regimen de alojamiento: $regimen \r\n";
|
||||||
|
$fichaReserva .= "Días Spa: $spa \r\n";
|
||||||
|
$fichaReserva .= "Días Guia: $guia \r\n";
|
||||||
|
$fichaReserva .= "Duración estancia: $noches \r\n";
|
||||||
|
$fichaReserva .= "Coste Total: $total \r\n";
|
||||||
|
$fichaReserva .= "Nombre: $nombre \r\n";
|
||||||
|
$fichaReserva .= "Correo electrónico: $email \r\n";
|
||||||
|
$fichaReserva .= "Teléfono: $telefono \r\n";
|
||||||
|
$fichaReserva .= "DNI: $dni \r\n";
|
||||||
|
$registroReserva = implode($separador, [$idReserva, $nombre, $email, $telefono, $entrada, $salida, $fechaReserva, $noches]) . "\r\n";
|
||||||
|
|
||||||
|
// Enviar un mensaje de correo al hotel con los detalles de la reserva y con su identificador
|
||||||
|
$destinatario = "appasin04@gmail.com";
|
||||||
|
$asunto = "Informacion de reserva - $idReserva";
|
||||||
|
$headers = 'Reply-To: appasin04@gmail.com' . "\r\n";
|
||||||
|
$headers .= 'Bcc: ' . $email . "\r\n";
|
||||||
|
if (mail($destinatario, $asunto, $fichaReserva, $headers)) {
|
||||||
|
|
||||||
|
// Crear la ficha de reserva con nombre(reserva_1708677602_7461.txt) y con esta estructura:
|
||||||
|
$nombre_archivo = "reservas/" . $idReserva . ".txt";
|
||||||
|
guardarFichaReserva($fichaReserva, $nombre_archivo);
|
||||||
|
|
||||||
|
// Añadir al listado_reservas.txt un línea de reserva:
|
||||||
|
$nombre_archivo = "listado_reservas.txt";
|
||||||
|
guardaListaDatos($registroReserva, $nombre_archivo);
|
||||||
|
|
||||||
|
// Mostrar el mensaje en pantalla al cliente con la siguiente estructura:
|
||||||
|
echo "Reserva confirmada ! <br> <br>";
|
||||||
|
echo nl2br($fichaReserva);
|
||||||
|
echo "<br>";
|
||||||
|
// Subir el DNI del cliente si cumple con con las siguientes características , tipo de archivo (jpg y pdf) y tamaño máximo 2mb.
|
||||||
|
if (isset($_FILES['dnifile']) && $_FILES['dnifile']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$nombreArchivo = implode("_", [$dni, $idReserva, $_FILES['dnifile']['name']]);
|
||||||
|
if (subirArchivo($_FILES['dnifile'], 2, ['image/jpeg', 'image/jpg', 'application/pdf'], 'dni_clientes/', $nombreArchivo)) {
|
||||||
|
echo "<p>Su DNI ha sido recibido</p>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<p>No se ha enviado documento identificado con la reserva</p>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<p>No se ha podido realizar la reserva correctamente!!!</p>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "No se han recibido datos del formulario";
|
||||||
|
}
|
||||||
|
// ************************************************************
|
||||||
|
function guardarFichaReserva($fichaReserva, $nombre_archivo)
|
||||||
|
{
|
||||||
|
$archivo = fopen($nombre_archivo, 'w');
|
||||||
|
fwrite($archivo, $fichaReserva);
|
||||||
|
fclose($archivo);
|
||||||
|
}
|
||||||
|
function guardaListaDatos($registroReserva, $nombre_archivo)
|
||||||
|
{
|
||||||
|
$archivo = fopen($nombre_archivo, 'a');
|
||||||
|
fwrite($archivo, $registroReserva);
|
||||||
|
fclose($archivo);
|
||||||
|
}
|
||||||
|
function subirArchivo($archivo, $tamanoMaximo, $tiposPermitidos, $carpetaDestino, $nombreArchivo)
|
||||||
|
{
|
||||||
|
$nombre = $nombreArchivo;
|
||||||
|
$tipo = $archivo['type'];
|
||||||
|
$tamano = $archivo['size'];
|
||||||
|
$tmp_name = $archivo['tmp_name'];
|
||||||
|
|
||||||
|
if (!in_array($tipo, $tiposPermitidos)) {
|
||||||
|
echo "<p>Error al enviar el fichero al servidor</p>";
|
||||||
|
echo "<p>Has intentado subir un archivo no permitido</p>";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($tamano > ($tamanoMaximo * 1024 * 1024)) {
|
||||||
|
echo "<p>Error al enviar el fichero al servidor</p>";
|
||||||
|
echo "<p>El tamaño excede de $tamanoMaximo Mbytes </p>";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move_uploaded_file($tmp_name, $carpetaDestino . $nombre)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
echo "<p>Error al enviar el fichero al servidor</p>";
|
||||||
|
echo "<p>Error de servidor en el almacenamiento del fichero</p>";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
<!Doctype html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>Reservas hotel</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="estilos.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<?php
|
||||||
|
// Verificar si se recibieron los datos del formulario
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
// Obtener los datos del formulario
|
||||||
|
$entrada = $_POST["entrada"];
|
||||||
|
$salida = $_POST["salida"];
|
||||||
|
$habitacion = $_POST["habitacion"];
|
||||||
|
$regimen = $_POST["regimen"];
|
||||||
|
$spa = $_POST["spa"];
|
||||||
|
$guia = $_POST["guia"];
|
||||||
|
$noches = $_POST["noches"];
|
||||||
|
$coste = $_POST["total"];
|
||||||
|
$nombre = $_POST["nombre"];
|
||||||
|
$email = $_POST["email"];
|
||||||
|
$telefono = $_POST["telefono"];
|
||||||
|
$dni = $_POST["dni"];
|
||||||
|
$info = $_POST["info"];
|
||||||
|
//var_dump($_POST);
|
||||||
|
echo "<br>";
|
||||||
|
// Identificador reserva
|
||||||
|
$id_reserva = time() . "_" . rand(1000, 9999);
|
||||||
|
// Fecha de la reserva
|
||||||
|
$fecha_reserva = date('d-m-Y H:i:s', time());
|
||||||
|
// Formatear los datos para escribir en el archivo
|
||||||
|
$datosReserva = "Id reserva: " . $id_reserva . "\n" .
|
||||||
|
"Fecha de reserva: " . $fecha_reserva . "\n" .
|
||||||
|
"Fecha de entrada: " . $entrada . "\n" .
|
||||||
|
"Fecha de salida: " . $salida . "\n" .
|
||||||
|
"Tipo de habitación: " . $habitacion . "\n" .
|
||||||
|
"Regimen de alojamiento: " . $regimen . "\n" .
|
||||||
|
"Días Spa: " . $spa . "\n" .
|
||||||
|
"Días Guia: " . $guia . "\n" .
|
||||||
|
"Duración estancia: " . $noches . "\n" .
|
||||||
|
"Coste Total: " . $coste . "\n" .
|
||||||
|
"Nombre: " . $nombre . "\n" .
|
||||||
|
"Correo electrónico: " . $email . "\n" .
|
||||||
|
"Teléfono: " . $telefono . "\n" .
|
||||||
|
"DNI: " . $dni . "\n\n";
|
||||||
|
// Mensaje correo para el hotel
|
||||||
|
// Correo electrónico de destino
|
||||||
|
$destinatario = "appasinxx@gmail.com";
|
||||||
|
// Asunto del correo electrónico
|
||||||
|
$asunto = "Hay una nueva reserva: $id_reserva ";
|
||||||
|
$headers = "Reply-To: " . $email . "\r\n";
|
||||||
|
// Envía el correo electrónico
|
||||||
|
//mail($destinatario, $asunto, $datosReserva,$headers);
|
||||||
|
|
||||||
|
// Ruta del archivo de reserva (dentro del directorio "reservas")
|
||||||
|
$archivoReserva = "reservas/reserva_" . $id_reserva . ".txt";
|
||||||
|
// Crear la ficha de reserva
|
||||||
|
if (file_put_contents($archivoReserva, $datosReserva) !== false) {
|
||||||
|
echo "<p>Reserva confirmada !</p>";
|
||||||
|
echo "<br>";
|
||||||
|
} else {
|
||||||
|
echo "<p>Error al registrar la reserva!</p>";
|
||||||
|
echo "<br>";
|
||||||
|
}
|
||||||
|
// Escribir en listado de reservas
|
||||||
|
$lista_reservas = "listado_reservas.txt";
|
||||||
|
$datos_reserva = $id_reserva . "/_/" . $nombre . "/_/" . $email . "/_/" . $telefono . "/_/" . $entrada . "/_/" . $salida . "/_/" . $fecha_reserva . "/_/" . $noches . "\r\n";
|
||||||
|
file_put_contents($lista_reservas, $datos_reserva, FILE_APPEND | LOCK_EX);
|
||||||
|
// Mensaje cliente confirmación de opciones
|
||||||
|
echo nl2br($info);
|
||||||
|
echo "<br>";
|
||||||
|
echo "<br>";
|
||||||
|
echo "<p>Esta es la información detallada de tu reserva:</p>";
|
||||||
|
echo nl2br($datosReserva);
|
||||||
|
// Recibir DNI cliente
|
||||||
|
// Directorio donde se guardarán los archivos subidos
|
||||||
|
$directorio_subida = "dni_clientes/";
|
||||||
|
// Nombre del archivo y ruta de destino
|
||||||
|
$nombre_archivo = $_FILES["dnifile"]["name"];
|
||||||
|
$nombre_archivo_final = $dni . '_' . $id_reserva . '_' . $nombre_archivo;
|
||||||
|
$ruta_archivo = $directorio_subida . $nombre_archivo_final;
|
||||||
|
// Tamaño máximo permitido (2MB)
|
||||||
|
$tamano_maximo = 2 * 1024 * 1024;
|
||||||
|
// Obtiene la extensión del archivo en minúsculas
|
||||||
|
$extension_archivo = strtolower(pathinfo($_FILES["dnifile"]["name"], PATHINFO_EXTENSION));
|
||||||
|
// Array de extensiones permitidas
|
||||||
|
$extensiones_permitidas = array("jpg", "jpeg", "pdf");
|
||||||
|
// Verifica si el archivo es una extensión permitida y no excede el tamaño máximo
|
||||||
|
if (in_array($extension_archivo, $extensiones_permitidas) && $_FILES["dnifile"]["size"] <= $tamano_maximo) {
|
||||||
|
// Intenta mover el archivo al directorio de destino
|
||||||
|
if (move_uploaded_file($_FILES["dnifile"]["tmp_name"], $ruta_archivo)) {
|
||||||
|
echo "Su DNI ha sido recibido.";
|
||||||
|
} else {
|
||||||
|
echo "Lo siento, hubo un error al subir su DNI.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Lo siento, solo se permiten archivos en formato JPG o PDF con un tamaño máximo de 2MB.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Si no se recibieron datos por POST, mostrar un mensaje de error
|
||||||
|
echo "Error: No se recibieron datos del formulario.";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||