-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.html
182 lines (149 loc) · 6.27 KB
/
check.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap" rel="stylesheet">
<style>
nav {
padding: 20px;
display: flex;
justify-content: space-between;
box-shadow: 3px 10px 17px -15px rgba(0, 0, 0, 0.48);
}
a,
a:hover {
color: black;
text-decoration: none;
}
.search {
margin: 50px 0px;
display: flex;
justify-content: center;
}
.search select {
margin: 0px 15px;
}
.table {
text-align: center;
}
</style>
</head>
<body>
<nav>
<a href="Home"><span style="font-size: 2em;line-height: 3;font-weight: bold;">Dashboard</span></a>
<img src="static/AASTL.png" style="width: 100px; height: 100px;">
<a href="#"><img src="static/setting2.png" style="width: 80px;height: 80px;"></a>
</nav>
<div class="search">
<form class="form-inline">
<input class="form-control mr-sm-2" type="ID" placeholder="ID" id="inputID">
<button class="btn btn-primary my-2 my-sm-0" type="button" onclick="checkID()">Check</button>
</form>
</div>
<div class="table-responsive">
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Membership Type</th>
<th scope="col">Gender</th>
<th scope="col">Period</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
<div style="display: flex; justify-content: center;">
<button class="btn btn-success btn-lg" type="button" onclick="enterMember()">Enter member</button>
</div>
<p style="text-align: center;color:darkgreen;display: none;font-size: 2em; margin-top: 50px;" id="Member_Accepted">
Member entered in the period</p>
<p style="text-align: center;color:darkred;display: none;font-size: 2em; margin-top: 50px;" id="Member_Rejected">
Member can't be entered because memebership ended</p>
<script type="text/javascript">
var mem = {};
var ID;
function checkID() {
ID = document.getElementById('inputID').value;
fetch("/members/" + ID)
.then(function (response) {
return response.json();
})
.then(function (data) {
var last = Date.parse(data.enddate);
var today = Date.now();
var st = "Not Active";
if (last > today)
st = "Active";
mem = {
ID: data.id,
Name: data.name,
Membership_type: data.membershiptype,
Gender: data.gender,
Period: data.period,
Status: st
}
})
.catch(function (err) {
console.log(err);
});
var b = document.getElementById('Member_Rejected');
b.style.display = 'none';
var b = document.getElementById('Member_Accepted');
b.style.display = 'none';
if (Object.keys(mem).length > 0) {
var table = document.getElementById('tbody');
var record = mem;
if (table.childNodes.length != 0)
table.removeChild(table.childNodes[0]);
if (record["ID"] == ID) {
tr = document.createElement('tr');
var Status_color;
if (record["Status"] == "Not Active")
Status_color = "rgb(180,0,0);";
else
Status_color = "rgb(0,100,0);"
tr.innerHTML =
"<th scope='row'>" + record['ID'] +
"</th><td>" + record['Name'] +
"</td><td>" + record['Membership_type'] +
"</td><td>" + record['Gender'] +
"</td><td>" + record['Period'] +
"</td><td> <p style='color:" + Status_color + " font-weight: bold;'>" + record['Status'] + "</p> </td>"
table.appendChild(tr);
}
}
}
function enterMember() {
ID = document.getElementById('inputID').value;
var record = mem;
if (Object.keys(mem).length > 0) {
if (record["Status"] == "Active") {
var b = document.getElementById('Member_Rejected');
b.style.display = 'none';
b = document.getElementById('Member_Accepted');
b.style.display = 'block';
}
else if (record["Status"] == "Not Active") {
var b = document.getElementById('Member_Accepted');
b.style.display = 'none';
b = document.getElementById('Member_Rejected');
b.style.display = 'block';
}
}
}
</script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
crossorigin="anonymous"></script>
</body>