-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
189 lines (178 loc) · 6.36 KB
/
Copy pathmain.php
File metadata and controls
189 lines (178 loc) · 6.36 KB
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
<!--<?php
$con = mysqli_connect("localhost","root","root","erp");
$result=mysqli_query($con,"select * from employee order by empfname;");
?>-->
<script type="text/javascript">
function show(val){
if(val==1){
document.getElementById('div1').style.display="inline";
document.getElementById('div2').style.display="none";
document.getElementById('div3').style.display="none";
}
else if(val==2){
document.getElementById('div1').style.display="none";
document.getElementById('div2').style.display="inline";
document.getElementById('div3').style.display="none";
}
else{
document.getElementById('div1').style.display="none";
document.getElementById('div2').style.display="none";
document.getElementById('div3').style.display="inline";
}
}
</script>
<script>
function change_myselect1() {
var obj, dbParam, xmlhttp, myObj, x, txt = "";
obj = {"id":document.getElementById('search2').value};
dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText)
myObj = JSON.parse(this.responseText);
txt+="<table border=2><tr><th>ID</th><th>First Name</th><th>Last Name </th><th>Absent/Present</th><th>Date</th></tr>";
for (x in myObj) {
txt += "<tr><td>" + myObj[x].id + "</td>";
txt+= "<td>"+myObj[x].empfname + "</td>";
txt+= "<td>"+myObj[x].emplname + "</td>";
txt+= "<td>"+myObj[x].present + "</td>";
txt+= "<td>"+myObj[x].attenddate + "</td></tr>";
}
txt+="</table>";
document.getElementById("saldiv").innerHTML = txt;
}
};
xmlhttp.open("POST", "Second.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("x=" + dbParam);
}
</script>
<!--mark the attendence -->
<script>
function mark_attendence(){
var obj, dbParam, xmlhttp;
var isattend=document.getElementsByName('attendR');
var value;
if(isattend[0].checked){
value=1.
}
else{
value=0
}
obj = {"id":document.getElementById('search').value,"present":value};
dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert("attend marked");
change_myselect();
}
};
xmlhttp.open("POST", "fouth.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("x=" + dbParam);
}
</script>
<script>
//script for poplating the select list
function populateString() {
var obj, dbParam, xmlhttp, myObj, x, txt = "";
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myObj = JSON.parse(this.responseText);
for (x in myObj) {
var option= document.createElement("option");
option.text=myObj[x].empfname;
option.value=myObj[x].id;
document.getElementById("search2").appendChild(option);
document.getElementById("search").appendChild(option.cloneNode(true));
change_myselect();
}
//document.getElementById("sellist").innerHTML = txt;
}
};
xmlhttp.open("POST", "third.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send();
}
</script>
<script>
function change_myselect() {
var obj, dbParam, xmlhttp, myObj, x, txt = "";
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText)
myObj = JSON.parse(this.responseText);
txt+="<table border=2><tr><th>ID</th><th>First Name</th><th>Last Name </th><th>Absent/Present</th></th></tr>";
for (x in myObj) {
txt += "<tr><td>" + myObj[x].id + "</td>";
txt+= "<td>"+myObj[x].empfname + "</td>";
txt+= "<td>"+myObj[x].emplname + "</td>";
txt+= "<td>"+myObj[x].present + "</td></tr>";
}
txt+="</table>";
document.getElementById("div1").innerHTML = txt;
}
};
xmlhttp.open("POST", "First.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send();
}
</script>
<body onload="populateString()">
<div style="float: left;width:20%">
<form method="post" action="">
<input type="button" name="ta" value="Take Attendence" onclick="show(1)"><br><br>
<input type="button" name="aemp" value="Add Employe" onclick="show(2)"><br><br>
<input type="button" name="salary" value="Calculate Salary" onclick="show(3)">
</form>
</div>
<div id="div1" style="display: block;width: 50%; float: left;">
This is a text written
<button onclick="change_myselect()">click me</button>
</table>
</div>
<div id="div2" style="display: none; width: 50%; float: left;" >
<form method="post">
Id:- <input type="text" name="id">
First name:- <input type=text name=empfname><br>
Last name:- <input type=text name=emplname><br>
Age:- <input type=number name=empage><br>
Salary:- <input type=number name=empsalary><br>
Work:- <select name="empwork">
<option value="pro">Enter the work</option>
</select><br>
Mobile no.:-<input type=number name=mobilenum><br><br>
<input type="submit" value="Add Employe" name="addEmployee">
<br>
<input type="reset" value="reset">
</form>
</div>
<div id="div3" style="display: none;width: 50%; float: left;">
<form method="post" action="">
<div id="sellist">
<select id="search2" value="null" onchange="change_myselect1()">
<option value="null">Enter your name</option>
</select>
</div>
<!--to be done -->
<input type="button" name="showsal" value="show sal">
<input type="button" name="paysal" value="pay sal">
</form>
<br><br><br>
<div id="saldiv" style="float: left;">
</div>
</div>
<div style="float:left">
Enter employe name:-
<div id="sellist2">
<select id='search'><option value='null'> Enter the name </option></select>
</div>
<br>
Present <input type=radio name="attendR" value=1> Absent<input type=radio name="attendR" value=0><br>
<button id="markAttendence" type="button" name="attendButton" onclick="mark_attendence()">Mark Attendence</button>
</div>
</body>