rangivinod commited on
Commit
086c7f7
·
verified ·
1 Parent(s): 17e9868

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +1779 -19
index.html CHANGED
@@ -1,19 +1,1779 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>DHT Unit Job Tracking</title>
7
+ <!-- Google Fonts (Inter) -->
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet">
9
+ <!-- Tailwind CSS CDN -->
10
+ <script src="https://cdn.tailwindcss.com"></script>
11
+
12
+ <style>
13
+
14
+ body {
15
+ font-family: 'Inter', sans-serif;
16
+ background: linear-gradient(to bottom, #E5E7EB, #F3F4F6);
17
+ margin: 0;
18
+ }
19
+ nav {
20
+ background-color: #F3F4F6;
21
+ padding: 0.5rem 1rem;
22
+ margin: 0; /* Remove all margins */
23
+ }
24
+ .container {
25
+ max-width: 1200px;
26
+ margin-left: auto;
27
+ margin-right: auto;
28
+ }
29
+ nav .container {
30
+ display: flex;
31
+ justify-content: space-between;
32
+ align-items: center;
33
+ }
34
+ .form-container {
35
+ background-color: #F9FAFB;
36
+ border: none;
37
+ box-shadow: 0 10px 20px rgba(0,0,0,0.1), 0 6px 6px rgba(0,0,0,0.1);
38
+ border-radius: 12px;
39
+ padding: 1rem;
40
+ transition: transform 0.2s ease;
41
+ }
42
+ .form-container:hover {
43
+ transform: scale(1.01);
44
+ }
45
+ .form-row {
46
+ display: grid;
47
+ grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 2fr;
48
+ gap: 1rem;
49
+ }
50
+ .date-input {
51
+ max-width: 160px;
52
+ }
53
+ .job-textarea, .remark-textarea {
54
+ height: 100px;
55
+ }
56
+ .narrow-field {
57
+ max-width: 400px;
58
+ }
59
+ .department-field {
60
+ max-width: 400px;
61
+ }
62
+ .input-field {
63
+ transition: all 0.2s ease;
64
+ }
65
+ .input-field:hover {
66
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
67
+ }
68
+ .select-placeholder {
69
+ color: #9CA3AF;
70
+ }
71
+ .completed-row {
72
+ background-color: #DCFCE7 !important;
73
+ }
74
+ .nav-ribbon {
75
+ background-color: #F3F4F6;
76
+ padding: 0.5rem 1rem; /* Match nav padding */
77
+ margin: 0; /* Remove all margins */
78
+ display: flex;
79
+ justify-content: flex-end;
80
+ align-items: center;
81
+ }
82
+ .nav-ribbon a {
83
+ padding: 0.5rem 1rem; /* Match nav link padding */
84
+ font-size: 1rem; /* Match nav link font size */
85
+ color: #374151;
86
+ text-decoration: none;
87
+ cursor: pointer;
88
+ }
89
+ .nav-ribbon a:hover {
90
+ color: #059669;
91
+ text-decoration: underline;
92
+ }
93
+ .nav-ribbon a.active {
94
+ color: #2DD4BF;
95
+ font-weight: 600;
96
+ text-decoration: underline;
97
+ background-color: #FFFFFF;
98
+ border-bottom: 2px solid #2DD4BF;
99
+ }
100
+ #reportsContent {
101
+ margin: 0; /* Remove margins */
102
+ padding-top: 0; /* Remove top padding */
103
+ }
104
+ #reportsContent header {
105
+ display: none; /* Hide Reports header to eliminate gap */
106
+ }
107
+
108
+ /* Table Styling for Both Homepage and Reports */
109
+ #jobTable, #reportTable {
110
+ table-layout: fixed;
111
+ width: 100%;
112
+ }
113
+ #jobTable tr, #reportTable tr {
114
+ height: 3rem;
115
+ max-height: 3rem;
116
+ overflow: hidden;
117
+ }
118
+ #jobTable th, #jobTable td, #reportTable th, #reportTable td {
119
+ padding: 0.75rem 0.5rem;
120
+ vertical-align: middle;
121
+ box-sizing: border-box;
122
+ }
123
+ #jobTable th, #reportTable th {
124
+ white-space: normal;
125
+ line-height: 1.5;
126
+ overflow: hidden;
127
+ text-overflow: ellipsis;
128
+ }
129
+
130
+ /* Column Widths for Homepage Table (8 columns) */
131
+ #jobTable th:nth-child(1), #jobTable td:nth-child(1) { width: 8%; }
132
+ #jobTable th:nth-child(2), #jobTable td:nth-child(2) { width: 21%; }
133
+ #jobTable th:nth-child(3), #jobTable td:nth-child(3) { width: 10%; }
134
+ #jobTable th:nth-child(4), #jobTable td:nth-child(4) { width: 8%; }
135
+ #jobTable th:nth-child(5), #jobTable td:nth-child(5) { width: 10%; }
136
+ #jobTable th:nth-child(6), #jobTable td:nth-child(6) { width: 10%; }
137
+ #jobTable th:nth-child(7), #jobTable td:nth-child(7) { width: 10%; }
138
+ #jobTable th:nth-child(8), #jobTable td:nth-child(8) { width: 11%; }
139
+
140
+ /* Column Widths for Reports Table (9 columns) */
141
+ #reportTable th:nth-child(1), #reportTable td:nth-child(1) { width: 10%; }
142
+ #reportTable th:nth-child(2), #reportTable td:nth-child(2) { width: 25%; }
143
+ #reportTable th:nth-child(3), #reportTable td:nth-child(3) { width: 8%; }
144
+ #reportTable th:nth-child(4), #reportTable td:nth-child(4) { width: 8%; }
145
+ #reportTable th:nth-child(5), #reportTable td:nth-child(5) { width: 10%; }
146
+ #reportTable th:nth-child(6), #reportTable td:nth-child(6) { width: 15%; }
147
+ #reportTable th:nth-child(7), #reportTable td:nth-child(7) { width: 8%; }
148
+ #reportTable th:nth-child(8), #reportTable td:nth-child(8) { width: 11%; }
149
+ #reportTable th:nth-child(9), #reportTable td:nth-child(9) { width: 5%; }
150
+
151
+ /* Text Wrapping for Long Content */
152
+ #jobTable td:nth-child(2), #jobTable td:nth-child(7),
153
+ #reportTable td:nth-child(2), #reportTable td:nth-child(6) {
154
+ overflow: hidden;
155
+ text-overflow: ellipsis;
156
+ white-space: nowrap;
157
+ max-height: 2.25rem;
158
+ line-height: 1.125rem;
159
+ cursor: pointer;
160
+ }
161
+
162
+ /* Adjust Status Dropdown and Save Button */
163
+ #reportTable select {
164
+ padding: 0.25rem 0.5rem;
165
+ font-size: 0.875rem;
166
+ width: 100%;
167
+ }
168
+ .save-btn {
169
+ padding: 0.25rem 0.5rem;
170
+ font-size: 0.75rem;
171
+ width: 100%;
172
+ }
173
+
174
+ .sortable {
175
+ cursor: pointer;
176
+ position: relative;
177
+ }
178
+ .sortable:hover {
179
+ background-color: #E5E7EB;
180
+ }
181
+ .sort-arrow {
182
+ display: inline-block;
183
+ margin-left: 0.25rem;
184
+ font-size: 0.75rem;
185
+ }
186
+ .filter-row {
187
+ display: flex;
188
+ gap: 0.75rem;
189
+ margin-bottom: 1rem;
190
+ flex-wrap: wrap;
191
+ align-items: flex-end;
192
+ max-width: 100%; /* Ensure it doesn't exceed container */
193
+ }
194
+ .filter-item {
195
+ flex: 0 0 auto;
196
+ min-width: 0; /* Allow shrinking */
197
+ }
198
+ .filter-search {
199
+ width: 100px;
200
+ }
201
+ .filter-narrow {
202
+ width: 90px;
203
+ }
204
+ #filterDepartment, #filterPriority, #filterJobType, #reportPriority, #reportJobType, #reportDepartment {
205
+ width: 100px;
206
+ }
207
+ @media (max-width: 640px) {
208
+ #filterDepartment, #filterPriority, #filterJobType, #reportPriority, #reportJobType, #reportDepartment {
209
+ width: 100% !important;
210
+ }
211
+ }
212
+
213
+ .filter-button {
214
+ width: 60px;
215
+ padding: 0.75rem 0.75rem;
216
+ line-height: 1rem;
217
+ font-size: 0.875rem;
218
+ border-radius: 9999px;
219
+ transition: all 0.2s ease;
220
+ }
221
+ .filter-button:hover {
222
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
223
+ }
224
+ .filter-item:last-child {
225
+ margin-right: 0;
226
+ }
227
+ .pagination {
228
+ display: flex;
229
+ justify-content: space-between;
230
+ align-items: center;
231
+ margin-top: 1rem;
232
+ flex-wrap: wrap;
233
+ gap: 0.5rem;
234
+ }
235
+ #toast.show {
236
+ opacity: 1;
237
+ display: block;
238
+ }
239
+ #toast {
240
+ opacity: 0;
241
+ display: none;
242
+ }
243
+ @media (max-width: 640px) {
244
+ #toast {
245
+ top: 2rem;
246
+ right: 1rem;
247
+ left: 1rem;
248
+ margin: 0 auto;
249
+ max-width: 90%;
250
+ }
251
+ }
252
+ .pagination button {
253
+ padding: 0.5rem 1rem;
254
+ border-radius: 4px;
255
+ font-size: 0.875rem;
256
+ }
257
+ .pagination button:disabled {
258
+ background-color: #D1D5DB;
259
+ cursor: not-allowed;
260
+ }
261
+ .pagination .page-number {
262
+ padding: 0.5rem 0.75rem;
263
+ border-radius: 4px;
264
+ cursor: pointer;
265
+ }
266
+ .pagination .page-number.active {
267
+ background-color: #2DD4BF;
268
+ color: white;
269
+ }
270
+ .pagination .page-number:hover:not(.active) {
271
+ background-color: #E5E7EB;
272
+ }
273
+ #homeContent, #reportsContent {
274
+ transition: opacity 0.3s ease;
275
+ }
276
+ #homeContent.hidden, #reportsContent.hidden {
277
+ display: none;
278
+ opacity: 0;
279
+ }
280
+ .jobs-per-page {
281
+ max-width: 120px;
282
+ font-size: 0.875rem;
283
+ }
284
+ @media (min-width: 1024px) {
285
+ .filter-row {
286
+ flex-wrap: nowrap;
287
+ }
288
+ }
289
+ @media (max-width: 640px) {
290
+ .form-row {
291
+ grid-template-columns: 1fr;
292
+ }
293
+ .date-input, .narrow-field, .department-field {
294
+ max-width: 100%;
295
+ }
296
+ .filter-row {
297
+ flex-wrap: wrap;
298
+ align-items: stretch;
299
+ }
300
+ .filter-item {
301
+ width: 100%;
302
+ }
303
+ .filter-search, .filter-narrow, .filter-button {
304
+ width: 100%;
305
+ }
306
+ .filter-item:last-child {
307
+ margin-right: 0;
308
+ }
309
+ .header {
310
+ padding: 0.5rem 0.75rem;
311
+ }
312
+ .header h1 {
313
+ font-size: 1.5rem;
314
+ }
315
+ #jobTable th, #jobTable td, #reportTable th, #reportTable td {
316
+ padding: 0.5rem 0.25rem;
317
+ font-size: 0.875rem;
318
+ }
319
+ #jobTable tr, #reportTable tr {
320
+ height: 4rem;
321
+ max-height: 4rem;
322
+ }
323
+ #jobTable td:nth-child(2), #jobTable td:nth-child(7),
324
+ #reportTable td:nth-child(2), #reportTable td:nth-child(6) {
325
+ max-height: 3rem;
326
+ line-height: 1.5rem;
327
+ }
328
+ .action-buttons {
329
+ flex-direction: column;
330
+ gap: 0.25rem;
331
+ }
332
+ .edit-btn, .delete-btn, .save-btn {
333
+ width: 100%;
334
+ }
335
+ .form-buttons {
336
+ flex-direction: column;
337
+ gap: 0.5rem;
338
+ }
339
+ .pagination {
340
+ flex-direction: column;
341
+ align-items: flex-start;
342
+ }
343
+ .pagination button, .pagination .page-number {
344
+ padding: 0.5rem;
345
+ font-size: 0.75rem;
346
+ }
347
+ .nav-ribbon {
348
+ justify-content: center; /* Center tabs on mobile */
349
+ padding: 0.25rem 0.5rem; /* Reduced padding for mobile */
350
+ }
351
+ .nav-ribbon a {
352
+ padding: 0.25rem 0.5rem; /* Reduced padding for mobile */
353
+ font-size: 0.875rem; /* Smaller font for mobile */
354
+ }
355
+ .jobs-per-page {
356
+ max-width: 100%;
357
+ }
358
+ .filter-item {
359
+ width: 100%;
360
+ max-width: 100%;
361
+ }
362
+ .filter-narrow {
363
+ width: 100% !important; /* Override inline max-width on mobile */
364
+ }
365
+ #filterNotificationNo {
366
+ max-width: 100% !important; /* Allow full width on mobile */
367
+ }
368
+ #reportPagination, #historyPagination {
369
+ display: flex;
370
+ justify-content: space-between;
371
+ align-items: center;
372
+ margin-top: 1rem;
373
+ flex-wrap: wrap;
374
+ gap: 0.5rem;
375
+ }
376
+ }
377
+ </style>
378
+
379
+ </head>
380
+ <body class="flex flex-col items-center min-h-screen">
381
+ <header class="w-full bg-blue-600 py-4 text-white text-center shadow-md">
382
+ <h1 class="text-2xl font-bold">DHT Unit Job Tracking</h1>
383
+ </header>
384
+ <nav class="container mx-auto px-4 nav-ribbon">
385
+ <a id="homeLink" class="active" href="#">Home</a>
386
+ <a id="reportsLink" href="#">Reports</a>
387
+ </nav>
388
+ <main class="container mx-auto mt-2 p-4">
389
+ <!-- Home Page Content -->
390
+ <div id="homeContent">
391
+ <!-- Form in 3D Box -->
392
+ <div class="form-container mb-10">
393
+ <form id="jobForm">
394
+ <div class="mb-2">
395
+ <label for="jobDate" class="block text-base font-medium text-gray-800 mb-2">Date</label>
396
+ <input type="date" id="jobDate" name="jobDate" class="input-field mt-1 block date-input rounded bg-white py-2 px-3 text-base placeholder-gray-400 focus:ring-2 focus:ring-teal-400 hover:shadow-sm" readonly required>
397
+ </div>
398
+ <div class="form-row">
399
+ <div>
400
+ <label for="job" class="block text-base font-semibold text-gray-800 mb-2">Job description</label>
401
+ <textarea id="job" name="job" class="input-field mt-1 block w-full job-textarea rounded bg-white py-2 px-3 text-base placeholder-gray-400 focus:ring-2 focus:ring-teal-400 hover:shadow-sm" placeholder="Enter job description" required></textarea>
402
+ </div>
403
+ <div class="department-field">
404
+ <label for="department" class="block text-base font-semibold text-gray-800 mb-2">Concern Department</label>
405
+ <select id="department" name="department" class="input-field mt-1 block w-full rounded bg-white py-2 px-3 text-base focus:ring-2 focus:ring-teal-400 hover:shadow-sm" required>
406
+ <option value="" class="select-placeholder">Select department</option>
407
+ <option value="Static">Static</option>
408
+ <option value="Electrical">Electrical</option>
409
+ <option value="Rotary">Rotary</option>
410
+ <option value="Instruments">Instruments</option>
411
+ <option value="Analyzers">Analyzers</option>
412
+ <option value="EED">EED</option>
413
+ <option value="Civil">Civil</option>
414
+ <option value="Other">Other</option>
415
+ </select>
416
+ </div>
417
+ <div class="narrow-field">
418
+ <label for="priority" class="block text-base font-semibold text-gray-800 mb-2">Priority</label>
419
+ <select id="priority" name="priority" class="input-field mt-1 block w-full rounded bg-white py-2 px-3 text-base focus:ring-2 focus:ring-teal-400 hover:shadow-sm" required>
420
+ <option value="" class="select-placeholder">Select priority</option>
421
+ <option value="High">High</option>
422
+ <option value="Medium">Medium</option>
423
+ <option value="Low">Low</option>
424
+ </select>
425
+ </div>
426
+ <div class="narrow-field">
427
+ <label for="jobType" class="block text-base font-semibold text-gray-800 mb-2">Job Type</label>
428
+ <select id="jobType" name="jobType" class="input-field mt-1 block w-full rounded bg-white py-2 px-3 text-base focus:ring-2 focus:ring-teal-400 hover:shadow-sm" required>
429
+ <option value="" class="select-placeholder">Select type</option>
430
+ <option value="Regular Job">Regular Job</option>
431
+ <option value="Shutdown Job">Shutdown Job</option>
432
+ </select>
433
+ </div>
434
+ <div class="narrow-field">
435
+ <label for="notificationNo" class="block text-base font-semibold text-gray-800 mb-1">Notification No</label>
436
+ <input type="text" id="notificationNo" name="notificationNo" class="input-field mt-0 block w-full rounded bg-white py-2 px-3 text-base placeholder-gray-400 focus:ring-2 focus:ring-teal-400 hover:shadow-sm" placeholder="Enter notification number" required>
437
+ </div>
438
+ <div>
439
+ <label for="remark" class="block text-base font-semibold text-gray-800 mb-1">Remark</label>
440
+ <textarea id="remark" name="remark" class="input-field mt-1 block w-full remark-textarea rounded bg-white py-2 px-3 text-base placeholder-gray-400 focus:ring-2 focus:ring-teal-400 hover:shadow-sm" placeholder="Enter remark"></textarea>
441
+ </div>
442
+ </div>
443
+ <div class="mt-4 flex justify-center form-buttons gap-4">
444
+ <button type="submit" id="submitButton" class="bg-blue-600 text-white py-3 px-6 rounded-lg hover:bg-blue-700 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-teal-400 active:bg-blue-600 transition-all duration-200 hover:scale-105" aria-label="Add or update job">Add Job</button>
445
+ <button type="button" id="cancelButton" class="hidden bg-gray-500 text-white py-3 px-6 rounded hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-teal-400 transition-all duration-200 hover:scale-105" aria-label="Cancel edit">Cancel</button>
446
+ </div>
447
+ </form>
448
+ </div>
449
+ <!-- Filters -->
450
+ <!-- Filters -->
451
+ <!-- Filters -->
452
+ <div class="filter-row">
453
+ <div class="filter-item">
454
+ <label for="filterStartDate" class="block text-sm font-semibold text-gray-800 mb-1">Start Date</label>
455
+ <input type="date" id="filterStartDate" class="input-field mt-1 filter-narrow block w-full px-3 py-2 rounded bg-white py-2 px-3 text-sm focus:ring-2 focus:ring-blue-400 hover:shadow-sm">
456
+ </div>
457
+ <div class="filter-item">
458
+ <label for="filterEndDate" class="block text-sm font-semibold text-gray-800 mb-1">End Date</label>
459
+ <input type="date" id="filterEndDate" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-blue-400 hover:shadow-sm" min="">
460
+ <div id="dateError" class="text-red-600 text-sm mt-1 hidden">End Date must be on or after Start Date.</div>
461
+ </div>
462
+ <div class="filter-item">
463
+ <label for="filterSearch" class="block text-sm font-semibold text-gray-800 mb-1">Search</label>
464
+ <input type="text" id="filterSearch" class="input-field mt-1 filter-search block w-full rounded bg-white py-2 px-3 text-sm placeholder-gray-500 focus:ring-blue-400 hover:shadow-sm" placeholder="Job or Remark">
465
+ </div>
466
+ <div class="filter-item">
467
+ <label for="filterDepartment" class="block text-sm font-semibold text-gray-800 mb-1">Department</label>
468
+ <select id="filterDepartment" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-2 focus:ring-blue-400 hover:shadow-sm">
469
+ <option value="">All</option>
470
+ <option value="Static">Static</option>
471
+ <option value="Electrical">Electrical</option>
472
+ <option value="Rotary">Rotary</option>
473
+ <option value="Instruments">Instruments</option>
474
+ <option value="Analyzers">Analyzers</option>
475
+ <option value="EED">EED</option>
476
+ <option value="Civil">Civil</option>
477
+ <option value="Other">Other</option>
478
+ </select>
479
+ </div>
480
+ <div class="filter-item">
481
+ <label for="filterPriority" class="block text-sm font-semibold text-gray-800 mb-1">Priority</label>
482
+ <select id="filterPriority" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-blue-400 hover:shadow-sm">
483
+ <option value="">All</option>
484
+ <option value="High">High</option>
485
+ <option value="Medium">Medium</option>
486
+ <option value="Low">Low</option>
487
+ </select>
488
+ </div>
489
+ <div class="filter-item">
490
+ <label for="filterJobType" class="block text-sm font-semibold text-gray-800 mb-1">Job Type</label>
491
+ <select id="filterJobType" class="input-field mt-1 filter-narrow w-full rounded bg-white py-2 px-3 text-sm focus:ring-blue-400 hover:shadow-sm">
492
+ <option value="">All</option>
493
+ <option value="Regular Job">Regular</option>
494
+ <option value="Shutdown Job">Shutdown</option>
495
+ </select>
496
+ </div>
497
+ <div class="filter-item">
498
+ <label for="filterNotificationNo" class="block text-sm font-semibold text-gray-800 mb-1">Notification</label>
499
+ <input type="text" id="filterNotificationNo" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm placeholder-gray-400 focus:ring-blue-400 hover:shadow-sm" style="max-width: 80px;" placeholder="No">
500
+ </div>
501
+ <div class="filter-item">
502
+ <button id="exportJobsHome" class="bg-green-500 text-white filter-button hover:bg-green-600" aria-label="Export filtered jobs">Export</button>
503
+ </div>
504
+ <div class="filter-item">
505
+ <button id="clearFilters" class="bg-gray-500 text-white filter-button hover:bg-gray-600">Clear</button>
506
+ </div>
507
+ </div>
508
+
509
+ <!-- Table -->
510
+ <div class="bg-white rounded-lg shadow">
511
+ <table id="jobTable" class="min-w-full divide-y divide-gray-200">
512
+ <thead class="bg-gray-50">
513
+ <tr>
514
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="date">Date <span class="sort-arrow"></span></th>
515
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Job Description</th>
516
+ <th class="sortable px-4 py-3 text-left text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="department">Department <span class="sort-arrow"></span></th>
517
+ <th class="sortable px-4 py-3 text-left text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="priority">Priority <span class="sort-arrow"></span></th>
518
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="jobType">Job Type <span class="sort-arrow"></span></th>
519
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-id="notificationNo">Notification No <span class="sort-arrow"></span></th>
520
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Remark</th>
521
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Actions</th>
522
+ </tr>
523
+ </thead>
524
+ <tbody id="jobTableBody" class="divide-y divide-gray-200">
525
+ <!-- Job entries will be added here -->
526
+ </tbody>
527
+ </table>
528
+ </div>
529
+
530
+ <!-- Pagination -->
531
+ <div id="pagination" class="pagination">
532
+ <div class="flex items-center gap-4 text-sm text-gray-600">
533
+ <div>
534
+ <label for="jobsPerPage" class="mr-2">Jobs per page:</label>
535
+ <select id="jobsPerPage" class="jobs-per-page input-field rounded bg-white py-1 px-2 focus:ring-2 focus:ring-teal-400 hover:shadow-sm">
536
+ <option value="10">10</option>
537
+ <option value="15" selected>15</option>
538
+ <option value="25">25</option>
539
+ </select>
540
+ </div>
541
+ <div id="paginationRange"></div>
542
+ </div>
543
+ </div>
544
+ </div>
545
+
546
+ <!-- Reports Page Content -->
547
+ <div id="reportsContent" class="hidden">
548
+ <div class="container mx-auto p-4">
549
+ <!-- Department Tabs -->
550
+ <nav class="nav-ribbon bg-gray-100 rounded-t-lg border-b border-gray-200 mb-4">
551
+ <a id="tabStatic" class="tab-link" href="#" data-department="Static" aria-label="View Static department jobs">Static</a>
552
+ <a id="tabElectrical" class="tab-link" href="#" data-department="Electrical" aria-label="View Electrical department jobs">Electrical</a>
553
+ <a id="tabRotary" class="tab-link" href="#" data-department="Rotary" aria-label="View Rotary department jobs">Rotary</a>
554
+ <a id="tabInstruments" class="tab-link" href="#" data-department="Instruments" aria-label="View Instruments department jobs">Instruments</a>
555
+ <a id="tabAnalyzers" class="tab-link" href="#" data-department="Analyzers" aria-label="View Analyzers department jobs">Analyzers</a>
556
+ <a id="tabEED" class="tab-link" href="#" data-department="EED" aria-label="View EED department jobs">EED</a>
557
+ <a id="tabCivil" class="tab-link" href="#" data-department="Civil" aria-label="View Civil department jobs">Civil</a>
558
+ <a id="tabOther" class="tab-link" href="#" data-department="Other" aria-label="View Other department jobs">Other</a>
559
+ <a id="tabHistory" class="tab-link" href="#" data-department="History" aria-label="View completed job history">History</a>
560
+ </nav>
561
+
562
+ <!-- Filters -->
563
+ <!-- Filters (Reports Page) -->
564
+ <div class="filter-row mb-6">
565
+ <div class="filter-item">
566
+ <label for="reportStartDate" class="block text-sm font-semibold text-gray-800 mb-1">Start Date</label>
567
+ <input type="date" id="reportStartDate" class="input-field mt-1 filter-narrow block w-full px-3 py-2 rounded bg-white text-sm focus:ring-2 focus:ring-blue-400 hover:shadow-sm">
568
+ </div>
569
+ <div class="filter-item">
570
+ <label for="reportEndDate" class="block text-sm font-semibold text-gray-800 mb-1">End Date</label>
571
+ <input type="date" id="reportEndDate" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-blue-400 hover:shadow-sm" min="">
572
+ <div id="reportDateError" class="text-red-600 text-sm mt-1 hidden">End Date must be on or after Start Date.</div>
573
+ </div>
574
+ <div class="filter-item" id="reportPriorityFilter">
575
+ <label for="reportPriority" class="block text-sm font-semibold text-gray-800 mb-1">Priority</label>
576
+ <select id="reportPriority" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-2 focus:ring-blue-400 hover:shadow-sm">
577
+ <option value="">All Priorities</option>
578
+ <option value="High">High</option>
579
+ <option value="Medium">Medium</option>
580
+ <option value="Low">Low</option>
581
+ </select>
582
+ </div>
583
+ <div class="filter-item">
584
+ <label for="reportJobType" class="block text-sm font-semibold text-gray-800 mb-1">Job Type</label>
585
+ <select id="reportJobType" class="input-field mt-1 filter-narrow w-full rounded bg-white py-2 px-3 text-sm focus:ring-blue-400 hover:shadow-sm">
586
+ <option value="">All Job Types</option>
587
+ <option value="Regular Job">Regular Jobs</option>
588
+ <option value="Shutdown Job">Shutdown Jobs</option>
589
+ </select>
590
+ </div>
591
+ <div class="filter-item">
592
+ <label for="reportSearch" class="block text-sm font-semibold text-gray-800 mb-1">Search</label>
593
+ <input type="text" id="reportSearch" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm placeholder-gray-500 focus:ring-blue-400 hover:shadow-sm" placeholder="Search Job or Remark">
594
+ </div>
595
+ <div class="filter-item" id="reportStatusFilter">
596
+ <label for="reportStatus" class="block text-sm font-semibold text-gray-800 mb-1">Status</label>
597
+ <select id="reportStatus" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-2 focus:ring-blue-400 hover:shadow-sm">
598
+ <option value="">All Statuses</option>
599
+ <option value="Pending">Pending</option>
600
+ <option value="Completed">Completed</option>
601
+ </select>
602
+ </div>
603
+ <div class="filter-item hidden" id="reportDepartmentFilter">
604
+ <label for="reportDepartment" class="block text-sm font-semibold text-gray-800 mb-1">Department</label>
605
+ <select id="reportDepartment" class="input-field mt-1 filter-narrow block w-full rounded bg-white py-2 px-3 text-sm focus:ring-2 focus:ring-blue-400 hover:shadow-sm">
606
+ <option value="">All Departments</option>
607
+ <option value="Static">Static</option>
608
+ <option value="Electrical">Electrical</option>
609
+ <option value="Rotary">Rotary</option>
610
+ <option value="Instruments">Instruments</option>
611
+ <option value="Analyzers">Analyzers</option>
612
+ <option value="EED">EED</option>
613
+ <option value="Civil">Civil</option>
614
+ <option value="Other">Other</option>
615
+ </select>
616
+ </div>
617
+ <div class="filter-item">
618
+ <button id="exportJobs" class="bg-teal-500 text-white filter-button hover:bg-teal-600" aria-label="Export filtered jobs">Export</button>
619
+ </div>
620
+ <div class="filter-item">
621
+ <button id="clearReportFilters" class="bg-gray-500 text-white filter-button hover:bg-gray-600" aria-label="Clear all report filters">Clear</button>
622
+ </div>
623
+ </div>
624
+ <!-- Report Table -->
625
+ <div class="bg-white rounded-lg shadow">
626
+ <table id="reportTable" class="min-w-full divide-y divide-gray-200">
627
+ <thead class="bg-gray-50">
628
+ <tr>
629
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="date">Date <span class="sort-arrow"></span></th>
630
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Job Description</th>
631
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="priority">Priority <span class="sort-arrow"></span></th>
632
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="jobType">Job Type <span class="sort-arrow"></span></th>
633
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="notificationNo">Notification No <span class="sort-arrow"></span></th>
634
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Remark</th>
635
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="completedDate">Completion Date <span class="sort-arrow"></span></th>
636
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="status">Status <span class="sort-arrow"></span></th>
637
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Actions</th>
638
+ </tr>
639
+ </thead>
640
+ <tbody id="reportTableBody" class="divide-y divide-gray-200"></tbody>
641
+ </table>
642
+ </div>
643
+
644
+ <!-- History Table -->
645
+ <div id="historyTableContainer" class="bg-white rounded-lg shadow hidden">
646
+ <table id="historyTable" class="min-w-full divide-y divide-gray-200">
647
+ <thead class="bg-gray-50">
648
+ <tr>
649
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="date">Date <span class="sort-arrow"></span></th>
650
+ <th class="px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider">Job Description</th>
651
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="department">Department <span class="sort-arrow"></span></th>
652
+ <th class="sortable px-4 py-3 text-left text-sm font-semibold text-gray-800 uppercase tracking-wider" data-sort="completedDate">Completed Date <span class="sort-arrow"></span></th>
653
+ </tr>
654
+ </thead>
655
+ <tbody id="historyTableBody"></tbody>
656
+ </table>
657
+ </div>
658
+
659
+ <!-- Pagination -->
660
+ <div id="reportPagination" class="pagination"></div>
661
+ <!-- Add this after the reportPagination div at line 673 -->
662
+ <div id="historyPagination" class="pagination hidden"></div>
663
+ </div>
664
+ </div>
665
+ </main>
666
+ <script>
667
+ // Show toast notification
668
+ function showToast(message, duration = 3000) {
669
+ const toast = document.getElementById('toast');
670
+ const toastMessage = document.getElementById('toastMessage');
671
+ toastMessage.textContent = message;
672
+ toast.classList.remove('hidden');
673
+ toast.classList.add('show');
674
+
675
+ setTimeout(() => {
676
+ toast.classList.remove('show');
677
+ toast.classList.add('hidden');
678
+ }, duration);
679
+ }
680
+
681
+ // Easter egg for header click
682
+ let headerClickCount = 0;
683
+ document.querySelector('header h1').addEventListener('click', () => {
684
+ headerClickCount++;
685
+ if (headerClickCount === 10) {
686
+ showToast('Created by Vinod Rangi, June 2025');
687
+ headerClickCount = 0; // Reset counter
688
+ }
689
+ });
690
+
691
+ // State management
692
+ let jobs = JSON.parse(localStorage.getItem('jobs')) || [];
693
+ // Initialize status for existing jobs
694
+ jobs = jobs.map(job => ({
695
+ ...job,
696
+ status: job.status || 'Pending'
697
+ }));
698
+ localStorage.setItem('jobs', JSON.stringify(jobs));
699
+ localStorage.removeItem('completedJobs'); // Clean up unused storage
700
+ let sortColumn = 'date';
701
+ let sortDirection = 'desc';
702
+ let filters = { startDate: '', endDate: '', department: '', priority: '', jobType: '', notificationNo: '', search: '' };
703
+ let editIndex = null;
704
+ let currentPage = 1;
705
+ let jobsPerPage = 15;
706
+ let currentView = 'home';
707
+ let reportFilters = { startDate: '', endDate: '', priority: '', jobType: '', search: '', status: '', department: '' };
708
+ let reportSortColumn = 'date';
709
+ let reportSortDirection = 'desc';
710
+ let reportJobsPerPage = 15;
711
+ let historyJobsPerPage = 15;
712
+ let reportCurrentPage = 1;
713
+ let historyCurrentPage = 1;
714
+ let historySortColumn = 'completedDate';
715
+ let historySortDirection = 'desc';
716
+ let activeDepartment = 'Static';
717
+
718
+ // DOM elements
719
+ const homeLink = document.getElementById('homeLink');
720
+ const reportsLink = document.getElementById('reportsLink');
721
+ const homeContent = document.getElementById('homeContent');
722
+ const reportsContent = document.getElementById('reportsContent');
723
+ const tableBody = document.getElementById('jobTableBody');
724
+
725
+ // Filter jobs by expiration (remove Completed jobs older than 7 days)
726
+ function filterExpiredJobs() {
727
+ const now = new Date();
728
+ jobs = jobs.filter(job => {
729
+ if (job.status === 'Completed' && job.completedDate) {
730
+ const completedDate = new Date(job.completedDate);
731
+ const daysDiff = (now - completedDate) / (1000 * 60 * 60 * 24);
732
+ return daysDiff <= 7;
733
+ }
734
+ return true;
735
+ });
736
+ localStorage.setItem('jobs', JSON.stringify(jobs));
737
+ }
738
+
739
+ // Navigation handling
740
+ function showHome(e) {
741
+ e.preventDefault();
742
+ currentView = 'home';
743
+ homeContent.classList.remove('hidden');
744
+ reportsContent.classList.add('hidden');
745
+ homeLink.classList.add('active');
746
+ reportsLink.classList.remove('active');
747
+ document.getElementById('jobDate').value = new Date().toISOString().split('T')[0];
748
+ renderJobs();
749
+ }
750
+
751
+ function showReports(e) {
752
+ e.preventDefault();
753
+ currentView = 'reports';
754
+ homeContent.classList.add('hidden');
755
+ reportsContent.classList.remove('hidden');
756
+ homeLink.classList.remove('active');
757
+ reportsLink.classList.add('active');
758
+
759
+ document.querySelectorAll('.tab-link').forEach(t => t.classList.remove('active'));
760
+ document.getElementById('tabStatic').classList.add('active');
761
+ activeDepartment = 'Static';
762
+
763
+ renderReports();
764
+ }
765
+
766
+ homeLink.addEventListener('click', showHome);
767
+ reportsLink.addEventListener('click', showReports);
768
+
769
+ // Reset form
770
+ function resetForm() {
771
+ document.getElementById('jobForm').reset();
772
+ document.getElementById('submitButton').textContent = 'Add Job';
773
+ document.getElementById('cancelButton').classList.add('hidden');
774
+ document.getElementById('jobDate').value = new Date().toISOString().split('T')[0];
775
+ editIndex = null;
776
+ }
777
+
778
+ // Scroll to form
779
+ function scrollToForm() {
780
+ const formContainer = document.querySelector('.form-container');
781
+ formContainer.scrollIntoView({ behavior: 'smooth', block: 'start' });
782
+ }
783
+
784
+ // Show/hide date error
785
+ function showDateError(show) {
786
+ const dateError = document.getElementById('dateError');
787
+ dateError.classList.toggle('hidden', !show);
788
+ }
789
+
790
+ // Render pagination (Homepage)
791
+ function renderPagination(totalJobs) {
792
+ const pagination = document.getElementById('pagination');
793
+ const totalPages = Math.ceil(totalJobs / jobsPerPage);
794
+ currentPage = Math.min(currentPage, totalPages || 1);
795
+ const startJob = (currentPage - 1) * jobsPerPage + 1;
796
+ const endJob = Math.min(currentPage * jobsPerPage, totalJobs);
797
+
798
+ let html = `
799
+ <div class="flex items-center gap-4 text-sm text-gray-600">
800
+ <div>
801
+ <label for="jobsPerPage" class="mr-2">Jobs per page:</label>
802
+ <select id="jobsPerPage" class="jobs-per-page input-field rounded bg-white py-1 px-2 focus:ring-2 focus:ring-teal-400 hover:shadow-sm">
803
+ <option value="10" ${jobsPerPage === 10 ? 'selected' : ''}>10</option>
804
+ <option value="15" ${jobsPerPage === 15 ? 'selected' : ''}>15</option>
805
+ <option value="25" ${jobsPerPage === 25 ? 'selected' : ''}>25</option>
806
+ </select>
807
+ </div>
808
+ <div id="paginationRange">
809
+ Showing ${totalJobs > 0 ? startJob : 0} to ${endJob} of ${totalJobs} jobs
810
+ </div>
811
+ </div>
812
+ <div class="flex gap-2 flex-wrap">
813
+ <button id="prevPage" class="bg-teal-500 text-white hover:bg-teal-600 disabled:bg-gray-300" ${currentPage === 1 ? 'disabled' : ''}>Previous</button>
814
+ <div class="flex gap-1">
815
+ `;
816
+
817
+ const maxPagesToShow = 5;
818
+ let startPage = Math.max(1, currentPage - Math.floor(maxPagesToShow / 2));
819
+ let endPage = Math.min(totalPages, startPage + maxPagesToShow - 1);
820
+ if (endPage - startPage + 1 < maxPagesToShow) {
821
+ startPage = Math.max(1, endPage - maxPagesToShow + 1);
822
+ }
823
+
824
+ if (startPage > 1) {
825
+ html += `<span class="page-number" data-page="1">1</span>`;
826
+ if (startPage > 2) html += `<span class="px-2">...</span>`;
827
+ }
828
+
829
+ for (let i = startPage; i <= endPage; i++) {
830
+ html += `<span class="page-number ${i === currentPage ? 'active' : ''}" data-page="${i}">${i}</span>`;
831
+ }
832
+
833
+ if (endPage < totalPages) {
834
+ if (endPage < totalPages - 1) html += `<span class="px-2">...</span>`;
835
+ html += `<span class="page-number" data-page="${totalPages}">${totalPages}</span>`;
836
+ }
837
+
838
+ html += `
839
+ </div>
840
+ <button id="nextPage" class="bg-teal-500 text-white hover:bg-teal-600 disabled:bg-gray-300" ${currentPage === totalPages ? 'disabled' : ''}>Next</button>
841
+ </div>
842
+ `;
843
+
844
+ pagination.innerHTML = html;
845
+
846
+ document.getElementById('prevPage')?.addEventListener('click', () => {
847
+ if (currentPage > 1) {
848
+ currentPage--;
849
+ renderJobs();
850
+ }
851
+ });
852
+
853
+ document.getElementById('nextPage')?.addEventListener('click', () => {
854
+ if (currentPage < totalPages) {
855
+ currentPage++;
856
+ renderJobs();
857
+ }
858
+ });
859
+
860
+ document.querySelectorAll('.page-number').forEach(btn => {
861
+ btn.addEventListener('click', () => {
862
+ currentPage = parseInt(btn.dataset.page);
863
+ renderJobs();
864
+ });
865
+ });
866
+
867
+ document.getElementById('jobsPerPage').addEventListener('change', (e) => {
868
+ jobsPerPage = parseInt(e.target.value);
869
+ currentPage = 1;
870
+ renderJobs();
871
+ });
872
+ }
873
+
874
+ // Render jobs (Homepage)
875
+ function renderJobs() {
876
+ if (currentView !== 'home') {
877
+ if (currentView === 'reports') renderReports();
878
+ return;
879
+ }
880
+ filterExpiredJobs();
881
+ tableBody.innerHTML = '';
882
+
883
+ function sanitizeTooltip(text) {
884
+ const div = document.createElement('div');
885
+ div.textContent = text || '';
886
+ return div.innerHTML.replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
887
+ }
888
+
889
+ let filteredJobs = jobs.map((job, originalIndex) => ({ job, originalIndex }))
890
+ .filter(({ job }) => {
891
+ const jobDate = new Date(job.date);
892
+ const startDate = filters.startDate ? new Date(filters.startDate) : null;
893
+ const endDate = filters.endDate ? new Date(filters.endDate) : null;
894
+ const jobMatches = !filters.search ||
895
+ job.job.toLowerCase().includes(filters.search.toLowerCase()) ||
896
+ (job.remark && job.remark.toLowerCase().includes(filters.search.toLowerCase()));
897
+ return (
898
+ (!startDate || jobDate >= startDate) &&
899
+ (!endDate || jobDate <= endDate) &&
900
+ jobMatches &&
901
+ (!filters.department || job.department === filters.department) &&
902
+ (!filters.priority || job.priority === filters.priority) &&
903
+ (!filters.jobType || job.jobType === filters.jobType) &&
904
+ (!filters.notificationNo || job.notificationNo.toLowerCase().includes(filters.notificationNo.toLowerCase()))
905
+ );
906
+ });
907
+
908
+ filteredJobs.sort((a, b) => {
909
+ let valA = a.job[sortColumn];
910
+ let valB = b.job[sortColumn];
911
+ if (sortColumn === 'date') {
912
+ valA = new Date(valA);
913
+ valB = new Date(valB);
914
+ }
915
+ if (valA < valB) return sortDirection === 'asc' ? -1 : 1;
916
+ if (valA > valB) return sortDirection === 'asc' ? 1 : -1;
917
+ return 0;
918
+ });
919
+
920
+ const startIndex = (currentPage - 1) * jobsPerPage;
921
+ const endIndex = startIndex + jobsPerPage;
922
+ const paginatedJobs = filteredJobs.slice(startIndex, endIndex);
923
+
924
+ if (paginatedJobs.length === 0) {
925
+ tableBody.innerHTML = '<tr><td colspan="8" class="px-6 py-4 text-center text-sm font-semibold text-gray-600">No jobs found. Try adjusting filters or adding a new job.</td></tr>';
926
+ } else {
927
+ paginatedJobs.forEach(({ job, originalIndex }, rowIndex) => {
928
+ const row = document.createElement('tr');
929
+ row.className = `even:bg-gray-50 ${job.status === 'Completed' ? 'completed-row' : ''}`;
930
+ row.innerHTML = `
931
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.date}</td>
932
+ <td class="px-6 py-4 text-sm text-gray-800" title="${sanitizeTooltip(job.job)}">${job.job}</td>
933
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.department}</td>
934
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.priority}</td>
935
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.jobType}</td>
936
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.notificationNo}</td>
937
+ <td class="px-6 py-4 text-sm text-gray-800" title="${sanitizeTooltip(job.remark)}">${job.remark || '-'}</td>
938
+ <td class="px-6 py-4 text-sm text-gray-800">
939
+ <div class="action-buttons">
940
+ <button class="edit-btn bg-blue-500 text-white px-1.5 py-0.5 rounded hover:bg-blue-600 text-[10px]" data-index="${originalIndex}" aria-label="Edit job">Edit</button>
941
+ <button class="delete-btn bg-red-500 text-white px-1.5 py-0.5 rounded hover:bg-red-600 text-[10px]" data-index="${originalIndex}" aria-label="Delete job">Delete</button>
942
+ </div>
943
+ </td>
944
+ `;
945
+ row.style.opacity = '0';
946
+ row.style.transition = 'opacity 0.3s ease';
947
+ tableBody.appendChild(row);
948
+ setTimeout(() => { row.style.opacity = '1'; }, 10);
949
+ });
950
+ }
951
+
952
+ renderPagination(filteredJobs.length);
953
+
954
+ document.querySelectorAll('#jobTable .sort-arrow').forEach(arrow => {
955
+ arrow.innerHTML = '';
956
+ });
957
+ const activeArrow = document.querySelector(`#jobTable th[data-sort="${sortColumn}"] .sort-arrow`);
958
+ if (activeArrow) {
959
+ activeArrow.innerHTML = sortDirection === 'asc' ? '↑' : '↓';
960
+ }
961
+ }
962
+
963
+ // Event delegation for table actions (Homepage)
964
+ tableBody.addEventListener('click', (e) => {
965
+ if (e.target.classList.contains('edit-btn')) {
966
+ const index = parseInt(e.target.dataset.index);
967
+ const job = jobs[index];
968
+ editIndex = index;
969
+ const jobDateInput = document.getElementById('jobDate');
970
+ jobDateInput.value = job.date;
971
+ jobDateInput.readOnly = true;
972
+ document.getElementById('job').value = job.job;
973
+ document.getElementById('department').value = job.department;
974
+ document.getElementById('priority').value = job.priority;
975
+ document.getElementById('jobType').value = job.jobType;
976
+ document.getElementById('notificationNo').value = job.notificationNo;
977
+ document.getElementById('remark').value = job.remark || '';
978
+ document.getElementById('submitButton').textContent = 'Update Job';
979
+ document.getElementById('cancelButton').classList.remove('hidden');
980
+ scrollToForm();
981
+ } else if (e.target.classList.contains('delete-btn')) {
982
+ const index = parseInt(e.target.dataset.index);
983
+ if (confirm('Are you sure you want to delete this job?')) {
984
+ jobs.splice(index, 1);
985
+ localStorage.setItem('jobs', JSON.stringify(jobs));
986
+ if (jobs.length <= (currentPage - 1) * jobsPerPage && currentPage > 1) {
987
+ currentPage--;
988
+ }
989
+ renderJobs();
990
+ showToast('Job Deleted Successfully');
991
+ }
992
+ }
993
+ });
994
+
995
+ // Form submission (Homepage)
996
+ document.getElementById('jobForm').addEventListener('submit', (e) => {
997
+ e.preventDefault();
998
+ const jobDate = new Date(document.getElementById('jobDate').value);
999
+ if (isNaN(jobDate)) {
1000
+ alert('Invalid date format');
1001
+ return;
1002
+ }
1003
+ const job = {
1004
+ date: jobDate.toISOString().split('T')[0],
1005
+ job: document.getElementById('job').value,
1006
+ department: document.getElementById('department').value,
1007
+ priority: document.getElementById('priority').value,
1008
+ jobType: document.getElementById('jobType').value,
1009
+ notificationNo: document.getElementById('notificationNo').value,
1010
+ remark: document.getElementById('remark').value || '',
1011
+ status: 'Pending'
1012
+ };
1013
+
1014
+ if (editIndex !== null) {
1015
+ job.status = jobs[editIndex].status || 'Pending';
1016
+ job.completedDate = jobs[editIndex].completedDate;
1017
+ jobs[editIndex] = job;
1018
+ localStorage.setItem('jobs', JSON.stringify(jobs));
1019
+ currentPage = 1;
1020
+ renderJobs();
1021
+ resetForm();
1022
+ showToast('Job Updated Successfully');
1023
+ } else {
1024
+ jobs.push(job);
1025
+ localStorage.setItem('jobs', JSON.stringify(jobs));
1026
+ currentPage = 1;
1027
+ renderJobs();
1028
+ resetForm();
1029
+ showToast('Job Saved Successfully');
1030
+ }
1031
+ });
1032
+
1033
+ // Cancel button
1034
+ document.getElementById('cancelButton').addEventListener('click', () => {
1035
+ resetForm();
1036
+ });
1037
+
1038
+ // Date filter validation (Homepage)
1039
+ document.getElementById('filterStartDate').addEventListener('change', (e) => {
1040
+ filters.startDate = e.target.value;
1041
+ document.getElementById('filterEndDate').min = e.target.value;
1042
+ if (filters.endDate && filters.endDate < e.target.value) {
1043
+ filters.endDate = '';
1044
+ document.getElementById('filterEndDate').value = '';
1045
+ showDateError(false);
1046
+ }
1047
+ currentPage = 1;
1048
+ renderJobs();
1049
+ });
1050
+
1051
+ document.getElementById('filterEndDate').addEventListener('change', (e) => {
1052
+ filters.endDate = e.target.value;
1053
+ if (filters.startDate && e.target.value < filters.startDate) {
1054
+ showDateError(true);
1055
+ e.target.value = filters.startDate;
1056
+ filters.endDate = filters.startDate;
1057
+ } else {
1058
+ showDateError(false);
1059
+ }
1060
+ currentPage = 1;
1061
+ renderJobs();
1062
+ });
1063
+
1064
+ // Other filters (Homepage)
1065
+ let debounceTimeout;
1066
+ document.getElementById('filterSearch').addEventListener('input', (e) => {
1067
+ clearTimeout(debounceTimeout);
1068
+ debounceTimeout = setTimeout(() => {
1069
+ filters.search = e.target.value;
1070
+ currentPage = 1;
1071
+ renderJobs();
1072
+ }, 300);
1073
+ });
1074
+
1075
+ document.getElementById('filterDepartment').addEventListener('change', (e) => {
1076
+ filters.department = e.target.value;
1077
+ currentPage = 1;
1078
+ renderJobs();
1079
+ });
1080
+
1081
+ document.getElementById('filterPriority').addEventListener('change', (e) => {
1082
+ filters.priority = e.target.value;
1083
+ currentPage = 1;
1084
+ renderJobs();
1085
+ });
1086
+
1087
+ document.getElementById('filterJobType').addEventListener('change', (e) => {
1088
+ filters.jobType = e.target.value;
1089
+ currentPage = 1;
1090
+ renderJobs();
1091
+ });
1092
+
1093
+ document.getElementById('filterNotificationNo').addEventListener('change', (e) => {
1094
+ filters.notificationNo = e.target.value;
1095
+ currentPage = 1;
1096
+ renderJobs();
1097
+ });
1098
+
1099
+ document.getElementById('clearFilters').addEventListener('click', () => {
1100
+ filters = { startDate: '', endDate: '', department: '', priority: '', jobType: '', notificationNo: '', search: '' };
1101
+ document.getElementById('filterStartDate').value = '';
1102
+ document.getElementById('filterEndDate').value = '';
1103
+ document.getElementById('filterEndDate').min = '';
1104
+ document.getElementById('filterDepartment').value = '';
1105
+ document.getElementById('filterPriority').value = '';
1106
+ document.getElementById('filterJobType').value = '';
1107
+ document.getElementById('filterNotificationNo').value = '';
1108
+ document.getElementById('filterSearch').value = '';
1109
+ showDateError(false);
1110
+ currentPage = 1;
1111
+ renderJobs();
1112
+ });
1113
+
1114
+ // Sorting (Homepage)
1115
+ document.querySelectorAll('#jobTable .sortable').forEach(header => {
1116
+ header.addEventListener('click', () => {
1117
+ const column = header.dataset.sort;
1118
+ if (sortColumn === column) {
1119
+ sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
1120
+ } else {
1121
+ sortColumn = column;
1122
+ sortDirection = 'asc';
1123
+ }
1124
+ currentPage = 1;
1125
+ renderJobs();
1126
+ });
1127
+ });
1128
+
1129
+ // Render reports (Reports page)
1130
+ function renderReports() {
1131
+ if (currentView !== 'reports') return;
1132
+ filterExpiredJobs();
1133
+ const reportTableBody = document.getElementById('reportTableBody');
1134
+
1135
+ function sanitizeTooltip(text) {
1136
+ const div = document.createElement('div');
1137
+ div.textContent = text || '';
1138
+ return div.innerHTML.replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
1139
+ }
1140
+
1141
+ let filteredJobs = jobs.map((job, originalIndex) => ({ job, originalIndex }))
1142
+ .filter(({ job }) => {
1143
+ const jobDate = new Date(job.date);
1144
+ const startDate = reportFilters.startDate ? new Date(reportFilters.startDate) : null;
1145
+ const endDate = reportFilters.endDate ? new Date(reportFilters.endDate) : null;
1146
+ const searchMatch = !reportFilters.search ||
1147
+ job.job.toLowerCase().includes(reportFilters.search.toLowerCase()) ||
1148
+ (job.remark && job.remark.toLowerCase().includes(reportFilters.search.toLowerCase()));
1149
+ const departmentMatch = job.department === activeDepartment;
1150
+ return (
1151
+ departmentMatch &&
1152
+ (!startDate || jobDate >= startDate) &&
1153
+ (!endDate || jobDate <= endDate) &&
1154
+ (!reportFilters.priority || job.priority === reportFilters.priority) &&
1155
+ (!reportFilters.jobType || job.jobType === reportFilters.jobType) &&
1156
+ searchMatch &&
1157
+ (!reportFilters.status || job.status === reportFilters.status)
1158
+ );
1159
+ });
1160
+
1161
+ filteredJobs.sort((a, b) => {
1162
+ let valA = a.job[reportSortColumn];
1163
+ let valB = b.job[reportSortColumn];
1164
+ if (reportSortColumn === 'date') {
1165
+ valA = new Date(valA);
1166
+ valB = new Date(valB);
1167
+ } else if (reportSortColumn === 'completedDate') {
1168
+ valA = valA ? new Date(valA) : null;
1169
+ valB = valB ? new Date(valB) : null;
1170
+ if (!valA && !valB) return 0;
1171
+ if (!valA) return 1;
1172
+ if (!valB) return -1;
1173
+ } else if (reportSortColumn === 'status') {
1174
+ valA = valA || 'Pending';
1175
+ valB = valB || 'Pending';
1176
+ const statusOrder = { 'Pending': 1, 'Completed': 0 };
1177
+ valA = statusOrder[valA];
1178
+ valB = statusOrder[valB];
1179
+ }
1180
+ if (valA < valB) return reportSortDirection === 'asc' ? -1 : 1;
1181
+ if (valA > valB) return reportSortDirection === 'asc' ? 1 : -1;
1182
+ return 0;
1183
+ });
1184
+
1185
+ const startIndex = (reportCurrentPage - 1) * reportJobsPerPage;
1186
+ const endIndex = startIndex + reportJobsPerPage;
1187
+ const paginatedJobs = filteredJobs.slice(startIndex, endIndex);
1188
+
1189
+ reportTableBody.innerHTML = paginatedJobs.length === 0
1190
+ ? `<tr><td colspan="9" class="px-6 py-4 text-center text-sm font-semibold text-gray-600">No jobs found for ${activeDepartment} department.</td></tr>`
1191
+ : paginatedJobs.map(({ job, originalIndex }) => `
1192
+ <tr class="even:bg-gray-50 ${job.status === 'Completed' ? 'completed-row' : ''}">
1193
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.date}</td>
1194
+ <td class="px-6 py-4 text-sm text-gray-800" title="${sanitizeTooltip(job.job)}">${job.job}</td>
1195
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.priority}</td>
1196
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.jobType}</td>
1197
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.notificationNo}</td>
1198
+ <td class="px-6 py-4 text-sm text-gray-800" title="${sanitizeTooltip(job.remark || '')}">${job.remark || '-'}</td>
1199
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.completedDate || '-'}</td>
1200
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">
1201
+ <select class="status-select input-field rounded bg-white py-1 px-2 text-sm focus:ring-2 focus:ring-blue-400" data-index="${originalIndex}">
1202
+ <option value="Pending" ${job.status === 'Pending' ? 'selected' : ''}>Pending</option>
1203
+ <option value="Completed" ${job.status === 'Completed' ? 'selected' : ''}>Completed</option>
1204
+ </select>
1205
+ </td>
1206
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">
1207
+ <button class="save-btn bg-blue-500 text-white px-1.5 py-0.5 rounded hover:bg-blue-600 text-[10px]" data-index="${originalIndex}" aria-label="Save job status">Save</button>
1208
+ </td>
1209
+ </tr>
1210
+ `).join('');
1211
+
1212
+ renderReportPagination(filteredJobs.length);
1213
+
1214
+ document.querySelectorAll('#reportTable .sortable').forEach(header => {
1215
+ const arrow = header.querySelector('.sort-arrow');
1216
+ arrow.innerHTML = '';
1217
+ header.setAttribute('aria-sort', header.dataset.sort === reportSortColumn ? (reportSortDirection === 'asc' ? 'ascending' : 'descending') : 'none');
1218
+ });
1219
+ const activeArrow = document.querySelector(`#reportTable th[data-sort="${reportSortColumn}"] .sort-arrow`);
1220
+ if (activeArrow) activeArrow.innerHTML = reportSortDirection === 'asc' ? '↑' : '↓';
1221
+ }
1222
+
1223
+ // Render report pagination (Reports page)
1224
+ function renderReportPagination(totalJobs) {
1225
+ const pagination = document.getElementById('reportPagination');
1226
+ const totalPages = Math.ceil(totalJobs / reportJobsPerPage);
1227
+ reportCurrentPage = Math.min(reportCurrentPage, totalPages || 1);
1228
+ const startJob = (reportCurrentPage - 1) * reportJobsPerPage + 1;
1229
+ const endJob = Math.min(reportCurrentPage * reportJobsPerPage, totalJobs);
1230
+
1231
+ let html = `
1232
+ <div class="flex items-center gap-4 text-sm text-gray-600">
1233
+ <div>
1234
+ <label for="reportJobsPerPage" class="mr-2">Jobs per page:</label>
1235
+ <select id="reportJobsPerPage" class="jobs-per-page input-field rounded bg-white py-1 px-2 focus:ring-2 focus:ring-teal-400 hover:shadow-sm">
1236
+ <option value="10" ${reportJobsPerPage === 10 ? 'selected' : ''}>10</option>
1237
+ <option value="15" ${reportJobsPerPage === 15 ? 'selected' : ''}>15</option>
1238
+ <option value="25" ${reportJobsPerPage === 25 ? 'selected' : ''}>25</option>
1239
+ </select>
1240
+ </div>
1241
+ <div id="reportPaginationRange">
1242
+ Showing ${totalJobs > 0 ? startJob : 0} to ${endJob} of ${totalJobs} jobs
1243
+ </div>
1244
+ </div>
1245
+ <div class="flex gap-2 flex-wrap">
1246
+ <button id="reportPrevPage" class="bg-teal-500 text-white hover:bg-teal-600 disabled:bg-gray-300" ${reportCurrentPage === 1 ? 'disabled' : ''}>Previous</button>
1247
+ <div class="flex gap-1">
1248
+ `;
1249
+
1250
+ const maxPagesToShow = 5;
1251
+ let startPage = Math.max(1, reportCurrentPage - Math.floor(maxPagesToShow / 2));
1252
+ let endPage = Math.min(totalPages, startPage + maxPagesToShow - 1);
1253
+ if (endPage - startPage + 1 < maxPagesToShow) {
1254
+ startPage = Math.max(1, endPage - maxPagesToShow + 1);
1255
+ }
1256
+
1257
+ if (startPage > 1) {
1258
+ html += `<span class="page-number" data-page="1">1</span>`;
1259
+ if (startPage > 2) html += `<span class="px-2">...</span>`;
1260
+ }
1261
+
1262
+ for (let i = startPage; i <= endPage; i++) {
1263
+ html += `<span class="page-number ${i === reportCurrentPage ? 'active' : ''}" data-page="${i}">${i}</span>`;
1264
+ }
1265
+
1266
+ if (endPage < totalPages) {
1267
+ if (endPage < totalPages - 1) html += `<span class="px-2">...</span>`;
1268
+ html += `<span class="page-number" data-page="${totalPages}">${totalPages}</span>`;
1269
+ }
1270
+
1271
+ html += `
1272
+ </div>
1273
+ <button id="reportNextPage" class="bg-teal-500 text-white hover:bg-teal-600 disabled:bg-gray-300" ${reportCurrentPage === totalPages ? 'disabled' : ''}>Next</button>
1274
+ </div>
1275
+ `;
1276
+
1277
+ pagination.innerHTML = html;
1278
+
1279
+ document.getElementById('reportPrevPage')?.addEventListener('click', () => {
1280
+ if (reportCurrentPage > 1) {
1281
+ reportCurrentPage--;
1282
+ renderReports();
1283
+ }
1284
+ });
1285
+
1286
+ document.getElementById('reportNextPage')?.addEventListener('click', () => {
1287
+ if (reportCurrentPage < totalPages) {
1288
+ reportCurrentPage++;
1289
+ renderReports();
1290
+ }
1291
+ });
1292
+
1293
+ document.querySelectorAll('#reportPagination .page-number').forEach(btn => {
1294
+ btn.addEventListener('click', () => {
1295
+ reportCurrentPage = parseInt(btn.dataset.page);
1296
+ renderReports();
1297
+ });
1298
+ });
1299
+
1300
+ document.getElementById('reportJobsPerPage').addEventListener('change', (e) => {
1301
+ reportJobsPerPage = parseInt(e.target.value);
1302
+ reportCurrentPage = 1;
1303
+ renderReports();
1304
+ });
1305
+ }
1306
+
1307
+ // Render history pagination (History tab)
1308
+ function renderHistoryPagination(totalJobs) {
1309
+ const pagination = document.getElementById('historyPagination');
1310
+ const totalPages = Math.ceil(totalJobs / historyJobsPerPage);
1311
+ historyCurrentPage = Math.min(historyCurrentPage, totalPages || 1);
1312
+ const startJob = (historyCurrentPage - 1) * historyJobsPerPage + 1;
1313
+ const endJob = Math.min(historyCurrentPage * historyJobsPerPage, totalJobs);
1314
+
1315
+ let html = `
1316
+ <div class="flex items-center gap-4 text-sm text-gray-600">
1317
+ <div>
1318
+ <label for="historyJobsPerPage" class="mr-2">Jobs per page:</label>
1319
+ <select id="historyJobsPerPage" class="jobs-per-page input-field rounded bg-white py-1 px-2 focus:ring-2 focus:ring-teal-400 hover:shadow-sm">
1320
+ <option value="10" ${historyJobsPerPage === 10 ? 'selected' : ''}>10</option>
1321
+ <option value="15" ${historyJobsPerPage === 15 ? 'selected' : ''}>15</option>
1322
+ <option value="25" ${historyJobsPerPage === 25 ? 'selected' : ''}>25</option>
1323
+ </select>
1324
+ </div>
1325
+ <div id="historyPaginationRange">
1326
+ Showing ${totalJobs > 0 ? startJob : 0} to ${endJob} of ${totalJobs} jobs
1327
+ </div>
1328
+ </div>
1329
+ <div class="flex gap-2 flex-wrap">
1330
+ <button id="historyPrevPage" class="bg-teal-500 text-white hover:bg-teal-600 disabled:bg-gray-300" ${historyCurrentPage === 1 ? 'disabled' : ''} aria-label="Previous page">Previous</button>
1331
+ <div class="flex gap-1">
1332
+ `;
1333
+
1334
+ const maxPagesToShow = 5;
1335
+ let startPage = Math.max(1, historyCurrentPage - Math.floor(maxPagesToShow / 2));
1336
+ let endPage = Math.min(totalPages, startPage + maxPagesToShow - 1);
1337
+ if (endPage - startPage + 1 < maxPagesToShow) {
1338
+ startPage = Math.max(1, endPage - maxPagesToShow + 1);
1339
+ }
1340
+
1341
+ if (startPage > 1) {
1342
+ html += `<span class="page-number" data-page="1">1</span>`;
1343
+ if (startPage > 2) html += `<span class="px-2">...</span>`;
1344
+ }
1345
+
1346
+ for (let i = startPage; i <= endPage; i++) {
1347
+ html += `<span class="page-number ${i === historyCurrentPage ? 'active' : ''}" data-page="${i}">${i}</span>`;
1348
+ }
1349
+
1350
+ if (endPage < totalPages) {
1351
+ if (endPage < totalPages - 1) html += `<span class="px-2">...</span>`;
1352
+ html += `<span class="page-number" data-page="${totalPages}">${totalPages}</span>`;
1353
+ }
1354
+
1355
+ html += `
1356
+ </div>
1357
+ <button id="historyNextPage" class="bg-teal-500 text-white hover:bg-teal-600 disabled:bg-gray-300" ${historyCurrentPage === totalPages ? 'disabled' : ''} aria-label="Next page">Next</button>
1358
+ </div>
1359
+ `;
1360
+
1361
+ pagination.innerHTML = html;
1362
+
1363
+ document.getElementById('historyPrevPage')?.addEventListener('click', () => {
1364
+ if (historyCurrentPage > 1) {
1365
+ historyCurrentPage--;
1366
+ renderHistory();
1367
+ }
1368
+ });
1369
+
1370
+ document.getElementById('historyNextPage')?.addEventListener('click', () => {
1371
+ if (historyCurrentPage < totalPages) {
1372
+ historyCurrentPage++;
1373
+ renderHistory();
1374
+ }
1375
+ });
1376
+
1377
+ document.querySelectorAll('#historyPagination .page-number').forEach(btn => {
1378
+ btn.addEventListener('click', () => {
1379
+ historyCurrentPage = parseInt(btn.dataset.page);
1380
+ renderHistory();
1381
+ });
1382
+ });
1383
+
1384
+ document.getElementById('historyJobsPerPage').addEventListener('change', (e) => {
1385
+ historyJobsPerPage = parseInt(e.target.value);
1386
+ historyCurrentPage = 1;
1387
+ renderHistory();
1388
+ });
1389
+ }
1390
+
1391
+ // Render history (History tab)
1392
+ function renderHistory() {
1393
+ const historyTableBody = document.getElementById('historyTableBody');
1394
+ function sanitizeTooltip(text) {
1395
+ const div = document.createElement('div');
1396
+ div.textContent = text || '';
1397
+ return div.innerHTML.replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
1398
+ }
1399
+
1400
+ let filteredHistory = jobs.filter(job =>
1401
+ job.status === 'Completed' &&
1402
+ (!reportFilters.startDate || new Date(job.completedDate) >= new Date(reportFilters.startDate)) &&
1403
+ (!reportFilters.endDate || new Date(job.completedDate) <= new Date(reportFilters.endDate)) &&
1404
+ (!reportFilters.search ||
1405
+ job.job.toLowerCase().includes(reportFilters.search.toLowerCase()) ||
1406
+ (job.remark && job.remark.toLowerCase().includes(reportFilters.search.toLowerCase()))) &&
1407
+ (!reportFilters.department || job.department === reportFilters.department)
1408
+ );
1409
+
1410
+ filteredHistory.sort((a, b) => {
1411
+ let valA = a[historySortColumn];
1412
+ let valB = b[historySortColumn];
1413
+ if (historySortColumn === 'date' || historySortColumn === 'completedDate') {
1414
+ valA = valA ? new Date(valA) : null;
1415
+ valB = valB ? new Date(valB) : null;
1416
+ if (!valA && !valB) return 0;
1417
+ if (!valA) return 1;
1418
+ if (!valB) return -1;
1419
+ }
1420
+ if (valA < valB) return historySortDirection === 'asc' ? -1 : 1;
1421
+ if (valA > valB) return historySortDirection === 'asc' ? 1 : -1;
1422
+ return 0;
1423
+ });
1424
+
1425
+ const startIndex = (historyCurrentPage - 1) * historyJobsPerPage;
1426
+ const endIndex = startIndex + historyJobsPerPage;
1427
+ const paginatedHistory = filteredHistory.slice(startIndex, endIndex);
1428
+
1429
+ historyTableBody.innerHTML = paginatedHistory.length === 0
1430
+ ? '<tr><td colspan="4" class="px-6 py-4 text-center text-sm font-semibold text-gray-600">No completed jobs found.</td></tr>'
1431
+ : paginatedHistory.map(job => `
1432
+ <tr class="even:bg-gray-50">
1433
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.date}</td>
1434
+ <td class="px-6 py-4 text-sm text-gray-800" title="${sanitizeTooltip(job.job)}">${job.job}</td>
1435
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.department}</td>
1436
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-800">${job.completedDate || '-'}</td>
1437
+ </tr>
1438
+ `).join('');
1439
+
1440
+ document.querySelectorAll('#historyTable .sortable').forEach(header => {
1441
+ const arrow = header.querySelector('.sort-arrow');
1442
+ arrow.innerHTML = '';
1443
+ header.setAttribute('aria-sort', header.dataset.sort === historySortColumn ? (historySortDirection === 'asc' ? 'ascending' : 'descending') : 'none');
1444
+ });
1445
+ const activeArrow = document.querySelector(`#historyTable th[data-sort="${historySortColumn}"] .sort-arrow`);
1446
+ if (activeArrow) activeArrow.innerHTML = historySortDirection === 'asc' ? '↑' : '↓';
1447
+
1448
+ renderHistoryPagination(filteredHistory.length);
1449
+ }
1450
+
1451
+ // Tab switching (Reports page)
1452
+ document.querySelectorAll('.tab-link').forEach(tab => {
1453
+ tab.addEventListener('click', (e) => {
1454
+ e.preventDefault();
1455
+ document.querySelectorAll('.tab-link').forEach(t => t.classList.remove('active'));
1456
+ tab.classList.add('active');
1457
+ activeDepartment = tab.dataset.department;
1458
+ const isHistoryTab = activeDepartment === 'History';
1459
+ document.getElementById('reportTable').classList.toggle('hidden', isHistoryTab);
1460
+ document.getElementById('historyTableContainer').classList.toggle('hidden', !isHistoryTab);
1461
+ document.getElementById('reportDepartmentFilter').classList.toggle('hidden', !isHistoryTab);
1462
+ document.getElementById('reportPriorityFilter').classList.toggle('hidden', isHistoryTab);
1463
+ document.getElementById('reportStatusFilter').classList.toggle('hidden', isHistoryTab);
1464
+ if (isHistoryTab) {
1465
+ reportFilters.status = 'Completed';
1466
+ reportFilters.priority = '';
1467
+ document.getElementById('reportStatus').value = 'Completed';
1468
+ document.getElementById('reportPriority').value = '';
1469
+ document.getElementById('reportPagination').classList.add('hidden');
1470
+ document.getElementById('historyPagination').classList.remove('hidden');
1471
+ historyCurrentPage = 1;
1472
+ historyJobsPerPage = 15;
1473
+ renderHistory();
1474
+ } else {
1475
+ reportFilters.status = '';
1476
+ reportFilters.department = '';
1477
+ document.getElementById('reportStatus').value = '';
1478
+ document.getElementById('reportDepartment').value = '';
1479
+ document.getElementById('reportPagination').classList.remove('hidden');
1480
+ document.getElementById('historyPagination').classList.add('hidden');
1481
+ reportCurrentPage = 1;
1482
+ renderReports();
1483
+ }
1484
+ });
1485
+ });
1486
+
1487
+ // Save status (Reports page)
1488
+ document.getElementById('reportTableBody').addEventListener('click', (e) => {
1489
+ if (e.target.classList.contains('save-btn')) {
1490
+ const index = parseInt(e.target.dataset.index);
1491
+ console.log('Save button clicked for index:', index);
1492
+ const select = document.querySelector(`#reportTableBody select[data-index="${index}"]`);
1493
+ if (!select) {
1494
+ console.error('Status select not found for index:', index);
1495
+ return;
1496
+ }
1497
+ const newStatus = select.value;
1498
+ console.log('New status:', newStatus);
1499
+ jobs[index].status = newStatus;
1500
+ if (newStatus === 'Completed') {
1501
+ const today = new Date().toISOString().split('T')[0];
1502
+ jobs[index].completedDate = today;
1503
+ console.log('Set completedDate to:', today);
1504
+ } else {
1505
+ delete jobs[index].completedDate;
1506
+ console.log('Cleared completedDate for index:', index);
1507
+ }
1508
+ console.log('Updated job:', jobs[index]);
1509
+ localStorage.setItem('jobs', JSON.stringify(jobs));
1510
+ console.log('Saved to localStorage:', jobs);
1511
+ renderReports();
1512
+ renderJobs();
1513
+ showToast('Status Updated Successfully');
1514
+ }
1515
+ });
1516
+
1517
+ // Date filter validation (Reports page)
1518
+ document.getElementById('reportStartDate').addEventListener('change', (e) => {
1519
+ reportFilters.startDate = e.target.value;
1520
+ document.getElementById('reportEndDate').min = e.target.value;
1521
+ if (reportFilters.endDate && reportFilters.endDate < e.target.value) {
1522
+ reportFilters.endDate = '';
1523
+ document.getElementById('reportEndDate').value = '';
1524
+ document.getElementById('reportDateError').classList.add('hidden');
1525
+ }
1526
+ reportCurrentPage = 1;
1527
+ if (activeDepartment === 'History') {
1528
+ renderHistory();
1529
+ } else {
1530
+ renderReports();
1531
+ }
1532
+ });
1533
+
1534
+ document.getElementById('reportEndDate').addEventListener('change', (e) => {
1535
+ reportFilters.endDate = e.target.value;
1536
+ if (reportFilters.startDate && e.target.value < reportFilters.startDate) {
1537
+ e.target.value = reportFilters.startDate;
1538
+ reportFilters.endDate = reportFilters.startDate;
1539
+ document.getElementById('reportDateError').classList.remove('hidden');
1540
+ } else {
1541
+ document.getElementById('reportDateError').classList.add('hidden');
1542
+ }
1543
+ reportCurrentPage = 1;
1544
+ if (activeDepartment === 'History') {
1545
+ renderHistory();
1546
+ } else {
1547
+ renderReports();
1548
+ }
1549
+ });
1550
+
1551
+ document.getElementById('reportPriority').addEventListener('change', (e) => {
1552
+ reportFilters.priority = e.target.value;
1553
+ reportCurrentPage = 1;
1554
+ if (activeDepartment !== 'History') {
1555
+ renderReports();
1556
+ }
1557
+ });
1558
+
1559
+ document.getElementById('reportJobType').addEventListener('change', (e) => {
1560
+ reportFilters.jobType = e.target.value;
1561
+ reportCurrentPage = 1;
1562
+ if (activeDepartment === 'History') {
1563
+ renderHistory();
1564
+ } else {
1565
+ renderReports();
1566
+ }
1567
+ });
1568
+
1569
+ document.getElementById('reportSearch').addEventListener('input', (e) => {
1570
+ clearTimeout(debounceTimeout);
1571
+ debounceTimeout = setTimeout(() => {
1572
+ reportFilters.search = e.target.value;
1573
+ if (activeDepartment === 'History') {
1574
+ historyCurrentPage = 1;
1575
+ renderHistory();
1576
+ } else {
1577
+ reportCurrentPage = 1;
1578
+ renderReports();
1579
+ }
1580
+ }, 300);
1581
+ });
1582
+
1583
+ document.getElementById('reportStatus').addEventListener('change', (e) => {
1584
+ reportFilters.status = e.target.value;
1585
+ reportCurrentPage = 1;
1586
+ if (activeDepartment !== 'History') {
1587
+ renderReports();
1588
+ }
1589
+ });
1590
+
1591
+ document.getElementById('reportDepartment').addEventListener('change', (e) => {
1592
+ reportFilters.department = e.target.value;
1593
+ reportCurrentPage = 1;
1594
+ if (activeDepartment === 'History') {
1595
+ renderHistory();
1596
+ }
1597
+ });
1598
+
1599
+ document.getElementById('clearReportFilters').addEventListener('click', () => {
1600
+ reportFilters = { startDate: '', endDate: '', priority: '', jobType: '', search: '', status: '', department: '' };
1601
+ document.getElementById('reportStartDate').value = '';
1602
+ document.getElementById('reportEndDate').value = '';
1603
+ document.getElementById('reportEndDate').min = '';
1604
+ document.getElementById('reportPriority').value = '';
1605
+ document.getElementById('reportJobType').value = '';
1606
+ document.getElementById('reportSearch').value = '';
1607
+ document.getElementById('reportStatus').value = '';
1608
+ document.getElementById('reportDepartment').value = '';
1609
+ document.getElementById('reportDateError').classList.add('hidden');
1610
+ reportCurrentPage = 1;
1611
+ if (activeDepartment === 'History') {
1612
+ renderHistory();
1613
+ } else {
1614
+ renderReports();
1615
+ }
1616
+ });
1617
+
1618
+ // Export jobs from Home page
1619
+ document.getElementById('exportJobsHome').addEventListener('click', () => {
1620
+ const filteredJobs = jobs.map((job, originalIndex) => ({ job, originalIndex }))
1621
+ .filter(({ job }) => {
1622
+ const jobDate = new Date(job.date);
1623
+ const startDate = filters.startDate ? new Date(filters.startDate) : null;
1624
+ const endDate = filters.endDate ? new Date(filters.endDate) : null;
1625
+ const jobMatches = !filters.search ||
1626
+ job.job.toLowerCase().includes(filters.search.toLowerCase()) ||
1627
+ (job.remark && job.remark.toLowerCase().includes(filters.search.toLowerCase()));
1628
+ return (
1629
+ (!startDate || jobDate >= startDate) &&
1630
+ (!endDate || jobDate <= endDate) &&
1631
+ jobMatches &&
1632
+ (!filters.department || job.department === filters.department) &&
1633
+ (!filters.priority || job.priority === filters.priority) &&
1634
+ (!filters.jobType || job.jobType === filters.jobType) &&
1635
+ (!filters.notificationNo || job.notificationNo.toLowerCase().includes(filters.notificationNo.toLowerCase()))
1636
+ );
1637
+ });
1638
+
1639
+ const headers = ['Date', 'Job Description', 'Department', 'Priority', 'Job Type', 'Notification No', 'Remark', 'Status', 'Completion Date'];
1640
+ const csvRows = [
1641
+ headers.join(','),
1642
+ ...filteredJobs.map(({ job }) => [
1643
+ `"${job.date}"`,
1644
+ `"${job.job.replace(/"/g, '""')}"`,
1645
+ `"${job.department}"`,
1646
+ `"${job.priority}"`,
1647
+ `"${job.jobType}"`,
1648
+ `"${job.notificationNo}"`,
1649
+ `"${(job.remark || '').replace(/"/g, '""')}"`,
1650
+ `"${job.status}"`,
1651
+ `"${job.completedDate || ''}"`
1652
+ ].join(','))
1653
+ ].join('\n');
1654
+
1655
+ const blob = new Blob([csvRows], { type: 'text/csv' });
1656
+ const url = window.URL.createObjectURL(blob);
1657
+ const a = document.createElement('a');
1658
+ a.href = url;
1659
+ a.download = `jobs_home_${new Date().toISOString().split('T')[0]}.csv`;
1660
+ a.click();
1661
+ window.URL.revokeObjectURL(url);
1662
+ });
1663
+
1664
+ // Export jobs from Reports page
1665
+ document.getElementById('exportJobs').addEventListener('click', () => {
1666
+ let filteredJobs;
1667
+ let headers;
1668
+ if (activeDepartment === 'History') {
1669
+ filteredJobs = jobs.filter(job =>
1670
+ job.status === 'Completed' &&
1671
+ (!reportFilters.startDate || new Date(job.completedDate) >= new Date(reportFilters.startDate)) &&
1672
+ (!reportFilters.endDate || new Date(job.completedDate) <= new Date(reportFilters.endDate)) &&
1673
+ (!reportFilters.search ||
1674
+ job.job.toLowerCase().includes(reportFilters.search.toLowerCase()) ||
1675
+ (job.remark && job.remark.toLowerCase().includes(reportFilters.search.toLowerCase()))) &&
1676
+ (!reportFilters.department || job.department === reportFilters.department)
1677
+ );
1678
+ headers = ['Date', 'Job Description', 'Department', 'Completion Date'];
1679
+ } else {
1680
+ filteredJobs = jobs.filter(job => {
1681
+ const jobDate = new Date(job.date);
1682
+ const startDate = reportFilters.startDate ? new Date(reportFilters.startDate) : null;
1683
+ const endDate = reportFilters.endDate ? new Date(reportFilters.endDate) : null;
1684
+ const searchMatch = !reportFilters.search ||
1685
+ job.job.toLowerCase().includes(reportFilters.search.toLowerCase()) ||
1686
+ (job.remark && job.remark.toLowerCase().includes(reportFilters.search.toLowerCase()));
1687
+ return (
1688
+ job.department === activeDepartment &&
1689
+ (!startDate || jobDate >= startDate) &&
1690
+ (!endDate || jobDate <= endDate) &&
1691
+ (!reportFilters.priority || job.priority === reportFilters.priority) &&
1692
+ (!reportFilters.jobType || job.jobType === reportFilters.jobType) &&
1693
+ searchMatch &&
1694
+ (!reportFilters.status || job.status === reportFilters.status)
1695
+ );
1696
+ });
1697
+ headers = ['Date', 'Job Description', 'Priority', 'Job Type', 'Notification No', 'Remark', 'Completion Date', 'Status', 'Department'];
1698
+ }
1699
+
1700
+ const csvRows = [
1701
+ headers.join(','),
1702
+ ...filteredJobs.map(job => {
1703
+ const row = [
1704
+ `"${job.date}"`,
1705
+ `"${job.job.replace(/"/g, '""')}"`
1706
+ ];
1707
+ if (activeDepartment === 'History') {
1708
+ row.push(`"${job.department}"`, `"${job.completedDate || ''}"`);
1709
+ } else {
1710
+ row.push(
1711
+ `"${job.priority}"`,
1712
+ `"${job.jobType}"`,
1713
+ `"${job.notificationNo}"`,
1714
+ `"${(job.remark || '').replace(/"/g, '""')}"`,
1715
+ `"${job.completedDate || ''}"`,
1716
+ `"${job.status}"`,
1717
+ `"${job.department}"`
1718
+ );
1719
+ }
1720
+ return row.join(',');
1721
+ })
1722
+ ].join('\n');
1723
+
1724
+ const blob = new Blob([csvRows], { type: 'text/csv' });
1725
+ const url = window.URL.createObjectURL(blob);
1726
+ const a = document.createElement('a');
1727
+ a.href = url;
1728
+ a.download = `jobs_${activeDepartment}_${new Date().toISOString().split('T')[0]}.csv`;
1729
+ a.click();
1730
+ window.URL.revokeObjectURL(url);
1731
+ });
1732
+
1733
+ // Sorting for History table
1734
+ document.querySelectorAll('#historyTable .sortable').forEach(header => {
1735
+ header.addEventListener('click', () => {
1736
+ const column = header.dataset.sort;
1737
+ if (historySortColumn === column) {
1738
+ historySortDirection = historySortDirection === 'asc' ? 'desc' : 'asc';
1739
+ } else {
1740
+ historySortColumn = column;
1741
+ historySortDirection = 'asc';
1742
+ }
1743
+ historyCurrentPage = 1;
1744
+ renderHistory();
1745
+ });
1746
+ });
1747
+
1748
+ // Sorting for Reports table
1749
+ document.querySelectorAll('#reportTable .sortable').forEach(header => {
1750
+ header.addEventListener('click', () => {
1751
+ const column = header.dataset.sort;
1752
+ if (reportSortColumn === column) {
1753
+ reportSortDirection = reportSortDirection === 'asc' ? 'desc' : 'asc';
1754
+ } else {
1755
+ reportSortColumn = column;
1756
+ reportSortDirection = 'asc';
1757
+ }
1758
+ reportCurrentPage = 1;
1759
+ renderReports();
1760
+ });
1761
+ });
1762
+
1763
+ // Initial render
1764
+ if (currentView === 'reports') {
1765
+ renderReports();
1766
+ } else {
1767
+ resetForm();
1768
+ renderJobs();
1769
+ }
1770
+
1771
+ </script>
1772
+
1773
+ <!-- Toast Notification -->
1774
+ <div id="toast" class="fixed top-4 right-4 z-50 hidden bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg transition-opacity duration-300">
1775
+ <span id="toastMessage"></span>
1776
+ </div>
1777
+ </body>
1778
+ </html>
1779
+ <!-- Created by Vinod Rangi, DHT Unit Job Tracking v1.0, June 2025 -->