-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddadmin.php
259 lines (121 loc) · 5.02 KB
/
addadmin.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
<?php
session_start();
if(!isset($_SESSION['adminusername']))
{
header("location: adminlogin.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>VisitorPass</title>
<link href="assets/main.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/w3.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<script>
function ColGenerator()
{
$("#autoCOL").show();
var i;
var rNo = parseInt($("#NoOfAdmin").val());
for (i = 0; i < rNo; i++) {
$('#autoCOL')
.append('<tr><td><input id="adminno' + i + '" type="text" class="input" /></td>' +
'</tr>');
}
$("#NoOfAdminTable").hide();
//when add admins button is clicked this logic sends data and recieves result from adminexecutor
$("#ADD").click(function(){
var values="";
i=0;
while (i!=rNo) {
if(i==rNo-1)
values += "('" + $('#adminno' + i).val() + "','rcf@123');"
else
values += "('" + $('#adminno' + i).val() + "','rcf@123'),"
i++;
}
var query = "INSERT INTO admin(admin_no,password) values " +values;
var tb_tag = "addadmin";
var dataValues = 'tag='+ tb_tag + '&Query='+ query;
$.ajax({
type: "POST",
url: "adminexecutor.php",
data: dataValues,
success: function(result){
$("#NoOfAdminTable").show();
alertMsg=result;
$("#alertBoxMain").show();
document.getElementById("alertBox").innerHTML=alertMsg;
window.setTimeout(function(){location.reload();},1500);
}
});
});
}
</script>
<div class="w3-red">
<div class="w3-container">
<h1> <img height = 80px width = 65px src="assets/rcf.png" > Visitor Management System</h1>
</div>
</div>
<div class="w3-sidebar w3-bar-block w3-collapse w3-card-2 w3-animate-left" style="width:200px;" id="mySidebar">
<button class="w3-bar-item w3-button w3-large w3-hide-large" onclick="w3_close()">Close ×</button>
<a class="w3-bar-item w3-button" href="admin.php">HOME</a>
<a class="w3-bar-item w3-button" href="addemp.php">Add New Employee</a>
<a class="w3-bar-item w3-button" href="removeemp.php">Remove Employee</a>
<a class="w3-bar-item w3-button" href="addcisf.php">Add CISF</a>
<a class="w3-bar-item w3-button" href="removecisf.php">Remove CISF</a>
<a class="w3-bar-item w3-button w3-green" href="addadmin.php">Add new Admin</a>
<a class="w3-bar-item w3-button" href="removeadmin.php">Remove Admin</a>
<a class="w3-bar-item w3-button" href="reports.php"> Appointment Reports</a>
</div>
<div class="w3-main" style="margin-left:200px">
<button class="w3-button w3-sand w3-xlarge w3-hide-large" onclick="w3_open()">☰</button>
<div class="w3-container w3-margin-top">
<nav class="w3-topnav" >
<span style="float:right;">
<a>Welcome,<span style="font-size:18px;"><i> <?php echo $_SESSION['adminusername']; ?></i></span></a>
<a align="right" href="logout.php"><button class="w3-btn w3-light-blue w3-round-xlarge" type="submit">Log Out</button></a>
</span>
</nav>
</div>
<div class="w3-container">
<!-- Alert Box Section by default its hidden start-->
<div id="alertBoxMain" class="w3-panel w3-green" style="display:none">
<p id="alertBox"></p>
</div>
<!-- Alert Box Section by default its hidden end -->
<p style="font-size: 9pt;">Note: Default password of newly added admin(s) is 'rcf@123' (without quotes)</p>
<table id="NoOfAdminTable">
<tr>
<td><label class="w3-label w3-text-blue">Number of Admins to add<span class="w3-text-red">*</span>: </label></td>
<td><input id="NoOfAdmin" class="w3-input w3-border" type="text" style="width:90%"></td>
<td><button class="w3-btn w3-blue w3-round-large"onclick="ColGenerator();">Add</button></td>
</tr>
</table>
<p>
<table id="autoCOL" class="w3-table-all w3-small" style="display:none">
<thead>
<tr class="w3-light-grey">
<th>Admin No.</th>
</tr>
</thead>
</table>
</p>
<p class="w3-right"><button id="ADD" class="w3-btn w3-red w3-round-xlarge">Add Admin(s)</button></p>
</div>
</div>
</body>
<script>
function w3_open() {
document.getElementById("mySidebar").style.display = "block";
}
function w3_close() {
document.getElementById("mySidebar").style.display = "none";
}
</script>
</html>