Beispiel #1
0
function GetAllMP($mp, $marking_period_id = '0')
{
    global $_openSIS;
    if ($marking_period_id == 0) {
        // there should be exactly one fy marking period
        $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID FROM school_years WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
        $marking_period_id = $RET[1]['MARKING_PERIOD_ID'];
        $mp = 'FY';
    } elseif (!$mp) {
        $mp = GetMPTable(GetMP($marking_period_id, 'TABLE'));
    }
    // echo $marking_period_id;
    if (!$_openSIS['GetAllMP'][$mp]) {
        switch ($mp) {
            case 'PRO':
                // there should be exactly one fy marking period
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID FROM school_years WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                $fy = $RET[1]['MARKING_PERIOD_ID'];
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID,SEMESTER_ID FROM school_quarters WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                foreach ($RET as $value) {
                    $_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = "'{$fy}','{$value['SEMESTER_ID']}','{$value['MARKING_PERIOD_ID']}'";
                    $_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] .= ',' . GetChildrenMP($mp, $value['MARKING_PERIOD_ID']);
                    if (substr($_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']], -1) == ',') {
                        $_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = substr($_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']], 0, -1);
                    }
                }
                break;
            case 'QTR':
                // there should be exactly one fy marking period
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID FROM school_years WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                $fy = $RET[1]['MARKING_PERIOD_ID'];
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID,SEMESTER_ID FROM school_quarters WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                foreach ($RET as $value) {
                    $_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = "'{$fy}','{$value['SEMESTER_ID']}','{$value['MARKING_PERIOD_ID']}'";
                }
                break;
            case 'SEM':
                // there should be exactly one fy marking period
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID FROM school_years WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                $fy = $RET[1]['MARKING_PERIOD_ID'];
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID,SEMESTER_ID FROM school_quarters WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''), array(), array('SEMESTER_ID'));
                foreach ($RET as $sem => $value) {
                    $_openSIS['GetAllMP'][$mp][$sem] = "'{$fy}','{$sem}'";
                    foreach ($value as $qtr) {
                        $_openSIS['GetAllMP'][$mp][$sem] .= ",'{$qtr['MARKING_PERIOD_ID']}'";
                    }
                }
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID FROM school_semesters s WHERE NOT EXISTS (SELECT \'\' FROM school_quarters q WHERE q.SEMESTER_ID=s.MARKING_PERIOD_ID) AND SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                foreach ($RET as $value) {
                    $_openSIS['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = "'{$fy}','{$value['MARKING_PERIOD_ID']}'";
                }
                break;
            case 'FY':
                // there should be exactly one fy marking period which better be $marking_period_id
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID,SEMESTER_ID FROM school_quarters WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''), array(), array('SEMESTER_ID'));
                $_openSIS['GetAllMP'][$mp][$marking_period_id] = "'{$marking_period_id}'";
                foreach ($RET as $sem => $value) {
                    $_openSIS['GetAllMP'][$mp][$marking_period_id] .= ",'{$sem}'";
                    foreach ($value as $qtr) {
                        $_openSIS['GetAllMP'][$mp][$marking_period_id] .= ",'{$qtr['MARKING_PERIOD_ID']}'";
                    }
                }
                $RET = DBGet(DBQuery('SELECT MARKING_PERIOD_ID FROM school_semesters s WHERE NOT EXISTS (SELECT \'\' FROM school_quarters q WHERE q.SEMESTER_ID=s.MARKING_PERIOD_ID) AND SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\''));
                foreach ($RET as $value) {
                    $_openSIS['GetAllMP'][$mp][$marking_period_id] .= ",'{$value['MARKING_PERIOD_ID']}'";
                }
                break;
        }
    }
    return $_openSIS['GetAllMP'][$mp][$marking_period_id];
}
 if (count($config_RET)) {
     foreach ($config_RET as $title => $value) {
         $programconfig[User('STAFF_ID')][$title] = $value[1]['VALUE'];
     }
 } else {
     $programconfig[User('STAFF_ID')] = true;
 }
 include_once 'functions/_makeLetterGrade.fnc.php';
 $course_period_id = UserCoursePeriod();
 $course_id = DBGet(DBQuery('SELECT COURSE_ID FROM course_periods WHERE COURSE_PERIOD_ID=\'' . UserCoursePeriod() . '\''));
 $course_id = $course_id[1]['COURSE_ID'];
 $grades_RET = DBGet(DBQuery('SELECT ID,TITLE,GPA_VALUE FROM report_card_grades WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\''), array(), array('ID'));
 if ($programconfig[User('STAFF_ID')]['WEIGHT'] == 'Y') {
     $points_RET = DBGet(DBQuery('SELECT DISTINCT s.STUDENT_ID,gt.ASSIGNMENT_TYPE_ID,     gt.ASSIGNMENT_TYPE_ID,sum(' . db_case(array('gg.POINTS', "'-1'", "'0'", 'gg.POINTS')) . ') AS PARTIAL_POINTS,sum(' . db_case(array('gg.POINTS', "'-1'", "'0'", 'ga.POINTS')) . ') AS PARTIAL_TOTAL,    gt.FINAL_GRADE_PERCENT FROM students s JOIN schedule ss ON (ss.STUDENT_ID=s.STUDENT_ID AND ss.COURSE_PERIOD_ID=\'' . $course_period_id . '\') JOIN gradebook_assignments ga ON ((ga.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID OR ga.COURSE_ID=\'' . $course_id . '\' AND ga.STAFF_ID=\'' . User('STAFF_ID') . '\') AND ga.MARKING_PERIOD_ID' . ($programconfig[User('STAFF_ID')]['ELIGIBILITY_CUMULITIVE'] == 'Y' ? ' IN (' . GetChildrenMP('SEM', UserMP()) . ')' : '=\'' . UserMP() . '\'') . ') LEFT OUTER JOIN gradebook_grades gg ON (gg.STUDENT_ID=s.STUDENT_ID AND gg.ASSIGNMENT_ID=ga.ASSIGNMENT_ID AND gg.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID),gradebook_assignment_types gt WHERE gt.ASSIGNMENT_TYPE_ID=ga.ASSIGNMENT_TYPE_ID AND gt.COURSE_ID=\'' . $course_id . '\' AND ((ga.ASSIGNED_DATE IS NULL OR CURRENT_DATE>=ga.ASSIGNED_DATE) AND (ga.DUE_DATE IS NULL OR CURRENT_DATE>=ga.DUE_DATE) OR gg.POINTS IS NOT NULL) GROUP BY s.STUDENT_ID,ss.START_DATE,gt.ASSIGNMENT_TYPE_ID,gt.FINAL_GRADE_PERCENT'), array(), array('STUDENT_ID'));
 } else {
     $points_RET = DBGet(DBQuery('SELECT s.STUDENT_ID,\'' . '-1' . '\' AS ASSIGNMENT_TYPE_ID,sum(' . db_case(array('gg.POINTS', "'-1'", "'0'", 'gg.POINTS')) . ') AS PARTIAL_POINTS,sum(' . db_case(array('gg.POINTS', "'-1'", "'0'", 'ga.POINTS')) . ') AS PARTIAL_TOTAL,\'' . '1' . '\' AS FINAL_GRADE_PERCENT FROM students s JOIN schedule ss ON (ss.STUDENT_ID=s.STUDENT_ID AND ss.COURSE_PERIOD_ID=\'' . $course_period_id . '\') JOIN gradebook_assignments ga ON ((ga.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID OR ga.COURSE_ID=\'' . $course_id . '\' AND ga.STAFF_ID=\'' . User('STAFF_ID') . '\') AND ga.MARKING_PERIOD_ID' . ($programconfig[User('STAFF_ID')]['ELIGIBILITY_CUMULITIVE'] == 'Y' ? ' IN (' . GetChildrenMP('SEM', UserMP()) . ')' : '=\'' . UserMP() . '\'') . ') LEFT OUTER JOIN gradebook_grades gg ON (gg.STUDENT_ID=s.STUDENT_ID AND gg.ASSIGNMENT_ID=ga.ASSIGNMENT_ID AND gg.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID)                               WHERE                                                                               ((ga.ASSIGNED_DATE IS NULL OR CURRENT_DATE>=ga.ASSIGNED_DATE) AND (ga.DUE_DATE IS NULL OR CURRENT_DATE>=ga.DUE_DATE) OR gg.POINTS IS NOT NULL) GROUP BY s.STUDENT_ID,ss.START_DATE                                             '), array(), array('STUDENT_ID'));
 }
 if (count($points_RET)) {
     foreach ($points_RET as $student_id => $student) {
         $total = $total_percent = 0;
         foreach ($student as $partial_points) {
             if ($partial_points['PARTIAL_TOTAL'] != 0) {
                 $total += $partial_points['PARTIAL_POINTS'] * $partial_points['FINAL_GRADE_PERCENT'] / $partial_points['PARTIAL_TOTAL'];
                 $total_percent += $partial_points['FINAL_GRADE_PERCENT'];
             }
         }
         if ($total_percent != 0) {
             $total /= $total_percent;
         }
         $grade = $grades_RET[_makeLetterGrade($total, 0, 0, 'ID')][1];
         if ($grade['GPA_VALUE'] == '0' || !$grade['GPA_VALUE']) {
 foreach ($attendance_codes as $code) {
     $extra['extra_header_left'] .= '<OPTION value=' . $code['ID'] . '>' . $code['TITLE'] . '</OPTION>';
 }
 $extra['extra_header_left'] .= '</SELECT></TD>';
 $extra['extra_header_left'] .= '</TR><TR>';
 $extra['extra_header_left'] .= '<TD><label><INPUT type="checkbox" name="elements[period_absences]" value="Y"> ' . _('Period-by-period absences') . '</label></TD>';
 $extra['extra_header_left'] .= '<TD></TD>';
 $extra['extra_header_left'] .= '</TR>';
 $extra['extra_header_left'] .= '</TABLE></TD></TR>';
 //modif Francois: get the title instead of the short marking period name
 $mps_RET = DBGet(DBQuery("SELECT PARENT_ID,MARKING_PERIOD_ID,SHORT_NAME,TITLE FROM SCHOOL_MARKING_PERIODS WHERE MP='QTR' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' ORDER BY SORT_ORDER"), array(), array('PARENT_ID'));
 $extra['extra_header_left'] .= '<TR><TD style="text-align:right">' . _('Marking Periods') . ':</TD><TD><TABLE><TR><TD><TABLE>';
 foreach ($mps_RET as $sem => $quarters) {
     $extra['extra_header_left'] .= '<TR>';
     foreach ($quarters as $qtr) {
         $pro = GetChildrenMP('PRO', $qtr['MARKING_PERIOD_ID']);
         if ($pro) {
             $pros = explode(',', str_replace("'", '', $pro));
             foreach ($pros as $pro) {
                 if (GetMP($pro, 'DOES_GRADES') == 'Y') {
                     $extra['extra_header_left'] .= '<TD><label><INPUT type="checkbox" name="mp_arr[]" value="' . $pro . '"> ' . GetMP($pro, 'TITLE') . '</label></TD>';
                 }
             }
         }
         $extra['extra_header_left'] .= '<TD><label><INPUT type="checkbox" name="mp_arr[]" value="' . $qtr['MARKING_PERIOD_ID'] . '"> ' . $qtr['TITLE'] . '</label></TD>';
     }
     if (GetMP($sem, 'DOES_GRADES') == 'Y') {
         $extra['extra_header_left'] .= '<TD><label><INPUT type="checkbox" name="mp_arr[]" value="' . $sem . '"> ' . GetMP($sem, 'TITLE') . '</label></TD>';
     }
     $extra['extra_header_left'] .= '</TR>';
 }
Beispiel #4
0
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#**************************************************************************
if (!$_REQUEST['modfunc'] && $_REQUEST['search_modfunc'] != 'list') {
    unset($_SESSION['MassSchedule.php']);
}
if ($_REQUEST['modfunc'] == 'save') {
    if ($_SESSION['MassSchedule.php']) {
        $start_date = $_REQUEST['day'] . '-' . $_REQUEST['month'] . '-' . $_REQUEST['year'];
        if (!VerifyDate($start_date)) {
            BackPrompt('The date you entered is not valid');
        }
        $course_mp = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . $_SESSION['MassSchedule.php']['course_period_id'] . "'"));
        $course_mp = $course_mp[1]['MARKING_PERIOD_ID'];
        $course_mp_table = GetMPTable(GetMP($course_mp, 'TABLE'));
        if ($course_mp_table != 'FY' && $course_mp != $_REQUEST['marking_period_id'] && strpos(GetChildrenMP($course_mp_table, $course_mp), "'" . $_REQUEST['marking_period_id'] . "'") === false) {
            //	BackPrompt("You cannot schedule a student into that course during the marking period that you chose.  This course meets on ".GetMP($course_mp).'.');
            ShowErr("You cannot schedule a student into that course during the marking period that you chose.  This course meets on " . GetMP($course_mp) . '.');
            for_error();
        }
        $mp_table = GetMPTable(GetMP($_REQUEST['marking_period_id'], 'TABLE'));
        $current_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM SCHEDULE WHERE COURSE_PERIOD_ID='" . $_SESSION['MassSchedule.php']['course_period_id'] . "' AND SYEAR='" . UserSyear() . "' AND (('" . $start_date . "' BETWEEN START_DATE AND END_DATE OR END_DATE IS NULL) AND '" . $start_date . "'>=START_DATE)"), array(), array('STUDENT_ID'));
        $request_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM SCHEDULE_REQUESTS WHERE WITH_PERIOD_ID=(SELECT PERIOD_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . $_SESSION['MassSchedule.php']['course_period_id'] . "') AND SYEAR='" . UserSyear() . "' AND COURSE_ID='" . $_SESSION['MassSchedule.php']['course_id'] . "'"), array(), array('STUDENT_ID'));
        $check_seats = DBGet(DBQuery("SELECT  (TOTAL_SEATS - FILLED_SEATS) AS AVAILABLE_SEATS FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . $_SESSION['MassSchedule.php']['course_period_id'] . "'"));
        $check_seats = $check_seats[1]['AVAILABLE_SEATS'];
        $no_seat = 'There is no available seats in this period.<br>Please increase the "Total Seats" from Scheduling>>Setup>Courses';
        foreach ($_REQUEST['student'] as $student_id => $yes) {
            if (!$current_RET[$student_id]) {
                if (!$request_RET[$student_id]) {
                    $sql = "INSERT INTO SCHEDULE (SYEAR,SCHOOL_ID,STUDENT_ID,COURSE_ID,COURSE_PERIOD_ID,MP,MARKING_PERIOD_ID,START_DATE)\n\t\t\t\t\t\t\t\tvalues('" . UserSyear() . "','" . UserSchool() . "','" . $student_id . "','" . $_SESSION['MassSchedule.php']['course_id'] . "','" . $_SESSION['MassSchedule.php']['course_period_id'] . "','" . $mp_table . "','" . $_REQUEST['marking_period_id'] . "','" . $start_date . "')";
                    DBQuery($sql);
Beispiel #5
0
 if (count($config_RET)) {
     foreach ($config_RET as $title => $value) {
         $programconfig[User('STAFF_ID')][$title] = $value[1]['VALUE'];
     }
 } else {
     $programconfig[User('STAFF_ID')] = true;
 }
 include 'ProgramFunctions/_makeLetterGrade.fnc.php';
 $course_period_id = UserCoursePeriod();
 $course_id = DBGet(DBQuery("SELECT COURSE_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . UserCoursePeriod() . "'"));
 $course_id = $course_id[1]['COURSE_ID'];
 $grades_RET = DBGet(DBQuery("SELECT ID,TITLE,GPA_VALUE FROM REPORT_CARD_GRADES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"), array(), array('ID'));
 if ($programconfig[User('STAFF_ID')]['WEIGHT'] == 'Y') {
     $points_RET = DBGet(DBQuery("SELECT DISTINCT ON (s.STUDENT_ID,gt.ASSIGNMENT_TYPE_ID) s.STUDENT_ID,     gt.ASSIGNMENT_TYPE_ID,sum(" . db_case(array('gg.POINTS', "'-1'", "'0'", 'gg.POINTS')) . ") AS PARTIAL_POINTS,sum(" . db_case(array('gg.POINTS', "'-1'", "'0'", 'ga.POINTS')) . ") AS PARTIAL_TOTAL,    gt.FINAL_GRADE_PERCENT FROM STUDENTS s JOIN SCHEDULE ss ON (ss.STUDENT_ID=s.STUDENT_ID AND ss.COURSE_PERIOD_ID='{$course_period_id}') JOIN GRADEBOOK_ASSIGNMENTS ga ON ((ga.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID OR ga.COURSE_ID='{$course_id}' AND ga.STAFF_ID='" . User('STAFF_ID') . "') AND ga.MARKING_PERIOD_ID" . ($programconfig[User('STAFF_ID')]['ELIGIBILITY_CUMULITIVE'] == 'Y' ? " IN (" . GetChildrenMP('SEM', UserMP()) . ")" : "='" . UserMP() . "'") . ") LEFT OUTER JOIN GRADEBOOK_GRADES gg ON (gg.STUDENT_ID=s.STUDENT_ID AND gg.ASSIGNMENT_ID=ga.ASSIGNMENT_ID AND gg.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID),GRADEBOOK_ASSIGNMENT_TYPES gt WHERE gt.ASSIGNMENT_TYPE_ID=ga.ASSIGNMENT_TYPE_ID AND gt.COURSE_ID='{$course_id}' AND ((ga.ASSIGNED_DATE IS NULL OR CURRENT_DATE>=ga.ASSIGNED_DATE) AND (ga.DUE_DATE IS NULL OR CURRENT_DATE>=ga.DUE_DATE) OR gg.POINTS IS NOT NULL) GROUP BY s.STUDENT_ID,ss.START_DATE,gt.ASSIGNMENT_TYPE_ID,gt.FINAL_GRADE_PERCENT"), array(), array('STUDENT_ID'));
 } else {
     $points_RET = DBGet(DBQuery("SELECT DISTINCT ON (s.STUDENT_ID)                       s.STUDENT_ID,'-1' AS ASSIGNMENT_TYPE_ID,sum(" . db_case(array('gg.POINTS', "'-1'", "'0'", 'gg.POINTS')) . ") AS PARTIAL_POINTS,sum(" . db_case(array('gg.POINTS', "'-1'", "'0'", 'ga.POINTS')) . ") AS PARTIAL_TOTAL,'1' AS FINAL_GRADE_PERCENT FROM STUDENTS s JOIN SCHEDULE ss ON (ss.STUDENT_ID=s.STUDENT_ID AND ss.COURSE_PERIOD_ID='{$course_period_id}') JOIN GRADEBOOK_ASSIGNMENTS ga ON ((ga.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID OR ga.COURSE_ID='{$course_id}' AND ga.STAFF_ID='" . User('STAFF_ID') . "') AND ga.MARKING_PERIOD_ID" . ($programconfig[User('STAFF_ID')]['ELIGIBILITY_CUMULITIVE'] == 'Y' ? " IN (" . GetChildrenMP('SEM', UserMP()) . ")" : "='" . UserMP() . "'") . ") LEFT OUTER JOIN GRADEBOOK_GRADES gg ON (gg.STUDENT_ID=s.STUDENT_ID AND gg.ASSIGNMENT_ID=ga.ASSIGNMENT_ID AND gg.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID)                               WHERE                                                                               ((ga.ASSIGNED_DATE IS NULL OR CURRENT_DATE>=ga.ASSIGNED_DATE) AND (ga.DUE_DATE IS NULL OR CURRENT_DATE>=ga.DUE_DATE) OR gg.POINTS IS NOT NULL) GROUP BY s.STUDENT_ID,ss.START_DATE                                             "), array(), array('STUDENT_ID'));
 }
 if (count($points_RET)) {
     foreach ($points_RET as $student_id => $student) {
         $total = $total_percent = 0;
         foreach ($student as $partial_points) {
             if ($partial_points['PARTIAL_TOTAL'] != 0) {
                 $total += $partial_points['PARTIAL_POINTS'] * $partial_points['FINAL_GRADE_PERCENT'] / $partial_points['PARTIAL_TOTAL'];
                 $total_percent += $partial_points['FINAL_GRADE_PERCENT'];
             }
         }
         if ($total_percent != 0) {
             $total /= $total_percent;
         }
         $grade = $grades_RET[_makeLetterGrade($total, 0, 0, 'ID')][1];
         if ($grade['GPA_VALUE'] == '0' || !$grade['GPA_VALUE']) {
Beispiel #6
0
$mp_RET = DBGet(DBQuery('SELECT MP FROM course_periods WHERE course_period_id = \'' . UserCoursePeriod() . '\''));
if ($mp_RET[1]['MP'] == 'SEM') {
    $sem = GetParentMP('SEM', UserMP());
    $pros = GetChildrenMP('PRO', UserMP());
}
if ($mp_RET[1]['MP'] == 'FY') {
    $sem = GetParentMP('SEM', UserMP());
    if ($sem) {
        $fy = GetParentMP('FY', $sem);
    } else {
        $fy = GetParentMP('FY', UserMP());
    }
    $pros = GetChildrenMP('PRO', UserMP());
}
if ($mp_RET[1]['MP'] == 'QTR') {
    $pros = GetChildrenMP('PRO', UserMP());
}
// if the UserMP has been changed, the REQUESTed MP may not work
if (!$_REQUEST['mp'] || strpos($str = "'" . UserMP() . "','" . $sem . "','" . $fy . "'," . $pros, "'" . ltrim($_REQUEST['mp'], 'E') . "'") === false) {
    $_REQUEST['mp'] = UserMP();
}
$course_period_id = UserCoursePeriod();
if ($course_period_id) {
    $course_RET = DBGet(DBQuery('SELECT cp.COURSE_ID,c.TITLE as COURSE_NAME, cp.TITLE, cp.GRADE_SCALE_ID,cp.STANDARD_SCALE_ID,CREDIT(cp.COURSE_PERIOD_ID,\'' . $_REQUEST['mp'] . '\') AS CREDITS,cp.COURSE_WEIGHT,cp.USE_STANDARDS FROM course_periods cp, courses c WHERE cp.COURSE_ID = c.COURSE_ID AND cp.COURSE_PERIOD_ID=\'' . $course_period_id . '\''));
}
//sg
//if(!$course_RET[1]['GRADE_SCALE_ID'])
if (!$course_RET[1]['GRADE_SCALE_ID'] && !$_REQUEST['include_inactive']) {
    echo ErrorMessage(array('You cannot enter grades for this course.'), 'error');
    $not_graded = true;
    $_REQUEST['use_percents'] = true;
Beispiel #7
0
<?php

if (!$_REQUEST['modfunc'] && $_REQUEST['search_modfunc'] != 'list') {
    unset($_SESSION['MassDrops.php']);
}
if (isset($_REQUEST['modfunc']) && $_REQUEST['modfunc'] == 'save') {
    if ($_SESSION['MassDrops.php']) {
        if (is_array($_REQUEST['student'])) {
            $END_DATE = $_REQUEST['day'] . '-' . $_REQUEST['month'] . '-' . $_REQUEST['year'];
            if (VerifyDate($END_DATE)) {
                $course_mp = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . $_SESSION['MassDrops.php']['course_period_id'] . "'"));
                $course_mp = $course_mp[1]['MARKING_PERIOD_ID'];
                $course_mp_table = GetMP($course_mp, 'MP');
                if ($course_mp_table == 'FY' || $course_mp == $_REQUEST['marking_period_id'] || mb_strpos(GetChildrenMP($course_mp_table, $course_mp), "'" . $_REQUEST['marking_period_id'] . "'") !== false) {
                    $mp_table = GetMP($_REQUEST['marking_period_id'], 'MP');
                    //$current_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM SCHEDULE WHERE COURSE_PERIOD_ID='".$_SESSION['MassDrops.php']['course_period_id']."' AND SYEAR='".UserSyear()."' AND (('".$start_date."' BETWEEN START_DATE AND END_DATE OR END_DATE IS NULL) AND '".$start_date."'>=START_DATE)"),array(),array('STUDENT_ID'));
                    $current_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM SCHEDULE WHERE COURSE_PERIOD_ID='" . $_SESSION['MassDrops.php']['course_period_id'] . "' "));
                    foreach ($_REQUEST['student'] as $student_id => $yes) {
                        if ($current_RET[$student_id]) {
                            DBQuery("UPDATE SCHEDULE SET END_DATE='" . $END_DATE . "' WHERE STUDENT_ID='" . $student_id . "' AND COURSE_PERIOD_ID='" . $_SESSION['MassDrops.php']['course_period_id'] . "'");
                            //echo "<b>student:</b>  $student_id ";
                            //$start_end_RET = DBGet(DBQuery("SELECT START_DATE,END_DATE FROM SCHEDULE WHERE STUDENT_ID='".UserStudentID()."' AND COURSE_PERIOD_ID='".$course_period_id."' AND END_DATE<START_DATE"));
                            $start_end_RET = DBGet(DBQuery("SELECT START_DATE,END_DATE FROM SCHEDULE WHERE STUDENT_ID='" . $student_id . "' AND COURSE_PERIOD_ID='" . $_SESSION['MassDrops.php']['course_period_id'] . "' AND END_DATE<START_DATE"));
                            if (count($start_end_RET)) {
                                //DBQuery("DELETE FROM SCHEDULE WHERE STUDENT_ID='".UserStudentID()."' AND END_DATE IS NOT NULL AND END_DATE<START_DATE");
                                DBQuery("DELETE FROM SCHEDULE WHERE STUDENT_ID='" . $student_id . "' AND COURSE_PERIOD_ID='" . $_SESSION['MassDrops.php']['course_period_id'] . "'");
                            }
                            //modif Francois: Moodle integrator
                            $moodleError .= Moodle($_REQUEST['modname'], 'core_role_unassign_roles');
                        }
                    }
Beispiel #8
0
         if ($mps[$mp][1]['GRADE_TITLE']) {
             break;
         }
     }
     //if(!$mps[$mp])
     $course_periods[$index][$mp][1]['STUDENT_MP_COMMENT'] = str_replace("\r", '`', str_replace('(', '{', str_replace(')', '}', $course_periods[$index][$mp][1]['STUDENT_MP_COMMENT'])));
     $course_periods[$index][$mp][1]['STUDENT_MP_COMMENT'] = wordwrap($course_periods[$index][$mp][1]['STUDENT_MP_COMMENT'], 59, "`");
     $comments = explode('`', $course_periods[$index][$mp][1]['STUDENT_MP_COMMENT']);
     for ($c = 0; $c <= count($comments); $c++) {
         $this_PDF = str_replace('/T(values[student_mp_comments][' . GetMP($mp, 'SORT_ORDER') . '][' . ($c + 1) . '])', "/T(values[{$student_count}][student_mp_comments][" . GetMP($mp, 'SORT_ORDER') . '][' . ($c + 1) . '])', $this_PDF);
         $this_PDF = str_replace('(default[student_mp_comments][' . GetMP($mp, 'SORT_ORDER') . '][' . ($c + 1) . '])', '(' . $comments[$c] . ')', $this_PDF);
     }
     for (; $c <= 19; $c++) {
         $this_PDF = str_replace('(default[student_mp_comments][' . GetMP($mp, 'SORT_ORDER') . '][' . ($c + 1) . '])', '( )', $this_PDF);
     }
     $qtr = str_replace("'", '', GetChildrenMP('SEM', $mp));
     if (strpos(',', $qtr) !== false) {
         $qtr = substr($qtr, strpos(',', $qtr));
     }
     foreach ($attendance_codes as $attendance_code) {
         $attendance_code = $attendance_code['SHORT_NAME'];
         $value = $attendance_RET[$student_id][$qtr][$attendance_code];
         $this_PDF = str_replace('/T(values[ac][' . $attendance_code . '][' . GetMP($mp, 'SORT_ORDER') . '])', "/T(values[{$student_count}][ac][" . $attendance_code . '][1])', $this_PDF);
         $this_PDF = str_replace('(default[ac][' . $attendance_code . '][' . GetMP($mp, 'SORT_ORDER') . '])', '( ' . count($value) . ' )', $this_PDF);
     }
     $this_PDF = str_replace('/T(values[abs][' . GetMP($mp, 'SORT_ORDER') . '])', "/T(values[{$student_count}][abs][1])", $this_PDF);
     $this_PDF = str_replace('(default[abs][' . GetMP($mp, 'SORT_ORDER') . '])', '( ' . count($attendance_day_RET[$student_id][$qtr]) . ' )', $this_PDF);
 }
 foreach ($_REQUEST['mp_arr'] as $mp) {
     $columns[$mp] = GetMP($mp, $mp_TITLE);
 }
function Widgets($item, &$myextra = null)
{
    global $extra, $_ROSARIO, $RosarioModules;
    if (isset($myextra)) {
        $extra =& $myextra;
    }
    if (!is_array($_ROSARIO['Widgets'])) {
        $_ROSARIO['Widgets'] = array();
    }
    if (!is_array($extra['functions'])) {
        $extra['functions'] = array();
    }
    if ((User('PROFILE') == 'admin' || User('PROFILE') == 'teacher') && !$_ROSARIO['Widgets'][$item]) {
        switch ($item) {
            case 'all':
                $extra['search'] .= '<TR><TD colspan="2"><TABLE class="width-100p cellpadding-2" style="border-collapse:separate; border-spacing: 2px">';
                if ($RosarioModules['Students'] && (!$_ROSARIO['Widgets']['calendar'] || !$_ROSARIO['Widgets']['next_year'] || !$_ROSARIO['Widgets']['enrolled'] || !$_ROSARIO['Widgets']['rolled'])) {
                    //modif Francois: css WPadmin
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'enrollment_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="enrollment_table_arrow" height="12"> <B>' . _('Enrollment') . '</B></A><BR /><TABLE id="enrollment_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('calendar', $extra);
                    Widgets('next_year', $extra);
                    Widgets('enrolled', $extra);
                    Widgets('rolled', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Scheduling'] && (!$_ROSARIO['Widgets']['course'] || !$_ROSARIO['Widgets']['request']) && User('PROFILE') == 'admin') {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'scheduling_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="scheduling_table_arrow" height="12"> <B>' . _('Scheduling') . '</B></A><BR /><TABLE id="scheduling_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('course', $extra);
                    //Widgets('request',$extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Attendance'] && !$_ROSARIO['Widgets']['absences']) {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'absences_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="absences_table_arrow" height="12"> <B>' . _('Attendance') . '</B></A><BR /><TABLE id="absences_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('absences', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Grades'] && (!$_ROSARIO['Widgets']['gpa'] || !$_ROSARIO['Widgets']['class_rank'] || !$_ROSARIO['Widgets']['letter_grade'])) {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'grades_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="grades_table_arrow" height="12"> <B>' . _('Grades') . '</B></A><BR /><TABLE style="padding:5px;" id="grades_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('gpa', $extra);
                    Widgets('class_rank', $extra);
                    Widgets('letter_grade', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Eligibility'] && (!$_ROSARIO['Widgets']['eligibility'] || !$_ROSARIO['Widgets']['activity'])) {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'eligibility_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="eligibility_table_arrow" height="12"> <B>' . _('Eligibility') . '</B></A><BR /><TABLE id="eligibility_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('eligibility', $extra);
                    Widgets('activity', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Food_Service'] && (!$_ROSARIO['Widgets']['fsa_balance'] || !$_ROSARIO['Widgets']['fsa_discount'] || !$_ROSARIO['Widgets']['fsa_status'] || !$_ROSARIO['Widgets']['fsa_barcode'])) {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'food_service_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="food_service_table_arrow" height="12"> <B>' . _('Food Service') . '</B></A><BR /><TABLE id="food_service_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('fsa_balance', $extra);
                    Widgets('fsa_discount', $extra);
                    Widgets('fsa_status', $extra);
                    Widgets('fsa_barcode', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Discipline'] && !$_ROSARIO['Widgets']['discipline']) {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'discipline_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="discipline_table_arrow" height="12"> <B>' . _('Discipline') . '</B></A><BR /><TABLE id="discipline_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('discipline', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                if ($RosarioModules['Student_Billing'] && !$_ROSARIO['Widgets']['balance']) {
                    $extra['search'] .= '<TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'billing_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="billing_table_arrow" height="12"> <B>' . _('Student Billing') . '</B></A><BR /><TABLE id="billing_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                    Widgets('balance', $extra);
                    $extra['search'] .= '</TABLE></TD></TR>';
                }
                $extra['search'] .= '</TABLE></TD></TR>';
                break;
            case 'user':
                $widgets_RET = DBGet(DBQuery("SELECT TITLE FROM PROGRAM_USER_CONFIG WHERE USER_ID='" . User('STAFF_ID') . "' AND PROGRAM='WidgetsSearch'" . (count($_ROSARIO['Widgets']) ? " AND TITLE NOT IN ('" . implode("','", array_keys($_ROSARIO['Widgets'])) . "')" : '')));
                foreach ($widgets_RET as $widget) {
                    Widgets($widget['TITLE'], $extra);
                }
                break;
            case 'course':
                if ($RosarioModules['Scheduling'] && User('PROFILE') == 'admin') {
                    if ($_REQUEST['w_course_period_id']) {
                        if ($_REQUEST['w_course_period_id_which'] == 'course') {
                            $course = DBGet(DBQuery("SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM COURSE_PERIODS cp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'"));
                            $extra['FROM'] .= ",SCHEDULE w_ss";
                            $extra['WHERE'] .= " AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_ID='" . $course[1]['COURSE_ID'] . "' AND ('" . DBDate() . "' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)";
                            if (!$extra['NoSearchTerms']) {
                                $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Course')) . ' </b>' . $course[1]['COURSE_TITLE'] . '<BR />';
                            }
                        } else {
                            $extra['FROM'] .= ",SCHEDULE w_ss";
                            $extra['WHERE'] .= " AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "' AND ('" . DBDate() . "' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)";
                            $course = DBGet(DBQuery("SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM COURSE_PERIODS cp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'"));
                            if (!$extra['NoSearchTerms']) {
                                $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Course Period')) . ' </b>' . $course[1]['COURSE_TITLE'] . ': ' . $course[1]['TITLE'] . '<BR />';
                            }
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Course') . "</TD><TD><DIV id=course_div></DIV> <A HREF=# onclick='window.open(\"Modules.php?modname=misc/ChooseCourse.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'>" . _('Choose') . '</A></TD></TR>';
                }
                break;
            case 'request':
                if ($RosarioModules['Scheduling'] && User('PROFILE') == 'admin') {
                    // PART OF THIS IS DUPLICATED IN PrintRequests.php
                    if ($_REQUEST['request_course_id']) {
                        $course = DBGet(DBQuery("SELECT c.TITLE FROM COURSES c WHERE c.COURSE_ID='" . $_REQUEST['request_course_id'] . "'"));
                        if (!$_REQUEST['not_request_course']) {
                            $extra['FROM'] .= ",SCHEDULE_REQUESTS sr";
                            $extra['WHERE'] .= " AND sr.STUDENT_ID=s.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.SCHOOL_ID=ssm.SCHOOL_ID AND sr.COURSE_ID='" . $_REQUEST['request_course_id'] . "' ";
                            if (!$extra['NoSearchTerms']) {
                                $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Request')) . ' </b>' . $course[1]['TITLE'] . '<BR />';
                            }
                        } else {
                            $extra['WHERE'] .= " AND NOT EXISTS (SELECT '' FROM SCHEDULE_REQUESTS sr WHERE sr.STUDENT_ID=ssm.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.COURSE_ID='" . $_REQUEST['request_course_id'] . "' ) ";
                            if (!$extra['NoSearchTerms']) {
                                $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Missing Request')) . ' </b>' . $course[1]['TITLE'] . '<BR />';
                            }
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px">' . _('Request') . '</TD><TD><DIV id="request_div"></DIV> <A HREF="#" onclick=\'window.open("Modules.php?modname=misc/ChooseRequest.php","","scrollbars=yes,resizable=yes,width=800,height=400");\'>' . _('Choose') . '</A></TD></TR>';
                }
                break;
            case 'absences':
                if ($RosarioModules['Attendance']) {
                    if (is_numeric($_REQUEST['absences_low']) && is_numeric($_REQUEST['absences_high'])) {
                        if ($_REQUEST['absences_low'] > $_REQUEST['absences_high']) {
                            $temp = $_REQUEST['absences_high'];
                            $_REQUEST['absences_high'] = $_REQUEST['absences_low'];
                            $_REQUEST['absences_low'] = $temp;
                        }
                        if ($_REQUEST['absences_low'] == $_REQUEST['absences_high']) {
                            $extra['WHERE'] .= " AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM ATTENDANCE_DAY ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (" . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ")) = '{$_REQUEST['absences_low']}'";
                        } else {
                            $extra['WHERE'] .= " AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM ATTENDANCE_DAY ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (" . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ")) BETWEEN '{$_REQUEST['absences_low']}' AND '{$_REQUEST['absences_high']}'";
                        }
                        switch ($_REQUEST['absences_term']) {
                            case 'FY':
                                $term = _('this school year to date');
                                break;
                            case 'SEM':
                                $term = _('this semester to date');
                                break;
                            case 'QTR':
                                $term = _('this marking period to date');
                                break;
                        }
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Days Absent') . '&nbsp;' . $term . ' ' . _('Between') . ' </b>' . $_REQUEST['absences_low'] . ' &amp; ' . $_REQUEST['absences_high'] . '<BR />';
                        }
                    }
                    //modif Francois: add <label> on radio
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Days Absent') . '<BR /><label><INPUT type="radio" name="absences_term" value="FY" checked />&nbsp;' . _('YTD') . '</label>&nbsp; <label><INPUT type="radio" name="absences_term" value="SEM">&nbsp;' . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . '</label>&nbsp; <label><INPUT type="radio" name="absences_term" value="QTR">&nbsp;' . GetMP(UserMP(), 'SHORT_NAME') . '</label></TD><TD>' . _('Between') . ' <INPUT type="text" name="absences_low" size="3" maxlength="5"> &amp; <INPUT type="text" name="absences_high" size="3" maxlength="5"></TD></TR>';
                }
                break;
            case 'gpa':
                if ($RosarioModules['Grades']) {
                    if (is_numeric($_REQUEST['gpa_low']) && is_numeric($_REQUEST['gpa_high'])) {
                        if ($_REQUEST['gpa_low'] > $_REQUEST['gpa_high']) {
                            $temp = $_REQUEST['gpa_high'];
                            $_REQUEST['gpa_high'] = $_REQUEST['gpa_low'];
                            $_REQUEST['gpa_low'] = $temp;
                        }
                        if ($_REQUEST['list_gpa']) {
                            //modif Francois: remove STUDENT_GPA_CALCULATED table
                            /*$extra['SELECT'] .= ',sgc.WEIGHTED_GPA,sgc.UNWEIGHTED_GPA';
                            		$extra['columns_after']['WEIGHTED_GPA'] = _('Weighted GPA');
                            		$extra['columns_after']['UNWEIGHTED_GPA'] = _('Unweighted GPA');*/
                            $extra['SELECT'] .= ',sms.CUM_WEIGHTED_FACTOR,sms.CUM_UNWEIGHTED_FACTOR';
                            $extra['columns_after']['CUM_WEIGHTED_FACTOR'] = _('Weighted GPA');
                            $extra['columns_after']['CUM_UNWEIGHTED_FACTOR'] = _('Unweighted GPA');
                        }
                        /*if(mb_strpos($extra['FROM'],'STUDENT_GPA_CALCULATED sgc')===false)
                        		{
                        			$extra['FROM'] .= ",STUDENT_GPA_CALCULATED sgc";
                        			$extra['WHERE'] .= " AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID='".$_REQUEST['gpa_term']."'";
                        		}*/
                        if (mb_strpos($extra['FROM'], 'STUDENT_MP_STATS sms') === false) {
                            $extra['FROM'] .= ",STUDENT_MP_STATS sms";
                            $extra['WHERE'] .= " AND sms.STUDENT_ID=s.STUDENT_ID AND sms.MARKING_PERIOD_ID='" . $_REQUEST['gpa_term'] . "'";
                        }
                        //$extra['WHERE'] .= " AND sgc.".(($_REQUEST['weighted']=='Y')?'WEIGHTED_':'')."GPA BETWEEN '$_REQUEST[gpa_low]' AND '$_REQUEST[gpa_high]' AND sgc.MARKING_PERIOD_ID='".$_REQUEST['gpa_term']."'";
                        $extra['WHERE'] .= " AND sms.CUM_" . ($_REQUEST['weighted'] == 'Y' ? '' : 'UN') . "WEIGHTED_FACTOR*(SELECT GP_SCALE FROM REPORT_CARD_GRADE_SCALES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "') BETWEEN '{$_REQUEST['gpa_low']}' AND '{$_REQUEST['gpa_high']}'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . ($_REQUEST['gpa_weighted'] == 'Y' ? _('Weighted GPA') . ' ' : _('Unweighted GPA') . ' ') . Localize('colon', _('Between')) . ' </b>' . $_REQUEST['gpa_low'] . ' &amp; ' . $_REQUEST['gpa_high'] . '<BR />';
                        }
                    }
                    //modif Francois: add <label> on checkbox
                    //modif Francois: replace Cumulative by Full Year
                    //$extra['search'] .= "<TR><TD style="text-align:right; width:120px:">"._('GPA')."<BR /><label><INPUT type=checkbox name=gpa_weighted value=Y>&nbsp;"._('Weighted').'</label><BR /><label><INPUT type="radio" name="gpa_term" value=CUM checked />&nbsp;'._('Cumulative').'</label>&nbsp; <label><INPUT type="radio" name="gpa_term" value="'.GetParentMP('SEM',UserMP()).'">&nbsp;'.GetMP(GetParentMP('SEM',UserMP()),'SHORT_NAME').'</label> &nbsp;<label><INPUT type="radio" name="gpa_term" value="'.UserMP().'">&nbsp;'.GetMP(UserMP(),'SHORT_NAME')."</label></TD><TD>"._('Between')." <INPUT type="text" name=gpa_low size=3 maxlength=5> &amp; <INPUT type="text" name=gpa_high size=3 maxlength=5></TD></TR>";
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('GPA') . '<BR /><label><INPUT type="checkbox" name="weighted" value="Y">&nbsp;' . _('Weighted') . '</label><BR />' . (GetMP($MPfy = GetParentMP('FY', GetParentMP('SEM', UserMP())), 'DOES_GRADES') == 'Y' ? '<label><INPUT type="radio" name="gpa_term" value="' . $MPfy . '" checked />&nbsp;' . GetMP($MPfy, 'SHORT_NAME') . '</label>&nbsp; ' : '') . (GetMP($MPsem = GetParentMP('SEM', UserMP()), 'DOES_GRADES') == 'Y' ? '<label><INPUT type="radio" name="gpa_term" value="' . $MPsem . '">&nbsp;' . GetMP($MPsem, 'SHORT_NAME') . '</label> &nbsp;' : '') . (GetMP($MPtrim = UserMP(), 'DOES_GRADES') == 'Y' ? '<label><INPUT type="radio" name="gpa_term" value="' . $MPtrim . '" checked />&nbsp;' . GetMP($MPtrim, 'SHORT_NAME') . '</label>' : '') . '</TD><TD>' . _('Between') . ' <INPUT type="text" name="gpa_low" size="3" maxlength="5"> &amp; <INPUT type="text" name="gpa_high" size="3" maxlength="5"></TD></TR>';
                }
                break;
            case 'class_rank':
                if ($RosarioModules['Grades']) {
                    if (is_numeric($_REQUEST['class_rank_low']) && is_numeric($_REQUEST['class_rank_high'])) {
                        if ($_REQUEST['class_rank_low'] > $_REQUEST['class_rank_high']) {
                            $temp = $_REQUEST['class_rank_high'];
                            $_REQUEST['class_rank_high'] = $_REQUEST['class_rank_low'];
                            $_REQUEST['class_rank_low'] = $temp;
                        }
                        //modif Francois: remove STUDENT_GPA_CALCULATED table
                        /*if(mb_strpos($extra['FROM'],'STUDENT_GPA_CALCULATED sgc')===false)
                        		{
                        			$extra['FROM'] .= ",STUDENT_GPA_CALCULATED sgc";
                        			$extra['WHERE'] .= " AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID='".$_REQUEST['class_rank_term']."'";
                        		}*/
                        if (mb_strpos($extra['FROM'], 'STUDENT_MP_STATS sms') === false) {
                            $extra['FROM'] .= ",STUDENT_MP_STATS sms";
                            $extra['WHERE'] .= " AND sms.STUDENT_ID=s.STUDENT_ID AND sms.MARKING_PERIOD_ID='" . $_REQUEST['class_rank_term'] . "'";
                        }
                        //$extra['WHERE'] .= " AND sgc.CLASS_RANK BETWEEN '$_REQUEST[class_rank_low]' AND '$_REQUEST[class_rank_high]'";
                        $extra['WHERE'] .= " AND sms.CUM_RANK BETWEEN '{$_REQUEST['class_rank_low']}' AND '{$_REQUEST['class_rank_high']}'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Class Rank')) . ' ' . _('Between') . '</b>' . $_REQUEST['class_rank_low'] . ' &amp; ' . $_REQUEST['class_rank_high'] . '<BR />';
                        }
                    }
                    //modif Francois: replace Cumulative by Full Year
                    //$extra['search'] .= "<TR><TD style="text-align:right; width:120px:">"._('Class Rank').'<BR /><label><INPUT type="radio" name="class_rank_term" value=CUM checked />&nbsp;'._('Cumulative').'</label> &nbsp;<label><INPUT type="radio" name="class_rank_term" value="'.GetParentMP('SEM',UserMP()).'">&nbsp;'.GetMP(GetParentMP('SEM',UserMP()),'SHORT_NAME').'</label> &nbsp;<label><INPUT type="radio" name="class_rank_term" value="'.UserMP().'">&nbsp;'.GetMP(UserMP(),'SHORT_NAME');
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Class Rank') . '<BR />' . (GetMP($MPfy = GetParentMP('FY', GetParentMP('SEM', UserMP())), 'DOES_GRADES') == 'Y' ? '<label><INPUT type="radio" name="class_rank_term" value="' . $MPfy . '">&nbsp;' . GetMP($MPfy, 'SHORT_NAME') . '</label>&nbsp; ' : '') . (GetMP($MPsem = GetParentMP('SEM', UserMP()), 'DOES_GRADES') == 'Y' ? '<label><INPUT type="radio" name="class_rank_term" value="' . $MPsem . '">&nbsp;' . GetMP($MPsem, 'SHORT_NAME') . '</label> &nbsp;' : '') . (GetMP($MPtrim = UserMP(), 'DOES_GRADES') == 'Y' ? '<label><INPUT type="radio" name="class_rank_term" value="' . $MPtrim . '" checked />&nbsp;' . GetMP($MPtrim, 'SHORT_NAME') . '</label>' : '');
                    if (mb_strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                        $pros = explode(',', str_replace("'", '', $pros));
                        foreach ($pros as $pro) {
                            $extra['search'] .= '<label><INPUT type="radio" name="class_rank_term" value="' . $pro . '">&nbsp;' . GetMP($pro, 'SHORT_NAME') . '</label> &nbsp;';
                        }
                    }
                    $extra['search'] .= '</TD><TD>' . _('Between') . ' <INPUT type="text" name="class_rank_low" size="3" maxlength="5"> &amp; <INPUT type="text" name="class_rank_high" size="3" maxlength="5"></TD></TR>';
                }
                break;
            case 'letter_grade':
                if ($RosarioModules['Grades']) {
                    if (count($_REQUEST['letter_grade'])) {
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . ($_REQUEST['letter_grade_exclude'] == 'Y' ? _('Without') : _('With')) . ' ' . _('Report Card Grade') . ': </b>';
                        }
                        $letter_grades_RET = DBGet(DBQuery("SELECT ID,TITLE FROM REPORT_CARD_GRADES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"), array(), array('ID'));
                        foreach ($_REQUEST['letter_grade'] as $grade => $Y) {
                            $letter_grades .= ",'{$grade}'";
                            if (!$extra['NoSearchTerms']) {
                                $_ROSARIO['SearchTerms'] .= $letter_grades_RET[$grade][1]['TITLE'] . ', ';
                            }
                        }
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] = mb_substr($_ROSARIO['SearchTerms'], 0, -2) . '<BR />';
                        }
                        $extra['WHERE'] .= " AND " . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'NOT ' : '') . "EXISTS (SELECT '' FROM STUDENT_REPORT_CARD_GRADES sg3 WHERE sg3.STUDENT_ID=ssm.STUDENT_ID AND sg3.SYEAR=ssm.SYEAR AND sg3.REPORT_CARD_GRADE_ID IN (" . mb_substr($letter_grades, 1) . ") AND sg3.MARKING_PERIOD_ID='" . $_REQUEST['letter_grade_term'] . "' )";
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Grade') . '<BR /><label><INPUT type="checkbox" name="letter_grade_exclude" value="Y">&nbsp;' . _('Did not receive') . '</label><BR /><label><INPUT type="radio" name="letter_grade_term" value="' . GetParentMP('SEM', UserMP()) . '">&nbsp;' . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . '</label>&nbsp; <label><INPUT type="radio" name="letter_grade_term" value="' . UserMP() . '">&nbsp;' . GetMP(UserMP(), 'SHORT_NAME') . '</label>';
                    if (mb_strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                        $pros = explode(',', str_replace("'", '', $pros));
                        foreach ($pros as $pro) {
                            $extra['search'] .= '<label><INPUT type="radio" name="letter_grade_term" value="' . $pro . '">&nbsp;' . GetMP($pro, 'SHORT_NAME') . '</label> &nbsp;';
                        }
                    }
                    $extra['search'] .= "</TD><TD>";
                    //modif Francois: fix error Invalid argument supplied for foreach()
                    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                        $letter_grades_RET = DBGet(DBQuery("SELECT rg.ID,rg.TITLE,rg.GRADE_SCALE_ID FROM REPORT_CARD_GRADES rg,REPORT_CARD_GRADE_SCALES rs WHERE rg.SCHOOL_ID='" . UserSchool() . "' AND rg.SYEAR='" . UserSyear() . "' AND rs.ID=rg.GRADE_SCALE_ID" . (User('PROFILE') == 'teacher' ? ' AND rg.GRADE_SCALE_ID=(SELECT GRADE_SCALE_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID=\'' . UserCoursePeriod() . '\')' : '') . " ORDER BY rs.SORT_ORDER,rs.ID,rg.BREAK_OFF IS NOT NULL DESC,rg.BREAK_OFF DESC,rg.SORT_ORDER"), array(), array('GRADE_SCALE_ID'));
                        foreach ($letter_grades_RET as $grades) {
                            $i = 0;
                            if (count($grades)) {
                                foreach ($grades as $grade) {
                                    if ($i % 9 == 0) {
                                        $extra['search'] .= '<BR />';
                                    }
                                    $extra['search'] .= '<label><INPUT type="checkbox" value="Y" name="letter_grade[' . $grade['ID'] . ']">&nbsp;' . $grade['TITLE'] . '</label>&nbsp; ';
                                    $i++;
                                }
                            }
                        }
                    }
                    $extra['search'] .= '</TD></TR>';
                }
                break;
            case 'eligibility':
                if ($RosarioModules['Eligibility']) {
                    if ($_REQUEST['ineligible'] == 'Y') {
                        $start_end_RET = DBGet(DBQuery("SELECT TITLE,VALUE FROM PROGRAM_CONFIG WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' AND PROGRAM='eligibility' AND TITLE IN ('START_DAY','END_DAY')"));
                        if (count($start_end_RET)) {
                            foreach ($start_end_RET as $value) {
                                ${$value}['TITLE'] = $value['VALUE'];
                            }
                        }
                        switch (date('D')) {
                            case 'Mon':
                                $today = 1;
                                break;
                            case 'Tue':
                                $today = 2;
                                break;
                            case 'Wed':
                                $today = 3;
                                break;
                            case 'Thu':
                                $today = 4;
                                break;
                            case 'Fri':
                                $today = 5;
                                break;
                            case 'Sat':
                                $today = 6;
                                break;
                            case 'Sun':
                                $today = 7;
                                break;
                        }
                        $start_date = mb_strtoupper(date('d-M-y', time() - ($today - $START_DAY) * 60 * 60 * 24));
                        $end_date = mb_strtoupper(date('d-M-y', time()));
                        $extra['WHERE'] .= " AND (SELECT count(*) FROM ELIGIBILITY e WHERE ssm.STUDENT_ID=e.STUDENT_ID AND e.SYEAR=ssm.SYEAR AND e.SCHOOL_DATE BETWEEN '{$start_date}' AND '{$end_date}' AND e.ELIGIBILITY_CODE='FAILING') > '0'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Eligibility')) . ' </b>' . _('Ineligible') . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:"></TD><TD><label><INPUT type="checkbox" name="ineligible" value="Y">&nbsp;' . _('Ineligible') . '</label></TD></TR>';
                }
                break;
            case 'activity':
                if ($RosarioModules['Eligibility']) {
                    if ($_REQUEST['activity_id']) {
                        $extra['FROM'] .= ",STUDENT_ELIGIBILITY_ACTIVITIES sea";
                        $extra['WHERE'] .= " AND sea.STUDENT_ID=s.STUDENT_ID AND sea.SYEAR=ssm.SYEAR AND sea.ACTIVITY_ID='" . $_REQUEST['activity_id'] . "'";
                        $activity = DBGet(DBQuery("SELECT TITLE FROM ELIGIBILITY_ACTIVITIES WHERE ID='" . $_REQUEST['activity_id'] . "'"));
                        if (!$extra['NoSearchTerms']) {
                            //modif Francois: add translation
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Activity') . ': </b>' . $activity[1]['TITLE'] . '<BR />';
                        }
                    }
                    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                        $activities_RET = DBGet(DBQuery("SELECT ID,TITLE FROM ELIGIBILITY_ACTIVITIES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"));
                    }
                    $select = '<SELECT name="activity_id"><OPTION value="">' . _('Not Specified') . '</OPTION>';
                    if (count($activities_RET)) {
                        foreach ($activities_RET as $activity) {
                            $select .= '<OPTION value="' . $activity['ID'] . '">' . $activity['TITLE'] . '</OPTION>';
                        }
                    }
                    $select .= '</SELECT>';
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Activity') . '</TD><TD>' . $select . '</TD></TR>';
                }
                break;
            case 'mailing_labels':
                if ($_REQUEST['mailing_labels'] == 'Y') {
                    $extra['SELECT'] .= ',coalesce(sam.ADDRESS_ID,-ssm.STUDENT_ID) AS ADDRESS_ID,sam.ADDRESS_ID AS MAILING_LABEL';
                    $extra['FROM'] = " LEFT OUTER JOIN STUDENTS_JOIN_ADDRESS sam ON (sam.STUDENT_ID=ssm.STUDENT_ID AND sam.MAILING='Y'" . ($_REQUEST['residence'] == 'Y' ? " AND sam.RESIDENCE='Y'" : '') . ")" . $extra['FROM'];
                    $extra['functions'] += array('MAILING_LABEL' => 'MailingLabel');
                }
                $extra['search'] .= '<TR><TD style="text-align:right; width:130px"><label>' . _('Mailing Labels') . '&nbsp;<INPUT type="checkbox" name="mailing_labels" value="Y"></label></TD>';
                break;
            case 'balance':
                if ($RosarioModules['Student_Billing']) {
                    if (is_numeric($_REQUEST['balance_low']) && is_numeric($_REQUEST['balance_high'])) {
                        if ($_REQUEST['balance_low'] > $_REQUEST['balance_high']) {
                            $temp = $_REQUEST['balance_high'];
                            $_REQUEST['balance_high'] = $_REQUEST['balance_low'];
                            $_REQUEST['balance_low'] = $temp;
                        }
                        $extra['WHERE'] .= " AND (coalesce((SELECT sum(p.AMOUNT) FROM BILLING_PAYMENTS p WHERE p.STUDENT_ID=ssm.STUDENT_ID AND p.SYEAR=ssm.SYEAR AND (p.LUNCH_PAYMENT!='Y' OR p.LUNCH_PAYMENT IS NULL)),0)-coalesce((SELECT sum(f.AMOUNT) FROM BILLING_FEES f WHERE f.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR),0)) BETWEEN '{$_REQUEST['balance_low']}' AND '{$_REQUEST['balance_high']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Student Billing Balance')) . ' </b>' . _('Between') . ' ' . $_REQUEST['balance_low'] . ' &amp; ' . $_REQUEST['balance_high'] . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Balance') . '<BR /></TD><TD>' . _('Between') . ' <INPUT type="text" name="balance_low" size="5" maxlength="10"> &amp; <INPUT type="text" name="balance_high" size="5" maxlength="10"></TD></TR>';
                }
                break;
            case 'discipline':
                if ($RosarioModules['Discipline']) {
                    if (is_array($_REQUEST['discipline'])) {
                        foreach ($_REQUEST['discipline'] as $key => $value) {
                            if (!$value) {
                                unset($_REQUEST['discipline'][$key]);
                            }
                        }
                    }
                    if ($_REQUEST['month_discipline_entry_begin'] && $_REQUEST['day_discipline_entry_begin'] && $_REQUEST['year_discipline_entry_begin']) {
                        $_REQUEST['discipline_entry_begin'] = $_REQUEST['day_discipline_entry_begin'] . '-' . $_REQUEST['month_discipline_entry_begin'] . '-' . $_REQUEST['year_discipline_entry_begin'];
                        if (!VerifyDate($_REQUEST['discipline_entry_begin'])) {
                            unset($_REQUEST['discipline_entry_begin']);
                        }
                        unset($_REQUEST['day_discipline_entry_begin']);
                        unset($_REQUEST['month_discipline_entry_begin']);
                        unset($_REQUEST['year_discipline_entry_begin']);
                    }
                    if ($_REQUEST['month_discipline_entry_end'] && $_REQUEST['day_discipline_entry_end'] && $_REQUEST['year_discipline_entry_end']) {
                        $_REQUEST['discipline_entry_end'] = $_REQUEST['day_discipline_entry_end'] . '-' . $_REQUEST['month_discipline_entry_end'] . '-' . $_REQUEST['year_discipline_entry_end'];
                        if (!VerifyDate($_REQUEST['discipline_entry_end'])) {
                            unset($_REQUEST['discipline_entry_end']);
                        }
                        unset($_REQUEST['day_discipline_entry_end']);
                        unset($_REQUEST['month_discipline_entry_end']);
                        unset($_REQUEST['year_discipline_entry_end']);
                    }
                    if ($_REQUEST['discipline_reporter'] || $_REQUEST['discipline_entry_begin'] || $_REQUEST['discipline_entry_end'] || count($_REQUEST['discipline']) || count($_REQUEST['discipline_begin']) || count($_REQUEST['discipline_end'])) {
                        $extra['WHERE'] .= ' AND dr.STUDENT_ID=ssm.STUDENT_ID AND dr.SYEAR=ssm.SYEAR AND dr.SCHOOL_ID=ssm.SCHOOL_ID ';
                        $extra['FROM'] .= ',DISCIPLINE_REFERRALS dr ';
                    }
                    $users_RET = DBGet(DBQuery("SELECT STAFF_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME FROM STAFF WHERE SYEAR='" . UserSyear() . "' AND (SCHOOLS IS NULL OR SCHOOLS LIKE '%," . UserSchool() . ",%') AND (PROFILE='admin' OR PROFILE='teacher') ORDER BY LAST_NAME,FIRST_NAME,MIDDLE_NAME"), array(), array('STAFF_ID'));
                    if ($_REQUEST['discipline_reporter']) {
                        $extra['WHERE'] .= " AND dr.STAFF_ID='{$_REQUEST['discipline_reporter']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Reporter') . ': </b>' . $users_RET[$_REQUEST['discipline_reporter']][1]['LAST_NAME'] . ', ' . $users_RET[$_REQUEST['discipline_reporter']][1]['FIRST_NAME'] . ' ' . $users_RET[$_REQUEST['discipline_reporter']][1]['MIDDLE_NAME'] . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Reporter') . '</TD><TD>';
                    $extra['search'] .= '<SELECT name=discipline_reporter><OPTION value="">' . _('Not Specified') . '</OPTION>';
                    foreach ($users_RET as $id => $user) {
                        $extra['search'] .= '<OPTION value=' . $id . '>' . $user[1]['LAST_NAME'] . ', ' . $user[1]['FIRST_NAME'] . ' ' . $user[1]['MIDDLE_NAME'] . '</OPTION>';
                    }
                    $extra['search'] .= '</SELECT>';
                    $extra['search'] .= '</TD></TR>';
                    $discipline_entry_begin_for_ProperDate = $_REQUEST['discipline_entry_begin'];
                    if (mb_strlen($_REQUEST['discipline_entry_begin']) > 10) {
                        //date = LAST_LOGIN = date + time
                        $discipline_entry_begin_for_ProperDate = mb_substr($_REQUEST['discipline_entry_begin'], 0, 10);
                    }
                    if ($_REQUEST['discipline_entry_begin'] && $_REQUEST['discipline_entry_end']) {
                        $extra['WHERE'] .= " AND dr.ENTRY_DATE BETWEEN '{$_REQUEST['discipline_entry_begin']}' AND '{$_REQUEST['discipline_entry_end']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Incident Date') . ' ' . _('Between') . ': </b>' . ProperDate($discipline_entry_begin_for_ProperDate) . '<b> ' . _('and') . ' </b>' . ProperDate($_REQUEST['discipline_entry_end']) . '<BR />';
                        }
                    } elseif ($_REQUEST['discipline_entry_begin']) {
                        $extra['WHERE'] .= " AND dr.ENTRY_DATE>='{$_REQUEST['discipline_entry_begin']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Incident Entered') . ' ' . _('On or After') . ' </b>' . ProperDate($discipline_entry_begin_for_ProperDate) . '<BR />';
                        }
                    } elseif ($_REQUEST['discipline_entry_end']) {
                        $extra['WHERE'] .= " AND dr.ENTRY_DATE<='{$_REQUEST['discipline_entry_end']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Incident Entered') . ' ' . _('On or Before') . ' </b>' . ProperDate($_REQUEST['discipline_entry_end']) . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Incident Date') . '</TD><TD><table class="cellpadding-0 cellspacing-0"><tr><td><span class="sizep2">&ge;</span>&nbsp;</td><td>' . PrepareDate('', '_discipline_entry_begin', true, array('short' => true)) . '</td></tr><tr><td><span class="sizep2">&le;</span>&nbsp;</td><td>' . PrepareDate('', '_discipline_entry_end', true, array('short' => true)) . '</td></tr></table></TD></TR>';
                }
                /*break;
                
                			case 'discipline_categories':*/
                if ($RosarioModules['Discipline']) {
                    $categories_RET = DBGet(DBQuery("SELECT f.ID,u.TITLE,f.DATA_TYPE,u.SELECT_OPTIONS FROM DISCIPLINE_FIELDS f,DISCIPLINE_FIELD_USAGE u WHERE u.DISCIPLINE_FIELD_ID=f.ID AND u.SYEAR='" . UserSyear() . "' AND u.SCHOOL_ID='" . UserSchool() . "' AND f.DATA_TYPE!='textarea'"));
                    foreach ($categories_RET as $category) {
                        if ($category['DATA_TYPE'] != 'date') {
                            $extra['search'] .= '<TR><TD width="150">' . $category['TITLE'] . '</TD><TD>';
                            switch ($category['DATA_TYPE']) {
                                case 'text':
                                    $extra['search'] .= '<INPUT type="text" name="discipline[' . $category['ID'] . ']" />';
                                    if ($_REQUEST['discipline'][$cateogory['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " LIKE '" . $_REQUEST['discipline'][$cateogory['ID']] . "%' ";
                                    }
                                    break;
                                case 'checkbox':
                                    $extra['search'] .= '<INPUT type="checkbox" name="discipline[' . $category['ID'] . ']" value="Y" />';
                                    if ($_REQUEST['discipline'][$cateogory['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " = 'Y' ";
                                    }
                                    break;
                                case 'numeric':
                                    $extra['search'] .= '<small>' . _('Between') . ' </small><INPUT type="text" name="discipline_begin[' . $category['ID'] . ']" size="3" maxlength="11" /> & <INPUT type="text" name="discipline_end[' . $category['ID'] . ']" size="3" maxlength="11" />';
                                    if ($_REQUEST['discipline_begin'][$cateogory['ID']] && $_REQUEST['discipline_begin'][$cateogory['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " BETWEEN '" . $_REQUEST['discipline_begin'][$cateogory['ID']] . "' AND '" . $_REQUEST['discipline_end'][$cateogory['ID']] . "' ";
                                    }
                                    break;
                                case 'multiple_checkbox':
                                case 'multiple_radio':
                                case 'select':
                                    $category['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $category['SELECT_OPTIONS']));
                                    $category['SELECT_OPTIONS'] = explode("\r", $category['SELECT_OPTIONS']);
                                    $extra['search'] .= '<SELECT name="discipline[' . $category['ID'] . ']"><OPTION value="">' . _('N/A') . '</OPTION>';
                                    foreach ($category['SELECT_OPTIONS'] as $option) {
                                        $extra['search'] .= '<OPTION value="' . $option . '">' . $option . '</OPTION>';
                                    }
                                    $extra['search'] .= '</SELECT>';
                                    if (($category['DATA_TYPE'] == 'multiple_radio' || $category['DATA_TYPE'] == 'select') && $_REQUEST['discipline'][$category['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " = '" . $_REQUEST['discipline'][$category['ID']] . "' ";
                                    } elseif ($category['DATA_TYPE'] == 'multiple_checkbox' && $_REQUEST['discipline'][$category['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " LIKE '%||" . $_REQUEST['discipline'][$category['ID']] . "||%' ";
                                    }
                                    break;
                            }
                            $extra['search'] .= '</TD></TR>';
                        }
                    }
                }
                break;
            case 'next_year':
                if ($RosarioModules['Students']) {
                    $schools_RET = DBGet(DBQuery("SELECT ID,TITLE FROM SCHOOLS WHERE ID!='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"), array(), array('ID'));
                    if ($_REQUEST['next_year'] == '!') {
                        $extra['WHERE'] .= " AND ssm.NEXT_SCHOOL IS NULL";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Next Year')) . ' </b>' . _('No Value') . '<BR />';
                        }
                    } elseif ($_REQUEST['next_year'] != '') {
                        $extra['WHERE'] .= " AND ssm.NEXT_SCHOOL='" . $_REQUEST['next_year'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . Localize('colon', _('Next Year')) . ' </b>' . ($_REQUEST['next_year'] == UserSchool() ? 'Next grade at current school' : ($_REQUEST['next_year'] == '0' ? 'Retain' : ($_REQUEST['next_year'] == '-1' ? 'Do not enroll after this school year' : $schools_RET[$_REQUEST['next_year']][1]['TITLE']))) . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Next Year') . '</TD><TD><SELECT name="next_year"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION><OPTION value="' . UserSchool() . '">' . _('Next grade at current school') . '</OPTION><OPTION value="0">' . _('Retain') . '</OPTION><OPTION value="-1">' . _('Do not enroll after this school year') . '</OPTION>';
                    foreach ($schools_RET as $id => $school) {
                        $extra['search'] .= '<OPTION value=' . $id . '>' . $school[1]['TITLE'] . '</OPTION>';
                    }
                    $extra['search'] .= '</SELECT></TD></TR>';
                }
                break;
            case 'calendar':
                if ($RosarioModules['Students']) {
                    $calendars_RET = DBGet(DBQuery("SELECT CALENDAR_ID,TITLE FROM ATTENDANCE_CALENDARS WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' ORDER BY DEFAULT_CALENDAR ASC"), array(), array('CALENDAR_ID'));
                    if ($_REQUEST['calendar'] == '!') {
                        $extra['WHERE'] .= " AND ssm.CALENDAR_ID IS " . ($_REQUEST['calendar_not'] == 'Y' ? 'NOT ' : '') . "NULL";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Calendar') . ': </b>' . ($_REQUEST['calendar_not'] == 'Y' ? _('Any Value') : _('No Value')) . '<BR />';
                        }
                    } elseif ($_REQUEST['calendar'] != '') {
                        $extra['WHERE'] .= " AND ssm.CALENDAR_ID" . ($_REQUEST['calendar_not'] == 'Y' ? '!' : '') . "='" . $_REQUEST['calendar'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Calendar') . ': </b>' . ($_REQUEST['calendar_not'] == 'Y' ? _('Not') . ' ' : '') . $calendars_RET[$_REQUEST['calendar']][1]['TITLE'] . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Calendar') . '</TD><TD><label><INPUT type="checkbox" name="calendar_not" value="Y"> ' . _('Not') . ' </label><SELECT name="calendar"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                    foreach ($calendars_RET as $id => $calendar) {
                        $extra['search'] .= '<OPTION value="' . $id . '">' . $calendar[1]['TITLE'] . '</OPTION>';
                    }
                    $extra['search'] .= '</SELECT></TD></TR>';
                }
                break;
            case 'enrolled':
                if ($RosarioModules['Students']) {
                    if ($_REQUEST['month_enrolled_begin'] && $_REQUEST['day_enrolled_begin'] && $_REQUEST['year_enrolled_begin']) {
                        $_REQUEST['enrolled_begin'] = $_REQUEST['day_enrolled_begin'] . '-' . $_REQUEST['month_enrolled_begin'] . '-' . $_REQUEST['year_enrolled_begin'];
                        if (!VerifyDate($_REQUEST['enrolled_begin'])) {
                            unset($_REQUEST['enrolled_begin']);
                        }
                    }
                    if ($_REQUEST['month_enrolled_end'] && $_REQUEST['day_enrolled_end'] && $_REQUEST['year_enrolled_end']) {
                        $_REQUEST['enrolled_end'] = $_REQUEST['day_enrolled_end'] . '-' . $_REQUEST['month_enrolled_end'] . '-' . $_REQUEST['year_enrolled_end'];
                        if (!VerifyDate($_REQUEST['enrolled_end'])) {
                            unset($_REQUEST['enrolled_end']);
                        }
                    }
                    if ($_REQUEST['enrolled_begin'] && $_REQUEST['enrolled_end']) {
                        $extra['WHERE'] .= " AND ssm.START_DATE BETWEEN '" . $_REQUEST['enrolled_begin'] . "' AND '" . $_REQUEST['enrolled_end'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Enrolled') . ' ' . _('Between') . ': </b>' . ProperDate($_REQUEST['enrolled_begin']) . ' and ' . ProperDate($_REQUEST['enrolled_end']) . '<BR />';
                        }
                    } elseif ($_REQUEST['enrolled_begin']) {
                        $extra['WHERE'] .= " AND ssm.START_DATE>='" . $_REQUEST['enrolled_begin'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Enrolled') . ' ' . _('On or After') . ': </b>' . ProperDate($_REQUEST['enrolled_begin']) . '<BR />';
                        }
                    }
                    if ($_REQUEST['enrolled_end']) {
                        $extra['WHERE'] .= " AND ssm.START_DATE<='" . $_REQUEST['enrolled_end'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Enrolled') . ' ' . _('On or Before') . ': </b>' . ProperDate($_REQUEST['enrolled_end']) . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Attendance Start') . '</TD><TD><table class="cellpadding-0 cellspacing-0"><tr><td><span class="sizep2">&ge;</span>&nbsp;</td><td>' . PrepareDate('', '_enrolled_begin', true, array('short' => true)) . '</td></tr><tr><td><span class="sizep2">&le;</span>&nbsp;</td><td>' . PrepareDate('', '_enrolled_end', true, array('short' => true)) . '</td></tr></table></TD></TR>';
                }
                break;
            case 'rolled':
                if ($RosarioModules['Students']) {
                    if ($_REQUEST['rolled']) {
                        $extra['WHERE'] .= " AND " . ($_REQUEST['rolled'] == 'Y' ? '' : 'NOT ') . "exists (SELECT '' FROM STUDENT_ENROLLMENT WHERE STUDENT_ID=ssm.STUDENT_ID AND SYEAR<ssm.SYEAR)";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Previously Enrolled') . ': </b>' . ($_REQUEST['rolled'] == 'Y' ? _('Yes') : _('No')) . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Previously Enrolled') . '</TD><TD><label><INPUT type="radio" value="" name="rolled" checked /> ' . _('N/A') . '</label> &nbsp;<label><INPUT type="radio" value="Y" name="rolled"> ' . _('Yes') . '</label> &nbsp;<label><INPUT type="radio" value="N" name="rolled"> ' . _('No') . '</label></TD></TR>';
                }
                break;
            case 'fsa_balance_warning':
                $value = $GLOBALS['warning'];
                $item = 'fsa_balance';
            case 'fsa_balance':
                if ($RosarioModules['Food_Service']) {
                    if ($_REQUEST['fsa_balance'] != '') {
                        if (!mb_strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ',FOOD_SERVICE_STUDENT_ACCOUNTS fssa';
                            $extra['WHERE'] .= ' AND fssa.STUDENT_ID=s.STUDENT_ID';
                        }
                        $extra['FROM'] .= ",FOOD_SERVICE_ACCOUNTS fsa";
                        $extra['WHERE'] .= " AND fsa.ACCOUNT_ID=fssa.ACCOUNT_ID AND fsa.BALANCE" . ($_REQUEST['fsa_bal_ge'] == 'Y' ? '>=' : '<') . "'" . round($_REQUEST['fsa_balance'], 2) . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Food Service Balance') . ': </b><span class="sizep2">' . ($_REQUEST['fsa_bal_ge'] == 'Y' ? '&ge;' : '&lt;') . number_format($_REQUEST['fsa_balance'], 2) . '</span><BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Balance') . '</TD><TD><table class="cellpadding-0 cellspacing-0"><tr><td><label><span class="sizep2">&lt;</span> <INPUT type="radio" name="fsa_bal_ge" value="" checked /></label></td><td rowspan="2"><INPUT type="text" name="fsa_balance" size=10' . ($value ? ' value="' . $value . '"' : '') . '></label></td></tr><tr><td><label><span class="sizep2">&ge;</span> <INPUT type="radio" name="fsa_bal_ge" value=Y></label></td></tr></table></TD></TR>';
                }
                break;
            case 'fsa_discount':
                if ($RosarioModules['Food_Service']) {
                    if ($_REQUEST['fsa_discount']) {
                        if (!mb_strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        if ($_REQUEST['fsa_discount'] == 'Full') {
                            $extra['WHERE'] .= " AND fssa.DISCOUNT IS NULL";
                        } else {
                            $extra['WHERE'] .= " AND fssa.DISCOUNT='" . $_REQUEST['fsa_discount'] . "'";
                        }
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Food Service Discount') . ': </b>' . $_REQUEST['fsa_discount'] . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Discount') . '</TD><TD><SELECT name=fsa_discount><OPTION value="">' . _('Not Specified') . '</OPTION><OPTION value="Full">' . _('Full') . '</OPTION><OPTION value="Reduced">' . _('Reduced') . '</OPTION><OPTION value="Free">' . _('Free') . '</OPTION></SELECT></TD></TR>';
                }
                break;
            case 'fsa_status_active':
                $value = 'active';
                $item = 'fsa_status';
            case 'fsa_status':
                if ($RosarioModules['Food_Service']) {
                    if ($_REQUEST['fsa_status']) {
                        if (!mb_strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        if ($_REQUEST['fsa_status'] == 'Active') {
                            $extra['WHERE'] .= " AND fssa.STATUS IS NULL";
                        } else {
                            $extra['WHERE'] .= " AND fssa.STATUS='" . $_REQUEST['fsa_status'] . "'";
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Account Status') . '</TD><TD><SELECT name=fsa_status><OPTION value="">' . _('Not Specified') . '</OPTION><OPTION value="Active"' . ($value == 'active' ? ' SELECTED="SELECTED"' : '') . '>' . _('Active') . '</OPTION><OPTION value="Inactive">' . _('Inactive') . '</OPTION><OPTION value="Disabled">' . _('Disabled') . '</OPTION><OPTION value="Closed">' . _('Closed') . '</OPTION></SELECT></TD></TR>';
                }
                break;
            case 'fsa_barcode':
                if ($RosarioModules['Food_Service']) {
                    if ($_REQUEST['fsa_barcode']) {
                        if (!mb_strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        $extra['WHERE'] .= " AND fssa.BARCODE='" . $_REQUEST['fsa_barcode'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Food Service Barcode') . ': </b>' . $_REQUEST['fsa_barcode'] . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Barcode') . '</TD><TD><INPUT type="text" name="fsa_barcode" size="15"></TD></TR>';
                }
                break;
            case 'fsa_account_id':
                if ($RosarioModules['Food_Service']) {
                    if ($_REQUEST['fsa_account_id']) {
                        if (!mb_strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        $extra['WHERE'] .= " AND fssa.ACCOUNT_ID='" . ($_REQUEST['fsa_account_id'] + 0) . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_ROSARIO['SearchTerms'] .= '<b>' . _('Food Service Account ID') . ': </b>' . ($_REQUEST['fsa_account_id'] + 0) . '<BR />';
                        }
                    }
                    $extra['search'] .= '<TR><TD style="text-align:right; width:120px:">' . _('Account ID') . '</TD><TD><INPUT type="text" name="fsa_account_id" size="15"></TD></TR>';
                }
                break;
        }
        $_ROSARIO['Widgets'][$item] = true;
    }
}
Beispiel #10
0
function calcSeats1($period, &$total_seats, &$filled_seats)
{
    if ($_REQUEST['include_child_mps']) {
        $mps = GetChildrenMP($period['MP'], $period['MARKING_PERIOD_ID']);
        if ($period['MP'] == 'FY' || $period['MP'] == 'SEM') {
            $mps = "'{$period['MARKING_PERIOD_ID']}'" . ($mps ? ',' . $mps : '');
        }
    } else {
        $mps = "'" . $period['MARKING_PERIOD_ID'] . "'";
    }
    foreach (explode(',', $mps) as $mp) {
        $mp = trim($mp, "'");
        $seats = DBGet(DBQuery("SELECT max((SELECT count(1) FROM SCHEDULE ss JOIN STUDENT_ENROLLMENT sem ON (sem.STUDENT_ID=ss.STUDENT_ID AND sem.SYEAR=ss.SYEAR) WHERE ss.COURSE_PERIOD_ID='{$period['COURSE_PERIOD_ID']}' AND (ss.MARKING_PERIOD_ID='{$mp}' OR ss.MARKING_PERIOD_ID IN (" . GetAllMP(GetMP($mp, 'MP'), $mp) . ")) AND (ac.SCHOOL_DATE>=ss.START_DATE AND (ss.END_DATE IS NULL OR ac.SCHOOL_DATE<=ss.END_DATE)) AND (ac.SCHOOL_DATE>=sem.START_DATE AND (sem.END_DATE IS NULL OR ac.SCHOOL_DATE<=sem.END_DATE)))) AS FILLED_SEATS FROM ATTENDANCE_CALENDAR ac WHERE ac.CALENDAR_ID='{$period['CALENDAR_ID']}' AND ac.SCHOOL_DATE BETWEEN " . db_case(array("(CURRENT_DATE>'" . GetMP($mp, 'END_DATE') . "')", 'TRUE', "'" . GetMP($mp, 'START_DATE') . "'", 'CURRENT_DATE')) . " AND '" . GetMP($mp, 'END_DATE') . "'"));
        if ($_REQUEST['include_child_mps']) {
            if ($total_seats[$mp] !== false) {
                if ($period['TOTAL_SEATS']) {
                    $total_seats[$mp] += $period['TOTAL_SEATS'];
                } else {
                    $total_seats[$mp] = false;
                }
            }
            if ($filled_seats !== false) {
                if ($seats[1]['FILLED_SEATS'] != '') {
                    $filled_seats[$mp] += $seats[1]['FILLED_SEATS'];
                } else {
                    $filled_seats[$mp] = false;
                }
            }
        } else {
            if ($total_seats !== false) {
                if ($period['TOTAL_SEATS']) {
                    $total_seats += $period['TOTAL_SEATS'];
                } else {
                    $total_seats = false;
                }
            }
            if ($filled_seats !== false) {
                if ($seats[1]['FILLED_SEATS'] != '') {
                    $filled_seats += $seats[1]['FILLED_SEATS'];
                } else {
                    $filled_seats = false;
                }
            }
        }
    }
}
function GetAllMP($mp, $marking_period_id = '0')
{
    global $_ROSARIO;
    if ($marking_period_id == 0) {
        // there should be exactly one fy marking period
        $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='FY' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
        $marking_period_id = $RET[1]['MARKING_PERIOD_ID'];
        $mp = 'FY';
    } elseif (!$mp) {
        $mp = GetMP($marking_period_id, 'MP');
    }
    if (!isset($_ROSARIO['GetAllMP'][$mp])) {
        switch ($mp) {
            case 'PRO':
                // there should be exactly one fy marking period
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='FY' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                $fy = $RET[1]['MARKING_PERIOD_ID'];
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,PARENT_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='QTR' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                foreach ($RET as $value) {
                    $_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = "'{$fy}','{$value['PARENT_ID']}','{$value['MARKING_PERIOD_ID']}'";
                    $_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] .= ',' . GetChildrenMP($mp, $value['MARKING_PERIOD_ID']);
                    if (mb_substr($_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']], -1) == ',') {
                        $_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = mb_substr($_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']], 0, -1);
                    }
                }
                break;
            case 'QTR':
                // there should be exactly one fy marking period
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='FY' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                $fy = $RET[1]['MARKING_PERIOD_ID'];
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,PARENT_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='QTR' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                foreach ($RET as $value) {
                    $_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = "'{$fy}','{$value['PARENT_ID']}','{$value['MARKING_PERIOD_ID']}'";
                }
                break;
            case 'SEM':
                // there should be exactly one fy marking period
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='FY' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                $fy = $RET[1]['MARKING_PERIOD_ID'];
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,PARENT_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='QTR' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"), array(), array('PARENT_ID'));
                foreach ($RET as $sem => $value) {
                    $_ROSARIO['GetAllMP'][$mp][$sem] = "'{$fy}','{$sem}'";
                    foreach ($value as $qtr) {
                        $_ROSARIO['GetAllMP'][$mp][$sem] .= ",'{$qtr['MARKING_PERIOD_ID']}'";
                    }
                }
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM SCHOOL_MARKING_PERIODS s WHERE MP='SEM' AND NOT EXISTS (SELECT '' FROM SCHOOL_MARKING_PERIODS q WHERE q.MP='QTR' AND q.PARENT_ID=s.MARKING_PERIOD_ID) AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                foreach ($RET as $value) {
                    $_ROSARIO['GetAllMP'][$mp][$value['MARKING_PERIOD_ID']] = "'{$fy}','{$value['MARKING_PERIOD_ID']}'";
                }
                break;
            case 'FY':
                // there should be exactly one fy marking period which better be $marking_period_id
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,PARENT_ID FROM SCHOOL_MARKING_PERIODS WHERE MP='QTR' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"), array(), array('PARENT_ID'));
                $_ROSARIO['GetAllMP'][$mp][$marking_period_id] = "'{$marking_period_id}'";
                foreach ($RET as $sem => $value) {
                    $_ROSARIO['GetAllMP'][$mp][$marking_period_id] .= ",'{$sem}'";
                    foreach ($value as $qtr) {
                        $_ROSARIO['GetAllMP'][$mp][$marking_period_id] .= ",'{$qtr['MARKING_PERIOD_ID']}'";
                    }
                }
                $RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM SCHOOL_MARKING_PERIODS s WHERE MP='SEM' AND NOT EXISTS (SELECT '' FROM SCHOOL_MARKING_PERIODS q WHERE q.MP='QTR' AND q.PARENT_ID=s.MARKING_PERIOD_ID) AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
                foreach ($RET as $value) {
                    $_ROSARIO['GetAllMP'][$mp][$marking_period_id] .= ",'{$value['MARKING_PERIOD_ID']}'";
                }
                break;
        }
    }
    return $_ROSARIO['GetAllMP'][$mp][$marking_period_id];
}
Beispiel #12
0
function Widgets($item, $allow_widget = false)
{
    global $extra, $_openSIS;
    if (!is_array($extra['functions'])) {
        $extra['functions'] = array();
    }
    if (User('PROFILE') == 'admin' || User('PROFILE') == 'teacher' || $allow_widget) {
        switch ($item) {
            case 'course':
                if (User('PROFILE') == 'admin' || $allow_widget) {
                    if ($_REQUEST['w_course_period_id']) {
                        if ($_REQUEST['w_course_period_id_which'] == 'course') {
                            $course = DBGet(DBQuery('SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM course_periods cp,courses c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID=\'' . $_REQUEST['w_course_period_id'] . '\''));
                            $extra['FROM'] .= ',schedule w_ss';
                            $extra['WHERE'] .= ' AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_ID=\'' . $course[1]['COURSE_ID'] . '\' AND (\'' . DBDate() . '\' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)';
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Course: </b></font>' . $course[1]['COURSE_TITLE'] . '<BR>';
                        } else {
                            $extra['FROM'] .= ',schedule w_ss';
                            $extra['WHERE'] .= ' AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_PERIOD_ID=\'' . $_REQUEST['w_course_period_id'] . '\' AND (\'' . DBDate() . '\' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)';
                            $course = DBGet(DBQuery('SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM course_periods cp,courses c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID=\'' . $_REQUEST['w_course_period_id'] . '\''));
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Course Period: </b></font>' . $course[1]['COURSE_TITLE'] . ': ' . $course[1]['TITLE'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>Course</TD><TD><DIV id=course_div></DIV> <A HREF=# onclick='window.open(\"ForWindow.php?modname=miscellaneous/ChooseCourse.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>Choose</SMALL></A></TD></TR>";
                }
                break;
            case 'request':
                if (User('PROFILE') == 'admin' || $allow_widget) {
                    // PART OF THIS IS DUPLICATED IN PrintRequests.php
                    if ($_REQUEST['request_course_id']) {
                        $course = DBGet(DBQuery('SELECT c.TITLE FROM courses c WHERE c.COURSE_ID=\'' . $_REQUEST['request_course_id'] . '\''));
                        if (!$_REQUEST['not_request_course']) {
                            $extra['FROM'] .= ',schedule_requests sr';
                            $extra['WHERE'] .= ' AND sr.STUDENT_ID=s.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.SCHOOL_ID=ssm.SCHOOL_ID AND sr.COURSE_ID=\'' . $_REQUEST['request_course_id'] . '\'';
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Request: </b></font>' . $course[1]['TITLE'] . '<BR>';
                        } else {
                            $extra['WHERE'] .= ' AND NOT EXISTS (SELECT \'\' FROM schedule_requests sr WHERE sr.STUDENT_ID=ssm.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.COURSE_ID=\'' . $_REQUEST['request_course_id'] . '\') ';
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Missing Request: </b></font>' . $course[1]['TITLE'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>Request</TD><TD><DIV id=request_div></DIV> <A HREF=# onclick='window.open(\"ForWindow.php?modname=miscellaneous/ChooseRequest.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>Choose</SMALL></A></TD></TR>";
                }
                break;
            case 'absences':
                if (is_numeric($_REQUEST['absences_low']) && is_numeric($_REQUEST['absences_high'])) {
                    if ($_REQUEST['absences_low'] > $_REQUEST['absences_high']) {
                        $temp = $_REQUEST['absences_high'];
                        $_REQUEST['absences_high'] = $_REQUEST['absences_low'];
                        $_REQUEST['absences_low'] = $temp;
                    }
                    if ($_REQUEST['absences_low'] == $_REQUEST['absences_high']) {
                        $extra['WHERE'] .= ' AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM attendance_day ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (' . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ')) = \'' . $_REQUEST[absences_low] . '\'';
                    } else {
                        $extra['WHERE'] .= ' AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM attendance_day ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (' . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ')) BETWEEN \'' . $_REQUEST[absences_low] . '\' AND \'' . $_REQUEST[absences_high] . '\'';
                    }
                    switch ($_REQUEST['absences_term']) {
                        case 'FY':
                            $term = 'this school year to date';
                            break;
                        case 'SEM':
                            $term = 'this semester to date';
                            break;
                        case 'QTR':
                            $term = 'this marking period to date';
                            break;
                    }
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Days Absent ' . $term . ' between: </b></font>' . $_REQUEST['absences_low'] . ' &amp; ' . $_REQUEST['absences_high'] . '<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Days Absent<BR><INPUT type=radio name=absences_term value=FY checked>YTD<INPUT type=radio name=absences_term value=SEM>" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=absences_term value=QTR>" . GetMP(UserMP(), 'SHORT_NAME') . "</TD><TD>Between <INPUT type=text name=absences_low size=3 class=cell_small maxlength=5> &amp; <INPUT type=text name=absences_high size=3 maxlength=5 class=cell_small></TD></TR>";
                break;
            case 'gpa':
                if (is_numeric($_REQUEST['gpa_low']) && is_numeric($_REQUEST['gpa_high'])) {
                    if ($_REQUEST['gpa_low'] > $_REQUEST['gpa_high']) {
                        $temp = $_REQUEST['gpa_high'];
                        $_REQUEST['gpa_high'] = $_REQUEST['gpa_low'];
                        $_REQUEST['gpa_low'] = $temp;
                    }
                    if ($_REQUEST['list_gpa']) {
                        $extra['SELECT'] .= ',sgc.GPA,sgc.weighted_gpa, sgc.unweighted_gpa';
                        $extra['columns_after']['GPA'] = 'GPA';
                    }
                    if (strpos($extra['FROM'], 'student_gpa_calculated sgc') === false) {
                        $extra['FROM'] .= ',student_gpa_calculated sgc';
                        $extra['WHERE'] .= ' AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID=\'' . $_REQUEST['gpa_term'] . '\'';
                    }
                    $extra['WHERE'] .= ' AND sgc.GPA BETWEEN \'' . $_REQUEST[gpa_low] . '\' AND \'' . $_REQUEST[gpa_high] . '\' AND sgc.MARKING_PERIOD_ID=\'' . $_REQUEST['gpa_term'] . '\'';
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>' . ($_REQUEST['gpa_weighted'] == 'Y' ? 'Weighted ' : '') . 'GPA between: </b></font>' . $_REQUEST['gpa_low'] . ' &amp; ' . $_REQUEST['gpa_high'] . '<BR>';
                }
                if (is_numeric($_REQUEST['cgpa_low']) && is_numeric($_REQUEST['cgpa_high'])) {
                    if ($_REQUEST['cgpa_low'] > $_REQUEST['cgpa_high']) {
                        $temp = $_REQUEST['cgpa_high'];
                        $_REQUEST['cgpa_high'] = $_REQUEST['cgpa_low'];
                        $_REQUEST['cgpa_low'] = $temp;
                    }
                    if ($_REQUEST['cgpa']) {
                        $extra['SELECT'] .= ',sgr.CGPA';
                        $extra['columns_after']['CGPA'] = 'CGPA';
                    }
                    //
                    if (strpos($extra['FROM'], 'student_gpa_runnings sgr') === false) {
                        $extra['FROM'] .= ',student_gpa_calculated sgr';
                        $extra['WHERE'] .= ' AND sgr.STUDENT_ID=s.STUDENT_ID ';
                    }
                    $extra['WHERE'] .= ' AND sgr.CGPA BETWEEN ' . $_REQUEST[cgpa_low] . ' AND ' . $_REQUEST[cgpa_high] . ' ';
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>CGPA between: </b></font>' . $_REQUEST['cgpa_low'] . ' &amp; ' . $_REQUEST['cgpa_high'] . '<BR>';
                }
                $qrtrs_query = DBGet(DBQuery('SELECT COUNT(*) as QUARTER FROM school_quarters where SCHOOL_ID=\'' . UserSchool() . '\' and SYEAR=\'' . UserSyear() . '\''));
                if ($qrtrs_query[1]['QUARTER'] > 1) {
                    $extra['search'] .= "<TR><TD align=right width=120><INPUT type=checkbox name=list_gpa value=Y>Marking Period GPA</TD></TR>\r\n                                                    <TR><TD align=right width=120><INPUT type=radio name=gpa_term value=" . GetParentMP('SEM', UserMP()) . ">" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "\r\n                                                                                                                 <INPUT type=radio name=gpa_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "</TD>\r\n                                                                                                                <TD>Between<INPUT type=text name=gpa_low class=cell_small size=3 maxlength=5> &amp; <INPUT type=text name=gpa_high size=3 maxlength=5 class=cell_small></TD></TR>";
                }
                if ($qrtrs_query[1]['QUARTER'] <= 1) {
                    $extra['search'] .= "<TR><TD align=right width=120><INPUT type=checkbox name=list_gpa value=Y>Marking Period GPA</TD></TR>\r\n                                                    <TR><TD align=right width=120>" . "<INPUT type=radio name=gpa_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "</TD>\r\n                                                                                                                <TD>Between<INPUT type=text name=gpa_low class=cell_small size=3 maxlength=5> &amp; <INPUT type=text name=gpa_high size=3 maxlength=5 class=cell_small></TD></TR>";
                }
                $extra['search'] .= "<TR><TD align=right width=120><INPUT type=checkbox name=cgpa value=Y>CGPA</TD></TR>\r\n                                                    <TR><TD align=right width=120></td><td>Between<INPUT type=text name=cgpa_low class=cell_small size=3 maxlength=5> &amp; <INPUT type=text name=cgpa_high size=3 maxlength=5 class=cell_small></TD></TR>";
                break;
            case 'class_rank':
                if (is_numeric($_REQUEST['class_rank_low']) && is_numeric($_REQUEST['class_rank_high'])) {
                    if ($_REQUEST['class_rank_low'] > $_REQUEST['class_rank_high']) {
                        $temp = $_REQUEST['class_rank_high'];
                        $_REQUEST['class_rank_high'] = $_REQUEST['class_rank_low'];
                        $_REQUEST['class_rank_low'] = $temp;
                    }
                    if (strpos($extra['FROM'], 'student_gpa_calculated sgc') === false) {
                        $extra['FROM'] .= ',student_gpa_calculated sgc';
                        $extra['WHERE'] .= ' AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID=\'' . $_REQUEST['class_rank_term'] . '\'';
                    }
                    $extra['WHERE'] .= ' AND sgc.CLASS_RANK BETWEEN \'' . $_REQUEST[class_rank_low] . '\' AND \'' . $_REQUEST[class_rank_high] . '\'';
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Class Rank between: </b></font>' . $_REQUEST['class_rank_low'] . ' &amp; ' . $_REQUEST['class_rank_high'] . '<BR>';
                }
                $qrtrs_query = DBGet(DBQuery('SELECT COUNT(*) as QUARTER FROM school_quarters where SCHOOL_ID=\'' . UserSchool() . '\' and SYEAR=\'' . UserSyear() . '\''));
                if ($qrtrs_query[1]['QUARTER'] > 1) {
                    $extra['search'] .= "<TR><TD align=right width=120>Class Rank<BR><INPUT type=radio name=class_rank_term value=CUM checked>Cumulative<INPUT type=radio name=class_rank_term value=" . GetParentMP('SEM', UserMP()) . ">" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=class_rank_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "";
                }
                if ($qrtrs_query[1]['QUARTER'] <= 1) {
                    $extra['search'] .= "<TR><TD align=right width=120>Class Rank<BR><INPUT type=radio name=class_rank_term value=CUM checked>Cumulative" . "<INPUT type=radio name=class_rank_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "";
                }
                if (strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                    $pros = explode(',', str_replace("'", '', $pros));
                    foreach ($pros as $pro) {
                        $extra['search'] .= "<INPUT type=radio name=class_rank_term value=" . $pro . ">" . GetMP($pro, 'SHORT_NAME') . "";
                    }
                }
                $extra['search'] .= "</TD><TD>Between<INPUT type=text name=class_rank_low size=3 maxlength=5 class=cell_small> &amp; <INPUT type=text name=class_rank_high size=3 maxlength=5 class=cell_small></TD></TR>";
                break;
            case 'letter_grade':
                if (count($_REQUEST['letter_grade'])) {
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>With' . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'out' : '') . ' Report Card Grade: </b></font>';
                    $letter_grades_RET = DBGet(DBQuery('SELECT ID,TITLE FROM report_card_grades WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\''), array(), array('ID'));
                    foreach ($_REQUEST['letter_grade'] as $grade => $Y) {
                        $letter_grades .= ",'{$grade}'";
                        $_openSIS['SearchTerms'] .= $letter_grades_RET[$grade][1]['TITLE'] . ', ';
                    }
                    $_openSIS['SearchTerms'] = substr($_openSIS['SearchTerms'], 0, -2);
                    $extra['WHERE'] .= " AND " . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'NOT ' : '') . "EXISTS (SELECT '' FROM student_report_card_grades sg3 WHERE sg3.STUDENT_ID=ssm.STUDENT_ID AND sg3.SYEAR=ssm.SYEAR AND sg3.REPORT_CARD_GRADE_ID IN (" . substr($letter_grades, 1) . ")" . ($_REQUEST['letter_grade_term'] != '' ? "AND sg3.MARKING_PERIOD_ID='" . $_REQUEST['letter_grade_term'] . "' " : '') . ")";
                    $_openSIS['SearchTerms'] .= '<BR>';
                }
                $qrtrs_query = DBGet(DBQuery('SELECT COUNT(*) as QUARTER FROM school_quarters where SCHOOL_ID=\'' . UserSchool() . '\' and SYEAR=\'' . UserSyear() . '\''));
                if ($qrtrs_query[1]['QUARTER'] > 1) {
                    $extra['search'] .= "<TR><TD align=right width=120>Letter Grade<BR><INPUT type=checkbox name=letter_grade_exclude value=Y>Did not receive<BR><INPUT type=radio name=letter_grade_term value=" . GetParentMP('SEM', UserMP()) . ">" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=letter_grade_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "";
                }
                if ($qrtrs_query[1]['QUARTER'] <= 1) {
                    $extra['search'] .= "<TR><TD align=right width=120>Letter Grade<BR><INPUT type=checkbox name=letter_grade_exclude value=Y>Did not receive<BR>" . "<INPUT type=radio name=letter_grade_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "";
                }
                if (strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                    $pros = explode(',', str_replace("'", '', $pros));
                    foreach ($pros as $pro) {
                        $extra['search'] .= "<INPUT type=radio name=letter_grade_term value=" . $pro . ">" . GetMP($pro, 'SHORT_NAME') . "";
                    }
                }
                $extra['search'] .= "</TD><TD>";
                if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                    $letter_grades_RET = DBGet(DBQuery('SELECT rg.ID,rg.TITLE,rg.GRADE_SCALE_ID FROM report_card_grades rg,report_card_grade_scales rs WHERE rg.SCHOOL_ID=\'' . UserSchool() . '\' AND rg.SYEAR=\'' . UserSyear() . '\' AND rs.ID=rg.GRADE_SCALE_ID' . (User('PROFILE') == 'teacher' ? ' AND rg.GRADE_SCALE_ID=(SELECT GRADE_SCALE_ID FROM course_periods WHERE COURSE_PERIOD_ID=\'' . UserCoursePeriod() . '\')' : '') . ' ORDER BY rs.SORT_ORDER,rs.ID,rg.BREAK_OFF IS NOT NULL DESC,rg.BREAK_OFF DESC,rg.SORT_ORDER'), array(), array('GRADE_SCALE_ID'));
                }
                foreach ($letter_grades_RET as $grades) {
                    $i = 0;
                    if (count($grades)) {
                        foreach ($grades as $grade) {
                            if ($i % 9 == 0) {
                                $extra['search'] .= '<BR>';
                            }
                            $extra['search'] .= '<INPUT type=checkbox value=Y name=letter_grade[' . $grade['ID'] . ']>' . $grade['TITLE'];
                            $i++;
                        }
                    }
                }
                $extra['search'] .= '</TD></TR>';
                break;
            case 'eligibility':
                if ($_REQUEST['ineligible'] == 'Y') {
                    $start_end_RET = DBGet(DBQuery('SELECT TITLE,VALUE FROM program_config WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\' AND PROGRAM=\'eligibility\' AND TITLE IN (\'START_DAY\',\'END_DAY\')'));
                    if (count($start_end_RET)) {
                        foreach ($start_end_RET as $value) {
                            ${$value}['TITLE'] = $value['VALUE'];
                        }
                    }
                    switch (date('D')) {
                        case 'Mon':
                            $today = 1;
                            break;
                        case 'Tue':
                            $today = 2;
                            break;
                        case 'Wed':
                            $today = 3;
                            break;
                        case 'Thu':
                            $today = 4;
                            break;
                        case 'Fri':
                            $today = 5;
                            break;
                        case 'Sat':
                            $today = 6;
                            break;
                        case 'Sun':
                            $today = 7;
                            break;
                    }
                    $start_date = strtoupper(date('d-M-y', time() - ($today - $START_DAY) * 60 * 60 * 24));
                    $end_date = strtoupper(date('d-M-y', time()));
                    $extra['WHERE'] .= ' AND (SELECT count(*) FROM eligibility e WHERE ssm.STUDENT_ID=e.STUDENT_ID AND e.SYEAR=ssm.SYEAR AND e.SCHOOL_DATE BETWEEN \'' . $start_date . '\' AND \'' . $end_date . '\' AND e.ELIGIBILITY_CODE=\'FAILING\') > \'0\'';
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Extracurricular: </b></font>Ineligible<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Ineligible</TD><TD><INPUT type=checkbox name=ineligible value='Y'></TD></TR>";
                break;
            case 'activity':
                if ($_REQUEST['activity_id']) {
                    $extra['FROM'] .= ',student_eligibility_activities sea';
                    $extra['WHERE'] .= ' AND sea.STUDENT_ID=s.STUDENT_ID AND sea.SYEAR=ssm.SYEAR AND sea.ACTIVITY_ID=\'' . $_REQUEST['activity_id'] . '\'';
                    $activity = DBGet(DBQuery('SELECT TITLE FROM eligibility_activities WHERE ID=\'' . $_REQUEST['activity_id'] . '\''));
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Activity: </b></font>' . $activity[1]['TITLE'] . '<BR>';
                }
                if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                    $activities_RET = DBGet(DBQuery('SELECT ID,TITLE FROM eligibility_activities WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\''));
                }
                $select = "<SELECT name=activity_id><OPTION value=''>Not Specified</OPTION>";
                if (count($activities_RET)) {
                    foreach ($activities_RET as $activity) {
                        $select .= "<OPTION value={$activity['ID']}>{$activity['TITLE']}</OPTION>";
                    }
                }
                $select .= '</SELECT>';
                $extra['search'] .= "<TR><TD align=right width=120>Activity</TD><TD>" . $select . "</TD></TR>";
                break;
            case 'mailing_labels':
                if ($_REQUEST['mailing_labels'] == 'Y') {
                    $extra['SELECT'] .= ',sam.ID AS MAILING_LABEL';
                    $extra['FROM'] = ' LEFT OUTER JOIN student_address sam ON (sam.STUDENT_ID=ssm.STUDENT_ID AND sam.TYPE=\'Home Address\' )' . $extra['FROM'];
                    $extra['functions'] += array('MAILING_LABEL' => 'MailingLabel');
                }
                $extra['search'] .= '<TR><TD align=right width=120>Mailing Labels</TD><TD><INPUT type=checkbox name=mailing_labels value=Y></TD>';
                break;
            case 'balance':
                if (is_numeric($_REQUEST['balance_low']) && is_numeric($_REQUEST['balance_high'])) {
                    if ($_REQUEST['balance_low'] > $_REQUEST['balance_high']) {
                        $temp = $_REQUEST['balance_high'];
                        $_REQUEST['balance_high'] = $_REQUEST['balance_low'];
                        $_REQUEST['balance_low'] = $temp;
                    }
                    $extra['WHERE'] .= ' AND (COALESCE((SELECT SUM(f.AMOUNT) FROM BILLING_FEES f,STUDENTS_JOIN_FEES sjf WHERE sjf.FEE_ID=f.ID AND sjf.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR),0)+(SELECT COALESCE(SUM(f.AMOUNT),0)-COALESCE(SUM(f.CASH),0) FROM LUNCH_TRANSACTIONS f WHERE f.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR)-COALESCE((SELECT SUM(p.AMOUNT) FROM BILLING_PAYMENTS p WHERE p.STUDENT_ID=ssm.STUDENT_ID AND p.SYEAR=ssm.SYEAR),0)) BETWEEN \'' . $_REQUEST[balance_low] . '\' AND \'' . $_REQUEST[balance_high] . '\' ';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Student Billing Balance<BR></TD><TD>Between<INPUT type=text name=balance_low size=5 maxlength=10 class=cell_small> &amp; <INPUT type=text name=balance_high size=5 maxlength=10 class=cell_small></TD></TR>";
                break;
                ############################ ##########################################################
            ############################ ##########################################################
            case 'parents':
                $extra['search'] .= "<TR><TD align=right width=120>Show Parents & Contacts<BR></TD><TD><INPUT type=radio name=show value=P></TD></TR>";
                break;
                ############################  ##########################################################
            ############################  ##########################################################
            case 'staff':
                $extra['search'] .= "<TR><TD align=right width=120>Show Staff<BR></TD><TD><INPUT type=radio name=show value=S></TD></TR>";
                break;
                ####################################################################################################################
                break;
        }
    }
}
Beispiel #13
0
function Widgets($item, $allow_widget = false)
{
    global $extra, $_openSIS;
    if (!is_array($extra['functions'])) {
        $extra['functions'] = array();
    }
    if (User('PROFILE') == 'admin' || User('PROFILE') == 'teacher' || $allow_widget) {
        switch ($item) {
            case 'course':
                if (User('PROFILE') == 'admin' || $allow_widget) {
                    if ($_REQUEST['w_course_period_id']) {
                        if ($_REQUEST['w_course_period_id_which'] == 'course') {
                            $course = DBGet(DBQuery("SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM COURSE_PERIODS cp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'"));
                            $extra['FROM'] .= ",SCHEDULE w_ss";
                            $extra['WHERE'] .= " AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_ID='" . $course[1]['COURSE_ID'] . "' AND ('" . DBDate() . "' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)";
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Course: </b></font>' . $course[1]['COURSE_TITLE'] . '<BR>';
                        } else {
                            $extra['FROM'] .= ",SCHEDULE w_ss";
                            $extra['WHERE'] .= " AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "' AND ('" . DBDate() . "' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)";
                            $course = DBGet(DBQuery("SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM COURSE_PERIODS cp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'"));
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Course Period: </b></font>' . $course[1]['COURSE_TITLE'] . ': ' . $course[1]['TITLE'] . '<BR>';
                        }
                    }
                    #	$extra['search'] .= "<TR><TD align=right width=120>Course</TD><TD><DIV id=course_div></DIV> <A HREF=# onclick='window.open(\"Modules.php?modname=misc/ChooseCourse.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>Choose</SMALL></A></TD></TR>";
                    $extra['search'] .= "<TR><TD align=right width=120>Course</TD><TD><DIV id=course_div></DIV> <A HREF=# onclick='window.open(\"for_window.php?modname=misc/ChooseCourse.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>Choose</SMALL></A></TD></TR>";
                }
                break;
            case 'request':
                if (User('PROFILE') == 'admin' || $allow_widget) {
                    // PART OF THIS IS DUPLICATED IN PrintRequests.php
                    if ($_REQUEST['request_course_id']) {
                        $course = DBGet(DBQuery("SELECT c.TITLE FROM COURSES c WHERE c.COURSE_ID='" . $_REQUEST['request_course_id'] . "'"));
                        if (!$_REQUEST['not_request_course']) {
                            $extra['FROM'] .= ",SCHEDULE_REQUESTS sr";
                            $extra['WHERE'] .= " AND sr.STUDENT_ID=s.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.SCHOOL_ID=ssm.SCHOOL_ID AND sr.COURSE_ID='" . $_REQUEST['request_course_id'] . "'";
                            //"' AND sr.COURSE_WEIGHT='".$_REQUEST['request_course_weight']."'";
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Request: </b></font>' . $course[1]['TITLE'] . '<BR>';
                            //.' - '.$_REQUEST['request_course_weight'].'<BR>';
                        } else {
                            $extra['WHERE'] .= " AND NOT EXISTS (SELECT '' FROM SCHEDULE_REQUESTS sr WHERE sr.STUDENT_ID=ssm.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.COURSE_ID='" . $_REQUEST['request_course_id'] . "') ";
                            //."' AND sr.COURSE_WEIGHT='".$_REQUEST['request_course_weight']."') ";
                            $_openSIS['SearchTerms'] .= '<font color=gray><b>Missing Request: </b></font>' . $course[1]['TITLE'] . '<BR>';
                            //.' - '.$_REQUEST['request_course_weight'].'<BR>';
                        }
                    }
                    #		$extra['search'] .= "<TR><TD align=right width=120>Request</TD><TD><DIV id=request_div></DIV> <A HREF=# onclick='window.open(\"Modules.php?modname=misc/ChooseRequest.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>Choose</SMALL></A></TD></TR>";
                    $extra['search'] .= "<TR><TD align=right width=120>Request</TD><TD><DIV id=request_div></DIV> <A HREF=# onclick='window.open(\"for_window.php?modname=misc/ChooseRequest.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>Choose</SMALL></A></TD></TR>";
                }
                break;
            case 'absences':
                if (is_numeric($_REQUEST['absences_low']) && is_numeric($_REQUEST['absences_high'])) {
                    if ($_REQUEST['absences_low'] > $_REQUEST['absences_high']) {
                        $temp = $_REQUEST['absences_high'];
                        $_REQUEST['absences_high'] = $_REQUEST['absences_low'];
                        $_REQUEST['absences_low'] = $temp;
                    }
                    if ($_REQUEST['absences_low'] == $_REQUEST['absences_high']) {
                        $extra['WHERE'] .= " AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM ATTENDANCE_DAY ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (" . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ")) = '{$_REQUEST['absences_low']}'";
                    } else {
                        $extra['WHERE'] .= " AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM ATTENDANCE_DAY ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (" . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ")) BETWEEN '{$_REQUEST['absences_low']}' AND '{$_REQUEST['absences_high']}'";
                    }
                    switch ($_REQUEST['absences_term']) {
                        case 'FY':
                            $term = 'this school year to date';
                            break;
                        case 'SEM':
                            $term = 'this semester to date';
                            break;
                        case 'QTR':
                            $term = 'this marking period to date';
                            break;
                    }
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Days Absent ' . $term . ' between: </b></font>' . $_REQUEST['absences_low'] . ' &amp; ' . $_REQUEST['absences_high'] . '<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Days Absent<BR><INPUT type=radio name=absences_term value=FY checked>YTD<INPUT type=radio name=absences_term value=SEM>" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=absences_term value=QTR>" . GetMP(UserMP(), 'SHORT_NAME') . "</TD><TD>Between <INPUT type=text name=absences_low size=3 class=cell_small maxlength=5> &amp; <INPUT type=text name=absences_high size=3 maxlength=5 class=cell_small></TD></TR>";
                break;
            case 'gpa':
                if (is_numeric($_REQUEST['gpa_low']) && is_numeric($_REQUEST['gpa_high'])) {
                    if ($_REQUEST['gpa_low'] > $_REQUEST['gpa_high']) {
                        $temp = $_REQUEST['gpa_high'];
                        $_REQUEST['gpa_high'] = $_REQUEST['gpa_low'];
                        $_REQUEST['gpa_low'] = $temp;
                    }
                    if ($_REQUEST['list_gpa']) {
                        $extra['SELECT'] .= ',sgc.WEIGHTED_GPA,sgc.UNWEIGHTED_GPA';
                        $extra['columns_after']['WEIGHTED_GPA'] = 'Weighted GPA';
                        $extra['columns_after']['UNWEIGHTED_GPA'] = 'Unweighted GPA';
                    }
                    if (strpos($extra['FROM'], 'STUDENT_GPA_CALCULATED sgc') === false) {
                        $extra['FROM'] .= ",STUDENT_GPA_CALCULATED sgc";
                        $extra['WHERE'] .= " AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID='" . $_REQUEST['gpa_term'] . "'";
                    }
                    $extra['WHERE'] .= " AND sgc." . ($_REQUEST['weighted'] == 'Y' ? 'WEIGHTED_' : '') . "GPA BETWEEN '{$_REQUEST['gpa_low']}' AND '{$_REQUEST['gpa_high']}' AND sgc.MARKING_PERIOD_ID='" . $_REQUEST['gpa_term'] . "'";
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>' . ($_REQUEST['gpa_weighted'] == 'Y' ? 'Weighted ' : '') . 'GPA between: </b></font>' . $_REQUEST['gpa_low'] . ' &amp; ' . $_REQUEST['gpa_high'] . '<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>GPA<BR><INPUT type=checkbox name=gpa_weighted value=Y>Weighted<BR><INPUT type=radio name=gpa_term value=CUM checked>Cumulative<INPUT type=radio name=gpa_term value=" . GetParentMP('SEM', UserMP()) . ">" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=gpa_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "</TD><TD>Between<INPUT type=text name=gpa_low class=cell_small size=3 maxlength=5> &amp; <INPUT type=text name=gpa_high size=3 maxlength=5 class=cell_small></TD></TR>";
                break;
            case 'class_rank':
                if (is_numeric($_REQUEST['class_rank_low']) && is_numeric($_REQUEST['class_rank_high'])) {
                    if ($_REQUEST['class_rank_low'] > $_REQUEST['class_rank_high']) {
                        $temp = $_REQUEST['class_rank_high'];
                        $_REQUEST['class_rank_high'] = $_REQUEST['class_rank_low'];
                        $_REQUEST['class_rank_low'] = $temp;
                    }
                    if (strpos($extra['FROM'], 'STUDENT_GPA_CALCULATED sgc') === false) {
                        $extra['FROM'] .= ",STUDENT_GPA_CALCULATED sgc";
                        $extra['WHERE'] .= " AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID='" . $_REQUEST['class_rank_term'] . "'";
                    }
                    $extra['WHERE'] .= " AND sgc.CLASS_RANK BETWEEN '{$_REQUEST['class_rank_low']}' AND '{$_REQUEST['class_rank_high']}'";
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Class Rank between: </b></font>' . $_REQUEST['class_rank_low'] . ' &amp; ' . $_REQUEST['class_rank_high'] . '<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Class Rank<BR><INPUT type=radio name=class_rank_term value=CUM checked>Cumulative<INPUT type=radio name=class_rank_term value=" . GetParentMP('SEM', UserMP()) . ">" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=class_rank_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "";
                if (strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                    $pros = explode(',', str_replace("'", '', $pros));
                    foreach ($pros as $pro) {
                        $extra['search'] .= "<INPUT type=radio name=class_rank_term value=" . $pro . ">" . GetMP($pro, 'SHORT_NAME') . "";
                    }
                }
                $extra['search'] .= "</TD><TD>Between<INPUT type=text name=class_rank_low size=3 maxlength=5 class=cell_small> &amp; <INPUT type=text name=class_rank_high size=3 maxlength=5 class=cell_small></TD></TR>";
                break;
            case 'letter_grade':
                if (count($_REQUEST['letter_grade'])) {
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>With' . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'out' : '') . ' Report Card Grade: </b></font>';
                    $letter_grades_RET = DBGet(DBQuery("SELECT ID,TITLE FROM REPORT_CARD_GRADES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"), array(), array('ID'));
                    foreach ($_REQUEST['letter_grade'] as $grade => $Y) {
                        $letter_grades .= ",'{$grade}'";
                        $_openSIS['SearchTerms'] .= $letter_grades_RET[$grade][1]['TITLE'] . ', ';
                    }
                    $_openSIS['SearchTerms'] = substr($_openSIS['SearchTerms'], 0, -2);
                    $extra['WHERE'] .= " AND " . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'NOT ' : '') . "EXISTS (SELECT '' FROM STUDENT_REPORT_CARD_GRADES sg3 WHERE sg3.STUDENT_ID=ssm.STUDENT_ID AND sg3.SYEAR=ssm.SYEAR AND sg3.REPORT_CARD_GRADE_ID IN (" . substr($letter_grades, 1) . ") AND sg3.MARKING_PERIOD_ID='" . $_REQUEST['letter_grade_term'] . "' )";
                    $_openSIS['SearchTerms'] .= '<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Letter Grade<BR><INPUT type=checkbox name=letter_grade_exclude value=Y>Did not receive<BR><INPUT type=radio name=letter_grade_term value=" . GetParentMP('SEM', UserMP()) . ">" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "<INPUT type=radio name=letter_grade_term value=" . UserMP() . ">" . GetMP(UserMP(), 'SHORT_NAME') . "";
                if (strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                    $pros = explode(',', str_replace("'", '', $pros));
                    foreach ($pros as $pro) {
                        $extra['search'] .= "<INPUT type=radio name=letter_grade_term value=" . $pro . ">" . GetMP($pro, 'SHORT_NAME') . "";
                    }
                }
                $extra['search'] .= "</TD><TD>";
                if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                    $letter_grades_RET = DBGet(DBQuery("SELECT rg.ID,rg.TITLE,rg.GRADE_SCALE_ID FROM REPORT_CARD_GRADES rg,REPORT_CARD_GRADE_SCALES rs WHERE rg.SCHOOL_ID='" . UserSchool() . "' AND rg.SYEAR='" . UserSyear() . "' AND rs.ID=rg.GRADE_SCALE_ID" . (User('PROFILE') == 'teacher' ? ' AND rg.GRADE_SCALE_ID=(SELECT GRADE_SCALE_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID=\'' . UserCoursePeriod() . '\')' : '') . " ORDER BY rs.SORT_ORDER,rs.ID,rg.BREAK_OFF IS NOT NULL DESC,rg.BREAK_OFF DESC,rg.SORT_ORDER"), array(), array('GRADE_SCALE_ID'));
                }
                foreach ($letter_grades_RET as $grades) {
                    $i = 0;
                    if (count($grades)) {
                        foreach ($grades as $grade) {
                            if ($i % 9 == 0) {
                                $extra['search'] .= '<BR>';
                            }
                            $extra['search'] .= '<INPUT type=checkbox value=Y name=letter_grade[' . $grade['ID'] . ']>' . $grade['TITLE'];
                            $i++;
                        }
                    }
                }
                $extra['search'] .= '</TD></TR>';
                break;
            case 'eligibility':
                if ($_REQUEST['ineligible'] == 'Y') {
                    $start_end_RET = DBGet(DBQuery("SELECT TITLE,VALUE FROM PROGRAM_CONFIG WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' AND PROGRAM='eligibility' AND TITLE IN ('START_DAY','END_DAY')"));
                    if (count($start_end_RET)) {
                        foreach ($start_end_RET as $value) {
                            ${$value}['TITLE'] = $value['VALUE'];
                        }
                    }
                    switch (date('D')) {
                        case 'Mon':
                            $today = 1;
                            break;
                        case 'Tue':
                            $today = 2;
                            break;
                        case 'Wed':
                            $today = 3;
                            break;
                        case 'Thu':
                            $today = 4;
                            break;
                        case 'Fri':
                            $today = 5;
                            break;
                        case 'Sat':
                            $today = 6;
                            break;
                        case 'Sun':
                            $today = 7;
                            break;
                    }
                    $start_date = strtoupper(date('d-M-y', time() - ($today - $START_DAY) * 60 * 60 * 24));
                    $end_date = strtoupper(date('d-M-y', time()));
                    $extra['WHERE'] .= " AND (SELECT count(*) FROM ELIGIBILITY e WHERE ssm.STUDENT_ID=e.STUDENT_ID AND e.SYEAR=ssm.SYEAR AND e.SCHOOL_DATE BETWEEN '{$start_date}' AND '{$end_date}' AND e.ELIGIBILITY_CODE='FAILING') > '0'";
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Eligibility: </b></font>Ineligible<BR>';
                }
                $extra['search'] .= "<TR><TD align=right width=120>Ineligible</TD><TD><INPUT type=checkbox name=ineligible value='Y'></TD></TR>";
                break;
            case 'activity':
                if ($_REQUEST['activity_id']) {
                    $extra['FROM'] .= ",STUDENT_ELIGIBILITY_ACTIVITIES sea";
                    $extra['WHERE'] .= " AND sea.STUDENT_ID=s.STUDENT_ID AND sea.SYEAR=ssm.SYEAR AND sea.ACTIVITY_ID='" . $_REQUEST['activity_id'] . "'";
                    $activity = DBGet(DBQuery("SELECT TITLE FROM ELIGIBILITY_ACTIVITIES WHERE ID='" . $_REQUEST['activity_id'] . "'"));
                    $_openSIS['SearchTerms'] .= '<font color=gray><b>Activity: </b></font>' . $activity[1]['TITLE'] . '<BR>';
                }
                if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                    $activities_RET = DBGet(DBQuery("SELECT ID,TITLE FROM ELIGIBILITY_ACTIVITIES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"));
                }
                $select = "<SELECT name=activity_id><OPTION value=''>Not Specified</OPTION>";
                if (count($activities_RET)) {
                    foreach ($activities_RET as $activity) {
                        $select .= "<OPTION value={$activity['ID']}>{$activity['TITLE']}</OPTION>";
                    }
                }
                $select .= '</SELECT>';
                $extra['search'] .= "<TR><TD align=right width=120>Activity</TD><TD>" . $select . "</TD></TR>";
                break;
            case 'mailing_labels':
                if ($_REQUEST['mailing_labels'] == 'Y') {
                    $extra['SELECT'] .= ',sam.ADDRESS_ID AS MAILING_LABEL';
                    $extra['FROM'] = " LEFT OUTER JOIN STUDENTS_JOIN_ADDRESS sam ON (sam.STUDENT_ID=ssm.STUDENT_ID AND sam.MAILING='Y')" . $extra['FROM'];
                    $extra['functions'] += array('MAILING_LABEL' => 'MailingLabel');
                }
                $extra['search'] .= '<TR><TD align=right width=120>Mailing Labels</TD><TD><INPUT type=checkbox name=mailing_labels value=Y></TD>';
                break;
            case 'balance':
                if (is_numeric($_REQUEST['balance_low']) && is_numeric($_REQUEST['balance_high'])) {
                    if ($_REQUEST['balance_low'] > $_REQUEST['balance_high']) {
                        $temp = $_REQUEST['balance_high'];
                        $_REQUEST['balance_high'] = $_REQUEST['balance_low'];
                        $_REQUEST['balance_low'] = $temp;
                    }
                    $extra['WHERE'] .= " AND (COALESCE((SELECT SUM(f.AMOUNT) FROM BILLING_FEES f,STUDENTS_JOIN_FEES sjf WHERE sjf.FEE_ID=f.ID AND sjf.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR),0)+(SELECT COALESCE(SUM(f.AMOUNT),0)-COALESCE(SUM(f.CASH),0) FROM LUNCH_TRANSACTIONS f WHERE f.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR)-COALESCE((SELECT SUM(p.AMOUNT) FROM BILLING_PAYMENTS p WHERE p.STUDENT_ID=ssm.STUDENT_ID AND p.SYEAR=ssm.SYEAR),0)) BETWEEN '{$_REQUEST['balance_low']}' AND '{$_REQUEST['balance_high']}' ";
                }
                $extra['search'] .= "<TR><TD align=right width=120>Student Billing Balance<BR></TD><TD>Between<INPUT type=text name=balance_low size=5 maxlength=10 class=cell_small> &amp; <INPUT type=text name=balance_high size=5 maxlength=10 class=cell_small></TD></TR>";
                break;
                ####################################################################################################################
                /*case 'discipline':
                				if(is_array($_REQUEST['discipline']))
                				{
                					foreach($_REQUEST['discipline'] as $key=>$value)
                					{
                						if(!$value)
                							unset($_REQUEST['discipline'][$key]);
                					}
                				}
                				if($_REQUEST['month_discipline_entry_begin'] && $_REQUEST['day_discipline_entry_begin'] && $_REQUEST['year_discipline_entry_begin'])
                				{
                					$_REQUEST['discipline_entry_begin'] = $_REQUEST['day_discipline_entry_begin'].'-'.$_REQUEST['month_discipline_entry_begin'].'-'.$_REQUEST['year_discipline_entry_begin'];
                					if(!VerifyDate($_REQUEST['discipline_entry_begin']))
                						unset($_REQUEST['discipline_entry_begin']);
                					$_REQUEST['discipline_entry_end'] = $_REQUEST['day_discipline_entry_end'].'-'.$_REQUEST['month_discipline_entry_end'].'-'.$_REQUEST['year_discipline_entry_end'];
                					if(!VerifyDate($_REQUEST['discipline_entry_end']))
                						unset($_REQUEST['discipline_entry_end']);
                				}
                				if($_REQUEST['discipline_begin'] && $_REQUEST['discipline_end'])
                				{
                					foreach($_REQUEST['discipline_begin'] as $key=>$begin)
                					{
                						if($begin > $_REQUEST['discipline_end'][$key])
                						{
                							$temp = $_REQUEST['discipline_begin'][$key];
                							$_REQUEST['discipline_begin'][$key] = $_REQUEST['discipline_end'][$key];
                							$_REQUEST['discipline_end'][$key] = $temp;
                						}
                					}
                				}
                				if($_REQUEST['discipline_reporter'] || ($_REQUEST['discipline_entry_begin'] && $_REQUEST['discipline_entry_end']) || count($_REQUEST['discipline']))
                				{
                					$extra['WHERE'] .= ' AND dr.STUDENT_ID=ssm.STUDENT_ID AND dr.SYEAR=ssm.SYEAR AND dr.SCHOOL_ID=ssm.SCHOOL_ID ';
                					$extra['FROM'] .= ',DISCIPLINE_REFERRALS dr ';
                					if($_REQUEST['discipline_reporter'])
                						$extra['WHERE'] .= " AND dr.STAFF_ID='$_REQUEST[discipline_reporter]' ";
                					if($_REQUEST['discipline_entry_begin'] && $_REQUEST['discipline_entry_end'])
                						$extra['WHERE'] .= " AND dr.ENTRY_DATE BETWEEN '$_REQUEST[discipline_entry_begin]' AND '$_REQUEST[discipline_entry_end]' ";
                				}
                				$extra['search'] .= '<TR><TD align=right width=120>Reporter</TD><TD>';
                				$users_RET = DBGet(DBQuery("SELECT STAFF_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME FROM STAFF WHERE SYEAR='".UserSyear()."' AND SCHOOLS LIKE '%,".UserSchool().",%' AND PROFILE IN ('admin','teacher') ORDER BY LAST_NAME,FIRST_NAME,MIDDLE_NAME"));
                				$extra['search'] .= '<SELECT name=discipline_reporter><OPTION value="">Not Specified</OPTION>';
                				foreach($users_RET as $user)
                					$extra['search'] .= '<OPTION value='.$user['STAFF_ID'].'>'.$user['LAST_NAME'].', '.$user['FIRST_NAME'].' '.$user['MIDDLE_NAME'].'</OPTION>';
                				$extra['search'] .= '</SELECT>';
                				$extra['search'] .= '</TD></TR>';
                
                				$extra['search'] .= '<TR><TD colspan=2>Incident Date<BR> &nbsp; &nbsp; Between '.PrepareDate('','_discipline_entry_begin',true,array('short'=>true)).' & '.PrepareDate('','_discipline_entry_end',true,array('short'=>true))."</font></TD></TR>";
                				$categories_RET = DBGet(DBQuery("SELECT ID,TITLE,TYPE,OPTIONS FROM DISCIPLINE_CATEGORIES WHERE SYEAR='".UserSyear()."' AND SCHOOL_ID='".UserSchool()."' AND TYPE!='textarea'"));
                				foreach($categories_RET as $category)
                				{
                					if($category['TYPE']!='date')
                					{
                						$extra['search'] .= '<TR><TD align=right width=120>'.$category['TITLE'].'</TD><TD>';
                						switch($category['TYPE'])
                						{
                							case 'text':
                								$extra['search'] .= '<INPUT type=text name=discipline['.$category['ID'].']>';
                								if($_REQUEST['discipline'][$cateogory['ID']])
                									$extra['WHERE'] .= " AND dr.CATEGORY_".$category['ID']." LIKE CONCAT('%',".$_REQUEST['discipline'][$cateogory['ID']].",'%') ";
                							break;
                							case 'checkbox':
                								$extra['search'] .= '<INPUT type=checkbox name=discipline['.$category['ID'].'] value=Y>';
                								if($_REQUEST['discipline'][$cateogory['ID']])
                									$extra['WHERE'] .= " AND dr.CATEGORY_".$category['ID']." = 'Y' ";
                							break;
                							case 'numeric':
                								$extra['search'] .= 'Between<INPUT type=text name=discipline_begin['.$category['ID'].'] size=3 maxlength=11 class=cell_small> &amp; <INPUT type=text name=discipline_end['.$category['ID'].'] size=3 maxlength=11 class=cell_small>';
                								if($_REQUEST['discipline_begin'][$cateogory['ID']] && $_REQUEST['discipline_begin'][$cateogory['ID']])
                									$extra['WHERE'] .= " AND dr.CATEGORY_".$category['ID']." BETWEEN '".$_REQUEST['discipline_begin'][$cateogory['ID']]."' AND '".$_REQUEST['discipline_end'][$cateogory['ID']]."' ";
                							break;
                							case 'multiple_checkbox':
                							case 'multiple_radio':
                							case 'select':
                								$category['OPTIONS'] = str_replace("\n","\r",str_replace("\r\n","\r",$category['OPTIONS']));
                								$category['OPTIONS'] = explode("\r",$category['OPTIONS']);
                
                								$extra['search'] .= '<SELECT name=discipline['.$category['ID'].']><OPTION value="">Not Specified</OPTION>';
                								foreach($category['OPTIONS'] as $option)
                									$extra['search'] .= '<OPTION value="'.$option.'">'.$option.'</OPTION>';
                								$extra['search'] .= '</SELECT>';
                								if($category['TYPE']=='multiple_radio' && $_REQUEST['discipline'][$category['ID']])
                									$extra['WHERE'] .= " AND dr.CATEGORY_".$category['ID']." = '".$_REQUEST['discipline'][$category['ID']]."' ";
                								elseif($category['TYPE']=='multiple_checkbox' && $_REQUEST['discipline'][$category['ID']])
                									$extra['WHERE'] .= " AND dr.CATEGORY_".$category['ID']." LIKE '%".$_REQUEST['discipline'][$category['ID']]."%' ";
                							break;
                						}
                					}
                				}*/
                break;
        }
    }
}
Beispiel #14
0
function Widgets($item, &$myextra = null)
{
    global $extra, $_CENTRE, $CentreModules;
    if (isset($myextra)) {
        $extra =& $myextra;
    }
    if (!is_array($_CENTRE['Widgets'])) {
        $_CENTRE['Widgets'] = array();
    }
    if (!is_array($extra['functions'])) {
        $extra['functions'] = array();
    }
    if ((User('PROFILE') == 'admin' || User('PROFILE') == 'teacher') && !$_CENTRE['Widgets'][$item]) {
        switch ($item) {
            case 'all':
                $extra['search'] .= '<TR><TD colspan=2>';
                if ($CentreModules['Students'] && (!$_CENTRE['Widgets']['calendar'] || !$_CENTRE['Widgets']['next_year'] || !$_CENTRE['Widgets']['enrolled'] || !$_CENTRE['Widgets']['rolled'])) {
                    $extra['search'] .= '<A onclick="switchMenu(\'enrollment_table\');"><IMG SRC=assets/arrow_right.gif id=enrollment_table_arrow> <B>' . _('Enrollment') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=enrollment_table style="display:none;">';
                    Widgets('calendar', $extra);
                    Widgets('next_year', $extra);
                    Widgets('enrolled', $extra);
                    Widgets('rolled', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Scheduling'] && (!$_CENTRE['Widgets']['course'] || !$_CENTRE['Widgets']['request']) && User('PROFILE') == 'admin') {
                    $extra['search'] .= '<A onclick="switchMenu(\'scheduling_table\');"><IMG SRC=assets/arrow_right.gif id=scheduling_table_arrow> <B>' . _('Scheduling') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=scheduling_table style="display:none;">';
                    Widgets('course', $extra);
                    //Widgets('request',$extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Attendance'] && !$_CENTRE['Widgets']['absences']) {
                    $extra['search'] .= '<A onclick="switchMenu(\'absences_table\');"><IMG SRC=assets/arrow_right.gif id=absences_table_arrow> <B>' . _('Attendance') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=absences_table style="display:none;">';
                    Widgets('absences', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Grades'] && (!$_CENTRE['Widgets']['gpa'] || !$_CENTRE['Widgets']['class_rank'] || !$_CENTRE['Widgets']['letter_grade'])) {
                    $extra['search'] .= '<A onclick="switchMenu(\'grades_table\');"><IMG SRC=assets/arrow_right.gif id=grades_table_arrow> <B>' . _('Grades') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% cellpadding=5 id=grades_table style="display:none;">';
                    Widgets('gpa', $extra);
                    Widgets('class_rank', $extra);
                    Widgets('letter_grade', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Eligibility'] && (!$_CENTRE['Widgets']['eligibility'] || !$_CENTRE['Widgets']['activity'])) {
                    $extra['search'] .= '<A onclick="switchMenu(\'eligibility_table\');"><IMG SRC=assets/arrow_right.gif id=eligibility_table_arrow> <B>' . _('Eligibility') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=eligibility_table style="display:none;">';
                    Widgets('eligibility', $extra);
                    Widgets('activity', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Food_Service'] && (!$_CENTRE['Widgets']['fsa_balance'] || !$_CENTRE['Widgets']['fsa_discount'] || !$_CENTRE['Widgets']['fsa_status'] || !$_CENTRE['Widgets']['fsa_barcode'])) {
                    $extra['search'] .= '<A onclick="switchMenu(\'food_service_table\');"><IMG SRC=assets/arrow_right.gif id=food_service_table_arrow> <B>' . _('Food Service') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=food_service_table style="display:none;">';
                    Widgets('fsa_balance', $extra);
                    Widgets('fsa_discount', $extra);
                    Widgets('fsa_status', $extra);
                    Widgets('fsa_barcode', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Discipline'] && (!$_CENTRE['Widgets']['discipline'] || !$_CENTRE['Widgets']['discipline_categories'])) {
                    $extra['search'] .= '<A onclick="switchMenu(\'discipline_table\');"><IMG SRC=assets/arrow_right.gif id=discipline_table_arrow> <B>' . _('Discipline') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=discipline_table style="display:none;">';
                    Widgets('discipline', $extra);
                    Widgets('discipline_categories', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                if ($CentreModules['Student_Billing'] && !$_CENTRE['Widgets']['balance']) {
                    $extra['search'] .= '<A onclick="switchMenu(\'billing_table\');"><IMG SRC=assets/arrow_right.gif id=billing_table_arrow> <B>' . _('Student Billing') . '</B></A><BR><TABLE bgcolor=#f8f8f9 width=100% id=billing_table style="display:none;">';
                    Widgets('balance', $extra);
                    $extra['search'] .= '</TABLE>';
                }
                $extra['search'] .= '</TD></TR>';
                break;
            case 'user':
                $widgets_RET = DBGet(DBQuery("SELECT TITLE FROM PROGRAM_USER_CONFIG WHERE USER_ID='" . User('STAFF_ID') . "' AND PROGRAM='WidgetsSearch'" . (count($_CENTRE['Widgets']) ? " AND TITLE NOT IN ('" . implode("','", array_keys($_CENTRE['Widgets'])) . "')" : '')));
                foreach ($widgets_RET as $widget) {
                    Widgets($widget['TITLE'], $extra);
                }
                break;
            case 'course':
                if ($CentreModules['Scheduling'] && User('PROFILE') == 'admin') {
                    if ($_REQUEST['w_course_period_id']) {
                        if ($_REQUEST['w_course_period_id_which'] == 'course') {
                            $course = DBGet(DBQuery("SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM COURSE_PERIODS cp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'"));
                            $extra['FROM'] .= ",SCHEDULE w_ss";
                            $extra['WHERE'] .= " AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_ID='" . $course[1]['COURSE_ID'] . "' AND ('" . DBDate() . "' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)";
                            if (!$extra['NoSearchTerms']) {
                                $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Course')) . ' </b></font>' . $course[1]['COURSE_TITLE'] . '<BR>';
                            }
                        } else {
                            $extra['FROM'] .= ",SCHEDULE w_ss";
                            $extra['WHERE'] .= " AND w_ss.STUDENT_ID=s.STUDENT_ID AND w_ss.SYEAR=ssm.SYEAR AND w_ss.SCHOOL_ID=ssm.SCHOOL_ID AND w_ss.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "' AND ('" . DBDate() . "' BETWEEN w_ss.START_DATE AND w_ss.END_DATE OR w_ss.END_DATE IS NULL)";
                            $course = DBGet(DBQuery("SELECT c.TITLE AS COURSE_TITLE,cp.TITLE,cp.COURSE_ID FROM COURSE_PERIODS cp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'"));
                            if (!$extra['NoSearchTerms']) {
                                $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Course Period')) . ' </b></font>' . $course[1]['COURSE_TITLE'] . ': ' . $course[1]['TITLE'] . '<BR>';
                            }
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Course') . "</TD><TD><DIV id=course_div></DIV> <A HREF=# onclick='window.open(\"Modules.php?modname=misc/ChooseCourse.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>" . _('Choose') . "</SMALL></A></TD></TR>";
                }
                break;
            case 'request':
                if ($CentreModules['Scheduling'] && User('PROFILE') == 'admin') {
                    // PART OF THIS IS DUPLICATED IN PrintRequests.php
                    if ($_REQUEST['request_course_id']) {
                        $course = DBGet(DBQuery("SELECT c.TITLE FROM COURSES c WHERE c.COURSE_ID='" . $_REQUEST['request_course_id'] . "'"));
                        if (!$_REQUEST['not_request_course']) {
                            $extra['FROM'] .= ",SCHEDULE_REQUESTS sr";
                            $extra['WHERE'] .= " AND sr.STUDENT_ID=s.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.SCHOOL_ID=ssm.SCHOOL_ID AND sr.COURSE_ID='" . $_REQUEST['request_course_id'] . "' ";
                            if (!$extra['NoSearchTerms']) {
                                $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Request')) . ' </b></font>' . $course[1]['TITLE'] . '<BR>';
                            }
                        } else {
                            $extra['WHERE'] .= " AND NOT EXISTS (SELECT '' FROM SCHEDULE_REQUESTS sr WHERE sr.STUDENT_ID=ssm.STUDENT_ID AND sr.SYEAR=ssm.SYEAR AND sr.COURSE_ID='" . $_REQUEST['request_course_id'] . "' ) ";
                            if (!$extra['NoSearchTerms']) {
                                $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Missing Request')) . ' </b></font>' . $course[1]['TITLE'] . '<BR>';
                            }
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Request') . "</TD><TD><DIV id=request_div></DIV> <A HREF=# onclick='window.open(\"Modules.php?modname=misc/ChooseRequest.php\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'><SMALL>" . _('Choose') . "</SMALL></A></TD></TR>";
                }
                break;
            case 'absences':
                if ($CentreModules['Attendance']) {
                    if (is_numeric($_REQUEST['absences_low']) && is_numeric($_REQUEST['absences_high'])) {
                        if ($_REQUEST['absences_low'] > $_REQUEST['absences_high']) {
                            $temp = $_REQUEST['absences_high'];
                            $_REQUEST['absences_high'] = $_REQUEST['absences_low'];
                            $_REQUEST['absences_low'] = $temp;
                        }
                        if ($_REQUEST['absences_low'] == $_REQUEST['absences_high']) {
                            $extra['WHERE'] .= " AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM ATTENDANCE_DAY ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (" . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ")) = '{$_REQUEST['absences_low']}'";
                        } else {
                            $extra['WHERE'] .= " AND (SELECT sum(1-STATE_VALUE) AS STATE_VALUE FROM ATTENDANCE_DAY ad WHERE ssm.STUDENT_ID=ad.STUDENT_ID AND ad.SYEAR=ssm.SYEAR AND ad.MARKING_PERIOD_ID IN (" . GetChildrenMP($_REQUEST['absences_term'], UserMP()) . ")) BETWEEN '{$_REQUEST['absences_low']}' AND '{$_REQUEST['absences_high']}'";
                        }
                        switch ($_REQUEST['absences_term']) {
                            case 'FY':
                                $term = _('this school year to date');
                                break;
                            case 'SEM':
                                $term = _('this semester to date');
                                break;
                            case 'QTR':
                                $term = _('this marking period to date');
                                break;
                        }
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . _('Days Absent') . '&nbsp;' . $term . ' ' . _('Between') . ' </b></font>' . $_REQUEST['absences_low'] . ' &amp; ' . $_REQUEST['absences_high'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Days Absent') . "<BR><INPUT type=radio name=absences_term value=FY checked><small>YTD</small><INPUT type=radio name=absences_term value=SEM><small>" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "</small><INPUT type=radio name=absences_term value=QTR><small>" . GetMP(UserMP(), 'SHORT_NAME') . "</small></TD><TD><small>" . _('Between') . "</small> <INPUT type=text name=absences_low size=3 maxlength=5> <small>&amp;</small> <INPUT type=text name=absences_high size=3 maxlength=5></TD></TR>";
                }
                break;
            case 'gpa':
                if ($CentreModules['Grades']) {
                    if (is_numeric($_REQUEST['gpa_low']) && is_numeric($_REQUEST['gpa_high'])) {
                        if ($_REQUEST['gpa_low'] > $_REQUEST['gpa_high']) {
                            $temp = $_REQUEST['gpa_high'];
                            $_REQUEST['gpa_high'] = $_REQUEST['gpa_low'];
                            $_REQUEST['gpa_low'] = $temp;
                        }
                        if ($_REQUEST['list_gpa']) {
                            $extra['SELECT'] .= ',sgc.WEIGHTED_GPA,sgc.UNWEIGHTED_GPA';
                            $extra['columns_after']['WEIGHTED_GPA'] = _('Weighted GPA');
                            $extra['columns_after']['UNWEIGHTED_GPA'] = _('Unweighted GPA');
                        }
                        if (strpos($extra['FROM'], 'STUDENT_GPA_CALCULATED sgc') === false) {
                            $extra['FROM'] .= ",STUDENT_GPA_CALCULATED sgc";
                            $extra['WHERE'] .= " AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID='" . $_REQUEST['gpa_term'] . "'";
                        }
                        $extra['WHERE'] .= " AND sgc." . ($_REQUEST['weighted'] == 'Y' ? 'WEIGHTED_' : '') . "GPA BETWEEN '{$_REQUEST['gpa_low']}' AND '{$_REQUEST['gpa_high']}' AND sgc.MARKING_PERIOD_ID='" . $_REQUEST['gpa_term'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . ($_REQUEST['gpa_weighted'] == 'Y' ? 'Weighted ' : '') . Localize('colon', _('GPA between')) . ' </b></font>' . $_REQUEST['gpa_low'] . ' &amp; ' . $_REQUEST['gpa_high'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>GPA<BR><INPUT type=checkbox name=gpa_weighted value=Y><small>" . _('Weighted') . "</small><BR><INPUT type=radio name=gpa_term value=CUM checked><small>" . _('Cumulative') . "</small><INPUT type=radio name=gpa_term value=" . GetParentMP('SEM', UserMP()) . "><small>" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "</small><INPUT type=radio name=gpa_term value=" . UserMP() . "><small>" . GetMP(UserMP(), 'SHORT_NAME') . "</small></TD><TD><small>" . _('Between') . "</small> <INPUT type=text name=gpa_low size=3 maxlength=5> <small>&amp;</small> <INPUT type=text name=gpa_high size=3 maxlength=5></TD></TR>";
                }
                break;
            case 'class_rank':
                if ($CentreModules['Grades']) {
                    if (is_numeric($_REQUEST['class_rank_low']) && is_numeric($_REQUEST['class_rank_high'])) {
                        if ($_REQUEST['class_rank_low'] > $_REQUEST['class_rank_high']) {
                            $temp = $_REQUEST['class_rank_high'];
                            $_REQUEST['class_rank_high'] = $_REQUEST['class_rank_low'];
                            $_REQUEST['class_rank_low'] = $temp;
                        }
                        if (strpos($extra['FROM'], 'STUDENT_GPA_CALCULATED sgc') === false) {
                            $extra['FROM'] .= ",STUDENT_GPA_CALCULATED sgc";
                            $extra['WHERE'] .= " AND sgc.STUDENT_ID=s.STUDENT_ID AND sgc.MARKING_PERIOD_ID='" . $_REQUEST['class_rank_term'] . "'";
                        }
                        $extra['WHERE'] .= " AND sgc.CLASS_RANK BETWEEN '{$_REQUEST['class_rank_low']}' AND '{$_REQUEST['class_rank_high']}'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Class Rank')) . ' ' . _('Between') . '</b></font>' . $_REQUEST['class_rank_low'] . ' &amp; ' . $_REQUEST['class_rank_high'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>Class Rank<BR><INPUT type=radio name=class_rank_term value=CUM checked><small>" . _('Cumulative') . "</small><INPUT type=radio name=class_rank_term value=" . GetParentMP('SEM', UserMP()) . "><small>" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "</small><INPUT type=radio name=class_rank_term value=" . UserMP() . "><small>" . GetMP(UserMP(), 'SHORT_NAME') . "</small>";
                    if (strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                        $pros = explode(',', str_replace("'", '', $pros));
                        foreach ($pros as $pro) {
                            $extra['search'] .= "<INPUT type=radio name=class_rank_term value=" . $pro . "><small>" . GetMP($pro, 'SHORT_NAME') . "</small>";
                        }
                    }
                    $extra['search'] .= "</TD><TD><small>" . _('Between') . "</small> <INPUT type=text name=class_rank_low size=3 maxlength=5> <small>&amp;</small> <INPUT type=text name=class_rank_high size=3 maxlength=5></TD></TR>";
                }
                break;
            case 'letter_grade':
                if ($CentreModules['Grades']) {
                    if (count($_REQUEST['letter_grade'])) {
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>With' . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'out' : '') . ' Report Card Grade: </b></font>';
                        }
                        $letter_grades_RET = DBGet(DBQuery("SELECT ID,TITLE FROM REPORT_CARD_GRADES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"), array(), array('ID'));
                        foreach ($_REQUEST['letter_grade'] as $grade => $Y) {
                            $letter_grades .= ",'{$grade}'";
                            if (!$extra['NoSearchTerms']) {
                                $_CENTRE['SearchTerms'] .= $letter_grades_RET[$grade][1]['TITLE'] . ', ';
                            }
                        }
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] = substr($_CENTRE['SearchTerms'], 0, -2) . '<BR>';
                        }
                        $extra['WHERE'] .= " AND " . ($_REQUEST['letter_grade_exclude'] == 'Y' ? 'NOT ' : '') . "EXISTS (SELECT '' FROM STUDENT_REPORT_CARD_GRADES sg3 WHERE sg3.STUDENT_ID=ssm.STUDENT_ID AND sg3.SYEAR=ssm.SYEAR AND sg3.REPORT_CARD_GRADE_ID IN (" . substr($letter_grades, 1) . ") AND sg3.MARKING_PERIOD_ID='" . $_REQUEST['letter_grade_term'] . "' )";
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Letter Grade') . "<BR><INPUT type=checkbox name=letter_grade_exclude value=Y><small>" . _('Did not receive') . "</small><BR><INPUT type=radio name=letter_grade_term value=" . GetParentMP('SEM', UserMP()) . "><small>" . GetMP(GetParentMP('SEM', UserMP()), 'SHORT_NAME') . "</small><INPUT type=radio name=letter_grade_term value=" . UserMP() . "><small>" . GetMP(UserMP(), 'SHORT_NAME') . "</small>";
                    if (strlen($pros = GetChildrenMP('PRO', UserMP()))) {
                        $pros = explode(',', str_replace("'", '', $pros));
                        foreach ($pros as $pro) {
                            $extra['search'] .= "<INPUT type=radio name=letter_grade_term value=" . $pro . "><small>" . GetMP($pro, 'SHORT_NAME') . "</small>";
                        }
                    }
                    $extra['search'] .= "</TD><TD>";
                    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                        $letter_grades_RET = DBGet(DBQuery("SELECT rg.ID,rg.TITLE,rg.GRADE_SCALE_ID FROM REPORT_CARD_GRADES rg,REPORT_CARD_GRADE_SCALES rs WHERE rg.SCHOOL_ID='" . UserSchool() . "' AND rg.SYEAR='" . UserSyear() . "' AND rs.ID=rg.GRADE_SCALE_ID" . (User('PROFILE') == 'teacher' ? ' AND rg.GRADE_SCALE_ID=(SELECT GRADE_SCALE_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID=\'' . UserCoursePeriod() . '\')' : '') . " ORDER BY rs.SORT_ORDER,rs.ID,rg.BREAK_OFF IS NOT NULL DESC,rg.BREAK_OFF DESC,rg.SORT_ORDER"), array(), array('GRADE_SCALE_ID'));
                    }
                    foreach ($letter_grades_RET as $grades) {
                        $i = 0;
                        if (count($grades)) {
                            foreach ($grades as $grade) {
                                if ($i % 9 == 0) {
                                    $extra['search'] .= '<BR>';
                                }
                                $extra['search'] .= '<INPUT type=checkbox value=Y name=letter_grade[' . $grade['ID'] . ']>' . $grade['TITLE'];
                                $i++;
                            }
                        }
                    }
                    $extra['search'] .= '</TD></TR>';
                }
                break;
            case 'eligibility':
                if ($CentreModules['Eligibility']) {
                    if ($_REQUEST['ineligible'] == 'Y') {
                        $start_end_RET = DBGet(DBQuery("SELECT TITLE,VALUE FROM PROGRAM_CONFIG WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' AND PROGRAM='eligibility' AND TITLE IN ('START_DAY','END_DAY')"));
                        if (count($start_end_RET)) {
                            foreach ($start_end_RET as $value) {
                                ${$value}['TITLE'] = $value['VALUE'];
                            }
                        }
                        switch (date('D')) {
                            case 'Mon':
                                $today = 1;
                                break;
                            case 'Tue':
                                $today = 2;
                                break;
                            case 'Wed':
                                $today = 3;
                                break;
                            case 'Thu':
                                $today = 4;
                                break;
                            case 'Fri':
                                $today = 5;
                                break;
                            case 'Sat':
                                $today = 6;
                                break;
                            case 'Sun':
                                $today = 7;
                                break;
                        }
                        $start_date = strtoupper(date('d-M-y', time() - ($today - $START_DAY) * 60 * 60 * 24));
                        $end_date = strtoupper(date('d-M-y', time()));
                        $extra['WHERE'] .= " AND (SELECT count(*) FROM ELIGIBILITY e WHERE ssm.STUDENT_ID=e.STUDENT_ID AND e.SYEAR=ssm.SYEAR AND e.SCHOOL_DATE BETWEEN '{$start_date}' AND '{$end_date}' AND e.ELIGIBILITY_CODE='FAILING') > '0'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Eligibility')) . ' </b></font>' . _('Ineligible') . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Ineligible') . "</TD><TD><INPUT type=checkbox name=ineligible value='Y'></TD></TR>";
                }
                break;
            case 'activity':
                if ($CentreModules['Eligibility']) {
                    if ($_REQUEST['activity_id']) {
                        $extra['FROM'] .= ",STUDENT_ELIGIBILITY_ACTIVITIES sea";
                        $extra['WHERE'] .= " AND sea.STUDENT_ID=s.STUDENT_ID AND sea.SYEAR=ssm.SYEAR AND sea.ACTIVITY_ID='" . $_REQUEST['activity_id'] . "'";
                        $activity = DBGet(DBQuery("SELECT TITLE FROM ELIGIBILITY_ACTIVITIES WHERE ID='" . $_REQUEST['activity_id'] . "'"));
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Activity: </b></font>' . $activity[1]['TITLE'] . '<BR>';
                        }
                    }
                    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
                        $activities_RET = DBGet(DBQuery("SELECT ID,TITLE FROM ELIGIBILITY_ACTIVITIES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"));
                    }
                    $select = "<SELECT name=activity_id><OPTION value=''>" . _('Not Specified') . "</OPTION>";
                    if (count($activities_RET)) {
                        foreach ($activities_RET as $activity) {
                            $select .= "<OPTION value={$activity['ID']}>{$activity['TITLE']}</OPTION>";
                        }
                    }
                    $select .= '</SELECT>';
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Activity') . "</TD><TD>" . $select . "</TD></TR>";
                }
                break;
            case 'mailing_labels':
                if ($_REQUEST['mailing_labels'] == 'Y') {
                    $extra['SELECT'] .= ',coalesce(sam.ADDRESS_ID,-ssm.STUDENT_ID) AS ADDRESS_ID,sam.ADDRESS_ID AS MAILING_LABEL';
                    $extra['FROM'] = " LEFT OUTER JOIN STUDENTS_JOIN_ADDRESS sam ON (sam.STUDENT_ID=ssm.STUDENT_ID AND sam.MAILING='Y'" . ($_REQUEST['residence'] == 'Y' ? " AND sam.RESIDENCE='Y'" : '') . ")" . $extra['FROM'];
                    $extra['functions'] += array('MAILING_LABEL' => 'MailingLabel');
                }
                $extra['search'] .= '<TR><TD align=right width=120>' . _('Mailing Labels') . '</TD><TD><INPUT type=checkbox name=mailing_labels value=Y></TD>';
                break;
            case 'balance':
                if ($CentreModules['Student_Billing']) {
                    if (is_numeric($_REQUEST['balance_low']) && is_numeric($_REQUEST['balance_high'])) {
                        if ($_REQUEST['balance_low'] > $_REQUEST['balance_high']) {
                            $temp = $_REQUEST['balance_high'];
                            $_REQUEST['balance_high'] = $_REQUEST['balance_low'];
                            $_REQUEST['balance_low'] = $temp;
                        }
                        $extra['WHERE'] .= " AND (coalesce((SELECT sum(f.AMOUNT) FROM BILLING_FEES f,STUDENTS_JOIN_FEES sjf WHERE sjf.FEE_ID=f.ID AND sjf.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR),0)+(SELECT coalesce(sum(f.AMOUNT),0)-coalesce(sum(f.CASH),0) FROM LUNCH_TRANSACTIONS f WHERE f.STUDENT_ID=ssm.STUDENT_ID AND f.SYEAR=ssm.SYEAR)-coalesce((SELECT sum(p.AMOUNT) FROM BILLING_PAYMENTS p WHERE p.STUDENT_ID=ssm.STUDENT_ID AND p.SYEAR=ssm.SYEAR),0)) BETWEEN '{$_REQUEST['balance_low']}' AND '{$_REQUEST['balance_high']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Student Billing Balance')) . ' </b></font>' . _('Between') . ' ' . $_REQUEST['balance_low'] . ' &amp; ' . $_REQUEST['balance_high'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Balance') . "<BR></TD><TD><small>" . _('Between') . "</small> <INPUT type=text name=balance_low size=5 maxlength=10> <small>&amp;</small> <INPUT type=text name=balance_high size=5 maxlength=10></TD></TR>";
                }
                break;
            case 'discipline':
                if ($CentreModules['Discipline']) {
                    if (is_array($_REQUEST['discipline'])) {
                        foreach ($_REQUEST['discipline'] as $key => $value) {
                            if (!$value) {
                                unset($_REQUEST['discipline'][$key]);
                            }
                        }
                    }
                    if ($_REQUEST['month_discipline_entry_begin'] && $_REQUEST['day_discipline_entry_begin'] && $_REQUEST['year_discipline_entry_begin']) {
                        $_REQUEST['discipline_entry_begin'] = $_REQUEST['day_discipline_entry_begin'] . '-' . $_REQUEST['month_discipline_entry_begin'] . '-' . $_REQUEST['year_discipline_entry_begin'];
                        if (!VerifyDate($_REQUEST['discipline_entry_begin'])) {
                            unset($_REQUEST['discipline_entry_begin']);
                        }
                        unset($_REQUEST['day_discipline_entry_begin']);
                        unset($_REQUEST['month_discipline_entry_begin']);
                        unset($_REQUEST['year_discipline_entry_begin']);
                    }
                    if ($_REQUEST['month_discipline_entry_end'] && $_REQUEST['day_discipline_entry_end'] && $_REQUEST['year_discipline_entry_end']) {
                        $_REQUEST['discipline_entry_end'] = $_REQUEST['day_discipline_entry_end'] . '-' . $_REQUEST['month_discipline_entry_end'] . '-' . $_REQUEST['year_discipline_entry_end'];
                        if (!VerifyDate($_REQUEST['discipline_entry_end'])) {
                            unset($_REQUEST['discipline_entry_end']);
                        }
                        unset($_REQUEST['day_discipline_entry_end']);
                        unset($_REQUEST['month_discipline_entry_end']);
                        unset($_REQUEST['year_discipline_entry_end']);
                    }
                    if ($_REQUEST['discipline_reporter'] || $_REQUEST['discipline_entry_begin'] || $_REQUEST['discipline_entry_end'] || count($_REQUEST['discipline']) || count($_REQUEST['discipline_begin']) || count($_REQUEST['discipline_end'])) {
                        $extra['WHERE'] .= ' AND dr.STUDENT_ID=ssm.STUDENT_ID AND dr.SYEAR=ssm.SYEAR AND dr.SCHOOL_ID=ssm.SCHOOL_ID ';
                        $extra['FROM'] .= ',DISCIPLINE_REFERRALS dr ';
                    }
                    $users_RET = DBGet(DBQuery("SELECT STAFF_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME FROM STAFF WHERE SYEAR='" . UserSyear() . "' AND (SCHOOLS IS NULL OR SCHOOLS LIKE '%," . UserSchool() . ",%') AND (PROFILE='admin' OR PROFILE='teacher') ORDER BY LAST_NAME,FIRST_NAME,MIDDLE_NAME"), array(), array('STAFF_ID'));
                    if ($_REQUEST['discipline_reporter']) {
                        $extra['WHERE'] .= " AND dr.STAFF_ID='{$_REQUEST['discipline_reporter']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Reporter: </b></font>' . $users_RET[$_REQUEST['discipline_reporter']][1]['LAST_NAME'] . ', ' . $users_RET[$_REQUEST['discipline_reporter']][1]['FIRST_NAME'] . ' ' . $users_RET[$_REQUEST['discipline_reporter']][1]['MIDDLE_NAME'] . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Reporter</TD><TD>';
                    $extra['search'] .= '<SELECT name=discipline_reporter><OPTION value="">' . _('Not Specified') . '</OPTION>';
                    foreach ($users_RET as $id => $user) {
                        $extra['search'] .= '<OPTION value=' . $id . '>' . $user[1]['LAST_NAME'] . ', ' . $user[1]['FIRST_NAME'] . ' ' . $user[1]['MIDDLE_NAME'] . '</OPTION>';
                    }
                    $extra['search'] .= '</SELECT>';
                    $extra['search'] .= '</TD></TR>';
                    if ($_REQUEST['discipline_entry_begin'] && $_REQUEST['discipline_entry_end']) {
                        $extra['WHERE'] .= " AND dr.ENTRY_DATE BETWEEN '{$_REQUEST['discipline_entry_begin']}' AND '{$_REQUEST['discipline_entry_end']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Incident Date Between: </b></font>' . ProperDate($_REQUEST['discipline_entry_begin']) . '<font color=gray><b> and </b></font>' . ProperDate($_REQUEST['discipline_entry_end']) . '<BR>';
                        }
                    } elseif ($_REQUEST['discipline_entry_begin']) {
                        $extra['WHERE'] .= " AND dr.ENTRY_DATE>='{$_REQUEST['discipline_entry_begin']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Incident Entered On or After </b></font>' . ProperDate($_REQUEST['discipline_entry_begin']) . '<BR>';
                        }
                    } elseif ($_REQUEST['discipline_entry_end']) {
                        $extra['WHERE'] .= " AND dr.ENTRY_DATE<='{$_REQUEST['discipline_entry_end']}' ";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Incident Entered On or Before </b></font>' . ProperDate($_REQUEST['discipline_entry_end']) . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Incident Date</TD><TD><table cellpadding=0 cellspacing=0><tr><td>&ge;&nbsp;</td><td>' . PrepareDate('', '_discipline_entry_begin', true, array('short' => true)) . '</td></tr><tr><td>&le;&nbsp;</td><td>' . PrepareDate('', '_discipline_entry_end', true, array('short' => true)) . '</td></tr></table></TD></TR>';
                }
                break;
            case 'discipline_categories':
                if ($CentreModules['Discipline']) {
                    $categories_RET = DBGet(DBQuery("SELECT ID,TITLE,TYPE,OPTIONS FROM DISCIPLINE_CATEGORIES WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' AND TYPE!='textarea'"));
                    foreach ($categories_RET as $category) {
                        if ($category['TYPE'] != 'date') {
                            $extra['search'] .= '<TR><TD align=right width=120>' . $category['TITLE'] . '</TD><TD>';
                            switch ($category['TYPE']) {
                                case 'text':
                                    $extra['search'] .= '<INPUT type=text name=discipline[' . $category['ID'] . ']>';
                                    if ($_REQUEST['discipline'][$cateogory['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " LIKE '" . $_REQUEST['discipline'][$cateogory['ID']] . "%' ";
                                    }
                                    break;
                                case 'checkbox':
                                    $extra['search'] .= '<INPUT type=checkbox name=discipline[' . $category['ID'] . '] value=Y>';
                                    if ($_REQUEST['discipline'][$cateogory['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " = 'Y' ";
                                    }
                                    break;
                                case 'numeric':
                                    if ($_REQUEST['discipline_begin'][$category['ID']] && $_REQUEST['discipline_end'][$category['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " BETWEEN '" . $_REQUEST['discipline_begin'][$category['ID']] . "' AND '" . $_REQUEST['discipline_end'][$category['ID']] . "' ";
                                        if (!$extra['NoSearchTerms']) {
                                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . $category['TITLE'] . ' &ge; </b></font>' . $_REQUEST['discipline_begin'][$category['ID']] . '<font color=gray><b> and &le; </b></font>' . $_REQUEST['discipline_end'][$category['ID']] . '<BR>';
                                        }
                                    } elseif ($_REQUEST['discipline_begin'][$category['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . ">='" . $_REQUEST['discipline_begin'][$category['ID']] . "' ";
                                        if (!$extra['NoSearchTerms']) {
                                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . $category['TITLE'] . ' &ge; </b></font>' . $_REQUEST['discipline_begin'][$category['ID']] . '<BR>';
                                        }
                                    } elseif ($_REQUEST['discipline_end'][$category['ID']]) {
                                        $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . "<='" . $_REQUEST['discipline_end'][$category['ID']] . "' ";
                                        if (!$extra['NoSearchTerms']) {
                                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . $category['TITLE'] . ' &le; </b></font>' . $_REQUEST['discipline_end'][$category['ID']] . '<BR>';
                                        }
                                    }
                                    $extra['search'] .= '&ge; <INPUT type=text name=discipline_begin[' . $category['ID'] . '] size=3 maxlength=11> &le; <INPUT type=text name=discipline_end[' . $category['ID'] . '] size=3 maxlength=11>';
                                    break;
                                case 'multiple_checkbox':
                                case 'multiple_radio':
                                case 'select':
                                    $category['OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $category['OPTIONS']));
                                    $category['OPTIONS'] = explode("\r", $category['OPTIONS']);
                                    $extra['search'] .= '<SELECT name=discipline[' . $category['ID'] . ']><OPTION value="">' . _('Not Specified') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                                    foreach ($category['OPTIONS'] as $option) {
                                        $extra['search'] .= '<OPTION value="' . $option . '">' . $option . '</OPTION>';
                                    }
                                    $extra['search'] .= '</SELECT>';
                                    if ($_REQUEST['discipline'][$category['ID']]) {
                                        if ($_REQUEST['discipline'][$category['ID']] == '!') {
                                            $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " IS NULL ";
                                        } elseif ($category['TYPE'] == 'multiple_radio' || $category['TYPE'] == 'select') {
                                            $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . "='" . $_REQUEST['discipline'][$category['ID']] . "' ";
                                        } elseif ($category['TYPE'] == 'multiple_checkbox') {
                                            $extra['WHERE'] .= " AND dr.CATEGORY_" . $category['ID'] . " LIKE '%||" . $_REQUEST['discipline'][$category['ID']] . "||%' ";
                                        }
                                    }
                                    break;
                            }
                            $extra['search'] .= '</TD></TR>';
                        }
                    }
                }
                break;
            case 'next_year':
                if ($CentreModules['Students']) {
                    $schools_RET = DBGet(DBQuery("SELECT ID,TITLE FROM SCHOOLS WHERE ID!='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'"), array(), array('ID'));
                    if ($_REQUEST['next_year'] == '!') {
                        $extra['WHERE'] .= " AND ssm.NEXT_SCHOOL IS NULL";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Next Year')) . ' </b></font>No Value<BR>';
                        }
                    } elseif ($_REQUEST['next_year'] != '') {
                        $extra['WHERE'] .= " AND ssm.NEXT_SCHOOL='" . $_REQUEST['next_year'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>' . Localize('colon', _('Next Year')) . ' </b></font>' . ($_REQUEST['next_year'] == UserSchool() ? 'Next grade at current school' : ($_REQUEST['next_year'] == '0' ? 'Retain' : ($_REQUEST['next_year'] == '-1' ? 'Do not enroll after this school year' : $schools_RET[$_REQUEST['next_year']][1]['TITLE']))) . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>" . _('Next Year') . "</TD><TD><SELECT name=next_year><OPTION value=''>N/A</OPTION><OPTION value='!'>" . _('No Value') . "</OPTION><OPTION value=" . UserSchool() . ">" . _('Next grade at current school') . "</OPTION><OPTION value=0>" . _('Retain') . "</OPTION><OPTION value=-1>" . _('Do not enroll after this school year') . "</OPTION>";
                    foreach ($schools_RET as $id => $school) {
                        $extra['search'] .= '<OPTION value=' . $id . '>' . $school[1]['TITLE'] . '</OPTION>';
                    }
                    $extra['search'] .= '</SELECT></TD></TR>';
                }
                break;
            case 'calendar':
                if ($CentreModules['Students']) {
                    $calendars_RET = DBGet(DBQuery("SELECT CALENDAR_ID,TITLE FROM ATTENDANCE_CALENDARS WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' ORDER BY DEFAULT_CALENDAR ASC"), array(), array('CALENDAR_ID'));
                    if ($_REQUEST['calendar'] == '!') {
                        $extra['WHERE'] .= " AND ssm.CALENDAR_ID IS " . ($_REQUEST['calendar_not'] == 'Y' ? 'NOT ' : '') . "NULL";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Calendar: </b></font>' . ($_REQUEST['calendar_not'] == 'Y' ? 'Any' : 'No') . ' Value<BR>';
                        }
                    } elseif ($_REQUEST['calendar'] != '') {
                        $extra['WHERE'] .= " AND ssm.CALENDAR_ID" . ($_REQUEST['calendar_not'] == 'Y' ? '!' : '') . "='" . $_REQUEST['calendar'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Calendar: </b></font>' . ($_REQUEST['calendar_not'] == 'Y' ? 'Not ' : '') . $calendars_RET[$_REQUEST['calendar']][1]['TITLE'] . '<BR>';
                        }
                    }
                    $extra['search'] .= "<TR><TD align=right width=120>Calendar</TD><TD><INPUT type=checkbox name=calendar_not value=Y>Not <SELECT name=calendar><OPTION value=''>N/A</OPTION><OPTION value='!'>No Value</OPTION>";
                    foreach ($calendars_RET as $id => $calendar) {
                        $extra['search'] .= '<OPTION value=' . $id . '>' . $calendar[1]['TITLE'] . '</OPTION>';
                    }
                    $extra['search'] .= '</SELECT></TD></TR>';
                }
                break;
            case 'enrolled':
                if ($CentreModules['Students']) {
                    if ($_REQUEST['month_enrolled_begin'] && $_REQUEST['day_enrolled_begin'] && $_REQUEST['year_enrolled_begin']) {
                        $_REQUEST['enrolled_begin'] = $_REQUEST['day_enrolled_begin'] . '-' . $_REQUEST['month_enrolled_begin'] . '-' . $_REQUEST['year_enrolled_begin'];
                        if (!VerifyDate($_REQUEST['enrolled_begin'])) {
                            unset($_REQUEST['enrolled_begin']);
                        }
                    }
                    if ($_REQUEST['month_enrolled_end'] && $_REQUEST['day_enrolled_end'] && $_REQUEST['year_enrolled_end']) {
                        $_REQUEST['enrolled_end'] = $_REQUEST['day_enrolled_end'] . '-' . $_REQUEST['month_enrolled_end'] . '-' . $_REQUEST['year_enrolled_end'];
                        if (!VerifyDate($_REQUEST['enrolled_end'])) {
                            unset($_REQUEST['enrolled_end']);
                        }
                    }
                    if ($_REQUEST['enrolled_begin'] && $_REQUEST['enrolled_end']) {
                        $extra['WHERE'] .= " AND ssm.START_DATE BETWEEN '" . $_REQUEST['enrolled_begin'] . "' AND '" . $_REQUEST['enrolled_end'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Enrolled Between: </b></font>' . ProperDate($_REQUEST['enrolled_begin']) . ' and ' . ProperDate($_REQUEST['enrolled_end']) . '<BR>';
                        }
                    } elseif ($_REQUEST['enrolled_begin']) {
                        $extra['WHERE'] .= " AND ssm.START_DATE>='" . $_REQUEST['enrolled_begin'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Enrolled On or After: </b></font>' . ProperDate($_REQUEST['enrolled_begin']) . '<BR>';
                        }
                    }
                    if ($_REQUEST['enrolled_end']) {
                        $extra['WHERE'] .= " AND ssm.START_DATE<='" . $_REQUEST['enrolled_end'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Enrolled On or Before: </b></font>' . ProperDate($_REQUEST['enrolled_end']) . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Attendance Start</TD><TD><table cellpadding=0 cellspacing=0><tr><td>&ge;&nbsp;</td><td>' . PrepareDate('', '_enrolled_begin', true, array('short' => true)) . '</td></tr><tr><td>&le;&nbsp;</td><td>' . PrepareDate('', '_enrolled_end', true, array('short' => true)) . '</td></tr></table></TD></TR>';
                }
                break;
            case 'rolled':
                if ($CentreModules['Students']) {
                    if ($_REQUEST['rolled']) {
                        $extra['WHERE'] .= " AND " . ($_REQUEST['rolled'] == 'Y' ? '' : 'NOT ') . "exists (SELECT '' FROM STUDENT_ENROLLMENT WHERE STUDENT_ID=ssm.STUDENT_ID AND SYEAR<ssm.SYEAR)";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Previously Enrolled: </b></font>' . ($_REQUEST['rolled'] == 'Y' ? 'Yes' : 'No') . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Previously Enrolled</TD><TD><INPUT type=radio value="" name=rolled checked>N/A <INPUT type=radio value=Y name=rolled>Yes <INPUT type=radio value=N name=rolled>No</TD></TR>';
                }
                break;
            case 'fsa_balance_warning':
                $value = $GLOBALS['warning'];
                $item = 'fsa_balance';
            case 'fsa_balance':
                if ($CentreModules['Food_Service']) {
                    if ($_REQUEST['fsa_balance'] != '') {
                        if (!strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ',FOOD_SERVICE_STUDENT_ACCOUNTS fssa';
                            $extra['WHERE'] .= ' AND fssa.STUDENT_ID=s.STUDENT_ID';
                        }
                        $extra['FROM'] .= ",FOOD_SERVICE_ACCOUNTS fsa";
                        $extra['WHERE'] .= " AND fsa.ACCOUNT_ID=fssa.ACCOUNT_ID AND fsa.BALANCE" . ($_REQUEST['fsa_bal_ge'] == 'Y' ? '>=' : '<') . "'" . round($_REQUEST['fsa_balance'], 2) . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Food Service Balance: </b></font>' . ($_REQUEST['fsa_bal_ge'] == 'Y' ? '&ge;' : '&lt;') . number_format($_REQUEST['fsa_balance'], 2) . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Balance</TD><TD><table cellpadding=0 cellspacing=0><tr><td>&lt;<INPUT type=radio name=fsa_bal_ge value="" CHECKED></td><td rowspan=2><INPUT type=text name=fsa_balance size=10' . ($value ? ' value="' . $value . '"' : '') . '></td></tr><tr><td>&ge;<INPUT type=radio name=fsa_bal_ge value=Y></td></tr></table></TD></TR>';
                }
                break;
            case 'fsa_discount':
                if ($CentreModules['Food_Service']) {
                    if ($_REQUEST['fsa_discount']) {
                        if (!strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        if ($_REQUEST['fsa_discount'] == 'Full') {
                            $extra['WHERE'] .= " AND fssa.DISCOUNT IS NULL";
                        } else {
                            $extra['WHERE'] .= " AND fssa.DISCOUNT='" . $_REQUEST['fsa_discount'] . "'";
                        }
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Food Service Dscount: </b></font>' . $_REQUEST['fsa_discount'] . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Discount</TD><TD><SELECT name=fsa_discount><OPTION value="">Not Specified</OPTION><OPTION value="Full">Full</OPTION><OPTION value="Reduced">Reduced</OPTION><OPTION value="Free">Free</OPTION></SELECT></TD></TR>';
                }
                break;
            case 'fsa_status_active':
                $value = 'active';
                $item = 'fsa_status';
            case 'fsa_status':
                if ($CentreModules['Food_Service']) {
                    if ($_REQUEST['fsa_status']) {
                        if (!strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        if ($_REQUEST['fsa_status'] == 'Active') {
                            $extra['WHERE'] .= " AND fssa.STATUS IS NULL";
                        } else {
                            $extra['WHERE'] .= " AND fssa.STATUS='" . $_REQUEST['fsa_status'] . "'";
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Account Status</TD><TD><SELECT name=fsa_status><OPTION value="">Not Specified</OPTION><OPTION value="Active"' . ($value == 'active' ? ' SELECTED' : '') . '>Active</OPTION><OPTION value="Inactive">Inactive</OPTION><OPTION value="Disabled">Disabled</OPTION><OPTION value="Closed">Closed</OPTION></SELECT></TD></TR>';
                }
                break;
            case 'fsa_barcode':
                if ($CentreModules['Food_Service']) {
                    if ($_REQUEST['fsa_barcode']) {
                        if (!strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        $extra['WHERE'] .= " AND fssa.BARCODE='" . $_REQUEST['fsa_barcode'] . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Food Service Barcode: </b></font>' . $_REQUEST['fsa_barcode'] . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Barcode</TD><TD><INPUT type=text name=fsa_barcode size="15"></TD></TR>';
                }
                break;
            case 'fsa_account_id':
                if ($CentreModules['Food_Service']) {
                    if ($_REQUEST['fsa_account_id']) {
                        if (!strpos($extra['FROM'], 'fssa')) {
                            $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
                            $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
                        }
                        $extra['WHERE'] .= " AND fssa.ACCOUNT_ID='" . ($_REQUEST['fsa_account_id'] + 0) . "'";
                        if (!$extra['NoSearchTerms']) {
                            $_CENTRE['SearchTerms'] .= '<font color=gray><b>Food Service Account ID: </b></font>' . ($_REQUEST['fsa_account_id'] + 0) . '<BR>';
                        }
                    }
                    $extra['search'] .= '<TR><TD align=right width=120>Account ID</TD><TD><INPUT type=text name=fsa_account_id size="15"></TD></TR>';
                }
                break;
        }
        $_CENTRE['Widgets'][$item] = true;
    }
}
Beispiel #15
0
function calcSeats1(&$periods, $date)
{
    $date_time = strtotime($date);
    foreach ($periods as $key => $period) {
        if ($_REQUEST['include_child_mps']) {
            $mps = GetChildrenMP($period['MP'], $period['MARKING_PERIOD_ID']);
            if ($period['MP'] == 'FY' || $period['MP'] == 'SEM') {
                $mps = "'{$period['MARKING_PERIOD_ID']}'" . ($mps ? ',' . $mps : '');
            }
        } else {
            $mps = "'" . $period['MARKING_PERIOD_ID'] . "'";
        }
        $periods[$key]['AVAILABLE_SEATS'] = '';
        foreach (explode(',', $mps) as $mp) {
            $mp = trim($mp, "'");
            if (strtotime(GetMP($mp, 'END_DATE')) >= $date_time) {
                $link = "Modules.php?modname={$_REQUEST['modname']}&modfunc={$_REQUEST['modfunc']}&subject_id={$period['SUBJECT_ID']}&course_id={$period['COURSE_ID']}";
                $link .= "&last_year={$_REQUEST['last_year']}&year_date={$_REQUEST['year_date']}&month_date={$_REQUEST['month_date']}&day_date={$_REQUEST['day_date']}";
                $link .= "&course_period_id={$period['COURSE_PERIOD_ID']}&course_marking_period_id={$mp}";
                if ($period['AVAILABLE_SEATS']) {
                    $seats = DBGet(DBQuery("SELECT max((SELECT count(1) FROM SCHEDULE ss JOIN STUDENT_ENROLLMENT sem ON (sem.STUDENT_ID=ss.STUDENT_ID AND sem.SYEAR=ss.SYEAR) WHERE ss.COURSE_PERIOD_ID='{$period['COURSE_PERIOD_ID']}' AND (ss.MARKING_PERIOD_ID='{$mp}' OR ss.MARKING_PERIOD_ID IN (" . GetAllMP(GetMP($mp, 'MP'), $mp) . ")) AND (ac.SCHOOL_DATE>=ss.START_DATE AND (ss.END_DATE IS NULL OR ac.SCHOOL_DATE<=ss.END_DATE)) AND (ac.SCHOOL_DATE>=sem.START_DATE AND (sem.END_DATE IS NULL OR ac.SCHOOL_DATE<=sem.END_DATE)))) AS FILLED_SEATS FROM ATTENDANCE_CALENDAR ac WHERE ac.CALENDAR_ID='{$period['CALENDAR_ID']}' AND ac.SCHOOL_DATE BETWEEN '{$date}' AND '" . GetMP($mp, 'END_DATE') . "'"));
                    if ($seats[1]['FILLED_SEATS'] != '') {
                        if ($_REQUEST['include_child_mps']) {
                            $periods[$key]['AVAILABLE_SEATS'] .= '<A href=' . $link . '>' . (GetMP($mp, 'SHORT_NAME') ? GetMP($mp, 'SHORT_NAME') : GetMP($mp)) . '<small>(' . ($period['AVAILABLE_SEATS'] - $seats[1]['FILLED_SEATS']) . ')</small></A> | ';
                        } else {
                            $periods[$key]['AVAILABLE_SEATS'] = $period['AVAILABLE_SEATS'] - $seats[1]['FILLED_SEATS'];
                        }
                    }
                } else {
                    if ($_REQUEST['include_child_mps']) {
                        $periods[$key]['AVAILABLE_SEATS'] .= '<A href=' . $link . '>' . (GetMP($mp, 'SHORT_NAME') ? GetMP($mp, 'SHORT_NAME') : GetMP($mp)) . '</A> | ';
                    } else {
                        $periods[$key]['AVAILABLE_SEATS'] = 'n/a';
                    }
                }
            }
        }
        if ($_REQUEST['include_child_mps']) {
            $periods[$key]['AVAILABLE_SEATS'] = substr($periods[$key]['AVAILABLE_SEATS'], 0, -3);
        }
    }
}