-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-manage-user.php
183 lines (148 loc) · 5.93 KB
/
admin-manage-user.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
<?php
require 'authentication.php'; // admin authentication check
// auth check
if ($user_id == NULL || $security_key == NULL) {
header('Location: index.php');
}
// check admin
if ($user_role != 1) {
header('Location: task-info.php');
}
if (isset($_GET['delete_user'])) {
$action_id = $_GET['admin_id'];
$task_sql = "DELETE FROM `task_info` WHERE `t_user_id` = $action_id";
$delete_task = $obj_admin->db->prepare($task_sql);
$delete_task->execute();
$attendance_sql = "DELETE FROM `attendance_info` WHERE `atn_user_id` = $action_id";
$delete_attendance = $obj_admin->db->prepare($attendance_sql);
$delete_attendance->execute();
$sql = "DELETE FROM `tbl_admin` WHERE `user_id` = :id";
$sent_po = "admin-manage-user.php";
$obj_admin->delete_data_by_this_method($sql, $action_id, $sent_po);
}
$page_name = "Admin";
include("include/sidebar.php");
if (isset($_POST['add_new_employee'])) {
$error = $obj_admin->add_new_user($_POST);
}
?>
<!--modal for employee add-->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h2 class="modal-title text-center">Add Employee Info</h2>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<?php if (isset($error)) { ?>
<h5 class="alert alert-danger"><?php echo $error; ?></h5>
<?php } ?>
<form role="form" action="" method="post" autocomplete="off">
<div class="form-horizontal">
<div class="form-group">
<label class="control-label text-p-reset">Fullname</label>
<div class="">
<input type="text" placeholder="Enter Employee Name" name="em_fullname" list="expense" class="form-control input-custom" id="default" required>
</div>
</div>
<div class="form-group">
<label class="control-label text-p-reset">Username</label>
<div class="">
<input type="text" placeholder="Enter Employee username" name="em_username" class="form-control input-custom" required>
</div>
</div>
<div class="form-group">
<label class="control-label text-p-reset">Email</label>
<div class="">
<input type="email" placeholder="Enter Employee Email" name="em_email" class="form-control input-custom" required>
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
<button type="submit" name="add_new_employee" class="btn btn-primary btn-sm rounded-0">Add Employee</button>
</div>
<div class="col-sm-3">
<button type="submit" class="btn btn-default btn-sm rounded-0" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!--modal for employee add-->
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="well well-custom">
<?php if (isset($error)) { ?>
<script type="text/javascript">
$('#myModal').modal('show');
</script>
<?php } ?>
<?php if ($user_role == 1) { ?>
<div class="btn-group">
<button class="btn btn-primary-custom btn-menu" data-toggle="modal" data-target="#myModal">Add New Employee</button>
</div>
<?php } ?>
<ul class="nav nav-tabs nav-justified nav-tabs-custom">
<li><a href="manage-admin.php">Manage Admin</a></li>
<li class="active"><a href="admin-manage-user.php">Manage Employee</a></li>
</ul>
<div class="gap"></div>
<div class="table-responsive">
<table class="table table-codensed table-custom">
<thead>
<tr>
<th>Serial No.</th>
<th>Fullname</th>
<th>Email</th>
<th>Username</th>
<th>Temp Password</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM tbl_admin WHERE user_role = 2 ORDER BY user_id DESC";
$info = $obj_admin->manage_all_info($sql);
$serial = 1;
$num_row = $info->rowCount();
if ($num_row == 0) {
echo '<tr><td colspan="7">No Data found</td></tr>';
}
while ($row = $info->fetch(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><?php echo $serial;
$serial++; ?></td>
<td><?php echo $row['fullname']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['username']; ?></td>
<td><?php echo $row['temp_password']; ?></td>
<td><a title="Update Employee" href="update-employee.php?admin_id=<?php echo $row['user_id']; ?>"><span class="glyphicon glyphicon-edit"></span></a> <a title="Delete" href="?delete_user=delete_user&admin_id=<?php echo $row['user_id']; ?>" onclick=" return check_delete();"><span class="glyphicon glyphicon-trash"></span></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
if (isset($_SESSION['update_user_pass'])) {
echo '<script>alert("Password updated successfully");</script>';
unset($_SESSION['update_user_pass']);
}
include("include/footer.php");
?>