-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
159 lines (142 loc) · 5.66 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Hospital Portal</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<h1>Hospital Portal</h1>
<?php
session_start();
if (!isset($_SESSION['username'])) {
// User is not logged in
header('location: login.php');
exit();
}
echo "Welcome, " . $_SESSION['username'] . "!";
$isAdmin = ($_SESSION['usertype'] === 'doctor') ? true : false;
// Fetch announcements from the database
$announcements = [
["id" => 1, "title" => "Announcement 1", "content" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit."],
["id" => 2, "title" => "Announcement 2", "content" => "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."],
// ...
];
// Fetch prescribed medicines from the database
$prescribedMedicines = [
["id" => 1, "patient" => "John Doe", "medicine" => "Medicine 1", "dosage" => "2 pills daily"],
["id" => 2, "patient" => "Jane Smith", "medicine" => "Medicine 2", "dosage" => "1 pill every 12 hours"],
// ...
];
// Fetch messages from the database
$messages = [
["id" => 1, "sender" => "Admin", "receiver" => "John Doe", "content" => "Message 1: Lorem ipsum dolor sit amet, consectetur adipiscing elit."],
["id" => 2, "sender" => "John Doe", "receiver" => "Admin", "content" => "Message 2: Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."],
// ...
]
?>
<div class="tab-links">
<a href="#" class="tab-link active" onclick="openTab('announcement-tab')">Announcement</a>
<a href="#" class="tab-link" onclick="openTab('medicine-tab')">Medicine</a>
<a href="#" class="tab-link" onclick="openTab('message-tab')">Messages</a>
</div>
<div id="announcement-tab" class="tab active">
<h2>Announcement</h2>
<?php if ($isAdmin): ?>
<!-- Only show form if user is a doctor -->
<!-- Your form here -->
<form action="post_announcement.php" method="POST">
<label for="announcement">Announcement:</label>
<textarea id="announcement" name="announcement" rows="4" required></textarea><br>
<input type="submit" value="Post Announcement">
</form>
<?php endif; ?>
<div class="message-container">
<?php foreach ($announcements as $announcement): ?>
<h3><?php echo $announcement['title']; ?></h3>
<p><?php echo $announcement['content']; ?></p>
<?php endforeach; ?>
</div>
</div>
<div id="medicine-tab" class="tab">
<h2>Medicine</h2>
<?php if ($isAdmin): ?>
<!-- Only show form if user is a doctor -->
<form action="prescribe_medicine.php" method="POST">
<label for="patient">Patient:</label>
<select id="patient" name="patient" required>
<!-- Populate options dynamically -->
<?php
// Fetch patient list from the database and populate the select options accordingly
$patients = [
["id" => 1, "name" => "John Doe"],
["id" => 2, "name" => "Jane Smith"],
// ...
];
foreach ($patients as $patient) {
echo '<option value="' . $patient["id"] . '">' . $patient["name"] . '</option>';
}
?>
</select><br>
<label for="medicine">Medicine:</label>
<input type="text" id="medicine" name="medicine" required><br>
<label for="dosage">Dosage:</label>
<input type="text" id="dosage" name="dosage" required><br>
<input type="submit" value="Prescribe Medicine">
</form>
<?php endif; ?>
<div class="message-container">
<h2>Prescribed Medicines</h2>
<?php foreach ($prescribedMedicines as $medicine): ?>
<h3><?php echo $medicine['patient']; ?></h3>
<p>Medicine: <?php echo $medicine['medicine']; ?></p>
<p>Dosage: <?php echo $medicine['dosage']; ?></p>
<?php endforeach; ?>
</div>
</div>
<div id="message-tab" class="tab">
<h2>Messages</h2>
<?php if ($isAdmin): ?>
<!-- Only show form if user is a doctor -->
<form action="send_message.php" method="POST">
<label for="receiver">Receiver:</label>
<select id="receiver" name="receiver" required>
<!-- Populate options dynamically -->
<?php
// Fetch user list from the database and populate the select options accordingly
$users = [
["id" => 1, "username" => "John Doe"],
["id" => 2, "username" => "Jane Smith"],
// ...
];
foreach ($users as $user) {
echo '<option value="' . $user["username"] . '">' . $user["username"] . '</option>';
}
?>
</select><br>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" required></textarea><br>
<input type="submit" value="Send Message">
</form>
<?php else: ?>
<!-- Show user-specific messages here -->
<?php foreach ($messages as $message): ?>
<?php if ($_SESSION['username'] === $message['sender'] || $_SESSION['username'] === $message['receiver']): ?>
<h3>From: <?php echo $message['sender']; ?></h3>
<p>To: <?php echo $message['receiver']; ?></p>
<p><?php echo $message['content']; ?></p>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<div class="message-container">
<h2>Inbox</h2>
<?php foreach ($messages as $message): ?>
<?php if ($_SESSION['username'] === $message['receiver']): ?>
<h3>From: <?php echo $message['sender']; ?></h3>
<p><?php echo $message['content']; ?></p>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<script src="main.js"></script>
</body>
</html>