-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpagos.php
109 lines (95 loc) · 3.38 KB
/
pagos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start();
require_once("gestionBD.php");
require_once("gestionarPagos.php");
if (!isset($_SESSION['Perfil']))
Header("Location: login.php");
if (isset($_REQUEST["unset"])) {
unset($_SESSION["formulario"]);
unset($_REQUEST);
}
$conexion = crearConexionBD();
$ultPagos = getUltimosPagos($conexion, $_SESSION["Perfil"]);
if (!empty($_POST)) {
$pagoEncontrado = null;
if ($_POST["FECHA"] == "0000-00-00") {
$pagoEncontrado["ERROR"] = "<p>La fecha no puede estar vacía</p>";
} else if (!preg_match("/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/", $_POST["FECHA"]))
$pagoEncontrado["ERROR"] = "<p>La fecha debe cumplir su formato</p>";
else {
$fecha = new DateTime($_POST["FECHA"]);
$pagoEncontrado = buscarPago($conexion, $_SESSION["Perfil"], $fecha->format('d/m/Y'));
if (empty($pagoEncontrado)) $pagoEncontrado["ERROR"] = "No hay ningún pago que coincida con la fecha indicada: " . $fecha->format('d/m/Y');
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>FiTrainer</title>
<meta name="description" content="Perfil">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="icon" href="img/logoFT.png">
</head>
<body>
<?php
include("header.php");
?>
<div class="WhiteBackgroundContainer">
<div class="bigContainer">
<h3>Últimos Pagos</h3>
<div class=scroll>
<table>
<tr>
<th>
Fecha
</th>
<th>
Archivo
</th>
</tr>
<?php foreach ($ultPagos as $p) { ?>
<tr>
<td>
Fecha <?php echo $p["FECHA"] ?>
</td>
<td>
Archivo <a href="<?php echo $p["RUTAFICHERO"] ?>"><?php echo $p["RUTAFICHERO"] ?></a>
</td>
</tr>
<?php } ?>
</table>
</div>
</div>
<div class=smallContainer>
<h3>Buscar pagos</h3>
<form method="POST" action="pagos.php">
<div class="row">
<label for="FECHA" class="col-25">Fecha:</label>
<input type="date" class="col-75" id="FECHA" name="FECHA" placeholder="dd/mm/yyyy">
</div>
<br>
<div class="row">
<input type="submit" value="Buscar">
</div>
</form>
<?php if (isset($pagoEncontrado["RUTAFICHERO"])) { ?>
<h3>Resultado de la Búsqueda</h3>
Archivo: <a href="<?php echo $pagoEncontrado["RUTAFICHERO"] ?>"> <?php echo $pagoEncontrado["RUTAFICHERO"] ?></a>
<?php
} elseif (isset($pagoEncontrado["ERROR"])) {
?>
<h3>Resultado de la Búsqueda</h3>
<?php echo $pagoEncontrado["ERROR"] ?></a>
<?php
}
?>
</div>
</div>
<?php
include("footer.php");
cerrarConexionBD($conexion);
?>
</body>
</html>