-
Notifications
You must be signed in to change notification settings - Fork 2
/
users.php
103 lines (96 loc) · 2.68 KB
/
users.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
<?php
?>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<button class="btn btn-primary float-right btn-sm" id="new_user"><i class="fa fa-plus"></i> New user</button>
</div>
</div>
<br>
<div class="row">
<div class="card col-lg-12">
<div class="card-body">
<table class="table-striped table-bordered col-md-12">
<thead>
<tr>
<th class="text-center">#</th>
<th class="text-center">Name</th>
<th class="text-center">Username</th>
<th class="text-center">Type</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
include 'db_connect.php';
$type = array("", "Admin", "Staff", "Alumnus/Alumna");
$users = $conn->query("SELECT * FROM users order by name asc");
$i = 1;
while ($row = $users->fetch_assoc()) :
?>
<tr>
<td class="text-center">
<?php echo $i++ ?>
</td>
<td>
<?php echo ucwords($row['name']) ?>
</td>
<td>
<?php echo $row['username'] ?>
</td>
<td>
<?php echo $type[$row['type']] ?>
</td>
<td>
<center>
<div class="btn-group">
<button type="button" class="btn btn-primary">Action</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item edit_user" href="javascript:void(0)" data-id='<?php echo $row['id'] ?>'>Edit</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item delete_user" href="javascript:void(0)" data-id='<?php echo $row['id'] ?>'>Delete</a>
</div>
</div>
</center>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
$('table').dataTable();
$('#new_user').click(function() {
uni_modal('New User', 'manage_user.php')
})
$('.edit_user').click(function() {
uni_modal('Edit User', 'manage_user.php?id=' + $(this).attr('data-id'))
})
$('.delete_user').click(function() {
_conf("Are you sure to delete this user?", "delete_user", [$(this).attr('data-id')])
})
function delete_user($id) {
start_load()
$.ajax({
url: 'ajax.php?action=delete_user',
method: 'POST',
data: {
id: $id
},
success: function(resp) {
if (resp == 1) {
alert_toast("Data successfully deleted", 'success')
setTimeout(function() {
location.reload()
}, 1500)
}
}
})
}
</script>