-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasignagrupo.php
273 lines (248 loc) · 14.3 KB
/
asignagrupo.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
include_once './bd/conexion.php';
$objconexion = new Conexion();
$conexion = $objconexion->Conectar();
$query_where = "WHERE true ";
if (isset($_GET["u"]) && preg_match("/^[0-9]+$/", $_GET["u"])){
$int = intval($_GET['u']);
$query_where = "WHERE u.id = ".$int." ";
}
$query_where_q = "and true ";
$op1 = "";
$op2 = "";
$op3 = "";
if (isset($_GET["q"])){
switch($_GET["q"]){
case "1":
$query_where_q = "and true ";
$op1 = "selected";
break;
case "2":
$query_where_q = "and u.follower = 1 ";
$op2 = "selected";
break;
case "3":
$query_where_q = "and u.following = 1 ";
$op3 = "selected";
break;
default:
$query_where_q = "and true ";
$op1 = "selected";
}
}else{
$op1 = "selected";
}
$query = "SELECT u.id, u.login, u.name, u.avatar_url, ".
"u.email, u.company, u.blog, u.location, u.bio, u.twitter_username, ".
"u.follower, u.following, ".
"(SELECT group_concat(concat(g.icon , ' ' , g.nombre) order by 1 asc separator ', ') ".
"from grupo_usuario gu, grupo g ".
"where gu.id_grupo = g.id and gu.id_usuario = u.id) grupos_asignado ".
"FROM USUARIO u ".
$query_where.
$query_where_q.
"ORDER BY name";
$resultado = $conexion->prepare($query);
$resultado->execute();
$query2 = "SELECT id, nombre, icon ".
"FROM GRUPO ".
"ORDER BY nombre";
$resultado2 = $conexion->prepare($query2);
$resultado2->execute();
?>
<!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, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Groups</title>
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" />
<link href="css/styles.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.1.0/js/all.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./vendor/sweetalert2/dist/dark.css" />
<link rel="stylesheet" href="./css/select_style.css" />
<!-- Custom styles for this page -->
<!-- <link href="./vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet"> -->
<link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.ico">
</head>
<body class="sb-nav-fixed">
<nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
<!-- Navbar Brand-->
<a href="index.php">
<img src="./assets/img/logo.png" class="logo-brand" alt="Logo" width="80px">
</a>
<a class="navbar-brand ps-3" href="index.php">Groups</a>
<!-- Sidebar Toggle-->
<button class="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" id="sidebarToggle" href="#!"><i class="fas fa-bars"></i></button>
<!-- Navbar Search-->
<form class="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
</form>
<!-- Navbar-->
<ul class="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fas fa-user fa-fw"></i></a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#!">Salir</a></li>
</ul>
</li>
</ul>
</nav>
<div id="layoutSidenav">
<div id="layoutSidenav_nav">
<nav class="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
<div class="sb-sidenav-menu">
<div class="nav">
<a class="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapseUsuarios" aria-expanded="false" aria-controls="collapseLayouts">
<div class="sb-nav-link-icon"><i class="fas fa-columns"></i></div>
Usuarios
<div class="sb-sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
</a>
<div class="collapse" id="collapseUsuarios" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordion">
<nav class="sb-sidenav-menu-nested nav">
<a class="nav-link" href="usuarios.php">Usuarios</a>
<a class="nav-link" href="importar.php">Importar</a>
<a class="nav-link" href="asignagrupo.php">Asigna Grupo</a>
</nav>
</div>
<a class="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapseGrupos" aria-expanded="false" aria-controls="collapseLayouts">
<div class="sb-nav-link-icon"><i class="fas fa-columns"></i></div>
Grupos
<div class="sb-sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
</a>
<div class="collapse" id="collapseGrupos" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordion">
<nav class="sb-sidenav-menu-nested nav">
<a class="nav-link" href="grupos.php">Grupos</a>
<a class="nav-link" href="index.php">Mis Grupos</a>
<a class="nav-link" href="detallegrupo.php">Detalle Grupos</a>
</nav>
</div>
</div>
</div>
<div class="sb-sidenav-footer">
<div class="small">By <a class="about" href="https://github.com/doguedogue">doguedogue</a></div>
</div>
</nav>
</div>
<div id="layoutSidenav_content">
<main>
<div class="container-fluid px-4">
<div class="card mb-4">
<div class="card-body">
<h2>Asigna Grupos</h2>
<ol class="breadcrumb mb-1">
<li class="breadcrumb-item mr-2 mb-2">
<select class="form-control combo-dark" name="search" id="search">
<option value="1" <?php echo $op1; ?>>Todos</option>
<option value="2" <?php echo $op2; ?>>Followers</option>
<option value="3" <?php echo $op3; ?>>Following</option>
</select>
</li>
<li class="breadcrumb-item mr-2 mb-2">
<button type="button" class="btn btn-success mr-2" id="grupos">
<span><i class='fas fa-people-group'></i></span>Grupos</button>
</li>
<li class="breadcrumb-item mr-2 mb-2">
<button type="button" class="btn btn-info mr-2" id="usuarios">
<span><i class='fas fa-user-group'></i></span>Usuarios</button>
</li>
</ol>
</div>
</div>
<div class="card mb-4">
<div class="card-body">
<ol class="breadcrumb mb-1">
<li class="breadcrumb-item mr-2 mb-2">
<select class="form-control combo-dark" name="grupos_select" id="grupos_select">
<?php
$i = 1;
while($data2 = $resultado2->fetch(PDO::FETCH_ASSOC)){
$selected = ($i==1)?"selected":"";
print "<option value='".$data2['id']."' ".$selected.">".$data2['icon']." ".$data2['nombre']."</option>";
$i += 1;
}
?>
</select>
</li>
<li class="breadcrumb-item mr-2 mb-2">
<button type="button" class="btn btn-primary mr-2" id="button">
<span><i class="fa-solid fa-layer-group"></i></span>Asigna</button>
</li>
</ol>
</div>
</div>
<div class="card mb-4">
<div class="card-body">
<div >
<table class="table table-bordered" width="100%" cellspacing="0" id="dataTablesUsuarios">
<thead>
<tr>
<th>Id</th>
<th>Imagen</th>
<th>Username</th>
<th>Nombre</th>
<th>Grupos</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Id</th>
<th>Imagen</th>
<th>Username</th>
<th>Nombre</th>
<th>Grupos</th>
</tr>
</tfoot>
<tbody>
<?php
while($data = $resultado->fetch(PDO::FETCH_ASSOC)){
print "<tr>";
print "<td>". $data['id'] . "</td>";
print "<td><img src='". $data['avatar_url'] ."' alt='avatar' width='40px' class='avatar'></td>";
print "<td>". $data['login'] . "</td>";
print "<td>". $data['name'] . "</td>";
print "<td>". $data['grupos_asignado'] . "</td>";
print "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<footer class="py-2 foooter-dark mt-auto">
<div class="container-fluid px-4">
<div class="d-flex align-items-center justify-content-between small">
<div class="text-muted">Copyright © Groups 2022
<div class="about">By <a href="https://github.com/doguedogue">doguedogue</a></div>
</div>
<div>
<a href="privacypolicy.html">Privacy Policy</a>
</div>
</div>
</div>
</footer>
</div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="./vendor/jquery/jquery.min.js"></script>
<script src="./vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="./vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Page level plugins -->
<script src="./vendor/datatables/jquery.dataTables.min.js"></script>
<script src="./vendor/datatables/dataTables.bootstrap4.min.js"></script>
<!-- Page level custom scripts -->
<script src="./js/datatables.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="js/scripts.js"></script>
<script src="js/asignagrupo.js"></script>
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" crossorigin="anonymous"></script>
<script src="js/datatables-simple.js"></script>
<script src="./vendor/sweetalert2/dist/sweetalert2.min.js"></script>
</body>
</html>