-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
151 lines (114 loc) · 7.32 KB
/
index.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
<?php
session_start();
if (isset($_SESSION["id"])){
include("engranajes/conexion.php");
$id= $_SESSION["id"];
$consulta="SELECT * FROM usuarios WHERE id = '$id'";
$resultado= mysqli_query($con,$consulta);
$user= mysqli_fetch_array($resultado);
}
else {
header("location: engranajes/ingresar.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="app/estilos.css">
<title>Home</title>
</head>
<body>
<!-- Como tiene un cambio, la pongo directamente aca en vez de incluir el archivo "header.php" !-->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top" style="max-height: 66px;">
<div class="container-fluid">
<div>
<img src="img/sp.ico" height="50px">
<a class="navbar-brand" href="index.php">SP-Gestor de tareas</a>
</div>
<a class="navbar-brand"><?php echo $user["nombre"]; ?> </a>
</div>
</nav>
<div id="dashboard">
<div class="item">
<a class="btn btn-primary" href="index.php" type="button" >Gestor de tareas</a>
</div>
<div class="item">
<a class="btn btn-primary" href="engranajes/usuarios.php">Usuarios registrados</a>
</div>
<div class="item" id="itemCerrar">
<form id="cSesionform"action="engranajes/cerrarsesion.php" method="post">
<button type="submit"name="salir" class="btn btn-danger"> Cerrar sesion </button>
</form>
</div>
</div>
<div class="card" id="centradoIndex" style="text-align: center; width: 18rem;">
<div class="card-header">
<h1 class="card-title">Tareas</h1>
<p class="card-text">Añade una tarea para organizar mejor tus proyectos</p>
</div>
<div class="card-body">
<form action="engranajes/añadirTarea.php" method="post">
<div class="form-group pb-1">
<input name="nombre"type="text" class="form-control" placeholder="Nombre de la tarea">
</div>
<div class="form-group pb-1">
<textarea name="descripcion" class="form-control" rows="4" placeholder="Desripcion de la tarea"></textarea>
</div>
<div class="form-group pb-1">
<button type="submit" class="btn btn-primary"> Añadir tarea </button>
</div>
</form>
</div>
<?php
if(isset($_SESSION["mensaje"])){
echo '<div class="alert alert-'.$_SESSION["colorMensaje"].' fade show" role="alert">'
.$_SESSION["mensaje"].'.'.
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
unset ($_SESSION["mensaje"]);
unset($_SESSION["colorMensaje"]);
}
?>
</div>
<?php
$consulta="SELECT * FROM tareas WHERE id_usuario = '$id'";
$resultado=mysqli_query($con,$consulta);
if(mysqli_fetch_array($resultado)){
echo '<table class="table table-dark" id="centradoIndex">';
echo'<thead>';
echo'<tr>';
echo'<th style="text-align: center;" scope="col">ID</th>';
echo'<th style="text-align: center;" scope="col">Nombre de tarea</th>';
echo'<th style="text-align: center;" scope="col">Descripcion</th>';
echo'<th style="text-align: center;" scope="col">Acciones</th>';
echo'</tr>';
echo'</thead>';
echo'<tbody>';
$consulta="SELECT * FROM tareas WHERE id_usuario = '$id'";
$resultado=mysqli_query($con,$consulta);
while ($fila = mysqli_fetch_array($resultado)){
echo '<tr>';
echo '<td style="text-align: center;">'. $fila['id_tarea'];
echo '<td style="text-align: center;">'. $fila['nombre_tarea'];
echo '<td style="text-align: center;">'. $fila['descripcion'];
echo '<td><a class="btn btn-danger" href="engranajes/eliminarTarea.php?id='.$fila['id_tarea'].'"'.'>Eliminar tarea</a>';
echo '<a class="btn btn-secondary" href="engranajes/editarTarea.php">Editar tarea</a>';
echo '</tr>';
}
echo'</tbody>';
echo'</table>';
}
else{
echo '<div class="card centrado" id="centradoIndex"style="text-align: center;"><i class="bi bi-card-checklist"> No tienes ninguna tarea por hacer.</i></div>';
}
?>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-SR1sx49pcuLnqZUnnPwx6FCym0wLsk5JZuNx2bPPENzswTNFaQU1RDvt3wT4gWFG" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-j0CNLUeiqtyaRmlzUHCPZ+Gy5fQu0dQ6eZ/xAww941Ai1SxSY+0EQqNXNE6DZiVc" crossorigin="anonymous"></script>
</body>
</html>