-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappointment.php
186 lines (145 loc) · 5.18 KB
/
appointment.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
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
<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['username'])) {
header("Location: login.html");
exit();
}
include_once('db_connection_short.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blood Donation Appointment</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
color: #333;
}
form {
max-width: 600px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 8px;
color: #333;
}
input,
select,
button {
width: 100%;
padding: 10px;
margin-bottom: 15px;
box-sizing: border-box;
}
button {
background-color: #4caf50;
color: #fff;
padding: 12px;
cursor: pointer;
border: none;
border-radius: 4px;
font-size: 16px;
}
button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
#weightError {
font-size: 14px;
}
input[type='text']{
cursor: not-allowed;
}
/* Add more styles as needed */
</style>
</head>
<body>
<h1>Blood Donation Appointment</h1>
<form id="appointmentForm" action="appointmentInsertion.php" method="post">
<label for="fullName">Full Name:</label>
<input type="text" id="fullName" name="fullName" value="<?php echo $_SESSION['name'];?>" readonly>
<label for="dob">Date of Birth:</label>
<input type="text" id="dob" name="dob" value="<?php echo $_SESSION['dob'];?>" readonly>
<label for="gender">Gender:</label>
<input type="text" id="gender" name="gender" value="<?php echo $_SESSION['gender'];?>" readonly>
<label for="bloodType">Blood Type:</label>
<input type="text" id="bloodType" name="bloodType" value="<?php echo $_SESSION['blood_group'];?>" readonly>
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" name="weight" required>
<span id="weightError" style="color: red;"></span>
<label for="preferredDate">Preferred Date:</label>
<input type="date" id="preferredDate" name="preferredDate" min="<?php echo date('Y-m-d'); ?>" required>
<label for="preferredTime">Preferred Time:</label>
<input type="time" id="preferredTime" name="preferredTime" required>
<label for="location">Preferred Location:</label>
<select id="location" name="location" required>
<option value="" disabled selected>---Select---</option>
<?php
$sql = "SELECT admin_id,name, city FROM admin_users";
$result = $conn->query($sql);
// Loop through all rows in the result set
while ($row = $result->fetch_assoc()) {
echo '<option value="' . $row['admin_id'] . '">' . $row['name'] . ', '. $row['city'] . '</option>';
}
?>
</select>
<button type="button" onclick="checkEligibility()">Check Eligibility</button>
<button type="submit" id="submitBtn" disabled>Submit</button>
</form>
<script>
function checkEligibility() {
var weight = document.getElementById('weight').value;
if (weight < 45) {
document.getElementById('weightError').innerText = 'Not eligible (Weight must be 45 kg or more)';
document.getElementById('submitBtn').disabled = true;
} else {
document.getElementById('weightError').innerText = '';
document.getElementById('submitBtn').disabled = false;
}
}
document.getElementById('preferredTime').addEventListener('input', function () {
var selectedTime = this.value;
// Set the time boundaries
var startTime = '09:00';
var endTime = '17:00';
if (selectedTime < startTime || selectedTime > endTime) {
alert('Please select a time between 09:00 and 17:00.');
this.value = ''; // Clear the input value
} else {
// Check if the selected time is in the past
validateTime();
}
});
document.getElementById('preferredDate').addEventListener('input', validateTime);
function validateTime() {
var selectedDate = new Date(document.getElementById('preferredDate').value);
var selectedTime = document.getElementById('preferredTime').value;
var selectedDateTime = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate(), selectedTime.split(':')[0], selectedTime.split(':')[1]);
// Get the current date and time
var currentTime = new Date();
// If the selected date is today and the selected time is in the past, show an alert
if (selectedDate.getDate() === currentTime.getDate() &&
selectedDate.getMonth() === currentTime.getMonth() &&
selectedDate.getFullYear() === currentTime.getFullYear() &&
selectedDateTime <= currentTime) {
alert('Please select a future time.');
document.getElementById('preferredTime').value = ''; // Clear the input value
}
}
</script>
</body>
</html>