-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangepassword.php
145 lines (104 loc) · 5.38 KB
/
changepassword.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
<?php ob_start(); ?>
<!DOCTYPE html>
<html lang="en">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<body>
<div class="container-scroller">
<?php
include("includes/header.php");
if (count($_POST) > 0) {
$employeeId = get_Employee_Id($_POST['employee']);
//echo $encrptPassword = encryptPassword($_POST["currentPassword"]);
//$passwordMatch = password_check($_POST["currentPassword"], $existingPassword );
$password = encryptPassword($_POST["newPassword"]);
if(updateUserPassword($employeeId,$password)){
echo "<script>alert('Password changed successfully')</script>";
}else{
echo "<script>alert('Error occured ')</script>";
}
}
if (strtolower($_SESSION["role"])!="super admin" && strtolower($_SESSION["role"])!="admin" && strtolower($_SESSION["role"])!="entry maker"){
header("Location: index.php");
}
$id = $_SESSION["id"];
?>
<div class="container-fluid page-body-wrapper">
<?php
include("includes/sidebar.php");
if (strtolower($_SESSION["role"])!="super admin" && strtolower($_SESSION["role"])!="admin" && strtolower($_SESSION["role"])!="entry maker"){
echo "<div class='col-md-8 grid-margin stretch-card' style='padding:75px;'><h3>Unauthorized Access!</h3></div>";exit;
}
?>
<div class="main-panel">
<div class="content-wrapper">
<div class="row">
<div class="col-md-8 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h3>Password Change</h3>
<div class="card" style="background: #fcfcfc; padding: 15px;" >
<form name="frmChange" method="post" action="" class="form form-vertical">
<div class="form-group">
<label>Select location</label>
<select name="location" id="locationselect" name="locationselect" class="form-control col-sm-5">
<option value="">Select</option>
<?php if (strtolower($_SESSION["role"])=="super admin"){
$result = getlocations();
while($row = mysqli_fetch_assoc($result )) {
$location_name = $row['location_name'];
if($location_name === isset($_GET['location'])){
echo "<option value='$location_name' selected optionid='$location_name'>{$location_name}</option>";
}else{
echo "<option value='$location_name' optionid='$location_name'>{$location_name}</option>";
}
}
}else if (strtolower($_SESSION["role"])=="admin" || strtolower($_SESSION["role"])=="entry maker"){
echo "<option value='".$_SESSION["location"]."'>".$_SESSION["location"]."</option>";
}
?>
</select>
</div>
<div class="form-group col-sm-5">
<label>Select Employee</label>
<select class="form-control" id="employee" name="employee" class="form-control col-sm-4">
</select>
</div>
<div class="form-group">
<label>New Password</label>
<input type="password" name="newPassword" class="form-control" /><span id="newPassword" class="required">
</div>
<div class="form-group">
<input type="submit" name="submit" value="Submit" class="btn btn-primary">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<?php include("includes/footer.php");?>
</div>
<!-- main-panel ends -->
</body>
<script type="text/javascript">
$('#locationselect').on('change', function() {
var region = $("#locationselect").val();
$.ajax({
type : "GET",
data : "region="+ region,
url : "getregionalemployees.php",
success : function(response)
{
var data = $.parseJSON(response);
$('#employee').html(data);
}
});
});
</script>
</html>