-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpending-application.php
More file actions
257 lines (224 loc) · 8.96 KB
/
pending-application.php
File metadata and controls
257 lines (224 loc) · 8.96 KB
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
<?php
session_start();
require_once 'inc/dbh.inc.php';
if (!isset($_SESSION["HospitalID"]) && !isset($_SESSION["RGD_Admin"])) {
header("Location: login.php");
exit();
}
if (isset($_GET['logout'])) {
session_unset();
session_destroy();
header("Location: index.php");
exit();
}
// ============================================================================
// PAGINATION AND SEARCH FOR APPROVED APPLICATIONS (RGD VIEW)
// ============================================================================
$limit = 10;
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int)$_GET['page'] : 1;
$offset = ($page - 1) * $limit;
$search = isset($_GET['search']) ? trim($_GET['search']) : '';
// Build WHERE clause for search
// Note: Can only search by FormID since other data is encrypted
$where = "WHERE status = 'approved'";
$params = [];
$types = '';
if ($search !== '') {
// Search by FormID only (encrypted data cannot be searched)
$where = "WHERE FormID LIKE ? AND status = 'approved'";
$like = "%{$search}%";
$params[] = &$like;
$types = 's';
}
// Count total records
$countSql = "SELECT COUNT(*) AS total FROM form_data_secure $where";
$countStmt = $conn->prepare($countSql);
if (!$countStmt) {
die('Count prepare failed: ' . $conn->error);
}
if ($search !== '') {
$countStmt->bind_param($types, $like);
}
$countStmt->execute();
$countResult = $countStmt->get_result();
$total_records = $countResult->fetch_assoc()['total'];
$total_pages = ceil($total_records / $limit);
$countStmt->close();
// Fetch page of results
$dataSql = "SELECT FormID, submitted_date, status, hospital_id
FROM form_data_secure
$where
ORDER BY submitted_date DESC
LIMIT ? OFFSET ?";
$dataStmt = $conn->prepare($dataSql);
if (!$dataStmt) {
die('Data prepare failed: ' . $conn->error);
}
// Bind parameters
if ($search !== '') {
$types2 = $types . 'ii';
$limitParam = $limit;
$offsetParam = $offset;
$dataStmt->bind_param($types2, $like, $limitParam, $offsetParam);
} else {
$dataStmt->bind_param('ii', $limit, $offset);
}
$dataStmt->execute();
$result = $dataStmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./src/css/pending-application.css" />
<link rel="stylesheet" href="./src/css/dashboard-rgd.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<title>Pending Birth Applications</title>
<style>
.search-info {
font-size: 12px;
color: #666;
margin-top: 5px;
}
.badge {
padding: 5px 12px;
border-radius: 12px;
font-size: 12px;
font-weight: 600;
display: inline-block;
background: #d4edda;
color: #155724;
}
</style>
</head>
<body>
<header class="dashboard-header">
<div class="logo-title">
<img src="./src/img/rgd-logo.png" alt="RGD Logo" style="max-height: 40px; padding-right:10px;">
<h2>BIS - Registrar General's Department</h2>
</div>
<a href="?logout=true" class="logout"><i class="fas fa-sign-out-alt"></i> Logout</a>
</header>
<nav class="breadcrumb">
<a href='rgd-dashboard.php'><b> Dashboard </b> </a> / Pending Birth Registration Application
</nav>
<main>
<div class="container">
<h3>Pending Birth Applications (Approved by Hospitals)</h3>
<form method="get" style="margin-bottom:1.5rem; display:flex; gap:0.5rem; flex-direction:column;">
<div style="display:flex; gap:0.5rem;">
<input type="text"
name="search"
placeholder="Search by Form ID (e.g., BT-20251013-0000001)"
value="<?= htmlspecialchars($search) ?>"
style="flex: 1;" />
<button type="submit" class="view-btn">
<i class="fas fa-search"></i> Search
</button>
<?php if ($search !== ''): ?>
<a href="pending-application.php" class="view-btn" style="background: #6c757d;">
<i class="fas fa-times"></i> Clear
</a>
<?php endif; ?>
</div>
</form>
<?php if ($total_records > 0): ?>
<div style="margin-bottom: 10px; font-size: 14px; color: #666;">
<i class="fas fa-clipboard-check"></i>
Showing <?= min($offset + 1, $total_records) ?>-<?= min($offset + $limit, $total_records) ?>
of <?= $total_records ?> approved application(s) awaiting RGD processing
</div>
<table>
<thead>
<tr>
<th>Form ID</th>
<th>Submitted Date</th>
<th>Hospital ID</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><strong><?= htmlspecialchars($row['FormID']) ?></strong></td>
<td><?= htmlspecialchars($row['submitted_date']) ?></td>
<td><?= htmlspecialchars($row['hospital_id'] ?? 'N/A') ?></td>
<td>
<span class="badge">
<i class="fas fa-check"></i> Approved
</span>
</td>
<td class="actions">
<a href="application-view.php?FormID=<?= urlencode($row['FormID']) ?>" class="view-btn">
<i class="fas fa-eye"></i> View & Process
</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php if ($total_pages > 1): ?>
<div class="pagination">
<?php if ($page > 1): ?>
<a href="?search=<?= urlencode($search) ?>&page=<?= $page - 1 ?>">
<i class="fas fa-chevron-left"></i> Prev
</a>
<?php endif; ?>
<?php
// Smart pagination
$start_page = max(1, $page - 2);
$end_page = min($total_pages, $page + 2);
if ($start_page > 1): ?>
<a href="?search=<?= urlencode($search) ?>&page=1">1</a>
<?php if ($start_page > 2): ?>
<span>...</span>
<?php endif; ?>
<?php endif; ?>
<?php for ($i = $start_page; $i <= $end_page; $i++): ?>
<a href="?search=<?= urlencode($search) ?>&page=<?= $i ?>"
<?php if ($i == $page) echo ' class="active"'; ?>>
<?= $i ?>
</a>
<?php endfor; ?>
<?php if ($end_page < $total_pages): ?>
<?php if ($end_page < $total_pages - 1): ?>
<span>...</span>
<?php endif; ?>
<a href="?search=<?= urlencode($search) ?>&page=<?= $total_pages ?>">
<?= $total_pages ?>
</a>
<?php endif; ?>
<?php if ($page < $total_pages): ?>
<a href="?search=<?= urlencode($search) ?>&page=<?= $page + 1 ?>">
Next <i class="fas fa-chevron-right"></i>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
<?php else: ?>
<div style="text-align: center; padding: 40px 20px; color: #999;">
<i class="fas fa-clipboard-check" style="font-size: 48px; margin-bottom: 15px; display: block; color: #28a745;"></i>
<h3 style="margin: 0 0 10px 0; color: #666;">No Pending Applications</h3>
<p style="margin: 0;">
<?php if ($search !== ''): ?>
No approved applications found matching "<?= htmlspecialchars($search) ?>".
<a href="pending-application.php" style="color: #007bff;">Clear search</a>
<?php else: ?>
There are no approved birth applications awaiting RGD processing at the moment.
<?php endif; ?>
</p>
</div>
<?php endif; ?>
</div>
</main>
<footer>
Register General's Department - Sri Lanka
</footer>
</body>
</html>
<?php
$dataStmt->close();
$conn->close();
?>