-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaintainadmin.html
120 lines (114 loc) · 3.95 KB
/
maintainadmin.html
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
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<title>Maintain Administrators</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="maintaindriver.html">Update Drivers</a></li>
<li><a href="maintainvehicle.html">Update Vehicles</a></li>
<li><a href="maintainroutes.html">Update Route</a></li>
<li><a href="maintainadmin.html">Update Admin</a></li>
<li><a href="utilisationReport.html">Utilisation Report</a></li>
<li><a href="logout.php">Log Out</a></li>
</ul>
</head>
<body>
<div class="container">
<br />
<br />
<br />
<div class="table-responsive">
<div id="main"> <h1> Administrator Form</h1><br />
<div id="live_data"></div>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
function fetch_data()
{
$.ajax({
url:"select.php",
method:"POST",
success:function(data){
$('#live_data').html(data);
}
});
}
fetch_data();
$(document).on('click', '#btn_add', function(){
var username = $('#Username').text();
var password = $('#Password').text();
if(username == '')
{
alert("Enter username");
return false;
}
if(password == '')
{
alert("Enter password");
return false;
}
$.ajax({
url:"insert.php",
method:"POST",
data:{username:username, password:password},
dataType:"text",
success:function(data)
{
alert(data);
fetch_data();
}
})
});
function edit_data(id, text, column_name)
{
$.ajax({
url:"edit.php",
method:"POST",
data:{id:id, text:text, column_name:column_name},
dataType:"text",
success:function(data){
alert(data);
}
});
}
$(document).on('blur', '.Username', function(){
if(confirm("Are you sure you want to edit this admin information?"))
{
var id = $(this).data("id1");
var username = $(this).text();
edit_data(id, username, "Username");}
});
$(document).on('blur', '.Password', function(){
if(confirm("Are you sure you want to edit this admin information?"))
{
var id = $(this).data("id2");
var password = $(this).text();
edit_data(id,password, "Password"); }
});
$(document).on('click', '.btn_delete', function(){
var id=$(this).data("id3");
if(confirm("Are you sure you want to delete this?"))
{
$.ajax({
url:"delete.php",
method:"POST",
data:{id:id},
dataType:"text"
,
success:function(data){
alert(data);
fetch_data();
}
});
}
});
});
</script>