-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhearings.html
More file actions
343 lines (298 loc) · 11.6 KB
/
hearings.html
File metadata and controls
343 lines (298 loc) · 11.6 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hearings - Court Management System</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- FullCalendar CSS -->
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.css" rel="stylesheet">
<!-- FontAwesome Icons -->
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<style>
/* Full Page Black Background */
body {
background-color: black;
color: white;
}
/* Sidebar Styling */
#sidebar {
width: 250px;
min-height: 100vh;
transition: all 0.3s ease;
background: #222;
padding: 10px;
}
#sidebar.collapsed {
width: 70px;
overflow: hidden;
}
#sidebar .nav-item a {
display: flex;
align-items: center;
padding: 12px;
color: white;
text-decoration: none;
}
/* Content Styling */
.content {
flex: 1;
padding: 20px;
background-color: black; /* Ensuring full black background */
}
/* Table Styling */
.table {
background-color: #333;
color: white;
}
.table thead {
background-color: #444;
}
/* Form Modal Background */
.modal-content {
background-color: #222;
color: white;
}
/* Button Colors */
.btn-primary {
background-color: yellow;
border-color: yellow;
color: black;
}
.btn-primary:hover {
background-color: gold;
}
/* Sidebar */
#sidebar {
width: 250px;
min-height: 100vh;
transition: all 0.3s ease;
background: #111;
padding: 10px;
}
#sidebar.collapsed {
width: 80px;
overflow: hidden;
}
#sidebar h4 {
text-align: center;
padding: 15px;
}
#sidebar .nav-item {
margin-bottom: 10px;
}
#sidebar .nav-item a {
display: flex;
align-items: center;
gap: 10px;
padding: 12px;
color: white;
text-decoration: none;
border-radius: 5px;
transition: background 0.3s;
}
#sidebar .nav-item a:hover {
background: #222;
}
#sidebar .nav-item i {
font-size: 18px;
}
/* Collapsed Sidebar - Show Icons Only */
#sidebar.collapsed a span {
display: none;
}
#sidebar.collapsed a {
justify-content: center;
}
</style>
</head>
<body>
<div class="d-flex">
<!-- Sidebar -->
<nav id="sidebar">
<h4 class="text-white text-center py-3">Court Management</h4>
<ul class="nav flex-column">
<li class="nav-item">
<a href="Index.html" class="nav-link"><i class="fas fa-home"></i> <span class="sidebar-text">Dashboard</span></a>
</li>
<li class="nav-item">
<a href="cases.html" class="nav-link"><i class="fas fa-balance-scale"></i> <span class="sidebar-text">Cases</span></a>
</li>
<li class="nav-item">
<a href="hearings.html" class="nav-link active"><i class="fas fa-gavel"></i> <span class="sidebar-text">Hearings</span></a>
</li>
<li class="nav-item">
<a href="documents.html" class="nav-link"><i class="fas fa-file-alt"></i> <span class="sidebar-text">Documents</span></a>
</li>
<li class="nav-item">
<a href="payments.html" class="nav-link"><i class="fas fa-cog"></i> <span class="sidebar-text">Payments</span></a>
</li>
<li class="nav-item">
<a href="Login.html" class="nav-link"><i class="fas fa-sign-out-alt"></i> <span class="sidebar-text">Logout</span></a>
</li>
</ul>
</nav>
<!-- Main Content -->
<div class="content">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container-fluid">
<button class="btn btn-dark" id="sidebarToggle"><i class="fas fa-bars"></i></button>
<h4 class="ms-3">Hearings Management</h4>
<button class="btn btn-primary ms-auto" data-bs-toggle="modal" data-bs-target="#addHearingModal">
<i class="fas fa-plus"></i> Add Hearing
</button>
</div>
</nav>
<!-- Calendar View -->
<div class="container mt-4">
<h5>Upcoming Hearings</h5>
<div id="calendar"></div>
</div>
<!-- Hearings Table -->
<div class="container mt-4">
<h5>All Hearings</h5>
<table class="table table-dark table-striped" id="hearingsTable">
<thead>
<tr>
<th>#</th>
<th>Case ID</th>
<th>Hearing Date</th>
<th>Judge</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!-- Dynamic Data -->
</tbody>
</table>
</div>
</div>
</div>
<!-- Add Hearing Modal -->
<div class="modal fade" id="addHearingModal" tabindex="-1" aria-labelledby="addHearingModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addHearingModalLabel">Schedule New Hearing</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="addHearingForm">
<div class="mb-3">
<label for="caseID" class="form-label">Case ID</label>
<input type="text" class="form-control" id="caseID" placeholder="Enter Case ID">
</div>
<div class="mb-3">
<label for="hearingDate" class="form-label">Hearing Date</label>
<input type="date" class="form-control" id="hearingDate">
</div>
<div class="mb-3">
<label for="judgeName" class="form-label">Judge Name</label>
<input type="text" class="form-control" id="judgeName" placeholder="Enter Judge's Name">
</div>
<button type="submit" class="btn btn-primary w-100">Schedule Hearing</button>
</form>
</div>
</div>
</div>
</div>
<!-- Bootstrap & FullCalendar JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.js"></script>
<!-- [unchanged HEAD section: skipped here for brevity, but it's fine] -->
<script>
let calendar; // Keep reference outside
// Sidebar Toggle
document.getElementById("sidebarToggle").addEventListener("click", function () {
let sidebar = document.getElementById("sidebar");
sidebar.classList.toggle("collapsed");
});
// Fetch and display hearings from backend
function fetchHearings() {
fetch("http://localhost:3000/hearings")
.then(response => response.json())
.then(data => {
const tableBody = document.querySelector("#hearingsTable tbody");
tableBody.innerHTML = ""; // Clear old data
const calendarEvents = [];
data.forEach((hearing, index) => {
const row = document.createElement("tr");
row.innerHTML = `
<td>${index + 1}</td>
<td>${hearing.case_id}</td>
<td>${hearing.hearing_date}</td>
<td>${hearing.judge}</td>
<td><span class="badge bg-warning">${hearing.status}</span></td>
<td>
<button class="btn btn-sm btn-warning"><i class="fas fa-edit"></i></button>
<button class="btn btn-sm btn-danger"><i class="fas fa-trash"></i></button>
</td>
`;
tableBody.appendChild(row);
calendarEvents.push({
title: `Hearing - ${hearing.case_id}`,
start: hearing.hearing_date
});
});
// Render Calendar (only once)
renderCalendar(calendarEvents);
})
.catch(error => console.error("Error fetching hearings:", error));
}
// Render Calendar
function renderCalendar(events) {
if (calendar) calendar.destroy(); // Destroy existing one if present
const calendarEl = document.getElementById("calendar");
calendar = new FullCalendar.Calendar(calendarEl, {
initialView: "dayGridMonth",
events: events
});
calendar.render();
}
// Submit new hearing
document.getElementById("addHearingForm").addEventListener("submit", function (event) {
event.preventDefault();
const case_id = document.getElementById("caseID").value.trim();
const hearing_date = document.getElementById("hearingDate").value;
const judge = document.getElementById("judgeName").value.trim();
if (!case_id || !hearing_date || !judge) {
alert("All fields are required.");
return;
}
const newHearing = {
case_id,
hearing_date,
judge,
status: "Scheduled"
};
fetch("http://localhost:3000/hearings", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(newHearing)
})
.then(response => {
if (!response.ok) throw new Error("Failed to schedule hearing");
return response.json();
})
.then(() => {
document.getElementById("addHearingForm").reset();
const modal = bootstrap.Modal.getInstance(document.getElementById("addHearingModal"));
modal.hide();
fetchHearings();
alert("Hearing scheduled successfully!");
})
.catch(error => {
console.error("Error posting hearing:", error);
alert("Error scheduling hearing.");
});
});
// Initial fetch
document.addEventListener("DOMContentLoaded", fetchHearings);
</script>
</body>
</html>