forked from nisiya/MaristIDCP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent_helpers.php
852 lines (830 loc) · 33.3 KB
/
student_helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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
<?php
$debug = true;
#Deprecated. Just use header() to redirect to pages and start the session on every page.
function load($page = 'add_student.php', $stu_id = -1){
session_start();
header("Location: $page");
$_SESSION['stu_id'] = $stu_id;
$_SESSION['addedCourse'] = false;
exit();
}
function loadSearch($page = 'add_student.php', $stu_id = -1){
session_start();
header("Location: $page");
$_SESSION['stu_id'] = $stu_id;
exit();
}
# Adds a new student to a program
function add_new_student_record($dbc, $stu_id, $stu_tag, $stu_lname, $stu_fname, $stu_initial, $stu_start, $stu_edu_lvl, $stu_job_title, $stu_street, $stu_city, $stu_state, $stu_country, $stu_zip, $stu_phone, $stu_email_1, $stu_email_2, $stu_dob, $stu_ethnicity, $stu_gender, $stu_citizen, $stu_transcript, $stu_comment, $stu_qualify_exam, $emp_id) {
$query = 'INSERT INTO STUDENT(STU_ID, STU_TAG, STU_LNAME, STU_FNAME, STU_INITIAL, STU_START, STU_EDU_LVL, STU_JOB_TITLE, STU_STREET, STU_CITY, STU_STATE, STU_COUNTRY, STU_ZIP, STU_PHONE, STU_EMAIL_1, STU_EMAIL_2, STU_DOB, STU_ETHNICITY, STU_GENDER, STU_CITIZEN, STU_TRANSCRIPT, STU_COMMENT, STU_QUALIFY_EXAM, EMP_ID) VALUES ('.$stu_id.' , "'.$stu_tag.'" , "'.$stu_lname.'" , "'.$stu_fname.'" , "'.$stu_initial.'" , "'.$stu_start.'" , "'.$stu_edu_lvl.'" , "'.$stu_job_title.'" , "'.$stu_street.'" , "'.$stu_city.'" , "'.$stu_state.'" , "'.$stu_country.'" , "'.$stu_zip.'" , "'.$stu_phone.'" , "'.$stu_email_1.'" , "'.$stu_email_2.'" , "'.$stu_dob.'" , "'.$stu_ethnicity.'" , "'.$stu_gender.'" , "'.$stu_citizen.'" , "'.$stu_transcript.'", "'.$stu_comment.'" , "'.$stu_qualify_exam.'", '.$emp_id.')' ;
show_query($query);
$results = mysqli_query($dbc,$query) ;
return $results ;
}
function add_new_prg_enrolled_record($dbc, $stu_id, $prg_id, $prg_enroll_start){
$query = 'INSERT INTO PRG_ENROLLED(STU_ID, PRG_ID, PRG_ENROLL_STATUS, PRG_ENROLL_START) VALUES ('.$stu_id.', '.$prg_id.', "Active", "'.$prg_enroll_start.'")';
// show_query($query);
$results = mysqli_query($dbc, $query);
return $results ;
}
function update_record($dbc, $stu_id, $stu_tag, $stu_lname, $stu_fname, $stu_initial, $stu_start, $stu_end, $stu_edu_lvl, $stu_job_title, $stu_street, $stu_city, $stu_state, $stu_country, $stu_zip, $stu_phone, $stu_email_1, $stu_email_2, $stu_dob, $stu_ethnicity, $stu_gender, $stu_citizen, $stu_transcript, $stu_comment, $stu_qualify_exam, $emp_id) {
$query = 'UPDATE STUDENT SET STU_TAG = "'.$stu_tag.'" , STU_LNAME = "'.$stu_lname.'" , STU_FNAME = "'.$stu_fname.'" , STU_INITIAL = "'.$stu_initial.'" , STU_START = "'.$stu_start.'" , STU_END = '. ($stu_end == NULL ? "NULL" : "'$stu_end'") .' , STU_EDU_LVL = "'.$stu_edu_lvl.'" , STU_JOB_TITLE = "'.$stu_job_title.'" , STU_STREET = "'.$stu_street.'" , STU_CITY = "'.$stu_city.'" , STU_STATE = "'.$stu_state.'" , STU_COUNTRY = "'.$stu_country.'" , STU_ZIP = "'.$stu_zip.'" , STU_PHONE = "'.$stu_phone.'" , STU_EMAIL_1 = "'.$stu_email_1.'" , STU_EMAIL_2 = "'.$stu_email_2.'" , STU_DOB = "'.$stu_dob.'" , STU_ETHNICITY = "'.$stu_ethnicity.'" , STU_GENDER = "'.$stu_gender.'" , STU_CITIZEN = "'.$stu_citizen.'" , STU_TRANSCRIPT = "'.$stu_transcript.'" , STU_COMMENT = "'.$stu_comment.'" , STU_QUALIFY_EXAM = "'.$stu_qualify_exam.'", EMP_ID = '.($emp_id == NULL ? "NULL" : $emp_id).' WHERE STU_ID = '.$stu_id;
// show_query($query);
$results = mysqli_query($dbc,$query) ;
// check_results($results) ;
return $results ;
}
function insert_record_crs_enrolled($dbc, $credit, $crs_enroll_start, $crs_id, $stu_id){
$query = 'INSERT INTO CRS_ENROLLED(CREDIT, CRS_ENROLL_STATUS, CRS_ENROLL_START, CRS_ID, STU_ID) VALUES ("'.$credit.'" , "Active" , "'.$crs_enroll_start.'" , "'.$crs_id.'" , '.$stu_id.')';
//show_query($query);
$results = mysqli_query($dbc,$query) ;
//check_results($results) ;
return $results ;
}
function insert_record_cert_earned($dbc, $stu_id, $cert_id, $mail_date, $earn_date){
$query = 'INSERT INTO CERT_EARNED(STU_ID, CERT_ID, MAIL_DATE, EARN_DATE) VALUES ("'.$stu_id.'", "'.$cert_id.'" , '. ($mail_date == NULL ? "NULL" : "'$mail_date'") .' , "'.$earn_date.'")';
//show_query($query);
$results = mysqli_query($dbc,$query) ;
//check_results($results) ;
return $results ;
}
function update_record_crs_enrolled($dbc, $credit, $grade, $crs_enroll_status, $crs_enroll_start, $crs_enroll_end, $crs_id, $stu_id, $crs_enroll_start_old){
// $query = 'UPDATE CRS_ENROLLED SET CREDIT = "'.$credit.'", CRS_ENROLL_STATUS = "'.$crs_enroll_status.'", GRADE = "'.$grade.'", CRS_ENROLL_START = "'.$crs_enroll_start.'", CRS_ENROLL_END = "'.$crs_enroll_end.'" WHERE CRS_ENROLL_START = "'.$crs_enroll_start_old.'" AND STU_ID = '.$stu_id.' AND CRS_ID = "'.$crs_id.'"';
$query = 'UPDATE CRS_ENROLLED SET CREDIT = "'.$credit.'", CRS_ENROLL_STATUS = "'.$crs_enroll_status.'", GRADE = "'.$grade.'", CRS_ENROLL_START = "'.$crs_enroll_start.'", CRS_ENROLL_END = '. ($crs_enroll_end == NULL ? "NULL" : "'$crs_enroll_end'") .' WHERE CRS_ENROLL_START = "'.$crs_enroll_start_old.'" AND STU_ID = '.$stu_id.' AND CRS_ID = "'.$crs_id.'"';
// show_query($query);
$results = mysqli_query($dbc,$query) ;
check_results($results) ;
return $results ;
}
function update_record_prg_enrolled($dbc, $enroll_status, $prg_enroll_start, $prg_enroll_end, $prg_id, $stu_id, $prg_enroll_start_old){
$query = 'UPDATE PRG_ENROLLED SET PRG_ENROLL_STATUS = "'.$enroll_status.'", PRG_ENROLL_START = "'.$prg_enroll_start.'", PRG_ENROLL_END = '. ($prg_enroll_end == NULL ? "NULL" : "'$prg_enroll_end'") .' WHERE PRG_ID = '.$prg_id.' AND PRG_ENROLL_START = "'.$prg_enroll_start_old.'" AND STU_ID = '.$stu_id;
// show_query($query);
$results = mysqli_query($dbc,$query) ;
check_results($results) ;
return $results ;
}
#Lists out the active courses for a student
function show_active_courses($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT * FROM CRS_ENROLLED, CRS_MADE_OF, PROGRAM, COURSE WHERE COURSE.CRS_ID = CRS_ENROLLED.CRS_ID AND CRS_MADE_OF.CRS_ID = CRS_ENROLLED.CRS_ID AND PROGRAM.PRG_ID = CRS_MADE_OF.PRG_ID AND CRS_ENROLL_STATUS = "Active" AND STU_ID = ' . $stu_id.' ORDER BY CRS_ENROLLED.CRS_ID';
// echo $query;
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>ID</TH>';
echo '<TH>Level</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Grade</TH>';
echo '<TH>Credit</TH>';
echo '<TH>Status</TH>';
echo '<TH>Program</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['CRS_ID'] . '</TD>' ;
echo '<TD>' . $row['CRS_LEVEL'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['GRADE'] . '</TD>' ;
echo '<TD>' . $row['CREDIT'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_STATUS'] . '</TD>' ;
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
# Free up the results in memory
mysqli_free_result( $results );
# DONT CLOSE CONNECTION YET!
mysqli_close( $dbc ) ;
}
function show_active_certificates($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = $query = 'SELECT CERT_NAME, EARN_DATE, MAIL_DATE FROM CERTIFICATE AS C, CERT_EARNED AS CE WHERE C.CERT_ID=CE.CERT_ID AND STU_ID='.$stu_id.' ORDER BY CERT_NAME';
// echo $query;
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>Certificate Name</TH>';
echo '<TH>Date Earned</TH>';
echo '<TH>Mail Date</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['CERT_NAME'] . '</TD>' ;
echo '<TD>' . $row['EARN_DATE'] . '</TD>' ;
echo '<TD>' . $row['MAIL_DATE'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
# Free up the results in memory
mysqli_free_result( $results );
# DONT CLOSE CONNECTION YET!
mysqli_close( $dbc ) ;
}
function show_completed_courses($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT * FROM CRS_ENROLLED, CRS_MADE_OF, PROGRAM, COURSE WHERE COURSE.CRS_ID = CRS_ENROLLED.CRS_ID AND CRS_MADE_OF.CRS_ID = CRS_ENROLLED.CRS_ID AND PROGRAM.PRG_ID = CRS_MADE_OF.PRG_ID AND CRS_ENROLL_STATUS = "Completed" AND STU_ID = ' . $stu_id.' ORDER BY CRS_ENROLLED.CRS_ID';
// echo $query;
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>ID</TH>';
echo '<TH>Level</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Grade</TH>';
echo '<TH>Credit</TH>';
echo '<TH>Status</TH>';
echo '<TH>Program</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['CRS_ID'] . '</TD>' ;
echo '<TD>' . $row['CRS_LEVEL'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['GRADE'] . '</TD>' ;
echo '<TD>' . $row['CREDIT'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_STATUS'] . '</TD>' ;
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
}
#Shows inactive courses of the student. These courses are probably dropped or failed.
function show_inactive_courses($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT * FROM CRS_ENROLLED, CRS_MADE_OF, PROGRAM, COURSE WHERE COURSE.CRS_ID = CRS_ENROLLED.CRS_ID AND CRS_MADE_OF.CRS_ID = CRS_ENROLLED.CRS_ID AND PROGRAM.PRG_ID = CRS_MADE_OF.PRG_ID AND CRS_ENROLL_STATUS <> "Active" AND CRS_ENROLL_STATUS <> "Completed" AND STU_ID = ' . $stu_id.' ORDER BY CRS_ENROLLED.CRS_ID';
// echo $query;
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>ID</TH>';
echo '<TH>Level</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Grade</TH>';
echo '<TH>Credit</TH>';
echo '<TH>Status</TH>';
echo '<TH>Program</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['CRS_ID'] . '</TD>' ;
echo '<TD>' . $row['CRS_LEVEL'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['GRADE'] . '</TD>' ;
echo '<TD>' . $row['CREDIT'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_STATUS'] . '</TD>' ;
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
}
# Shows courses student is enrolled in in a table. Used for while adding courses for a new student
function show_student_courses($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //connection is closed at end of this function, so need to reopen it every time
$query = 'SELECT * FROM CRS_ENROLLED WHERE STU_ID = ' . $stu_id;
$results = mysqli_query($dbc, $query);
check_results($results);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed">';
echo '<TR>';
echo '<TH>ID</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Grade</TH>';
echo '<TH>Credit</TH>';
echo '<TH>Status</TH>';
echo '</TR>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo '<TR>' ;
echo '<TD>' . $row['CRS_ID'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['GRADE'] . '</TD>' ;
echo '<TD>' . $row['CREDIT'] . '</TD>' ;
echo '<TD>' . $row['CRS_ENROLL_STATUS'] . '</TD>' ;
echo '</TR>';
}
echo '</TABLE>';
echo '</div>';
}
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
function show_active_programs($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT * FROM PRG_ENROLLED, PROGRAM WHERE PROGRAM.PRG_ID = PRG_ENROLLED.PRG_ID AND PRG_ENROLL_STATUS = "Active" AND STU_ID = ' . $stu_id. ' ORDER BY PRG_NAME';
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>Program Name</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Status</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_STATUS'] . '</TD>' ;
echo '</TR>';
// echo '<input type="hidden" name="CRS_ID" value="'.$row['CRS_ID'].'">';
// echo '</form>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
# Free up the results in memory
mysqli_free_result( $results );
# DONT CLOSE CONNECTION YET!
mysqli_close( $dbc ) ;
}
function show_completed_programs($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT * FROM PRG_ENROLLED, PROGRAM WHERE PROGRAM.PRG_ID = PRG_ENROLLED.PRG_ID AND PRG_ENROLL_STATUS = "Completed" AND STU_ID = ' . $stu_id.' ORDER BY PRG_NAME';
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>Program Name</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Status</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_STATUS'] . '</TD>' ;
echo '</TR>';
// echo '<input type="hidden" name="CRS_ID" value="'.$row['CRS_ID'].'">';
// echo '</form>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
#Shows inactive courses of the student. These courses are probably dropped or failed.
function show_inactive_programs($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT * FROM PRG_ENROLLED, PROGRAM WHERE PROGRAM.PRG_ID = PRG_ENROLLED.PRG_ID AND PRG_ENROLL_STATUS <> "Completed" AND PRG_ENROLL_STATUS <> "Active" AND STU_ID = ' . $stu_id.' ORDER BY PRG_NAME';
$results = mysqli_query($dbc, $query);
if($results){
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>Program Name</TH>';
echo '<TH>Enroll Date</TH>';
echo '<TH>Completion Date</TH>';
echo '<TH>Status</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) )
{
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_START'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_END'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_STATUS'] . '</TD>' ;
echo '</TR>';
// echo '<input type="hidden" name="CRS_ID" value="'.$row['CRS_ID'].'">';
// echo '</form>';
}
echo '</TBODY>';
echo '</TABLE>';
echo '</div>';
}
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
// function show_student_program_information($dbc, $stu_id){
// require( 'includes/connect_db_c9.php' ) ;
// $query = "SELECT * FROM PRG_ENROLLED WHERE STU_ID = $stu_id";
// $results = mysqli_query($dbc, $query);
// check_results($results);
// if($results){
// while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) ){
// $prg_id = $row['PRG_ID'];
// $query2 = "SELECT PRG_NAME FROM PROGRAM WHERE PRG_ID = $prg_id";
// $results2 = mysqli_query($dbc, $query2);
// $row2 = mysqli_fetch_array( $results2, MYSQLI_ASSOC);
// $prg_name = $row2['PRG_NAME'];
// echo '<h3>'.$prg_name.'</h3>';
// echo '<div class="d-flex flex-wrap">';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">Start Year</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo $row['PRG_ENROLL_YR_START'];
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">Start Month</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo month_num_to_name($row['PRG_ENROLL_MON_START']);
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">Start Day</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo $row['PRG_ENROLL_DAY_START'];
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">End Year</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo $row['PRG_ENROLL_YR_END'];
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">End Month</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo month_num_to_name($row['PRG_ENROLL_MON_END']);
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">End Day</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo $row['PRG_ENROLL_DAY_END'];
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '<div class = "panel panel-red" style="display: inline-block; margin:2px" >';
// echo '<div class = "panel-heading">';
// echo '<h3 class = "panel-title">Enrollment Status</h3>';
// echo '</div>';
// echo '<div class = "panel-body">';
// echo $row['PRG_ENROLL_STATUS'];
// echo '<a style="visibility: hidden">a</a>';
// echo '</div>';
// echo '</div>';
// echo '</div>';
// }
// }
// }
#Shows table with small part of all student info. Allows user to click on student to view their profile.
function show_brief_students($dbc){
$query = 'SELECT STU_ID, STU_TAG, STU_LNAME, STU_FNAME FROM STUDENT';
$results = mysqli_query($dbc, $query);
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>ID</TH>';
echo '<TH>Tag</TH>';
echo '<TH>Last Name</TH>';
echo '<TH>First Name</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
if($results){
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) ){
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['STU_ID'] . '</TD>' ;
echo '<TD>' . $row['STU_TAG'] . '</TD>' ;
echo '<TD>' . $row['STU_LNAME'] . '</TD>' ;
echo '<TD>' . $row['STU_FNAME'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
}
echo '</div>';
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
#Shows results of search
function show_brief_students_results($dbc, $string, $order){
$query = "SELECT STU_ID, STU_TAG, STU_LNAME, STU_FNAME FROM STUDENT WHERE STU_ID LIKE '%$string%' OR STU_LNAME LIKE '%$string%' OR STU_FNAME LIKE '%$string%'";
if($order == "Last Name"){
$query = $query . ' ORDER BY STU_LNAME ';
}
else if($order == "First Name"){
$query = $query . ' ORDER BY STU_FNAME ';
}
// show_query($query);
$results = mysqli_query($dbc, $query);
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed table-striped table-hover">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>ID</TH>';
echo '<TH>Tag</TH>';
echo '<TH>Last Name</TH>';
echo '<TH>First Name</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
if($results){
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) ){
echo "<TR class='clickable-row'>";
echo '<TD>' . $row['STU_ID'] . '</TD>' ;
echo '<TD>' . $row['STU_TAG'] . '</TD>' ;
echo '<TD>' . $row['STU_LNAME'] . '</TD>' ;
echo '<TD>' . $row['STU_FNAME'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
}
echo '</div>';
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
# Gets the id of the student
function get_student_id($dbc, $stu_name){
$query = "SELECT STU_ID FROM STUDENT WHERE STU_FNAME = '".$stu_name."'";
$results = mysqli_query($dbc,$query) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$stu_id = $row [ 'STU_ID' ] ;
return intval($stu_id) ;
}
# Gets the id of the course
function get_crs_id($dbc, $crs_name){
$query = "SELECT CRS_ID FROM COURSE WHERE CRS_NAME = '".$crs_name."'";
$results = mysqli_query($dbc,$query) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$crs_id = $row [ 'CRS_ID' ] ;
return $crs_id;
}
function get_emp_name($dbc, $emp_id){
$query = "SELECT EMP_NAME FROM EMPLOYER WHERE EMP_ID = $emp_id";
$results = mysqli_query($dbc,$query) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$emp_id= $row [ 'EMP_NAME' ] ;
return $emp_id;
}
}
# Gets the id of the employer
function get_employer_id($dbc, $emp_name){
$query = "SELECT EMP_ID FROM EMPLOYER WHERE EMP_NAME = '".$emp_name."'";
$results = mysqli_query($dbc,$query) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$emp_id = $row [ 'EMP_ID' ] ;
return intval($emp_id) ;
}
# Gets the full name of the student from the student ID
function get_stu_name($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT STU_FNAME, STU_LNAME FROM STUDENT WHERE STU_ID = $stu_id";
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$fname = $row [ 'STU_FNAME' ] ;
$lname = $row [ 'STU_LNAME' ] ;
$name = $fname . " " . $lname;
return $name;
}
else{
echo $stu_id;
}
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
#Gets the programs the student is in
function get_student_programs($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT * FROM PRG_ENROLLED, PROGRAM WHERE PROGRAM.PRG_ID = PRG_ENROLLED.PRG_ID AND STU_ID = $stu_id";
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
echo '<div class="span3" style="height: 200px !important; overflow: auto;">';
echo '<TABLE class="table table-condensed">';
echo '<THEAD>';
echo '<TR>';
echo '<TH>Program Name</TH>';
echo '<TH>Enrollment Status</TH>';
echo '<TH>Enrollment Date</TH>';
echo '</TR>';
echo '</THEAD>';
echo '<TBODY>';
if($results){
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) ){
echo '<TD>' . $row['PRG_NAME'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_STATUS'] . '</TD>' ;
echo '<TD>' . $row['PRG_ENROLL_START'] . '</TD>' ;
echo '</TR>';
}
echo '</TBODY>';
echo '</TABLE>';
}
echo '</div>';
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
# Gets the program name from program id
function get_prg_name($dbc, $prg_id){
require( 'includes/connect_db_c9.php' ) ;
$query = "SELECT PRG_NAME FROM PROGRAM WHERE PRG_ID = $prg_id";
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$name = $row [ 'PRG_NAME' ] ;
return $name;
}
else{
echo $prg_id;
}
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
# Gets the program name from program id
function get_prg_id($dbc, $prg_name){
require( 'includes/connect_db_c9.php' ) ;
$query = "SELECT PRG_ID FROM PROGRAM WHERE PRG_NAME = '$prg_name'";
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$id = $row [ 'PRG_ID' ] ;
return $id;
}
else{
echo $prg_id;
}
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
function get_stu_cert_earn_date($dbc, $stu_id, $cert_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT EARN_DATE FROM CERTIFICATE AS C, CERT_EARNED AS CE WHERE C.CERT_ID=CE.CERT_ID AND CE.STU_ID='.$stu_id.' AND CE.CERT_ID = '.$cert_id;
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$id = $row [ 'EARN_DATE' ] ;
return $id;
}
else{
echo 'nope';
}
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
function get_stu_cert_mail_date($dbc, $stu_id, $cert_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT MAIL_DATE FROM CERTIFICATE AS C, CERT_EARNED AS CE WHERE C.CERT_ID=CE.CERT_ID AND CE.STU_ID='.$stu_id.' AND CE.CERT_ID = '.$cert_id;
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$id = $row [ 'MAIL_DATE' ] ;
return $id;
}
else{
echo 'nope';
}
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
function get_stu_cert_id($dbc, $cert_name){
$query = "SELECT CERT_ID FROM CERTIFICATE WHERE CERT_NAME = '.$cert_name.'";
$results = mysqli_query($dbc, $query);
$row = mysqli_fetch_array( $results , MYSQLI_ASSOC );
$cert_id = $row['CERT_ID'];
return $cert_id;
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
function get_stu_cert_name($dbc, $stu_id, $cert_id){
require( 'includes/connect_db_c9.php' ) ;
$query = 'SELECT CERT_NAME FROM CERTIFICATE AS C, CERT_EARNED AS CE WHERE C.CERT_ID=CE.CERT_ID AND CE.STU_ID='.$stu_id.' AND CE.CERT_ID = '.$cert_id;
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$id = $row [ 'CERT_NAME' ] ;
return $id;
}
else{
echo 'nope';
}
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
function update_record_cert_earned($dbc, $stu_id, $cert_id, $mail_date, $earn_date) {
$query = 'UPDATE CERT_EARNED SET MAIL_DATE = '. ($mail_date == NULL ? "NULL" : "'$mail_date'").' , EARN_DATE = "'.$earn_date.'" WHERE STU_ID = '.$stu_id.' AND CERT_ID ='.$cert_id;
// show_query($query);
$results = mysqli_query($dbc,$query) ;
// check_results($results) ;
return $results ;
}
# Gets the course name from course id
function get_crs_name($dbc, $crs_id){
require( 'includes/connect_db_c9.php' ) ;
$query = "SELECT CRS_NAME FROM COURSE WHERE CRS_ID = '$crs_id'";
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
if($results){
$row = mysqli_fetch_array($results, MYSQLI_ASSOC);
$name = $row [ 'CRS_NAME' ] ;
return $name;
}
else{
echo $crs_id;
}
}
function get_stu_gender($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT STU_GENDER FROM STUDENT WHERE STU_ID = $stu_id";
//show_query($query) ;
$results = mysqli_query( $dbc, $query ) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$stu_gender = $row [ 'STU_GENDER' ] ;
return $stu_gender ;
}
function get_stu_start($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT STU_START FROM STUDENT WHERE STU_ID = $stu_id";
$results = mysqli_query( $dbc, $query ) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$stu_start = $row [ 'STU_START' ] ;
return $stu_start ;
}
function get_stu_yr_start($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT STU_YR_START FROM STUDENT WHERE STU_ID = $stu_id";
$results = mysqli_query( $dbc, $query ) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$stu_yr_start = $row [ 'STU_YR_START' ] ;
return $stu_yr_start ;
}
function get_stu_mon_start($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT STU_MON_START FROM STUDENT WHERE STU_ID = $stu_id";
$results = mysqli_query( $dbc, $query ) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$stu_yr_start = $row [ 'STU_MON_START' ] ;
return $stu_yr_start ;
}
function get_stu_day_start($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT STU_DAY_START FROM STUDENT WHERE STU_ID = $stu_id";
$results = mysqli_query( $dbc, $query ) ;
$row = mysqli_fetch_array($results, MYSQLI_ASSOC) ;
$stu_yr_start = $row [ 'STU_DAY_START' ] ;
return $stu_yr_start ;
}
#Shows 3 recent courses the student has taken/is in
function show_recent_student_courses($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT COURSE.CRS_ID, COURSE.CRS_NAME, CRS_ENROLLED.CRS_ENROLL_STATUS FROM CRS_ENROLLED, COURSE WHERE CRS_ENROLLED.CRS_ID = COURSE.CRS_ID AND CRS_ENROLLED.STU_ID = $stu_id";
$results = mysqli_query( $dbc, $query ) ;
$counter = 0;
if(mysqli_num_rows($results) == 0) {echo '<p>(None)</p>';}
while($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){
if($counter < 3){
echo '<p><label>'.$row['CRS_ID'].'</label><br>';
echo $row['CRS_NAME'] . " (" . $row['CRS_ENROLL_STATUS'] . ")";
echo '</p>';
$counter++;
}
}
}
#Shows programs student is in. Shows 3 programs. Can remove this.
function show_student_programs($dbc, $stu_id){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT PROGRAM.PRG_ID, PROGRAM.PRG_NAME, PRG_ENROLLED.PRG_ENROLL_STATUS FROM PRG_ENROLLED, PROGRAM WHERE PRG_ENROLLED.PRG_ID = PROGRAM.PRG_ID AND PRG_ENROLLED.STU_ID = $stu_id";
$results = mysqli_query( $dbc, $query ) ;
$counter = 0;
if(mysqli_num_rows($results) == 0) {echo '<p>(None)</p>';}
while($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){
if($counter < 3){
echo '<p><label>'.$row['PRG_NAME'].'</label> ';
echo " (" . $row['PRG_ENROLL_STATUS'] . ")";
echo '</p>';
$counter++;
}
}
}
# Shows the query as a debugging aid
function show_query($query) {
global $debug;
if($debug)
echo "<p>Query = $query</p>" ;
}
# Checks the query results as a debugging aid
function check_results($results) {
global $dbc;
if($results != true)
echo '<p>SQL ERROR = ' . mysqli_error( $dbc ) . '</p>' ;
}
#Created function that validates a number
function valid_number($num) {
if (empty($num) || !is_numeric($num))
return false;
else {
$num = intval($num);
if($num <= 0)
return false;
}
return true;
}
#Created function that validates name input
function valid_name($name) {
if (empty($name))
return false;
else
return true;
}
// new
function populate_emp_name($dbc){
require( 'includes/connect_db_c9.php' ) ; //Not sure why we need this here...
$query = "SELECT EMP_NAME FROM EMPLOYER";
$results = mysqli_query( $dbc, $query ) ;
if($results){
while ( $row = mysqli_fetch_array( $results , MYSQLI_ASSOC ) ){
echo '<option value='.$row['EMP_NAME'].'>' . $row['EMP_NAME'] . '</option>' ;
}
}
# Free up the results in memory
mysqli_free_result( $results );
mysqli_close( $dbc ) ;
}
// new end
?>