-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlista_perfiles.php
118 lines (97 loc) · 3.32 KB
/
lista_perfiles.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
<?php
include 'seguro.php';
include 'conectadb.php';
if(isset($_GET['f_rol'])){
$xid_rol=$_GET['f_rol'];
}else{
$xid_rol="X";
}
if($xid_rol == null ){
$xid_rol="X";
}
if(isset($_GET['f_texto'])){
$texto=$_GET['f_texto'];
}else{
$texto="X";
}
//echo "id_rol :".$xid_rol;
//echo $texto;
$cont=0;
?>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<HR>
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Rol</th>
<th class="text-center">Usuarios</th>
<th class="text-center" colspan="3">Opciones</th>
</tr>
</thead>
<?php
$query= " Select ".
" a.idrol, a.nom_rol, b.idrol, ".
" SUM(case when b.idrol IS NULL then 0 else 1 END) cant ".
" FROM roles a ".
" left outer join usuarios b on (a.idrol = b.idrol) ";
if($xid_rol != "X"){
$query .="where a.idrol ='".$xid_rol."' ";
}
if($texto != "X"){
// $query .="where CONCAT (nombre, ' ', apellido) like '%".$texto."%' ";
}
$query .= " group by a.idrol, a.nom_rol, b.idrol order by a.nom_rol ";
// echo $query;
$rset=mysql_query($query,$con) or die ("conexion fallida: ".mysql_error());
while($line=mysql_fetch_array($rset,MYSQL_ASSOC)){
$cont++;
?>
<tbody>
<tr>
<td><?php echo $cont ?></td>
<td><?php echo $line['nom_rol'] ?></td>
<td class="text-center"><?php echo $line['cant'] ?></td>
<td class="text-center">
<input type='button' dir="<?php echo $line['idrol'] ?>" role="<?php echo $line['nom_rol']?>" class='usuarios_perfil btn btn-xs btn-warning btn-sm"' value='Usuarios'>
</td>
<td class="text-center">
<input type='button' dir="<?php echo $line['idrol'] ?>" role="<?php echo $line['nom_rol']?>" class='accesos_perfil btn btn-xs btn-success btn-sm"' value='Accesos'>
</td>
<!-- <td class="text-center">
<input type='button' dir="<?php echo $line['idrol'] ?>" class='editar_perfil btn btn-xs btn-primary btn-sm"' value='Editar'>
</td>
<td class="text-center">
<input type='button' dir="<?php echo $line['idrol'] ?>" class='eliminar_perfil btn btn-xs btn-danger btn-sm"' value='Eliminar'>
</td>-->
</tr>
<?php
}
?>
</tbody>
</table>
<script>
$(function(){
$('.eliminar_perfil').click(function(event) {
id_perfil = $(this).attr('dir');
//alert(id_acceso);
$.post('del_pefil.php', { id_perfil: id_perfil },
function(data, textStatus, xhr) {
data = $.trim(data);
if(data=='1'){
cargar('perfiles.php');
}
});
});
$('.usuarios_perfil').click(function(event) {
idx = $(this).attr('dir');
name = $(this).attr('role');
cargar('usuarios_perfil.php?f_id='+idx+'&nombre='+name);
});
$('.accesos_perfil').click(function(event) {
idx = $(this).attr('dir');
name = $(this).attr('role');
cargar('accesos_perfil.php?f_id='+idx+'&nombre='+name);
});
})
</script>