-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetStudents.fnc.php
103 lines (75 loc) · 2.6 KB
/
getStudents.fnc.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
<?php
/* Get all Course Periods being taught by the From Teacher */
/* the general rosario functions do not persis into ajax called PHP as they are normally loaded through a warehouse function routine. So we have to get them back in play
We could rebuild the database connection and the query call ability BUT then we need to modify it with every new module using AJAX
*/
$year = $_POST['year'];
$grade = $_POST['grade'];
$lastname = $_POST['lastname'];
$schoolid = $_POST['school_id'];
$type = $_POST['returnType'];
/**
* Load functions
*/
/**
* Include config.inc.php file.
*
* Do NOT change for require_once, include_once allows the error message to be displayed.
*/
if ( ! include_once '../../config.inc.php' )
{
die( 'config.inc.php file not found. Please read the installation directions.' );
}
require_once '../../database.inc.php';
$functions = glob( '../../functions/*.php' );
foreach ( $functions as $function )
{
require_once $function;
}
//============================ Code below / Setup Above ====================
/* Determine the items in the where clause know that year is required */
$createFromSelect = '';
if(! empty($year)){
$whereClause = " AND se.SYEAR = '" . $year . "'";
}
if(! empty($grade) && $grade != 'NO'){
$whereClause .= " And se.GRADE_ID = '" . $grade . "'";
}
if(! empty($lastname)){
$whereClause .= " And s.LAST_NAME LIKE '%" . $lastname . "%'";
}
$students = DBGET("Select s.*
From students s,
student_enrollment se
Where s.STUDENT_ID = se.STUDENT_ID
AND se.DROP_CODE IS NULL
AND se.END_DATE IS NULL
AND se.SCHOOL_ID = '" . $schoolid . "'"
. $whereClause
);
//easier for speed to do the if outside the loop
if($type == "selectOption"){
$createFromSelect = '<option value="NO" selected> --- Possible Students --- </option>';
foreach($students as $student){
$name = trim($student['FIRST_NAME'] . ' ' . $student['LAST_NAME']);
$createFromSelect .= '<option value="' .
$student['STUDENT_ID'] .'">' . $name . '</option>';
}
}else{
//$createFromSelect = '<div id="ToStudents"></div>';
foreach($students as $student){
$name = trim($student['FIRST_NAME'] . ' ' . $student['LAST_NAME']);
$createFromSelect .= '<input type="checkbox" id="targetStudents[]" name="targetStudents[]" value="' .$student['STUDENT_ID'] . '">' . $name . '</input></br>';
}
}
echo $createFromSelect;
/*
* @param mixed &$var Variable.
* @param mixed $default Default value if undefined. Defaults to null.
* @return mixed Variable or default.
*/
function issetVal( &$var, $default = null )
{
return ( isset( $var ) ) ? $var : $default;
}
?>