////	$extra['functions']['TEACHER'] = '_makeTeacher';
 //	$extra['group']	= array('STUDENT_ID');
 //	//$extra['group']	= array('STUDENT_ID','COURSE_PERIOD_ID');
 //        $RET = GetStuList($extra);
 // print_r($RET);
 $RET = DBGet(DBQuery("SELECT DISTINCT s.STUDENT_ID, CONCAT(s.LAST_NAME,', ',coalesce(s.COMMON_NAME,s.FIRST_NAME)) AS FULL_NAME FROM students s,student_standards ss, report_card_grades rcg, course_periods cp\r\n        WHERE ss.GRADE_ID=rcg.ID AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND s.STUDENT_ID=ss.STUDENT_ID\r\n        AND s.STUDENT_ID IN ({$st_list})\r\n        "));
 if (count($RET)) {
     $grade_RET = DBGet(DBQuery("SELECT TITLE, COMMENT FROM report_card_grades WHERE SCHOOL_ID=" . UserSchool() . " AND SYEAR=" . UserSyear()));
     $handle = PDFStart();
     foreach ($RET as $student) {
         /*echo "SELECT DISTINCT cp.COURSE_PERIOD_ID AS CP_ID, cp.TITLE AS CP_TITLE, cp.MARKING_PERIOD_ID, CONCAT(st.TITLE, ' ', st.LAST_NAME, ' ',st.FIRST_NAME) AS TEACHER FROM STUDENTS s,STUDENT_STANDARDS ss, REPORT_CARD_GRADES rcg, COURSE_PERIODS cp, MARKING_PERIODS mp, STAFF st
           WHERE ss.GRADE_ID=rcg.ID AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND s.STUDENT_ID=ss.STUDENT_ID AND cp.MARKING_PERIOD_ID=mp.MARKING_PERIOD_ID AND cp.TEACHER_ID=st.STAFF_ID
           AND s.STUDENT_ID=$student[STUDENT_ID]";*/
         $periods = DBGet(DBQuery("SELECT DISTINCT cp.COURSE_PERIOD_ID AS CP_ID, cp.TITLE AS CP_TITLE, cp.MARKING_PERIOD_ID, CONCAT(st.TITLE, ' ', st.LAST_NAME, ' ',st.FIRST_NAME) AS TEACHER FROM students s,student_standards ss, report_card_grades rcg, course_periods cp, marking_periods mp, staff st\r\n                WHERE ss.GRADE_ID=rcg.ID AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND s.STUDENT_ID=ss.STUDENT_ID AND cp.MARKING_PERIOD_ID=mp.MARKING_PERIOD_ID AND cp.TEACHER_ID=st.STAFF_ID\r\n                AND s.STUDENT_ID={$student['STUDENT_ID']}"));
         echo "<table width=100%  style=\" font-family:Arial; font-size:12px;\" >";
         echo "<tr><td style=\"font-size:15px; font-weight:bold; padding-top:20px;\">" . GetSchool(UserSchool()) . "<div style=\"font-size:12px;\">Elementary Grades " . GetMp(UserMp()) . "</div><div style=\"font-size:12px;\">Student: " . $student[FULL_NAME] . " &nbsp;( " . $student[STUDENT_ID] . " )</div></td><td align=right style=\"padding-top:20px;\">" . ProperDate(DBDate()) . "<br />Powered by openSIS</td></tr><tr><td colspan=2 style=\"border-top:1px solid #333;\">&nbsp;</td></tr></table>";
         echo "<table >";
         echo '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0" class="course_period_tbl">';
         echo '<TR><TH align="left">Attendance</TH>';
         $mp_RET = DBGet(DBQuery("SELECT DISTINCT mp.TITLE, mp.MARKING_PERIOD_ID FROM marking_periods mp, course_periods cp, attendance_period ap\r\n                WHERE mp.MARKING_PERIOD_ID=cp.MARKING_PERIOD_ID\r\n                AND cp.SCHOOL_ID=" . UserSchool() . " AND cp.SYEAR=" . UserSyear() . "\r\n                AND cp.COURSE_PERIOD_ID=ap.COURSE_PERIOD_ID AND ap.STUDENT_ID={$student['STUDENT_ID']}"));
         $mp_name = DBGet(DBQuery("SELECT DISTINCT mp.SHORT_NAME,mp.MARKING_PERIOD_ID FROM marking_periods mp WHERE mp.SCHOOL_ID=" . UserSchool() . " AND mp.SYEAR=" . UserSyear() . ""));
         foreach ($mp_name as $mp1) {
             echo '<TH align="center" width="60px">' . $mp1[SHORT_NAME] . '</TH>';
         }
         echo '</TR>';
         $atteadance_code_RET = DBGet(DBQuery("SELECT ID, TITLE FROM attendance_codes WHERE SCHOOL_ID=" . UserSchool() . " AND SYEAR=" . UserSyear() . " ORDER BY SORT_ORDER, TITLE"));
         foreach ($atteadance_code_RET as $ac) {
             echo '<TR>';
             echo '<TD class="course_period">' . $ac[TITLE] . '</TD>';
             //echo '<TD class="course_period"></TD>';
             //echo '<TD class="course_period"></TD>';
Exemple #2
0
if ($_REQUEST['modfunc'] == 'course_periods' || $_REQUEST['students'] == 'course_periods') {
    echo '<TD valign=top>';
    $get_mp_t = DBGet(DBQuery('SELECT MP_TYPE FROM marking_periods WHERE MARKING_PERIOD_ID=' . UserMP()));
    $other_mps = array();
    if ($get_mp_t[1]['MP_TYPE'] != 'year') {
        if ($get_mp_t[1]['MP_TYPE'] == 'semester') {
            $get_mp_ids = DBGet(DBQuery('SELECT PARENT_ID FROM marking_periods WHERE MARKING_PERIOD_ID=' . UserMP()));
            $other_mps[] = $get_mp_ids[1]['PARENT_ID'];
        }
        if ($get_mp_t[1]['MP_TYPE'] == 'quarter') {
            $get_mp_ids = DBGet(DBQuery('SELECT PARENT_ID,GRANDPARENT_ID FROM marking_periods WHERE MARKING_PERIOD_ID=' . UserMP()));
            $other_mps[] = $get_mp_ids[1]['PARENT_ID'];
            $other_mps[] = $get_mp_ids[1]['GRANDPARENT_ID'];
        }
    }
    $QI = "SELECT cp.COURSE_ID,cp.COURSE_PERIOD_ID,cp.TITLE,sum(cp.TOTAL_SEATS) as TOTAL_SEATS,sum(cp.FILLED_SEATS) as FILLED_SEATS,NULL AS OPEN_SEATS FROM course_periods cp WHERE cp.COURSE_ID='" . $_REQUEST['course_id'] . "' AND cp.SYEAR='" . UserSyear() . "' AND cp.SCHOOL_ID='" . UserSchool() . "' AND " . (count($other_mps) > 0 ? " cp.MARKING_PERIOD_ID IN (" . UserMp() . "," . implode(',', $other_mps) . ") " : " cp.MARKING_PERIOD_ID=" . UserMp()) . "  GROUP BY cp.COURSE_ID,cp.COURSE_PERIOD_ID,cp.TITLE ORDER BY cp.TITLE";
    $QI = DBQuery($QI);
    $RET = DBGet($QI, array('OPEN_SEATS' => '_calcOpenSeats'));
    if (count($RET) && $_REQUEST['course_period_id']) {
        foreach ($RET as $key => $value) {
            if ($value['COURSE_PERIOD_ID'] == $_REQUEST['course_period_id']) {
                $RET[$key]['row_color'] = Preferences('HIGHLIGHT');
            }
        }
    }
    $link = array();
    $link['TITLE']['link'] = "Modules.php?modname={$_REQUEST['modname']}&modfunc=students&students=course_periods&subject_id={$_REQUEST['subject_id']}&course_id={$_REQUEST['course_id']}";
    $link['TITLE']['variables'] = array('course_period_id' => 'COURSE_PERIOD_ID');
    ListOutput($RET, array('TITLE' => 'Period - Teacher', 'OPEN_SEATS' => 'Open', 'TOTAL_SEATS' => 'Total'), 'Course Period', 'Course Periods', $link, array(), $LO_options);
    echo '</TD>';
}
function MyWidgets($item, $mp)
{
    global $extra, $THIS_RET;
    switch ($item) {
        case 'honor_roll':
            if ($_REQUEST['honor_roll'] != 986 && $_REQUEST['honor_roll']) {
                $honor = DBGet(DBQuery('SELECT VALUE  FROM honor_roll WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\' ORDER BY VALUE DESC'));
                $honor_gpa1 = $_REQUEST['honor_roll'];
                foreach ($honor as $gp_val) {
                    $gpa_value[] = $gp_val['VALUE'];
                }
                foreach ($gpa_value as $gpa_val_key => $gpa_val) {
                    if ($gpa_val == $honor_gpa1) {
                        $key = $gpa_val_key;
                    }
                }
                if ($key !== 0) {
                    if ($gpa_value[$key + 1] > $honor_gpa1) {
                        $honor_gpa2 = $gpa_value[$key + 1];
                    } else {
                        $honor_gpa2 = $gpa_value[$key - 1];
                    }
                }
                if ($honor_gpa2) {
                    $extra['FROM'] .= ',student_report_card_grades srg';
                    if ($_REQUEST['w_course_period_id']) {
                        $extra['SELECT'] .= ',( SELECT hr.TITLE FROM honor_roll hr WHERE  hr.VALUE=(SELECT if((ROUND(AVG(srcg.grade_percent))>=' . $honor_gpa1 . ' and ROUND(AVG(srcg.grade_percent))<' . $honor_gpa2 . '),' . $honor_gpa1 . ',"")  FROM
                                                   `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                   and srcg.STUDENT_ID=ssm.STUDENT_ID)  AND hr.SCHOOL_ID=' . UserSchool() . ' )AS HONOR_ROLL';
                        $extra['WHERE'] .= 'AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                   `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                   and srcg.STUDENT_ID=ssm.STUDENT_ID)>=' . $honor_gpa1 . ' ) AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                   `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                   and srcg.STUDENT_ID=ssm.STUDENT_ID)<' . $honor_gpa2 . ' )  ';
                    } else {
                        $extra['SELECT'] .= ',( SELECT hr.TITLE FROM honor_roll hr WHERE  hr.VALUE=(SELECT if((ROUND(AVG(srcg.grade_percent))>=' . $honor_gpa1 . ' and ROUND(AVG(srcg.grade_percent))<' . $honor_gpa2 . '),' . $honor_gpa1 . ',"")  FROM
                                                   `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                   and srcg.STUDENT_ID=ssm.STUDENT_ID)  AND hr.SCHOOL_ID=' . UserSchool() . '  )AS HONOR_ROLL';
                        $extra['WHERE'] .= 'AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                   `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                   and srcg.STUDENT_ID=ssm.STUDENT_ID)>=' . $honor_gpa1 . ' ) AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                   `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                   and srcg.STUDENT_ID=ssm.STUDENT_ID)<' . $honor_gpa2 . ' )  ';
                    }
                    $extra['GROUP'] .= ' s.STUDENT_ID';
                } else {
                    $honor_gpa2 = 100;
                    $extra['FROM'] .= ',student_report_card_grades srg';
                    if ($_REQUEST['w_course_period_id']) {
                        $extra['SELECT'] .= ',(SELECT hr.TITLE FROM honor_roll hr WHERE  hr.VALUE=(SELECT if((ROUND(AVG(srcg.grade_percent))>=' . $honor_gpa1 . ' and ROUND(AVG(srcg.grade_percent))<' . $honor_gpa2 . '),' . $honor_gpa1 . ',"") FROM
                                                `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID)  AND hr.SCHOOL_ID=' . UserSchool() . ' )AS HONOR_ROLL';
                        $extra['WHERE'] .= 'AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID)>=' . $honor_gpa1 . ' ) AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID)<' . $honor_gpa2 . ' )  ';
                    } else {
                        $extra['SELECT'] .= ',(SELECT hr.TITLE FROM honor_roll hr WHERE  hr.VALUE=(SELECT if((ROUND(AVG(srcg.grade_percent))>=' . $honor_gpa1 . ' and ROUND(AVG(srcg.grade_percent))<' . $honor_gpa2 . '),' . $honor_gpa1 . ',"") FROM
                                                `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID)  AND hr.SCHOOL_ID=' . UserSchool() . ' )AS HONOR_ROLL';
                        $extra['WHERE'] .= 'AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID)>=' . $honor_gpa1 . ' ) AND ((SELECT ROUND(AVG(srcg.grade_percent)) FROM
                                                `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID)<' . $honor_gpa2 . ' )  ';
                    }
                    $extra['GROUP'] .= ' s.STUDENT_ID';
                }
                $extra['columns_after'] = array('HONOR_ROLL' => 'Honor Roll');
            } elseif ($_REQUEST['honor_roll'] == 986) {
                if ($_REQUEST['w_course_period_id']) {
                    $extra['SELECT'] .= ',(SELECT hr.TITLE FROM honor_roll hr WHERE hr.VALUE=
                                                                (SELECT if(
                                                                            (ROUND(AVG(srcg.grade_percent))>=(SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE>=
                                                                             (SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll="Y" and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value desc limit 1)
                                                                and ROUND(AVG(srcg.grade_percent))<
                                                                (SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE
                                                                >(SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll="Y"
                                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value asc limit 1)),(SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE>(SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value asc limit 1),(SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE<=(SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.course_period_id=\'' . $_REQUEST['w_course_period_id'] . '\' and cpp.does_honor_roll=\'Y\'
                                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value desc limit 1))
                                                                FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll="Y" and srcg.`STUDENT_ID`=ssm.STUDENT_ID)  AND hr.SCHOOL_ID=' . UserSchool() . ' )AS HONOR_ROLL';
                } else {
                    $extra['SELECT'] .= ',(SELECT hr.TITLE FROM honor_roll hr WHERE hr.VALUE=
                                                                (SELECT if(
                                                                            (ROUND(AVG(srcg.grade_percent))>=(SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE>=
                                                                             (SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll="Y" and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value desc limit 1)
                                                                and ROUND(AVG(srcg.grade_percent))<
                                                                (SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE
                                                                >(SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll="Y"
                                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value asc limit 1)),(SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE>(SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value asc limit 1),(SELECT hr.VALUE FROM honor_roll hr WHERE hr.VALUE<=(SELECT ROUND(AVG(srcg.grade_percent)) FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll=\'Y\'
                                                                and srcg.`STUDENT_ID`=ssm.STUDENT_ID) order by hr.value desc limit 1))
                                                                FROM `student_report_card_grades` srcg,course_periods cpp WHERE srcg.MARKING_PERIOD_ID = ' . UserMp() . ' and srcg.course_period_id=cpp.course_period_id  and cpp.does_honor_roll="Y" and srcg.`STUDENT_ID`=ssm.STUDENT_ID)  AND hr.SCHOOL_ID=' . UserSchool() . ' )AS HONOR_ROLL';
                }
                $extra['columns_after'] = array('HONOR_ROLL' => 'Honor Roll');
            }
            $option = DBGet(DBQuery('SELECT TITLE,VALUE  FROM honor_roll WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\'  ORDER BY VALUE'));
            $options['986'] = 'All';
            foreach ($option as $option_value) {
                $options[$option_value['VALUE']] = $option_value['TITLE'];
            }
            $extra['search'] .= '<TR><TD align=right width=120>Honor Roll</TD><TD>' . SelectInput("", 'honor_roll', '', $options, false, '') . '</TD></TR>';
            break;
    }
}
if ($_REQUEST['modfunc'] == 'course_periods' || $_REQUEST['students'] == 'course_periods') {
    echo '<TD valign=top>';
    $get_mp_t = DBGet(DBQuery('SELECT MP_TYPE FROM marking_periods WHERE MARKING_PERIOD_ID=' . UserMP()));
    $other_mps = array();
    if ($get_mp_t[1]['MP_TYPE'] != 'year') {
        if ($get_mp_t[1]['MP_TYPE'] == 'semester') {
            $get_mp_ids = DBGet(DBQuery('SELECT PARENT_ID FROM marking_periods WHERE MARKING_PERIOD_ID=' . UserMP()));
            $other_mps[] = $get_mp_ids[1]['PARENT_ID'];
        }
        if ($get_mp_t[1]['MP_TYPE'] == 'quarter') {
            $get_mp_ids = DBGet(DBQuery('SELECT PARENT_ID,GRANDPARENT_ID FROM marking_periods WHERE MARKING_PERIOD_ID=' . UserMP()));
            $other_mps[] = $get_mp_ids[1]['PARENT_ID'];
            $other_mps[] = $get_mp_ids[1]['GRANDPARENT_ID'];
        }
    }
    $QI = "SELECT cp.COURSE_ID,cp.COURSE_PERIOD_ID,cp.TITLE,sum(cp.TOTAL_SEATS) as TOTAL_SEATS,sum(cp.FILLED_SEATS) as FILLED_SEATS,NULL AS OPEN_SEATS FROM course_periods cp WHERE cp.COURSE_ID='" . $_REQUEST['course_id'] . "' AND cp.SYEAR='" . UserSyear() . "' AND cp.SCHOOL_ID='" . UserSchool() . "' AND " . (count($other_mps) > 0 ? " (cp.MARKING_PERIOD_ID IN (" . UserMp() . "," . implode(',', $other_mps) . ") " : " (cp.MARKING_PERIOD_ID=" . UserMp()) . " OR cp.MARKING_PERIOD_ID IS NULL) AND ('" . date('Y-m-d', strtotime(DBDate())) . "' BETWEEN cp.BEGIN_DATE AND cp.END_DATE) GROUP BY cp.COURSE_ID,cp.COURSE_PERIOD_ID,cp.TITLE ORDER BY cp.TITLE";
    $QI = DBQuery($QI);
    $RET = DBGet($QI, array('OPEN_SEATS' => '_calcOpenSeats'));
    if (count($RET) && $_REQUEST['course_period_id']) {
        foreach ($RET as $key => $value) {
            if ($value['COURSE_PERIOD_ID'] == $_REQUEST['course_period_id']) {
                $RET[$key]['row_color'] = Preferences('HIGHLIGHT');
            }
        }
    }
    $link = array();
    $link['TITLE']['link'] = "Modules.php?modname={$_REQUEST['modname']}&modfunc=students&students=course_periods&subject_id={$_REQUEST['subject_id']}&course_id={$_REQUEST['course_id']}";
    $link['TITLE']['variables'] = array('course_period_id' => 'COURSE_PERIOD_ID');
    ListOutput($RET, array('TITLE' => 'Period - Teacher', 'OPEN_SEATS' => 'Open', 'TOTAL_SEATS' => 'Total'), 'Course Period', 'Course Periods', $link, array(), $LO_options);
    echo '</TD>';
}