-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhealth_record_dashboard.php
500 lines (434 loc) · 19.5 KB
/
health_record_dashboard.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
<?php
session_start();
include 'db_connection.php';
include 'header.php';
$message = '';
$message_type = '';
// إذا كانت الرسالة موجودة في الجلسة، قم بتعيينها للمتغيرات
if (isset($_SESSION['message'])) {
$message = $_SESSION['message'];
$message_type = $_SESSION['message_type'] ?? 'success'; // افتراضي على أنه نجاح
unset($_SESSION['message']);
unset($_SESSION['message_type']);
}
?>
<?php //TEMPLATES
include 'templates_html/header.html';
if (isset($_SESSION['user_role'])) {
switch ($_SESSION['user_role']) {
case 'admin':
include 'templates_html/main-grid-content-2columns.html';
include 'templates_html/admin-side-bar.html';
default:
include 'templates_html/alert-dashboard.php';
include 'templates_html/employee.php';
include 'templates_html/main-grid-content-1column.html';
}
} else {
include 'templates_html/main-grid-content-1column.html';
}
include 'templates_html/main-content.html';
?>
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>جدول السجلات الصحية</title>
<link rel="stylesheet" href="style.css">
<style>
.success-message {
color: green;
font-weight: bold;
text-align: center;
margin: 20px 0;
padding: 10px;
border: 1px solid green;
border-radius: 5px;
background-color: #e8f9e9;
}
.error-message {
color: red;
font-weight: bold;
text-align: center;
margin: 20px 0;
padding: 10px;
border: 1px solid red;
border-radius: 5px;
background-color: #f8d7da;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
table, th, td {
border: 1px solid #ccc;
text-align: center;
padding: 10px;
}
th {
background-color: #f4f4f4;
}
button {
padding: 5px 10px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
}
button.delete-btn { background-color: #dc3545; }
button.edit-btn { background-color: #007bff; }
button:hover { opacity: 0.9; }
/* نمط الموديل */
.modal {
display: none; /* يتم إخفاؤه بشكل افتراضي */
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%; /* عرض كامل */
height: 100%; /* ارتفاع كامل */
overflow: auto; /* السماح بالتمرير إذا لزم الأمر */
background-color: rgba(0,0,0,0.4); /* شفافية الخلفية */
}
/* تعديل نمط الموديل */
.modal-content {
background-color: #fefefe;
margin: 10% auto; /* يظل من أعلى 10% وauto من الجانبين */
padding: 20px;
border: 1px solid #888;
width: 400px; /* عرض 400px للنموذج */
border-radius: 8px; /* زوايا دائرية */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* ظل خفيف للنموذج */
}
/* تحسين تنسيق الزر داخل النموذج */
#healthRecordForm button {
background-color: #28a745; /* لون زر إضافة السجل الصحي */
border: none;
color: white;
padding: 10px 15px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s; /* تأثير تدرج للون عند التحويم */
}
#healthRecordForm button:hover {
background-color: #218838; /* لون الزر عند التحويم */
}
/* نمط الحقول داخل النموذج */
#healthRecordForm select,
#healthRecordForm input[type="date"],
#healthRecordForm textarea {
width: 100%; /* جعل العرض 100% */
padding: 8px; /* إضافة حشوة */
margin: 10px 0; /* إضافة هوامش */
border: 1px solid #ccc; /* إضافة حدود */
border-radius: 4px; /* زوايا دائرية */
}
/* تحسين الحواف والتباعد */
h2 {
text-align: center; /* توسيط العنوان */
}
p{
text-align: center; /* توسيط العنوان */
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover, .close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
/* أنماط البحث */
.search-container {
margin-bottom: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.search-container input {
padding: 8px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 4px;
width: 200px;
}
.search-container button {
padding: 8px 12px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.search-container button:hover {
background-color: #0056b3;
}
/* جدول */
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
table, th, td {
border: 1px solid #ccc;
text-align: center;
padding: 10px;
}
th {
background-color: #f4f4f4;
}
</style>
</head>
<body>
<h1>Elder Health Records </h1>
<hr>
<?php if (!empty($message)): ?>
<div class="<?= $message_type == 'error' ? 'error-message' : 'success-message' ?>">
<?= htmlspecialchars($message) ?>
</div>
<?php endif; ?>
<button id="openModalBtn">Add_New_Record</button><br><br>
<!-- حاوية البحث -->
<div class="search-container">
<label for="alert_date">RecordID :</label>
<input type="text" id="searchRecordId" placeholder="SearchRecordID" oninput="filterRecords()">
<label for="alert_date">SearchName :</label>
<input type="text" id="searchName" placeholder=" ElderName" oninput="filterRecords()">
<label for="alert_date">SearchDOB :</label>
<input type="date" id="searchDateOfBirth" placeholder=" DOB" oninput="filterRecords()">
<label for="alert_date">RecordDate :</label>
<input type="date" id="searchRecordDate" placeholder="RecordDate" oninput="filterRecords()">
<label for="alert_date">HealthCondition :</label>
<input type="text" id="searchHealthCondition" placeholder="HealthCondition" oninput="filterRecords()">
<button onclick="location.reload();">Update</button>
</div>
<table id="healthRecordsTable">
<thead>
<tr>
<th>RecordNO</th>
<th> ElderName</th>
<th>Date_Of_Birth</th>
<th>RecordDate</th>
<th>Vital_signs</th>
<th>Health_status</th>
<th>Doctor_Prescriptions</th>
<th>Notes</th>
<th>Procedures</th>
</tr>
</thead>
<tbody>
<?php
// استعلام لجلب البيانات من health_records واسم كبير السن وتاريخ الميلاد من elderly_profiles
$sql = "SELECT hr.id, ep.name AS elderly_name, ep.age AS date_of_birth, hr.date, hr.vital_signs, hr.notes, hr.updated_by, hr.health_condition, hr.prescriptions
FROM health_records hr
JOIN elderly_profiles ep ON hr.elderly_id = ep.id";
$result = $conn->query($sql);
// عرض السجلات في الجدول
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['elderly_name'] . "</td>";
echo "<td>" . $row['date_of_birth'] . "</td>"; // عرض تاريخ الميلاد
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['vital_signs'] . "</td>";
echo "<td>" . $row['health_condition'] . "</td>";
echo "<td>" . $row['prescriptions'] . "</td>";
echo "<td>" . $row['notes'] . "</td>";
echo "<td>";
echo "<button class='edit-btn' onclick='openEditRecordModal(" . json_encode($row) . ")'>Edit</button>"; // استدعاء جافا سكريبت مع بيانات السجل
echo "<button class='delete-btn' onclick='openConfirmModal(" . $row['id'] . ")'>Delet</button>";
echo "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='9'>There Is NO Records </td></tr>";
}
?>
</tbody>
</table>
<!--موديل تعديل السجل -->
<!-- Modal تعديل السجل -->
<div id="editRecordModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeEditRecordModal()">×</span>
<h2>Edit_RecordModa </h2>
<form id="editRecordForm" method="POST" action="update_health_record.php">
<input type="hidden" id="editRecordId" name="id">
<label for="editElderlyName"> ElderName:</label>
<input type="text" id="editElderlyName" name="elderly_name" readonly><br><br>
<label for="editDateOfBirth">Date_Of_Birth:</label>
<input type="date" id="editDateOfBirth" name="date_of_birth" readonly><br><br>
<label for="editDate">Edit_Date:</label>
<input type="date" id="editDate" name="date" required><br><br>
<label for="editVitalSigns">Vital_signs:</label>
<input type="text" id="editVitalSigns" name="vital_signs" required><br><br>
<label for="editHealthCondition">Health_status:</label>
<input type="text" id="editHealthCondition" name="health_condition" required><br><br>
<label for="editPrescriptions">Doctor_Prescriptions:</label>
<input type="text" id="editPrescriptions" name="prescriptions"><br><br>
<label for="editNotes">Notes:</label>
<textarea id="editNotes" name="notes"></textarea><br><br>
<div style="text-align: center;">
<button type="submit">Edit</button>
<button type="button" onclick="closeEditRecordModal()">Cancel</button>
</div>
</form>
</div>
</div>
<script>
// فتح المودال مع تعبئة البيانات
function openEditRecordModal(record) {
document.getElementById('editRecordModal').style.display = 'block';
// تعبئة البيانات في النموذج
document.getElementById('editRecordId').value = record.id;
document.getElementById('editElderlyName').value = record.elderly_name;
document.getElementById('editDateOfBirth').value = record.date_of_birth;
document.getElementById('editDate').value = record.date;
document.getElementById('editVitalSigns').value = record.vital_signs;
document.getElementById('editHealthCondition').value = record.health_condition;
document.getElementById('editPrescriptions').value = record.prescriptions;
document.getElementById('editNotes').value = record.notes;
}
// إغلاق المودال
function closeEditRecordModal() {
document.getElementById('editRecordModal').style.display = 'none';
}
// إغلاق الموديل عند الضغط على أي مكان خارج الموديل
window.onclick = function(event) {
if (event.target == document.getElementById('editRecordModal')) {
closeModal();
}
}
</script>
<!-- الموديل لتأكيد الحذف -->
<div id="confirmDeleteModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeConfirmModal()">×</span>
<h2>Confirm deletion!!</h2>
<p>Are you sure you want to delete this record?</p>
<div style="text-align: center;">
<button id="confirmDeleteBtn" class="delete-btn">Yes</button>
<button class="edit-btn" onclick="closeConfirmModal()">Cancel</button>
</div>
</div>
</div>
<script>
let recordIdToDelete;
function openConfirmModal(recordId) {
recordIdToDelete = recordId; // حفظ الـ ID للسجل الذي سيتم حذفه
document.getElementById('confirmDeleteModal').style.display = 'block';
}
function closeConfirmModal() {
document.getElementById('confirmDeleteModal').style.display = 'none';
}
// تنفيذ عملية الحذف عند تأكيد الحذف
document.getElementById('confirmDeleteBtn').onclick = function() {
window.location.href = 'delete_record.php?id=' + recordIdToDelete; // إعادة توجيه إلى صفحة الحذف
}
</script>
<script>
function filterRecords() {
const recordId = document.getElementById("searchRecordId").value.toLowerCase();
const name = document.getElementById("searchName").value.toLowerCase();
const dateOfBirth = document.getElementById("searchDateOfBirth").value.toLowerCase();
const recordDate = document.getElementById("searchRecordDate").value.toLowerCase();
const healthCondition = document.getElementById("searchHealthCondition").value.toLowerCase();
const table = document.getElementById("healthRecordsTable");
const rows = table.getElementsByTagName("tr");
for (let i = 1; i < rows.length; i++) {
let showRow = true;
const cells = rows[i].getElementsByTagName("td");
if (recordId && cells[0].innerText.toLowerCase() !== recordId) {
showRow = false;
}
if (name && !cells[1].innerText.toLowerCase().includes(name)) {
showRow = false;
}
if (dateOfBirth && cells[2].innerText.toLowerCase() !== dateOfBirth) {
showRow = false;
}
if (recordDate && cells[3].innerText.toLowerCase() !== recordDate) {
showRow = false;
}
if (healthCondition && !cells[5].innerText.toLowerCase().includes(healthCondition)) {
showRow = false;
}
rows[i].style.display = showRow ? "" : "none"; // إظهار أو إخفاء الصف
}
}
</script>
<div id="healthRecordModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeModal()">×</span>
<h2>Add_Health_Record</h2>
<form id="healthRecordForm" action="add_health_record.php" method="POST">
<label for="elderly_id">Select_Elder_name:</label>
<select name="elderly_id" required>
<option value="">-----</option>
<?php
// جلب أسماء كبار السن من قاعدة البيانات
$sql = "SELECT id, name FROM elderly_profiles";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<option value='" . $row['id'] . "'>" . $row['name'] . " (ID: " . $row['id'] . ")</option>";
}
} else {
echo "<option value=''>There is No Elder ..... </option>";
}
?>
</select>
<label for="alert_date">DOB :</label>
<input type="date" name="date" required>
<label for="alert_date">Vital_signs :</label>
<textarea name="vital_signs" placeholder=" vital_signs" required></textarea>
<label for="alert_date">Health status :</label>
<textarea name="health_condition" placeholder=" Health status" required></textarea>
<label for="alert_date">Doctor prescription :</label>
<textarea name="prescriptions" placeholder=" prescriptions" ></textarea>
<label for="alert_date">Notes :</label>
<textarea name="notes" placeholder="notes"></textarea>
<div style="text-align: center;">
<button type="submit" style="padding: 10px 15px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">ِAdd</button>
<button type="button" onclick="closeModal()" style="padding: 10px 15px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">Cancel</button>
</div>
</form>
</div>
</div>
<script>
// إخفاء الرسالة بعد 4 ثواني (4000 مللي ثانية)
setTimeout(function() {
var message = document.querySelector('.success-message, .error-message');
if (message) {
message.style.display = 'none';
}
}, 4000);
// فتح الموديل
document.getElementById('openModalBtn').onclick = function() {
document.getElementById('healthRecordModal').style.display = 'block';
}
// إغلاق الموديل
function closeModal() {
document.getElementById('healthRecordModal').style.display = 'none';
}
// إغلاق الموديل عند الضغط على أي مكان خارج الموديل
window.onclick = function(event) {
if (event.target == document.getElementById('healthRecordModal')) {
closeModal();
}
}
</script>
<script>
</script>
</body>
</html>
<?php // TEMPLATES
include 'templates_html/end-main-content.html';
include 'templates_html/footer.html';
?>