-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathestadisticas.php
165 lines (146 loc) · 6.1 KB
/
estadisticas.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
session_start();
require_once("gestionBD.php");
require_once("consultasEstadisticas.php");
require_once("consultasSql.php");
require_once("gestionJugadores.php");
require_once("gestionarUsuarios.php");
if(isset($_SESSION['login'])){
$nickUsuario = $_SESSION['login'];
}else{
Header("Location: login.php");
}
$conexion = crearConexionBD();
$nombreVideojuegoElegido="";
if(isset($_REQUEST["nVideojuegos"])) {
$nombreVideojuegoElegido=$_REQUEST["nVideojuegos"];
$_SESSION["nVideojuegos"]=$nombreVideojuegoElegido;
}
$fechaElegida="";
if(isset($_POST["fecha"]) ) {
$fechaElegida=$_POST["fecha"];
if($fechaElegida==""){
echo "<font color='red' class='error'><strong>Las fechas son incompatibles.</strong></font>";
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<title>Resultados</title>
<?php include_once("headComun.php"); ?>
<link rel="stylesheet" type="text/css" href="css/error_form.css">
<link rel="stylesheet" type="text/css" href="css/perfil.css">
<link rel="stylesheet" type="text/css" href="css/estadisticas.css">
</head>
<body>
<?php
if(isset($_SESSION['ADMIN'])){
include_once("navegacion_ADMIN.php");
}else{
include_once("navegacion.php");
}
?>
<?php
$nombreElegido=$nombreVideojuegoElegido;
if($nombreElegido!=""){
$nombre_Videojuego=$nombreElegido;
}else{
$nombre_Videojuego=$_SESSION["nVideojuegos"];
}
$IDVideojuego=obtenOID_V($conexion, $nombre_Videojuego);
$competicionesJugadas=competiciones_jugadas($conexion, $nombre_Videojuego);
$competicionesJugadasConcrete=competiciones_jugadas_concrete($conexion, $nombre_Videojuego);
$competicionesGanadas=competiciones_ganadas($conexion, $nombre_Videojuego);
$partidosTotales=partidos_totales($conexion, $nombre_Videojuego);
$partidosGanados=cantidad_partidos_ganados($conexion, $nombre_Videojuego);
$partidosPerdidos=cantidad_partidos_perdidos($conexion, $nombre_Videojuego);
$partidosJugadosConcrete=partidos_jugados_concrete($conexion, $nombre_Videojuego);
$rachaActualPorVideojuego=racha_videojuego($conexion, $nombre_Videojuego);
$competicionesGanadasConcrete=competiciones_ganadas_concrete($conexion, $nombre_Videojuego);
$mejorJugadosEstadisticas= mejorJugadorEstadisticas($conexion,$nombre_Videojuego);
if($partidosGanados[0]!=0 || $partidosTotales[0]!=0){
$porcentajeVictorias=($partidosGanados[0]*100)/$partidosTotales[0];
}else{
$porcentajeVictorias=0;
}
?>
<form class="col-3 formularioCalendario" action="estadisticas.php" method="post">
<input class="calendarF" id="fecha" name="fecha" type="date">
<input type="submit" name="Insertar" value="Buscar">
</form>
<center><h1 class="tittle">UDConstantina <?php ECHO $nombre_Videojuego ?></h1></center>
<img class="image" src="images/logo.png">
<h2 class="col-3 scroll"><?php partidosDestallados($partidosJugadosConcrete,$fechaElegida) ?></h2>
<div class="col-3 stadisticData">
<h1>Partidos jugados: <?php ECHO $partidosTotales[0] ?></h1>
<h1>Partidos ganados: <?php ECHO $partidosGanados[0] ?></h1>
<h1>Partidos perdidos: <?php ECHO $partidosPerdidos[0] ?></h1>
<h1>Porcentaje de victorias: <?php ECHO $porcentajeVictorias."%" ?></h1>
<h1>Racha actual del equipo: <?php ECHO $rachaActualPorVideojuego[0] ?></h1>
<h1>Hemos competido en <?php ECHO $competicionesJugadas[0] ?> ocasiones: <?php echo "<br />"; ECHO nombreCompeticiones($competicionesJugadasConcrete) ?></h1>
<h1>Hemos ganado <?php ECHO $competicionesGanadas[0] ?> veces : <?php echo "<br />"; nombreCompeticionesGanadas($competicionesGanadasConcrete) ?></h1>
</div>
<div class="col-tab-10 col-3 mejorJugadorEstadisticas">
<h1>MEJOR JUGADOR DEL EQUIPO</h1>
<h2 ><?php mejorJugadorEstats($mejorJugadosEstadisticas) ?></h2>
</div>
<?php
function nombreCompeticiones($competicionesJugadasConcrete){
foreach($competicionesJugadasConcrete as $competicion) {
$nombre_competicion = $competicion[0];
ECHO "-".$nombre_competicion."<br />";
}
}
?>
<?php
function mejorJugadorEstats($mejorJugadosEstadisticas){
foreach($mejorJugadosEstadisticas as $estadistica) {
$nombre=$estadistica["NOMBREJUGADOR"];
$nick=$estadistica["NOMBREVIRTUALJUGADOR"];
$nacionalidad=$estadistica["NACIONALIDADJUGADOR"];
$aniosDeExperiencia=$estadistica["NUMAÑOSEXPERIENCIAJUGADOR"];
ECHO "<br />Nombre: ".$nombre."<br />Nick: ".$nick."<br />Nacionalidad: ".$nacionalidad."<br />Años de experiencia: ".$aniosDeExperiencia;
}
}
?>
<?php
function nombreCompeticionesGanadas($competicionesGanadasConcrete){
foreach($competicionesGanadasConcrete as $competicion) {
$nombre_competicion = $competicion[0];
ECHO "-".$nombre_competicion."<br />";
}
}
?>
<?php
function partidosDestallados($partidosJugadosConcrete,$fechaElegida){
foreach($partidosJugadosConcrete as $partido) {
$lugar = $partido["LUGAR"];
$fecha=$partido["FECHACOMPETICION"];
$premio=$partido["PREMIO"];
$medio=$partido["MEDIO"];
$ganada=$partido["GANADA"];
if($ganada!=1){
if($fechaElegida!=""){
$fechaFormateada=date("d/m/y", strtotime($fechaElegida));
if($fecha==$fechaFormateada ){
ECHO "Lugar: ".$lugar."<br />Fecha: ".$fecha."<br /> Premio: ".$premio."€<br /> Medio: ".$medio."<br /> Resultado: "."Perdido <br />";
}
}else{
ECHO "Lugar: ".$lugar."<br />Fecha: ".$fecha."<br />Premio: ".$premio."€<br />Medio: ".$medio."<br /> Resultado:"."Perdido <br />";
}
}else{
if($fechaElegida!="" ){
$fechaFormateada=date("d/m/y", strtotime($fechaElegida));
if($fecha==$fechaFormateada ){
ECHO "Lugar: ".$lugar."<br />Fecha: ".$fecha."<br /> Premio: ".$premio."€<br /> Medio: ".$medio."<br /> Resultado: "."Ganada <br />";
}
}else{
ECHO "Lugar: ".$lugar."<br />Fecha: ".$fecha."<br />Premio: ".$premio."€<br />Medio: ".$medio."<br /> Resultado:"."Ganado <br />";
}
}
echo "<br/>";
}
}
?>
</body>