-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1902 lines (1701 loc) · 106 KB
/
Copy pathindex.html
File metadata and controls
1902 lines (1701 loc) · 106 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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Utica University - Academic Course Scheduler & Banner Exporter</title>
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- FontAwesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- SheetJS with Styling CDN (xlsx-js-style) -->
<script src="https://cdn.jsdelivr.net/npm/xlsx-js-style@1.2.0/dist/xlsx.bundle.js"></script>
</head>
<body class="bg-slate-100 text-slate-800 min-h-screen font-sans flex flex-col">
<!-- Header styled in Utica Navy and Orange -->
<header class="bg-[#002D62] text-white shadow-xl border-b-4 border-[#E85E26]">
<div class="max-w-7xl mx-auto px-4 py-4 flex flex-col md:flex-row justify-between items-center gap-4">
<div class="flex items-center space-x-3">
<div class="bg-[#E85E26] text-white p-2.5 rounded-xl shadow-md">
<i class="fa-solid fa-graduation-cap text-2xl"></i>
</div>
<div>
<div class="flex items-center space-x-2">
<h1 class="text-xl font-black tracking-wider uppercase text-white">Utica University</h1>
<span class="bg-[#E85E26] text-white text-[10px] font-bold px-2 py-0.5 rounded uppercase tracking-widest">Scheduler</span>
</div>
<p class="text-xs text-slate-300">Banner Schedule Roll & Course Assignment Management System</p>
</div>
</div>
<!-- Header Action Controls -->
<div class="flex flex-wrap items-center gap-2">
<a href="https://github.com/securemindorg/utica-scheduling-generator/blob/main/index.html"
target="_blank"
rel="noopener noreferrer"
class="bg-slate-900/80 hover:bg-black text-slate-100 border border-slate-700/80 font-semibold px-3 py-2 rounded-lg shadow-md flex items-center space-x-2 transition text-xs hover:border-slate-500 group">
<i class="fa-brands fa-github text-base text-white group-hover:scale-110 transition-transform"></i>
<span>README</span>
</a>
<button onclick="exportModifiedExcel()" class="bg-[#E85E26] hover:bg-[#d14f1d] text-white font-bold px-4 py-2 rounded-lg shadow-md flex items-center space-x-2 transition text-sm">
<i class="fa-solid fa-file-excel"></i>
<span>Export Changes Only (.xlsx)</span>
</button>
<button onclick="runAutoScheduler()" class="bg-[#001D42] hover:bg-[#00122B] text-amber-400 font-semibold px-4 py-2 rounded-lg shadow border border-amber-500/30 flex items-center space-x-2 transition text-sm">
<i class="fa-solid fa-bolt text-amber-400"></i>
<span>Auto-Assign</span>
</button>
<button onclick="exportToBannerCSV()" class="bg-emerald-600 hover:bg-emerald-700 text-white font-semibold px-4 py-2 rounded-lg shadow flex items-center space-x-2 transition text-sm">
<i class="fa-solid fa-file-csv"></i>
<span>Banner output.csv</span>
</button>
</div>
</div>
</header>
<!-- Navigation Tabs -->
<nav class="bg-white border-b border-slate-200 shadow-sm sticky top-0 z-30">
<div class="max-w-7xl mx-auto px-4 flex overflow-x-auto space-x-6 scrollbar-none">
<button onclick="switchTab('dashboard')" id="tab-dashboard" class="tab-btn py-3.5 px-3 border-b-2 font-bold text-sm border-[#E85E26] text-[#002D62] flex items-center space-x-2 whitespace-nowrap">
<i class="fa-solid fa-chart-pie text-[#E85E26]"></i><span>Dashboard</span>
</button>
<button onclick="switchTab('courses')" id="tab-courses" class="tab-btn py-3.5 px-3 border-b-2 font-medium text-sm border-transparent text-slate-500 hover:text-[#002D62] flex items-center space-x-2 whitespace-nowrap">
<i class="fa-solid fa-book"></i><span>Course Catalog</span>
</button>
<button onclick="switchTab('faculty')" id="tab-faculty" class="tab-btn py-3.5 px-3 border-b-2 font-medium text-sm border-transparent text-slate-500 hover:text-[#002D62] flex items-center space-x-2 whitespace-nowrap">
<i class="fa-solid fa-user-graduate"></i><span>Faculty Roster</span>
</button>
<button onclick="switchTab('rooms')" id="tab-rooms" class="tab-btn py-3.5 px-3 border-b-2 font-medium text-sm border-transparent text-slate-500 hover:text-[#002D62] flex items-center space-x-2 whitespace-nowrap">
<i class="fa-solid fa-door-open"></i><span>Classrooms</span>
</button>
<button onclick="switchTab('timeslots')" id="tab-timeslots" class="tab-btn py-3.5 px-3 border-b-2 font-medium text-sm border-transparent text-slate-500 hover:text-[#002D62] flex items-center space-x-2 whitespace-nowrap">
<i class="fa-solid fa-clock"></i><span>Timeslots</span>
</button>
<button onclick="switchTab('schedule')" id="tab-schedule" class="tab-btn py-3.5 px-3 border-b-2 font-medium text-sm border-transparent text-slate-500 hover:text-[#002D62] flex items-center space-x-2 whitespace-nowrap">
<i class="fa-solid fa-table-cells"></i><span>Schedule Grid</span>
</button>
</div>
</nav>
<!-- Main Content Area -->
<main class="max-w-7xl mx-auto px-4 py-6 flex-grow w-full">
<!-- DASHBOARD TAB -->
<section id="content-dashboard" class="tab-content space-y-6">
<!-- Metrics Overview Grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4">
<div class="bg-white p-5 rounded-xl shadow-sm border border-slate-200 border-t-4 border-t-[#002D62]">
<div class="text-xs font-bold text-slate-400 uppercase tracking-wider">Total Active Courses</div>
<div class="text-3xl font-black text-[#002D62] mt-1" id="stat-total-courses">0</div>
<div class="text-xs text-slate-500 mt-1" id="stat-courses-breakdown">0 On-Ground / 0 Online</div>
</div>
<div class="bg-white p-5 rounded-xl shadow-sm border border-slate-200 border-t-4 border-t-[#E85E26]">
<div class="text-xs font-bold text-slate-400 uppercase tracking-wider">Faculty Roster</div>
<div class="text-3xl font-black text-[#002D62] mt-1" id="stat-total-faculty">0</div>
<div class="text-xs text-slate-500 mt-1">Active Professors</div>
</div>
<div class="bg-white p-5 rounded-xl shadow-sm border border-slate-200 border-t-4 border-t-[#002D62]">
<div class="text-xs font-bold text-slate-400 uppercase tracking-wider">Classrooms</div>
<div class="text-3xl font-black text-[#002D62] mt-1" id="stat-total-rooms">0</div>
<div class="text-xs text-slate-500 mt-1">Available Rooms</div>
</div>
<div class="bg-white p-5 rounded-xl shadow-sm border border-slate-200 border-t-4 border-t-[#E85E26]">
<div class="text-xs font-bold text-slate-400 uppercase tracking-wider">Modified Items</div>
<div class="text-3xl font-black text-[#E85E26] mt-1" id="stat-total-modified">0</div>
<div class="text-xs text-amber-700 font-semibold mt-1">Pending Excel Export</div>
</div>
<div class="bg-white p-5 rounded-xl shadow-sm border border-slate-200 border-t-4 border-t-emerald-600">
<div class="text-xs font-bold text-slate-400 uppercase tracking-wider">Schedule Status</div>
<div class="text-2xl font-black text-amber-600 mt-1" id="stat-schedule-status">Pending</div>
<div class="text-xs text-slate-500 mt-1" id="stat-conflicts-count">0 Conflicts Detected</div>
</div>
</div>
<!-- Dashboard Upload Hero -->
<div class="bg-gradient-to-br from-[#002D62] via-[#001D42] to-[#0A3C7D] rounded-2xl shadow-lg p-6 md:p-8 text-white relative overflow-hidden border-l-8 border-[#E85E26]">
<div class="relative z-10 max-w-4xl">
<span class="inline-block bg-[#E85E26] text-white text-xs font-bold uppercase tracking-wider px-3 py-1 rounded-full mb-3 shadow">
Workflow Stage 1, 2 & 3
</span>
<h2 class="text-2xl md:text-3xl font-extrabold tracking-tight">Schedule & Saved Changes Management</h2>
<p class="text-slate-200 text-sm md:text-base mt-2 leading-relaxed">
Import your previous term schedule spreadsheet, upload your updated faculty roster, and apply any saved change files (<code class="bg-black/30 px-1.5 py-0.5 rounded text-amber-300">.xlsx</code>) to resume editing at any time.
</p>
<!-- File Drop / Upload Grid -->
<div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
<label class="bg-white/10 hover:bg-white/20 border-2 border-dashed border-amber-400/50 hover:border-amber-400 rounded-xl p-4 cursor-pointer transition flex items-center space-x-3 text-left group">
<i class="fa-solid fa-file-excel text-3xl text-emerald-400 group-hover:scale-110 transition"></i>
<div>
<p class="text-sm font-bold text-white">1. Load Semester Schedule (.xlsx)</p>
<p class="text-xs text-slate-300">Import Banner schedule roll export</p>
</div>
<input type="file" accept=".xlsx, .xls" class="hidden" onchange="importMasterScheduleFile(event)">
</label>
<label class="bg-white/10 hover:bg-white/20 border-2 border-dashed border-amber-400/50 hover:border-amber-400 rounded-xl p-4 cursor-pointer transition flex items-center space-x-3 text-left group">
<i class="fa-solid fa-user-graduate text-3xl text-sky-400 group-hover:scale-110 transition"></i>
<div>
<p class="text-sm font-bold text-white">2. Load Faculty Roster (.xlsx, .csv)</p>
<p class="text-xs text-slate-300">Import faculty list & Banner IDs</p>
</div>
<input type="file" accept=".xlsx, .xls, .csv" class="hidden" onchange="importFacultyFile(event)">
</label>
<label class="bg-white/10 hover:bg-white/20 border-2 border-dashed border-amber-400/50 hover:border-amber-400 rounded-xl p-4 cursor-pointer transition flex items-center space-x-3 text-left group">
<i class="fa-solid fa-file-import text-3xl text-amber-400 group-hover:scale-110 transition"></i>
<div>
<p class="text-sm font-bold text-white">3. Load Saved Changes (.xlsx)</p>
<p class="text-xs text-slate-300">Resume editing from previous session</p>
</div>
<input type="file" accept=".xlsx, .xls" class="hidden" onchange="importChangesFile(event)">
</label>
</div>
<div class="mt-4 flex flex-wrap gap-2 justify-end">
<button onclick="loadSampleData()" class="bg-white/10 hover:bg-white/20 text-white border border-white/30 font-semibold px-4 py-2 rounded-xl text-xs transition flex items-center space-x-2">
<i class="fa-solid fa-rotate-left text-amber-300"></i>
<span>Reset / Load Sample</span>
</button>
<button onclick="exportModifiedExcel()" class="bg-[#E85E26] hover:bg-[#d14f1d] text-white font-bold px-4 py-2 rounded-xl text-xs transition shadow flex items-center space-x-2">
<i class="fa-solid fa-file-export"></i>
<span>Export Changes (.xlsx)</span>
</button>
</div>
</div>
</div>
<!-- Dashboard Recent Activity -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6">
<div class="flex justify-between items-center mb-4">
<div>
<h3 class="font-extrabold text-[#002D62] text-lg">Modified Schedule Log</h3>
<p class="text-xs text-slate-500">Items updated or deleted in this session that will be exported to your custom changes spreadsheet.</p>
</div>
<button onclick="exportModifiedExcel()" class="bg-[#E85E26] hover:bg-[#d14f1d] text-white font-bold text-xs px-3 py-1.5 rounded shadow">
Export Highlighted Excel
</button>
</div>
<div id="modified-log-container" class="divide-y divide-slate-100 max-h-60 overflow-y-auto">
<p class="text-xs text-slate-400 italic py-4 text-center">No modifications recorded yet. Make edits in the Course Catalog to track changes here.</p>
</div>
</div>
</section>
<!-- COURSE CATALOG TAB -->
<section id="content-courses" class="tab-content hidden space-y-6">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<h2 class="text-2xl font-black text-[#002D62]">Course Catalog</h2>
<p class="text-xs text-slate-500">Filter courses by major code, manage capacity, edit details, or upload new templates.</p>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="bg-emerald-600 hover:bg-emerald-700 text-white font-semibold px-3 py-2 rounded-lg shadow text-xs cursor-pointer flex items-center space-x-2 transition">
<i class="fa-solid fa-file-excel"></i>
<span>Upload Schedule (.xlsx)</span>
<input type="file" accept=".xlsx, .xls" class="hidden" onchange="importMasterScheduleFile(event)">
</label>
<label class="bg-amber-600 hover:bg-amber-700 text-white font-semibold px-3 py-2 rounded-lg shadow text-xs cursor-pointer flex items-center space-x-2 transition">
<i class="fa-solid fa-file-import"></i>
<span>Load Changes (.xlsx)</span>
<input type="file" accept=".xlsx, .xls" class="hidden" onchange="importChangesFile(event)">
</label>
<button onclick="openCourseModal()" class="bg-[#002D62] hover:bg-[#001D42] text-white font-semibold px-3 py-2 rounded-lg shadow text-xs flex items-center space-x-2 transition">
<i class="fa-solid fa-plus"></i><span>Add Course</span>
</button>
</div>
</div>
<!-- Major Code & Search Filter Bar -->
<div class="bg-white p-4 rounded-xl shadow-sm border border-slate-200 flex flex-col md:flex-row gap-4 items-center justify-between">
<div class="flex flex-col sm:flex-row items-center gap-3 w-full md:w-auto">
<div class="w-full sm:w-64">
<label class="block text-[10px] font-extrabold uppercase text-[#002D62] mb-1">Filter by Major Code</label>
<select id="course-filter-major" onchange="filterCourseCatalog()" class="w-full bg-slate-50 border border-slate-300 font-semibold text-slate-800 text-sm rounded-lg px-3 py-2 focus:ring-2 focus:ring-[#E85E26] outline-none">
<option value="ALL">All Majors / Subjects</option>
</select>
</div>
<div class="w-full sm:w-48">
<label class="block text-[10px] font-extrabold uppercase text-[#002D62] mb-1">Modality</label>
<select id="course-filter-modality" onchange="filterCourseCatalog()" class="w-full bg-slate-50 border border-slate-300 font-semibold text-slate-800 text-sm rounded-lg px-3 py-2 focus:ring-2 focus:ring-[#E85E26] outline-none">
<option value="ALL">All Modalities</option>
<option value="GRND">On-Ground (GRND)</option>
<option value="DIST">Online (DIST)</option>
</select>
</div>
</div>
<div class="w-full md:w-72">
<label class="block text-[10px] font-extrabold uppercase text-[#002D62] mb-1">Search Courses</label>
<div class="relative">
<i class="fa-solid fa-magnifying-glass absolute left-3 top-2.5 text-slate-400 text-sm"></i>
<input type="text" id="course-filter-search" oninput="filterCourseCatalog()" placeholder="Search title, CRN, code..." class="w-full bg-slate-50 border border-slate-300 text-sm rounded-lg pl-9 pr-3 py-1.5 focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
</div>
</div>
<!-- Course Catalog Table -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
<div class="px-4 py-2 bg-slate-50 border-b border-slate-200 flex justify-between items-center text-xs text-slate-500">
<span id="course-filter-count">Showing 0 courses</span>
<span class="text-slate-400">Items highlighted with badge have unsaved changes for export</span>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse min-w-[900px]">
<thead>
<tr class="bg-[#002D62] text-white text-xs font-bold uppercase tracking-wider">
<th class="p-3.5">CRN / Code</th>
<th class="p-3.5">Course Title</th>
<th class="p-3.5">Sec</th>
<th class="p-3.5">Max Seats</th>
<th class="p-3.5">Modality</th>
<th class="p-3.5">Timeslot</th>
<th class="p-3.5">Room</th>
<th class="p-3.5">Instructor</th>
<th class="p-3.5">Status</th>
<th class="p-3.5 text-right">Actions</th>
</tr>
</thead>
<tbody id="course-table-body" class="divide-y divide-slate-200 text-sm">
<!-- Populated dynamically -->
</tbody>
</table>
</div>
</div>
</section>
<!-- FACULTY TAB -->
<section id="content-faculty" class="tab-content hidden space-y-6">
<div class="flex justify-between items-center">
<div>
<h2 class="text-2xl font-black text-[#002D62]">Faculty Roster</h2>
<p class="text-xs text-slate-500">Manage instructors, max teaching loads, and course assignments.</p>
</div>
<div class="flex space-x-2">
<label class="bg-emerald-600 hover:bg-emerald-700 text-white font-semibold px-3 py-2 rounded-lg shadow text-xs cursor-pointer flex items-center space-x-2 transition">
<i class="fa-solid fa-file-excel"></i>
<span>Import Roster</span>
<input type="file" id="faculty-file-input" accept=".xlsx, .xls, .csv" class="hidden" onchange="importFacultyFile(event)">
</label>
<button onclick="openFacultyModal()" class="bg-[#002D62] hover:bg-[#001D42] text-white font-semibold px-3 py-2 rounded-lg shadow text-xs flex items-center space-x-2 transition">
<i class="fa-solid fa-plus"></i><span>Add Faculty</span>
</button>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-[#002D62] text-white text-xs font-bold uppercase tracking-wider">
<th class="p-3.5">Banner ID</th>
<th class="p-3.5">Faculty Name</th>
<th class="p-3.5">Max Course Load</th>
<th class="p-3.5">Assigned Courses</th>
<th class="p-3.5 text-right">Actions</th>
</tr>
</thead>
<tbody id="faculty-table-body" class="divide-y divide-slate-200 text-sm">
<!-- Populated dynamically -->
</tbody>
</table>
</div>
</section>
<!-- CLASSROOMS TAB -->
<section id="content-rooms" class="tab-content hidden space-y-6">
<div class="flex justify-between items-center">
<div>
<h2 class="text-2xl font-black text-[#002D62]">Classroom Management</h2>
<p class="text-xs text-slate-500">Campus buildings, room capacities, and physical room types.</p>
</div>
<button onclick="openRoomModal()" class="bg-[#002D62] hover:bg-[#001D42] text-white font-semibold px-3 py-2 rounded-lg shadow text-xs flex items-center space-x-2 transition">
<i class="fa-solid fa-plus"></i><span>Add Room</span>
</button>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-[#002D62] text-white text-xs font-bold uppercase tracking-wider">
<th class="p-3.5">Building & Room</th>
<th class="p-3.5">Seating Capacity</th>
<th class="p-3.5">Room Type</th>
<th class="p-3.5 text-right">Actions</th>
</tr>
</thead>
<tbody id="room-table-body" class="divide-y divide-slate-200 text-sm">
<!-- Populated dynamically -->
</tbody>
</table>
</div>
</section>
<!-- TIMESLOTS TAB -->
<section id="content-timeslots" class="tab-content hidden space-y-6">
<div class="flex justify-between items-center">
<div>
<h2 class="text-2xl font-black text-[#002D62]">Standard Timeslots</h2>
<p class="text-xs text-slate-500">Configure default teaching blocks for MWF, MW, MF, and TR patterns.</p>
</div>
<button onclick="openTimeslotModal()" class="bg-[#002D62] hover:bg-[#001D42] text-white font-semibold px-3 py-2 rounded-lg shadow text-xs flex items-center space-x-2 transition">
<i class="fa-solid fa-plus"></i><span>Add Custom Timeslot</span>
</button>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
<!-- MWF Card -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5 border-t-4 border-t-[#002D62]">
<div class="flex items-center justify-between border-b pb-3 mb-4">
<h3 class="font-bold text-[#002D62] flex items-center space-x-2 text-sm">
<i class="fa-solid fa-calendar-day text-[#E85E26]"></i>
<span>Mon / Wed / Fri (MWF)</span>
</h3>
<span class="text-xs font-semibold px-2 py-0.5 bg-orange-50 text-[#E85E26] rounded">50 min</span>
</div>
<div id="timeslots-mwf-list" class="space-y-2"></div>
</div>
<!-- MW Card -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5 border-t-4 border-t-[#002D62]">
<div class="flex items-center justify-between border-b pb-3 mb-4">
<h3 class="font-bold text-[#002D62] flex items-center space-x-2 text-sm">
<i class="fa-solid fa-calendar-day text-[#E85E26]"></i>
<span>Mon / Wed (MW)</span>
</h3>
<span class="text-xs font-semibold px-2 py-0.5 bg-orange-50 text-[#E85E26] rounded">75 min</span>
</div>
<div id="timeslots-mw-list" class="space-y-2"></div>
</div>
<!-- MF Card -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5 border-t-4 border-t-[#002D62]">
<div class="flex items-center justify-between border-b pb-3 mb-4">
<h3 class="font-bold text-[#002D62] flex items-center space-x-2 text-sm">
<i class="fa-solid fa-calendar-day text-[#E85E26]"></i>
<span>Mon / Fri (MF)</span>
</h3>
<span class="text-xs font-semibold px-2 py-0.5 bg-orange-50 text-[#E85E26] rounded">75 min</span>
</div>
<div id="timeslots-mf-list" class="space-y-2"></div>
</div>
<!-- TR Card -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-5 border-t-4 border-t-[#002D62]">
<div class="flex items-center justify-between border-b pb-3 mb-4">
<h3 class="font-bold text-[#002D62] flex items-center space-x-2 text-sm">
<i class="fa-solid fa-calendar-day text-[#E85E26]"></i>
<span>Tue / Thu (TR)</span>
</h3>
<span class="text-xs font-semibold px-2 py-0.5 bg-orange-50 text-[#E85E26] rounded">75 min</span>
</div>
<div id="timeslots-tr-list" class="space-y-2"></div>
</div>
</div>
</section>
<!-- SCHEDULE VIEW TAB -->
<section id="content-schedule" class="tab-content hidden space-y-6">
<div class="flex justify-between items-center">
<div>
<h2 class="text-2xl font-black text-[#002D62]">Master Schedule Grid</h2>
<p class="text-xs text-slate-500">Visual layout of assigned courses across campus timeslots.</p>
</div>
<button onclick="exportToBannerCSV()" class="bg-emerald-600 hover:bg-emerald-700 text-white font-semibold px-3 py-2 rounded-lg shadow text-xs flex items-center space-x-2 transition">
<i class="fa-solid fa-download"></i><span>Download Banner CSV</span>
</button>
</div>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-x-auto p-4">
<table class="w-full text-center border-collapse min-w-[800px]">
<thead>
<tr class="bg-[#002D62] text-white text-xs uppercase font-bold">
<th class="p-3 border border-slate-700">Day Pattern</th>
<th class="p-3 border border-slate-700">Time Block</th>
<th class="p-3 border border-slate-700">Scheduled Course & Room</th>
<th class="p-3 border border-slate-700">Assigned Instructor</th>
</tr>
</thead>
<tbody id="schedule-grid-body" class="text-sm divide-y divide-slate-200">
<!-- Generated dynamically -->
</tbody>
</table>
</div>
</section>
</main>
<!-- MODALS -->
<!-- Faculty Modal -->
<div id="faculty-modal" class="fixed inset-0 bg-slate-900/60 backdrop-blur-sm hidden flex justify-center items-center z-50">
<div class="bg-white rounded-xl shadow-2xl w-full max-w-md p-6 border-t-4 border-[#E85E26]">
<h3 class="text-lg font-extrabold text-[#002D62] mb-4" id="faculty-modal-title">Add Faculty Member</h3>
<form onsubmit="saveFaculty(event)" class="space-y-4">
<input type="hidden" id="faculty-id">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Banner ID</label>
<input type="text" id="faculty-banner-id" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">First Name</label>
<input type="text" id="faculty-first-name" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Last Name</label>
<input type="text" id="faculty-last-name" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Max Courses Allowed</label>
<input type="number" id="faculty-max-courses" value="3" min="1" max="10" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" onclick="closeFacultyModal()" class="px-4 py-2 border border-slate-300 text-slate-600 rounded-lg text-sm font-semibold hover:bg-slate-50">Cancel</button>
<button type="submit" class="px-4 py-2 bg-[#002D62] hover:bg-[#001D42] text-white rounded-lg text-sm font-semibold">Save Faculty</button>
</div>
</form>
</div>
</div>
<!-- Course Modal -->
<div id="course-modal" class="fixed inset-0 bg-slate-900/60 backdrop-blur-sm hidden flex justify-center items-center z-50">
<div class="bg-white rounded-xl shadow-2xl w-full max-w-lg p-6 border-t-4 border-[#E85E26]">
<h3 class="text-lg font-extrabold text-[#002D62] mb-4" id="course-modal-title">Add Course</h3>
<form onsubmit="saveCourse(event)" class="space-y-4">
<input type="hidden" id="course-id">
<div class="grid grid-cols-3 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Subject Code</label>
<input type="text" id="course-subj" placeholder="CYB" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none font-bold text-[#002D62]">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Crse#</label>
<input type="text" id="course-num" placeholder="101" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Section</label>
<input type="text" id="course-section" placeholder="A" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">CRN</label>
<input type="text" id="course-crn" placeholder="5236" class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Department</label>
<input type="text" id="course-dept" placeholder="Cybersecurity" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Course Title</label>
<input type="text" id="course-title" placeholder="Intro to Cybersecurity" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div class="grid grid-cols-3 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Max Seats</label>
<input type="number" id="course-max-seats" value="25" min="1" max="500" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Credit Hours</label>
<input type="number" id="course-credits" value="3" min="1" max="6" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Modality</label>
<select id="course-modality" class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none text-sm font-semibold">
<option value="GRND">On-Ground (GRND)</option>
<option value="DIST">Distance/Online (DIST)</option>
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Preferred Timeslot</label>
<select id="course-timeslot-select" class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none text-sm">
<!-- Populated dynamically -->
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Assigned Instructor</label>
<select id="course-instructor-select" class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none text-sm">
<!-- Populated dynamically -->
</select>
</div>
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" onclick="closeCourseModal()" class="px-4 py-2 border border-slate-300 text-slate-600 rounded-lg text-sm font-semibold hover:bg-slate-50">Cancel</button>
<button type="submit" class="px-4 py-2 bg-[#E85E26] hover:bg-[#d14f1d] text-white rounded-lg text-sm font-bold shadow">Save & Flag Changed</button>
</div>
</form>
</div>
</div>
<!-- Room Modal -->
<div id="room-modal" class="fixed inset-0 bg-slate-900/60 backdrop-blur-sm hidden flex justify-center items-center z-50">
<div class="bg-white rounded-xl shadow-2xl w-full max-w-md p-6 border-t-4 border-[#E85E26]">
<h3 class="text-lg font-extrabold text-[#002D62] mb-4">Add Classroom</h3>
<form onsubmit="saveRoom(event)" class="space-y-4">
<input type="hidden" id="room-id">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Building & Room Code</label>
<input type="text" id="room-name" placeholder="ECJS214" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Capacity</label>
<input type="number" id="room-capacity" value="30" min="1" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Type</label>
<select id="room-type" class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
<option value="Lecture">Lecture</option>
<option value="Lab">Computer Lab</option>
<option value="Seminar">Seminar</option>
</select>
</div>
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" onclick="closeRoomModal()" class="px-4 py-2 border border-slate-300 text-slate-600 rounded-lg text-sm font-semibold hover:bg-slate-50">Cancel</button>
<button type="submit" class="px-4 py-2 bg-[#002D62] hover:bg-[#001D42] text-white rounded-lg text-sm font-semibold">Save Room</button>
</div>
</form>
</div>
</div>
<!-- Timeslot Modal -->
<div id="timeslot-modal" class="fixed inset-0 bg-slate-900/60 backdrop-blur-sm hidden flex justify-center items-center z-50">
<div class="bg-white rounded-xl shadow-2xl w-full max-w-md p-6 border-t-4 border-[#E85E26]">
<h3 class="text-lg font-extrabold text-[#002D62] mb-4">Add Custom Timeslot</h3>
<form onsubmit="saveTimeslot(event)" class="space-y-4">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Day Pattern</label>
<select id="ts-days" class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
<option value="MWF">Monday Wednesday Friday (MWF)</option>
<option value="MW">Monday Wednesday (MW)</option>
<option value="MF">Monday Friday (MF)</option>
<option value="TR">Tuesday Thursday (TR)</option>
<option value="M">Monday (M)</option>
<option value="T">Tuesday (T)</option>
<option value="W">Wednesday (W)</option>
<option value="R">Thursday (R)</option>
<option value="F">Friday (F)</option>
</select>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">Start Time (24h)</label>
<input type="time" id="ts-start" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
<div>
<label class="block text-xs font-bold text-slate-600 uppercase mb-1">End Time (24h)</label>
<input type="time" id="ts-end" required class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-[#E85E26] outline-none">
</div>
</div>
<div class="flex justify-end space-x-3 pt-4 border-t">
<button type="button" onclick="closeTimeslotModal()" class="px-4 py-2 border border-slate-300 text-slate-600 rounded-lg text-sm font-semibold hover:bg-slate-50">Cancel</button>
<button type="submit" class="px-4 py-2 bg-[#002D62] hover:bg-[#001D42] text-white rounded-lg text-sm font-semibold">Save Timeslot</button>
</div>
</form>
</div>
</div>
<!-- JAVASCRIPT APPLICATION LOGIC -->
<script>
// --- INITIAL STATE ---
let timeslots = [
{ id: 'ts-mwf-1', days: 'MWF', start: '08:30', end: '09:20' },
{ id: 'ts-mwf-2', days: 'MWF', start: '09:30', end: '10:20' },
{ id: 'ts-mwf-3', days: 'MWF', start: '10:30', end: '11:20' },
{ id: 'ts-mwf-4', days: 'MWF', start: '11:30', end: '12:20' },
{ id: 'ts-mw-1', days: 'MW', start: '08:30', end: '09:45' },
{ id: 'ts-mw-2', days: 'MW', start: '10:00', end: '11:15' },
{ id: 'ts-mw-3', days: 'MW', start: '13:00', end: '14:15' },
{ id: 'ts-mw-4', days: 'MW', start: '14:30', end: '15:45' },
{ id: 'ts-mf-1', days: 'MF', start: '12:30', end: '13:45' },
{ id: 'ts-mf-2', days: 'MF', start: '14:00', end: '15:15' },
{ id: 'ts-mf-3', days: 'MF', start: '15:30', end: '16:45' },
{ id: 'ts-tr-1', days: 'TR', start: '08:30', end: '09:45' },
{ id: 'ts-tr-2', days: 'TR', start: '10:00', end: '11:15' },
{ id: 'ts-tr-3', days: 'TR', start: '11:30', end: '12:45' },
{ id: 'ts-tr-4', days: 'TR', start: '13:00', end: '14:15' },
{ id: 'ts-tr-5', days: 'TR', start: '14:30', end: '15:45' },
{ id: 'ts-tr-6', days: 'TR', start: '16:00', end: '17:15' }
];
let facultyList = [];
let roomList = [];
let courseList = [];
// --- APP INITIALIZATION ---
document.addEventListener('DOMContentLoaded', () => {
renderTimeslots();
loadSampleData();
});
// --- TAB NAVIGATION ---
function switchTab(tabName) {
document.querySelectorAll('.tab-content').forEach(el => el.classList.add('hidden'));
document.querySelectorAll('.tab-btn').forEach(el => {
el.classList.remove('border-[#E85E26]', 'text-[#002D62]', 'font-bold');
el.classList.add('border-transparent', 'text-slate-500');
});
document.getElementById(`content-${tabName}`).classList.remove('hidden');
const activeBtn = document.getElementById(`tab-${tabName}`);
activeBtn.classList.remove('border-transparent', 'text-slate-500');
activeBtn.classList.add('border-[#E85E26]', 'text-[#002D62]', 'font-bold');
if (tabName === 'schedule') renderScheduleGrid();
}
// --- SAMPLE DATA LOAD ---
function loadSampleData() {
facultyList = [
{ id: 'f1', bannerId: '2588', firstName: 'Lawrence', lastName: 'Aaronson', maxCourses: 3 },
{ id: 'f2', bannerId: '3469', firstName: 'Claudette', lastName: 'Abounader', maxCourses: 3 },
{ id: 'f3', bannerId: '334398', firstName: 'Timothy', lastName: 'Abraham', maxCourses: 2 },
{ id: 'f4', bannerId: '296782', firstName: 'Joseph', lastName: 'Adamo', maxCourses: 3 }
];
roomList = [
{ id: 'r1', name: 'FAC101', capacity: 40, type: 'Lecture' },
{ id: 'r2', name: 'HUBBAR108', capacity: 32, type: 'Lecture' },
{ id: 'r3', name: 'ECJS210', capacity: 24, type: 'Lab' }
];
courseList = [
{
id: 'c1',
crn: '1253',
subj: 'ACC',
num: '201',
section: 'B',
dept: 'Accounting',
title: 'Financial Accounting',
maxSeats: 30,
credits: 3,
modality: 'GRND',
timeslotId: 'ts-tr-3',
assignedRoomId: 'r1',
assignedFacultyId: 'f1',
isModified: false,
isLoaded: true,
isDeleted: false
},
{
id: 'c2',
crn: '3087',
subj: 'ACC',
num: '202',
section: 'Z1',
dept: 'Accounting',
title: 'Managerial Accounting',
maxSeats: 29,
credits: 3,
modality: 'DIST',
timeslotId: '',
assignedRoomId: '',
assignedFacultyId: 'f2',
isModified: false,
isLoaded: true,
isDeleted: false
},
{
id: 'c3',
crn: '8841',
subj: 'CYB',
num: '101',
section: 'A',
dept: 'Cybersecurity',
title: 'Introduction to Cybersecurity',
maxSeats: 25,
credits: 3,
modality: 'GRND',
timeslotId: 'ts-mwf-2',
assignedRoomId: 'r3',
assignedFacultyId: 'f4',
isModified: false,
isLoaded: true,
isDeleted: false
},
{
id: 'c4',
crn: '8842',
subj: 'CYB',
num: '333',
section: 'Z1',
dept: 'Cybersecurity',
title: 'Information Assurance',
maxSeats: 20,
credits: 3,
modality: 'DIST',
timeslotId: '',
assignedRoomId: '',
assignedFacultyId: 'f4',
isModified: false,
isLoaded: true,
isDeleted: false
}
];
populateMajorFilterOptions();
renderFacultyTable();
renderRoomTable();
filterCourseCatalog();
updateDashboardStats();
renderModifiedLog();
}
// --- MASTER SCHEDULE SPREADSHEET PARSER ---
function importMasterScheduleFile(e) {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(evt) {
try {
const data = new Uint8Array(evt.target.result);
const workbook = XLSX.read(data, { type: 'array' });
let targetSheetName = workbook.SheetNames.includes('ALL 202710') ? 'ALL 202710' : workbook.SheetNames[0];
let worksheet = workbook.Sheets[targetSheetName];
const json = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
if (json.length < 2) {
alert("The uploaded spreadsheet appears to be empty or formatted incorrectly.");
return;
}
let headerRowIdx = 0;
for (let i = 0; i < Math.min(json.length, 10); i++) {
const rowStr = JSON.stringify(json[i] || []);
if (rowStr.includes('CRN') && (rowStr.includes('Subj') || rowStr.includes('Subject'))) {
headerRowIdx = i;
break;
}
}
const headers = json[headerRowIdx];
const crnIdx = headers.findIndex(h => h && h.toString().trim() === 'CRN');
const deptIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase() === 'dept');
const subjIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase() === 'subj');
const crseNumIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('crse'));
const sectionIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase() === 'section');
const titleIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase() === 'title');
const maxSeatsIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('max seats'));
const creditsIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('credit hours'));
const modalityAttrIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('modality(attribute)'));
const meetDaysIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('meet days'));
const meetBeginIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('meet begin time'));
const meetEndIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('meet end time'));
const meetRoomIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('meet building and room'));
const instructorIdx = headers.findIndex(h => h && h.toString().trim().toLowerCase().includes('instructor'));
let importedCoursesCount = 0;
courseList = [];
for (let i = headerRowIdx + 1; i < json.length; i++) {
const row = json[i];
if (!row || row.length === 0) continue;
const subj = subjIdx !== -1 ? String(row[subjIdx] || '').trim() : '';
const crseNum = crseNumIdx !== -1 ? String(row[crseNumIdx] || '').trim() : '';
if (!subj || !crseNum) continue;
const crn = crnIdx !== -1 ? String(row[crnIdx] || '').trim() : '';
const dept = deptIdx !== -1 ? String(row[deptIdx] || '').trim() : 'General';
const section = sectionIdx !== -1 ? String(row[sectionIdx] || '').trim() : 'A';
const title = titleIdx !== -1 ? String(row[titleIdx] || '').trim() : 'Untitled Course';
const maxSeats = maxSeatsIdx !== -1 ? parseInt(row[maxSeatsIdx], 10) || 25 : 25;
const credits = creditsIdx !== -1 ? parseInt(row[creditsIdx], 10) || 3 : 3;
const modalityAttr = modalityAttrIdx !== -1 ? String(row[modalityAttrIdx] || '').trim() : 'GRND';
const modality = (modalityAttr.includes('DIST') || modalityAttr.includes('OL')) ? 'DIST' : 'GRND';
const roomName = meetRoomIdx !== -1 ? String(row[meetRoomIdx] || '').trim() : '';
const meetDays = meetDaysIdx !== -1 ? String(row[meetDaysIdx] || '').trim() : '';
const meetBegin = meetBeginIdx !== -1 ? String(row[meetBeginIdx] || '').trim() : '';
const meetEnd = meetEndIdx !== -1 ? String(row[meetEndIdx] || '').trim() : '';
const rawInstructor = instructorIdx !== -1 ? String(row[instructorIdx] || '').trim() : '';
let assignedFacultyId = '';
if (rawInstructor && rawInstructor !== '-' && rawInstructor !== ' - ') {
let cleanName = rawInstructor.replace('*', '').trim();
let facObj = facultyList.find(f => `${f.lastName}, ${f.firstName}`.toLowerCase() === cleanName.toLowerCase());
if (!facObj) {
let parts = cleanName.split(',');
let lastName = parts[0] ? parts[0].trim() : cleanName;
let firstName = parts[1] ? parts[1].trim() : '';
const newFacId = 'f_' + Date.now() + '_' + Math.floor(Math.random() * 1000);
facObj = {
id: newFacId,
bannerId: 'P' + Math.floor(100000 + Math.random() * 900000),
firstName,
lastName,
maxCourses: 3
};
facultyList.push(facObj);
}
assignedFacultyId = facObj.id;
}
let assignedRoomId = '';
if (roomName && roomName !== 'ONLINE') {
let existingRoom = roomList.find(r => r.name.toLowerCase() === roomName.toLowerCase());
if (!existingRoom) {
const newRoomId = 'r_' + Date.now() + '_' + Math.floor(Math.random() * 1000);
existingRoom = {
id: newRoomId,
name: roomName,
capacity: maxSeats + 5,
type: 'Lecture'
};
roomList.push(existingRoom);
}
assignedRoomId = existingRoom.id;
}
let matchedTimeslotId = '';
if (meetDays && meetBegin) {
let cleanBegin = convertTo24Hour(meetBegin);
let cleanEnd = convertTo24Hour(meetEnd);
let foundTs = timeslots.find(t => t.days === meetDays && t.start === cleanBegin);
if (foundTs) {
matchedTimeslotId = foundTs.id;
} else if (cleanBegin) {
const newTsId = 'ts_' + Date.now() + '_' + Math.floor(Math.random() * 1000);
timeslots.push({
id: newTsId,
days: meetDays,
start: cleanBegin,
end: cleanEnd || '09:45'
});
matchedTimeslotId = newTsId;
}
}
courseList.push({
id: 'c_' + Date.now() + '_' + importedCoursesCount,
crn,
subj,
num: crseNum,
section,
dept,
title,
maxSeats,
credits,
modality,
timeslotId: matchedTimeslotId,
assignedRoomId: modality === 'DIST' ? '' : assignedRoomId,
assignedFacultyId,
isModified: false,
isLoaded: true,
isDeleted: false
});
importedCoursesCount++;
}
populateMajorFilterOptions();
filterCourseCatalog();
renderFacultyTable();
renderRoomTable();
renderTimeslots();
updateDashboardStats();
renderModifiedLog();
alert(`Successfully imported ${importedCoursesCount} courses from previous semester Excel spreadsheet!`);
} catch (err) {
console.error(err);
alert("Error parsing spreadsheet file. Please verify it matches the standard Banner export format.");
}
};
e.target.value = '';
reader.readAsArrayBuffer(file);
}
// --- IMPORT SAVED CHANGES (.XLSX) ---
function importChangesFile(e) {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(evt) {
try {
const data = new Uint8Array(evt.target.result);
const workbook = XLSX.read(data, { type: 'array' });
let targetSheetName = workbook.SheetNames.includes('Modified Items') ? 'Modified Items' : workbook.SheetNames[0];
let worksheet = workbook.Sheets[targetSheetName];
const json = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
if (json.length < 2) {
alert("The uploaded change file appears to be empty or missing headers.");
return;
}
let headerRowIdx = 0;
for (let i = 0; i < Math.min(json.length, 10); i++) {
const rowStr = JSON.stringify(json[i] || []);
if (rowStr.includes('CRN') || rowStr.includes('Subject') || rowStr.includes('Course Num')) {
headerRowIdx = i;
break;
}
}
const headers = json[headerRowIdx].map(h => String(h || '').trim().toLowerCase());
const crnIdx = headers.findIndex(h => h === 'crn');
const subjIdx = headers.findIndex(h => h.includes('subject') || h === 'subj');
const numIdx = headers.findIndex(h => h.includes('course num') || h.includes('crse') || h === 'num');
const secIdx = headers.findIndex(h => h.includes('section') || h === 'sec');
const titleIdx = headers.findIndex(h => h.includes('title'));
const deptIdx = headers.findIndex(h => h.includes('department') || h === 'dept');
const modalityIdx = headers.findIndex(h => h.includes('modality'));
const maxSeatsIdx = headers.findIndex(h => h.includes('max seats'));
const creditsIdx = headers.findIndex(h => h.includes('credits') || h.includes('credit hours'));
const instructorIdx = headers.findIndex(h => h.includes('instructor'));
const roomIdx = headers.findIndex(h => h.includes('room') || h.includes('building'));
const daysIdx = headers.findIndex(h => h.includes('meeting days') || h.includes('meet days') || h === 'days');
const startIdx = headers.findIndex(h => h.includes('start time') || h.includes('meet begin'));
const endIdx = headers.findIndex(h => h.includes('end time') || h.includes('meet end'));
const changeStatusIdx = headers.findIndex(h => h.includes('change status') || h.includes('status'));
let updatedCount = 0;
let newAddedCount = 0;
for (let i = headerRowIdx + 1; i < json.length; i++) {
const row = json[i];
if (!row || row.length === 0) continue;
const crn = crnIdx !== -1 ? String(row[crnIdx] || '').trim() : '';
const subj = subjIdx !== -1 ? String(row[subjIdx] || '').trim().toUpperCase() : '';
const num = numIdx !== -1 ? String(row[numIdx] || '').trim() : '';
const section = secIdx !== -1 ? String(row[secIdx] || '').trim().toUpperCase() : 'A';
const changeStatus = changeStatusIdx !== -1 ? String(row[changeStatusIdx] || '').trim().toUpperCase() : '';
const isDeletedInFile = changeStatus.includes('DELETE');
if (!subj && !num && !crn) continue;
const title = titleIdx !== -1 ? String(row[titleIdx] || '').trim() : 'Untitled Course';
const dept = deptIdx !== -1 ? String(row[deptIdx] || '').trim() : 'General';
const modality = modalityIdx !== -1 ? (String(row[modalityIdx] || '').trim().toUpperCase().includes('DIST') ? 'DIST' : 'GRND') : 'GRND';
const maxSeats = maxSeatsIdx !== -1 ? parseInt(row[maxSeatsIdx], 10) || 25 : 25;
const credits = creditsIdx !== -1 ? parseInt(row[creditsIdx], 10) || 3 : 3;