-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathappointment.php
174 lines (163 loc) · 6.06 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
<?php include 'server/server.php' ?>
<?php
$query = "SELECT * FROM tbl_appointment ORDER BY id DESC";
$result = $conn->query($query);
$appointment = array();
while($row = $result->fetch_assoc()){
$appointment[] = $row;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'templates/header.php' ?>
<title>Appointment - Masili Health Service System</title>
</head>
<body>
<div class="wrapper">
<?php include 'templates/main-header.php' ?>
<?php include 'templates/sidebar.php' ?>
<div class="main-panel">
<div class="content">
<div class="page-inner">
<div class="row">
<div class="col-md-12">
<!-- action alert -->
<?php if(isset($_SESSION['message'])): ?>
<div class="alert alert-<?= $_SESSION['success']; ?> <?= $_SESSION['success']=='danger' ? 'bg-danger text-light' : null ?>" role="alert">
<?php echo $_SESSION['message']; ?>
</div>
<?php unset($_SESSION['message']); ?>
<?php endif ?>
<!-- end of action alert -->
<?php include 'templates/loading_screen.php' ?>
<div class="card">
<div class="card-header">
<div class="card-head-row">
<div class="card-title text-primary">
<h1>APPOINTMENT RECORD</h1>
</div>
<div class="card-tools">
<a href="appointment_add_form.php" class="btn btn-primary mr-1">
<i class="fa fa-plus mr-2"></i>
Appointment
</a>
<?php if(isset($_SESSION['username']) && $_SESSION['role']!='resident'): ?>
<button onclick="Export()" class="btn btn-default btn-default">
<i class="fa fa-download mr-2"></i>
Export to CSV
</button>
<?php endif?>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="appointment" class="display table">
<thead>
<tr class="text-primary">
<th scope="col">Resident Name</th>
<th scope="col">Age</th>
<th scope="col">Staff In Charge</th>
<th scope="col">Request Date</th>
<th scope="col">Appointment type</th>
<th scope="col">Appointment Date</th>
<th scope="col">Status</th>
<?php if(isset($_SESSION['username']) && $_SESSION['role'] !='resident'): ?>
<th scope="col">Action</th>
<?php endif ?>
</tr>
</thead>
<tbody>
<?php if(!empty($appointment)): ?>
<?php foreach($appointment as $row): ?>
<tr>
<td><?= ucwords($row['resident_name']) ?></td>
<td><?= ucwords($row['age']) ?></td>
<td>
<?php if($row['staff_in_charge']=='unassigned'): ?>
<span class="badge text-primary" style="width:90px;">Unassigned</span>
<?php else:?>
<?= ucwords($row['staff_in_charge']) ?>
<?php endif ?>
</td>
<td><?= ucwords($row['request_date']) ?></td>
<td><?= ucwords($row['appointment_type']) ?></td>
<td>
<?php if(!$row['appointment_date']): ?>
<span class="badge text-primary">No appointment yet</span>
<?php else:?>
<?= ucwords($row['appointment_date']) ?>
<?php endif ?>
<td class="text-center">
<?php if($row['status']=='scheduled'): ?>
<span class="badge badge-warning" style="width:90px;">Scheduled</span>
<?php elseif($row['status']=='active'): ?>
<span class="badge badge-primary" style="width:90px;">Active</span>
<?php else: ?>
<span class="badge badge-success" style="width:90px;">Completed</span>
<?php endif ?>
</td>
<?php if(isset($_SESSION['username']) && $_SESSION['role'] !='resident'): ?>
<td>
<?php if($row['status'] !='completed'): ?>
<a href="appointment_update_form.php?id=<?= $row['id'] ?>&tbl=tbl_appointment&page=appointment" class="btn btn-link">
<i class="fa fa-edit mr-2"></i>Update
</a>
<?php else: ?>
<a href="appointment_detail.php?id=<?= $row['id'] ?>&tbl=tbl_appointment&page=appointment" class="btn btn-link">
<i class="fa fa-file-medical-alt mr-2"></i>Details
</a>
<?php endif ?>
</td>
<?php endif ?>
</tr>
<?php endforeach ?>
<?php endif ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Main Footer -->
<?php include 'templates/main-footer.php' ?>
<!-- End Main Footer -->
</div>
</div>
<?php include 'templates/footer.php' ?>
<script src="assets/js/plugin/datatables/datatables.min.js"></script>
<script>
$(document).ready(function() {
var oTable = $('#appointment').DataTable({
"order": [[ 4, "desc" ]]
});
});
function Export(){
// should have policy like 2 weeks retention of records and scope for export to csv
var conf = confirm("Export appointment to CSV?");
var stmt = "SELECT * FROM tbl_appointment";
var tblHeader = 'No,Resident Name,Age,Staff In Charge,Request Date,Concern,Appointment Type,Status,Appointment Date,Remarks';
var fileName = "appointment";
if(conf){
window.open(`export.php?query=${stmt}&tblHeader=${tblHeader}&fileName=${fileName}`, '_blank');
}
}
</script>
<style>
.text-primary, .text-primary a{
color: #1c9790 !important;
}
.btn-primary, .btn-primary:hover, .btn-primary:focus, .btn-primary:disabled{
background: #1c9790 !important;
border-color: #1c9790 !important;
}
.text-primary:hover, .text-primary a:hover{
color: #1c9790 !important;
}
</style>
</body>
</html>