forked from NAchref/Admin_Panel_Management_PHP_MYSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
197 lines (157 loc) · 7.37 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
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
<?php
include 'inc/header.php';
Session::CheckSession();
$logMsg = Session::get('logMsg');
if (isset($logMsg)) {
echo $logMsg;
}
$msg = Session::get('msg');
if (isset($msg)) {
echo $msg;
}
Session::set("msg", NULL);
Session::set("logMsg", NULL);
?>
<?php
if (isset($_GET['remove'])) {
$remove = preg_replace('/[^a-zA-Z0-9-]/', '', (int)$_GET['remove']);
$removeUser = $users->deleteUserById($remove);
}
if (isset($removeUser)) {
echo $removeUser;
}
if (isset($_GET['deactive'])) {
$deactive = preg_replace('/[^a-zA-Z0-9-]/', '', (int)$_GET['deactive']);
$deactiveId = $users->userDeactiveByAdmin($deactive);
}
if (isset($deactiveId)) {
echo $deactiveId;
}
if (isset($_GET['active'])) {
$active = preg_replace('/[^a-zA-Z0-9-]/', '', (int)$_GET['active']);
$activeId = $users->userActiveByAdmin($active);
}
if (isset($activeId)) {
echo $activeId;
}
?>
<div class="card ">
<div class="card-header">
<h3><i class="fas fa-users mr-2"></i>User list <span class="float-right">Welcome! <strong>
<span class="badge badge-lg badge-secondary text-white">
<?php
$username = Session::get('username');
if (isset($username)) {
echo $username;
}
?></span>
</strong></span></h3>
</div>
<div class="card-body pr-2 pl-2">
<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th class="text-center">SL</th>
<th class="text-center">Name</th>
<th class="text-center">Username</th>
<th class="text-center">Email address</th>
<th class="text-center">Mobile</th>
<th class="text-center">Status</th>
<th class="text-center">Created</th>
<th width='25%' class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
$allUser = $users->selectAllUserData();
if ($allUser) {
$i = 0;
foreach ($allUser as $value) {
$i++;
?>
<tr class="text-center"
<?php if (Session::get("id") == $value->id) {
echo "style='background:#d9edf7' ";
} ?>
>
<td><?php echo $i; ?></td>
<td><?php echo $value->name; ?></td>
<td><?php echo $value->username; ?> <br>
<?php if ($value->roleid == '1'){
echo "<span class='badge badge-lg badge-info text-white'>Admin</span>";
} elseif ($value->roleid == '2') {
echo "<span class='badge badge-lg badge-dark text-white'>Editor</span>";
}elseif ($value->roleid == '3') {
echo "<span class='badge badge-lg badge-dark text-white'>User Only</span>";
} ?></td>
<td><?php echo $value->email; ?></td>
<td><span class="badge badge-lg badge-secondary text-white"><?php echo $value->mobile; ?></span></td>
<td>
<?php if ($value->isActive == '0') { ?>
<span class="badge badge-lg badge-info text-white">Active</span>
<?php }else{ ?>
<span class="badge badge-lg badge-danger text-white">Deactive</span>
<?php } ?>
</td>
<td><span class="badge badge-lg badge-secondary text-white"><?php echo $users->formatDate($value->created_at); ?></span></td>
<td>
<?php if ( Session::get("roleid") == '1') {?>
<a class="btn btn-success btn-sm
" href="profile.php?id=<?php echo $value->id;?>">View</a>
<a class="btn btn-info btn-sm " href="profile.php?id=<?php echo $value->id;?>">Edit</a>
<a onclick="return confirm('Are you sure To Delete ?')" class="btn btn-danger
<?php if (Session::get("id") == $value->id) {
echo "disabled";
} ?>
btn-sm " href="?remove=<?php echo $value->id;?>">Remove</a>
<?php if ($value->isActive == '0') { ?>
<a onclick="return confirm('Are you sure To Deactive ?')" class="btn btn-warning
<?php if (Session::get("id") == $value->id) {
echo "disabled";
} ?>
btn-sm " href="?deactive=<?php echo $value->id;?>">Disable</a>
<?php } elseif($value->isActive == '1'){?>
<a onclick="return confirm('Are you sure To Active ?')" class="btn btn-secondary
<?php if (Session::get("id") == $value->id) {
echo "disabled";
} ?>
btn-sm " href="?active=<?php echo $value->id;?>">Active</a>
<?php } ?>
<?php }elseif(Session::get("id") == $value->id && Session::get("roleid") == '2'){ ?>
<a class="btn btn-success btn-sm " href="profile.php?id=<?php echo $value->id;?>">View</a>
<a class="btn btn-info btn-sm " href="profile.php?id=<?php echo $value->id;?>">Edit</a>
<?php }elseif( Session::get("roleid") == '2'){ ?>
<a class="btn btn-success btn-sm
<?php if ($value->roleid == '1') {
echo "disabled";
} ?>
" href="profile.php?id=<?php echo $value->id;?>">View</a>
<a class="btn btn-info btn-sm
<?php if ($value->roleid == '1') {
echo "disabled";
} ?>
" href="profile.php?id=<?php echo $value->id;?>">Edit</a>
<?php }elseif(Session::get("id") == $value->id && Session::get("roleid") == '3'){ ?>
<a class="btn btn-success btn-sm " href="profile.php?id=<?php echo $value->id;?>">View</a>
<a class="btn btn-info btn-sm " href="profile.php?id=<?php echo $value->id;?>">Edit</a>
<?php }else{ ?>
<a class="btn btn-success btn-sm
<?php if ($value->roleid == '1') {
echo "disabled";
} ?>
" href="profile.php?id=<?php echo $value->id;?>">View</a>
<?php } ?>
</td>
</tr>
<?php }}else{ ?>
<tr class="text-center">
<td>No user availabe now !</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php
include 'inc/footer.php';
?>